lines =
+ Files.lines(Paths.get("/proc/" + pid + "/cmdline"))) {
+ return lines.findFirst().orElse(null);
+ } catch (IOException | UncheckedIOException e) {
+ return null;
+ }
+ }
+
+ private static boolean isModuleWhiteSpaceOption(String option) {
+ return option.equals("-p") ||
+ option.equals("--module-path") ||
+ option.equals("--upgrade-module-path") ||
+ option.equals("--add-modules") ||
+ option.equals("--limit-modules") ||
+ option.equals("--add-exports") ||
+ option.equals("--add-opens") ||
+ option.equals("--add-reads") ||
+ option.equals("--patch-module");
+ }
+}
diff -r e47423f1318b -r ca19b94eac7a src/jdk.jcmd/share/classes/sun/tools/common/ProcessArgumentMatcher.java
--- a/src/jdk.jcmd/share/classes/sun/tools/common/ProcessArgumentMatcher.java Mon Sep 23 09:16:05 2019 -0700
+++ b/src/jdk.jcmd/share/classes/sun/tools/common/ProcessArgumentMatcher.java Wed Sep 25 22:40:41 2019 +0200
@@ -79,15 +79,10 @@
private static boolean check(VirtualMachineDescriptor vmd, String excludeClass, String partialMatch) {
- String mainClass = null;
+ // Try to get the main class name using (platform specific) ProcessHelper
+ String mainClass = ProcessHelper.getMainClass(vmd.id());
- // Get the main class name using platform specific helper
- ProcessHelper helper = ProcessHelper.platformProcessHelper();
- if (helper != null) {
- mainClass = helper.getMainClass(vmd.id());
- }
-
- // If the main class name is still unset then retrieve it with the attach mechanism
+ // If the main class name could not be retrieved by ProcessHelper, get it with the attach mechanism
if (mainClass == null) {
try {
VmIdentifier vmId = new VmIdentifier(vmd.id());
diff -r e47423f1318b -r ca19b94eac7a src/jdk.jcmd/share/classes/sun/tools/common/ProcessHelper.java
--- a/src/jdk.jcmd/share/classes/sun/tools/common/ProcessHelper.java Mon Sep 23 09:16:05 2019 -0700
+++ b/src/jdk.jcmd/share/classes/sun/tools/common/ProcessHelper.java Wed Sep 25 22:40:41 2019 +0200
@@ -25,33 +25,12 @@
package sun.tools.common;
-import java.lang.reflect.Method;
-
/**
* A helper class to retrieve the main class name for a running
- * Java process.
+ * Java process. Default implementation returns null. Platform specific
+ * implementation currently available for Linux only.
*/
-
-public interface ProcessHelper {
-
- /**
- * Returns an instance of the ProcessHelper class.
- *
- * @return ProcessHelper object or null if not supported on this platform.
- */
- public static ProcessHelper platformProcessHelper() {
- try {
- Class> c = Class.forName("sun.tools.ProcessHelper");
- @SuppressWarnings("unchecked")
- Method m = c.getMethod("getInstance");
- return (ProcessHelper) m.invoke(null);
- } catch (ClassNotFoundException e) {
- return null;
- } catch (ReflectiveOperationException e) {
- throw new InternalError(e);
- }
- }
-
+final class ProcessHelper {
/**
* Returns the main class name for the given Java process
@@ -59,6 +38,7 @@
* @param pid - process ID (pid)
* @return main class name or null if the main class could not be retrieved
*/
-
- String getMainClass(String pid);
+ static String getMainClass(String pid) {
+ return null;
+ }
}
diff -r e47423f1318b -r ca19b94eac7a src/jdk.naming.dns/share/classes/com/sun/jndi/dns/DnsClient.java
--- a/src/jdk.naming.dns/share/classes/com/sun/jndi/dns/DnsClient.java Mon Sep 23 09:16:05 2019 -0700
+++ b/src/jdk.naming.dns/share/classes/com/sun/jndi/dns/DnsClient.java Wed Sep 25 22:40:41 2019 +0200
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -29,7 +29,9 @@
import java.net.DatagramSocket;
import java.net.DatagramPacket;
import java.net.InetAddress;
+import java.net.InetSocketAddress;
import java.net.Socket;
+import java.net.SocketTimeoutException;
import java.security.SecureRandom;
import javax.naming.*;
@@ -82,7 +84,7 @@
private static final SecureRandom random = JCAUtil.getSecureRandom();
private InetAddress[] servers;
private int[] serverPorts;
- private int timeout; // initial timeout on UDP queries in ms
+ private int timeout; // initial timeout on UDP and TCP queries in ms
private int retries; // number of UDP retries
private final Object udpSocketLock = new Object();
@@ -100,7 +102,7 @@
/*
* Each server is of the form "server[:port]". IPv6 literal host names
* include delimiting brackets.
- * "timeout" is the initial timeout interval (in ms) for UDP queries,
+ * "timeout" is the initial timeout interval (in ms) for queries,
* and "retries" gives the number of retries per server.
*/
public DnsClient(String[] servers, int timeout, int retries)
@@ -237,6 +239,7 @@
// Try each server, starting with the one that just
// provided the truncated message.
+ int retryTimeout = (timeout * (1 << retry));
for (int j = 0; j < servers.length; j++) {
int ij = (i + j) % servers.length;
if (doNotRetry[ij]) {
@@ -244,7 +247,7 @@
}
try {
Tcp tcp =
- new Tcp(servers[ij], serverPorts[ij]);
+ new Tcp(servers[ij], serverPorts[ij], retryTimeout);
byte[] msg2;
try {
msg2 = doTcpQuery(tcp, pkt);
@@ -327,7 +330,7 @@
// Try each name server.
for (int i = 0; i < servers.length; i++) {
try {
- Tcp tcp = new Tcp(servers[i], serverPorts[i]);
+ Tcp tcp = new Tcp(servers[i], serverPorts[i], timeout);
byte[] msg;
try {
msg = doTcpQuery(tcp, pkt);
@@ -462,11 +465,11 @@
*/
private byte[] continueTcpQuery(Tcp tcp) throws IOException {
- int lenHi = tcp.in.read(); // high-order byte of response length
+ int lenHi = tcp.read(); // high-order byte of response length
if (lenHi == -1) {
return null; // EOF
}
- int lenLo = tcp.in.read(); // low-order byte of response length
+ int lenLo = tcp.read(); // low-order byte of response length
if (lenLo == -1) {
throw new IOException("Corrupted DNS response: bad length");
}
@@ -474,7 +477,7 @@
byte[] msg = new byte[len];
int pos = 0; // next unfilled position in msg
while (len > 0) {
- int n = tcp.in.read(msg, pos, len);
+ int n = tcp.read(msg, pos, len);
if (n == -1) {
throw new IOException(
"Corrupted DNS response: too little data");
@@ -682,20 +685,62 @@
class Tcp {
- private Socket sock;
- java.io.InputStream in;
- java.io.OutputStream out;
+ private final Socket sock;
+ private final java.io.InputStream in;
+ final java.io.OutputStream out;
+ private int timeoutLeft;
- Tcp(InetAddress server, int port) throws IOException {
- sock = new Socket(server, port);
- sock.setTcpNoDelay(true);
- out = new java.io.BufferedOutputStream(sock.getOutputStream());
- in = new java.io.BufferedInputStream(sock.getInputStream());
+ Tcp(InetAddress server, int port, int timeout) throws IOException {
+ sock = new Socket();
+ try {
+ long start = System.currentTimeMillis();
+ sock.connect(new InetSocketAddress(server, port), timeout);
+ timeoutLeft = (int) (timeout - (System.currentTimeMillis() - start));
+ if (timeoutLeft <= 0)
+ throw new SocketTimeoutException();
+
+ sock.setTcpNoDelay(true);
+ out = new java.io.BufferedOutputStream(sock.getOutputStream());
+ in = new java.io.BufferedInputStream(sock.getInputStream());
+ } catch (Exception e) {
+ try {
+ sock.close();
+ } catch (IOException ex) {
+ e.addSuppressed(ex);
+ }
+ throw e;
+ }
}
void close() throws IOException {
sock.close();
}
+
+ private interface SocketReadOp {
+ int read() throws IOException;
+ }
+
+ private int readWithTimeout(SocketReadOp reader) throws IOException {
+ if (timeoutLeft <= 0)
+ throw new SocketTimeoutException();
+
+ sock.setSoTimeout(timeoutLeft);
+ long start = System.currentTimeMillis();
+ try {
+ return reader.read();
+ }
+ finally {
+ timeoutLeft -= System.currentTimeMillis() - start;
+ }
+ }
+
+ int read() throws IOException {
+ return readWithTimeout(() -> in.read());
+ }
+
+ int read(byte b[], int off, int len) throws IOException {
+ return readWithTimeout(() -> in.read(b, off, len));
+ }
}
/*
diff -r e47423f1318b -r ca19b94eac7a src/jdk.naming.dns/share/classes/module-info.java
--- a/src/jdk.naming.dns/share/classes/module-info.java Mon Sep 23 09:16:05 2019 -0700
+++ b/src/jdk.naming.dns/share/classes/module-info.java Wed Sep 25 22:40:41 2019 +0200
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2019, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -26,7 +26,38 @@
/**
* Provides the implementation of the DNS Java Naming provider.
*
+ * Environment Properties
+ *
+ * The following JNDI environment properties may be used when creating
+ * the initial context.
+ *
+ *
+ * - com.sun.jndi.dns.timeout.initial
+ * - com.sun.jndi.dns.timeout.retries
+ *
+ *
+ * These properties are used to alter the timeout-related defaults that the
+ * DNS provider uses when submitting queries. The DNS provider submits queries
+ * using the following exponential backoff algorithm. The provider submits a
+ * query to a DNS server and waits for a response to arrive within a timeout
+ * period (1 second by default). If it receives no response within the timeout
+ * period, it queries the next server, and so on. If the provider receives no
+ * response from any server, it doubles the timeout period and repeats the
+ * process of submitting the query to each server, up to a maximum number of
+ * retries (4 by default).
+ *
+ *
The {@code com.sun.jndi.dns.timeout.initial} property, if set, specifies
+ * the number of milliseconds to use as the initial timeout period (i.e., before
+ * any doubling). If this property has not been set, the default initial timeout
+ * is 1000 milliseconds.
+ *
+ *
The {@code com.sun.jndi.dns.timeout.retries} property, if set, specifies
+ * the number of times to retry each server using the exponential backoff
+ * algorithm described previously. If this property has not been set, the
+ * default number of retries is 4.
+ *
* @provides javax.naming.spi.InitialContextFactory
+ *
* @moduleGraph
* @since 9
*/
diff -r e47423f1318b -r ca19b94eac7a src/jdk.security.auth/share/classes/com/sun/security/auth/module/NTSystem.java
--- a/src/jdk.security.auth/share/classes/com/sun/security/auth/module/NTSystem.java Mon Sep 23 09:16:05 2019 -0700
+++ b/src/jdk.security.auth/share/classes/com/sun/security/auth/module/NTSystem.java Wed Sep 25 22:40:41 2019 +0200
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -35,12 +35,14 @@
private native void getCurrent(boolean debug);
private native long getImpersonationToken0();
+ // Warning: the next 6 fields are used by nt.c
private String userName;
private String domain;
private String domainSID;
private String userSID;
private String[] groupIDs;
private String primaryGroupID;
+
private long impersonationToken;
/**
diff -r e47423f1318b -r ca19b94eac7a src/jdk.security.auth/share/classes/com/sun/security/auth/module/UnixSystem.java
--- a/src/jdk.security.auth/share/classes/com/sun/security/auth/module/UnixSystem.java Mon Sep 23 09:16:05 2019 -0700
+++ b/src/jdk.security.auth/share/classes/com/sun/security/auth/module/UnixSystem.java Wed Sep 25 22:40:41 2019 +0200
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -33,6 +33,7 @@
private native void getUnixInfo();
+ // Warning: the following 4 fields are used by Unix.c
protected String username;
protected long uid;
protected long gid;
diff -r e47423f1318b -r ca19b94eac7a test/hotspot/jtreg/ProblemList-graal.txt
--- a/test/hotspot/jtreg/ProblemList-graal.txt Mon Sep 23 09:16:05 2019 -0700
+++ b/test/hotspot/jtreg/ProblemList-graal.txt Wed Sep 25 22:40:41 2019 +0200
@@ -43,8 +43,6 @@
compiler/unsafe/UnsafeGetConstantField.java 8181833 generic-all
compiler/unsafe/UnsafeGetStableArrayElement.java 8181833 generic-all
-compiler/unsafe/UnsafeOffHeapBooleanTest.java 8181833 generic-all
-compiler/unsafe/UnsafeOnHeapBooleanTest.java 8181833 generic-all
compiler/whitebox/ClearMethodStateTest.java 8181831 generic-all
compiler/whitebox/EnqueueMethodForCompilationTest.java 8181831 generic-all
diff -r e47423f1318b -r ca19b94eac7a test/hotspot/jtreg/compiler/escapeAnalysis/TestSelfArrayCopy.java
--- a/test/hotspot/jtreg/compiler/escapeAnalysis/TestSelfArrayCopy.java Mon Sep 23 09:16:05 2019 -0700
+++ b/test/hotspot/jtreg/compiler/escapeAnalysis/TestSelfArrayCopy.java Wed Sep 25 22:40:41 2019 +0200
@@ -23,7 +23,7 @@
/*
* @test
- * @bug 8229016
+ * @bug 8229016 8231055
* @summary Test correct elimination of array allocation with arraycopy to itself.
* @library /test/lib
* @run main/othervm -Xbatch -XX:CompileCommand=compileonly,compiler.escapeAnalysis.TestSelfArrayCopy::test
@@ -39,7 +39,7 @@
private static final int rI1 = Utils.getRandomInstance().nextInt();
private static final int rI2 = Utils.getRandomInstance().nextInt();
- private static int test() {
+ private static int test1() {
// Non-escaping allocation
Integer[] array = {rI1, rI2};
// Arraycopy with src == dst
@@ -51,14 +51,40 @@
return array[0] + array[1];
}
+ private static int test2() {
+ // Non-escaping allocation
+ Integer[] array = {rI1, rI2};
+ // Arraycopy with src == dst
+ System.arraycopy(array, 0, array, 1, 1);
+ if (b) {
+ // Uncommon trap
+ System.out.println(array[0]);
+ }
+ return array[0] + array[1];
+ }
+
public static void main(String[] args) {
- int expected = rI1 + rI2;
+ int expected1 = rI1 + rI2;
+ int expected2 = rI1 + rI1;
// Trigger compilation
for (int i = 0; i < 20_000; ++i) {
- int result = test();
- if (result != expected) {
- throw new RuntimeException("Incorrect result: " + result + " != " + expected);
+ int result = test1();
+ if (result != expected1) {
+ throw new RuntimeException("Incorrect result: " + result + " != " + expected1);
+ }
+ result = test2();
+ if (result != expected2) {
+ throw new RuntimeException("Incorrect result: " + result + " != " + expected2);
}
}
+ b = true;
+ int result = test1();
+ if (result != expected1) {
+ throw new RuntimeException("Incorrect result: " + result + " != " + expected1);
+ }
+ result = test2();
+ if (result != expected2) {
+ throw new RuntimeException("Incorrect result: " + result + " != " + expected2);
+ }
}
}
diff -r e47423f1318b -r ca19b94eac7a test/hotspot/jtreg/compiler/linkage/TestLinkageErrorInGenerateOopMap.java
--- a/test/hotspot/jtreg/compiler/linkage/TestLinkageErrorInGenerateOopMap.java Mon Sep 23 09:16:05 2019 -0700
+++ b/test/hotspot/jtreg/compiler/linkage/TestLinkageErrorInGenerateOopMap.java Wed Sep 25 22:40:41 2019 +0200
@@ -47,6 +47,8 @@
"-XX:-BytecodeVerificationLocal",
"-XX:-TieredCompilation",
"-XX:CompileCommand=dontinline,compiler/linkage/OSRWithBadOperandStack.m*",
+ "-XX:-CreateCoredumpOnCrash",
+ "-Xmx64m",
"compiler.linkage.TestLinkageErrorInGenerateOopMap", "run"};
ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(flags);
OutputAnalyzer out = new OutputAnalyzer(pb.start());
diff -r e47423f1318b -r ca19b94eac7a test/hotspot/jtreg/compiler/loopstripmining/AntiDependentLoadInOuterStripMinedLoop.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/compiler/loopstripmining/AntiDependentLoadInOuterStripMinedLoop.java Wed Sep 25 22:40:41 2019 +0200
@@ -0,0 +1,92 @@
+/*
+ * Copyright (c) 2019, Red Hat, Inc. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/**
+ * @test
+ * @bug 8229483
+ * @summary Sinking load out of loop may trigger: assert(found_sfpt) failed: no node in loop that's not input to safepoint
+ *
+ * @run main/othervm -XX:-TieredCompilation -XX:-BackgroundCompilation -XX:-UseOnStackReplacement -XX:LoopMaxUnroll=0 AntiDependentLoadInOuterStripMinedLoop
+ *
+ */
+
+public class AntiDependentLoadInOuterStripMinedLoop {
+ private static int field;
+ private static volatile int barrier;
+
+ public static void main(String[] args) {
+ int[] array = new int[1];
+ A a = new A();
+ for (int i = 0; i < 20_000; i++) {
+ test1(array);
+ test2(a, array);
+ test2_helper(array, 0, 0);
+ }
+ }
+
+ private static int test1(int[] array) {
+ int res = 1;
+
+ for (int i = 0; i < 10; i++) {
+ barrier = 1;
+ // field load doesn't float higher than here
+
+ for (int j = 0; j < 2000; j++) {
+ array[0] = j; // seen as anti dependence by C2 during loop opts, sunk out of loop
+ res *= j;
+ }
+ }
+
+ return field + res + field * 2;
+ }
+
+ private static int test2(A a, int[] array) {
+ int ignore = a.field;
+ int res = 1;
+
+ int k = 0;
+ for (k = 0; k < 2; k++) {
+ }
+
+ for (int i = 0; i < 10; i++) {
+ barrier = 1;
+
+ for (int j = 0; j < 2000; j++) {
+ test2_helper(array, k, j);
+ res *= j;
+ }
+ }
+
+ return a.field + res + a.field * 2;
+ }
+
+ private static void test2_helper(int[] array, int k, int j) {
+ if (k == 2) {
+ array[0] = j;
+ }
+ }
+
+ private static class A {
+ public int field;
+ }
+}
diff -r e47423f1318b -r ca19b94eac7a test/hotspot/jtreg/compiler/loopstripmining/DeadNodesInOuterLoopAtLoopCloning.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/compiler/loopstripmining/DeadNodesInOuterLoopAtLoopCloning.java Wed Sep 25 22:40:41 2019 +0200
@@ -0,0 +1,84 @@
+/*
+ * Copyright (c) 2019, Red Hat, Inc. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/**
+ * @test
+ * @bug 8230061
+ * @summary loop unrolling breaks when outer strip mined loop contains dead node
+ *
+ * @run main/othervm -Xmx1G DeadNodesInOuterLoopAtLoopCloning
+ *
+ */
+
+public class DeadNodesInOuterLoopAtLoopCloning {
+
+ public static final int N = 400;
+
+ public static long instanceCount=-2288355609708559532L;
+
+ public static double checkSum(double[] a) {
+ double sum = 0;
+ for (int j = 0; j < a.length; j++) {
+ sum += (a[j] / (j + 1) + a[j] % (j + 1));
+ }
+ return sum;
+ }
+
+ public static int iMeth(double d1) {
+
+ int i4=6022, i5=-211, i6=-15841, iArr[]=new int[N];
+ double d2=-8.78129, dArr[]=new double[N];
+
+ i5 = 1;
+ do {
+ i6 = 1;
+ while (++i6 < 5) {
+ i4 = -933;
+ i4 *= i4;
+ dArr[i5 + 1] = i4;
+ i4 -= i4;
+ d2 = 1;
+ do {
+ iArr[(int)(d2 + 1)] += (int)instanceCount;
+ try {
+ i4 = (i4 % -51430);
+ i4 = (iArr[i6] % 31311);
+ iArr[i6 + 1] = (24197 / i5);
+ } catch (ArithmeticException a_e) {}
+ i4 -= (int)instanceCount;
+ i4 <<= i5;
+ i4 &= 12;
+ } while (++d2 < 1);
+ }
+ } while (++i5 < 320);
+ long meth_res = Double.doubleToLongBits(checkSum(dArr));
+ return (int)meth_res;
+ }
+
+ public static void main(String[] strArr) {
+ DeadNodesInOuterLoopAtLoopCloning _instance = new DeadNodesInOuterLoopAtLoopCloning();
+ for (int i = 0; i < 10 * 320; i++ ) {
+ _instance.iMeth(0.8522);
+ }
+ }
+}
diff -r e47423f1318b -r ca19b94eac7a test/hotspot/jtreg/gc/g1/TestGCLogMessages.java
--- a/test/hotspot/jtreg/gc/g1/TestGCLogMessages.java Mon Sep 23 09:16:05 2019 -0700
+++ b/test/hotspot/jtreg/gc/g1/TestGCLogMessages.java Wed Sep 25 22:40:41 2019 +0200
@@ -128,8 +128,7 @@
new LogMessageWithLevel("CLDG Roots", Level.TRACE),
new LogMessageWithLevel("JVMTI Roots", Level.TRACE),
new LogMessageWithLevel("CM RefProcessor Roots", Level.TRACE),
- new LogMessageWithLevel("Wait For Strong CLD", Level.TRACE),
- new LogMessageWithLevel("Weak CLD Roots", Level.TRACE),
+ new LogMessageWithLevel("Wait For Strong Roots", Level.TRACE),
// Redirty Cards
new LogMessageWithLevel("Redirty Cards", Level.DEBUG),
new LogMessageWithLevel("Parallel Redirty", Level.TRACE),
diff -r e47423f1318b -r ca19b94eac7a test/hotspot/jtreg/gc/shenandoah/compiler/TestClone.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/gc/shenandoah/compiler/TestClone.java Wed Sep 25 22:40:41 2019 +0200
@@ -0,0 +1,239 @@
+/*
+ * Copyright (c) 2019, Red Hat, Inc. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test TestClone
+ * @summary Test clone barriers work correctly
+ * @key gc
+ * @requires vm.gc.Shenandoah & !vm.graal.enabled
+ *
+ * @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -Xms1g -Xmx1g
+ * -XX:+UseShenandoahGC
+ * TestClone
+ * @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -Xms1g -Xmx1g
+ * -XX:+UseShenandoahGC
+ * -Xint
+ * TestClone
+ * @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -Xms1g -Xmx1g
+ * -XX:+UseShenandoahGC
+ * -XX:-TieredCompilation
+ * TestClone
+ * @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -Xms1g -Xmx1g
+ * -XX:+UseShenandoahGC
+ * -XX:TieredStopAtLevel=1
+ * TestClone
+ * @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -Xms1g -Xmx1g
+ * -XX:+UseShenandoahGC
+ * -XX:TieredStopAtLevel=4
+ * TestClone
+ */
+
+/*
+ * @test TestClone
+ * @summary Test clone barriers work correctly
+ * @key gc
+ * @requires vm.gc.Shenandoah & !vm.graal.enabled
+ *
+ * @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -Xms1g -Xmx1g
+ * -XX:+UseShenandoahGC
+ * -XX:+ShenandoahVerify
+ * TestClone
+ * @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -Xms1g -Xmx1g
+ * -XX:+UseShenandoahGC
+ * -XX:+ShenandoahVerify
+ * -Xint
+ * TestClone
+ * @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -Xms1g -Xmx1g
+ * -XX:+UseShenandoahGC
+ * -XX:+ShenandoahVerify
+ * -XX:-TieredCompilation
+ * TestClone
+ * @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -Xms1g -Xmx1g
+ * -XX:+UseShenandoahGC
+ * -XX:+ShenandoahVerify
+ * -XX:TieredStopAtLevel=1
+ * TestClone
+ * @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -Xms1g -Xmx1g
+ * -XX:+UseShenandoahGC
+ * -XX:+ShenandoahVerify
+ * -XX:TieredStopAtLevel=4
+ * TestClone
+ */
+
+/*
+ * @test TestClone
+ * @summary Test clone barriers work correctly
+ * @key gc
+ * @requires vm.gc.Shenandoah & !vm.graal.enabled
+ *
+ * @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -Xms1g -Xmx1g
+ * -XX:+UseShenandoahGC -XX:ShenandoahGCHeuristics=aggressive
+ * TestClone
+ * @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -Xms1g -Xmx1g
+ * -XX:+UseShenandoahGC -XX:ShenandoahGCHeuristics=aggressive
+ * -Xint
+ * TestClone
+ * @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -Xms1g -Xmx1g
+ * -XX:+UseShenandoahGC -XX:ShenandoahGCHeuristics=aggressive
+ * -XX:-TieredCompilation
+ * TestClone
+ * @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -Xms1g -Xmx1g
+ * -XX:+UseShenandoahGC -XX:ShenandoahGCHeuristics=aggressive
+ * -XX:TieredStopAtLevel=1
+ * TestClone
+ * @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -Xms1g -Xmx1g
+ * -XX:+UseShenandoahGC -XX:ShenandoahGCHeuristics=aggressive
+ * -XX:TieredStopAtLevel=4
+ * TestClone
+ */
+
+/*
+ * @test TestClone
+ * @summary Test clone barriers work correctly
+ * @key gc
+ * @requires vm.gc.Shenandoah & !vm.graal.enabled & (vm.bits == "64")
+ *
+ * @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -Xms1g -Xmx1g
+ * -XX:-UseCompressedOops
+ * -XX:+UseShenandoahGC
+ * TestClone
+ * @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -Xms1g -Xmx1g
+ * -XX:-UseCompressedOops
+ * -XX:+UseShenandoahGC
+ * -Xint
+ * TestClone
+ * @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -Xms1g -Xmx1g
+ * -XX:-UseCompressedOops
+ * -XX:+UseShenandoahGC
+ * -XX:-TieredCompilation
+ * TestClone
+ * @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -Xms1g -Xmx1g
+ * -XX:-UseCompressedOops
+ * -XX:+UseShenandoahGC
+ * -XX:TieredStopAtLevel=1
+ * TestClone
+ * @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -Xms1g -Xmx1g
+ * -XX:-UseCompressedOops
+ * -XX:+UseShenandoahGC
+ * -XX:TieredStopAtLevel=4
+ * TestClone
+ */
+
+/*
+ * @test TestClone
+ * @summary Test clone barriers work correctly
+ * @key gc
+ * @requires vm.gc.Shenandoah & !vm.graal.enabled & (vm.bits == "64")
+ *
+ * @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -Xms1g -Xmx1g
+ * -XX:-UseCompressedOops
+ * -XX:+UseShenandoahGC
+ * -XX:+ShenandoahVerify
+ * TestClone
+ * @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -Xms1g -Xmx1g
+ * -XX:-UseCompressedOops
+ * -XX:+UseShenandoahGC
+ * -XX:+ShenandoahVerify
+ * -Xint
+ * TestClone
+ * @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -Xms1g -Xmx1g
+ * -XX:-UseCompressedOops
+ * -XX:+UseShenandoahGC
+ * -XX:+ShenandoahVerify
+ * -XX:-TieredCompilation
+ * TestClone
+ * @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -Xms1g -Xmx1g
+ * -XX:-UseCompressedOops
+ * -XX:+UseShenandoahGC
+ * -XX:+ShenandoahVerify
+ * -XX:TieredStopAtLevel=1
+ * TestClone
+ * @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -Xms1g -Xmx1g
+ * -XX:-UseCompressedOops
+ * -XX:+UseShenandoahGC
+ * -XX:+ShenandoahVerify
+ * -XX:TieredStopAtLevel=4
+ * TestClone
+ */
+
+/*
+ * @test TestClone
+ * @summary Test clone barriers work correctly
+ * @key gc
+ * @requires vm.gc.Shenandoah & !vm.graal.enabled & (vm.bits == "64")
+ *
+ * @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -Xms1g -Xmx1g
+ * -XX:-UseCompressedOops
+ * -XX:+UseShenandoahGC -XX:ShenandoahGCHeuristics=aggressive
+ * TestClone
+ * @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -Xms1g -Xmx1g
+ * -XX:-UseCompressedOops
+ * -XX:+UseShenandoahGC -XX:ShenandoahGCHeuristics=aggressive
+ * -Xint
+ * TestClone
+ * @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -Xms1g -Xmx1g
+ * -XX:-UseCompressedOops
+ * -XX:+UseShenandoahGC -XX:ShenandoahGCHeuristics=aggressive
+ * -XX:-TieredCompilation
+ * TestClone
+ * @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -Xms1g -Xmx1g
+ * -XX:-UseCompressedOops
+ * -XX:+UseShenandoahGC -XX:ShenandoahGCHeuristics=aggressive
+ * -XX:TieredStopAtLevel=1
+ * TestClone
+ * @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -Xms1g -Xmx1g
+ * -XX:-UseCompressedOops
+ * -XX:+UseShenandoahGC -XX:ShenandoahGCHeuristics=aggressive
+ * -XX:TieredStopAtLevel=4
+ * TestClone
+ */
+
+
+public class TestClone {
+
+ public static void main(String[] args) throws Exception {
+ for (int i = 0; i < 10000; i++) {
+ Object[] src = new Object[i];
+ for (int c = 0; c < src.length; c++) {
+ src[c] = new Object();
+ }
+ testWith(src);
+ }
+ }
+
+ static void testWith(Object[] src) {
+ Object[] dst = src.clone();
+ int srcLen = src.length;
+ int dstLen = dst.length;
+ if (srcLen != dstLen) {
+ throw new IllegalStateException("Lengths do not match: " + srcLen + " vs " + dstLen);
+ }
+ for (int c = 0; c < src.length; c++) {
+ Object s = src[c];
+ Object d = dst[c];
+ if (s != d) {
+ throw new IllegalStateException("Elements do not match at " + c + ": " + s + " vs " + d);
+ }
+ }
+ }
+}
diff -r e47423f1318b -r ca19b94eac7a test/hotspot/jtreg/runtime/CheckUnhandledOops/TestVerifyOops.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/runtime/CheckUnhandledOops/TestVerifyOops.java Wed Sep 25 22:40:41 2019 +0200
@@ -0,0 +1,36 @@
+/*
+ * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 8231058
+ * @requires vm.debug & (os.arch != "sparc") & (os.arch != "sparcv9")
+ * @run main/othervm -XX:+VerifyOops TestVerifyOops
+ */
+
+public class TestVerifyOops {
+
+ public static void main(String[] args) {
+ System.out.println("Test passed");
+ }
+}
diff -r e47423f1318b -r ca19b94eac7a test/hotspot/jtreg/runtime/InvocationTests/invocationC1Tests.java
--- a/test/hotspot/jtreg/runtime/InvocationTests/invocationC1Tests.java Mon Sep 23 09:16:05 2019 -0700
+++ b/test/hotspot/jtreg/runtime/InvocationTests/invocationC1Tests.java Wed Sep 25 22:40:41 2019 +0200
@@ -49,8 +49,9 @@
System.out.println("\nC1 invocation tests, Tests: " + whichTests +
", class file version: " + classFileVersion);
ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(false, "-Xmx128M",
- "-Xcomp", "-XX:TieredStopAtLevel=1", whichTests,
- "--classfile_version=" + classFileVersion);
+ "-Xcomp", "-XX:TieredStopAtLevel=1",
+ "--add-exports", "java.base/jdk.internal.org.objectweb.asm=ALL-UNNAMED",
+ whichTests, "--classfile_version=" + classFileVersion);
OutputAnalyzer output = new OutputAnalyzer(pb.start());
try {
output.shouldContain("EXECUTION STATUS: PASSED");
diff -r e47423f1318b -r ca19b94eac7a test/hotspot/jtreg/runtime/InvocationTests/invocationGraalTests.java
--- a/test/hotspot/jtreg/runtime/InvocationTests/invocationGraalTests.java Mon Sep 23 09:16:05 2019 -0700
+++ b/test/hotspot/jtreg/runtime/InvocationTests/invocationGraalTests.java Wed Sep 25 22:40:41 2019 +0200
@@ -51,6 +51,7 @@
", class file version: " + classFileVersion);
ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(false, "-Xmx128M",
"-XX:+UnlockExperimentalVMOptions", "-XX:+EnableJVMCI", "-XX:+UseJVMCICompiler",
+ "--add-exports", "java.base/jdk.internal.org.objectweb.asm=ALL-UNNAMED",
whichTests, "--classfile_version=" + classFileVersion);
OutputAnalyzer output = new OutputAnalyzer(pb.start());
try {
diff -r e47423f1318b -r ca19b94eac7a test/hotspot/jtreg/runtime/InvocationTests/invokeinterfaceTests.java
--- a/test/hotspot/jtreg/runtime/InvocationTests/invokeinterfaceTests.java Mon Sep 23 09:16:05 2019 -0700
+++ b/test/hotspot/jtreg/runtime/InvocationTests/invokeinterfaceTests.java Wed Sep 25 22:40:41 2019 +0200
@@ -48,6 +48,7 @@
System.out.println("\ninvokeinterface invocation tests, option: " + option +
", class file version: " + classFileVersion);
ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(false, "-Xmx128M", option,
+ "--add-exports", "java.base/jdk.internal.org.objectweb.asm=ALL-UNNAMED",
"invokeinterface.Generator", "--classfile_version=" + classFileVersion);
OutputAnalyzer output = new OutputAnalyzer(pb.start());
try {
diff -r e47423f1318b -r ca19b94eac7a test/hotspot/jtreg/runtime/InvocationTests/invokespecialTests.java
--- a/test/hotspot/jtreg/runtime/InvocationTests/invokespecialTests.java Mon Sep 23 09:16:05 2019 -0700
+++ b/test/hotspot/jtreg/runtime/InvocationTests/invokespecialTests.java Wed Sep 25 22:40:41 2019 +0200
@@ -47,6 +47,7 @@
System.out.println("\ninvokespecial invocation tests, option: " + option +
", class file version: " + classFileVersion);
ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(false, "-Xmx128M", option,
+ "--add-exports", "java.base/jdk.internal.org.objectweb.asm=ALL-UNNAMED",
"invokespecial.Generator", "--classfile_version=" + classFileVersion);
OutputAnalyzer output = new OutputAnalyzer(pb.start());
try {
diff -r e47423f1318b -r ca19b94eac7a test/hotspot/jtreg/runtime/InvocationTests/invokevirtualTests.java
--- a/test/hotspot/jtreg/runtime/InvocationTests/invokevirtualTests.java Mon Sep 23 09:16:05 2019 -0700
+++ b/test/hotspot/jtreg/runtime/InvocationTests/invokevirtualTests.java Wed Sep 25 22:40:41 2019 +0200
@@ -47,6 +47,7 @@
System.out.println("\ninvokevirtual invocation tests, option: " + option +
", class file version: " + classFileVersion);
ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(false, "-Xmx128M", option,
+ "--add-exports", "java.base/jdk.internal.org.objectweb.asm=ALL-UNNAMED",
"invokevirtual.Generator", "--classfile_version=" + classFileVersion);
OutputAnalyzer output = new OutputAnalyzer(pb.start());
try {
diff -r e47423f1318b -r ca19b94eac7a test/hotspot/jtreg/runtime/Unsafe/InternalErrorTest.java
--- a/test/hotspot/jtreg/runtime/Unsafe/InternalErrorTest.java Mon Sep 23 09:16:05 2019 -0700
+++ b/test/hotspot/jtreg/runtime/Unsafe/InternalErrorTest.java Wed Sep 25 22:40:41 2019 +0200
@@ -28,6 +28,7 @@
* @summary Check that SIGBUS errors caused by memory accesses in Unsafe_CopyMemory()
* and UnsafeCopySwapMemory() get converted to java.lang.InternalError exceptions.
* @modules java.base/jdk.internal.misc
+ * java.base/java.nio:+open
*
* @library /test/lib
* @build sun.hotspot.WhiteBox
diff -r e47423f1318b -r ca19b94eac7a test/hotspot/jtreg/runtime/cds/appcds/ParallelLoadTest.java
--- a/test/hotspot/jtreg/runtime/cds/appcds/ParallelLoadTest.java Mon Sep 23 09:16:05 2019 -0700
+++ b/test/hotspot/jtreg/runtime/cds/appcds/ParallelLoadTest.java Wed Sep 25 22:40:41 2019 +0200
@@ -33,29 +33,52 @@
* @run driver ParallelLoadTest
*/
+import java.io.File;
+
public class ParallelLoadTest {
public static final int MAX_CLASSES = 40;
+ /* For easy stress testing, do this:
+
+ i=0; while jtreg -DParallelLoadTest.app.loops=100 -DParallelLoadTest.boot.loops=100 \
+ ParallelLoadTest.java; do i=$(expr $i + 1); echo =====$i; done
+
+ */
+
+ private static final int APP_LOOPS = Integer.parseInt(System.getProperty("ParallelLoadTest.app.loops", "1"));
+ private static final int BOOT_LOOPS = Integer.parseInt(System.getProperty("ParallelLoadTest.boot.loops", "1"));
+
public static void main(String[] args) throws Exception {
- JarBuilder.build("parallel_load", getClassList(true));
- String appJar = TestCommon.getTestJar("parallel_load.jar");
- TestCommon.test(appJar, getClassList(false), "ParallelLoad");
+ JarBuilder.build("parallel_load_app", "ParallelLoad", "ParallelLoadThread", "ParallelLoadWatchdog");
+ JarBuilder.build("parallel_load_classes", getClassList());
+ String appJar = TestCommon.getTestJar("parallel_load_app.jar");
+ String classesJar = TestCommon.getTestJar("parallel_load_classes.jar");
+
+ // (1) Load the classes from app class loader
+ String CP = appJar + File.pathSeparator + classesJar;
+ TestCommon.testDump(CP, getClassList());
+ for (int i = 0; i < APP_LOOPS; i++) {
+ TestCommon.run("-cp", CP, "ParallelLoad").assertNormalExit();
+ }
+
+ // (2) Load the classes from boot class loader
+ String bootcp = "-Xbootclasspath/a:" + classesJar;
+ TestCommon.testDump(appJar, getClassList(), bootcp);
+ for (int i = 0; i < BOOT_LOOPS; i++) {
+ TestCommon.run(bootcp, "-cp", appJar,
+ // "-Xlog:class+load=debug",
+ "ParallelLoad").assertNormalExit();
+ }
}
- private static String[] getClassList(boolean includeWatchdog) {
- int extra = includeWatchdog ? 3 : 2;
- String[] classList = new String[MAX_CLASSES + extra];
+ private static String[] getClassList() {
+ String[] classList = new String[MAX_CLASSES];
int i;
- for (i=0; i 0) {
- throw new RuntimeException("test.dynamic.dump not supported empty classpath with non-empty classlist");
+ throw new RuntimeException("test.dynamic.dump is not supported with an empty classpath while the classlist is not empty");
}
cmd.add("-version");
}
@@ -242,7 +242,12 @@
if (opts.appJarDir != null) {
pb.directory(new File(opts.appJarDir));
}
- return executeAndLog(pb, "dump");
+
+ OutputAnalyzer output = executeAndLog(pb, "dump");
+ if (DYNAMIC_DUMP && isUnableToMap(output)) {
+ throw new SkippedException(UnableToMapMsg);
+ }
+ return output;
}
// This allows you to run the AppCDS tests with JFR enabled at runtime (though not at
@@ -462,9 +467,6 @@
String... suffix) throws Exception {
OutputAnalyzer output = dump(appJar, classList, suffix);
if (DYNAMIC_DUMP) {
- if (isUnableToMap(output)) {
- throw new SkippedException(UnableToMapMsg);
- }
output.shouldContain("Written dynamic archive");
} else {
output.shouldContain("Loading classes to share");
@@ -477,9 +479,6 @@
String... suffix) throws Exception {
OutputAnalyzer output = dump(appJarDir, appJar, classList, suffix);
if (DYNAMIC_DUMP) {
- if (isUnableToMap(output)) {
- throw new SkippedException(UnableToMapMsg);
- }
output.shouldContain("Written dynamic archive");
} else {
output.shouldContain("Loading classes to share");
diff -r e47423f1318b -r ca19b94eac7a test/hotspot/jtreg/runtime/cds/appcds/test-classes/ParallelLoad.java
--- a/test/hotspot/jtreg/runtime/cds/appcds/test-classes/ParallelLoad.java Mon Sep 23 09:16:05 2019 -0700
+++ b/test/hotspot/jtreg/runtime/cds/appcds/test-classes/ParallelLoad.java Wed Sep 25 22:40:41 2019 +0200
@@ -25,6 +25,7 @@
import java.io.*;
import java.net.*;
import java.lang.reflect.Field;
+import java.util.concurrent.atomic.AtomicInteger;
// This test helper is parameterized by:
@@ -78,7 +79,7 @@
if ("FINGERPRINT_MODE".equals(args[1])) {
mode = FINGERPRINT_MODE;
classLoaders = new ClassLoader[NUM_THREADS];
- for (int i=0; i timeout + TOLERANCE) {
+ throw new RuntimeException(String.format(
+ "elapsed=%s, timeout=%s, TOLERANCE=%s, PREMATURE_RETURN=%s",
+ elapsed, timeout, TOLERANCE, PREMATURE_RETURN));
+ }
+
+ DNSTestUtils.debug(attrs);
+
+ /* Note that the returned attributes are truncated and the response
+ is not valid. */
+ var txtAttr = attrs.get("TXT");
+ if (txtAttr == null)
+ throw new RuntimeException("TXT attribute missing.");
+ }
+
+ @Override
+ public void initTest(String[] args) {
+ /* We need to bind the TCP server on the same port the UDP server is
+ listening to. This may not be possible if that port is in use. Retry
+ MAX_RETRIES times relying on UDP port randomness. */
+ final int MAX_RETRIES = 5;
+ for (int i = 0; i < MAX_RETRIES; i++) {
+ super.initTest(args);
+ var udpServer = (Server) env().get(DNSTestUtils.TEST_DNS_SERVER_THREAD);
+ int port = udpServer.getPort();
+ try {
+ tcpDnsServer = new TcpDnsServer(port);
+ break; // success
+ } catch (BindException be) {
+ DNSTestUtils.debug("Failed to bind server socket on port " + port
+ + ", retry no. " + (i + 1) + ", " + be.getMessage());
+ } catch (Exception ex) {
+ throw new RuntimeException("Unexpected exception during initTest", ex);
+ } finally {
+ if (tcpDnsServer == null) { // cleanup behind exceptions
+ super.cleanupTest();
+ }
+ }
+ }
+
+ if (tcpDnsServer == null) {
+ throw new SkippedException("Cannot start TCP server after "
+ + MAX_RETRIES
+ + " tries, skip the test");
+ }
+ }
+
+ @Override
+ public void cleanupTest() {
+ super.cleanupTest();
+ if (tcpDnsServer != null)
+ tcpDnsServer.stopServer();
+ }
+
+ /**
+ * A TCP server that accepts a connection and does nothing else: causes read
+ * timeout on client side.
+ */
+ private static class TcpDnsServer {
+ final ServerSocket serverSocket;
+
+ TcpDnsServer(int port) throws IOException {
+ serverSocket = new ServerSocket(port, 0, InetAddress.getLoopbackAddress());
+ System.out.println("TcpDnsServer: listening on port " + port);
+ }
+
+ void stopServer() {
+ try {
+ if (serverSocket != null)
+ serverSocket.close();
+ } catch (Exception ignored) { }
+ }
+ }
+}
diff -r e47423f1318b -r ca19b94eac7a test/jdk/java/net/httpclient/websocket/Abort.java
--- a/test/jdk/java/net/httpclient/websocket/Abort.java Mon Sep 23 09:16:05 2019 -0700
+++ b/test/jdk/java/net/httpclient/websocket/Abort.java Wed Sep 25 22:40:41 2019 +0200
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2018, 2019, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -29,7 +29,6 @@
* Abort
*/
-import org.testng.annotations.AfterTest;
import org.testng.annotations.Test;
import java.io.IOException;
@@ -56,38 +55,35 @@
private static final Class IAE = IllegalArgumentException.class;
private static final Class IOE = IOException.class;
- private DummyWebSocketServer server;
- private WebSocket webSocket;
-
- @AfterTest
- public void cleanup() {
- server.close();
- webSocket.abort();
- }
@Test
public void onOpenThenAbort() throws Exception {
int[] bytes = new int[]{
0x88, 0x00, // opcode=close
};
- server = Support.serverWithCannedData(bytes);
- server.open();
- // messages are available
- MockListener listener = new MockListener() {
- @Override
- protected void onOpen0(WebSocket webSocket) {
- // unbounded request
- webSocket.request(Long.MAX_VALUE);
+ try (var server = Support.serverWithCannedData(bytes)) {
+ server.open();
+ // messages are available
+ MockListener listener = new MockListener() {
+ @Override
+ protected void onOpen0(WebSocket webSocket) {
+ // unbounded request
+ webSocket.request(Long.MAX_VALUE);
+ webSocket.abort();
+ }
+ };
+ var webSocket = newHttpClient().newWebSocketBuilder()
+ .buildAsync(server.getURI(), listener)
+ .join();
+ try {
+ TimeUnit.SECONDS.sleep(5);
+ List inv = listener.invocationsSoFar();
+ // no more invocations after onOpen as WebSocket was aborted
+ assertEquals(inv, List.of(MockListener.Invocation.onOpen(webSocket)));
+ } finally {
webSocket.abort();
}
- };
- webSocket = newHttpClient().newWebSocketBuilder()
- .buildAsync(server.getURI(), listener)
- .join();
- TimeUnit.SECONDS.sleep(5);
- List inv = listener.invocationsSoFar();
- // no more invocations after onOpen as WebSocket was aborted
- assertEquals(inv, List.of(MockListener.Invocation.onOpen(webSocket)));
+ }
}
@Test
@@ -96,33 +92,38 @@
0x81, 0x00, // opcode=text, fin=true
0x88, 0x00, // opcode=close
};
- server = Support.serverWithCannedData(bytes);
- server.open();
- MockListener listener = new MockListener() {
- @Override
- protected void onOpen0(WebSocket webSocket) {
- // unbounded request
- webSocket.request(Long.MAX_VALUE);
- }
+ try (var server = Support.serverWithCannedData(bytes)) {
+ server.open();
+ MockListener listener = new MockListener() {
+ @Override
+ protected void onOpen0(WebSocket webSocket) {
+ // unbounded request
+ webSocket.request(Long.MAX_VALUE);
+ }
- @Override
- protected CompletionStage> onText0(WebSocket webSocket,
- CharSequence message,
- boolean last) {
+ @Override
+ protected CompletionStage> onText0(WebSocket webSocket,
+ CharSequence message,
+ boolean last) {
+ webSocket.abort();
+ return super.onText0(webSocket, message, last);
+ }
+ };
+ var webSocket = newHttpClient().newWebSocketBuilder()
+ .buildAsync(server.getURI(), listener)
+ .join();
+ try {
+ TimeUnit.SECONDS.sleep(5);
+ List inv = listener.invocationsSoFar();
+ // no more invocations after onOpen, onBinary as WebSocket was aborted
+ List expected = List.of(
+ MockListener.Invocation.onOpen(webSocket),
+ MockListener.Invocation.onText(webSocket, "", true));
+ assertEquals(inv, expected);
+ } finally {
webSocket.abort();
- return super.onText0(webSocket, message, last);
}
- };
- webSocket = newHttpClient().newWebSocketBuilder()
- .buildAsync(server.getURI(), listener)
- .join();
- TimeUnit.SECONDS.sleep(5);
- List inv = listener.invocationsSoFar();
- // no more invocations after onOpen, onBinary as WebSocket was aborted
- List expected = List.of(
- MockListener.Invocation.onOpen(webSocket),
- MockListener.Invocation.onText(webSocket, "", true));
- assertEquals(inv, expected);
+ }
}
@Test
@@ -131,33 +132,38 @@
0x82, 0x00, // opcode=binary, fin=true
0x88, 0x00, // opcode=close
};
- server = Support.serverWithCannedData(bytes);
- server.open();
- MockListener listener = new MockListener() {
- @Override
- protected void onOpen0(WebSocket webSocket) {
- // unbounded request
- webSocket.request(Long.MAX_VALUE);
- }
+ try (var server = Support.serverWithCannedData(bytes)) {
+ server.open();
+ MockListener listener = new MockListener() {
+ @Override
+ protected void onOpen0(WebSocket webSocket) {
+ // unbounded request
+ webSocket.request(Long.MAX_VALUE);
+ }
- @Override
- protected CompletionStage> onBinary0(WebSocket webSocket,
- ByteBuffer message,
- boolean last) {
+ @Override
+ protected CompletionStage> onBinary0(WebSocket webSocket,
+ ByteBuffer message,
+ boolean last) {
+ webSocket.abort();
+ return super.onBinary0(webSocket, message, last);
+ }
+ };
+ var webSocket = newHttpClient().newWebSocketBuilder()
+ .buildAsync(server.getURI(), listener)
+ .join();
+ try {
+ TimeUnit.SECONDS.sleep(5);
+ List inv = listener.invocationsSoFar();
+ // no more invocations after onOpen, onBinary as WebSocket was aborted
+ List expected = List.of(
+ MockListener.Invocation.onOpen(webSocket),
+ MockListener.Invocation.onBinary(webSocket, ByteBuffer.allocate(0), true));
+ assertEquals(inv, expected);
+ } finally {
webSocket.abort();
- return super.onBinary0(webSocket, message, last);
}
- };
- webSocket = newHttpClient().newWebSocketBuilder()
- .buildAsync(server.getURI(), listener)
- .join();
- TimeUnit.SECONDS.sleep(5);
- List inv = listener.invocationsSoFar();
- // no more invocations after onOpen, onBinary as WebSocket was aborted
- List expected = List.of(
- MockListener.Invocation.onOpen(webSocket),
- MockListener.Invocation.onBinary(webSocket, ByteBuffer.allocate(0), true));
- assertEquals(inv, expected);
+ }
}
@Test
@@ -166,32 +172,37 @@
0x89, 0x00, // opcode=ping
0x88, 0x00, // opcode=close
};
- server = Support.serverWithCannedData(bytes);
- server.open();
- MockListener listener = new MockListener() {
- @Override
- protected void onOpen0(WebSocket webSocket) {
- // unbounded request
- webSocket.request(Long.MAX_VALUE);
- }
+ try (var server = Support.serverWithCannedData(bytes)) {
+ server.open();
+ MockListener listener = new MockListener() {
+ @Override
+ protected void onOpen0(WebSocket webSocket) {
+ // unbounded request
+ webSocket.request(Long.MAX_VALUE);
+ }
- @Override
- protected CompletionStage> onPing0(WebSocket webSocket,
- ByteBuffer message) {
+ @Override
+ protected CompletionStage> onPing0(WebSocket webSocket,
+ ByteBuffer message) {
+ webSocket.abort();
+ return super.onPing0(webSocket, message);
+ }
+ };
+ var webSocket = newHttpClient().newWebSocketBuilder()
+ .buildAsync(server.getURI(), listener)
+ .join();
+ try {
+ TimeUnit.SECONDS.sleep(5);
+ List inv = listener.invocationsSoFar();
+ // no more invocations after onOpen, onPing as WebSocket was aborted
+ List expected = List.of(
+ MockListener.Invocation.onOpen(webSocket),
+ MockListener.Invocation.onPing(webSocket, ByteBuffer.allocate(0)));
+ assertEquals(inv, expected);
+ } finally {
webSocket.abort();
- return super.onPing0(webSocket, message);
}
- };
- webSocket = newHttpClient().newWebSocketBuilder()
- .buildAsync(server.getURI(), listener)
- .join();
- TimeUnit.SECONDS.sleep(5);
- List inv = listener.invocationsSoFar();
- // no more invocations after onOpen, onPing as WebSocket was aborted
- List expected = List.of(
- MockListener.Invocation.onOpen(webSocket),
- MockListener.Invocation.onPing(webSocket, ByteBuffer.allocate(0)));
- assertEquals(inv, expected);
+ }
}
@Test
@@ -200,32 +211,37 @@
0x8a, 0x00, // opcode=pong
0x88, 0x00, // opcode=close
};
- server = Support.serverWithCannedData(bytes);
- server.open();
- MockListener listener = new MockListener() {
- @Override
- protected void onOpen0(WebSocket webSocket) {
- // unbounded request
- webSocket.request(Long.MAX_VALUE);
- }
+ try (var server = Support.serverWithCannedData(bytes)) {
+ server.open();
+ MockListener listener = new MockListener() {
+ @Override
+ protected void onOpen0(WebSocket webSocket) {
+ // unbounded request
+ webSocket.request(Long.MAX_VALUE);
+ }
- @Override
- protected CompletionStage> onPong0(WebSocket webSocket,
- ByteBuffer message) {
+ @Override
+ protected CompletionStage> onPong0(WebSocket webSocket,
+ ByteBuffer message) {
+ webSocket.abort();
+ return super.onPong0(webSocket, message);
+ }
+ };
+ var webSocket = newHttpClient().newWebSocketBuilder()
+ .buildAsync(server.getURI(), listener)
+ .join();
+ try {
+ TimeUnit.SECONDS.sleep(5);
+ List inv = listener.invocationsSoFar();
+ // no more invocations after onOpen, onPong as WebSocket was aborted
+ List expected = List.of(
+ MockListener.Invocation.onOpen(webSocket),
+ MockListener.Invocation.onPong(webSocket, ByteBuffer.allocate(0)));
+ assertEquals(inv, expected);
+ } finally {
webSocket.abort();
- return super.onPong0(webSocket, message);
}
- };
- webSocket = newHttpClient().newWebSocketBuilder()
- .buildAsync(server.getURI(), listener)
- .join();
- TimeUnit.SECONDS.sleep(5);
- List inv = listener.invocationsSoFar();
- // no more invocations after onOpen, onPong as WebSocket was aborted
- List expected = List.of(
- MockListener.Invocation.onOpen(webSocket),
- MockListener.Invocation.onPong(webSocket, ByteBuffer.allocate(0)));
- assertEquals(inv, expected);
+ }
}
@Test
@@ -234,33 +250,38 @@
0x88, 0x00, // opcode=close
0x8a, 0x00, // opcode=pong
};
- server = Support.serverWithCannedData(bytes);
- server.open();
- MockListener listener = new MockListener() {
- @Override
- protected void onOpen0(WebSocket webSocket) {
- // unbounded request
- webSocket.request(Long.MAX_VALUE);
- }
+ try (var server = Support.serverWithCannedData(bytes)) {
+ server.open();
+ MockListener listener = new MockListener() {
+ @Override
+ protected void onOpen0(WebSocket webSocket) {
+ // unbounded request
+ webSocket.request(Long.MAX_VALUE);
+ }
- @Override
- protected CompletionStage> onClose0(WebSocket webSocket,
- int statusCode,
- String reason) {
+ @Override
+ protected CompletionStage> onClose0(WebSocket webSocket,
+ int statusCode,
+ String reason) {
+ webSocket.abort();
+ return super.onClose0(webSocket, statusCode, reason);
+ }
+ };
+ var webSocket = newHttpClient().newWebSocketBuilder()
+ .buildAsync(server.getURI(), listener)
+ .join();
+ try {
+ TimeUnit.SECONDS.sleep(5);
+ List inv = listener.invocationsSoFar();
+ // no more invocations after onOpen, onClose
+ List expected = List.of(
+ MockListener.Invocation.onOpen(webSocket),
+ MockListener.Invocation.onClose(webSocket, 1005, ""));
+ assertEquals(inv, expected);
+ } finally {
webSocket.abort();
- return super.onClose0(webSocket, statusCode, reason);
}
- };
- webSocket = newHttpClient().newWebSocketBuilder()
- .buildAsync(server.getURI(), listener)
- .join();
- TimeUnit.SECONDS.sleep(5);
- List inv = listener.invocationsSoFar();
- // no more invocations after onOpen, onClose
- List expected = List.of(
- MockListener.Invocation.onOpen(webSocket),
- MockListener.Invocation.onClose(webSocket, 1005, ""));
- assertEquals(inv, expected);
+ }
}
@Test
@@ -271,32 +292,37 @@
int[] bytes = new int[badPingHeader.length + 128 + closeMessage.length];
System.arraycopy(badPingHeader, 0, bytes, 0, badPingHeader.length);
System.arraycopy(closeMessage, 0, bytes, badPingHeader.length + 128, closeMessage.length);
- server = Support.serverWithCannedData(bytes);
- server.open();
- MockListener listener = new MockListener() {
- @Override
- protected void onOpen0(WebSocket webSocket) {
- // unbounded request
- webSocket.request(Long.MAX_VALUE);
- }
+ try (var server = Support.serverWithCannedData(bytes)) {
+ server.open();
+ MockListener listener = new MockListener() {
+ @Override
+ protected void onOpen0(WebSocket webSocket) {
+ // unbounded request
+ webSocket.request(Long.MAX_VALUE);
+ }
- @Override
- protected void onError0(WebSocket webSocket, Throwable error) {
+ @Override
+ protected void onError0(WebSocket webSocket, Throwable error) {
+ webSocket.abort();
+ super.onError0(webSocket, error);
+ }
+ };
+ var webSocket = newHttpClient().newWebSocketBuilder()
+ .buildAsync(server.getURI(), listener)
+ .join();
+ try {
+ TimeUnit.SECONDS.sleep(5);
+ List inv = listener.invocationsSoFar();
+ // no more invocations after onOpen, onError
+ List expected = List.of(
+ MockListener.Invocation.onOpen(webSocket),
+ MockListener.Invocation.onError(webSocket, ProtocolException.class));
+ System.out.println("actual invocations:" + Arrays.toString(inv.toArray()));
+ assertEquals(inv, expected);
+ } finally {
webSocket.abort();
- super.onError0(webSocket, error);
}
- };
- webSocket = newHttpClient().newWebSocketBuilder()
- .buildAsync(server.getURI(), listener)
- .join();
- TimeUnit.SECONDS.sleep(5);
- List inv = listener.invocationsSoFar();
- // no more invocations after onOpen, onError
- List expected = List.of(
- MockListener.Invocation.onOpen(webSocket),
- MockListener.Invocation.onError(webSocket, ProtocolException.class));
- System.out.println("actual invocations:" + Arrays.toString(inv.toArray()));
- assertEquals(inv, expected);
+ }
}
@Test
@@ -352,65 +378,70 @@
0x82, 0x00, // opcode=binary, fin=true
0x88, 0x00, // opcode=close
};
- server = Support.serverWithCannedData(bytes);
- server.open();
+ try (var server = Support.serverWithCannedData(bytes)) {
+ server.open();
- WebSocket ws = newHttpClient()
- .newWebSocketBuilder()
- .buildAsync(server.getURI(), listener)
- .join();
- for (int i = 0; i < 3; i++) {
- System.out.printf("iteration #%s%n", i);
- // after the first abort() each consecutive one must be a no-op,
- // moreover, query methods should continue to return consistent
- // values
- for (int j = 0; j < 3; j++) {
- System.out.printf("abort #%s%n", j);
+ WebSocket ws = newHttpClient()
+ .newWebSocketBuilder()
+ .buildAsync(server.getURI(), listener)
+ .join();
+ try {
+ for (int i = 0; i < 3; i++) {
+ System.out.printf("iteration #%s%n", i);
+ // after the first abort() each consecutive one must be a no-op,
+ // moreover, query methods should continue to return consistent
+ // values
+ for (int j = 0; j < 3; j++) {
+ System.out.printf("abort #%s%n", j);
+ ws.abort();
+ assertTrue(ws.isInputClosed());
+ assertTrue(ws.isOutputClosed());
+ assertEquals(ws.getSubprotocol(), "");
+ }
+ // at this point valid requests MUST be a no-op:
+ for (int j = 0; j < 3; j++) {
+ System.out.printf("request #%s%n", j);
+ ws.request(1);
+ ws.request(2);
+ ws.request(8);
+ ws.request(Integer.MAX_VALUE);
+ ws.request(Long.MAX_VALUE);
+ // invalid requests MUST throw IAE:
+ assertThrows(IAE, () -> ws.request(Integer.MIN_VALUE));
+ assertThrows(IAE, () -> ws.request(Long.MIN_VALUE));
+ assertThrows(IAE, () -> ws.request(-1));
+ assertThrows(IAE, () -> ws.request(0));
+ }
+ }
+ // even though there is a bunch of messages readily available on the
+ // wire we shouldn't have received any of them as we aborted before
+ // the first request
+ try {
+ messageReceived.get(5, TimeUnit.SECONDS);
+ fail();
+ } catch (TimeoutException expected) {
+ System.out.println("Finished waiting");
+ }
+ for (int i = 0; i < 3; i++) {
+ System.out.printf("send #%s%n", i);
+ Support.assertFails(IOE, ws.sendText("text!", false));
+ Support.assertFails(IOE, ws.sendText("text!", true));
+ Support.assertFails(IOE, ws.sendBinary(ByteBuffer.allocate(16), false));
+ Support.assertFails(IOE, ws.sendBinary(ByteBuffer.allocate(16), true));
+ Support.assertFails(IOE, ws.sendPing(ByteBuffer.allocate(16)));
+ Support.assertFails(IOE, ws.sendPong(ByteBuffer.allocate(16)));
+ Support.assertFails(IOE, ws.sendClose(NORMAL_CLOSURE, "a reason"));
+ assertThrows(NPE, () -> ws.sendText(null, false));
+ assertThrows(NPE, () -> ws.sendText(null, true));
+ assertThrows(NPE, () -> ws.sendBinary(null, false));
+ assertThrows(NPE, () -> ws.sendBinary(null, true));
+ assertThrows(NPE, () -> ws.sendPing(null));
+ assertThrows(NPE, () -> ws.sendPong(null));
+ assertThrows(NPE, () -> ws.sendClose(NORMAL_CLOSURE, null));
+ }
+ } finally {
ws.abort();
- assertTrue(ws.isInputClosed());
- assertTrue(ws.isOutputClosed());
- assertEquals(ws.getSubprotocol(), "");
}
- // at this point valid requests MUST be a no-op:
- for (int j = 0; j < 3; j++) {
- System.out.printf("request #%s%n", j);
- ws.request(1);
- ws.request(2);
- ws.request(8);
- ws.request(Integer.MAX_VALUE);
- ws.request(Long.MAX_VALUE);
- // invalid requests MUST throw IAE:
- assertThrows(IAE, () -> ws.request(Integer.MIN_VALUE));
- assertThrows(IAE, () -> ws.request(Long.MIN_VALUE));
- assertThrows(IAE, () -> ws.request(-1));
- assertThrows(IAE, () -> ws.request(0));
- }
- }
- // even though there is a bunch of messages readily available on the
- // wire we shouldn't have received any of them as we aborted before
- // the first request
- try {
- messageReceived.get(5, TimeUnit.SECONDS);
- fail();
- } catch (TimeoutException expected) {
- System.out.println("Finished waiting");
- }
- for (int i = 0; i < 3; i++) {
- System.out.printf("send #%s%n", i);
- Support.assertFails(IOE, ws.sendText("text!", false));
- Support.assertFails(IOE, ws.sendText("text!", true));
- Support.assertFails(IOE, ws.sendBinary(ByteBuffer.allocate(16), false));
- Support.assertFails(IOE, ws.sendBinary(ByteBuffer.allocate(16), true));
- Support.assertFails(IOE, ws.sendPing(ByteBuffer.allocate(16)));
- Support.assertFails(IOE, ws.sendPong(ByteBuffer.allocate(16)));
- Support.assertFails(IOE, ws.sendClose(NORMAL_CLOSURE, "a reason"));
- assertThrows(NPE, () -> ws.sendText(null, false));
- assertThrows(NPE, () -> ws.sendText(null, true));
- assertThrows(NPE, () -> ws.sendBinary(null, false));
- assertThrows(NPE, () -> ws.sendBinary(null, true));
- assertThrows(NPE, () -> ws.sendPing(null));
- assertThrows(NPE, () -> ws.sendPong(null));
- assertThrows(NPE, () -> ws.sendClose(NORMAL_CLOSURE, null));
}
}
}
diff -r e47423f1318b -r ca19b94eac7a test/jdk/java/net/httpclient/websocket/AutomaticPong.java
--- a/test/jdk/java/net/httpclient/websocket/AutomaticPong.java Mon Sep 23 09:16:05 2019 -0700
+++ b/test/jdk/java/net/httpclient/websocket/AutomaticPong.java Wed Sep 25 22:40:41 2019 +0200
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2018, 2019, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -28,8 +28,6 @@
* -Djdk.internal.httpclient.websocket.debug=true
* AutomaticPong
*/
-
-import org.testng.annotations.AfterTest;
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;
@@ -46,16 +44,6 @@
import static org.testng.Assert.fail;
public class AutomaticPong {
-
- private DummyWebSocketServer server;
- private WebSocket webSocket;
-
- @AfterTest
- public void cleanup() {
- server.close();
- webSocket.abort();
- }
-
/*
* The sendClose method has been invoked and a Ping comes from the server.
* Naturally, the client cannot reply with a Pong (the output has been
@@ -72,32 +60,36 @@
0x89, 0x06, 0x68, 0x65, 0x6c, 0x6c, 0x6f, 0x3f, // ping hello?
0x88, 0x00, // close
};
- server = Support.serverWithCannedData(bytes);
- server.open();
- MockListener listener = new MockListener() {
- @Override
- protected void onOpen0(WebSocket webSocket) {
- /* request nothing */
+ try (var server = Support.serverWithCannedData(bytes)) {
+ server.open();
+ MockListener listener = new MockListener() {
+ @Override
+ protected void onOpen0(WebSocket webSocket) {
+ /* request nothing */
+ }
+ };
+ var webSocket = newHttpClient()
+ .newWebSocketBuilder()
+ .buildAsync(server.getURI(), listener)
+ .join();
+ try {
+ webSocket.sendClose(WebSocket.NORMAL_CLOSURE, "ok").join();
+ // now request all messages available
+ webSocket.request(Long.MAX_VALUE);
+ List actual = listener.invocations();
+ ByteBuffer hello = ByteBuffer.wrap("hello?".getBytes(StandardCharsets.UTF_8));
+ ByteBuffer empty = ByteBuffer.allocate(0);
+ List expected = List.of(
+ MockListener.Invocation.onOpen(webSocket),
+ MockListener.Invocation.onPing(webSocket, empty),
+ MockListener.Invocation.onPing(webSocket, hello),
+ MockListener.Invocation.onClose(webSocket, 1005, "")
+ );
+ assertEquals(actual, expected);
+ } finally {
+ webSocket.abort();
}
- };
- webSocket = newHttpClient()
- .newWebSocketBuilder()
- .buildAsync(server.getURI(), listener)
- .join();
-
- webSocket.sendClose(WebSocket.NORMAL_CLOSURE, "ok").join();
- // now request all messages available
- webSocket.request(Long.MAX_VALUE);
- List actual = listener.invocations();
- ByteBuffer hello = ByteBuffer.wrap("hello?".getBytes(StandardCharsets.UTF_8));
- ByteBuffer empty = ByteBuffer.allocate(0);
- List expected = List.of(
- MockListener.Invocation.onOpen(webSocket),
- MockListener.Invocation.onPing(webSocket, empty),
- MockListener.Invocation.onPing(webSocket, hello),
- MockListener.Invocation.onClose(webSocket, 1005, "")
- );
- assertEquals(actual, expected);
+ }
}
/*
@@ -131,84 +123,100 @@
.write(buffer);
buffer.putChar((char) 1000);
buffer.flip();
- server = Support.serverWithCannedData(buffer.array());
- server.open();
- MockListener listener = new MockListener();
- webSocket = newHttpClient()
- .newWebSocketBuilder()
- .buildAsync(server.getURI(), listener)
- .join();
- List inv = listener.invocations();
- assertEquals(inv.size(), nPings + 2); // n * onPing + onOpen + onClose
+ try (var server = Support.serverWithCannedData(buffer.array())) {
+ server.open();
+ MockListener listener = new MockListener();
+ var webSocket = newHttpClient()
+ .newWebSocketBuilder()
+ .buildAsync(server.getURI(), listener)
+ .join();
+ try {
+ List inv = listener.invocations();
+ assertEquals(inv.size(), nPings + 2); // n * onPing + onOpen + onClose
+
+ ByteBuffer data = server.read();
+ Frame.Reader reader = new Frame.Reader();
+
+ Frame.Consumer consumer = new Frame.Consumer() {
- ByteBuffer data = server.read();
- Frame.Reader reader = new Frame.Reader();
+ ByteBuffer number = ByteBuffer.allocate(4);
+ Frame.Masker masker = new Frame.Masker();
+ int i = -1;
+ boolean closed;
+
+ @Override
+ public void fin(boolean value) {
+ assertTrue(value);
+ }
- Frame.Consumer consumer = new Frame.Consumer() {
+ @Override
+ public void rsv1(boolean value) {
+ assertFalse(value);
+ }
+
+ @Override
+ public void rsv2(boolean value) {
+ assertFalse(value);
+ }
+
+ @Override
+ public void rsv3(boolean value) {
+ assertFalse(value);
+ }
- ByteBuffer number = ByteBuffer.allocate(4);
- Frame.Masker masker = new Frame.Masker();
- int i = -1;
- boolean closed;
+ @Override
+ public void opcode(Frame.Opcode value) {
+ if (value == Frame.Opcode.CLOSE) {
+ closed = true;
+ return;
+ }
+ assertEquals(value, Frame.Opcode.PONG);
+ }
- @Override
- public void fin(boolean value) { assertTrue(value); }
+ @Override
+ public void mask(boolean value) {
+ assertTrue(value);
+ }
- @Override
- public void rsv1(boolean value) { assertFalse(value); }
+ @Override
+ public void payloadLen(long value) {
+ if (!closed)
+ assertEquals(value, 4);
+ }
+
+ @Override
+ public void maskingKey(int value) {
+ masker.mask(value);
+ }
- @Override
- public void rsv2(boolean value) { assertFalse(value); }
-
- @Override
- public void rsv3(boolean value) { assertFalse(value); }
+ @Override
+ public void payloadData(ByteBuffer src) {
+ masker.transferMasking(src, number);
+ if (closed) {
+ return;
+ }
+ number.flip();
+ int n = number.getInt();
+ System.out.printf("pong number=%s%n", n);
+ number.clear();
+ // a Pong with the number less than the maximum of Pongs already
+ // received MUST never be received
+ if (i >= n) {
+ fail(String.format("i=%s, n=%s", i, n));
+ }
+ i = n;
+ }
- @Override
- public void opcode(Frame.Opcode value) {
- if (value == Frame.Opcode.CLOSE) {
- closed = true;
- return;
+ @Override
+ public void endFrame() {
+ }
+ };
+ while (data.hasRemaining()) {
+ reader.readFrame(data, consumer);
}
- assertEquals(value, Frame.Opcode.PONG);
- }
-
- @Override
- public void mask(boolean value) { assertTrue(value); }
-
- @Override
- public void payloadLen(long value) {
- if (!closed)
- assertEquals(value, 4);
- }
-
- @Override
- public void maskingKey(int value) {
- masker.mask(value);
+ } finally {
+ webSocket.abort();
}
-
- @Override
- public void payloadData(ByteBuffer src) {
- masker.transferMasking(src, number);
- if (closed) {
- return;
- }
- number.flip();
- int n = number.getInt();
- System.out.printf("pong number=%s%n", n);
- number.clear();
- // a Pong with the number less than the maximum of Pongs already
- // received MUST never be received
- if (i >= n) {
- fail(String.format("i=%s, n=%s", i, n));
- }
- i = n;
- }
-
- @Override
- public void endFrame() { }
- };
- while (data.hasRemaining()) {
- reader.readFrame(data, consumer);
}
}
diff -r e47423f1318b -r ca19b94eac7a test/jdk/java/net/httpclient/websocket/SendTest.java
--- a/test/jdk/java/net/httpclient/websocket/SendTest.java Mon Sep 23 09:16:05 2019 -0700
+++ b/test/jdk/java/net/httpclient/websocket/SendTest.java Wed Sep 25 22:40:41 2019 +0200
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2018, 2019, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -29,7 +29,6 @@
* SendTest
*/
-import org.testng.annotations.AfterTest;
import org.testng.annotations.Test;
import java.io.IOException;
@@ -46,40 +45,35 @@
private static final Class NPE = NullPointerException.class;
- private DummyWebSocketServer server;
- private WebSocket webSocket;
-
- @AfterTest
- public void cleanup() {
- server.close();
- webSocket.abort();
- }
-
@Test
public void sendMethodsThrowNPE() throws IOException {
- server = new DummyWebSocketServer();
- server.open();
- webSocket = newBuilder().proxy(NO_PROXY).build().newWebSocketBuilder()
- .buildAsync(server.getURI(), new WebSocket.Listener() { })
- .join();
+ try (var server = new DummyWebSocketServer()) {
+ server.open();
+ var webSocket = newBuilder().proxy(NO_PROXY).build().newWebSocketBuilder()
+ .buildAsync(server.getURI(), new WebSocket.Listener() { })
+ .join();
+ try {
+ assertThrows(NPE, () -> webSocket.sendText(null, false));
+ assertThrows(NPE, () -> webSocket.sendText(null, true));
+ assertThrows(NPE, () -> webSocket.sendBinary(null, false));
+ assertThrows(NPE, () -> webSocket.sendBinary(null, true));
+ assertThrows(NPE, () -> webSocket.sendPing(null));
+ assertThrows(NPE, () -> webSocket.sendPong(null));
+ assertThrows(NPE, () -> webSocket.sendClose(NORMAL_CLOSURE, null));
- assertThrows(NPE, () -> webSocket.sendText(null, false));
- assertThrows(NPE, () -> webSocket.sendText(null, true));
- assertThrows(NPE, () -> webSocket.sendBinary(null, false));
- assertThrows(NPE, () -> webSocket.sendBinary(null, true));
- assertThrows(NPE, () -> webSocket.sendPing(null));
- assertThrows(NPE, () -> webSocket.sendPong(null));
- assertThrows(NPE, () -> webSocket.sendClose(NORMAL_CLOSURE, null));
+ webSocket.abort();
- webSocket.abort();
-
- assertThrows(NPE, () -> webSocket.sendText(null, false));
- assertThrows(NPE, () -> webSocket.sendText(null, true));
- assertThrows(NPE, () -> webSocket.sendBinary(null, false));
- assertThrows(NPE, () -> webSocket.sendBinary(null, true));
- assertThrows(NPE, () -> webSocket.sendPing(null));
- assertThrows(NPE, () -> webSocket.sendPong(null));
- assertThrows(NPE, () -> webSocket.sendClose(NORMAL_CLOSURE, null));
+ assertThrows(NPE, () -> webSocket.sendText(null, false));
+ assertThrows(NPE, () -> webSocket.sendText(null, true));
+ assertThrows(NPE, () -> webSocket.sendBinary(null, false));
+ assertThrows(NPE, () -> webSocket.sendBinary(null, true));
+ assertThrows(NPE, () -> webSocket.sendPing(null));
+ assertThrows(NPE, () -> webSocket.sendPong(null));
+ assertThrows(NPE, () -> webSocket.sendClose(NORMAL_CLOSURE, null));
+ } finally {
+ webSocket.abort();
+ }
+ }
}
// TODO: request in onClose/onError
@@ -88,14 +82,20 @@
@Test
public void sendCloseCompleted() throws IOException {
- server = new DummyWebSocketServer();
- server.open();
- webSocket = newBuilder().proxy(NO_PROXY).build().newWebSocketBuilder()
- .buildAsync(server.getURI(), new WebSocket.Listener() { })
- .join();
- webSocket.sendClose(NORMAL_CLOSURE, "").join();
- assertTrue(webSocket.isOutputClosed());
- assertEquals(webSocket.getSubprotocol(), "");
- webSocket.request(1); // No exceptions must be thrown
+ try (var server = new DummyWebSocketServer()) {
+ server.open();
+ var webSocket = newBuilder().proxy(NO_PROXY).build().newWebSocketBuilder()
+ .buildAsync(server.getURI(), new WebSocket.Listener() { })
+ .join();
+ try {
+ webSocket.sendClose(NORMAL_CLOSURE, "").join();
+ assertTrue(webSocket.isOutputClosed());
+ assertEquals(webSocket.getSubprotocol(), "");
+ webSocket.request(1); // No exceptions must be thrown
+ } finally {
+ webSocket.abort();
+ }
+ }
}
}
+
diff -r e47423f1318b -r ca19b94eac7a test/jdk/java/net/httpclient/websocket/WebSocketTest.java
--- a/test/jdk/java/net/httpclient/websocket/WebSocketTest.java Mon Sep 23 09:16:05 2019 -0700
+++ b/test/jdk/java/net/httpclient/websocket/WebSocketTest.java Wed Sep 25 22:40:41 2019 +0200
@@ -29,7 +29,6 @@
* WebSocketTest
*/
-import org.testng.annotations.AfterTest;
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;
@@ -73,150 +72,150 @@
Support.assertCompletesExceptionally(clazz, stage);
}
- private DummyWebSocketServer server;
- private WebSocket webSocket;
-
- @AfterTest
- public void cleanup() {
- System.out.println("AFTER TEST");
- if (server != null)
- server.close();
- if (webSocket != null)
- webSocket.abort();
- }
-
@Test
public void illegalArgument() throws IOException {
- server = new DummyWebSocketServer();
- server.open();
- webSocket = newBuilder().proxy(NO_PROXY).build()
- .newWebSocketBuilder()
- .buildAsync(server.getURI(), new WebSocket.Listener() { })
- .join();
+ try (var server = new DummyWebSocketServer()) {
+ server.open();
+ var webSocket = newBuilder().proxy(NO_PROXY).build()
+ .newWebSocketBuilder()
+ .buildAsync(server.getURI(), new WebSocket.Listener() { })
+ .join();
+ try {
+ assertFails(IAE, webSocket.sendPing(ByteBuffer.allocate(126)));
+ assertFails(IAE, webSocket.sendPing(ByteBuffer.allocate(127)));
+ assertFails(IAE, webSocket.sendPing(ByteBuffer.allocate(128)));
+ assertFails(IAE, webSocket.sendPing(ByteBuffer.allocate(129)));
+ assertFails(IAE, webSocket.sendPing(ByteBuffer.allocate(256)));
- assertFails(IAE, webSocket.sendPing(ByteBuffer.allocate(126)));
- assertFails(IAE, webSocket.sendPing(ByteBuffer.allocate(127)));
- assertFails(IAE, webSocket.sendPing(ByteBuffer.allocate(128)));
- assertFails(IAE, webSocket.sendPing(ByteBuffer.allocate(129)));
- assertFails(IAE, webSocket.sendPing(ByteBuffer.allocate(256)));
+ assertFails(IAE, webSocket.sendPong(ByteBuffer.allocate(126)));
+ assertFails(IAE, webSocket.sendPong(ByteBuffer.allocate(127)));
+ assertFails(IAE, webSocket.sendPong(ByteBuffer.allocate(128)));
+ assertFails(IAE, webSocket.sendPong(ByteBuffer.allocate(129)));
+ assertFails(IAE, webSocket.sendPong(ByteBuffer.allocate(256)));
- assertFails(IAE, webSocket.sendPong(ByteBuffer.allocate(126)));
- assertFails(IAE, webSocket.sendPong(ByteBuffer.allocate(127)));
- assertFails(IAE, webSocket.sendPong(ByteBuffer.allocate(128)));
- assertFails(IAE, webSocket.sendPong(ByteBuffer.allocate(129)));
- assertFails(IAE, webSocket.sendPong(ByteBuffer.allocate(256)));
+ assertFails(IOE, webSocket.sendText(Support.incompleteString(), true));
+ assertFails(IOE, webSocket.sendText(Support.incompleteString(), false));
+ assertFails(IOE, webSocket.sendText(Support.malformedString(), true));
+ assertFails(IOE, webSocket.sendText(Support.malformedString(), false));
- assertFails(IOE, webSocket.sendText(Support.incompleteString(), true));
- assertFails(IOE, webSocket.sendText(Support.incompleteString(), false));
- assertFails(IOE, webSocket.sendText(Support.malformedString(), true));
- assertFails(IOE, webSocket.sendText(Support.malformedString(), false));
+ assertFails(IAE, webSocket.sendClose(NORMAL_CLOSURE, Support.stringWithNBytes(124)));
+ assertFails(IAE, webSocket.sendClose(NORMAL_CLOSURE, Support.stringWithNBytes(125)));
+ assertFails(IAE, webSocket.sendClose(NORMAL_CLOSURE, Support.stringWithNBytes(128)));
+ assertFails(IAE, webSocket.sendClose(NORMAL_CLOSURE, Support.stringWithNBytes(256)));
+ assertFails(IAE, webSocket.sendClose(NORMAL_CLOSURE, Support.stringWithNBytes(257)));
+ assertFails(IAE, webSocket.sendClose(NORMAL_CLOSURE, Support.stringWith2NBytes((123 / 2) + 1)));
+ assertFails(IAE, webSocket.sendClose(NORMAL_CLOSURE, Support.malformedString()));
+ assertFails(IAE, webSocket.sendClose(NORMAL_CLOSURE, Support.incompleteString()));
- assertFails(IAE, webSocket.sendClose(NORMAL_CLOSURE, Support.stringWithNBytes(124)));
- assertFails(IAE, webSocket.sendClose(NORMAL_CLOSURE, Support.stringWithNBytes(125)));
- assertFails(IAE, webSocket.sendClose(NORMAL_CLOSURE, Support.stringWithNBytes(128)));
- assertFails(IAE, webSocket.sendClose(NORMAL_CLOSURE, Support.stringWithNBytes(256)));
- assertFails(IAE, webSocket.sendClose(NORMAL_CLOSURE, Support.stringWithNBytes(257)));
- assertFails(IAE, webSocket.sendClose(NORMAL_CLOSURE, Support.stringWith2NBytes((123 / 2) + 1)));
- assertFails(IAE, webSocket.sendClose(NORMAL_CLOSURE, Support.malformedString()));
- assertFails(IAE, webSocket.sendClose(NORMAL_CLOSURE, Support.incompleteString()));
+ assertFails(IAE, webSocket.sendClose(-2, "a reason"));
+ assertFails(IAE, webSocket.sendClose(-1, "a reason"));
+ assertFails(IAE, webSocket.sendClose(0, "a reason"));
+ assertFails(IAE, webSocket.sendClose(1, "a reason"));
+ assertFails(IAE, webSocket.sendClose(500, "a reason"));
+ assertFails(IAE, webSocket.sendClose(998, "a reason"));
+ assertFails(IAE, webSocket.sendClose(999, "a reason"));
+ assertFails(IAE, webSocket.sendClose(1002, "a reason"));
+ assertFails(IAE, webSocket.sendClose(1003, "a reason"));
+ assertFails(IAE, webSocket.sendClose(1006, "a reason"));
+ assertFails(IAE, webSocket.sendClose(1007, "a reason"));
+ assertFails(IAE, webSocket.sendClose(1009, "a reason"));
+ assertFails(IAE, webSocket.sendClose(1010, "a reason"));
+ assertFails(IAE, webSocket.sendClose(1012, "a reason"));
+ assertFails(IAE, webSocket.sendClose(1013, "a reason"));
+ assertFails(IAE, webSocket.sendClose(1015, "a reason"));
+ assertFails(IAE, webSocket.sendClose(5000, "a reason"));
+ assertFails(IAE, webSocket.sendClose(32768, "a reason"));
+ assertFails(IAE, webSocket.sendClose(65535, "a reason"));
+ assertFails(IAE, webSocket.sendClose(65536, "a reason"));
+ assertFails(IAE, webSocket.sendClose(Integer.MAX_VALUE, "a reason"));
+ assertFails(IAE, webSocket.sendClose(Integer.MIN_VALUE, "a reason"));
- assertFails(IAE, webSocket.sendClose(-2, "a reason"));
- assertFails(IAE, webSocket.sendClose(-1, "a reason"));
- assertFails(IAE, webSocket.sendClose(0, "a reason"));
- assertFails(IAE, webSocket.sendClose(1, "a reason"));
- assertFails(IAE, webSocket.sendClose(500, "a reason"));
- assertFails(IAE, webSocket.sendClose(998, "a reason"));
- assertFails(IAE, webSocket.sendClose(999, "a reason"));
- assertFails(IAE, webSocket.sendClose(1002, "a reason"));
- assertFails(IAE, webSocket.sendClose(1003, "a reason"));
- assertFails(IAE, webSocket.sendClose(1006, "a reason"));
- assertFails(IAE, webSocket.sendClose(1007, "a reason"));
- assertFails(IAE, webSocket.sendClose(1009, "a reason"));
- assertFails(IAE, webSocket.sendClose(1010, "a reason"));
- assertFails(IAE, webSocket.sendClose(1012, "a reason"));
- assertFails(IAE, webSocket.sendClose(1013, "a reason"));
- assertFails(IAE, webSocket.sendClose(1015, "a reason"));
- assertFails(IAE, webSocket.sendClose(5000, "a reason"));
- assertFails(IAE, webSocket.sendClose(32768, "a reason"));
- assertFails(IAE, webSocket.sendClose(65535, "a reason"));
- assertFails(IAE, webSocket.sendClose(65536, "a reason"));
- assertFails(IAE, webSocket.sendClose(Integer.MAX_VALUE, "a reason"));
- assertFails(IAE, webSocket.sendClose(Integer.MIN_VALUE, "a reason"));
+ assertThrows(IAE, () -> webSocket.request(Integer.MIN_VALUE));
+ assertThrows(IAE, () -> webSocket.request(Long.MIN_VALUE));
+ assertThrows(IAE, () -> webSocket.request(-1));
+ assertThrows(IAE, () -> webSocket.request(0));
- assertThrows(IAE, () -> webSocket.request(Integer.MIN_VALUE));
- assertThrows(IAE, () -> webSocket.request(Long.MIN_VALUE));
- assertThrows(IAE, () -> webSocket.request(-1));
- assertThrows(IAE, () -> webSocket.request(0));
-
- server.close();
+ } finally {
+ webSocket.abort();
+ }
+ }
}
@Test
public void partialBinaryThenText() throws IOException {
- server = new DummyWebSocketServer();
- server.open();
- webSocket = newBuilder().proxy(NO_PROXY).build().newWebSocketBuilder()
- .buildAsync(server.getURI(), new WebSocket.Listener() { })
- .join();
- webSocket.sendBinary(ByteBuffer.allocate(16), false).join();
- assertFails(ISE, webSocket.sendText("text", false));
- assertFails(ISE, webSocket.sendText("text", true));
- // Pings & Pongs are fine
- webSocket.sendPing(ByteBuffer.allocate(125)).join();
- webSocket.sendPong(ByteBuffer.allocate(125)).join();
- server.close();
+ try (var server = new DummyWebSocketServer()) {
+ server.open();
+ var webSocket = newBuilder().proxy(NO_PROXY).build().newWebSocketBuilder()
+ .buildAsync(server.getURI(), new WebSocket.Listener() { })
+ .join();
+ try {
+ webSocket.sendBinary(ByteBuffer.allocate(16), false).join();
+ assertFails(ISE, webSocket.sendText("text", false));
+ assertFails(ISE, webSocket.sendText("text", true));
+ // Pings & Pongs are fine
+ webSocket.sendPing(ByteBuffer.allocate(125)).join();
+ webSocket.sendPong(ByteBuffer.allocate(125)).join();
+ } finally {
+ webSocket.abort();
+ }
+ }
}
@Test
public void partialTextThenBinary() throws IOException {
- server = new DummyWebSocketServer();
- server.open();
- webSocket = newBuilder().proxy(NO_PROXY).build().newWebSocketBuilder()
- .buildAsync(server.getURI(), new WebSocket.Listener() { })
- .join();
-
- webSocket.sendText("text", false).join();
- assertFails(ISE, webSocket.sendBinary(ByteBuffer.allocate(16), false));
- assertFails(ISE, webSocket.sendBinary(ByteBuffer.allocate(16), true));
- // Pings & Pongs are fine
- webSocket.sendPing(ByteBuffer.allocate(125)).join();
- webSocket.sendPong(ByteBuffer.allocate(125)).join();
- server.close();
+ try (var server = new DummyWebSocketServer()) {
+ server.open();
+ var webSocket = newBuilder().proxy(NO_PROXY).build().newWebSocketBuilder()
+ .buildAsync(server.getURI(), new WebSocket.Listener() { })
+ .join();
+ try {
+ webSocket.sendText("text", false).join();
+ assertFails(ISE, webSocket.sendBinary(ByteBuffer.allocate(16), false));
+ assertFails(ISE, webSocket.sendBinary(ByteBuffer.allocate(16), true));
+ // Pings & Pongs are fine
+ webSocket.sendPing(ByteBuffer.allocate(125)).join();
+ webSocket.sendPong(ByteBuffer.allocate(125)).join();
+ } finally {
+ webSocket.abort();
+ }
+ }
}
@Test
public void sendMethodsThrowIOE1() throws IOException {
- server = new DummyWebSocketServer();
- server.open();
- webSocket = newBuilder().proxy(NO_PROXY).build()
- .newWebSocketBuilder()
- .buildAsync(server.getURI(), new WebSocket.Listener() { })
- .join();
+ try (var server = new DummyWebSocketServer()) {
+ server.open();
+ var webSocket = newBuilder().proxy(NO_PROXY).build()
+ .newWebSocketBuilder()
+ .buildAsync(server.getURI(), new WebSocket.Listener() { })
+ .join();
+ try {
+ webSocket.sendClose(NORMAL_CLOSURE, "ok").join();
- webSocket.sendClose(NORMAL_CLOSURE, "ok").join();
-
- assertFails(IOE, webSocket.sendClose(WebSocket.NORMAL_CLOSURE, "ok"));
+ assertFails(IOE, webSocket.sendClose(WebSocket.NORMAL_CLOSURE, "ok"));
- assertFails(IOE, webSocket.sendText("", true));
- assertFails(IOE, webSocket.sendText("", false));
- assertFails(IOE, webSocket.sendText("abc", true));
- assertFails(IOE, webSocket.sendText("abc", false));
- assertFails(IOE, webSocket.sendBinary(ByteBuffer.allocate(0), true));
- assertFails(IOE, webSocket.sendBinary(ByteBuffer.allocate(0), false));
- assertFails(IOE, webSocket.sendBinary(ByteBuffer.allocate(1), true));
- assertFails(IOE, webSocket.sendBinary(ByteBuffer.allocate(1), false));
+ assertFails(IOE, webSocket.sendText("", true));
+ assertFails(IOE, webSocket.sendText("", false));
+ assertFails(IOE, webSocket.sendText("abc", true));
+ assertFails(IOE, webSocket.sendText("abc", false));
+ assertFails(IOE, webSocket.sendBinary(ByteBuffer.allocate(0), true));
+ assertFails(IOE, webSocket.sendBinary(ByteBuffer.allocate(0), false));
+ assertFails(IOE, webSocket.sendBinary(ByteBuffer.allocate(1), true));
+ assertFails(IOE, webSocket.sendBinary(ByteBuffer.allocate(1), false));
- assertFails(IOE, webSocket.sendPing(ByteBuffer.allocate(125)));
- assertFails(IOE, webSocket.sendPing(ByteBuffer.allocate(124)));
- assertFails(IOE, webSocket.sendPing(ByteBuffer.allocate(1)));
- assertFails(IOE, webSocket.sendPing(ByteBuffer.allocate(0)));
+ assertFails(IOE, webSocket.sendPing(ByteBuffer.allocate(125)));
+ assertFails(IOE, webSocket.sendPing(ByteBuffer.allocate(124)));
+ assertFails(IOE, webSocket.sendPing(ByteBuffer.allocate(1)));
+ assertFails(IOE, webSocket.sendPing(ByteBuffer.allocate(0)));
- assertFails(IOE, webSocket.sendPong(ByteBuffer.allocate(125)));
- assertFails(IOE, webSocket.sendPong(ByteBuffer.allocate(124)));
- assertFails(IOE, webSocket.sendPong(ByteBuffer.allocate(1)));
- assertFails(IOE, webSocket.sendPong(ByteBuffer.allocate(0)));
-
- server.close();
+ assertFails(IOE, webSocket.sendPong(ByteBuffer.allocate(125)));
+ assertFails(IOE, webSocket.sendPong(ByteBuffer.allocate(124)));
+ assertFails(IOE, webSocket.sendPong(ByteBuffer.allocate(1)));
+ assertFails(IOE, webSocket.sendPong(ByteBuffer.allocate(0)));
+ } finally {
+ webSocket.abort();
+ }
+ }
}
@DataProvider(name = "sequence")
@@ -251,150 +250,153 @@
public void listenerSequentialOrder(int[] binary, long requestSize)
throws IOException
{
-
- server = Support.serverWithCannedData(binary);
- server.open();
+ try (var server = Support.serverWithCannedData(binary)) {
+ server.open();
- CompletableFuture violation = new CompletableFuture<>();
+ CompletableFuture violation = new CompletableFuture<>();
- MockListener listener = new MockListener(requestSize) {
+ MockListener listener = new MockListener(requestSize) {
- final AtomicBoolean guard = new AtomicBoolean();
+ final AtomicBoolean guard = new AtomicBoolean();
- private T checkRunExclusively(Supplier action) {
- if (guard.getAndSet(true)) {
- violation.completeExceptionally(new RuntimeException());
- }
- try {
- return action.get();
- } finally {
- if (!guard.getAndSet(false)) {
+ private T checkRunExclusively(Supplier action) {
+ if (guard.getAndSet(true)) {
violation.completeExceptionally(new RuntimeException());
}
+ try {
+ return action.get();
+ } finally {
+ if (!guard.getAndSet(false)) {
+ violation.completeExceptionally(new RuntimeException());
+ }
+ }
}
- }
- @Override
- public void onOpen(WebSocket webSocket) {
- checkRunExclusively(() -> {
- super.onOpen(webSocket);
- return null;
- });
- }
+ @Override
+ public void onOpen(WebSocket webSocket) {
+ checkRunExclusively(() -> {
+ super.onOpen(webSocket);
+ return null;
+ });
+ }
- @Override
- public CompletionStage> onText(WebSocket webSocket,
- CharSequence data,
- boolean last) {
- return checkRunExclusively(
- () -> super.onText(webSocket, data, last));
- }
+ @Override
+ public CompletionStage> onText(WebSocket webSocket,
+ CharSequence data,
+ boolean last) {
+ return checkRunExclusively(
+ () -> super.onText(webSocket, data, last));
+ }
- @Override
- public CompletionStage> onBinary(WebSocket webSocket,
- ByteBuffer data,
- boolean last) {
- return checkRunExclusively(
- () -> super.onBinary(webSocket, data, last));
- }
+ @Override
+ public CompletionStage> onBinary(WebSocket webSocket,
+ ByteBuffer data,
+ boolean last) {
+ return checkRunExclusively(
+ () -> super.onBinary(webSocket, data, last));
+ }
- @Override
- public CompletionStage> onPing(WebSocket webSocket,
- ByteBuffer message) {
- return checkRunExclusively(
- () -> super.onPing(webSocket, message));
- }
+ @Override
+ public CompletionStage> onPing(WebSocket webSocket,
+ ByteBuffer message) {
+ return checkRunExclusively(
+ () -> super.onPing(webSocket, message));
+ }
- @Override
- public CompletionStage> onPong(WebSocket webSocket,
- ByteBuffer message) {
- return checkRunExclusively(
- () -> super.onPong(webSocket, message));
- }
+ @Override
+ public CompletionStage> onPong(WebSocket webSocket,
+ ByteBuffer message) {
+ return checkRunExclusively(
+ () -> super.onPong(webSocket, message));
+ }
- @Override
- public CompletionStage> onClose(WebSocket webSocket,
- int statusCode,
- String reason) {
- return checkRunExclusively(
- () -> super.onClose(webSocket, statusCode, reason));
- }
+ @Override
+ public CompletionStage> onClose(WebSocket webSocket,
+ int statusCode,
+ String reason) {
+ return checkRunExclusively(
+ () -> super.onClose(webSocket, statusCode, reason));
+ }
- @Override
- public void onError(WebSocket webSocket, Throwable error) {
- checkRunExclusively(() -> {
- super.onError(webSocket, error);
- return null;
- });
- }
- };
+ @Override
+ public void onError(WebSocket webSocket, Throwable error) {
+ checkRunExclusively(() -> {
+ super.onError(webSocket, error);
+ return null;
+ });
+ }
+ };
- webSocket = newBuilder().proxy(NO_PROXY).build().newWebSocketBuilder()
- .buildAsync(server.getURI(), listener)
- .join();
-
-
- listener.invocations();
- violation.complete(null); // won't affect if completed exceptionally
- violation.join();
-
- server.close();
+ var webSocket = newBuilder().proxy(NO_PROXY).build().newWebSocketBuilder()
+ .buildAsync(server.getURI(), listener)
+ .join();
+ try {
+ listener.invocations();
+ violation.complete(null); // won't affect if completed exceptionally
+ violation.join();
+ } finally {
+ webSocket.abort();
+ }
+ }
}
@Test
public void sendMethodsThrowIOE2() throws Exception {
- server = Support.serverWithCannedData(0x88, 0x00);
- server.open();
- CompletableFuture onCloseCalled = new CompletableFuture<>();
- CompletableFuture canClose = new CompletableFuture<>();
+ try (var server = Support.serverWithCannedData(0x88, 0x00)) {
+ server.open();
+
+ CompletableFuture onCloseCalled = new CompletableFuture<>();
+ CompletableFuture canClose = new CompletableFuture<>();
- WebSocket.Listener listener = new WebSocket.Listener() {
- @Override
- public CompletionStage> onClose(WebSocket webSocket,
- int statusCode,
- String reason) {
- System.out.printf("onClose(%s, '%s')%n", statusCode, reason);
- onCloseCalled.complete(null);
- return canClose;
- }
+ WebSocket.Listener listener = new WebSocket.Listener() {
+ @Override
+ public CompletionStage> onClose(WebSocket webSocket,
+ int statusCode,
+ String reason) {
+ System.out.printf("onClose(%s, '%s')%n", statusCode, reason);
+ onCloseCalled.complete(null);
+ return canClose;
+ }
- @Override
- public void onError(WebSocket webSocket, Throwable error) {
- System.out.println("onError(" + error + ")");
- onCloseCalled.completeExceptionally(error);
- }
- };
-
- webSocket = newBuilder().proxy(NO_PROXY).build().newWebSocketBuilder()
- .buildAsync(server.getURI(), listener)
- .join();
+ @Override
+ public void onError(WebSocket webSocket, Throwable error) {
+ System.out.println("onError(" + error + ")");
+ onCloseCalled.completeExceptionally(error);
+ }
+ };
- onCloseCalled.join(); // Wait for onClose to be called
- canClose.complete(null); // Signal to the WebSocket it can close the output
- TimeUnit.SECONDS.sleep(5); // Give canClose some time to reach the WebSocket
+ var webSocket = newBuilder().proxy(NO_PROXY).build().newWebSocketBuilder()
+ .buildAsync(server.getURI(), listener)
+ .join();
+ try {
+ onCloseCalled.join(); // Wait for onClose to be called
+ canClose.complete(null); // Signal to the WebSocket it can close the output
+ TimeUnit.SECONDS.sleep(5); // Give canClose some time to reach the WebSocket
- assertFails(IOE, webSocket.sendClose(WebSocket.NORMAL_CLOSURE, "ok"));
+ assertFails(IOE, webSocket.sendClose(WebSocket.NORMAL_CLOSURE, "ok"));
- assertFails(IOE, webSocket.sendText("", true));
- assertFails(IOE, webSocket.sendText("", false));
- assertFails(IOE, webSocket.sendText("abc", true));
- assertFails(IOE, webSocket.sendText("abc", false));
- assertFails(IOE, webSocket.sendBinary(ByteBuffer.allocate(0), true));
- assertFails(IOE, webSocket.sendBinary(ByteBuffer.allocate(0), false));
- assertFails(IOE, webSocket.sendBinary(ByteBuffer.allocate(1), true));
- assertFails(IOE, webSocket.sendBinary(ByteBuffer.allocate(1), false));
+ assertFails(IOE, webSocket.sendText("", true));
+ assertFails(IOE, webSocket.sendText("", false));
+ assertFails(IOE, webSocket.sendText("abc", true));
+ assertFails(IOE, webSocket.sendText("abc", false));
+ assertFails(IOE, webSocket.sendBinary(ByteBuffer.allocate(0), true));
+ assertFails(IOE, webSocket.sendBinary(ByteBuffer.allocate(0), false));
+ assertFails(IOE, webSocket.sendBinary(ByteBuffer.allocate(1), true));
+ assertFails(IOE, webSocket.sendBinary(ByteBuffer.allocate(1), false));
- assertFails(IOE, webSocket.sendPing(ByteBuffer.allocate(125)));
- assertFails(IOE, webSocket.sendPing(ByteBuffer.allocate(124)));
- assertFails(IOE, webSocket.sendPing(ByteBuffer.allocate(1)));
- assertFails(IOE, webSocket.sendPing(ByteBuffer.allocate(0)));
+ assertFails(IOE, webSocket.sendPing(ByteBuffer.allocate(125)));
+ assertFails(IOE, webSocket.sendPing(ByteBuffer.allocate(124)));
+ assertFails(IOE, webSocket.sendPing(ByteBuffer.allocate(1)));
+ assertFails(IOE, webSocket.sendPing(ByteBuffer.allocate(0)));
- assertFails(IOE, webSocket.sendPong(ByteBuffer.allocate(125)));
- assertFails(IOE, webSocket.sendPong(ByteBuffer.allocate(124)));
- assertFails(IOE, webSocket.sendPong(ByteBuffer.allocate(1)));
- assertFails(IOE, webSocket.sendPong(ByteBuffer.allocate(0)));
-
- server.close();
+ assertFails(IOE, webSocket.sendPong(ByteBuffer.allocate(125)));
+ assertFails(IOE, webSocket.sendPong(ByteBuffer.allocate(124)));
+ assertFails(IOE, webSocket.sendPong(ByteBuffer.allocate(1)));
+ assertFails(IOE, webSocket.sendPong(ByteBuffer.allocate(0)));
+ } finally {
+ webSocket.abort();
+ }
+ }
}
// Used to verify a server requiring Authentication
@@ -458,74 +460,76 @@
};
CompletableFuture> actual = new CompletableFuture<>();
- server = serverSupplier.apply(binary);
- server.open();
-
- WebSocket.Listener listener = new WebSocket.Listener() {
+ try (var server = serverSupplier.apply(binary)) {
+ server.open();
- List collectedBytes = new ArrayList<>();
- ByteBuffer buffer = ByteBuffer.allocate(1024);
+ WebSocket.Listener listener = new WebSocket.Listener() {
- @Override
- public CompletionStage> onBinary(WebSocket webSocket,
- ByteBuffer message,
- boolean last) {
- System.out.printf("onBinary(%s, %s)%n", message, last);
- webSocket.request(1);
+ List collectedBytes = new ArrayList<>();
+ ByteBuffer buffer = ByteBuffer.allocate(1024);
- append(message);
- if (last) {
- buffer.flip();
- byte[] bytes = new byte[buffer.remaining()];
- buffer.get(bytes);
- buffer.clear();
- processWholeBinary(bytes);
- }
- return null;
- }
+ @Override
+ public CompletionStage> onBinary(WebSocket webSocket,
+ ByteBuffer message,
+ boolean last) {
+ System.out.printf("onBinary(%s, %s)%n", message, last);
+ webSocket.request(1);
- private void append(ByteBuffer message) {
- if (buffer.remaining() < message.remaining()) {
- assert message.remaining() > 0;
- int cap = (buffer.capacity() + message.remaining()) * 2;
- ByteBuffer b = ByteBuffer.allocate(cap);
- b.put(buffer.flip());
- buffer = b;
+ append(message);
+ if (last) {
+ buffer.flip();
+ byte[] bytes = new byte[buffer.remaining()];
+ buffer.get(bytes);
+ buffer.clear();
+ processWholeBinary(bytes);
+ }
+ return null;
}
- buffer.put(message);
- }
- private void processWholeBinary(byte[] bytes) {
- String stringBytes = new String(bytes, UTF_8);
- System.out.println("processWholeBinary: " + stringBytes);
- collectedBytes.add(bytes);
- }
+ private void append(ByteBuffer message) {
+ if (buffer.remaining() < message.remaining()) {
+ assert message.remaining() > 0;
+ int cap = (buffer.capacity() + message.remaining()) * 2;
+ ByteBuffer b = ByteBuffer.allocate(cap);
+ b.put(buffer.flip());
+ buffer = b;
+ }
+ buffer.put(message);
+ }
- @Override
- public CompletionStage> onClose(WebSocket webSocket,
- int statusCode,
- String reason) {
- actual.complete(collectedBytes);
- return null;
- }
+ private void processWholeBinary(byte[] bytes) {
+ String stringBytes = new String(bytes, UTF_8);
+ System.out.println("processWholeBinary: " + stringBytes);
+ collectedBytes.add(bytes);
+ }
- @Override
- public void onError(WebSocket webSocket, Throwable error) {
- actual.completeExceptionally(error);
- }
- };
+ @Override
+ public CompletionStage> onClose(WebSocket webSocket,
+ int statusCode,
+ String reason) {
+ actual.complete(collectedBytes);
+ return null;
+ }
+
+ @Override
+ public void onError(WebSocket webSocket, Throwable error) {
+ actual.completeExceptionally(error);
+ }
+ };
- webSocket = newBuilder()
- .proxy(NO_PROXY)
- .authenticator(new WSAuthenticator())
- .build().newWebSocketBuilder()
- .buildAsync(server.getURI(), listener)
- .join();
-
- List a = actual.join();
- assertEquals(a, expected);
-
- server.close();
+ var webSocket = newBuilder()
+ .proxy(NO_PROXY)
+ .authenticator(new WSAuthenticator())
+ .build().newWebSocketBuilder()
+ .buildAsync(server.getURI(), listener)
+ .join();
+ try {
+ List a = actual.join();
+ assertEquals(a, expected);
+ } finally {
+ webSocket.abort();
+ }
+ }
}
@Test(dataProvider = "servers")
@@ -554,59 +558,61 @@
};
CompletableFuture> actual = new CompletableFuture<>();
- server = serverSupplier.apply(binary);
- server.open();
+ try (var server = serverSupplier.apply(binary)) {
+ server.open();
+
+ WebSocket.Listener listener = new WebSocket.Listener() {
+
+ List collectedStrings = new ArrayList<>();
+ StringBuilder text = new StringBuilder();
- WebSocket.Listener listener = new WebSocket.Listener() {
-
- List collectedStrings = new ArrayList<>();
- StringBuilder text = new StringBuilder();
+ @Override
+ public CompletionStage> onText(WebSocket webSocket,
+ CharSequence message,
+ boolean last) {
+ System.out.printf("onText(%s, %s)%n", message, last);
+ webSocket.request(1);
+ text.append(message);
+ if (last) {
+ String str = text.toString();
+ text.setLength(0);
+ processWholeText(str);
+ }
+ return null;
+ }
- @Override
- public CompletionStage> onText(WebSocket webSocket,
- CharSequence message,
- boolean last) {
- System.out.printf("onText(%s, %s)%n", message, last);
- webSocket.request(1);
- text.append(message);
- if (last) {
- String str = text.toString();
- text.setLength(0);
- processWholeText(str);
+ private void processWholeText(String string) {
+ System.out.println(string);
+ collectedStrings.add(string);
+ }
+
+ @Override
+ public CompletionStage> onClose(WebSocket webSocket,
+ int statusCode,
+ String reason) {
+ actual.complete(collectedStrings);
+ return null;
}
- return null;
- }
+
+ @Override
+ public void onError(WebSocket webSocket, Throwable error) {
+ actual.completeExceptionally(error);
+ }
+ };
- private void processWholeText(String string) {
- System.out.println(string);
- collectedStrings.add(string);
+ var webSocket = newBuilder()
+ .proxy(NO_PROXY)
+ .authenticator(new WSAuthenticator())
+ .build().newWebSocketBuilder()
+ .buildAsync(server.getURI(), listener)
+ .join();
+ try {
+ List a = actual.join();
+ assertEquals(a, expected);
+ } finally {
+ webSocket.abort();
}
-
- @Override
- public CompletionStage> onClose(WebSocket webSocket,
- int statusCode,
- String reason) {
- actual.complete(collectedStrings);
- return null;
- }
-
- @Override
- public void onError(WebSocket webSocket, Throwable error) {
- actual.completeExceptionally(error);
- }
- };
-
- webSocket = newBuilder()
- .proxy(NO_PROXY)
- .authenticator(new WSAuthenticator())
- .build().newWebSocketBuilder()
- .buildAsync(server.getURI(), listener)
- .join();
-
- List a = actual.join();
- assertEquals(a, expected);
-
- server.close();
+ }
}
/*
@@ -639,73 +645,75 @@
};
CompletableFuture> actual = new CompletableFuture<>();
- server = serverSupplier.apply(binary);
- server.open();
+ try (var server = serverSupplier.apply(binary)) {
+ server.open();
- WebSocket.Listener listener = new WebSocket.Listener() {
+ WebSocket.Listener listener = new WebSocket.Listener() {
- List parts = new ArrayList<>();
- /*
- * A CompletableFuture which will complete once the current
- * message has been fully assembled. Until then the listener
- * returns this instance for every call.
- */
- CompletableFuture> currentCf = new CompletableFuture<>();
- List collected = new ArrayList<>();
+ List parts = new ArrayList<>();
+ /*
+ * A CompletableFuture which will complete once the current
+ * message has been fully assembled. Until then the listener
+ * returns this instance for every call.
+ */
+ CompletableFuture> currentCf = new CompletableFuture<>();
+ List collected = new ArrayList<>();
- @Override
- public CompletionStage> onText(WebSocket webSocket,
- CharSequence message,
- boolean last) {
- parts.add(message);
- if (!last) {
- webSocket.request(1);
- } else {
- this.currentCf.thenRun(() -> webSocket.request(1));
- CompletableFuture> refCf = this.currentCf;
- processWholeMessage(new ArrayList<>(parts), refCf);
- currentCf = new CompletableFuture<>();
- parts.clear();
- return refCf;
+ @Override
+ public CompletionStage> onText(WebSocket webSocket,
+ CharSequence message,
+ boolean last) {
+ parts.add(message);
+ if (!last) {
+ webSocket.request(1);
+ } else {
+ this.currentCf.thenRun(() -> webSocket.request(1));
+ CompletableFuture> refCf = this.currentCf;
+ processWholeMessage(new ArrayList<>(parts), refCf);
+ currentCf = new CompletableFuture<>();
+ parts.clear();
+ return refCf;
+ }
+ return currentCf;
}
- return currentCf;
- }
- @Override
- public CompletionStage> onClose(WebSocket webSocket,
- int statusCode,
- String reason) {
- actual.complete(collected);
- return null;
- }
+ @Override
+ public CompletionStage> onClose(WebSocket webSocket,
+ int statusCode,
+ String reason) {
+ actual.complete(collected);
+ return null;
+ }
- @Override
- public void onError(WebSocket webSocket, Throwable error) {
- actual.completeExceptionally(error);
- }
+ @Override
+ public void onError(WebSocket webSocket, Throwable error) {
+ actual.completeExceptionally(error);
+ }
- public void processWholeMessage(List data,
- CompletableFuture> cf) {
- StringBuilder b = new StringBuilder();
- data.forEach(b::append);
- String s = b.toString();
- System.out.println(s);
- cf.complete(null);
- collected.add(s);
- }
- };
+ public void processWholeMessage(List data,
+ CompletableFuture> cf) {
+ StringBuilder b = new StringBuilder();
+ data.forEach(b::append);
+ String s = b.toString();
+ System.out.println(s);
+ cf.complete(null);
+ collected.add(s);
+ }
+ };
- webSocket = newBuilder()
- .proxy(NO_PROXY)
- .authenticator(new WSAuthenticator())
- .build().newWebSocketBuilder()
- .buildAsync(server.getURI(), listener)
- .join();
-
- List a = actual.join();
- assertEquals(a, expected);
-
- server.close();
+ var webSocket = newBuilder()
+ .proxy(NO_PROXY)
+ .authenticator(new WSAuthenticator())
+ .build().newWebSocketBuilder()
+ .buildAsync(server.getURI(), listener)
+ .join();
+ try {
+ List a = actual.join();
+ assertEquals(a, expected);
+ } finally {
+ webSocket.abort();
+ }
+ }
}
// -- authentication specific tests
@@ -725,6 +733,7 @@
.newWebSocketBuilder()
.buildAsync(server.getURI(), new WebSocket.Listener() { })
.join();
+ webSocket.abort();
}
}
@@ -745,6 +754,7 @@
.header("Authorization", hv)
.buildAsync(server.getURI(), new WebSocket.Listener() { })
.join();
+ webSocket.abort();
}
}
@@ -763,6 +773,7 @@
try {
var webSocket = cf.join();
+ silentAbort(webSocket);
fail("Expected exception not thrown");
} catch (CompletionException expected) {
WebSocketHandshakeException e = (WebSocketHandshakeException)expected.getCause();
@@ -783,7 +794,7 @@
Authenticator authenticator = new Authenticator() {
@Override protected PasswordAuthentication getPasswordAuthentication() {
- return new PasswordAuthentication("BAD"+USERNAME, "".toCharArray());
+ return new PasswordAuthentication("BAD" + USERNAME, "".toCharArray());
}
};
@@ -796,10 +807,16 @@
try {
var webSocket = cf.join();
+ silentAbort(webSocket);
fail("Expected exception not thrown");
} catch (CompletionException expected) {
System.out.println("caught expected exception:" + expected);
}
}
}
+ private static void silentAbort(WebSocket ws) {
+ try {
+ ws.abort();
+ } catch (Throwable t) { }
+ }
}
diff -r e47423f1318b -r ca19b94eac7a test/jdk/java/nio/channels/spi/SelectorProvider/inheritedChannel/InheritedChannelTest.java
--- a/test/jdk/java/nio/channels/spi/SelectorProvider/inheritedChannel/InheritedChannelTest.java Mon Sep 23 09:16:05 2019 -0700
+++ b/test/jdk/java/nio/channels/spi/SelectorProvider/inheritedChannel/InheritedChannelTest.java Wed Sep 25 22:40:41 2019 +0200
@@ -25,7 +25,7 @@
* @test
* @bug 4673940 4930794 8211842
* @summary Unit tests for inetd feature
- * @requires (os.family == "linux" | os.family == "solaris")
+ * @requires (os.family == "linux" | os.family == "solaris" | os.family == "mac")
* @library /test/lib
* @build jdk.test.lib.Utils
* jdk.test.lib.Asserts
@@ -33,7 +33,8 @@
* jdk.test.lib.JDKToolLauncher
* jdk.test.lib.Platform
* jdk.test.lib.process.*
- * UnixSocketTest StateTest StateTestService EchoTest EchoService CloseTest Launcher Util
+ * UnixSocketTest StateTest StateTestService EchoTest EchoService
+ * UnixDomainChannelTest CloseTest Launcher Util
* @run testng/othervm/native InheritedChannelTest
* @key intermittent
*/
@@ -73,7 +74,8 @@
@DataProvider
public Object[][] testCases() {
- return new Object[][]{
+ return new Object[][] {
+ { "UnixDomainChannelTest", List.of(UnixDomainChannelTest.class.getName())},
{ "UnixSocketTest", List.of(UnixSocketTest.class.getName())},
{ "StateTest", List.of(StateTest.class.getName()) },
{ "EchoTest", List.of(EchoTest.class.getName()) },
@@ -83,6 +85,7 @@
// Note that the system properties are arguments to StateTest and not options.
// These system properties are passed to the launched service as options:
// java [-options] class [args...]
+
{ "StateTest run with " + POLICY_PASS, List.of(StateTest.class.getName(),
"-Djava.security.manager",
"-Djava.security.policy="
@@ -97,7 +100,7 @@
};
}
- @Test(dataProvider = "testCases")
+ @Test(dataProvider = "testCases", timeOut=30000)
public void test(String desc, List opts) throws Throwable {
String pathVar = Platform.sharedLibraryPathVariableName();
System.out.println(pathVar + "=" + libraryPath);
diff -r e47423f1318b -r ca19b94eac7a test/jdk/java/nio/channels/spi/SelectorProvider/inheritedChannel/Launcher.java
--- a/test/jdk/java/nio/channels/spi/SelectorProvider/inheritedChannel/Launcher.java Mon Sep 23 09:16:05 2019 -0700
+++ b/test/jdk/java/nio/channels/spi/SelectorProvider/inheritedChannel/Launcher.java Wed Sep 25 22:40:41 2019 +0200
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2019, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -75,6 +75,15 @@
return socks[1];
}
+ /**
+ * Launch specified class with an AF_UNIX socket created externally, and one String arg to child VM
+ */
+ public static void launchWithUnixDomainSocket(String className, UnixDomainSocket socket, String arg) throws IOException {
+ String[] args = new String[1];
+ args[0] = arg;
+ launch(className, null, args, socket.fd());
+ }
+
/*
* Launch 'java' with specified class with the specified arguments (may be null).
* The launched process will inherit a connected TCP socket. The remote endpoint
diff -r e47423f1318b -r ca19b94eac7a test/jdk/java/nio/channels/spi/SelectorProvider/inheritedChannel/UnixDomainChannelTest.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/test/jdk/java/nio/channels/spi/SelectorProvider/inheritedChannel/UnixDomainChannelTest.java Wed Sep 25 22:40:41 2019 +0200
@@ -0,0 +1,117 @@
+/*
+ * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+import java.nio.channels.*;
+import java.nio.ByteBuffer;
+import java.io.IOException;
+import static java.nio.charset.StandardCharsets.ISO_8859_1;
+
+/*
+ * Make sure that System.inheritedChannel returns null when given a UNIX domain socket
+ */
+
+public class UnixDomainChannelTest {
+
+ public static class Child {
+ public static void main(String[] args) throws Exception {
+ // we just want to make sure that System.inheritedChannel either
+ // returns a connected channel, or null if it is given a listener
+ Channel channel = System.inheritedChannel();
+ String result = channel == null ? "N" : "Y";
+ if (args[0].equals("test1") || args[0].equals("test2")) {
+ // socket is writeable
+ ByteChannel bc = (ByteChannel)channel;
+ ByteBuffer buf = ByteBuffer.wrap(result.getBytes(ISO_8859_1));
+ bc.write(buf);
+ } else { // test3
+ // in this case the socket is a listener
+ // we can't write to it. So, use UnixDatagramSocket
+ // to accept a writeable socket
+ UnixDomainSocket listener = new UnixDomainSocket(0); // fd 0
+ UnixDomainSocket sock = listener.accept();
+ sock.write((int)result.charAt(0));
+ }
+ }
+ }
+
+ static boolean passed = true;
+
+ public static void main(String args[]) throws Exception {
+ test1();
+ test2();
+ test3();
+ if (!passed)
+ throw new RuntimeException();
+ }
+
+ private static void closeAll(UnixDomainSocket... sockets) {
+ for (UnixDomainSocket sock : sockets) {
+ sock.close();
+ }
+ }
+
+ // Test with a named connected socket
+ private static void test1() throws Exception {
+ UnixDomainSocket listener = new UnixDomainSocket();
+ listener.bind("foo.socket");
+ UnixDomainSocket sock1 = new UnixDomainSocket();
+ sock1.connect("foo.socket");
+ UnixDomainSocket sock2 = listener.accept();
+
+ Launcher.launchWithUnixDomainSocket("UnixDomainChannelTest$Child", sock2, "test1");
+ int c = sock1.read();
+ if (c != 'Y') {
+ System.err.printf("test1: failed %d d\n", c );
+ passed = false;
+ }
+ closeAll(listener, sock1, sock2);
+ }
+
+ // Test with unnamed socketpair
+ private static void test2() throws Exception {
+ UnixDomainSocket[] pair = UnixDomainSocket.socketpair();
+ System.out.println("test2: launching child");
+ Launcher.launchWithUnixDomainSocket("UnixDomainChannelTest$Child", pair[0], "test2");
+ if (pair[1].read() != 'Y') {
+ System.err.println("test2: failed");
+ passed = false;
+ }
+ closeAll(pair[0], pair[1]);
+ }
+
+ // Test with a named listener
+ private static void test3() throws Exception {
+ UnixDomainSocket listener = new UnixDomainSocket();
+ listener.bind("foo.socket");
+ UnixDomainSocket sock1 = new UnixDomainSocket();
+ System.out.println("test3: launching child");
+ Launcher.launchWithUnixDomainSocket("UnixDomainChannelTest$Child", listener, "test3");
+ sock1.connect("foo.socket");
+ if (sock1.read() != 'N') {
+ System.err.println("test3: failed");
+ passed = false;
+ }
+ closeAll(listener, sock1);
+ }
+
+}
diff -r e47423f1318b -r ca19b94eac7a test/jdk/java/nio/channels/spi/SelectorProvider/inheritedChannel/UnixDomainSocket.java
--- a/test/jdk/java/nio/channels/spi/SelectorProvider/inheritedChannel/UnixDomainSocket.java Mon Sep 23 09:16:05 2019 -0700
+++ b/test/jdk/java/nio/channels/spi/SelectorProvider/inheritedChannel/UnixDomainSocket.java Wed Sep 25 22:40:41 2019 +0200
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2018, 2019 Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -37,21 +37,44 @@
}
private final int fd;
+ private volatile String name;
+
+ public UnixDomainSocket() throws IOException {
+ this.fd = create();
+ }
+
+ public void bind(String name) throws IOException {
+ bind0(fd, name);
+ this.name = name;
+ }
+
+ public UnixDomainSocket accept() throws IOException {
+ int newsock = accept0(fd);
+ return new UnixDomainSocket(newsock);
+ }
public UnixDomainSocket(int fd) {
this.fd = fd;
}
+ public void connect(String dest) throws IOException {
+ connect0(fd, dest);
+ }
+
public int read() throws IOException {
return read0(fd);
}
+ public String name() {
+ return name;
+ }
+
public void write(int w) throws IOException {
write0(fd, w);
}
public void close() {
- close0(fd);
+ close0(fd, name); // close0 will unlink name if non-null
}
public int fd() {
@@ -62,11 +85,16 @@
return "UnixDomainSocket: fd=" + Integer.toString(fd);
}
+ private static native int create() throws IOException;
+ private static native void bind0(int fd, String name) throws IOException;
+ private static native int accept0(int fd) throws IOException;
+ private static native int connect0(int fd, String name) throws IOException;
+
/* read and write bytes with UNIX domain sockets */
private static native int read0(int fd) throws IOException;
private static native void write0(int fd, int w) throws IOException;
- private static native void close0(int fd);
+ private static native void close0(int fd, String name);
private static native void init();
public static native UnixDomainSocket[] socketpair();
}
diff -r e47423f1318b -r ca19b94eac7a test/jdk/java/nio/channels/spi/SelectorProvider/inheritedChannel/libInheritedChannel.c
--- a/test/jdk/java/nio/channels/spi/SelectorProvider/inheritedChannel/libInheritedChannel.c Mon Sep 23 09:16:05 2019 -0700
+++ b/test/jdk/java/nio/channels/spi/SelectorProvider/inheritedChannel/libInheritedChannel.c Wed Sep 25 22:40:41 2019 +0200
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2019, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -26,8 +26,10 @@
*/
#include
#include
+#include
#include
#include
+#include
#include
#include
#include
@@ -147,19 +149,18 @@
/*
* We need to close all file descriptors except for serviceFd. To
- * get the list of open file descriptos we read through /proc/self/fd
+ * get the list of open file descriptos we read through /proc/self/fd (/dev/fd)
* but to open this requires a file descriptor. We could use a specific
* file descriptor and fdopendir but Linux doesn't seem to support
* fdopendir. Instead we use opendir and make an assumption on the
* file descriptor that is used (by opening & closing a file).
*/
- thisFd = open("/dev/null", O_RDONLY);
+ thisFd = open("/dev/fd", O_RDONLY);
if (thisFd < 0) {
_exit(-1);
}
- close(thisFd);
- if ((dp = opendir("/proc/self/fd")) == NULL) {
+ if ((dp = fdopendir(thisFd)) == NULL) {
_exit(-1);
}
@@ -216,6 +217,65 @@
return result;
}
+JNIEXPORT jint JNICALL Java_UnixDomainSocket_create
+ (JNIEnv *env, jclass cls)
+{
+ int sock = socket(AF_UNIX, SOCK_STREAM, 0);
+ if (sock == -1) {
+ ThrowException(env, "java/io/IOException", "socket create error");
+ }
+ return sock;
+}
+
+JNIEXPORT void JNICALL Java_UnixDomainSocket_bind0
+ (JNIEnv *env, jclass cls, jint sock, jstring name)
+{
+ struct sockaddr_un addr;
+ const char *nameUtf = (*env)->GetStringUTFChars(env, name, NULL);
+ int ret = -1;
+ unlink(nameUtf);
+ memset(&addr, 0, sizeof(addr));
+ addr.sun_family = AF_UNIX;
+ strncpy(addr.sun_path, nameUtf, strlen(nameUtf));
+ ret = bind(sock, (const struct sockaddr*)&addr, sizeof(addr));
+ if (ret == -1) {
+ ThrowException(env, "java/io/IOException", "socket bind error");
+ }
+ ret = listen(sock, 5);
+ if (ret == -1) {
+ ThrowException(env, "java/io/IOException", "socket bind error");
+ }
+ (*env)->ReleaseStringUTFChars(env, name, nameUtf);
+}
+
+JNIEXPORT jint JNICALL Java_UnixDomainSocket_accept0
+ (JNIEnv *env, jclass cls, jint sock)
+{
+ struct sockaddr_storage addr;
+ socklen_t len = sizeof(addr);
+ int ret = accept(sock, (struct sockaddr *)&addr, &len);
+ if (ret == -1)
+ ThrowException(env, "java/io/IOException", "socket accept error");
+ return ret;
+}
+
+JNIEXPORT void JNICALL Java_UnixDomainSocket_connect0
+ (JNIEnv *env, jclass cls, jint fd, jstring name)
+{
+ struct sockaddr_un addr;
+ const char *nameUtf = (*env)->GetStringUTFChars(env, name, NULL);
+ int ret = -1;
+ memset(&addr, 0, sizeof(addr));
+ addr.sun_family = AF_UNIX;
+ strncpy(addr.sun_path, nameUtf, strlen(nameUtf));
+ ret = connect(fd, (const struct sockaddr*)&addr, sizeof(addr));
+ if (ret == -1) {
+ ThrowException(env, "java/io/IOException", "socket connect error");
+ }
+ (*env)->ReleaseStringUTFChars(env, name, nameUtf);
+}
+
+
JNIEXPORT jint JNICALL Java_UnixDomainSocket_read0
(JNIEnv *env, jclass cls, jint fd)
{
@@ -243,7 +303,12 @@
}
JNIEXPORT void JNICALL Java_UnixDomainSocket_close0
- (JNIEnv *env, jclass cls, jint fd)
+ (JNIEnv *env, jclass cls, jint fd, jstring name)
{
close(fd);
+ if (name != NULL) {
+ const char *nameUtf = (*env)->GetStringUTFChars(env, name, NULL);
+ unlink(nameUtf);
+ (*env)->ReleaseStringUTFChars(env, name, nameUtf);
+ }
}
diff -r e47423f1318b -r ca19b94eac7a test/jdk/java/nio/file/attribute/BasicFileAttributeView/SetTimesNanos.java
--- a/test/jdk/java/nio/file/attribute/BasicFileAttributeView/SetTimesNanos.java Mon Sep 23 09:16:05 2019 -0700
+++ b/test/jdk/java/nio/file/attribute/BasicFileAttributeView/SetTimesNanos.java Wed Sep 25 22:40:41 2019 +0200
@@ -22,9 +22,9 @@
*/
/* @test
- * @bug 8181493
+ * @bug 8181493 8231174
* @summary Verify that nanosecond precision is maintained for file timestamps
- * @requires (os.family == "linux") | (os.family == "mac") | (os.family == "solaris")
+ * @requires (os.family == "linux") | (os.family == "mac") | (os.family == "solaris") | (os.family == "windows")
* @modules java.base/sun.nio.fs:+open
*/
@@ -40,14 +40,21 @@
import java.util.concurrent.TimeUnit;
public class SetTimesNanos {
+ private static final boolean IS_WINDOWS =
+ System.getProperty("os.name").startsWith("Windows");
+
public static void main(String[] args) throws Exception {
- // Check whether futimens() system call is supported
- Class unixNativeDispatcherClass = Class.forName("sun.nio.fs.UnixNativeDispatcher");
- Method futimensSupported = unixNativeDispatcherClass.getDeclaredMethod("futimensSupported");
- futimensSupported.setAccessible(true);
- if (!(boolean)futimensSupported.invoke(null)) {
- System.err.println("futimens() system call not supported; skipping test");
- return;
+ if (!IS_WINDOWS) {
+ // Check whether futimens() system call is supported
+ Class unixNativeDispatcherClass =
+ Class.forName("sun.nio.fs.UnixNativeDispatcher");
+ Method futimensSupported =
+ unixNativeDispatcherClass.getDeclaredMethod("futimensSupported");
+ futimensSupported.setAccessible(true);
+ if (!(boolean)futimensSupported.invoke(null)) {
+ System.err.println("futimens() not supported; skipping test");
+ return;
+ }
}
Path dirPath = Path.of("test");
@@ -56,7 +63,8 @@
System.out.format("FileStore: \"%s\" on %s (%s)%n",
dir, store.name(), store.type());
- Set testedTypes = Set.of("apfs", "ext4", "xfs", "zfs");
+ Set testedTypes = IS_WINDOWS ?
+ Set.of("NTFS") : Set.of("apfs", "ext4", "xfs", "zfs");
if (!testedTypes.contains(store.type())) {
System.err.format("%s not in %s; skipping test", store.type(), testedTypes);
return;
@@ -77,6 +85,11 @@
Files.getFileAttributeView(path, BasicFileAttributeView.class);
view.setTimes(pathTime, pathTime, null);
+ // Windows file time resolution is 100ns so truncate
+ if (IS_WINDOWS) {
+ timeNanos = 100L*(timeNanos/100L);
+ }
+
// Read attributes
BasicFileAttributes attrs =
Files.readAttributes(path, BasicFileAttributes.class);
diff -r e47423f1318b -r ca19b94eac7a test/jdk/java/nio/file/etc/MacVolumesTest.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/test/jdk/java/nio/file/etc/MacVolumesTest.java Wed Sep 25 22:40:41 2019 +0200
@@ -0,0 +1,203 @@
+/*
+ * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/* @test
+ * @bug 8231254
+ * @requires os.family == "mac"
+ * @summary Check access and basic NIO APIs on APFS for macOS version >= 10.15
+ */
+import java.io.BufferedReader;
+import java.io.FileInputStream;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.IOException;
+import java.io.Reader;
+import java.nio.ByteBuffer;
+import java.nio.channels.SeekableByteChannel;
+import java.nio.file.DirectoryStream;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.StandardOpenOption;
+import java.nio.file.attribute.FileTime;
+import java.util.Arrays;
+import java.util.Iterator;
+import java.util.Random;
+
+public class MacVolumesTest {
+ private static final String SYSTEM_VOLUME = "/";
+ private static final String DATA_VOLUME = "/System/Volumes/Data";
+ private static final String FIRMLINKS = "/usr/share/firmlinks";
+
+ private static final void checkSystemVolume() throws IOException {
+ System.out.format("--- Checking system volume %s ---%n", SYSTEM_VOLUME);
+ Path root = Path.of(SYSTEM_VOLUME);
+ if (!Files.getFileStore(root).isReadOnly()) {
+ throw new RuntimeException("Root volume is not read-only");
+ }
+
+ Path tempDir;
+ try {
+ tempDir = Files.createTempDirectory(root, "tempDir");
+ throw new RuntimeException("Created temporary directory in root");
+ } catch (IOException ignore) {
+ }
+
+ Path tempFile;
+ try {
+ tempFile = Files.createTempFile(root, "tempFile", null);
+ throw new RuntimeException("Created temporary file in root");
+ } catch (IOException ignore) {
+ }
+
+ Path path = null;
+ Path etc = Path.of(SYSTEM_VOLUME, "etc");
+ if (Files.isWritable(etc)) {
+ throw new RuntimeException("System path " + etc + " is writable");
+ }
+ try (DirectoryStream ds = Files.newDirectoryStream(etc)) {
+ Iterator paths = ds.iterator();
+ while (paths.hasNext()) {
+ Path p = paths.next();
+ if (Files.isReadable(p) && Files.isRegularFile(p)) {
+ path = p;
+ break;
+ }
+ }
+ }
+ if (path == null) {
+ System.err.println("No root test file found: skipping file test");
+ return;
+ }
+ System.out.format("Using root test file %s%n", path);
+
+ if (Files.isWritable(path)) {
+ throw new RuntimeException("Test file " + path + " is writable");
+ }
+
+ FileTime creationTime =
+ (FileTime)Files.getAttribute(path, "basic:creationTime");
+ System.out.format("%s creation time: %s%n", path, creationTime);
+
+ long size = Files.size(path);
+ int capacity = (int)Math.min(1024, size);
+ ByteBuffer buf = ByteBuffer.allocate(capacity);
+ try (SeekableByteChannel sbc = Files.newByteChannel(path)) {
+ int n = sbc.read(buf);
+ System.out.format("Read %d bytes from %s%n", n, path);
+ }
+ }
+
+ private static final void checkDataVolume() throws IOException {
+ System.out.format("--- Checking data volume %s ---%n", DATA_VOLUME);
+ Path data = Path.of(DATA_VOLUME, "tmp");
+ if (Files.getFileStore(data).isReadOnly()) {
+ throw new RuntimeException("Data volume is read-only");
+ }
+
+ Path tempDir = Files.createTempDirectory(data, "tempDir");
+ tempDir.toFile().deleteOnExit();
+ System.out.format("Temporary directory: %s%n", tempDir);
+ if (!Files.isWritable(tempDir)) {
+ throw new RuntimeException("Temporary directory is not writable");
+ }
+
+ Path tempFile = Files.createTempFile(tempDir, "tempFile", null);
+ tempFile.toFile().deleteOnExit();
+ System.out.format("Temporary file: %s%n", tempFile);
+ if (!Files.isWritable(tempFile)) {
+ throw new RuntimeException("Temporary file is not writable");
+ }
+
+ byte[] bytes = new byte[42];
+ new Random().nextBytes(bytes);
+ try (SeekableByteChannel sbc = Files.newByteChannel(tempFile,
+ StandardOpenOption.WRITE)) {
+ ByteBuffer src = ByteBuffer.wrap(bytes);
+ if (sbc.write(src) != bytes.length) {
+ throw new RuntimeException("Incorrect number of bytes written");
+ }
+ }
+
+ try (SeekableByteChannel sbc = Files.newByteChannel(tempFile)) {
+ ByteBuffer dst = ByteBuffer.allocate(bytes.length);
+ if (sbc.read(dst) != bytes.length) {
+ throw new RuntimeException("Incorrect number of bytes read");
+ }
+ if (!Arrays.equals(dst.array(), bytes)) {
+ throw new RuntimeException("Bytes read != bytes written");
+ }
+ }
+ }
+
+ static void checkFirmlinks() throws IOException {
+ System.out.format("--- Checking firmlinks %s ---%n", FIRMLINKS);
+ Path firmlinks = Path.of(FIRMLINKS);
+ if (!Files.exists(firmlinks)) {
+ System.err.format("%s does not exist: skipping firmlinks test%n",
+ firmlinks);
+ return;
+ } else if (!Files.isReadable(firmlinks)) {
+ throw new RuntimeException(String.format("%s is not readable",
+ firmlinks));
+ }
+
+ try (BufferedReader br = Files.newBufferedReader(firmlinks)) {
+ String line;
+ while ((line = br.readLine()) != null) {
+ String file = line.split("\\s")[0];
+ Path path = Path.of(file);
+ if (!Files.exists(path)) {
+ System.err.format("Firmlink %s does not exist: skipping%n",
+ file);
+ continue;
+ }
+ if (Files.getFileStore(path).isReadOnly()) {
+ String msg = String.format("%s is read-only%n", file);
+ throw new RuntimeException(msg);
+ } else {
+ System.out.format("Firmlink %s OK%n", file);
+ }
+ }
+ }
+ }
+
+ public static void main(String[] args) throws Exception {
+ String[] osv = System.getProperty("os.version").split("\\.");
+ int major = Integer.valueOf(osv[0]);
+ int minor = Integer.valueOf(osv[1]);
+ if (major < 10 || (major == 10 && minor < 15)) {
+ System.out.format("macOS version %d.%d too old: skipping test%n",
+ major, minor);
+ return;
+ }
+
+ // Check system volume for read-only.
+ checkSystemVolume();
+
+ // Check data volume for read-write.
+ checkDataVolume();
+
+ // Check firmlinks for read-write.
+ checkFirmlinks();
+ }
+}
diff -r e47423f1318b -r ca19b94eac7a test/jdk/java/security/Provider/GetServiceRace.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/test/jdk/java/security/Provider/GetServiceRace.java Wed Sep 25 22:40:41 2019 +0200
@@ -0,0 +1,98 @@
+/*
+ * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 8231387
+ * @library ../testlibrary
+ * @summary make sure getService() avoids a race
+ * @author Tianmin Shi
+ */
+
+import java.security.Provider;
+
+public class GetServiceRace {
+
+ private static final Provider testProvider;
+ static {
+ testProvider = new Provider("MyProvider", 1.0, "test") {
+ };
+ testProvider.put("CertificateFactory.Fixed", "MyCertificateFactory");
+ }
+
+ private static final int NUMBER_OF_RETRIEVERS = 3;
+ private static final int TEST_TIME_MS = 1000;
+
+ public static boolean testFailed = false;
+
+ public static void main(String[] args) throws Exception {
+ Updater updater = new Updater();
+ updater.start();
+ Retriever [] retrievers = new Retriever[NUMBER_OF_RETRIEVERS];
+ for (int i=0; i isFrameShowing = frame.isShowing());
+ if (!isFrameShowing) {
+ Thread.sleep(1000);
+ }
+ } catch (InterruptedException ex) {
+ } catch (Exception ex) {
+ throw new RuntimeException(ex);
+ }
+ }
+ }
+
private static void executeTest() throws Exception {
-
Point point = Util.getCenterPoint(menu);
performMouseOperations(point);
point = Util.getCenterPoint(menuItem);
diff -r e47423f1318b -r ca19b94eac7a test/jdk/javax/swing/plaf/metal/MetalIcons/MetalHiDPIIconsTest.java
--- a/test/jdk/javax/swing/plaf/metal/MetalIcons/MetalHiDPIIconsTest.java Mon Sep 23 09:16:05 2019 -0700
+++ b/test/jdk/javax/swing/plaf/metal/MetalIcons/MetalHiDPIIconsTest.java Wed Sep 25 22:40:41 2019 +0200
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2016, 2019, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -23,7 +23,7 @@
/*
* @test
- * @bug 8160986 8174845 8176883
+ * @bug 8160986 8174845 8176883 8165828
* @summary Bad rendering of Swing UI controls with Metal L&F on HiDPI display
* @run main/manual MetalHiDPIIconsTest
*/
@@ -50,7 +50,7 @@
+ "Verify that icons are painted smoothly for standard Swing UI controls.\n\n"
+ "If the display does not support HiDPI mode press PASS.\n\n"
+ "1. Run the SwingSet2 demo on HiDPI Display.\n"
- + "2. Select Metal Look and Feel\n"
+ + "2. Select Java Look and Feel. It is equivalent to Metal Look And Feel\n"
+ "3. Check that the icons are painted smoothly on Swing UI controls like:\n"
+ " - JRadioButton\n"
+ " - JCheckBox\n"
diff -r e47423f1318b -r ca19b94eac7a test/jdk/jdk/jfr/event/gc/collection/TestG1ParallelPhases.java
--- a/test/jdk/jdk/jfr/event/gc/collection/TestG1ParallelPhases.java Mon Sep 23 09:16:05 2019 -0700
+++ b/test/jdk/jdk/jfr/event/gc/collection/TestG1ParallelPhases.java Wed Sep 25 22:40:41 2019 +0200
@@ -98,8 +98,7 @@
"CLDGRoots",
"JVMTIRoots",
"CMRefRoots",
- "WaitForStrongCLD",
- "WeakCLDRoots",
+ "WaitForStrongRoots",
"MergeER",
"MergeHCC",
"MergeRS",
diff -r e47423f1318b -r ca19b94eac7a test/jdk/jdk/jfr/jcmd/TestJcmdConfigure.java
--- a/test/jdk/jdk/jfr/jcmd/TestJcmdConfigure.java Mon Sep 23 09:16:05 2019 -0700
+++ b/test/jdk/jdk/jfr/jcmd/TestJcmdConfigure.java Wed Sep 25 22:40:41 2019 +0200
@@ -25,6 +25,7 @@
package jdk.jfr.jcmd;
+import java.io.File;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.ArrayList;
@@ -56,8 +57,8 @@
private static final String SAMPLE_THREADS = "samplethreads";
private static final String UNSUPPORTED_OPTION = "unsupportedoption";
- private static final String REPOSITORYPATH_1 = "./repo1";
- private static final String REPOSITORYPATH_2 = "./repo2";
+ private static final String REPOSITORYPATH_1 = "." + File.pathSeparator + "repo1";
+ private static final String REPOSITORYPATH_2 = "." + File.pathSeparator + "repo2";
private static final String REPOSITORYPATH_SETTING_1 = "repositorypath="+REPOSITORYPATH_1;
private static final String REPOSITORYPATH_SETTING_2 = "repositorypath="+REPOSITORYPATH_2;
diff -r e47423f1318b -r ca19b94eac7a test/jdk/sun/java2d/marlin/FlipBitTest.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/test/jdk/sun/java2d/marlin/FlipBitTest.java Wed Sep 25 22:40:41 2019 +0200
@@ -0,0 +1,104 @@
+/*
+ * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+
+import java.awt.BasicStroke;
+import java.awt.Color;
+import java.awt.Graphics2D;
+import java.awt.Rectangle;
+import java.awt.RenderingHints;
+import java.awt.geom.AffineTransform;
+import java.awt.geom.Ellipse2D;
+import java.awt.image.BufferedImage;
+import java.io.File;
+import java.io.IOException;
+import javax.imageio.ImageIO;
+
+
+/**
+ * Tests calculating user space line with a negative determinant (flip).
+ *
+ * @test
+ * @summary verify that flipped transformed lines are properly rasterized
+ * @bug 8230728
+ */
+public class FlipBitTest {
+
+ static final boolean SAVE_IMAGE = false;
+
+ public static void main(final String[] args) {
+
+ final int size = 100;
+
+ // First display which renderer is tested:
+ // JDK9 only:
+ System.setProperty("sun.java2d.renderer.verbose", "true");
+
+ System.out.println("FlipBitTest: size = " + size);
+
+ final BufferedImage image = new BufferedImage(size, size, BufferedImage.TYPE_INT_ARGB);
+
+ final Graphics2D g2d = (Graphics2D) image.getGraphics();
+ try {
+ g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
+ g2d.setRenderingHint(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY);
+ g2d.setRenderingHint(RenderingHints.KEY_STROKE_CONTROL, RenderingHints.VALUE_STROKE_NORMALIZE);
+
+ final AffineTransform at = new AffineTransform();
+ at.setToScale(1, -1.01);
+ g2d.setTransform(at);
+
+ g2d.translate(0, -image.getHeight());
+ g2d.setPaint(Color.WHITE);
+ g2d.fill(new Rectangle(image.getWidth(), image.getHeight()));
+
+ g2d.setPaint(Color.BLACK);
+ g2d.setStroke(new BasicStroke(0.1f));
+ g2d.draw(new Ellipse2D.Double(25, 25, 50, 50));
+
+ if (SAVE_IMAGE) {
+ try {
+ final File file = new File("FlipBitTest.png");
+
+ System.out.println("Writing file: " + file.getAbsolutePath());
+ ImageIO.write(image, "PNG", file);
+ } catch (IOException ex) {
+ ex.printStackTrace();
+ }
+ }
+
+ boolean nonWhitePixelFound = false;
+ for (int x = 0; x < image.getWidth(); ++x) {
+ if (image.getRGB(x, 50) != Color.WHITE.getRGB()) {
+ nonWhitePixelFound = true;
+ break;
+ }
+ }
+ if (!nonWhitePixelFound) {
+ throw new IllegalStateException("The ellipse was not drawn");
+ }
+ } finally {
+ g2d.dispose();
+ }
+ }
+}
diff -r e47423f1318b -r ca19b94eac7a test/jdk/sun/java2d/pipe/hw/RSLAPITest/RSLAPITest.java
--- a/test/jdk/sun/java2d/pipe/hw/RSLAPITest/RSLAPITest.java Mon Sep 23 09:16:05 2019 -0700
+++ b/test/jdk/sun/java2d/pipe/hw/RSLAPITest/RSLAPITest.java Wed Sep 25 22:40:41 2019 +0200
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2007, 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2007, 2019, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -44,7 +44,6 @@
import java.util.HashSet;
import sun.java2d.DestSurfaceProvider;
import sun.java2d.Surface;
-import sun.java2d.pipe.BufferedContext;
import sun.java2d.pipe.RenderQueue;
import sun.java2d.pipe.hw.AccelGraphicsConfig;
import sun.java2d.pipe.hw.AccelSurface;
@@ -161,8 +160,6 @@
AccelGraphicsConfig agc = (AccelGraphicsConfig) gc;
printAGC(agc);
- testContext(agc);
-
VolatileImage vi = gc.createCompatibleVolatileImage(10, 10);
vi.validate(gc);
if (vi instanceof DestSurfaceProvider) {
@@ -250,22 +247,6 @@
}
}
- private static void testContext(final AccelGraphicsConfig agc) {
- BufferedContext c = agc.getContext();
-
- RenderQueue rq = c.getRenderQueue();
- rq.lock();
- try {
- c.saveState();
- rq.flushNow();
- c.restoreState();
- rq.flushNow();
- System.out.println("Passed: Save/Restore");
- } finally {
- rq.unlock();
- }
- }
-
private static void testForNPEDuringCreation(AccelGraphicsConfig agc) {
int iterations = 100;
HashSet vis = new HashSet();
diff -r e47423f1318b -r ca19b94eac7a test/jdk/sun/java2d/pipe/hw/RSLContextInvalidationTest/RSLContextInvalidationTest.java
--- a/test/jdk/sun/java2d/pipe/hw/RSLContextInvalidationTest/RSLContextInvalidationTest.java Mon Sep 23 09:16:05 2019 -0700
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,110 +0,0 @@
-/*
- * Copyright (c) 2007, 2018, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-/*
- * @test
- * @key headful
- * @bug 6764257 8198613
- * @summary Tests that the color is reset properly after save/restore context
- * @author Dmitri.Trembovetski@sun.com: area=Graphics
- * @modules java.desktop/sun.java2d
- * java.desktop/sun.java2d.pipe
- * java.desktop/sun.java2d.pipe.hw
- * @compile -XDignore.symbol.file=true RSLContextInvalidationTest.java
- * @run main/othervm RSLContextInvalidationTest
- * @run main/othervm -Dsun.java2d.noddraw=true RSLContextInvalidationTest
- */
-
-import java.awt.Color;
-import java.awt.Graphics;
-import java.awt.GraphicsConfiguration;
-import java.awt.GraphicsDevice;
-import java.awt.GraphicsEnvironment;
-import java.awt.image.BufferedImage;
-import java.awt.image.VolatileImage;
-import sun.java2d.DestSurfaceProvider;
-import sun.java2d.Surface;
-import sun.java2d.pipe.RenderQueue;
-import sun.java2d.pipe.hw.*;
-
-public class RSLContextInvalidationTest {
-
- public static void main(String[] args) {
- GraphicsEnvironment ge =
- GraphicsEnvironment.getLocalGraphicsEnvironment();
- GraphicsDevice gd = ge.getDefaultScreenDevice();
- GraphicsConfiguration gc = gd.getDefaultConfiguration();
- VolatileImage vi = gc.createCompatibleVolatileImage(100, 100);
- vi.validate(gc);
- VolatileImage vi1 = gc.createCompatibleVolatileImage(100, 100);
- vi1.validate(gc);
-
- if (!(vi instanceof DestSurfaceProvider)) {
- System.out.println("Test considered PASSED: no HW acceleration");
- return;
- }
-
- DestSurfaceProvider p = (DestSurfaceProvider)vi;
- Surface s = p.getDestSurface();
- if (!(s instanceof AccelSurface)) {
- System.out.println("Test considered PASSED: no HW acceleration");
- return;
- }
- AccelSurface dst = (AccelSurface)s;
-
- Graphics g = vi.createGraphics();
- g.drawImage(vi1, 95, 95, null);
- g.setColor(Color.red);
- g.fillRect(0, 0, 100, 100);
- g.setColor(Color.black);
- g.fillRect(0, 0, 100, 100);
- // after this the validated context color is black
-
- RenderQueue rq = dst.getContext().getRenderQueue();
- rq.lock();
- try {
- dst.getContext().saveState();
- dst.getContext().restoreState();
- } finally {
- rq.unlock();
- }
-
- // this will cause ResetPaint (it will set color to extended EA=ff,
- // which is ffffffff==Color.white)
- g.drawImage(vi1, 95, 95, null);
-
- // now try filling with black again, but it will come up as white
- // because this fill rect won't validate the color properly
- g.setColor(Color.black);
- g.fillRect(0, 0, 100, 100);
-
- BufferedImage bi = vi.getSnapshot();
- if (bi.getRGB(50, 50) != Color.black.getRGB()) {
- throw new RuntimeException("Test FAILED: found color="+
- Integer.toHexString(bi.getRGB(50, 50))+" instead of "+
- Integer.toHexString(Color.black.getRGB()));
- }
-
- System.out.println("Test PASSED.");
- }
-}
diff -r e47423f1318b -r ca19b94eac7a test/jdk/sun/tools/jcmd/TestProcessHelper.java
--- a/test/jdk/sun/tools/jcmd/TestProcessHelper.java Mon Sep 23 09:16:05 2019 -0700
+++ b/test/jdk/sun/tools/jcmd/TestProcessHelper.java Wed Sep 25 22:40:41 2019 +0200
@@ -21,16 +21,13 @@
* questions.
*/
-import jdk.internal.module.ModuleInfoWriter;
-import jdk.test.lib.JDKToolFinder;
-import jdk.test.lib.process.ProcessTools;
-import jdk.test.lib.util.JarUtils;
-import sun.tools.common.ProcessHelper;
-
import java.io.File;
import java.io.IOException;
import java.io.OutputStream;
+import java.lang.invoke.MethodHandle;
+import java.lang.invoke.MethodHandles;
import java.lang.module.ModuleDescriptor;
+import java.lang.reflect.Method;
import java.nio.file.FileSystems;
import java.nio.file.Files;
import java.nio.file.Path;
@@ -44,6 +41,11 @@
import java.util.stream.Collectors;
import java.util.stream.Stream;
+import jdk.internal.module.ModuleInfoWriter;
+import jdk.test.lib.JDKToolFinder;
+import jdk.test.lib.process.ProcessTools;
+import jdk.test.lib.util.JarUtils;
+
/*
* @test
* @bug 8205654
@@ -52,15 +54,13 @@
*
* @requires os.family == "linux"
* @library /test/lib
- * @modules jdk.jcmd/sun.tools.common
+ * @modules jdk.jcmd/sun.tools.common:+open
* java.base/jdk.internal.module
* @build test.TestProcess
* @run main/othervm TestProcessHelper
*/
public class TestProcessHelper {
- private ProcessHelper PROCESS_HELPER = ProcessHelper.platformProcessHelper();
-
private static final String TEST_PROCESS_MAIN_CLASS_NAME = "TestProcess";
private static final String TEST_PROCESS_MAIN_CLASS_PACKAGE = "test";
private static final String TEST_PROCESS_MAIN_CLASS = TEST_PROCESS_MAIN_CLASS_PACKAGE + "."
@@ -89,6 +89,29 @@
private static final String[] PATCH_MODULE_OPTIONS = {"--patch-module", null};
+ private static final MethodHandle MH_GET_MAIN_CLASS = resolveMainClassMH();
+
+ private static MethodHandle resolveMainClassMH() {
+ try {
+ Method getMainClassMethod = Class
+ .forName("sun.tools.common.ProcessHelper")
+ .getDeclaredMethod("getMainClass", String.class);
+ getMainClassMethod.setAccessible(true);
+ return MethodHandles.lookup().unreflect(getMainClassMethod);
+ } catch (ClassNotFoundException | NoSuchMethodException | SecurityException | IllegalAccessException e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ private static String callGetMainClass(Process p) {
+ try {
+ return (String)MH_GET_MAIN_CLASS.invoke(Long.toString(p.pid()));
+ } catch (Throwable e) {
+ throw new RuntimeException(e);
+ }
+
+ }
+
public static void main(String[] args) throws Exception {
new TestProcessHelper().runTests();
}
@@ -188,7 +211,7 @@
}
private void checkMainClass(Process p, String expectedMainClass) {
- String mainClass = PROCESS_HELPER.getMainClass(Long.toString(p.pid()));
+ String mainClass = callGetMainClass(p);
// getMainClass() may return null, e.g. due to timing issues.
// Attempt some limited retries.
if (mainClass == null) {
@@ -204,7 +227,7 @@
} catch (InterruptedException e) {
// ignore
}
- mainClass = PROCESS_HELPER.getMainClass(Long.toString(p.pid()));
+ mainClass = callGetMainClass(p);
retrycount++;
sleepms *= 2;
}
diff -r e47423f1318b -r ca19b94eac7a test/jdk/tools/launcher/TestSpecialArgs.java
--- a/test/jdk/tools/launcher/TestSpecialArgs.java Mon Sep 23 09:16:05 2019 -0700
+++ b/test/jdk/tools/launcher/TestSpecialArgs.java Wed Sep 25 22:40:41 2019 +0200
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2012, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 2019, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -132,11 +132,9 @@
* Code to create env variable not executed.
* 4) give and invalid value and check to make sure JVM commented
*/
- String launcherPidString = "launcher.pid=";
String envVarPidString = "TRACER_MARKER: NativeMemoryTracking: env var is NMT_LEVEL_";
String NMT_Option_Value = "off";
String myClassName = "helloworld";
- boolean haveLauncherPid = false;
// === Run the tests ===
// ---Test 1a
@@ -163,46 +161,6 @@
throw new RuntimeException("Error: env Var Pid in tracking info is empty string");
}
- /*
- * On Linux, Launcher Tracking will print the PID. Use this info
- * to validate what we got as the PID in the Launcher itself.
- * Linux is the only one that prints this, and trying to get it
- * here for win is awful. So let the linux test make sure we get
- * the valid pid, and for non-linux, just make sure pid string is
- * non-zero.
- */
- if (isLinux) {
- // get what the test says is the launcher pid
- String launcherPid = null;
- for (String line : tr.testOutput) {
- int index = line.indexOf(launcherPidString);
- if (index >= 0) {
- int sindex = index + launcherPidString.length();
- int tindex = sindex + line.substring(sindex).indexOf("'");
- System.out.println("DEBUG INFO: sindex = " + sindex);
- System.out.println("DEBUG INFO: searching substring: " + line.substring(sindex));
- System.out.println("DEBUG INFO: tindex = " + tindex);
- // DEBUG INFO
- System.out.println(tr);
- launcherPid = line.substring(sindex, tindex);
- break;
- }
- }
- if (launcherPid == null) {
- System.out.println(tr);
- throw new RuntimeException("Error: failed to find launcher Pid in launcher tracking info");
- }
-
- // did we create the env var with the correct pid?
- if (!launcherPid.equals(envVarPid)) {
- System.out.println(tr);
- System.out.println("Error: wrong pid in creating env var");
- System.out.println("Error Info: launcherPid = " + launcherPid);
- System.out.println("Error Info: envVarPid = " + envVarPid);
- throw new RuntimeException("Error: wrong pid in creating env var");
- }
- }
-
// --- Test 1b
if (!tr.contains("NativeMemoryTracking: got value " + NMT_Option_Value)) {
System.out.println(tr);
diff -r e47423f1318b -r ca19b94eac7a test/langtools/jdk/javadoc/doclet/testSearchScript/TestSearchScript.java
--- a/test/langtools/jdk/javadoc/doclet/testSearchScript/TestSearchScript.java Mon Sep 23 09:16:05 2019 -0700
+++ b/test/langtools/jdk/javadoc/doclet/testSearchScript/TestSearchScript.java Wed Sep 25 22:40:41 2019 +0200
@@ -149,11 +149,12 @@
checkSearch(inv, "operty", List.of());
// search tag
- checkSearch(inv, "search tag", List.of("search tag"));
- checkSearch(inv, "search tag", List.of("search tag"));
- checkSearch(inv, "search ", List.of("search tag"));
- checkSearch(inv, "tag", List.of("search tag"));
- checkSearch(inv, "sea", List.of("search tag"));
+ checkSearch(inv, "search tag", List.of("multiline search tag", "search tag"));
+ checkSearch(inv, "search tag", List.of("multiline search tag", "search tag"));
+ checkSearch(inv, "search ", List.of("multiline search tag", "search tag"));
+ checkSearch(inv, "tag", List.of("multiline search tag", "search tag"));
+ checkSearch(inv, "sea", List.of("multiline search tag", "search tag"));
+ checkSearch(inv, "multi", List.of("multiline search tag"));
checkSearch(inv, "ear", List.of());
}
@@ -244,7 +245,7 @@
List.of("listpkg.List.of(E, E, E, E)", "listpkg.List.of(E, E, E, E, E)"));
checkSearch(inv, "l . o (e,e,e,",
List.of("listpkg.List.of(E, E, E, E)", "listpkg.List.of(E, E, E, E, E)"));
- checkSearch(inv, "search \tt", List.of("search tag"));
+ checkSearch(inv, "search \tt", List.of("other search tag"));
checkSearch(inv, "sear ch", List.of());
checkSearch(inv, "( e ..", List.of("listpkg.List.of(E...)"));
checkSearch(inv, "( i [ ]", List.of("listpkg.Nolist.withArrayArg(int[])"));
diff -r e47423f1318b -r ca19b94eac7a test/langtools/jdk/javadoc/doclet/testSearchScript/listpkg/Nolist.java
--- a/test/langtools/jdk/javadoc/doclet/testSearchScript/listpkg/Nolist.java Mon Sep 23 09:16:05 2019 -0700
+++ b/test/langtools/jdk/javadoc/doclet/testSearchScript/listpkg/Nolist.java Wed Sep 25 22:40:41 2019 +0200
@@ -27,9 +27,8 @@
import java.util.Map;
/**
- * Example class containing "list" but not matching at any word boundary.
- *
- * {@index "search tag"}.
+ * Example class containing "list" but not matching at any word boundary. {@index "other
+ * search tag"}.
*/
public class Nolist {
diff -r e47423f1318b -r ca19b94eac7a test/langtools/jdk/javadoc/doclet/testSearchScript/mapmodule/mappkg/Map.java
--- a/test/langtools/jdk/javadoc/doclet/testSearchScript/mapmodule/mappkg/Map.java Mon Sep 23 09:16:05 2019 -0700
+++ b/test/langtools/jdk/javadoc/doclet/testSearchScript/mapmodule/mappkg/Map.java Wed Sep 25 22:40:41 2019 +0200
@@ -25,6 +25,13 @@
import java.util.Iterator;
+/**
+ * Map interface.
+ *
+ * {@index "multiline
+ * search
+ * tag"}
+ */
public interface Map {
public void put(Object key, Object value);
public boolean contains(Object key);