For example, here is an initial version of a class that uses
- * divide-by-two recursive decomposition to divide work into single
- * pieces (leaf tasks). Even when work is split into individual calls,
- * tree-based techniques are usually preferable to directly forking
- * leaf tasks, because they reduce inter-thread communication and
- * improve load balancing. In the recursive case, the second of each
- * pair of subtasks to finish triggers completion of its parent
+ *
For example, here is an initial version of a utility method that
+ * uses divide-by-two recursive decomposition to divide work into
+ * single pieces (leaf tasks). Even when work is split into individual
+ * calls, tree-based techniques are usually preferable to directly
+ * forking leaf tasks, because they reduce inter-thread communication
+ * and improve load balancing. In the recursive case, the second of
+ * each pair of subtasks to finish triggers completion of their parent
* (because no result combination is performed, the default no-op
* implementation of method {@code onCompletion} is not overridden).
- * A static utility method sets up the base task and invokes it
- * (here, implicitly using the {@link ForkJoinPool#commonPool()}).
+ * The utility method sets up the root task and invokes it (here,
+ * implicitly using the {@link ForkJoinPool#commonPool()}). It is
+ * straightforward and reliable (but not optimal) to always set the
+ * pending count to the number of child tasks and call {@code
+ * tryComplete()} immediately before returning.
*
*
The common pool is by default constructed with default
- * parameters, but these may be controlled by setting three
+ * parameters, but these may be controlled by setting the following
* {@linkplain System#getProperty system properties}:
*
* - {@code java.util.concurrent.ForkJoinPool.common.parallelism}
@@ -3241,7 +3241,7 @@ public class ForkJoinPool extends AbstractExecutorService {
* An ACC to restrict permissions for the factory itself.
* The constructed workers have no permissions set.
*/
- private static final AccessControlContext innocuousAcc;
+ private static final AccessControlContext INNOCUOUS_ACC;
static {
Permissions innocuousPerms = new Permissions();
innocuousPerms.add(modifyThreadPermission);
@@ -3249,7 +3249,7 @@ public class ForkJoinPool extends AbstractExecutorService {
"enableContextClassLoaderOverride"));
innocuousPerms.add(new RuntimePermission(
"modifyThreadGroup"));
- innocuousAcc = new AccessControlContext(new ProtectionDomain[] {
+ INNOCUOUS_ACC = new AccessControlContext(new ProtectionDomain[] {
new ProtectionDomain(null, innocuousPerms)
});
}
@@ -3260,7 +3260,7 @@ public class ForkJoinPool extends AbstractExecutorService {
public ForkJoinWorkerThread run() {
return new ForkJoinWorkerThread.
InnocuousForkJoinWorkerThread(pool);
- }}, innocuousAcc);
+ }}, INNOCUOUS_ACC);
}
}
diff --git a/jdk/src/java.base/share/classes/java/util/concurrent/Semaphore.java b/jdk/src/java.base/share/classes/java/util/concurrent/Semaphore.java
index 1298a6ee30d..f73c7fe2d5a 100644
--- a/jdk/src/java.base/share/classes/java/util/concurrent/Semaphore.java
+++ b/jdk/src/java.base/share/classes/java/util/concurrent/Semaphore.java
@@ -72,8 +72,8 @@ import java.util.concurrent.locks.AbstractQueuedSynchronizer;
* protected synchronized Object getNextAvailableItem() {
* for (int i = 0; i < MAX_AVAILABLE; ++i) {
* if (!used[i]) {
- * used[i] = true;
- * return items[i];
+ * used[i] = true;
+ * return items[i];
* }
* }
* return null; // not reached
@@ -82,11 +82,11 @@ import java.util.concurrent.locks.AbstractQueuedSynchronizer;
* protected synchronized boolean markAsUnused(Object item) {
* for (int i = 0; i < MAX_AVAILABLE; ++i) {
* if (item == items[i]) {
- * if (used[i]) {
- * used[i] = false;
- * return true;
- * } else
- * return false;
+ * if (used[i]) {
+ * used[i] = false;
+ * return true;
+ * } else
+ * return false;
* }
* }
* return false;
diff --git a/jdk/src/java.base/share/classes/java/util/concurrent/SubmissionPublisher.java b/jdk/src/java.base/share/classes/java/util/concurrent/SubmissionPublisher.java
index b59887d415c..5d96cae3f82 100644
--- a/jdk/src/java.base/share/classes/java/util/concurrent/SubmissionPublisher.java
+++ b/jdk/src/java.base/share/classes/java/util/concurrent/SubmissionPublisher.java
@@ -554,8 +554,9 @@ public class SubmissionPublisher implements Flow.Publisher,
while (r != null) {
BufferedSubscription nextRetry = r.nextRetry;
r.nextRetry = null;
- int stat = (nanos > 0L) ? r.timedOffer(item, nanos) :
- r.offer(item);
+ int stat = (nanos > 0L)
+ ? r.timedOffer(item, nanos)
+ : r.offer(item);
if (stat == 0 && onDrop != null &&
onDrop.test(r.subscriber, item))
stat = r.offer(item);
diff --git a/jdk/src/java.base/share/classes/java/util/concurrent/ThreadPoolExecutor.java b/jdk/src/java.base/share/classes/java/util/concurrent/ThreadPoolExecutor.java
index d947a87cbd5..0016bfffe87 100644
--- a/jdk/src/java.base/share/classes/java/util/concurrent/ThreadPoolExecutor.java
+++ b/jdk/src/java.base/share/classes/java/util/concurrent/ThreadPoolExecutor.java
@@ -617,6 +617,9 @@ public class ThreadPoolExecutor extends AbstractExecutorService {
/** Per-thread task counter */
volatile long completedTasks;
+ // TODO: switch to AbstractQueuedLongSynchronizer and move
+ // completedTasks into the lock word.
+
/**
* Creates with given first task and thread from ThreadFactory.
* @param firstTask the first task (null if none)
diff --git a/jdk/src/java.base/share/classes/java/util/concurrent/atomic/AtomicInteger.java b/jdk/src/java.base/share/classes/java/util/concurrent/atomic/AtomicInteger.java
index c7fa1c66e52..4e4c51eb53a 100644
--- a/jdk/src/java.base/share/classes/java/util/concurrent/atomic/AtomicInteger.java
+++ b/jdk/src/java.base/share/classes/java/util/concurrent/atomic/AtomicInteger.java
@@ -193,7 +193,7 @@ public class AtomicInteger extends Number implements java.io.Serializable {
/**
* Atomically increments the current value,
- * with memory effects as specified by {@link VarHandle#addAndGet}.
+ * with memory effects as specified by {@link VarHandle#getAndAdd}.
*
*
Equivalent to {@code addAndGet(1)}.
*
@@ -205,7 +205,7 @@ public class AtomicInteger extends Number implements java.io.Serializable {
/**
* Atomically decrements the current value,
- * with memory effects as specified by {@link VarHandle#addAndGet}.
+ * with memory effects as specified by {@link VarHandle#getAndAdd}.
*
*
Equivalent to {@code addAndGet(-1)}.
*
diff --git a/jdk/src/java.base/share/classes/java/util/concurrent/locks/StampedLock.java b/jdk/src/java.base/share/classes/java/util/concurrent/locks/StampedLock.java
index 8b9d401ee10..18fac82b111 100644
--- a/jdk/src/java.base/share/classes/java/util/concurrent/locks/StampedLock.java
+++ b/jdk/src/java.base/share/classes/java/util/concurrent/locks/StampedLock.java
@@ -154,13 +154,13 @@ import jdk.internal.vm.annotation.ReservedStackAccess;
* long stamp = sl.tryOptimisticRead();
* double currentX = x, currentY = y;
* if (!sl.validate(stamp)) {
- * stamp = sl.readLock();
- * try {
- * currentX = x;
- * currentY = y;
- * } finally {
- * sl.unlockRead(stamp);
- * }
+ * stamp = sl.readLock();
+ * try {
+ * currentX = x;
+ * currentY = y;
+ * } finally {
+ * sl.unlockRead(stamp);
+ * }
* }
* return Math.sqrt(currentX * currentX + currentY * currentY);
* }
diff --git a/jdk/src/java.base/share/classes/java/util/jar/JarFile.java b/jdk/src/java.base/share/classes/java/util/jar/JarFile.java
index 2c4500d169b..6b3abf50d78 100644
--- a/jdk/src/java.base/share/classes/java/util/jar/JarFile.java
+++ b/jdk/src/java.base/share/classes/java/util/jar/JarFile.java
@@ -536,19 +536,6 @@ class JarFile extends ZipFile {
* @return an ordered {@code Stream} of entries in this jar file
* @throws IllegalStateException if the jar file has been closed
* @since 1.8
- *
- * @apiNote A versioned view of the stream obtained from a {@code JarFile}
- * configured to process a multi-release jar file can be created with code
- * similar to the following:
- *
- * {@code
- * Stream versionedStream(JarFile jf) {
- * return jf.stream().map(JarEntry::getName)
- * .filter(name -> !name.startsWith("META-INF/versions/"))
- * .map(jf::getJarEntry);
- * }
- * }
- *
*/
public Stream stream() {
return StreamSupport.stream(Spliterators.spliterator(
@@ -571,7 +558,7 @@ class JarFile extends ZipFile {
private ZipEntry getVersionedEntry(ZipEntry ze) {
ZipEntry vze = null;
- if (BASE_VERSION_MAJOR < versionMajor && !ze.isDirectory()) {
+ if (BASE_VERSION_MAJOR < versionMajor) {
String name = ze.getName();
if (!name.startsWith(META_INF)) {
vze = searchForVersionedEntry(versionMajor, name);
@@ -836,18 +823,25 @@ class JarFile extends ZipFile {
private static final byte[] CLASSPATH_CHARS =
{'C','L','A','S','S','-','P','A','T','H', ':', ' '};
- // The bad character shift for "class-path:"
+ // The bad character shift for "class-path: "
private static final byte[] CLASSPATH_LASTOCC;
+ // The good suffix shift for "class-path: "
+ private static final byte[] CLASSPATH_OPTOSFT;
+
private static final byte[] MULTIRELEASE_CHARS =
{'M','U','L','T','I','-','R','E','L','E', 'A', 'S', 'E', ':',
' ', 'T', 'R', 'U', 'E'};
- // The bad character shift for "multi-release: "
+ // The bad character shift for "multi-release: true"
private static final byte[] MULTIRELEASE_LASTOCC;
+ // The good suffix shift for "multi-release: true"
+ private static final byte[] MULTIRELEASE_OPTOSFT;
+
static {
CLASSPATH_LASTOCC = new byte[64];
+ CLASSPATH_OPTOSFT = new byte[12];
CLASSPATH_LASTOCC[(int)'C' - 32] = 1;
CLASSPATH_LASTOCC[(int)'L' - 32] = 2;
CLASSPATH_LASTOCC[(int)'S' - 32] = 5;
@@ -858,8 +852,13 @@ class JarFile extends ZipFile {
CLASSPATH_LASTOCC[(int)'H' - 32] = 10;
CLASSPATH_LASTOCC[(int)':' - 32] = 11;
CLASSPATH_LASTOCC[(int)' ' - 32] = 12;
+ for (int i = 0; i < 11; i++) {
+ CLASSPATH_OPTOSFT[i] = 12;
+ }
+ CLASSPATH_OPTOSFT[11] = 1;
MULTIRELEASE_LASTOCC = new byte[64];
+ MULTIRELEASE_OPTOSFT = new byte[19];
MULTIRELEASE_LASTOCC[(int)'M' - 32] = 1;
MULTIRELEASE_LASTOCC[(int)'I' - 32] = 5;
MULTIRELEASE_LASTOCC[(int)'-' - 32] = 6;
@@ -872,6 +871,11 @@ class JarFile extends ZipFile {
MULTIRELEASE_LASTOCC[(int)'R' - 32] = 17;
MULTIRELEASE_LASTOCC[(int)'U' - 32] = 18;
MULTIRELEASE_LASTOCC[(int)'E' - 32] = 19;
+ for (int i = 0; i < 17; i++) {
+ MULTIRELEASE_OPTOSFT[i] = 19;
+ }
+ MULTIRELEASE_OPTOSFT[17] = 6;
+ MULTIRELEASE_OPTOSFT[18] = 1;
}
private JarEntry getManEntry() {
@@ -913,7 +917,7 @@ class JarFile extends ZipFile {
* Since there are no repeated substring in our search strings,
* the good suffix shifts can be replaced with a comparison.
*/
- private int match(byte[] src, byte[] b, byte[] lastOcc) {
+ private int match(byte[] src, byte[] b, byte[] lastOcc, byte[] optoSft) {
int len = src.length;
int last = b.length - len;
int i = 0;
@@ -926,9 +930,8 @@ class JarFile extends ZipFile {
if (c != src[j]) {
// no match
- int goodShift = (j < len - 1) ? len : 1;
int badShift = lastOcc[c - 32];
- i += Math.max(j + 1 - badShift, goodShift);
+ i += Math.max(j + 1 - badShift, optoSft[j]);
continue next;
}
} else {
@@ -958,10 +961,11 @@ class JarFile extends ZipFile {
if (manEntry != null) {
byte[] b = getBytes(manEntry);
hasClassPathAttribute = match(CLASSPATH_CHARS, b,
- CLASSPATH_LASTOCC) != -1;
+ CLASSPATH_LASTOCC, CLASSPATH_OPTOSFT) != -1;
// is this a multi-release jar file
if (MULTI_RELEASE_ENABLED) {
- int i = match(MULTIRELEASE_CHARS, b, MULTIRELEASE_LASTOCC);
+ int i = match(MULTIRELEASE_CHARS, b, MULTIRELEASE_LASTOCC,
+ MULTIRELEASE_OPTOSFT);
if (i != -1) {
i += MULTIRELEASE_CHARS.length;
if (i < b.length) {
diff --git a/jdk/src/java.base/share/classes/jdk/internal/util/jar/VersionedStream.java b/jdk/src/java.base/share/classes/jdk/internal/util/jar/VersionedStream.java
new file mode 100644
index 00000000000..3eb33a428c6
--- /dev/null
+++ b/jdk/src/java.base/share/classes/jdk/internal/util/jar/VersionedStream.java
@@ -0,0 +1,85 @@
+/*
+ * Copyright (c) 2016, 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. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * 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.
+ */
+
+package jdk.internal.util.jar;
+
+import java.util.Objects;
+import java.util.jar.JarEntry;
+import java.util.jar.JarFile;
+import java.util.stream.Stream;
+
+public class VersionedStream {
+ private static final String META_INF_VERSIONS = "META-INF/versions/";
+
+ /**
+ * Returns a stream of versioned entries, derived from the base names of
+ * all entries in a multi-release {@code JarFile} that are present either in
+ * the base directory or in any versioned directory with a version number
+ * less than or equal to the {@code Runtime.Version::major} that the
+ * {@code JarFile} was opened with. These versioned entries are aliases
+ * for the real entries -- i.e. the names are base names and the content
+ * may come from a versioned directory entry. If the {@code jarFile} is not
+ * a multi-release jar, a stream of all entries is returned.
+ *
+ * @param jf the input JarFile
+ * @return stream of entries
+ * @since 9
+ */
+ public static Stream stream(JarFile jf) {
+ if (jf.isMultiRelease()) {
+ int version = jf.getVersion().major();
+ return jf.stream()
+ .map(je -> getBaseSuffix(je, version))
+ .filter(Objects::nonNull)
+ .distinct()
+ .map(jf::getJarEntry);
+ }
+ return jf.stream();
+ }
+
+ private static String getBaseSuffix(JarEntry je, int version) {
+ String name = je.getName();
+ if (name.startsWith(META_INF_VERSIONS)) {
+ int len = META_INF_VERSIONS.length();
+ int index = name.indexOf('/', len);
+ if (index == -1 || index == (name.length() - 1)) {
+ // filter out META-INF/versions/* and META-INF/versions/*/
+ return null;
+ }
+ try {
+ if (Integer.parseInt(name, len, index, 10) > version) {
+ // not an integer
+ return null;
+ }
+ } catch (NumberFormatException x) {
+ // silently remove malformed entries
+ return null;
+ }
+ // We know name looks like META-INF/versions/*/*
+ return name.substring(index + 1);
+ }
+ return name;
+ }
+}
diff --git a/jdk/src/java.base/share/classes/module-info.java b/jdk/src/java.base/share/classes/module-info.java
index ae5ebbbb070..f49111be646 100644
--- a/jdk/src/java.base/share/classes/module-info.java
+++ b/jdk/src/java.base/share/classes/module-info.java
@@ -143,7 +143,8 @@ module java.base {
exports jdk.internal.org.objectweb.asm.signature to
jdk.scripting.nashorn;
exports jdk.internal.loader to
- java.instrument;
+ java.instrument,
+ java.logging;
exports jdk.internal.math to
java.desktop;
exports jdk.internal.module to
diff --git a/jdk/src/java.base/share/classes/sun/net/www/protocol/jar/JarURLConnection.java b/jdk/src/java.base/share/classes/sun/net/www/protocol/jar/JarURLConnection.java
index daa56325e2f..fb12cf77626 100644
--- a/jdk/src/java.base/share/classes/sun/net/www/protocol/jar/JarURLConnection.java
+++ b/jdk/src/java.base/share/classes/sun/net/www/protocol/jar/JarURLConnection.java
@@ -125,7 +125,9 @@ public class JarURLConnection extends java.net.JarURLConnection {
* to get the jarFile, and set it as our permission.
*/
if (getUseCaches()) {
+ boolean oldUseCaches = jarFileURLConnection.getUseCaches();
jarFileURLConnection = factory.getConnection(jarFile);
+ jarFileURLConnection.setUseCaches(oldUseCaches);
}
if ((entryName != null)) {
diff --git a/jdk/src/java.base/share/classes/sun/security/provider/certpath/OCSP.java b/jdk/src/java.base/share/classes/sun/security/provider/certpath/OCSP.java
index 2d917d0604e..ad805e60b41 100644
--- a/jdk/src/java.base/share/classes/sun/security/provider/certpath/OCSP.java
+++ b/jdk/src/java.base/share/classes/sun/security/provider/certpath/OCSP.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2009, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2009, 2016, 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
@@ -125,7 +125,7 @@ public final class OCSP {
("Exception while encoding OCSPRequest", e);
}
OCSPResponse ocspResponse = check(Collections.singletonList(certId),
- responderURI, issuerCert, null, null,
+ responderURI, new OCSPResponse.IssuerInfo(issuerCert), null, null,
Collections.emptyList());
return (RevocationStatus)ocspResponse.getSingleResponse(certId);
}
@@ -173,7 +173,8 @@ public final class OCSP {
("Exception while encoding OCSPRequest", e);
}
OCSPResponse ocspResponse = check(Collections.singletonList(certId),
- responderURI, issuerCert, responderCert, date, extensions);
+ responderURI, new OCSPResponse.IssuerInfo(issuerCert),
+ responderCert, date, extensions);
return (RevocationStatus) ocspResponse.getSingleResponse(certId);
}
@@ -182,7 +183,7 @@ public final class OCSP {
*
* @param certIds the CertIds to be checked
* @param responderURI the URI of the OCSP responder
- * @param issuerCert the issuer's certificate
+ * @param issuerInfo the issuer's certificate and/or subject and public key
* @param responderCert the OCSP responder's certificate
* @param date the time the validity of the OCSP responder's certificate
* should be checked against. If null, the current time is used.
@@ -195,8 +196,8 @@ public final class OCSP {
* @throws CertPathValidatorException if an exception occurs while
* encoding the OCSP Request or validating the OCSP Response
*/
- static OCSPResponse check(List certIds, URI responderURI,
- X509Certificate issuerCert,
+ static OCSPResponse check(List certIds, URI responderURI,
+ OCSPResponse.IssuerInfo issuerInfo,
X509Certificate responderCert, Date date,
List extensions)
throws IOException, CertPathValidatorException
@@ -214,7 +215,7 @@ public final class OCSP {
ocspResponse = new OCSPResponse(response);
// verify the response
- ocspResponse.verify(certIds, issuerCert, responderCert, date,
+ ocspResponse.verify(certIds, issuerInfo, responderCert, date,
nonce);
} catch (IOException ioe) {
throw new CertPathValidatorException(
diff --git a/jdk/src/java.base/share/classes/sun/security/provider/certpath/OCSPResponse.java b/jdk/src/java.base/share/classes/sun/security/provider/certpath/OCSPResponse.java
index 0ef14abc68a..a2b74d1bdeb 100644
--- a/jdk/src/java.base/share/classes/sun/security/provider/certpath/OCSPResponse.java
+++ b/jdk/src/java.base/share/classes/sun/security/provider/certpath/OCSPResponse.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2003, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2016, 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
@@ -41,6 +41,7 @@ import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
+import java.util.Objects;
import java.util.Set;
import javax.security.auth.x500.X500Principal;
@@ -373,8 +374,8 @@ public final class OCSPResponse {
}
}
- void verify(List certIds, X509Certificate issuerCert,
- X509Certificate responderCert, Date date, byte[] nonce)
+ void verify(List certIds, IssuerInfo issuerInfo,
+ X509Certificate responderCert, Date date, byte[] nonce)
throws CertPathValidatorException
{
switch (responseStatus) {
@@ -414,7 +415,9 @@ public final class OCSPResponse {
// Add the Issuing CA cert and/or Trusted Responder cert to the list
// of certs from the OCSP response
try {
- certs.add(X509CertImpl.toImpl(issuerCert));
+ if (issuerInfo.getCertificate() != null) {
+ certs.add(X509CertImpl.toImpl(issuerInfo.getCertificate()));
+ }
if (responderCert != null) {
certs.add(X509CertImpl.toImpl(responderCert));
}
@@ -464,7 +467,10 @@ public final class OCSPResponse {
// Check whether the signer cert returned by the responder is trusted
if (signerCert != null) {
// Check if the response is signed by the issuing CA
- if (signerCert.equals(issuerCert)) {
+ if (signerCert.getSubjectX500Principal().equals(
+ issuerInfo.getName()) &&
+ signerCert.getPublicKey().equals(
+ issuerInfo.getPublicKey())) {
if (debug != null) {
debug.println("OCSP response is signed by the target's " +
"Issuing CA");
@@ -481,7 +487,7 @@ public final class OCSPResponse {
// Check if the response is signed by an authorized responder
} else if (signerCert.getIssuerX500Principal().equals(
- issuerCert.getSubjectX500Principal())) {
+ issuerInfo.getName())) {
// Check for the OCSPSigning key purpose
try {
@@ -502,7 +508,8 @@ public final class OCSPResponse {
// Check algorithm constraints specified in security property
// "jdk.certpath.disabledAlgorithms".
AlgorithmChecker algChecker = new AlgorithmChecker(
- new TrustAnchor(issuerCert, null));
+ new TrustAnchor(issuerInfo.getName(),
+ issuerInfo.getPublicKey(), null));
algChecker.init(false);
algChecker.check(signerCert, Collections.emptySet());
@@ -540,7 +547,7 @@ public final class OCSPResponse {
// verify the signature
try {
- signerCert.verify(issuerCert.getPublicKey());
+ signerCert.verify(issuerInfo.getPublicKey());
if (debug != null) {
debug.println("OCSP response is signed by an " +
"Authorized Responder");
@@ -971,4 +978,86 @@ public final class OCSPResponse {
return sb.toString();
}
}
+
+ /**
+ * Helper class that allows consumers to pass in issuer information. This
+ * will always consist of the issuer's name and public key, but may also
+ * contain a certificate if the originating data is in that form.
+ */
+ static final class IssuerInfo {
+ private final X509Certificate certificate;
+ private final X500Principal name;
+ private final PublicKey pubKey;
+
+ IssuerInfo(X509Certificate issuerCert) {
+ certificate = Objects.requireNonNull(issuerCert,
+ "Constructor requires non-null certificate");
+ name = certificate.getSubjectX500Principal();
+ pubKey = certificate.getPublicKey();
+ }
+
+ IssuerInfo(X500Principal subjectName, PublicKey key) {
+ certificate = null;
+ name = Objects.requireNonNull(subjectName,
+ "Constructor requires non-null subject");
+ pubKey = Objects.requireNonNull(key,
+ "Constructor requires non-null public key");
+ }
+
+ IssuerInfo(TrustAnchor anchor) {
+ certificate = anchor.getTrustedCert();
+ if (certificate != null) {
+ name = certificate.getSubjectX500Principal();
+ pubKey = certificate.getPublicKey();
+ } else {
+ name = anchor.getCA();
+ pubKey = anchor.getCAPublicKey();
+ }
+ }
+
+ /**
+ * Get the certificate in this IssuerInfo if present.
+ *
+ * @return the {@code X509Certificate} used to create this IssuerInfo
+ * object, or {@code null} if a certificate was not used in its
+ * creation.
+ */
+ X509Certificate getCertificate() {
+ return certificate;
+ }
+
+ /**
+ * Get the name of this issuer.
+ *
+ * @return an {@code X500Principal} corresponding to this issuer's
+ * name. If derived from an issuer's {@code X509Certificate} this
+ * would be equivalent to the certificate subject name.
+ */
+ X500Principal getName() {
+ return name;
+ }
+
+ /**
+ * Get the public key for this issuer.
+ *
+ * @return a {@code PublicKey} for this issuer.
+ */
+ PublicKey getPublicKey() {
+ return pubKey;
+ }
+
+ /**
+ * Create a string representation of this IssuerInfo.
+ *
+ * @return a {@code String} form of this IssuerInfo object.
+ */
+ @Override
+ public String toString() {
+ StringBuilder sb = new StringBuilder();
+ sb.append("Issuer Info:\n");
+ sb.append("Name: ").append(name.toString()).append("\n");
+ sb.append("Public Key:\n").append(pubKey.toString()).append("\n");
+ return sb.toString();
+ }
+ }
}
diff --git a/jdk/src/java.base/share/classes/sun/security/provider/certpath/RevocationChecker.java b/jdk/src/java.base/share/classes/sun/security/provider/certpath/RevocationChecker.java
index 002a6c37776..e3de6a959e7 100644
--- a/jdk/src/java.base/share/classes/sun/security/provider/certpath/RevocationChecker.java
+++ b/jdk/src/java.base/share/classes/sun/security/provider/certpath/RevocationChecker.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2012, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 2016, 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
@@ -61,12 +61,12 @@ class RevocationChecker extends PKIXRevocationChecker {
private List certStores;
private Map ocspResponses;
private List ocspExtensions;
- private boolean legacy;
+ private final boolean legacy;
private LinkedList softFailExceptions =
new LinkedList<>();
// state variables
- private X509Certificate issuerCert;
+ private OCSPResponse.IssuerInfo issuerInfo;
private PublicKey prevPubKey;
private boolean crlSignFlag;
private int certIndex;
@@ -301,9 +301,9 @@ class RevocationChecker extends PKIXRevocationChecker {
CertPathValidatorException("forward checking not supported");
}
if (anchor != null) {
- issuerCert = anchor.getTrustedCert();
- prevPubKey = (issuerCert != null) ? issuerCert.getPublicKey()
- : anchor.getCAPublicKey();
+ issuerInfo = new OCSPResponse.IssuerInfo(anchor);
+ prevPubKey = issuerInfo.getPublicKey();
+
}
crlSignFlag = true;
if (params != null && params.certPath() != null) {
@@ -437,7 +437,7 @@ class RevocationChecker extends PKIXRevocationChecker {
private void updateState(X509Certificate cert)
throws CertPathValidatorException
{
- issuerCert = cert;
+ issuerInfo = new OCSPResponse.IssuerInfo(cert);
// Make new public key if parameters are missing
PublicKey pubKey = cert.getPublicKey();
@@ -708,14 +708,8 @@ class RevocationChecker extends PKIXRevocationChecker {
OCSPResponse response = null;
CertId certId = null;
try {
- if (issuerCert != null) {
- certId = new CertId(issuerCert,
- currCert.getSerialNumberObject());
- } else {
- // must be an anchor name and key
- certId = new CertId(anchor.getCA(), anchor.getCAPublicKey(),
- currCert.getSerialNumberObject());
- }
+ certId = new CertId(issuerInfo.getName(), issuerInfo.getPublicKey(),
+ currCert.getSerialNumberObject());
// check if there is a cached OCSP response available
byte[] responseBytes = ocspResponses.get(cert);
@@ -732,8 +726,8 @@ class RevocationChecker extends PKIXRevocationChecker {
nonce = ext.getValue();
}
}
- response.verify(Collections.singletonList(certId), issuerCert,
- responderCert, params.date(), nonce);
+ response.verify(Collections.singletonList(certId), issuerInfo,
+ responderCert, params.date(), nonce);
} else {
URI responderURI = (this.responderURI != null)
@@ -746,8 +740,8 @@ class RevocationChecker extends PKIXRevocationChecker {
}
response = OCSP.check(Collections.singletonList(certId),
- responderURI, issuerCert, responderCert,
- null, ocspExtensions);
+ responderURI, issuerInfo,
+ responderCert, null, ocspExtensions);
}
} catch (IOException e) {
throw new CertPathValidatorException(
diff --git a/jdk/src/java.base/share/classes/sun/util/locale/provider/BreakDictionary.java b/jdk/src/java.base/share/classes/sun/util/locale/provider/BreakDictionary.java
index ddb4bb53f2c..4be1363b58f 100644
--- a/jdk/src/java.base/share/classes/sun/util/locale/provider/BreakDictionary.java
+++ b/jdk/src/java.base/share/classes/sun/util/locale/provider/BreakDictionary.java
@@ -149,7 +149,10 @@ class BreakDictionary {
BufferedInputStream in;
try {
PrivilegedExceptionAction pa = () -> {
- InputStream is = module.getResourceAsStream("sun/text/resources/" + dictionaryName);
+ String pathName = "jdk.localedata".equals(module.getName()) ?
+ "sun/text/resources/ext/" :
+ "sun/text/resources/";
+ InputStream is = module.getResourceAsStream(pathName + dictionaryName);
if (is == null) {
// Try to load the file with "java.base" module instance. Assumption
// here is that the fall back data files to be read should reside in
diff --git a/jdk/src/java.base/share/classes/sun/util/locale/provider/RuleBasedBreakIterator.java b/jdk/src/java.base/share/classes/sun/util/locale/provider/RuleBasedBreakIterator.java
index 7c00ee052f1..ebf6ba1956e 100644
--- a/jdk/src/java.base/share/classes/sun/util/locale/provider/RuleBasedBreakIterator.java
+++ b/jdk/src/java.base/share/classes/sun/util/locale/provider/RuleBasedBreakIterator.java
@@ -444,7 +444,10 @@ class RuleBasedBreakIterator extends BreakIterator {
BufferedInputStream is;
try {
PrivilegedExceptionAction pa = () -> {
- InputStream in = module.getResourceAsStream("sun/text/resources/" + datafile);
+ String pathName = "jdk.localedata".equals(module.getName()) ?
+ "sun/text/resources/ext/" :
+ "sun/text/resources/";
+ InputStream in = module.getResourceAsStream(pathName + datafile);
if (in == null) {
// Try to load the file with "java.base" module instance. Assumption
// here is that the fall back data files to be read should reside in
diff --git a/jdk/src/java.base/share/native/libjli/java.h b/jdk/src/java.base/share/native/libjli/java.h
index 41a232714c8..b5056de84a9 100644
--- a/jdk/src/java.base/share/native/libjli/java.h
+++ b/jdk/src/java.base/share/native/libjli/java.h
@@ -112,6 +112,9 @@ GetXUsagePath(char *buf, jint bufsize);
jboolean
GetApplicationHome(char *buf, jint bufsize);
+jboolean
+GetApplicationHomeFromDll(char *buf, jint bufsize);
+
#define GetArch() GetArchPath(CURRENT_DATA_MODEL)
/*
diff --git a/jdk/src/java.base/solaris/native/libnet/solaris_close.c b/jdk/src/java.base/solaris/native/libnet/solaris_close.c
index 0cf7b5c96fc..091dc00d251 100644
--- a/jdk/src/java.base/solaris/native/libnet/solaris_close.c
+++ b/jdk/src/java.base/solaris/native/libnet/solaris_close.c
@@ -35,7 +35,7 @@
if (1) { \
do { \
_result = _cmd; \
- } while((_result == -1) && (errno == EINTR)); \
+ } while((_result == -1) && (errno == EINTR)); \
return _result; \
} \
} while(0)
@@ -44,6 +44,10 @@ int NET_Read(int s, void* buf, size_t len) {
RESTARTABLE_RETURN_INT(recv(s, buf, len, 0));
}
+int NET_NonBlockingRead(int s, void* buf, size_t len) {
+ RESTARTABLE_RETURN_INT(recv(s, buf, len, MSG_DONTWAIT));
+}
+
int NET_RecvFrom(int s, void *buf, int len, unsigned int flags,
struct sockaddr *from, socklen_t *fromlen) {
RESTARTABLE_RETURN_INT(recvfrom(s, buf, len, flags, from, fromlen));
@@ -86,19 +90,14 @@ int NET_Poll(struct pollfd *ufds, unsigned int nfds, int timeout) {
RESTARTABLE_RETURN_INT(poll(ufds, nfds, timeout));
}
-int NET_Timeout(int s, long timeout) {
+int NET_Timeout0(int s, long timeout, long currentTime) {
int result;
struct timeval t;
- long prevtime, newtime;
+ long prevtime = currentTime, newtime;
struct pollfd pfd;
pfd.fd = s;
pfd.events = POLLIN;
- if (timeout > 0) {
- gettimeofday(&t, NULL);
- prevtime = (t.tv_sec * 1000) + t.tv_usec / 1000;
- }
-
for(;;) {
result = poll(&pfd, 1, timeout);
if (result < 0 && errno == EINTR) {
diff --git a/jdk/src/java.base/unix/native/libjli/java_md_common.c b/jdk/src/java.base/unix/native/libjli/java_md_common.c
index 48c0d8b377e..3c3c4bda969 100644
--- a/jdk/src/java.base/unix/native/libjli/java_md_common.c
+++ b/jdk/src/java.base/unix/native/libjli/java_md_common.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2012, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 2016, 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
@@ -25,8 +25,49 @@
#include "java.h"
/*
- * If app is "/foo/bin/javac", or "/foo/bin/sparcv9/javac" then put
- * "/foo" into buf.
+ * Find the last occurrence of a string
+ */
+char* findLastPathComponent(char *buffer, const char *comp) {
+ char* t = buffer;
+ char* p = NULL;
+ size_t l = JLI_StrLen(comp);
+ t = JLI_StrStr(t, comp);
+
+ while (t != NULL) {
+ p = t;
+ t += l;
+ t = JLI_StrStr(t, comp);
+ }
+ return p;
+}
+
+/*
+ * Removes the trailing file name and any intermediate platform
+ * directories, if any, and its enclosing directory.
+ * Ex: if a buffer contains "/foo/bin/javac" or "/foo/bin/x64/javac", the
+ * truncated resulting buffer will contain "/foo".
+ */
+jboolean
+TruncatePath(char *buf)
+{
+ // try bin directory, maybe an executable
+ char *p = findLastPathComponent(buf, "/bin/");
+ if (p != NULL) {
+ *p = '\0';
+ return JNI_TRUE;
+ }
+ // try lib directory, maybe a library
+ p = findLastPathComponent(buf, "/lib/");
+ if (p != NULL) {
+ *p = '\0';
+ return JNI_TRUE;
+ }
+ return JNI_FALSE;
+}
+
+/*
+ * Retrieves the path to the JRE home by locating the executable file
+ * of the current process and then truncating the path to the executable
*/
jboolean
GetApplicationHome(char *buf, jint bufsize)
@@ -38,26 +79,27 @@ GetApplicationHome(char *buf, jint bufsize)
} else {
return JNI_FALSE;
}
-
- if (JLI_StrRChr(buf, '/') == 0) {
- buf[0] = '\0';
- return JNI_FALSE;
- }
- *(JLI_StrRChr(buf, '/')) = '\0'; /* executable file */
- if (JLI_StrLen(buf) < 4 || JLI_StrRChr(buf, '/') == 0) {
- buf[0] = '\0';
- return JNI_FALSE;
- }
- if (JLI_StrCmp("/bin", buf + JLI_StrLen(buf) - 4) != 0)
- *(JLI_StrRChr(buf, '/')) = '\0'; /* sparcv9 or amd64 */
- if (JLI_StrLen(buf) < 4 || JLI_StrCmp("/bin", buf + JLI_StrLen(buf) - 4) != 0) {
- buf[0] = '\0';
- return JNI_FALSE;
- }
- *(JLI_StrRChr(buf, '/')) = '\0'; /* bin */
-
- return JNI_TRUE;
+ return TruncatePath(buf);
}
+
+/*
+ * Retrieves the path to the JRE home by locating the
+ * shared library and then truncating the path to it.
+ */
+jboolean
+GetApplicationHomeFromDll(char *buf, jint bufsize)
+{
+ /* try to find ourselves instead */
+ Dl_info info;
+ if (dladdr((void*)&GetApplicationHomeFromDll, &info) != 0) {
+ char *path = realpath(info.dli_fname, buf);
+ if (path == buf) {
+ return TruncatePath(buf);
+ }
+ }
+ return JNI_FALSE;
+}
+
/*
* Return true if the named program exists
*/
diff --git a/jdk/src/java.base/unix/native/libjli/java_md_solinux.c b/jdk/src/java.base/unix/native/libjli/java_md_solinux.c
index 38d8834a932..b9091aaead3 100644
--- a/jdk/src/java.base/unix/native/libjli/java_md_solinux.c
+++ b/jdk/src/java.base/unix/native/libjli/java_md_solinux.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1998, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1998, 2016, 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
@@ -666,6 +666,7 @@ static jboolean
GetJREPath(char *path, jint pathsize, const char * arch, jboolean speculative)
{
char libjava[MAXPATHLEN];
+ struct stat s;
if (GetApplicationHome(path, pathsize)) {
/* Is JRE co-located with the application? */
@@ -688,6 +689,14 @@ GetJREPath(char *path, jint pathsize, const char * arch, jboolean speculative)
}
}
+ if (GetApplicationHomeFromDll(path, pathsize)) {
+ JLI_Snprintf(libjava, sizeof(libjava), "%s/lib/%s/" JAVA_DLL, path, arch);
+ if (stat(libjava, &s) == 0) {
+ JLI_TraceLauncher("JRE path is %s\n", path);
+ return JNI_TRUE;
+ }
+ }
+
if (!speculative)
JLI_ReportErrorMessage(JRE_ERROR8 JAVA_DLL);
return JNI_FALSE;
diff --git a/jdk/src/java.base/unix/native/libnet/SocketInputStream.c b/jdk/src/java.base/unix/native/libnet/SocketInputStream.c
index 08d8508b154..380c03bfeaa 100644
--- a/jdk/src/java.base/unix/native/libnet/SocketInputStream.c
+++ b/jdk/src/java.base/unix/native/libnet/SocketInputStream.c
@@ -35,7 +35,6 @@
#include "java_net_SocketInputStream.h"
-
/************************************************************************
* SocketInputStream
*/
@@ -52,6 +51,40 @@ Java_java_net_SocketInputStream_init(JNIEnv *env, jclass cls) {
IO_fd_fdID = NET_GetFileDescriptorID(env);
}
+static int NET_ReadWithTimeout(JNIEnv *env, int fd, char *bufP, int len, long timeout) {
+ int result = 0;
+ long prevtime = NET_GetCurrentTime(), newtime;
+ while (timeout > 0) {
+ result = NET_TimeoutWithCurrentTime(fd, timeout, prevtime);
+ if (result <= 0) {
+ if (result == 0) {
+ JNU_ThrowByName(env, JNU_JAVANETPKG "SocketTimeoutException", "Read timed out");
+ } else if (result == -1) {
+ if (errno == EBADF) {
+ JNU_ThrowByName(env, JNU_JAVANETPKG "SocketException", "Socket closed");
+ } else if (errno == ENOMEM) {
+ JNU_ThrowOutOfMemoryError(env, "NET_Timeout native heap allocation failed");
+ } else {
+ JNU_ThrowByNameWithMessageAndLastError
+ (env, JNU_JAVANETPKG "SocketException", "select/poll failed");
+ }
+ }
+ return -1;
+ }
+ result = NET_NonBlockingRead(fd, bufP, len);
+ if (result == -1 && ((errno == EAGAIN) || (errno == EWOULDBLOCK))) {
+ newtime = NET_GetCurrentTime();
+ timeout -= newtime - prevtime;
+ if (timeout > 0) {
+ prevtime = newtime;
+ }
+ } else {
+ break;
+ }
+ }
+ return result;
+}
+
/*
* Class: java_net_SocketInputStream
* Method: socketRead0
@@ -98,32 +131,18 @@ Java_java_net_SocketInputStream_socketRead0(JNIEnv *env, jobject this,
} else {
bufP = BUF;
}
-
if (timeout) {
- nread = NET_Timeout(fd, timeout);
- if (nread <= 0) {
- if (nread == 0) {
- JNU_ThrowByName(env, JNU_JAVANETPKG "SocketTimeoutException",
- "Read timed out");
- } else if (nread == -1) {
- if (errno == EBADF) {
- JNU_ThrowByName(env, JNU_JAVANETPKG "SocketException", "Socket closed");
- } else if (errno == ENOMEM) {
- JNU_ThrowOutOfMemoryError(env, "NET_Timeout native heap allocation failed");
- } else {
- JNU_ThrowByNameWithMessageAndLastError
- (env, JNU_JAVANETPKG "SocketException", "select/poll failed");
- }
- }
+ nread = NET_ReadWithTimeout(env, fd, bufP, len, timeout);
+ if ((*env)->ExceptionCheck(env)) {
if (bufP != BUF) {
free(bufP);
}
- return -1;
+ return nread;
}
+ } else {
+ nread = NET_Read(fd, bufP, len);
}
- nread = NET_Read(fd, bufP, len);
-
if (nread <= 0) {
if (nread < 0) {
@@ -143,7 +162,6 @@ Java_java_net_SocketInputStream_socketRead0(JNIEnv *env, jobject this,
JNU_ThrowByName(env, JNU_JAVAIOPKG "InterruptedIOException",
"Operation interrupted");
break;
-
default:
JNU_ThrowByNameWithMessageAndLastError
(env, JNU_JAVANETPKG "SocketException", "Read failed");
diff --git a/jdk/src/java.base/unix/native/libnet/net_util_md.c b/jdk/src/java.base/unix/native/libnet/net_util_md.c
index c801a824bc3..66670f900cc 100644
--- a/jdk/src/java.base/unix/native/libnet/net_util_md.c
+++ b/jdk/src/java.base/unix/native/libnet/net_util_md.c
@@ -33,6 +33,7 @@
#include
#include
#include
+#include
#ifndef _ALLBSD_SOURCE
#include
@@ -1669,3 +1670,18 @@ NET_Wait(JNIEnv *env, jint fd, jint flags, jint timeout)
return timeout;
}
+
+long NET_GetCurrentTime() {
+ struct timeval time;
+ gettimeofday(&time, NULL);
+ return (time.tv_sec * 1000 + time.tv_usec / 1000);
+}
+
+int NET_TimeoutWithCurrentTime(int s, long timeout, long currentTime) {
+ return NET_Timeout0(s, timeout, currentTime);
+}
+
+int NET_Timeout(int s, long timeout) {
+ long currentTime = (timeout > 0) ? NET_GetCurrentTime() : 0;
+ return NET_Timeout0(s, timeout, currentTime);
+}
diff --git a/jdk/src/java.base/unix/native/libnet/net_util_md.h b/jdk/src/java.base/unix/native/libnet/net_util_md.h
index 3a8c9f4d48e..1f5b6f60eca 100644
--- a/jdk/src/java.base/unix/native/libnet/net_util_md.h
+++ b/jdk/src/java.base/unix/native/libnet/net_util_md.h
@@ -35,7 +35,11 @@
#include
int NET_Timeout(int s, long timeout);
+int NET_Timeout0(int s, long timeout, long currentTime);
int NET_Read(int s, void* buf, size_t len);
+int NET_NonBlockingRead(int s, void* buf, size_t len);
+int NET_TimeoutWithCurrentTime(int s, long timeout, long currentTime);
+long NET_GetCurrentTime();
int NET_RecvFrom(int s, void *buf, int len, unsigned int flags,
struct sockaddr *from, socklen_t *fromlen);
int NET_ReadV(int s, const struct iovec * vector, int count);
diff --git a/jdk/src/java.base/windows/native/libjli/java_md.c b/jdk/src/java.base/windows/native/libjli/java_md.c
index 3b031d59dcc..3d29357542b 100644
--- a/jdk/src/java.base/windows/native/libjli/java_md.c
+++ b/jdk/src/java.base/windows/native/libjli/java_md.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2016, 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
@@ -348,7 +348,6 @@ GetJREPath(char *path, jint pathsize)
JLI_ReportErrorMessage(JRE_ERROR8 JAVA_DLL);
return JNI_FALSE;
-
}
/*
@@ -423,11 +422,11 @@ TruncatePath(char *buf)
*JLI_StrRChr(buf, '\\') = '\0'; /* remove .exe file name */
if ((cp = JLI_StrRChr(buf, '\\')) == 0) {
/* This happens if the application is in a drive root, and
- * there is no bin directory. */
+ * there is no bin directory. */
buf[0] = '\0';
return JNI_FALSE;
}
- *cp = '\0'; /* remove the bin\ part */
+ *cp = '\0'; /* remove the bin\ part */
return JNI_TRUE;
}
@@ -449,16 +448,16 @@ GetApplicationHome(char *buf, jint bufsize)
jboolean
GetApplicationHomeFromDll(char *buf, jint bufsize)
{
- HMODULE hModule;
- DWORD dwFlags =
- GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS |
- GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT;
+ HMODULE module;
+ DWORD flags = GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS |
+ GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT;
- if (GetModuleHandleEx(dwFlags, (LPCSTR)&GetJREPath, &hModule) == 0) {
- return JNI_FALSE;
- };
- GetModuleFileName(hModule, buf, bufsize);
- return TruncatePath(buf);
+ if (GetModuleHandleEx(flags, (LPCSTR)&GetJREPath, &module) != 0) {
+ if (GetModuleFileName(module, buf, bufsize) != 0) {
+ return TruncatePath(buf);
+ }
+ }
+ return JNI_FALSE;
}
/*
diff --git a/jdk/src/java.base/windows/native/libjli/java_md.h b/jdk/src/java.base/windows/native/libjli/java_md.h
index ec3131f6b61..a2392eba8fc 100644
--- a/jdk/src/java.base/windows/native/libjli/java_md.h
+++ b/jdk/src/java.base/windows/native/libjli/java_md.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1998, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1998, 2016, 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
@@ -54,7 +54,4 @@ extern jlong Counter2Micros(jlong counts);
int UnsetEnv(char *name);
-jboolean
-GetApplicationHomeFromDll(char *buf, jint bufsize);
-
#endif /* JAVA_MD_H */
diff --git a/jdk/src/java.instrument/share/classes/java/lang/instrument/package.html b/jdk/src/java.instrument/share/classes/java/lang/instrument/package.html
index 9b1b02ea06f..c1f6c852982 100644
--- a/jdk/src/java.instrument/share/classes/java/lang/instrument/package.html
+++ b/jdk/src/java.instrument/share/classes/java/lang/instrument/package.html
@@ -105,6 +105,10 @@ method is not invoked.
The agent class will be loaded by the system class loader
(see {@link java.lang.ClassLoader#getSystemClassLoader ClassLoader.getSystemClassLoader}). This is
the class loader which typically loads the class containing the application main method.
+The system class loader must support a mechanism to add an agent JAR file to the system class path.
+If it is a custom system class loader then it must define the
+appendToClassPathForInstrumentation method as specified in
+{@link Instrumentation#appendToSystemClassLoaderSearch appendToSystemClassLoaderSearch}.
The premain methods will be run under the same security and classloader
rules as the application main method.
There are no modeling restrictions on what the agent premain method may do.
@@ -140,7 +144,10 @@ supports the starting of agents after the VM has started the following applies:
The system class loader (
{@link java.lang.ClassLoader#getSystemClassLoader ClassLoader.getSystemClassLoader}) must
- support a mechanism to add an agent JAR file to the system class path.
+ support a mechanism to add an agent JAR file to the system class path.
+ If it is a custom system class loader then it must define the
+ appendToClassPathForInstrumentation method as specified in
+ {@link Instrumentation#appendToSystemClassLoaderSearch appendToSystemClassLoaderSearch}.
diff --git a/jdk/src/java.instrument/share/native/libinstrument/InvocationAdapter.c b/jdk/src/java.instrument/share/native/libinstrument/InvocationAdapter.c
index a74b2b725ba..625ea1ad13d 100644
--- a/jdk/src/java.instrument/share/native/libinstrument/InvocationAdapter.c
+++ b/jdk/src/java.instrument/share/native/libinstrument/InvocationAdapter.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2003, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2016, 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
@@ -190,10 +190,8 @@ DEF_Agent_OnLoad(JavaVM *vm, char *tail, void * reserved) {
return JNI_ERR;
}
- /*
- * Add to the jarfile
- */
- appendClassPath(agent, jarfile);
+ /* Save the jarfile name */
+ agent->mJarfile = jarfile;
/*
* The value of the Premain-Class attribute becomes the agent
@@ -241,7 +239,6 @@ DEF_Agent_OnLoad(JavaVM *vm, char *tail, void * reserved) {
/*
* Clean-up
*/
- free(jarfile);
if (options != NULL) free(options);
freeAttributes(attributes);
free(premainClass);
@@ -459,7 +456,23 @@ eventHandlerVMInit( jvmtiEnv * jvmtienv,
/* process the premain calls on the all the JPL agents */
if ( environment != NULL ) {
- jthrowable outstandingException = preserveThrowable(jnienv);
+ jthrowable outstandingException = NULL;
+ /*
+ * Add the jarfile to the system class path
+ */
+ JPLISAgent * agent = environment->mAgent;
+ if (appendClassPath(agent, agent->mJarfile)) {
+ fprintf(stderr, "Unable to add %s to system class path - "
+ "the system class loader does not define the "
+ "appendToClassPathForInstrumentation method or the method failed\n",
+ agent->mJarfile);
+ free((void *)agent->mJarfile);
+ abortJVM(jnienv, JPLIS_ERRORMESSAGE_CANNOTSTART);
+ }
+ free((void *)agent->mJarfile);
+ agent->mJarfile = NULL;
+
+ outstandingException = preserveThrowable(jnienv);
success = processJavaStart( environment->mAgent,
jnienv);
restoreThrowable(jnienv, outstandingException);
@@ -631,32 +644,19 @@ appendClassPath( JPLISAgent* agent,
jvmtierr = (*jvmtienv)->AddToSystemClassLoaderSearch(jvmtienv, jarfile);
check_phase_ret_1(jvmtierr);
- if (jvmtierr == JVMTI_ERROR_NONE) {
- return 0;
- } else {
- jvmtiPhase phase;
- jvmtiError err;
-
- err = (*jvmtienv)->GetPhase(jvmtienv, &phase);
- /* can be called from any phase */
- jplis_assert(err == JVMTI_ERROR_NONE);
-
- if (phase == JVMTI_PHASE_LIVE) {
- switch (jvmtierr) {
- case JVMTI_ERROR_CLASS_LOADER_UNSUPPORTED :
- fprintf(stderr, "System class loader does not support adding "
- "JAR file to system class path during the live phase!\n");
- break;
- default:
- fprintf(stderr, "Unexpected error (%d) returned by "
- "AddToSystemClassLoaderSearch\n", jvmtierr);
- break;
- }
- return -1;
- }
- jplis_assert(0);
+ switch (jvmtierr) {
+ case JVMTI_ERROR_NONE :
+ return 0;
+ case JVMTI_ERROR_CLASS_LOADER_UNSUPPORTED :
+ fprintf(stderr, "System class loader does not define "
+ "the appendToClassPathForInstrumentation method\n");
+ break;
+ default:
+ fprintf(stderr, "Unexpected error (%d) returned by "
+ "AddToSystemClassLoaderSearch\n", jvmtierr);
+ break;
}
- return -2;
+ return -1;
}
diff --git a/jdk/src/java.instrument/share/native/libinstrument/JPLISAgent.c b/jdk/src/java.instrument/share/native/libinstrument/JPLISAgent.c
index 3017cca1f7a..12f2a451e49 100644
--- a/jdk/src/java.instrument/share/native/libinstrument/JPLISAgent.c
+++ b/jdk/src/java.instrument/share/native/libinstrument/JPLISAgent.c
@@ -272,6 +272,7 @@ initializeJPLISAgent( JPLISAgent * agent,
agent->mNativeMethodPrefixAdded = JNI_FALSE;
agent->mAgentClassName = NULL;
agent->mOptionsString = NULL;
+ agent->mJarfile = NULL;
/* make sure we can recover either handle in either direction.
* the agent has a ref to the jvmti; make it mutual
diff --git a/jdk/src/java.instrument/share/native/libinstrument/JPLISAgent.h b/jdk/src/java.instrument/share/native/libinstrument/JPLISAgent.h
index 6ecfde2d5c5..008b2fabc6a 100644
--- a/jdk/src/java.instrument/share/native/libinstrument/JPLISAgent.h
+++ b/jdk/src/java.instrument/share/native/libinstrument/JPLISAgent.h
@@ -107,6 +107,7 @@ struct _JPLISAgent {
jboolean mNativeMethodPrefixAdded; /* indicates if can_set_native_method_prefix capability has been added */
char const * mAgentClassName; /* agent class name */
char const * mOptionsString; /* -javaagent options string */
+ const char * mJarfile; /* agent jar file name */
};
/*
diff --git a/jdk/src/java.logging/share/classes/java/util/logging/Level.java b/jdk/src/java.logging/share/classes/java/util/logging/Level.java
index fa0da4c1306..f7f7a4380be 100644
--- a/jdk/src/java.logging/share/classes/java/util/logging/Level.java
+++ b/jdk/src/java.logging/share/classes/java/util/logging/Level.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 2016, 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
@@ -24,13 +24,22 @@
*/
package java.util.logging;
+import java.lang.ref.Reference;
+import java.lang.ref.ReferenceQueue;
+import java.lang.ref.WeakReference;
import java.lang.reflect.Module;
+import java.security.AccessController;
+import java.security.PrivilegedAction;
import java.util.ArrayList;
+import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Locale;
import java.util.Map;
+import java.util.Optional;
import java.util.ResourceBundle;
+import java.util.function.Function;
+import jdk.internal.loader.ClassLoaderValue;
/**
* The Level class defines a set of standard logging levels that
@@ -177,6 +186,10 @@ public class Level implements java.io.Serializable {
*/
public static final Level ALL = new Level("ALL", Integer.MIN_VALUE, defaultBundle);
+ private static final Level[] standardLevels = {
+ OFF, SEVERE, WARNING, INFO, CONFIG, FINE, FINER, FINEST, ALL
+ };
+
/**
* Create a named Level with a given integer value.
*
@@ -267,7 +280,8 @@ public class Level implements java.io.Serializable {
// or its defining class loader, if it's unnamed module,
// of this Level instance that can be a custom Level subclass;
Module module = this.getClass().getModule();
- ResourceBundle rb = ResourceBundle.getBundle(resourceBundleName, newLocale, module);
+ ResourceBundle rb = ResourceBundle.getBundle(resourceBundleName,
+ newLocale, module);
final String localizedName = rb.getString(name);
final boolean isDefaultBundle = defaultBundle.equals(resourceBundleName);
@@ -350,12 +364,12 @@ public class Level implements java.io.Serializable {
throw new NullPointerException();
}
- KnownLevel level;
+ Optional level;
// Look for a known Level with the given non-localized name.
- level = KnownLevel.findByName(name);
- if (level != null) {
- return level.mirroredLevel;
+ level = KnownLevel.findByName(name, KnownLevel::mirrored);
+ if (level.isPresent()) {
+ return level.get();
}
// Now, check if the given name is an integer. If so,
@@ -363,21 +377,24 @@ public class Level implements java.io.Serializable {
// if necessary create one.
try {
int x = Integer.parseInt(name);
- level = KnownLevel.findByValue(x);
- if (level == null) {
+ level = KnownLevel.findByValue(x, KnownLevel::mirrored);
+ if (!level.isPresent()) {
// add new Level
Level levelObject = new Level(name, x);
- level = KnownLevel.findByValue(x);
+ // There's no need to use a reachability fence here because
+ // KnownLevel keeps a strong reference on the level when
+ // level.getClass() == Level.class.
+ return KnownLevel.findByValue(x, KnownLevel::mirrored).get();
}
- return level.mirroredLevel;
} catch (NumberFormatException ex) {
// Not an integer.
// Drop through.
}
- level = KnownLevel.findByLocalizedLevelName(name);
- if (level != null) {
- return level.mirroredLevel;
+ level = KnownLevel.findByLocalizedLevelName(name,
+ KnownLevel::mirrored);
+ if (level.isPresent()) {
+ return level.get();
}
return null;
@@ -408,15 +425,13 @@ public class Level implements java.io.Serializable {
// Serialization magic to prevent "doppelgangers".
// This is a performance optimization.
private Object readResolve() {
- KnownLevel o = KnownLevel.matches(this);
- if (o != null) {
- return o.levelObject;
+ Optional level = KnownLevel.matches(this);
+ if (level.isPresent()) {
+ return level.get();
}
-
// Woops. Whoever sent us this object knows
// about a new log level. Add it to our list.
- Level level = new Level(this.name, this.value, this.resourceBundleName);
- return level;
+ return new Level(this.name, this.value, this.resourceBundleName);
}
/**
@@ -450,12 +465,12 @@ public class Level implements java.io.Serializable {
// Check that name is not null.
name.length();
- KnownLevel level;
+ Optional level;
// Look for a known Level with the given non-localized name.
- level = KnownLevel.findByName(name);
- if (level != null) {
- return level.levelObject;
+ level = KnownLevel.findByName(name, KnownLevel::referent);
+ if (level.isPresent()) {
+ return level.get();
}
// Now, check if the given name is an integer. If so,
@@ -463,13 +478,16 @@ public class Level implements java.io.Serializable {
// if necessary create one.
try {
int x = Integer.parseInt(name);
- level = KnownLevel.findByValue(x);
- if (level == null) {
- // add new Level
- Level levelObject = new Level(name, x);
- level = KnownLevel.findByValue(x);
+ level = KnownLevel.findByValue(x, KnownLevel::referent);
+ if (level.isPresent()) {
+ return level.get();
}
- return level.levelObject;
+ // add new Level.
+ Level levelObject = new Level(name, x);
+ // There's no need to use a reachability fence here because
+ // KnownLevel keeps a strong reference on the level when
+ // level.getClass() == Level.class.
+ return KnownLevel.findByValue(x, KnownLevel::referent).get();
} catch (NumberFormatException ex) {
// Not an integer.
// Drop through.
@@ -478,9 +496,9 @@ public class Level implements java.io.Serializable {
// Finally, look for a known level with the given localized name,
// in the current default locale.
// This is relatively expensive, but not excessively so.
- level = KnownLevel.findByLocalizedLevelName(name);
- if (level != null) {
- return level.levelObject;
+ level = KnownLevel.findByLocalizedLevelName(name, KnownLevel::referent);
+ if (level .isPresent()) {
+ return level.get();
}
// OK, we've tried everything and failed
@@ -530,22 +548,67 @@ public class Level implements java.io.Serializable {
// If Level.getName, Level.getLocalizedName, Level.getResourceBundleName methods
// were final, the following KnownLevel implementation can be removed.
// Future API change should take this into consideration.
- static final class KnownLevel {
+ static final class KnownLevel extends WeakReference {
private static Map> nameToLevels = new HashMap<>();
private static Map> intToLevels = new HashMap<>();
- final Level levelObject; // instance of Level class or Level subclass
+ private static final ReferenceQueue QUEUE = new ReferenceQueue<>();
+
+ // CUSTOM_LEVEL_CLV is used to register custom level instances with
+ // their defining class loader, so that they are garbage collected
+ // if and only if their class loader is no longer strongly
+ // referenced.
+ private static final ClassLoaderValue> CUSTOM_LEVEL_CLV =
+ new ClassLoaderValue<>();
+
final Level mirroredLevel; // mirror of the custom Level
KnownLevel(Level l) {
- this.levelObject = l;
+ super(l, QUEUE);
if (l.getClass() == Level.class) {
this.mirroredLevel = l;
} else {
// this mirrored level object is hidden
- this.mirroredLevel = new Level(l.name, l.value, l.resourceBundleName, false);
+ this.mirroredLevel = new Level(l.name, l.value,
+ l.resourceBundleName, false);
}
}
+ Optional mirrored() {
+ return Optional.of(mirroredLevel);
+ }
+
+ Optional referent() {
+ return Optional.ofNullable(get());
+ }
+
+ private void remove() {
+ Optional.ofNullable(nameToLevels.get(mirroredLevel.name))
+ .ifPresent((x) -> x.remove(this));
+ Optional.ofNullable(intToLevels.get(mirroredLevel.value))
+ .ifPresent((x) -> x.remove(this));
+ }
+
+ // Remove all stale KnownLevel instances
+ static synchronized void purge() {
+ Reference extends Level> ref;
+ while ((ref = QUEUE.poll()) != null) {
+ if (ref instanceof KnownLevel) {
+ ((KnownLevel)ref).remove();
+ }
+ }
+ }
+
+ private static void registerWithClassLoader(Level customLevel) {
+ PrivilegedAction pa =
+ () -> customLevel.getClass().getClassLoader();
+ PrivilegedAction pn = customLevel.getClass()::getName;
+ final String name = AccessController.doPrivileged(pn);
+ final ClassLoader cl = AccessController.doPrivileged(pa);
+ CUSTOM_LEVEL_CLV.computeIfAbsent(cl, (c, v) -> new ArrayList<>())
+ .add(customLevel);
+ }
+
static synchronized void add(Level l) {
+ purge();
// the mirroredLevel object is always added to the list
// before the custom Level instance
KnownLevel o = new KnownLevel(l);
@@ -562,24 +625,36 @@ public class Level implements java.io.Serializable {
intToLevels.put(l.value, list);
}
list.add(o);
+
+ // keep the custom level reachable from its class loader
+ // This will ensure that custom level values are not GC'ed
+ // until there class loader is GC'ed.
+ if (o.mirroredLevel != l) {
+ registerWithClassLoader(l);
+ }
+
}
// Returns a KnownLevel with the given non-localized name.
- static synchronized KnownLevel findByName(String name) {
- List list = nameToLevels.get(name);
- if (list != null) {
- return list.get(0);
- }
- return null;
+ static synchronized Optional findByName(String name,
+ Function> selector) {
+ purge();
+ return nameToLevels.getOrDefault(name, Collections.emptyList())
+ .stream()
+ .map(selector)
+ .flatMap(Optional::stream)
+ .findFirst();
}
// Returns a KnownLevel with the given value.
- static synchronized KnownLevel findByValue(int value) {
- List list = intToLevels.get(value);
- if (list != null) {
- return list.get(0);
- }
- return null;
+ static synchronized Optional findByValue(int value,
+ Function> selector) {
+ purge();
+ return intToLevels.getOrDefault(value, Collections.emptyList())
+ .stream()
+ .map(selector)
+ .flatMap(Optional::stream)
+ .findFirst();
}
// Returns a KnownLevel with the given localized name matching
@@ -587,32 +662,34 @@ public class Level implements java.io.Serializable {
// from the resourceBundle associated with the Level object).
// This method does not call Level.getLocalizedName() that may
// be overridden in a subclass implementation
- static synchronized KnownLevel findByLocalizedLevelName(String name) {
- for (List levels : nameToLevels.values()) {
- for (KnownLevel l : levels) {
- String lname = l.levelObject.getLocalizedLevelName();
- if (name.equals(lname)) {
- return l;
- }
- }
- }
- return null;
+ static synchronized Optional findByLocalizedLevelName(String name,
+ Function> selector) {
+ purge();
+ return nameToLevels.values().stream()
+ .flatMap(List::stream)
+ .map(selector)
+ .flatMap(Optional::stream)
+ .filter(l -> name.equals(l.getLocalizedLevelName()))
+ .findFirst();
}
- static synchronized KnownLevel matches(Level l) {
+ static synchronized Optional matches(Level l) {
+ purge();
List list = nameToLevels.get(l.name);
if (list != null) {
- for (KnownLevel level : list) {
- Level other = level.mirroredLevel;
+ for (KnownLevel ref : list) {
+ Level levelObject = ref.get();
+ if (levelObject == null) continue;
+ Level other = ref.mirroredLevel;
if (l.value == other.value &&
(l.resourceBundleName == other.resourceBundleName ||
(l.resourceBundleName != null &&
l.resourceBundleName.equals(other.resourceBundleName)))) {
- return level;
+ return Optional.of(levelObject);
}
}
}
- return null;
+ return Optional.empty();
}
}
diff --git a/jdk/src/jdk.attach/linux/classes/sun/tools/attach/VirtualMachineImpl.java b/jdk/src/jdk.attach/linux/classes/sun/tools/attach/VirtualMachineImpl.java
index 5cc81e9a2d0..edb0c0ba640 100644
--- a/jdk/src/jdk.attach/linux/classes/sun/tools/attach/VirtualMachineImpl.java
+++ b/jdk/src/jdk.attach/linux/classes/sun/tools/attach/VirtualMachineImpl.java
@@ -308,10 +308,6 @@ public class VirtualMachineImpl extends HotSpotVirtualMachine {
//-- native methods
- static native boolean isLinuxThreads();
-
- static native int getLinuxThreadsManager(int pid) throws IOException;
-
static native void sendQuitToChildrenOf(int pid) throws IOException;
static native void sendQuitTo(int pid) throws IOException;
diff --git a/jdk/src/jdk.attach/linux/native/libattach/VirtualMachineImpl.c b/jdk/src/jdk.attach/linux/native/libattach/VirtualMachineImpl.c
index 08ca4c481ea..85d355a1e6a 100644
--- a/jdk/src/jdk.attach/linux/native/libattach/VirtualMachineImpl.c
+++ b/jdk/src/jdk.attach/linux/native/libattach/VirtualMachineImpl.c
@@ -194,113 +194,6 @@ JNIEXPORT void JNICALL Java_sun_tools_attach_VirtualMachineImpl_connect
}
}
-/*
- * Class: sun_tools_attach_VirtualMachineImpl
- * Method: isLinuxThreads
- * Signature: ()V
- */
-JNIEXPORT jboolean JNICALL Java_sun_tools_attach_VirtualMachineImpl_isLinuxThreads
- (JNIEnv *env, jclass cls)
-{
-# ifndef _CS_GNU_LIBPTHREAD_VERSION
-# define _CS_GNU_LIBPTHREAD_VERSION 3
-# endif
- size_t n;
- char* s;
- jboolean res;
-
- n = confstr(_CS_GNU_LIBPTHREAD_VERSION, NULL, 0);
- if (n <= 0) {
- /* glibc before 2.3.2 only has LinuxThreads */
- return JNI_TRUE;
- }
-
- s = (char *)malloc(n);
- if (s == NULL) {
- JNU_ThrowOutOfMemoryError(env, "malloc failed");
- return JNI_TRUE;
- }
- confstr(_CS_GNU_LIBPTHREAD_VERSION, s, n);
-
- /*
- * If the LIBPTHREAD version include "NPTL" then we know we
- * have the new threads library and not LinuxThreads
- */
- res = (jboolean)(strstr(s, "NPTL") == NULL);
- free(s);
- return res;
-}
-
-/*
- * Structure and callback function used to count the children of
- * a given process, and record the pid of the "manager thread".
- */
-typedef struct {
- pid_t ppid;
- int count;
- pid_t mpid;
-} ChildCountContext;
-
-static void ChildCountCallback(const pid_t pid, void* user_data) {
- ChildCountContext* context = (ChildCountContext*)user_data;
- if (getParent(pid) == context->ppid) {
- context->count++;
- /*
- * Remember the pid of the first child. If the final count is
- * one then this is the pid of the LinuxThreads manager.
- */
- if (context->count == 1) {
- context->mpid = pid;
- }
- }
-}
-
-/*
- * Class: sun_tools_attach_VirtualMachineImpl
- * Method: getLinuxThreadsManager
- * Signature: (I)I
- */
-JNIEXPORT jint JNICALL Java_sun_tools_attach_VirtualMachineImpl_getLinuxThreadsManager
- (JNIEnv *env, jclass cls, jint pid)
-{
- ChildCountContext context;
-
- /*
- * Iterate over all processes to find how many children 'pid' has
- */
- context.ppid = pid;
- context.count = 0;
- context.mpid = (pid_t)0;
- forEachProcess(ChildCountCallback, (void*)&context);
-
- /*
- * If there's no children then this is likely the pid of the primordial
- * created by the launcher - in that case the LinuxThreads manager is the
- * parent of this process.
- */
- if (context.count == 0) {
- pid_t parent = getParent(pid);
- if ((int)parent > 0) {
- return (jint)parent;
- }
- }
-
- /*
- * There's one child so this is likely the embedded VM case where the
- * the primordial thread == LinuxThreads initial thread. The LinuxThreads
- * manager in that case is the child.
- */
- if (context.count == 1) {
- return (jint)context.mpid;
- }
-
- /*
- * If we get here it's most likely we were given the wrong pid
- */
- JNU_ThrowIOException(env, "Unable to get pid of LinuxThreads manager thread");
- return -1;
-}
-
/*
* Structure and callback function used to send a QUIT signal to all
* children of a given process
diff --git a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/builder/DefaultImageBuilder.java b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/builder/DefaultImageBuilder.java
index 850147aff31..a695de7e0c2 100644
--- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/builder/DefaultImageBuilder.java
+++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/builder/DefaultImageBuilder.java
@@ -55,6 +55,7 @@ import java.util.Objects;
import java.util.Optional;
import java.util.Properties;
import java.util.Set;
+import java.util.stream.Collectors;
import jdk.tools.jlink.internal.BasicImageWriter;
import jdk.tools.jlink.internal.plugins.FileCopierPlugin.SymImageFile;
import jdk.tools.jlink.internal.ExecutableImage;
@@ -159,7 +160,7 @@ public final class DefaultImageBuilder implements ImageBuilder {
}
i++;
}
- props.setProperty("MODULES", builder.toString());
+ props.setProperty("MODULES", quote(builder.toString()));
}
@Override
@@ -217,19 +218,38 @@ public final class DefaultImageBuilder implements ImageBuilder {
}
}
+ // Parse version string and return a string that includes only version part
+ // leaving "pre", "build" information. See also: java.lang.Runtime.Version.
+ private static String parseVersion(String str) {
+ return Runtime.Version.parse(str).
+ version().
+ stream().
+ map(Object::toString).
+ collect(Collectors.joining("."));
+ }
+
+ private static String quote(String str) {
+ return "\"" + str + "\"";
+ }
+
private Properties releaseProperties(ResourcePool pool) throws IOException {
Properties props = new Properties();
Optional javaBase = pool.moduleView().findModule("java.base");
javaBase.ifPresent(mod -> {
// fill release information available from transformed "java.base" module!
ModuleDescriptor desc = mod.descriptor();
- desc.osName().ifPresent(s -> props.setProperty("OS_NAME", s));
- desc.osVersion().ifPresent(s -> props.setProperty("OS_VERSION", s));
- desc.osArch().ifPresent(s -> props.setProperty("OS_ARCH", s));
- props.setProperty("JAVA_VERSION", System.getProperty("java.version"));
+ desc.osName().ifPresent(s -> {
+ props.setProperty("OS_NAME", quote(s));
+ this.targetOsName = s;
+ });
+ desc.osVersion().ifPresent(s -> props.setProperty("OS_VERSION", quote(s)));
+ desc.osArch().ifPresent(s -> props.setProperty("OS_ARCH", quote(s)));
+ desc.version().ifPresent(s -> props.setProperty("JAVA_VERSION",
+ quote(parseVersion(s.toString()))));
+ desc.version().ifPresent(s -> props.setProperty("JAVA_FULL_VERSION",
+ quote(s.toString())));
});
- this.targetOsName = props.getProperty("OS_NAME");
if (this.targetOsName == null) {
throw new PluginException("TargetPlatform attribute is missing for java.base module");
}
diff --git a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/IncludeLocalesPlugin.java b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/IncludeLocalesPlugin.java
index b6e29bfccdc..a0b93962a8d 100644
--- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/IncludeLocalesPlugin.java
+++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/IncludeLocalesPlugin.java
@@ -264,8 +264,8 @@ public final class IncludeLocalesPlugin implements Plugin, ResourcePrevisitor {
// Add Thai BreakIterator related data files
if (tag.equals("th")) {
- files.add(".+sun/text/resources/thai_dict");
- files.add(".+sun/text/resources/[^_]+BreakIteratorData_th");
+ files.add(".+sun/text/resources/ext/thai_dict");
+ files.add(".+sun/text/resources/ext/[^_]+BreakIteratorData_th");
}
// Add Taiwan resource bundles for Hong Kong
diff --git a/jdk/src/jdk.localedata/share/classes/sun/text/resources/thai_dict b/jdk/src/jdk.localedata/share/classes/sun/text/resources/ext/thai_dict
similarity index 100%
rename from jdk/src/jdk.localedata/share/classes/sun/text/resources/thai_dict
rename to jdk/src/jdk.localedata/share/classes/sun/text/resources/ext/thai_dict
diff --git a/jdk/test/ProblemList.txt b/jdk/test/ProblemList.txt
index cd0b2844a46..b3372f50846 100644
--- a/jdk/test/ProblemList.txt
+++ b/jdk/test/ProblemList.txt
@@ -159,7 +159,6 @@ javax/management/remote/mandatory/notif/NotifReconnectDeadlockTest.java 8042215
# jdk_net
-
java/net/MulticastSocket/NoLoopbackPackets.java 7122846 macosx-all
java/net/MulticastSocket/SetLoopbackMode.java 7122846 macosx-all
@@ -173,6 +172,8 @@ java/net/httpclient/http2/BasicTest.java 8157408 linux-al
java/net/httpclient/http2/ErrorTest.java 8158127 solaris-all,windows-all
java/net/httpclient/http2/TLSConnection.java 8157482 macosx-all
+sun/net/www/protocol/jar/JarURLConnectionUseCaches.java 8165988 windows-all
+
############################################################################
# jdk_nio
@@ -217,66 +218,6 @@ sun/security/tools/keytool/ListKeychainStore.sh 8156889 macosx-a
sun/security/tools/jarsigner/warnings/BadKeyUsageTest.java 8026393 generic-all
-sun/security/pkcs11/Cipher/ReinitCipher.java 8077138,8023434 windows-all
-sun/security/pkcs11/Cipher/TestPKCS5PaddingError.java 8077138,8023434 windows-all
-sun/security/pkcs11/Cipher/TestRSACipher.java 8077138,8023434 windows-all
-sun/security/pkcs11/Cipher/TestRSACipherWrap.java 8077138,8023434 windows-all
-sun/security/pkcs11/Cipher/TestRawRSACipher.java 8077138,8023434 windows-all
-sun/security/pkcs11/Cipher/TestSymmCiphers.java 8077138,8023434 windows-all
-sun/security/pkcs11/Cipher/TestSymmCiphersNoPad.java 8077138,8023434 windows-all
-sun/security/pkcs11/KeyAgreement/TestDH.java 8077138,8023434 windows-all
-sun/security/pkcs11/KeyAgreement/TestInterop.java 8077138,8023434 windows-all
-sun/security/pkcs11/KeyAgreement/TestShort.java 8077138,8023434 windows-all
-sun/security/pkcs11/KeyAgreement/SupportedDHKeys.java 8077138 windows-all
-sun/security/pkcs11/KeyAgreement/UnsupportedDHKeys.java 8077138 windows-all
-sun/security/pkcs11/KeyGenerator/DESParity.java 8077138,8023434 windows-all
-sun/security/pkcs11/KeyGenerator/TestKeyGenerator.java 8077138,8023434 windows-all
-sun/security/pkcs11/KeyPairGenerator/TestDH2048.java 8077138,8023434 windows-all
-sun/security/pkcs11/KeyStore/SecretKeysBasic.sh 8077138,8023434 windows-all
-sun/security/pkcs11/Mac/MacKAT.java 8077138,8023434 windows-all
-sun/security/pkcs11/Mac/MacSameTest.java 8077138,8023434 windows-all
-sun/security/pkcs11/Mac/ReinitMac.java 8077138,8023434 windows-all
-sun/security/pkcs11/MessageDigest/ByteBuffers.java 8077138,8023434 windows-all
-sun/security/pkcs11/MessageDigest/DigestKAT.java 8077138,8023434 windows-all
-sun/security/pkcs11/MessageDigest/ReinitDigest.java 8077138,8023434 windows-all
-sun/security/pkcs11/MessageDigest/TestCloning.java 8077138,8023434 windows-all
-sun/security/pkcs11/Provider/ConfigQuotedString.sh 8077138,8023434 windows-all
-sun/security/pkcs11/Provider/Login.sh 8077138,8023434 windows-all
-sun/security/pkcs11/SampleTest.java 8077138,8023434 windows-all
-sun/security/pkcs11/Secmod/AddPrivateKey.java 8077138,8023434 windows-all
-sun/security/pkcs11/Secmod/AddTrustedCert.java 8077138,8023434 windows-all
-sun/security/pkcs11/Secmod/Crypto.java 8077138,8023434 windows-all
-sun/security/pkcs11/Secmod/GetPrivateKey.java 8077138,8023434 windows-all
-sun/security/pkcs11/Secmod/JksSetPrivateKey.java 8077138,8023434 windows-all
-sun/security/pkcs11/Secmod/LoadKeystore.java 8077138,8023434 windows-all
-sun/security/pkcs11/SecureRandom/Basic.java 8077138,8023434 windows-all
-sun/security/pkcs11/SecureRandom/TestDeserialization.java 8077138,8023434 windows-all
-sun/security/pkcs11/Serialize/SerializeProvider.java 8077138,8023434 windows-all
-sun/security/pkcs11/Signature/ByteBuffers.java 8077138,8023434 windows-all
-sun/security/pkcs11/Signature/ReinitSignature.java 8077138,8023434 windows-all
-sun/security/pkcs11/Signature/TestDSA.java 8077138,8023434 windows-all
-sun/security/pkcs11/Signature/TestDSAKeyLength.java 8077138,8023434 windows-all
-sun/security/pkcs11/Signature/TestRSAKeyLength.java 8077138,8023434 windows-all
-sun/security/pkcs11/ec/ReadCertificates.java 8077138,8023434 windows-all
-sun/security/pkcs11/ec/ReadPKCS12.java 8077138,8023434 windows-all
-sun/security/pkcs11/ec/TestCurves.java 8077138,8023434 windows-all
-sun/security/pkcs11/ec/TestECDH.java 8077138,8023434 windows-all
-sun/security/pkcs11/ec/TestECDH2.java 8077138,8023434 windows-all
-sun/security/pkcs11/ec/TestECDSA.java 8077138,8023434 windows-all
-sun/security/pkcs11/ec/TestECDSA2.java 8077138,8023434 windows-all
-sun/security/pkcs11/ec/TestECGenSpec.java 8077138,8023434 windows-all
-sun/security/pkcs11/rsa/KeyWrap.java 8077138,8023434 windows-all
-sun/security/pkcs11/rsa/TestCACerts.java 8077138,8023434 windows-all
-sun/security/pkcs11/rsa/TestKeyFactory.java 8077138,8023434 windows-all
-sun/security/pkcs11/rsa/TestKeyPairGenerator.java 8077138,8023434 windows-all
-sun/security/pkcs11/rsa/TestSignatures.java 8077138,8023434 windows-all
-sun/security/pkcs11/sslecc/ClientJSSEServerJSSE.java 8077138,8023434 windows-all
-sun/security/pkcs11/tls/TestKeyMaterial.java 8077138,8023434 windows-all
-sun/security/pkcs11/tls/TestLeadingZeroesP11.java 8077138,8023434 windows-all
-sun/security/pkcs11/tls/TestMasterSecret.java 8077138,8023434 windows-all
-sun/security/pkcs11/tls/TestPRF.java 8077138,8023434 windows-all
-sun/security/pkcs11/tls/TestPremaster.java 8077138,8023434 windows-all
-
sun/security/krb5/auto/HttpNegotiateServer.java 8038079 generic-all
sun/security/ssl/SSLSocketImpl/AsyncSSLSocketClose.java 8161232 macosx-all
@@ -312,8 +253,6 @@ tools/pack200/CommandLineTests.java 7143279,8059906
tools/launcher/FXLauncherTest.java 8068049 linux-all,macosx-all
-tools/pack200/Pack200Props.java 8155857 generic-all
-
############################################################################
# jdk_jdi
diff --git a/jdk/test/java/lang/instrument/CustomSystemLoader/Agent.java b/jdk/test/java/lang/instrument/CustomSystemLoader/Agent.java
new file mode 100644
index 00000000000..0432c2d9587
--- /dev/null
+++ b/jdk/test/java/lang/instrument/CustomSystemLoader/Agent.java
@@ -0,0 +1,55 @@
+/*
+ * Copyright (c) 2016, 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.io.PrintStream;
+import java.lang.instrument.*;
+import java.lang.reflect.Field;
+
+/**
+ * @test
+ * @bug 8160950
+ * @summary test for custom system class loader
+ *
+ * @run build App Agent CustomLoader
+ * @run shell ../MakeJAR3.sh Agent 'Can-Retransform-Classes: true'
+ * @run main/othervm -javaagent:Agent.jar -Djava.system.class.loader=CustomLoader App
+ */
+
+public class Agent {
+ private static PrintStream err = System.err;
+ private static PrintStream out = System.out;
+ public static boolean failed = false;
+
+ public static void premain(String agentArgs, Instrumentation instrumentation) {
+ ClassLoader myClassLoader = Agent.class.getClassLoader();
+ out.println("Agent: started; myClassLoader: " + myClassLoader);
+ try {
+ Field fld = myClassLoader.getClass().getField("agentClassLoader");
+ fld.set(myClassLoader.getClass(), myClassLoader);
+ } catch (Exception ex) {
+ failed = true;
+ ex.printStackTrace();
+ }
+ out.println("Agent: finished");
+ }
+}
diff --git a/jdk/test/java/lang/instrument/CustomSystemLoader/App.java b/jdk/test/java/lang/instrument/CustomSystemLoader/App.java
new file mode 100644
index 00000000000..a5eac03f14e
--- /dev/null
+++ b/jdk/test/java/lang/instrument/CustomSystemLoader/App.java
@@ -0,0 +1,46 @@
+/*
+ * Copyright (c) 2016, 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.io.PrintStream;
+
+public class App {
+
+ public static void main(String args[]) throws Exception {
+ (new App()).run(args, System.out);
+ }
+
+ public void run(String args[], PrintStream out) throws Exception {
+ out.println("App: Test started");
+ if (CustomLoader.agentClassLoader != CustomLoader.myself) {
+ System.out.println("App: agentClassLoader: " + CustomLoader.agentClassLoader);
+ System.out.println("App: CustomLoader.myself: " + CustomLoader.myself);
+ System.out.println("App: myClassLoader: " + App.class.getClassLoader());
+ throw new Exception("App: Agent's system class loader is not CustomLoader");
+ } else if (Agent.failed) {
+ throw new Exception("App: Agent failed");
+ } else if (CustomLoader.failed) {
+ throw new Exception("App: CustomLoader failed");
+ }
+ out.println("App: Test passed");
+ }
+}
diff --git a/jdk/test/java/lang/instrument/CustomSystemLoader/CustomLoader.java b/jdk/test/java/lang/instrument/CustomSystemLoader/CustomLoader.java
new file mode 100644
index 00000000000..f90e244b4a1
--- /dev/null
+++ b/jdk/test/java/lang/instrument/CustomSystemLoader/CustomLoader.java
@@ -0,0 +1,81 @@
+/*
+ * Copyright (c) 2016, 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.io.DataInputStream;
+import java.io.InputStream;
+import java.io.IOException;
+import java.io.PrintStream;
+import java.util.jar.JarFile;
+import java.util.zip.ZipEntry;
+
+public class CustomLoader extends ClassLoader {
+ private static PrintStream out = System.out;
+ public static ClassLoader myself;
+ public static ClassLoader agentClassLoader;
+ public static boolean failed = true;
+
+ public CustomLoader(ClassLoader classLoader) {
+ super(classLoader);
+ myself = this;
+ }
+
+ @Override
+ public Class> loadClass(String name) throws ClassNotFoundException {
+ out.println("CustomLoader: loading class: " + name);
+ if (name.equals("Agent")) {
+ Class c = null;
+ try {
+ byte[] buf = locateBytes();
+ c = defineClass(name, buf, 0, buf.length);
+ } catch (IOException ex) {
+ throw new ClassNotFoundException(ex.getMessage());
+ }
+ resolveClass(c);
+ out.println("CustomLoader.loadClass after resolveClass: " + name +
+ "; Class: " + c + "; ClassLoader: " + c.getClassLoader());
+ return c;
+ }
+ return super.loadClass(name);
+ }
+
+ private byte[] locateBytes() throws IOException {
+ try {
+ JarFile jar = new JarFile("Agent.jar");
+ InputStream is = jar.getInputStream(jar.getEntry("Agent.class"));
+ int len = is.available();
+ byte[] buf = new byte[len];
+ DataInputStream in = new DataInputStream(is);
+ in.readFully(buf);
+ return buf;
+ } catch (IOException ioe) {
+ ioe.printStackTrace();
+ throw new IOException("Test failed due to IOException!");
+ }
+ }
+
+ void appendToClassPathForInstrumentation(String path) {
+ out.println("CustomLoader.appendToClassPathForInstrumentation: " +
+ this + ", jar: " + path);
+ failed = false;
+ }
+}
diff --git a/jdk/test/java/security/cert/CertPathValidator/trustAnchor/ValWithAnchorByName.java b/jdk/test/java/security/cert/CertPathValidator/trustAnchor/ValWithAnchorByName.java
new file mode 100644
index 00000000000..29abfb9f551
--- /dev/null
+++ b/jdk/test/java/security/cert/CertPathValidator/trustAnchor/ValWithAnchorByName.java
@@ -0,0 +1,292 @@
+/*
+ * Copyright (c) 2004, 2016, 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 8132926
+ * @summary PKIXParameters built with public key form of TrustAnchor causes
+ * NPE during cert path building/validation
+ * @run main ValWithAnchorByName
+ */
+
+import java.io.ByteArrayInputStream;
+import java.security.cert.CertificateException;
+import java.security.cert.CertificateFactory;
+import java.security.cert.CertPath;
+import java.security.cert.CertPathValidator;
+import java.security.cert.PKIXParameters;
+import java.security.cert.PKIXRevocationChecker;
+import java.security.cert.TrustAnchor;
+import java.security.cert.X509Certificate;
+import java.util.ArrayList;
+import java.util.Base64;
+import java.util.Collections;
+import java.util.Date;
+import java.util.List;
+import java.util.Map;
+import java.util.HashMap;
+
+// To get certpath debugging, add -Djava.security.debug=certpath
+
+public class ValWithAnchorByName {
+
+ // The following certificates and OCSP responses were captured from
+ // a test run that used certificates and responses generated by
+ // sun.security.testlibrary.CertificateBuilder and
+ // sun.security.testlibrary.SimpleOCSPServer.
+
+ // Subject: CN=SSLCertificate, O=SomeCompany
+ // Issuer: CN=Intermediate CA Cert, O=SomeCompany
+ // Validity: Tue Aug 30 14:37:19 PDT 2016 to Wed Aug 30 14:37:19 PDT 2017
+ private static final String EE_CERT =
+ "-----BEGIN CERTIFICATE-----\n" +
+ "MIIDnTCCAoWgAwIBAgICEAAwDQYJKoZIhvcNAQELBQAwNTEUMBIGA1UEChMLU29t\n" +
+ "ZUNvbXBhbnkxHTAbBgNVBAMTFEludGVybWVkaWF0ZSBDQSBDZXJ0MB4XDTE2MDgz\n" +
+ "MDIxMzcxOVoXDTE3MDgzMDIxMzcxOVowLzEUMBIGA1UEChMLU29tZUNvbXBhbnkx\n" +
+ "FzAVBgNVBAMTDlNTTENlcnRpZmljYXRlMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8A\n" +
+ "MIIBCgKCAQEAjgv8KKE4CO0rbCjRLA1hXjRiSq30jeusCJ8frbRG+QOBgQ3j6jgc\n" +
+ "vk5wG1aTu7R4AFn0/HRDMzP9ZbRlZVIbJUTd8YiaNyZeyWapPnxHWrPCd5e1xopk\n" +
+ "ElieDdEH5FiLGtIrWy56CGA1hfQb1vUVYegyeY+TTtMFVHt0PrmMk4ZRgj/GtVNp\n" +
+ "BQQYIzaYAcrcWMeCn30ZrhaGAL1hsdgmEVV1wsTD4JeNMSwLwMYem7fg8ondGZIR\n" +
+ "kZuGtuSdOHu4Xz+mgDNXTeX/Bp/dQFucxCG+FOOM9Hoz72RY2W8YqgL38RlnwYWp\n" +
+ "nUNxhXWFH6vyINRQVEu3IgahR6HXjxM7LwIDAQABo4G8MIG5MBQGA1UdEQQNMAuC\n" +
+ "CWxvY2FsaG9zdDAyBggrBgEFBQcBAQQmMCQwIgYIKwYBBQUHMAGGFmh0dHA6Ly9s\n" +
+ "b2NhbGhvc3Q6NDIzMzMwHwYDVR0jBBgwFoAUYT525lwHCI4CmuWs8a7poaeKRJ4w\n" +
+ "HQYDVR0OBBYEFCaQnOX4L1ovqyfeKuoay+kI+lXgMA4GA1UdDwEB/wQEAwIFoDAd\n" +
+ "BgNVHSUEFjAUBggrBgEFBQcDAQYIKwYBBQUHAwIwDQYJKoZIhvcNAQELBQADggEB\n" +
+ "AD8dqQIqFasJcL8lm4mPTsBl0JgNiN8tQcXM7VCvcH+yDvEyh9vudDjuhpSORqPq\n" +
+ "f1o/EvJ+gfs269mBnYQujYRvmSd6EAcBntv5zn6amOh03o6PqTY9KaUC/mL9hB84\n" +
+ "Y5/LYioP16sME7egKnlrGUgKh0ZvGzm7c3SYx3Z5YoeFBOkZajc7Jm+cBw/uBQkF\n" +
+ "a9mLEczIvOgkq1wto8vr2ptH1gEuvFRcorN3muvq34bk40G08+AHlP3fCLFpI3FA\n" +
+ "IStJLJZRcO+Ib4sOcKuaBGnuMo/QVOCEMDUs6RgiWtSd93OZKFIUOASVp6YIkcSs\n" +
+ "5/rmc06sICqBjLfPEB68Jjw=\n" +
+ "-----END CERTIFICATE-----";
+
+ // Subject: CN=Intermediate CA Cert, O=SomeCompany
+ // Issuer: CN=Root CA Cert, O=SomeCompany
+ // Validity: Sun Aug 07 14:37:19 PDT 2016 to Tue Aug 07 14:37:19 PDT 2018
+ private static final String INT_CA_CERT =
+ "-----BEGIN CERTIFICATE-----\n" +
+ "MIIDdjCCAl6gAwIBAgIBZDANBgkqhkiG9w0BAQsFADAtMRQwEgYDVQQKEwtTb21l\n" +
+ "Q29tcGFueTEVMBMGA1UEAxMMUm9vdCBDQSBDZXJ0MB4XDTE2MDgwNzIxMzcxOVoX\n" +
+ "DTE4MDgwNzIxMzcxOVowNTEUMBIGA1UEChMLU29tZUNvbXBhbnkxHTAbBgNVBAMT\n" +
+ "FEludGVybWVkaWF0ZSBDQSBDZXJ0MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIB\n" +
+ "CgKCAQEAnJR5CnE7GKlQjigExSJ6hHu302mc0PcA6TDgsIitPYD/r8RBbBuE51OQ\n" +
+ "7IP7AXmfPUV3/+pO/uxx6mgY5O6XeUl7KadhVPtPcL0BVVevCSOdTMVa3iV4zRpa\n" +
+ "C6Uy2ouUFnafKnDtlbieggyETUoNgVNJYA9L0XNhtSnENoLHC4Pq0v8OsNtsOWFR\n" +
+ "NiMTOA49NNDBw85WgPyFAxjqO4z0J0zxdWq3W4rSMB8xrkulv2Rvj3GcfYJK/ab8\n" +
+ "V1IJ6PMWCpujASY3BzvYPnN7BKuBjbWJPgZdPYfX1cxeG80u0tOuMfWWiNONSMSA\n" +
+ "7m9y304QA0gKqlrFFn9U4hU89kv1IwIDAQABo4GYMIGVMA8GA1UdEwEB/wQFMAMB\n" +
+ "Af8wMgYIKwYBBQUHAQEEJjAkMCIGCCsGAQUFBzABhhZodHRwOi8vbG9jYWxob3N0\n" +
+ "OjM5MTM0MB8GA1UdIwQYMBaAFJNMsejEyJUB9tiWycVczvpiMVQZMB0GA1UdDgQW\n" +
+ "BBRhPnbmXAcIjgKa5azxrumhp4pEnjAOBgNVHQ8BAf8EBAMCAYYwDQYJKoZIhvcN\n" +
+ "AQELBQADggEBAE4nOFdW9OirPnRvxihQXYL9CXLuGQz5tr0XgN8wSY6Un9b6CRiK\n" +
+ "7obgIGimVdhvUC1qdRcwJqgOfJ2/jR5/5Qo0TVp+ww4dHNdUoj73tagJ7jTu0ZMz\n" +
+ "5Zdp0uwd4RD/syvTeVcbPc3m4awtgEvRgzpDMcSeKPZWInlo7fbnowKSAUAfO8de\n" +
+ "0cDkxEBkzPIzGNu256cdLZOqOK9wLJ9mQ0zKgi/2NsldNc2pl/6jkGpA6uL5lJsm\n" +
+ "fo9sDusWNHV1YggqjDQ19hrf40VuuC9GFl/qAW3marMuEzY/NiKVUxty1q1s48SO\n" +
+ "g5LoEPDDkbygOt7ICL3HYG1VufhC1Q2YY9c=\n" +
+ "-----END CERTIFICATE-----";
+
+ // Subject: CN=Root CA Cert, O=SomeCompany
+ // Issuer: CN=Root CA Cert, O=SomeCompany
+ // Validity: Fri Jul 08 14:37:18 PDT 2016 to Fri Jun 28 14:37:18 PDT 2019
+ private static final String ROOT_CA_CERT =
+ "-----BEGIN CERTIFICATE-----\n" +
+ "MIIDODCCAiCgAwIBAgIBATANBgkqhkiG9w0BAQsFADAtMRQwEgYDVQQKEwtTb21l\n" +
+ "Q29tcGFueTEVMBMGA1UEAxMMUm9vdCBDQSBDZXJ0MB4XDTE2MDcwODIxMzcxOFoX\n" +
+ "DTE5MDYyODIxMzcxOFowLTEUMBIGA1UEChMLU29tZUNvbXBhbnkxFTATBgNVBAMT\n" +
+ "DFJvb3QgQ0EgQ2VydDCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAIlN\n" +
+ "M3WYEqkU2elXEZrV9QSDbDKwyaLEHafLFciH8Edoag3q/7jEzFJxI7JZ831tdbWQ\n" +
+ "Bm6Hgo+8pvetOFW1BckL8eIjyOONP2CKfFaeMaozsWi1cgxa+rjpU/Rekc+zBqvv\n" +
+ "y4Sr97TwT6nQiLlgjC1nCfR1SVpO51qoDChS7n785rsKEZxw/p+kkVWSZffU7zN9\n" +
+ "c645cPg//L/kjiyeKMkaquGQOYS68gQgy8YZXQv1E3l/8e8Ci1s1DYA5wpCbaBqg\n" +
+ "Tw84Rr4zlUEQBgXzQlRt+mPzeaDpdG1EeGkXrcdkZ+0EMELoOVXOEn6VNsz6vT3I\n" +
+ "KrnvQBSnN06xq/iWwC0CAwEAAaNjMGEwDwYDVR0TAQH/BAUwAwEB/zAfBgNVHSME\n" +
+ "GDAWgBSTTLHoxMiVAfbYlsnFXM76YjFUGTAdBgNVHQ4EFgQUk0yx6MTIlQH22JbJ\n" +
+ "xVzO+mIxVBkwDgYDVR0PAQH/BAQDAgGGMA0GCSqGSIb3DQEBCwUAA4IBAQAAi+Nl\n" +
+ "sxP9t2IhiZIHRJGSBZuQlXIjwYIwbq3ZWc/ApZ+0oxtl7DYQi5uRNt8/opcGNCHc\n" +
+ "IY0fG93SbkDubXbxPYBW6D/RUjbz59ZryaP5ym55p1MjHTOqy+AM8g41xNTJikc3\n" +
+ "UUFXXnckeFbawijCsb7vf71owzKuxgBXi9n1rmXXtncKoA/LrUVXoUlKefdgDnsU\n" +
+ "sl3Q29eibE3HSqziMMoAOLm0jjekFGWIgLeTtyRYR1d0dNaUwsHTrQpPjxxUTn1x\n" +
+ "sAPpXKfzPnsYAZeeiaaE75GwbWlHzrNinvxdZQd0zctpfBJfVqD/+lWANlw+rOaK\n" +
+ "J2GyCaJINsyaI/I2\n" +
+ "-----END CERTIFICATE-----";
+
+ // OCSP Response Status: successful (0x0)
+ // Response Type: Basic OCSP Response
+ // Version: 1 (0x0)
+ // Responder Id: CN=Intermediate CA Cert, O=SomeCompany
+ // Produced At: Sep 6 21:37:20 2016 GMT
+ // Responses:
+ // Certificate ID:
+ // Hash Algorithm: sha1
+ // Issuer Name Hash: 7ED23D4396152EAB7D0C4AD8C1CA1418AA05DD54
+ // Issuer Key Hash: 613E76E65C07088E029AE5ACF1AEE9A1A78A449E
+ // Serial Number: 1000
+ // Cert Status: good
+ // This Update: Sep 6 21:37:20 2016 GMT
+ // Next Update: Sep 6 22:37:19 2016 GMT
+ private static final String EE_OCSP_RESP =
+ "MIIFbAoBAKCCBWUwggVhBgkrBgEFBQcwAQEEggVSMIIFTjCBtaE3MDUxFDASBgNV\n" +
+ "BAoTC1NvbWVDb21wYW55MR0wGwYDVQQDExRJbnRlcm1lZGlhdGUgQ0EgQ2VydBgP\n" +
+ "MjAxNjA5MDYyMTM3MjBaMGUwYzA7MAkGBSsOAwIaBQAEFH7SPUOWFS6rfQxK2MHK\n" +
+ "FBiqBd1UBBRhPnbmXAcIjgKa5azxrumhp4pEngICEACAABgPMjAxNjA5MDYyMTM3\n" +
+ "MjBaoBEYDzIwMTYwOTA2MjIzNzE5WqECMAAwDQYJKoZIhvcNAQELBQADggEBAF13\n" +
+ "cLwxDG8UYPIbzID86vZGOWUuv5c35VnvebMk/ajAUdpItDYshIQVi90Z8BB2TEi/\n" +
+ "wtx1aNkIv7db0uQ0NnRfvME8vG2PWbty36CNAYr/M5UVzUmELH2sGTyf2fKfNIUK\n" +
+ "Iya/NRxCqxLAc34NYH0YyGJ9VcDjbEMNSBAHIqDdBNqKUPnjn454yoivU2oEs294\n" +
+ "cGePMx3QLyPepMwUss8nW74yIF7vxfJ+KFDBGWNuZDRfXScsGIoeM0Vt9B+4fmnV\n" +
+ "nP4Dw6l3IwmQH4ppjg08qTKvyrXcF2dPDWa98Xw6bA5G085Z/b/6/6GpkvKx/q6i\n" +
+ "UqKwF7q5hkDcB+N4/5SgggN+MIIDejCCA3YwggJeoAMCAQICAWQwDQYJKoZIhvcN\n" +
+ "AQELBQAwLTEUMBIGA1UEChMLU29tZUNvbXBhbnkxFTATBgNVBAMTDFJvb3QgQ0Eg\n" +
+ "Q2VydDAeFw0xNjA4MDcyMTM3MTlaFw0xODA4MDcyMTM3MTlaMDUxFDASBgNVBAoT\n" +
+ "C1NvbWVDb21wYW55MR0wGwYDVQQDExRJbnRlcm1lZGlhdGUgQ0EgQ2VydDCCASIw\n" +
+ "DQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAJyUeQpxOxipUI4oBMUieoR7t9Np\n" +
+ "nND3AOkw4LCIrT2A/6/EQWwbhOdTkOyD+wF5nz1Fd//qTv7scepoGOTul3lJeymn\n" +
+ "YVT7T3C9AVVXrwkjnUzFWt4leM0aWgulMtqLlBZ2nypw7ZW4noIMhE1KDYFTSWAP\n" +
+ "S9FzYbUpxDaCxwuD6tL/DrDbbDlhUTYjEzgOPTTQwcPOVoD8hQMY6juM9CdM8XVq\n" +
+ "t1uK0jAfMa5Lpb9kb49xnH2CSv2m/FdSCejzFgqbowEmNwc72D5zewSrgY21iT4G\n" +
+ "XT2H19XMXhvNLtLTrjH1lojTjUjEgO5vct9OEANICqpaxRZ/VOIVPPZL9SMCAwEA\n" +
+ "AaOBmDCBlTAPBgNVHRMBAf8EBTADAQH/MDIGCCsGAQUFBwEBBCYwJDAiBggrBgEF\n" +
+ "BQcwAYYWaHR0cDovL2xvY2FsaG9zdDozOTEzNDAfBgNVHSMEGDAWgBSTTLHoxMiV\n" +
+ "AfbYlsnFXM76YjFUGTAdBgNVHQ4EFgQUYT525lwHCI4CmuWs8a7poaeKRJ4wDgYD\n" +
+ "VR0PAQH/BAQDAgGGMA0GCSqGSIb3DQEBCwUAA4IBAQBOJzhXVvToqz50b8YoUF2C\n" +
+ "/Qly7hkM+ba9F4DfMEmOlJ/W+gkYiu6G4CBoplXYb1AtanUXMCaoDnydv40ef+UK\n" +
+ "NE1afsMOHRzXVKI+97WoCe407tGTM+WXadLsHeEQ/7Mr03lXGz3N5uGsLYBL0YM6\n" +
+ "QzHEnij2ViJ5aO3256MCkgFAHzvHXtHA5MRAZMzyMxjbtuenHS2TqjivcCyfZkNM\n" +
+ "yoIv9jbJXTXNqZf+o5BqQOri+ZSbJn6PbA7rFjR1dWIIKow0NfYa3+NFbrgvRhZf\n" +
+ "6gFt5mqzLhM2PzYilVMbctatbOPEjoOS6BDww5G8oDreyAi9x2BtVbn4QtUNmGPX";
+
+ // OCSP Response Status: successful (0x0)
+ // Response Type: Basic OCSP Response
+ // Version: 1 (0x0)
+ // Responder Id: O = SomeCompany, CN = Root CA Cert
+ // Produced At: Sep 6 21:37:20 2016 GMT
+ // Responses:
+ // Certificate ID:
+ // Hash Algorithm: sha1
+ // Issuer Name Hash: C8ED9F4E9AC0052A978257C569E6A7C9C45F5CB5
+ // Issuer Key Hash: 934CB1E8C4C89501F6D896C9C55CCEFA62315419
+ // Serial Number: 64
+ // Cert Status: good
+ // This Update: Sep 6 21:37:20 2016 GMT
+ // Next Update: Sep 6 22:37:19 2016 GMT
+ private static final String INT_CA_OCSP_RESP =
+ "MIIFJQoBAKCCBR4wggUaBgkrBgEFBQcwAQEEggULMIIFBzCBrKEvMC0xFDASBgNV\n" +
+ "BAoTC1NvbWVDb21wYW55MRUwEwYDVQQDEwxSb290IENBIENlcnQYDzIwMTYwOTA2\n" +
+ "MjEzNzIwWjBkMGIwOjAJBgUrDgMCGgUABBTI7Z9OmsAFKpeCV8Vp5qfJxF9ctQQU\n" +
+ "k0yx6MTIlQH22JbJxVzO+mIxVBkCAWSAABgPMjAxNjA5MDYyMTM3MjBaoBEYDzIw\n" +
+ "MTYwOTA2MjIzNzE5WqECMAAwDQYJKoZIhvcNAQELBQADggEBAAgs8jpuEejPD8qO\n" +
+ "+xckvqMz/5pItOHaSB0xyPNpIapqjcDkLktJdBVq5XJWernO9DU+P7yr7TDbvo6h\n" +
+ "P5jBZklLz16Z1aRlEyow2jhelVjNl6nxoiij/6LOGK4tLHa8fK7hTB4Ykw22Bxzt\n" +
+ "LcbrU5jgUDhdZkTrs+rWM8nw7mVWIQYQfwzCMDZ5a02MxzhdwggJGRzqMrbhY/Q7\n" +
+ "RRUK3ohSgzHmLjVkvA0KeM/Px7EefzbEbww08fSsLybmBoIEbcckWSHkkXx4cuIR\n" +
+ "T9FiTz4Ms4r8qzPCo61qeklE2I5lfnfieROADV6sfwbul/0U1HqKhHVaxJ8yYw+T\n" +
+ "/FMxrUKgggNAMIIDPDCCAzgwggIgoAMCAQICAQEwDQYJKoZIhvcNAQELBQAwLTEU\n" +
+ "MBIGA1UEChMLU29tZUNvbXBhbnkxFTATBgNVBAMTDFJvb3QgQ0EgQ2VydDAeFw0x\n" +
+ "NjA3MDgyMTM3MThaFw0xOTA2MjgyMTM3MThaMC0xFDASBgNVBAoTC1NvbWVDb21w\n" +
+ "YW55MRUwEwYDVQQDEwxSb290IENBIENlcnQwggEiMA0GCSqGSIb3DQEBAQUAA4IB\n" +
+ "DwAwggEKAoIBAQCJTTN1mBKpFNnpVxGa1fUEg2wysMmixB2nyxXIh/BHaGoN6v+4\n" +
+ "xMxScSOyWfN9bXW1kAZuh4KPvKb3rThVtQXJC/HiI8jjjT9ginxWnjGqM7FotXIM\n" +
+ "Wvq46VP0XpHPswar78uEq/e08E+p0Ii5YIwtZwn0dUlaTudaqAwoUu5+/Oa7ChGc\n" +
+ "cP6fpJFVkmX31O8zfXOuOXD4P/y/5I4snijJGqrhkDmEuvIEIMvGGV0L9RN5f/Hv\n" +
+ "AotbNQ2AOcKQm2gaoE8POEa+M5VBEAYF80JUbfpj83mg6XRtRHhpF63HZGftBDBC\n" +
+ "6DlVzhJ+lTbM+r09yCq570AUpzdOsav4lsAtAgMBAAGjYzBhMA8GA1UdEwEB/wQF\n" +
+ "MAMBAf8wHwYDVR0jBBgwFoAUk0yx6MTIlQH22JbJxVzO+mIxVBkwHQYDVR0OBBYE\n" +
+ "FJNMsejEyJUB9tiWycVczvpiMVQZMA4GA1UdDwEB/wQEAwIBhjANBgkqhkiG9w0B\n" +
+ "AQsFAAOCAQEAAIvjZbMT/bdiIYmSB0SRkgWbkJVyI8GCMG6t2VnPwKWftKMbZew2\n" +
+ "EIubkTbfP6KXBjQh3CGNHxvd0m5A7m128T2AVug/0VI28+fWa8mj+cpueadTIx0z\n" +
+ "qsvgDPIONcTUyYpHN1FBV153JHhW2sIowrG+73+9aMMyrsYAV4vZ9a5l17Z3CqAP\n" +
+ "y61FV6FJSnn3YA57FLJd0NvXomxNx0qs4jDKADi5tI43pBRliIC3k7ckWEdXdHTW\n" +
+ "lMLB060KT48cVE59cbAD6Vyn8z57GAGXnommhO+RsG1pR86zYp78XWUHdM3LaXwS\n" +
+ "X1ag//pVgDZcPqzmiidhsgmiSDbMmiPyNg==";
+
+ // Do path validation as if it is always Tue, 06 Sep 2016 22:12:21 GMT
+ // This value is within the lifetimes of all certificates and both OCSP
+ // responses.
+ private static final Date EVAL_DATE = new Date(1473199941000L);
+
+ private static final Base64.Decoder DECODER = Base64.getMimeDecoder();
+
+ public static void main(String[] args) throws Exception {
+ TrustAnchor anchor;
+ CertificateFactory cf = CertificateFactory.getInstance("X.509");
+ X509Certificate rootCert = generateCertificate(cf, ROOT_CA_CERT);
+ X509Certificate eeCert = generateCertificate(cf, EE_CERT);
+ X509Certificate intCaCert = generateCertificate(cf, INT_CA_CERT);
+ List certList = new ArrayList() {{
+ add(eeCert);
+ add(intCaCert);
+ }};
+
+ System.out.println("==== Certificate Path =====");
+ for (X509Certificate c : certList) {
+ System.out.println(c + "\n");
+ }
+ System.out.println("===========================");
+
+ System.out.println("===== Test 1: TA(X509Certificate) =====");
+ anchor = new TrustAnchor(rootCert, null);
+ runTest(cf, certList, anchor);
+
+ System.out.println("===== Test 2: TA(X500Principal, PublicKey =====");
+ anchor = new TrustAnchor(rootCert.getSubjectX500Principal(),
+ rootCert.getPublicKey(), null);
+ runTest(cf, certList, anchor);
+
+ System.out.println("===== Test 3: TA(String, PublicKey =====");
+ anchor = new TrustAnchor(rootCert.getSubjectX500Principal().getName(),
+ rootCert.getPublicKey(), null);
+ runTest(cf, certList, anchor);
+ }
+
+ private static void runTest(CertificateFactory cf,
+ List certList, TrustAnchor anchor)
+ throws Exception {
+ CertPath path = cf.generateCertPath(certList);
+ CertPathValidator validator = CertPathValidator.getInstance("PKIX");
+
+ System.out.println(anchor);
+
+ // Attach the OCSP responses to a PKIXParameters object
+ PKIXRevocationChecker pkrev =
+ (PKIXRevocationChecker)validator.getRevocationChecker();
+ Map responseMap = new HashMap<>();
+ responseMap.put(certList.get(0), DECODER.decode(EE_OCSP_RESP));
+ responseMap.put(certList.get(1), DECODER.decode(INT_CA_OCSP_RESP));
+ pkrev.setOcspResponses(responseMap);
+ PKIXParameters params =
+ new PKIXParameters(Collections.singleton(anchor));
+ params.addCertPathChecker(pkrev);
+ params.setDate(EVAL_DATE);
+
+ validator.validate(path, params);
+ }
+
+ private static X509Certificate generateCertificate(CertificateFactory cf,
+ String encoded) throws CertificateException {
+ ByteArrayInputStream is = new ByteArrayInputStream(encoded.getBytes());
+ return (X509Certificate)cf.generateCertificate(is);
+ }
+}
diff --git a/jdk/test/java/util/PriorityQueue/NoNulls.java b/jdk/test/java/util/PriorityQueue/NoNulls.java
index 5ef7c536c8a..f2e147a34b6 100644
--- a/jdk/test/java/util/PriorityQueue/NoNulls.java
+++ b/jdk/test/java/util/PriorityQueue/NoNulls.java
@@ -38,10 +38,8 @@
*/
import java.util.ArrayList;
-import java.util.Arrays;
import java.util.Comparator;
import java.util.Collection;
-import java.util.Collections;
import java.util.PriorityQueue;
import java.util.SortedSet;
import java.util.TreeSet;
diff --git a/jdk/test/java/util/concurrent/BlockingQueue/LoopHelpers.java b/jdk/test/java/util/concurrent/BlockingQueue/LoopHelpers.java
index ed3d8719dff..3f664d54570 100644
--- a/jdk/test/java/util/concurrent/BlockingQueue/LoopHelpers.java
+++ b/jdk/test/java/util/concurrent/BlockingQueue/LoopHelpers.java
@@ -31,8 +31,6 @@
* http://creativecommons.org/publicdomain/zero/1.0/
*/
-import java.util.concurrent.atomic.AtomicLong;
-
/**
* Misc utilities in JSR166 performance tests
*/
diff --git a/jdk/test/java/util/concurrent/BlockingQueue/OfferDrainToLoops.java b/jdk/test/java/util/concurrent/BlockingQueue/OfferDrainToLoops.java
index 9154683995d..9d6f289634a 100644
--- a/jdk/test/java/util/concurrent/BlockingQueue/OfferDrainToLoops.java
+++ b/jdk/test/java/util/concurrent/BlockingQueue/OfferDrainToLoops.java
@@ -43,7 +43,6 @@ import java.util.List;
import java.util.SplittableRandom;
import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.BlockingQueue;
-import java.util.concurrent.CyclicBarrier;
import java.util.concurrent.LinkedBlockingDeque;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.LinkedTransferQueue;
diff --git a/jdk/test/java/util/concurrent/ConcurrentHashMap/LoopHelpers.java b/jdk/test/java/util/concurrent/ConcurrentHashMap/LoopHelpers.java
index ed3d8719dff..3f664d54570 100644
--- a/jdk/test/java/util/concurrent/ConcurrentHashMap/LoopHelpers.java
+++ b/jdk/test/java/util/concurrent/ConcurrentHashMap/LoopHelpers.java
@@ -31,8 +31,6 @@
* http://creativecommons.org/publicdomain/zero/1.0/
*/
-import java.util.concurrent.atomic.AtomicLong;
-
/**
* Misc utilities in JSR166 performance tests
*/
diff --git a/jdk/test/java/util/concurrent/ConcurrentQueues/LoopHelpers.java b/jdk/test/java/util/concurrent/ConcurrentQueues/LoopHelpers.java
index ed3d8719dff..3f664d54570 100644
--- a/jdk/test/java/util/concurrent/ConcurrentQueues/LoopHelpers.java
+++ b/jdk/test/java/util/concurrent/ConcurrentQueues/LoopHelpers.java
@@ -31,8 +31,6 @@
* http://creativecommons.org/publicdomain/zero/1.0/
*/
-import java.util.concurrent.atomic.AtomicLong;
-
/**
* Misc utilities in JSR166 performance tests
*/
diff --git a/jdk/test/java/util/concurrent/ConcurrentQueues/OfferRemoveLoops.java b/jdk/test/java/util/concurrent/ConcurrentQueues/OfferRemoveLoops.java
index 96008fa67b2..bc6d7a99a72 100644
--- a/jdk/test/java/util/concurrent/ConcurrentQueues/OfferRemoveLoops.java
+++ b/jdk/test/java/util/concurrent/ConcurrentQueues/OfferRemoveLoops.java
@@ -43,7 +43,6 @@ import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.LinkedTransferQueue;
import java.util.concurrent.PriorityBlockingQueue;
import java.util.concurrent.Semaphore;
-import java.util.concurrent.ThreadLocalRandom;
@SuppressWarnings({"unchecked", "rawtypes", "deprecation"})
public class OfferRemoveLoops {
diff --git a/jdk/test/java/util/concurrent/DelayQueue/Stress.java b/jdk/test/java/util/concurrent/DelayQueue/Stress.java
index 5a25b077521..44a20fff936 100644
--- a/jdk/test/java/util/concurrent/DelayQueue/Stress.java
+++ b/jdk/test/java/util/concurrent/DelayQueue/Stress.java
@@ -22,7 +22,6 @@
*/
import static java.util.concurrent.TimeUnit.NANOSECONDS;
-import static java.util.concurrent.TimeUnit.SECONDS;
import java.util.concurrent.DelayQueue;
import java.util.concurrent.Delayed;
diff --git a/jdk/test/java/util/concurrent/Exchanger/LoopHelpers.java b/jdk/test/java/util/concurrent/Exchanger/LoopHelpers.java
index ed3d8719dff..3f664d54570 100644
--- a/jdk/test/java/util/concurrent/Exchanger/LoopHelpers.java
+++ b/jdk/test/java/util/concurrent/Exchanger/LoopHelpers.java
@@ -31,8 +31,6 @@
* http://creativecommons.org/publicdomain/zero/1.0/
*/
-import java.util.concurrent.atomic.AtomicLong;
-
/**
* Misc utilities in JSR166 performance tests
*/
diff --git a/jdk/test/java/util/concurrent/ExecutorCompletionService/LoopHelpers.java b/jdk/test/java/util/concurrent/ExecutorCompletionService/LoopHelpers.java
index ed3d8719dff..3f664d54570 100644
--- a/jdk/test/java/util/concurrent/ExecutorCompletionService/LoopHelpers.java
+++ b/jdk/test/java/util/concurrent/ExecutorCompletionService/LoopHelpers.java
@@ -31,8 +31,6 @@
* http://creativecommons.org/publicdomain/zero/1.0/
*/
-import java.util.concurrent.atomic.AtomicLong;
-
/**
* Misc utilities in JSR166 performance tests
*/
diff --git a/jdk/test/java/util/concurrent/FutureTask/LoopHelpers.java b/jdk/test/java/util/concurrent/FutureTask/LoopHelpers.java
index ed3d8719dff..3f664d54570 100644
--- a/jdk/test/java/util/concurrent/FutureTask/LoopHelpers.java
+++ b/jdk/test/java/util/concurrent/FutureTask/LoopHelpers.java
@@ -31,8 +31,6 @@
* http://creativecommons.org/publicdomain/zero/1.0/
*/
-import java.util.concurrent.atomic.AtomicLong;
-
/**
* Misc utilities in JSR166 performance tests
*/
diff --git a/jdk/test/java/util/concurrent/ScheduledThreadPoolExecutor/ZeroCorePoolSize.java b/jdk/test/java/util/concurrent/ScheduledThreadPoolExecutor/ZeroCorePoolSize.java
index 4aff18e2a25..23ce8bb0e95 100644
--- a/jdk/test/java/util/concurrent/ScheduledThreadPoolExecutor/ZeroCorePoolSize.java
+++ b/jdk/test/java/util/concurrent/ScheduledThreadPoolExecutor/ZeroCorePoolSize.java
@@ -33,7 +33,6 @@
import static java.util.concurrent.TimeUnit.MILLISECONDS;
import java.util.concurrent.ScheduledThreadPoolExecutor;
-import java.util.concurrent.TimeUnit;
import jdk.testlibrary.Utils;
/**
diff --git a/jdk/test/java/util/concurrent/ScheduledThreadPoolExecutor/ZeroCoreThreads.java b/jdk/test/java/util/concurrent/ScheduledThreadPoolExecutor/ZeroCoreThreads.java
index f78c8d854d3..87dfd6ed4bd 100644
--- a/jdk/test/java/util/concurrent/ScheduledThreadPoolExecutor/ZeroCoreThreads.java
+++ b/jdk/test/java/util/concurrent/ScheduledThreadPoolExecutor/ZeroCoreThreads.java
@@ -40,7 +40,6 @@
import static java.util.concurrent.TimeUnit.HOURS;
import static java.util.concurrent.TimeUnit.MILLISECONDS;
-import static java.util.concurrent.TimeUnit.SECONDS;
import java.lang.reflect.Field;
import java.util.concurrent.BlockingQueue;
diff --git a/jdk/test/java/util/concurrent/ThreadPoolExecutor/ConfigChanges.java b/jdk/test/java/util/concurrent/ThreadPoolExecutor/ConfigChanges.java
index a7ff015bc77..71862dc8935 100644
--- a/jdk/test/java/util/concurrent/ThreadPoolExecutor/ConfigChanges.java
+++ b/jdk/test/java/util/concurrent/ThreadPoolExecutor/ConfigChanges.java
@@ -28,13 +28,13 @@
* @library /lib/testlibrary/
* @build jdk.testlibrary.RandomFactory
* @run main/othervm ConfigChanges
- * @key randomness intermittent
+ * @key randomness
* @author Martin Buchholz
*/
import static java.util.concurrent.TimeUnit.MILLISECONDS;
import static java.util.concurrent.TimeUnit.MINUTES;
-import static java.util.concurrent.TimeUnit.SECONDS;
+import static java.util.concurrent.TimeUnit.NANOSECONDS;
import java.security.Permission;
import java.util.Random;
@@ -44,7 +44,6 @@ import java.util.concurrent.ExecutorService;
import java.util.concurrent.RejectedExecutionException;
import java.util.concurrent.ThreadFactory;
import java.util.concurrent.ThreadPoolExecutor;
-import java.util.concurrent.atomic.AtomicInteger;
import jdk.testlibrary.RandomFactory;
public class ConfigChanges {
@@ -95,10 +94,10 @@ public class ConfigChanges {
check(tpe.getQueue().isEmpty());
check(tpe.isTerminated());
check(! tpe.isTerminating());
- equal(tpe.getActiveCount(), 0);
- equal(tpe.getPoolSize(), 0);
+ equal(0, tpe.getActiveCount());
+ equal(0, tpe.getPoolSize());
equal(tpe.getTaskCount(), tpe.getCompletedTaskCount());
- check(tpe.awaitTermination(0L, SECONDS));
+ check(tpe.awaitTermination(0L, MINUTES));
} catch (Throwable t) { unexpected(t); }
}
@@ -110,6 +109,21 @@ public class ConfigChanges {
static volatile Runnable runnableDuJour;
+ static void awaitIdleness(ThreadPoolExecutor tpe, long taskCount) {
+ restart: for (;;) {
+ // check twice to make chance of race vanishingly small
+ for (int i = 0; i < 2; i++) {
+ if (tpe.getQueue().size() != 0 ||
+ tpe.getActiveCount() != 0 ||
+ tpe.getCompletedTaskCount() != taskCount) {
+ Thread.yield();
+ continue restart;
+ }
+ }
+ return;
+ }
+ }
+
private static void realMain(String[] args) throws Throwable {
if (rnd.nextBoolean())
System.setSecurityManager(new PermissiveSecurityManger());
@@ -137,8 +151,9 @@ public class ConfigChanges {
if (prestart) {
tpe.prestartAllCoreThreads();
- equal(tg.activeCount(), n);
- equal(tg.activeCount(), tpe.getCorePoolSize());
+ equal(n, tg.activeCount());
+ equal(n, tpe.getCorePoolSize());
+ equal(n, tpe.getLargestPoolSize());
}
final Runnable runRunnableDuJour =
@@ -153,7 +168,7 @@ public class ConfigChanges {
tpe.execute(runRunnableDuJour);
// Wait for prestarted threads to dequeue their initial tasks.
while (! tpe.getQueue().isEmpty())
- Thread.sleep(10);
+ Thread.sleep(1);
for (int i = 0; i < 5*n; i++)
tpe.execute(runRunnableDuJour);
} else {
@@ -163,73 +178,76 @@ public class ConfigChanges {
//report("submitted", tpe);
pumpedUp.await();
- equal(tg.activeCount(), 3*n);
- equal(tg.activeCount(), tpe.getMaximumPoolSize());
- equal(tpe.getCorePoolSize(), n);
+ equal(3*n, tg.activeCount());
+ equal(3*n, tpe.getMaximumPoolSize());
+ equal(3*n, tpe.getLargestPoolSize());
+ equal(n, tpe.getCorePoolSize());
+ equal(3*n, tpe.getActiveCount());
+ equal(6L*n, tpe.getTaskCount());
+ equal(0L, tpe.getCompletedTaskCount());
+
//report("pumped up", tpe);
- equal(tpe.getMaximumPoolSize(), 3*n);
tpe.setMaximumPoolSize(4*n);
- equal(tpe.getMaximumPoolSize(), 4*n);
+ equal(4*n, tpe.getMaximumPoolSize());
//report("pumped up2", tpe);
final CyclicBarrier pumpedUp2 = new CyclicBarrier(n + 1);
runnableDuJour = waiter(pumpedUp2);
for (int i = 0; i < 1*n; i++)
tpe.execute(runRunnableDuJour);
pumpedUp2.await();
- equal(tg.activeCount(), 4*n);
- equal(tg.activeCount(), tpe.getMaximumPoolSize());
- equal(tpe.getCompletedTaskCount(), 0L);
+ equal(4*n, tg.activeCount());
+ equal(4*n, tpe.getMaximumPoolSize());
+ equal(4*n, tpe.getLargestPoolSize());
+ equal(4*n, tpe.getActiveCount());
+ equal(7L*n, tpe.getTaskCount());
+ equal(0L, tpe.getCompletedTaskCount());
//report("pumped up2", tpe);
runnableDuJour = new Runnable() { public void run() {}};
tpe.setMaximumPoolSize(2*n);
- //report("after set", tpe);
+ //report("after setMaximumPoolSize", tpe);
pumpedUp2.await();
pumpedUp.await();
-// while (tg.activeCount() != n &&
-// tg.activeCount() != n)
-// Thread.sleep(10);
-// equal(tg.activeCount(), n);
-// equal(tg.activeCount(), tpe.getCorePoolSize());
-
while (tg.activeCount() != 2*n &&
tg.activeCount() != 2*n)
- Thread.sleep(10);
- equal(tg.activeCount(), 2*n);
- equal(tg.activeCount(), tpe.getMaximumPoolSize());
+ Thread.yield();
+ equal(2*n, tg.activeCount());
+ equal(2*n, tpe.getMaximumPoolSize());
+ equal(4*n, tpe.getLargestPoolSize());
+ //report("draining", tpe);
+ awaitIdleness(tpe, 7L*n);
-//report("draining", tpe);
- while (tpe.getCompletedTaskCount() < 7*n &&
- tpe.getCompletedTaskCount() < 7*n)
- Thread.sleep(10);
+ equal(2*n, tg.activeCount());
+ equal(2*n, tpe.getMaximumPoolSize());
+ equal(4*n, tpe.getLargestPoolSize());
- //equal(tg.activeCount(), n);
- //equal(tg.activeCount(), tpe.getCorePoolSize());
- equal(tg.activeCount(), 2*n);
- equal(tg.activeCount(), tpe.getMaximumPoolSize());
+ equal(7L*n, tpe.getTaskCount());
+ equal(7L*n, tpe.getCompletedTaskCount());
+ equal(0, tpe.getActiveCount());
- equal(tpe.getTaskCount(), 7L*n);
- equal(tpe.getCompletedTaskCount(), 7L*n);
-
- equal(tpe.getKeepAliveTime(MINUTES), 3L);
+ equal(3L, tpe.getKeepAliveTime(MINUTES));
+ long t0 = System.nanoTime();
tpe.setKeepAliveTime(7L, MILLISECONDS);
- equal(tpe.getKeepAliveTime(MILLISECONDS), 7L);
+ equal(7L, tpe.getKeepAliveTime(MILLISECONDS));
while (tg.activeCount() > n &&
tg.activeCount() > n)
- Thread.sleep(10);
- equal(tg.activeCount(), n);
+ Thread.sleep(4);
+ equal(n, tg.activeCount());
+ check(System.nanoTime() - t0 >= tpe.getKeepAliveTime(NANOSECONDS));
//report("idle", tpe);
check(! tpe.allowsCoreThreadTimeOut());
+ t0 = System.nanoTime();
tpe.allowCoreThreadTimeOut(true);
check(tpe.allowsCoreThreadTimeOut());
while (tg.activeCount() > 0 &&
tg.activeCount() > 0)
- Thread.sleep(10);
+ Thread.sleep(4);
equal(tg.activeCount(), 0);
+ check(System.nanoTime() - t0 >= tpe.getKeepAliveTime(NANOSECONDS));
//report("idle", tpe);
diff --git a/jdk/test/java/util/concurrent/ThreadPoolExecutor/ThreadRestarts.java b/jdk/test/java/util/concurrent/ThreadPoolExecutor/ThreadRestarts.java
index 5d10213dc99..1a51d583e20 100644
--- a/jdk/test/java/util/concurrent/ThreadPoolExecutor/ThreadRestarts.java
+++ b/jdk/test/java/util/concurrent/ThreadPoolExecutor/ThreadRestarts.java
@@ -40,7 +40,6 @@
*/
import static java.util.concurrent.TimeUnit.MILLISECONDS;
-import static java.util.concurrent.TimeUnit.SECONDS;
import java.util.concurrent.ScheduledThreadPoolExecutor;
import java.util.concurrent.ThreadFactory;
diff --git a/jdk/test/java/util/concurrent/ThreadPoolExecutor/TimeOutShrink.java b/jdk/test/java/util/concurrent/ThreadPoolExecutor/TimeOutShrink.java
index 463d388b5da..007c52c8cb1 100644
--- a/jdk/test/java/util/concurrent/ThreadPoolExecutor/TimeOutShrink.java
+++ b/jdk/test/java/util/concurrent/ThreadPoolExecutor/TimeOutShrink.java
@@ -34,7 +34,6 @@ import static java.util.concurrent.TimeUnit.MILLISECONDS;
import java.util.concurrent.CyclicBarrier;
import java.util.concurrent.SynchronousQueue;
import java.util.concurrent.ThreadPoolExecutor;
-import java.util.concurrent.TimeUnit;
import jdk.testlibrary.Utils;
public class TimeOutShrink {
diff --git a/jdk/test/java/util/concurrent/atomic/AtomicReferenceTest.java b/jdk/test/java/util/concurrent/atomic/AtomicReferenceTest.java
index d1a4fddbcd0..008ac062afb 100644
--- a/jdk/test/java/util/concurrent/atomic/AtomicReferenceTest.java
+++ b/jdk/test/java/util/concurrent/atomic/AtomicReferenceTest.java
@@ -22,7 +22,6 @@
*/
import java.util.concurrent.atomic.AtomicReference;
-import java.util.function.UnaryOperator;
import org.testng.annotations.Test;
import static org.testng.Assert.*;
diff --git a/jdk/test/java/util/concurrent/forkjoin/SubmissionTest.java b/jdk/test/java/util/concurrent/forkjoin/SubmissionTest.java
index 5a3db577ddd..24ffd259217 100644
--- a/jdk/test/java/util/concurrent/forkjoin/SubmissionTest.java
+++ b/jdk/test/java/util/concurrent/forkjoin/SubmissionTest.java
@@ -22,27 +22,35 @@
*/
import java.util.concurrent.ForkJoinPool;
-import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicBoolean;
+import jdk.testlibrary.Utils;
/*
* @test
* @bug 8078490
* @summary Test submission and execution of task without joining
+ * @library /lib/testlibrary/
*/
public class SubmissionTest {
+ static final long LONG_DELAY_MS = Utils.adjustTimeout(10_000);
+
+ static long millisElapsedSince(long startTime) {
+ return (System.nanoTime() - startTime) / (1000L * 1000L);
+ }
+
public static void main(String[] args) throws Throwable {
final ForkJoinPool e = new ForkJoinPool(1);
final AtomicBoolean b = new AtomicBoolean();
final Runnable setFalse = () -> b.set(false);
- for (int i = 0; i < 100000; i++) {
+ for (int i = 0; i < 30_000; i++) {
b.set(true);
e.execute(setFalse);
- long st = System.nanoTime();
+ long startTime = System.nanoTime();
while (b.get()) {
- if (System.nanoTime() - st >= TimeUnit.SECONDS.toNanos(10)) {
+ if (millisElapsedSince(startTime) >= LONG_DELAY_MS) {
throw new RuntimeException("Submitted task failed to execute");
}
+ Thread.yield();
}
}
}
diff --git a/jdk/test/java/util/concurrent/locks/Lock/LoopHelpers.java b/jdk/test/java/util/concurrent/locks/Lock/LoopHelpers.java
index ed3d8719dff..3f664d54570 100644
--- a/jdk/test/java/util/concurrent/locks/Lock/LoopHelpers.java
+++ b/jdk/test/java/util/concurrent/locks/Lock/LoopHelpers.java
@@ -31,8 +31,6 @@
* http://creativecommons.org/publicdomain/zero/1.0/
*/
-import java.util.concurrent.atomic.AtomicLong;
-
/**
* Misc utilities in JSR166 performance tests
*/
diff --git a/jdk/test/java/util/concurrent/locks/Lock/Mutex.java b/jdk/test/java/util/concurrent/locks/Lock/Mutex.java
index 40bb16064a8..1a118f18a36 100644
--- a/jdk/test/java/util/concurrent/locks/Lock/Mutex.java
+++ b/jdk/test/java/util/concurrent/locks/Lock/Mutex.java
@@ -35,7 +35,6 @@ import java.util.concurrent.TimeUnit;
import java.util.concurrent.locks.AbstractQueuedSynchronizer;
import java.util.concurrent.locks.Condition;
import java.util.concurrent.locks.Lock;
-import java.util.concurrent.atomic.AtomicInteger;
import java.io.IOException;
import java.io.ObjectInputStream;
diff --git a/jdk/test/java/util/concurrent/locks/LockSupport/ParkLoops.java b/jdk/test/java/util/concurrent/locks/LockSupport/ParkLoops.java
index 2d82c455574..dc204906551 100644
--- a/jdk/test/java/util/concurrent/locks/LockSupport/ParkLoops.java
+++ b/jdk/test/java/util/concurrent/locks/LockSupport/ParkLoops.java
@@ -43,7 +43,6 @@ import java.util.SplittableRandom;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
-import java.util.concurrent.atomic.AtomicLong;
import java.util.concurrent.atomic.AtomicReferenceArray;
import java.util.concurrent.locks.LockSupport;
diff --git a/jdk/test/java/util/concurrent/locks/ReentrantLock/LoopHelpers.java b/jdk/test/java/util/concurrent/locks/ReentrantLock/LoopHelpers.java
index ed3d8719dff..3f664d54570 100644
--- a/jdk/test/java/util/concurrent/locks/ReentrantLock/LoopHelpers.java
+++ b/jdk/test/java/util/concurrent/locks/ReentrantLock/LoopHelpers.java
@@ -31,8 +31,6 @@
* http://creativecommons.org/publicdomain/zero/1.0/
*/
-import java.util.concurrent.atomic.AtomicLong;
-
/**
* Misc utilities in JSR166 performance tests
*/
diff --git a/jdk/test/java/util/concurrent/locks/ReentrantReadWriteLock/LoopHelpers.java b/jdk/test/java/util/concurrent/locks/ReentrantReadWriteLock/LoopHelpers.java
index ed3d8719dff..3f664d54570 100644
--- a/jdk/test/java/util/concurrent/locks/ReentrantReadWriteLock/LoopHelpers.java
+++ b/jdk/test/java/util/concurrent/locks/ReentrantReadWriteLock/LoopHelpers.java
@@ -31,8 +31,6 @@
* http://creativecommons.org/publicdomain/zero/1.0/
*/
-import java.util.concurrent.atomic.AtomicLong;
-
/**
* Misc utilities in JSR166 performance tests
*/
diff --git a/jdk/test/java/util/concurrent/locks/StampedLock/ReadersUnlockAfterWriteUnlock.java b/jdk/test/java/util/concurrent/locks/StampedLock/ReadersUnlockAfterWriteUnlock.java
index 6d459372515..be721a7b128 100644
--- a/jdk/test/java/util/concurrent/locks/StampedLock/ReadersUnlockAfterWriteUnlock.java
+++ b/jdk/test/java/util/concurrent/locks/StampedLock/ReadersUnlockAfterWriteUnlock.java
@@ -22,7 +22,6 @@
/*
* @test
- * @run main/othervm/timeout=60 ReadersUnlockAfterWriteUnlock
* @bug 8023234
* @summary StampedLock serializes readers on writer unlock
* @author Dmitry Chyuko
@@ -30,26 +29,23 @@
*/
import java.util.concurrent.CyclicBarrier;
+import java.util.concurrent.atomic.AtomicReference;
import java.util.concurrent.locks.StampedLock;
public class ReadersUnlockAfterWriteUnlock {
- static final int RNUM = 2;
- static final StampedLock sl = new StampedLock();
- static volatile boolean isDone;
+ public static void main(String[] args) throws InterruptedException {
+ final int RNUM = 2;
+ final int REPS = 128;
+ final StampedLock sl = new StampedLock();
+ final AtomicReference bad = new AtomicReference<>();
- static CyclicBarrier iterationStart = new CyclicBarrier(RNUM + 1);
- static CyclicBarrier readersHaveLocks = new CyclicBarrier(RNUM);
- static CyclicBarrier writerHasLock = new CyclicBarrier(RNUM + 1);
+ final CyclicBarrier iterationStart = new CyclicBarrier(RNUM + 1);
+ final CyclicBarrier readersHaveLocks = new CyclicBarrier(RNUM);
+ final CyclicBarrier writerHasLock = new CyclicBarrier(RNUM + 1);
- static class Reader extends Thread {
- final String name;
- Reader(String name) {
- super();
- this.name = name;
- }
- public void run() {
- while (!isDone && !isInterrupted()) {
- try {
+ Runnable reader = () -> {
+ try {
+ for (int i = 0; i < REPS; i++) {
iterationStart.await();
writerHasLock.await();
long rs = sl.readLock();
@@ -59,30 +55,45 @@ public class ReadersUnlockAfterWriteUnlock {
readersHaveLocks.await();
sl.unlockRead(rs);
- } catch (Exception e) {
- throw new IllegalStateException(e);
}
+ } catch (Throwable ex) {
+ ex.printStackTrace();
+ bad.set(ex);
}
- }
- }
+ };
- public static void main(String[] args) throws InterruptedException {
- for (int r = 0 ; r < RNUM; ++r) {
- new Reader("r" + r).start();
+ Thread[] threads = new Thread[RNUM];
+ for (int i = 0 ; i < RNUM; i++) {
+ Thread thread = new Thread(reader, "Reader");
+ threads[i] = thread;
+ thread.start();
}
- int i;
- for (i = 0; i < 1024; ++i) {
+ for (int i = 0; i < REPS; i++) {
try {
iterationStart.await();
long ws = sl.writeLock();
writerHasLock.await();
- Thread.sleep(10);
+ awaitWaitState(threads);
sl.unlockWrite(ws);
} catch (Exception e) {
throw new IllegalStateException(e);
}
}
- isDone = true;
+ for (Thread thread : threads)
+ thread.join();
+ if (bad.get() != null)
+ throw new AssertionError(bad.get());
}
+ static void awaitWaitState(Thread[] threads) {
+ restart: for (;;) {
+ for (Thread thread : threads) {
+ if (thread.getState() != Thread.State.WAITING) {
+ Thread.yield();
+ continue restart;
+ }
+ }
+ break;
+ }
+ }
}
diff --git a/jdk/test/java/util/concurrent/tck/AtomicIntegerArray9Test.java b/jdk/test/java/util/concurrent/tck/AtomicIntegerArray9Test.java
index d074b140ba2..b7b20bdf6b0 100644
--- a/jdk/test/java/util/concurrent/tck/AtomicIntegerArray9Test.java
+++ b/jdk/test/java/util/concurrent/tck/AtomicIntegerArray9Test.java
@@ -31,7 +31,6 @@
* http://creativecommons.org/publicdomain/zero/1.0/
*/
-import java.util.Arrays;
import java.util.concurrent.atomic.AtomicIntegerArray;
import junit.framework.Test;
diff --git a/jdk/test/java/util/concurrent/tck/AtomicLongArray9Test.java b/jdk/test/java/util/concurrent/tck/AtomicLongArray9Test.java
index 488b195e014..2011c789b91 100644
--- a/jdk/test/java/util/concurrent/tck/AtomicLongArray9Test.java
+++ b/jdk/test/java/util/concurrent/tck/AtomicLongArray9Test.java
@@ -31,7 +31,6 @@
* http://creativecommons.org/publicdomain/zero/1.0/
*/
-import java.util.Arrays;
import java.util.concurrent.atomic.AtomicLongArray;
import junit.framework.Test;
diff --git a/jdk/test/java/util/concurrent/tck/AtomicReferenceArray9Test.java b/jdk/test/java/util/concurrent/tck/AtomicReferenceArray9Test.java
index 9ebec5b2ef6..44bcdbe281f 100644
--- a/jdk/test/java/util/concurrent/tck/AtomicReferenceArray9Test.java
+++ b/jdk/test/java/util/concurrent/tck/AtomicReferenceArray9Test.java
@@ -31,7 +31,6 @@
* http://creativecommons.org/publicdomain/zero/1.0/
*/
-import java.util.Arrays;
import java.util.concurrent.atomic.AtomicReferenceArray;
import junit.framework.Test;
diff --git a/jdk/test/java/util/concurrent/tck/CompletableFutureTest.java b/jdk/test/java/util/concurrent/tck/CompletableFutureTest.java
index 203fd812ec5..a29f50e0a24 100644
--- a/jdk/test/java/util/concurrent/tck/CompletableFutureTest.java
+++ b/jdk/test/java/util/concurrent/tck/CompletableFutureTest.java
@@ -59,7 +59,6 @@ import java.util.concurrent.ForkJoinPool;
import java.util.concurrent.ForkJoinTask;
import java.util.concurrent.RejectedExecutionException;
import java.util.concurrent.TimeoutException;
-import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.atomic.AtomicReference;
import java.util.function.BiConsumer;
diff --git a/jdk/test/java/util/concurrent/tck/ConcurrentHashMap8Test.java b/jdk/test/java/util/concurrent/tck/ConcurrentHashMap8Test.java
index 18695548129..fd62ada71cb 100644
--- a/jdk/test/java/util/concurrent/tck/ConcurrentHashMap8Test.java
+++ b/jdk/test/java/util/concurrent/tck/ConcurrentHashMap8Test.java
@@ -38,7 +38,6 @@ import static java.util.Spliterator.NONNULL;
import java.util.AbstractMap;
import java.util.Arrays;
import java.util.Collection;
-import java.util.Collections;
import java.util.Iterator;
import java.util.Map;
import java.util.NoSuchElementException;
diff --git a/jdk/test/java/util/concurrent/tck/CopyOnWriteArrayListTest.java b/jdk/test/java/util/concurrent/tck/CopyOnWriteArrayListTest.java
index e8be651d53d..c457f6b85f9 100644
--- a/jdk/test/java/util/concurrent/tck/CopyOnWriteArrayListTest.java
+++ b/jdk/test/java/util/concurrent/tck/CopyOnWriteArrayListTest.java
@@ -36,7 +36,6 @@
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
-import java.util.Collections;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
diff --git a/jdk/test/java/util/concurrent/tck/CopyOnWriteArraySetTest.java b/jdk/test/java/util/concurrent/tck/CopyOnWriteArraySetTest.java
index 21f932e09a3..db7536856fe 100644
--- a/jdk/test/java/util/concurrent/tck/CopyOnWriteArraySetTest.java
+++ b/jdk/test/java/util/concurrent/tck/CopyOnWriteArraySetTest.java
@@ -36,7 +36,6 @@
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
-import java.util.Collections;
import java.util.Iterator;
import java.util.NoSuchElementException;
import java.util.Set;
diff --git a/jdk/test/java/util/concurrent/tck/CountedCompleterTest.java b/jdk/test/java/util/concurrent/tck/CountedCompleterTest.java
index 8be66850920..88ff1f33a99 100644
--- a/jdk/test/java/util/concurrent/tck/CountedCompleterTest.java
+++ b/jdk/test/java/util/concurrent/tck/CountedCompleterTest.java
@@ -40,9 +40,12 @@ import java.util.concurrent.CountedCompleter;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.ForkJoinPool;
import java.util.concurrent.ForkJoinTask;
+import java.util.concurrent.ThreadLocalRandom;
import java.util.concurrent.TimeoutException;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.atomic.AtomicReference;
+import java.util.function.BiConsumer;
+import java.util.function.Consumer;
import junit.framework.Test;
import junit.framework.TestSuite;
@@ -1869,4 +1872,115 @@ public class CountedCompleterTest extends JSR166TestCase {
testInvokeOnPool(singletonPool(), a);
}
+ /** CountedCompleter class javadoc code sample, version 1. */
+ public static void forEach1(E[] array, Consumer action) {
+ class Task extends CountedCompleter {
+ final int lo, hi;
+ Task(Task parent, int lo, int hi) {
+ super(parent); this.lo = lo; this.hi = hi;
+ }
+
+ public void compute() {
+ if (hi - lo >= 2) {
+ int mid = (lo + hi) >>> 1;
+ // must set pending count before fork
+ setPendingCount(2);
+ new Task(this, mid, hi).fork(); // right child
+ new Task(this, lo, mid).fork(); // left child
+ }
+ else if (hi > lo)
+ action.accept(array[lo]);
+ tryComplete();
+ }
+ }
+ new Task(null, 0, array.length).invoke();
+ }
+
+ /** CountedCompleter class javadoc code sample, version 2. */
+ public static void forEach2(E[] array, Consumer action) {
+ class Task extends CountedCompleter {
+ final int lo, hi;
+ Task(Task parent, int lo, int hi) {
+ super(parent); this.lo = lo; this.hi = hi;
+ }
+
+ public void compute() {
+ if (hi - lo >= 2) {
+ int mid = (lo + hi) >>> 1;
+ setPendingCount(1); // looks off by one, but correct!
+ new Task(this, mid, hi).fork(); // right child
+ new Task(this, lo, mid).compute(); // direct invoke
+ } else {
+ if (hi > lo)
+ action.accept(array[lo]);
+ tryComplete();
+ }
+ }
+ }
+ new Task(null, 0, array.length).invoke();
+ }
+
+ /** CountedCompleter class javadoc code sample, version 3. */
+ public static void forEach3(E[] array, Consumer action) {
+ class Task extends CountedCompleter {
+ final int lo, hi;
+ Task(Task parent, int lo, int hi) {
+ super(parent); this.lo = lo; this.hi = hi;
+ }
+
+ public void compute() {
+ int n = hi - lo;
+ for (; n >= 2; n /= 2) {
+ addToPendingCount(1);
+ new Task(this, lo + n/2, lo + n).fork();
+ }
+ if (n > 0)
+ action.accept(array[lo]);
+ propagateCompletion();
+ }
+ }
+ new Task(null, 0, array.length).invoke();
+ }
+
+ /** CountedCompleter class javadoc code sample, version 4. */
+ public static void forEach4(E[] array, Consumer action) {
+ class Task extends CountedCompleter {
+ final int lo, hi;
+ Task(Task parent, int lo, int hi) {
+ super(parent, 31 - Integer.numberOfLeadingZeros(hi - lo));
+ this.lo = lo; this.hi = hi;
+ }
+
+ public void compute() {
+ for (int n = hi - lo; n >= 2; n /= 2)
+ new Task(this, lo + n/2, lo + n).fork();
+ action.accept(array[lo]);
+ propagateCompletion();
+ }
+ }
+ if (array.length > 0)
+ new Task(null, 0, array.length).invoke();
+ }
+
+ void testRecursiveDecomposition(
+ BiConsumer> action) {
+ int n = ThreadLocalRandom.current().nextInt(8);
+ Integer[] a = new Integer[n];
+ for (int i = 0; i < n; i++) a[i] = i + 1;
+ AtomicInteger ai = new AtomicInteger(0);
+ action.accept(a, (x) -> ai.addAndGet(x));
+ assertEquals(n * (n + 1) / 2, ai.get());
+ }
+
+ /**
+ * Variants of divide-by-two recursive decomposition into leaf tasks,
+ * as described in the CountedCompleter class javadoc code samples
+ */
+ public void testRecursiveDecomposition() {
+ testRecursiveDecomposition(CountedCompleterTest::forEach1);
+ testRecursiveDecomposition(CountedCompleterTest::forEach2);
+ testRecursiveDecomposition(CountedCompleterTest::forEach3);
+ testRecursiveDecomposition(CountedCompleterTest::forEach4);
+ }
+
}
diff --git a/jdk/test/java/util/concurrent/tck/ExecutorCompletionService9Test.java b/jdk/test/java/util/concurrent/tck/ExecutorCompletionService9Test.java
index 8169d5fa5f6..d72d7dcc78f 100644
--- a/jdk/test/java/util/concurrent/tck/ExecutorCompletionService9Test.java
+++ b/jdk/test/java/util/concurrent/tck/ExecutorCompletionService9Test.java
@@ -42,7 +42,6 @@ import java.util.concurrent.CompletionService;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.Executor;
import java.util.concurrent.ExecutorCompletionService;
-import java.util.concurrent.ExecutorService;
import java.util.concurrent.Future;
import junit.framework.Test;
diff --git a/jdk/test/java/util/concurrent/tck/ExecutorCompletionServiceTest.java b/jdk/test/java/util/concurrent/tck/ExecutorCompletionServiceTest.java
index 6e4d00f3d0f..0ab6084b978 100644
--- a/jdk/test/java/util/concurrent/tck/ExecutorCompletionServiceTest.java
+++ b/jdk/test/java/util/concurrent/tck/ExecutorCompletionServiceTest.java
@@ -40,7 +40,6 @@ import java.util.concurrent.Callable;
import java.util.concurrent.CompletionService;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.ExecutionException;
-import java.util.concurrent.Executor;
import java.util.concurrent.ExecutorCompletionService;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Future;
diff --git a/jdk/test/java/util/concurrent/tck/ForkJoinPool8Test.java b/jdk/test/java/util/concurrent/tck/ForkJoinPool8Test.java
index ee991a21c80..b0fea9a0bfe 100644
--- a/jdk/test/java/util/concurrent/tck/ForkJoinPool8Test.java
+++ b/jdk/test/java/util/concurrent/tck/ForkJoinPool8Test.java
@@ -296,12 +296,11 @@ public class ForkJoinPool8Test extends JSR166TestCase {
RecursiveAction a = new CheckedRecursiveAction() {
protected void realCompute() {
FibAction f = new FibAction(8);
- final Thread myself = Thread.currentThread();
+ final Thread currentThread = Thread.currentThread();
// test join()
assertSame(f, f.fork());
- myself.interrupt();
- assertTrue(myself.isInterrupted());
+ currentThread.interrupt();
assertNull(f.join());
Thread.interrupted();
assertEquals(21, f.result);
@@ -310,8 +309,7 @@ public class ForkJoinPool8Test extends JSR166TestCase {
f = new FibAction(8);
f.cancel(true);
assertSame(f, f.fork());
- myself.interrupt();
- assertTrue(myself.isInterrupted());
+ currentThread.interrupt();
try {
f.join();
shouldThrow();
@@ -323,8 +321,7 @@ public class ForkJoinPool8Test extends JSR166TestCase {
f = new FibAction(8);
f.completeExceptionally(new FJException());
assertSame(f, f.fork());
- myself.interrupt();
- assertTrue(myself.isInterrupted());
+ currentThread.interrupt();
try {
f.join();
shouldThrow();
@@ -336,8 +333,7 @@ public class ForkJoinPool8Test extends JSR166TestCase {
// test quietlyJoin()
f = new FibAction(8);
assertSame(f, f.fork());
- myself.interrupt();
- assertTrue(myself.isInterrupted());
+ currentThread.interrupt();
f.quietlyJoin();
Thread.interrupted();
assertEquals(21, f.result);
@@ -346,8 +342,7 @@ public class ForkJoinPool8Test extends JSR166TestCase {
f = new FibAction(8);
f.cancel(true);
assertSame(f, f.fork());
- myself.interrupt();
- assertTrue(myself.isInterrupted());
+ currentThread.interrupt();
f.quietlyJoin();
Thread.interrupted();
checkCancelled(f);
@@ -355,8 +350,7 @@ public class ForkJoinPool8Test extends JSR166TestCase {
f = new FibAction(8);
f.completeExceptionally(new FJException());
assertSame(f, f.fork());
- myself.interrupt();
- assertTrue(myself.isInterrupted());
+ currentThread.interrupt();
f.quietlyJoin();
Thread.interrupted();
checkCompletedAbnormally(f, f.getException());
diff --git a/jdk/test/java/util/concurrent/tck/ForkJoinTask8Test.java b/jdk/test/java/util/concurrent/tck/ForkJoinTask8Test.java
index 54e944b54d0..c1063da31aa 100644
--- a/jdk/test/java/util/concurrent/tck/ForkJoinTask8Test.java
+++ b/jdk/test/java/util/concurrent/tck/ForkJoinTask8Test.java
@@ -35,7 +35,6 @@ import static java.util.concurrent.TimeUnit.MILLISECONDS;
import static java.util.concurrent.TimeUnit.SECONDS;
import java.util.Arrays;
-import java.util.Collections;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.ForkJoinPool;
diff --git a/jdk/test/java/util/concurrent/tck/ForkJoinTaskTest.java b/jdk/test/java/util/concurrent/tck/ForkJoinTaskTest.java
index c3e1c1802a5..807785aced6 100644
--- a/jdk/test/java/util/concurrent/tck/ForkJoinTaskTest.java
+++ b/jdk/test/java/util/concurrent/tck/ForkJoinTaskTest.java
@@ -35,9 +35,7 @@ import static java.util.concurrent.TimeUnit.MILLISECONDS;
import static java.util.concurrent.TimeUnit.SECONDS;
import java.util.Arrays;
-import java.util.Collections;
import java.util.HashSet;
-import java.util.List;
import java.util.concurrent.CancellationException;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.ForkJoinPool;
diff --git a/jdk/test/java/util/concurrent/tck/JSR166TestCase.java b/jdk/test/java/util/concurrent/tck/JSR166TestCase.java
index f6c3e2a930c..aaa97d8abcb 100644
--- a/jdk/test/java/util/concurrent/tck/JSR166TestCase.java
+++ b/jdk/test/java/util/concurrent/tck/JSR166TestCase.java
@@ -1264,7 +1264,7 @@ public class JSR166TestCase extends TestCase {
* Sleeps until the given time has elapsed.
* Throws AssertionFailedError if interrupted.
*/
- void sleep(long millis) {
+ static void sleep(long millis) {
try {
delay(millis);
} catch (InterruptedException fail) {
diff --git a/jdk/test/java/util/concurrent/tck/RecursiveActionTest.java b/jdk/test/java/util/concurrent/tck/RecursiveActionTest.java
index 9ce68c34166..01bd92770b7 100644
--- a/jdk/test/java/util/concurrent/tck/RecursiveActionTest.java
+++ b/jdk/test/java/util/concurrent/tck/RecursiveActionTest.java
@@ -285,12 +285,11 @@ public class RecursiveActionTest extends JSR166TestCase {
RecursiveAction a = new CheckedRecursiveAction() {
protected void realCompute() {
FibAction f = new FibAction(8);
- final Thread myself = Thread.currentThread();
+ final Thread currentThread = Thread.currentThread();
// test join()
assertSame(f, f.fork());
- myself.interrupt();
- assertTrue(myself.isInterrupted());
+ currentThread.interrupt();
assertNull(f.join());
Thread.interrupted();
assertEquals(21, f.result);
@@ -299,8 +298,7 @@ public class RecursiveActionTest extends JSR166TestCase {
f = new FibAction(8);
f.cancel(true);
assertSame(f, f.fork());
- myself.interrupt();
- assertTrue(myself.isInterrupted());
+ currentThread.interrupt();
try {
f.join();
shouldThrow();
@@ -312,8 +310,7 @@ public class RecursiveActionTest extends JSR166TestCase {
f = new FibAction(8);
f.completeExceptionally(new FJException());
assertSame(f, f.fork());
- myself.interrupt();
- assertTrue(myself.isInterrupted());
+ currentThread.interrupt();
try {
f.join();
shouldThrow();
@@ -325,8 +322,7 @@ public class RecursiveActionTest extends JSR166TestCase {
// test quietlyJoin()
f = new FibAction(8);
assertSame(f, f.fork());
- myself.interrupt();
- assertTrue(myself.isInterrupted());
+ currentThread.interrupt();
f.quietlyJoin();
Thread.interrupted();
assertEquals(21, f.result);
@@ -335,8 +331,7 @@ public class RecursiveActionTest extends JSR166TestCase {
f = new FibAction(8);
f.cancel(true);
assertSame(f, f.fork());
- myself.interrupt();
- assertTrue(myself.isInterrupted());
+ currentThread.interrupt();
f.quietlyJoin();
Thread.interrupted();
checkCancelled(f);
@@ -344,8 +339,7 @@ public class RecursiveActionTest extends JSR166TestCase {
f = new FibAction(8);
f.completeExceptionally(new FJException());
assertSame(f, f.fork());
- myself.interrupt();
- assertTrue(myself.isInterrupted());
+ currentThread.interrupt();
f.quietlyJoin();
Thread.interrupted();
checkCompletedAbnormally(f, f.getException());
@@ -385,22 +379,20 @@ public class RecursiveActionTest extends JSR166TestCase {
public void realRun() throws InterruptedException {
FibAction[] fibActions = sq.take();
FibAction f;
- final Thread myself = Thread.currentThread();
+ final Thread currentThread = Thread.currentThread();
// test join() ------------
f = fibActions[0];
assertFalse(ForkJoinTask.inForkJoinPool());
- myself.interrupt();
- assertTrue(myself.isInterrupted());
+ currentThread.interrupt();
assertNull(f.join());
assertTrue(Thread.interrupted());
assertEquals(21, f.result);
checkCompletedNormally(f);
f = fibActions[1];
- myself.interrupt();
- assertTrue(myself.isInterrupted());
+ currentThread.interrupt();
try {
f.join();
shouldThrow();
@@ -410,8 +402,7 @@ public class RecursiveActionTest extends JSR166TestCase {
}
f = fibActions[2];
- myself.interrupt();
- assertTrue(myself.isInterrupted());
+ currentThread.interrupt();
try {
f.join();
shouldThrow();
@@ -423,23 +414,20 @@ public class RecursiveActionTest extends JSR166TestCase {
// test quietlyJoin() ---------
f = fibActions[3];
- myself.interrupt();
- assertTrue(myself.isInterrupted());
+ currentThread.interrupt();
f.quietlyJoin();
assertTrue(Thread.interrupted());
assertEquals(21, f.result);
checkCompletedNormally(f);
f = fibActions[4];
- myself.interrupt();
- assertTrue(myself.isInterrupted());
+ currentThread.interrupt();
f.quietlyJoin();
assertTrue(Thread.interrupted());
checkCancelled(f);
f = fibActions[5];
- myself.interrupt();
- assertTrue(myself.isInterrupted());
+ currentThread.interrupt();
f.quietlyJoin();
assertTrue(Thread.interrupted());
assertTrue(f.getException() instanceof FJException);
diff --git a/jdk/test/java/util/concurrent/tck/ScheduledExecutorSubclassTest.java b/jdk/test/java/util/concurrent/tck/ScheduledExecutorSubclassTest.java
index ead869ed648..30cf187a64b 100644
--- a/jdk/test/java/util/concurrent/tck/ScheduledExecutorSubclassTest.java
+++ b/jdk/test/java/util/concurrent/tck/ScheduledExecutorSubclassTest.java
@@ -44,7 +44,6 @@ import java.util.concurrent.CancellationException;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.Delayed;
import java.util.concurrent.ExecutionException;
-import java.util.concurrent.Executors;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Future;
import java.util.concurrent.RejectedExecutionException;
diff --git a/jdk/test/java/util/concurrent/tck/ScheduledExecutorTest.java b/jdk/test/java/util/concurrent/tck/ScheduledExecutorTest.java
index 53ebc5ea179..1cb2a472658 100644
--- a/jdk/test/java/util/concurrent/tck/ScheduledExecutorTest.java
+++ b/jdk/test/java/util/concurrent/tck/ScheduledExecutorTest.java
@@ -45,7 +45,6 @@ import java.util.concurrent.Callable;
import java.util.concurrent.CancellationException;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.ExecutionException;
-import java.util.concurrent.Executors;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Future;
import java.util.concurrent.RejectedExecutionException;
diff --git a/jdk/test/java/util/concurrent/tck/StampedLockTest.java b/jdk/test/java/util/concurrent/tck/StampedLockTest.java
index 5ced6c93d4d..a03be993f88 100644
--- a/jdk/test/java/util/concurrent/tck/StampedLockTest.java
+++ b/jdk/test/java/util/concurrent/tck/StampedLockTest.java
@@ -44,7 +44,6 @@ import java.util.concurrent.TimeUnit;
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.StampedLock;
import java.util.function.BiConsumer;
-import java.util.function.Consumer;
import java.util.function.Function;
import junit.framework.Test;
diff --git a/jdk/test/java/util/concurrent/tck/SubmissionPublisherTest.java b/jdk/test/java/util/concurrent/tck/SubmissionPublisherTest.java
index ab4c9e90438..d72f1af9f5c 100644
--- a/jdk/test/java/util/concurrent/tck/SubmissionPublisherTest.java
+++ b/jdk/test/java/util/concurrent/tck/SubmissionPublisherTest.java
@@ -37,24 +37,14 @@ import java.util.concurrent.Executor;
import java.util.concurrent.Executors;
import java.util.concurrent.Flow;
import java.util.concurrent.ForkJoinPool;
-import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.SubmissionPublisher;
-import java.util.concurrent.ThreadFactory;
-import java.util.concurrent.ThreadPoolExecutor;
-import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicInteger;
-import java.util.function.BiConsumer;
-import java.util.function.BiFunction;
-import java.util.function.BiPredicate;
-import java.util.stream.Stream;
import junit.framework.Test;
import junit.framework.TestSuite;
-import static java.util.concurrent.Flow.Publisher;
import static java.util.concurrent.Flow.Subscriber;
import static java.util.concurrent.Flow.Subscription;
import static java.util.concurrent.TimeUnit.MILLISECONDS;
-import static java.util.concurrent.TimeUnit.SECONDS;
public class SubmissionPublisherTest extends JSR166TestCase {
diff --git a/jdk/test/java/util/concurrent/tck/ThreadPoolExecutorSubclassTest.java b/jdk/test/java/util/concurrent/tck/ThreadPoolExecutorSubclassTest.java
index 3959527af70..83a4f42412c 100644
--- a/jdk/test/java/util/concurrent/tck/ThreadPoolExecutorSubclassTest.java
+++ b/jdk/test/java/util/concurrent/tck/ThreadPoolExecutorSubclassTest.java
@@ -44,7 +44,6 @@ import java.util.concurrent.Callable;
import java.util.concurrent.CancellationException;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.ExecutionException;
-import java.util.concurrent.Executors;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Future;
import java.util.concurrent.FutureTask;
diff --git a/jdk/test/java/util/concurrent/tck/ThreadPoolExecutorTest.java b/jdk/test/java/util/concurrent/tck/ThreadPoolExecutorTest.java
index 5df3c94b120..8a72586f3ae 100644
--- a/jdk/test/java/util/concurrent/tck/ThreadPoolExecutorTest.java
+++ b/jdk/test/java/util/concurrent/tck/ThreadPoolExecutorTest.java
@@ -55,7 +55,6 @@ import java.util.concurrent.RejectedExecutionHandler;
import java.util.concurrent.SynchronousQueue;
import java.util.concurrent.ThreadFactory;
import java.util.concurrent.ThreadPoolExecutor;
-import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicInteger;
import junit.framework.Test;
diff --git a/jdk/test/java/util/jar/JarFile/mrjar/MultiReleaseJarAPI.java b/jdk/test/java/util/jar/JarFile/mrjar/MultiReleaseJarAPI.java
index 4ea94150844..b620e2316ee 100644
--- a/jdk/test/java/util/jar/JarFile/mrjar/MultiReleaseJarAPI.java
+++ b/jdk/test/java/util/jar/JarFile/mrjar/MultiReleaseJarAPI.java
@@ -23,23 +23,29 @@
/*
* @test
- * @bug 8132734 8144062
+ * @bug 8132734 8144062 8165723
* @summary Test the extended API and the aliasing additions in JarFile that
* support multi-release jar files
- * @library /lib/testlibrary/java/util/jar
+ * @library /lib/testlibrary/java/util/jar /lib/testlibrary/
* @build Compiler JarBuilder CreateMultiReleaseTestJars
+ * @build jdk.testlibrary.RandomFactory
* @run testng MultiReleaseJarAPI
*/
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
+import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.util.Arrays;
+import java.util.Map;
+import java.util.Random;
import java.util.jar.JarFile;
import java.util.zip.ZipEntry;
import java.util.zip.ZipFile;
+import jdk.testlibrary.RandomFactory;
+
import org.testng.Assert;
import org.testng.annotations.AfterClass;
import org.testng.annotations.BeforeClass;
@@ -48,12 +54,15 @@ import org.testng.annotations.Test;
public class MultiReleaseJarAPI {
+ private static final Random RANDOM = RandomFactory.getRandom();
+
String userdir = System.getProperty("user.dir",".");
CreateMultiReleaseTestJars creator = new CreateMultiReleaseTestJars();
File unversioned = new File(userdir, "unversioned.jar");
File multirelease = new File(userdir, "multi-release.jar");
File signedmultirelease = new File(userdir, "signed-multi-release.jar");
+
@BeforeClass
public void initialize() throws Exception {
creator.compileEntries();
@@ -99,10 +108,35 @@ public class MultiReleaseJarAPI {
testCustomMultiReleaseValue("true\r ", false);
testCustomMultiReleaseValue("true\n true", false);
testCustomMultiReleaseValue("true\r\n true", false);
+
+ // generate "random" Strings to use as extra attributes, and
+ // verify that Multi-Release: true is always properly matched
+ for (int i = 0; i < 100; i++) {
+ byte[] keyBytes = new byte[RANDOM.nextInt(70) + 1];
+ Arrays.fill(keyBytes, (byte)('a' + RANDOM.nextInt(24)));
+ byte[] valueBytes = new byte[RANDOM.nextInt(70) + 1];
+ Arrays.fill(valueBytes, (byte)('a' + RANDOM.nextInt(24)));
+
+ String key = new String(keyBytes, StandardCharsets.UTF_8);
+ String value = new String(valueBytes, StandardCharsets.UTF_8);
+ // test that Multi-Release: true anywhere in the manifest always
+ // return true
+ testCustomMultiReleaseValue("true", Map.of(key, value), true);
+
+ // test that we don't get any false positives
+ testCustomMultiReleaseValue("false", Map.of(key, value), false);
+ }
}
- private void testCustomMultiReleaseValue(String value, boolean expected) throws Exception {
- creator.buildCustomMultiReleaseJar("custom-mr.jar", value);
+ private void testCustomMultiReleaseValue(String value, boolean expected)
+ throws Exception {
+ testCustomMultiReleaseValue(value, Map.of(), expected);
+ }
+
+ private void testCustomMultiReleaseValue(String value,
+ Map extraAttributes, boolean expected)
+ throws Exception {
+ creator.buildCustomMultiReleaseJar("custom-mr.jar", value, extraAttributes);
File custom = new File(userdir, "custom-mr.jar");
try (JarFile jf = new JarFile(custom, true, ZipFile.OPEN_READ, Runtime.version())) {
Assert.assertEquals(jf.isMultiRelease(), expected);
diff --git a/jdk/test/java/util/logging/Level/CustomLevel.java b/jdk/test/java/util/logging/Level/CustomLevel.java
index a3c452a1e09..8045831d33c 100644
--- a/jdk/test/java/util/logging/Level/CustomLevel.java
+++ b/jdk/test/java/util/logging/Level/CustomLevel.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 2016, 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
@@ -22,12 +22,20 @@
*/
import java.io.*;
+import java.lang.ref.Reference;
+import java.lang.ref.ReferenceQueue;
+import java.lang.ref.WeakReference;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.net.URLClassLoader;
import java.util.*;
import java.util.logging.*;
/*
* @test
- * @bug 8026027
+ * @bug 8026027 6543126
* @summary Test Level.parse to look up custom levels by name and its
* localized name
*
@@ -41,23 +49,168 @@ public class CustomLevel extends Level {
private static final List levels = new ArrayList<>();
private static final String RB_NAME = "myresource";
+ private static final String OTHERRB_NAME = "myresource2";
+
+ private static class CustomLevelReference extends WeakReference {
+ final String name;
+ final int value;
+ final String resourceBundleName;
+ public CustomLevelReference(Level level, ReferenceQueue queue) {
+ super(level, queue);
+ name = level.getName();
+ value = level.intValue();
+ resourceBundleName = level.getResourceBundleName();
+ }
+
+ @Override
+ public String toString() {
+ return "CustomLevelReference(\"" + name + "\", " + value + ", \""
+ + resourceBundleName + "\")";
+ }
+
+ }
+
public static void main(String[] args) throws Exception {
setupCustomLevels();
+ setUpCustomLevelsOtherLoader();
// Level.parse will return the custom Level instance
- ResourceBundle rb = ResourceBundle.getBundle(RB_NAME);
for (Level level : levels) {
+ final ResourceBundle rb = getResourceBundle(level);
String name = level.getName();
- if (!name.equals("WARNING") && !name.equals("INFO")) {
+ Level l = Level.parse(name);
+ if (!name.equals("WARNING") && !name.equals("INFO")
+ && !name.equals("SEVERE")) {
// custom level whose name doesn't conflict with any standard one
- checkCustomLevel(Level.parse(name), level);
+ checkCustomLevel(l, level);
+ } else if (l != Level.WARNING && l != Level.INFO && l != Level.SEVERE
+ || !name.equals(l.getName())) {
+ throw new RuntimeException("Unexpected level " + formatLevel(l));
}
+ System.out.println("Level.parse found expected level: "
+ + formatLevel(l));
String localizedName = rb.getString(level.getName());
- Level l = Level.parse(localizedName);
+ l = Level.parse(localizedName);
if (l != level) {
- throw new RuntimeException("Unexpected level " + l + " " + l.getClass());
+ throw new RuntimeException("Unexpected level " + l + " "
+ + l.getClass() + " for " + localizedName
+ + " in " + rb.getBaseBundleName());
}
}
+
+ final long otherLevelCount = levels.stream()
+ .filter(CustomLevel::isCustomLoader)
+ .count();
+
+ // Now verify that custom level instances are correctly
+ // garbage collected when no longer referenced
+ ReferenceQueue queue = new ReferenceQueue<>();
+ List refs = new ArrayList<>();
+ List customRefs = new ArrayList<>();
+ int otherLevels = 0;
+ while (!levels.isEmpty()) {
+ Level l = levels.stream().findAny().get();
+ boolean isCustomLoader = isCustomLoader(l);
+ if (isCustomLoader) otherLevels++;
+
+ CustomLevelReference ref = new CustomLevelReference(l, queue);
+ if (isCustomLoader) {
+ customRefs.add(ref);
+ } else {
+ refs.add(ref);
+ }
+
+ // remove strong references to l
+ levels.remove(l);
+ l = null;
+
+ // Run gc and wait for garbage collection
+ if (otherLevels == otherLevelCount) {
+ if (customRefs.size() != otherLevelCount) {
+ throw new RuntimeException("Test bug: customRefs.size() != "
+ + otherLevelCount);
+ }
+ waitForGC(customRefs, queue);
+ }
+ }
+ if (otherLevelCount != otherLevels || otherLevelCount == 0) {
+ throw new RuntimeException("Test bug: "
+ + "no or wrong count of levels loaded from custom loader");
+ }
+ if (!customRefs.isEmpty()) {
+ throw new RuntimeException(
+ "Test bug: customRefs.size() should be empty!");
+ }
+ while (!refs.isEmpty()) {
+ final Reference> ref = refs.remove(0);
+ if (ref.get() == null) {
+ throw new RuntimeException("Unexpected garbage collection for "
+ + ref);
+ }
+ }
+ }
+
+ private static void waitForGC(List customRefs,
+ ReferenceQueue queue)
+ throws InterruptedException
+ {
+ while (!customRefs.isEmpty()) {
+ Reference extends Level> ref2;
+ do {
+ System.gc();
+ Thread.sleep(100);
+ } while ((ref2 = queue.poll()) == null);
+
+ // Check garbage collected reference
+ if (!customRefs.contains(ref2)) {
+ throw new RuntimeException("Unexpected reference: " + ref2);
+ }
+ CustomLevelReference ref = customRefs.remove(customRefs.indexOf(ref2));
+ System.out.println(ref2 + " garbage collected");
+ final String name = ref.name;
+ Level l;
+ try {
+ l = Level.parse(name);
+ if (!name.equals("SEVERE")
+ && !name.equals("INFO")
+ || !name.equals(l.getName())) {
+ throw new RuntimeException("Unexpected level "
+ + formatLevel(l));
+ } else {
+ if (l == Level.WARNING || l == Level.INFO
+ || l == Level.SEVERE) {
+ System.out.println("Level.parse found expected level: "
+ + formatLevel(l));
+ } else {
+ throw new RuntimeException("Unexpected level "
+ + formatLevel(l));
+ }
+ }
+ } catch (IllegalArgumentException iae) {
+ if (!name.equals("WARNING")
+ && !name.equals("INFO")
+ && !name.equals("SEVERE")) {
+ System.out.println("Level.parse fired expected exception: "
+ + iae);
+ } else {
+ throw iae;
+ }
+ }
+ }
+ }
+
+ private static boolean isCustomLoader(Level level) {
+ final ClassLoader cl = level.getClass().getClassLoader();
+ return cl != null
+ && cl != ClassLoader.getPlatformClassLoader()
+ && cl != ClassLoader.getSystemClassLoader();
+ }
+
+ static ResourceBundle getResourceBundle(Level level) {
+ return isCustomLoader(level)
+ ? ResourceBundle.getBundle(OTHERRB_NAME, Locale.getDefault(),
+ level.getClass().getClassLoader())
+ : ResourceBundle.getBundle(RB_NAME);
}
private static void setupCustomLevels() throws IOException {
@@ -67,22 +220,53 @@ public class CustomLevel extends Level {
levels.add(new CustomLevel("WARNING", 1010, RB_NAME));
levels.add(new CustomLevel("INFO", 1000, RB_NAME));
}
+
+ static void setUpCustomLevelsOtherLoader()
+ throws MalformedURLException,
+ ClassNotFoundException, NoSuchMethodException,
+ IllegalAccessException, InvocationTargetException
+ {
+ final String classes = System.getProperty("test.classes",
+ "build/classes");
+ final String sources = System.getProperty("test.src",
+ "src");
+ final URL curl = new File(classes).toURI().toURL();
+ final URL surl = new File(sources).toURI().toURL();
+ URLClassLoader loader = new URLClassLoader(new URL[] {curl, surl},
+ ClassLoader.getPlatformClassLoader());
+ Class> customLevelClass = Class.forName("CustomLevel", false, loader);
+ Method m = customLevelClass.getMethod("setUpCustomLevelsOtherLoader",
+ List.class);
+ m.invoke(null, levels);
+ }
+
+ public static void setUpCustomLevelsOtherLoader(List levels) {
+ levels.add(new CustomLevel("OTHEREMERGENCY", 1091, OTHERRB_NAME));
+ levels.add(new CustomLevel("OTHERALERT", 1061, OTHERRB_NAME));
+ levels.add(new CustomLevel("OTHERCRITICAL", 1031, OTHERRB_NAME));
+ levels.add(new CustomLevel("SEVERE", 1011, OTHERRB_NAME));
+ levels.add(new CustomLevel("INFO", 1000, OTHERRB_NAME));
+ }
+
static void checkCustomLevel(Level level, Level expected) {
// Level value must be the same
if (!level.equals(expected)) {
- throw new RuntimeException(formatLevel(level) + " != " + formatLevel(expected));
+ throw new RuntimeException(formatLevel(level) + " != "
+ + formatLevel(expected));
}
if (!level.getName().equals(expected.getName())) {
- throw new RuntimeException(formatLevel(level) + " != " + formatLevel(expected));
+ throw new RuntimeException(formatLevel(level) + " != "
+ + formatLevel(expected));
}
// Level.parse is expected to return the custom Level
if (level != expected) {
- throw new RuntimeException(formatLevel(level) + " != " + formatLevel(expected));
+ throw new RuntimeException(formatLevel(level) + " != "
+ + formatLevel(expected));
}
- ResourceBundle rb = ResourceBundle.getBundle(RB_NAME);
+ final ResourceBundle rb = getResourceBundle(level);
String name = rb.getString(level.getName());
if (!level.getLocalizedName().equals(name)) {
// must have the same localized name
diff --git a/jdk/test/java/util/logging/Level/myresource2.properties b/jdk/test/java/util/logging/Level/myresource2.properties
new file mode 100644
index 00000000000..b7e68d4673a
--- /dev/null
+++ b/jdk/test/java/util/logging/Level/myresource2.properties
@@ -0,0 +1,5 @@
+OTHEREMERGENCY=localized.otheremergency
+OTHERALERT=localized.otheralert
+OTHERCRITICAL=localized.othercritical
+SEVERE=localized.severe
+INFO=localized.info.2
diff --git a/jdk/test/javax/script/ExceptionTest.java b/jdk/test/javax/script/ExceptionTest.java
index ccfcc73130f..02c86e304d2 100644
--- a/jdk/test/javax/script/ExceptionTest.java
+++ b/jdk/test/javax/script/ExceptionTest.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2006, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2006, 2016, 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,10 +26,14 @@
* @bug 6474943 6705893
* @summary Test that script engine exception messages are
* available from ScriptException.
+ * @modules jdk.scripting.nashorn
*/
-import java.io.*;
-import javax.script.*;
+import javax.script.Compilable;
+import javax.script.CompiledScript;
+import javax.script.ScriptEngine;
+import javax.script.ScriptEngineManager;
+import javax.script.ScriptException;
public class ExceptionTest {
private static final String ERROR_MSG = "error from JavaScript";
diff --git a/jdk/test/javax/script/JavaScriptScopeTest.java b/jdk/test/javax/script/JavaScriptScopeTest.java
index 248fdb7c108..b1ed27e36a1 100644
--- a/jdk/test/javax/script/JavaScriptScopeTest.java
+++ b/jdk/test/javax/script/JavaScriptScopeTest.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2005, 2008, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2016, 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,9 +28,13 @@
* get affected by default scope assignments. Also, verify
* that script globals can be created and accessed from Java
* as well as JavaScript.
+ * @modules jdk.scripting.nashorn
*/
-import javax.script.*;
+import javax.script.Bindings;
+import javax.script.ScriptEngine;
+import javax.script.ScriptEngineManager;
+
public class JavaScriptScopeTest {
diff --git a/jdk/test/javax/script/NullUndefinedVarTest.java b/jdk/test/javax/script/NullUndefinedVarTest.java
index a02656f895d..e9ad24705a4 100644
--- a/jdk/test/javax/script/NullUndefinedVarTest.java
+++ b/jdk/test/javax/script/NullUndefinedVarTest.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2005, 2008, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2016, 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,9 +26,11 @@
* @bug 6346732 6705893
* @summary should be able to assign null and undefined
* value to JavaScript global variables.
+ * @modules jdk.scripting.nashorn
*/
-import javax.script.*;
+import javax.script.ScriptEngine;
+import javax.script.ScriptEngineManager;
public class NullUndefinedVarTest {
diff --git a/jdk/test/javax/script/PluggableContextTest.java b/jdk/test/javax/script/PluggableContextTest.java
index 9f68090c159..07a32125740 100644
--- a/jdk/test/javax/script/PluggableContextTest.java
+++ b/jdk/test/javax/script/PluggableContextTest.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2006, 2008, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2006, 2016, 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,9 +26,12 @@
* @bug 6398614 6705893
* @summary Create a user defined ScriptContext and check
* that script can access variables from non-standard scopes
+ * @modules jdk.scripting.nashorn
*/
-import javax.script.*;
+import javax.script.ScriptContext;
+import javax.script.ScriptEngine;
+import javax.script.ScriptEngineManager;
public class PluggableContextTest {
public static void main(String[] args) throws Exception {
diff --git a/jdk/test/javax/script/Test1.java b/jdk/test/javax/script/Test1.java
index 9d5bebbebda..3c45b938f1e 100644
--- a/jdk/test/javax/script/Test1.java
+++ b/jdk/test/javax/script/Test1.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2005, 2008, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2016, 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,10 +26,13 @@
* @bug 6249843 6705893
* @summary Create JavaScript engine and execute a simple script.
* Tests script engine discovery mechanism.
+ * @modules jdk.scripting.nashorn
*/
-import javax.script.*;
-import java.io.*;
+import java.io.File;
+import java.io.FileReader;
+import javax.script.ScriptEngine;
+import javax.script.ScriptEngineManager;
public class Test1 {
public static void main(String[] args) throws Exception {
diff --git a/jdk/test/javax/script/Test2.java b/jdk/test/javax/script/Test2.java
index ea93ca5918c..318aae09d8e 100644
--- a/jdk/test/javax/script/Test2.java
+++ b/jdk/test/javax/script/Test2.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2005, 2008, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2016, 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
@@ -25,10 +25,13 @@
* @test
* @bug 6249843
* @summary Test exposing a Java object to script
+ * @modules jdk.scripting.nashorn
*/
-import javax.script.*;
-import java.io.*;
+import java.io.File;
+import java.io.FileReader;
+import javax.script.ScriptEngine;
+import javax.script.ScriptEngineManager;
public class Test2 {
public static class Testobj {
diff --git a/jdk/test/javax/script/Test3.java b/jdk/test/javax/script/Test3.java
index 83237193e52..0c28bf35437 100644
--- a/jdk/test/javax/script/Test3.java
+++ b/jdk/test/javax/script/Test3.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2005, 2008, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2016, 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
@@ -25,11 +25,17 @@
* @test
* @bug 6249843 6705893
* @summary Test engine and global scopes
+ * @modules jdk.scripting.nashorn
*/
-import javax.script.*;
-import java.io.*;
-import java.util.*;
+import java.io.File;
+import java.io.FileReader;
+import java.io.Reader;
+import javax.script.Bindings;
+import javax.script.ScriptContext;
+import javax.script.ScriptEngine;
+import javax.script.ScriptEngineManager;
+import javax.script.SimpleBindings;
public class Test3 {
public static void main(String[] args) throws Exception {
diff --git a/jdk/test/javax/script/Test4.java b/jdk/test/javax/script/Test4.java
index a92c99c22ed..106de4fd59a 100644
--- a/jdk/test/javax/script/Test4.java
+++ b/jdk/test/javax/script/Test4.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2005, 2008, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2016, 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
@@ -25,10 +25,14 @@
* @test
* @bug 6249843 6705893
* @summary Test script functions implementing Java interface
+ * @modules jdk.scripting.nashorn
*/
-import javax.script.*;
-import java.io.*;
+import java.io.File;
+import java.io.FileReader;
+import javax.script.Invocable;
+import javax.script.ScriptEngine;
+import javax.script.ScriptEngineManager;
public class Test4 {
public static void main(String[] args) throws Exception {
diff --git a/jdk/test/javax/script/Test5.java b/jdk/test/javax/script/Test5.java
index 2159647c6c4..1bcb7239b8d 100644
--- a/jdk/test/javax/script/Test5.java
+++ b/jdk/test/javax/script/Test5.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2016, 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
@@ -25,10 +25,18 @@
* @test
* @bug 6249843 6705893
* @summary Tests engine, global scopes and scope hiding.
+ * @modules jdk.scripting.nashorn
*/
-import java.io.*;
-import javax.script.*;
+import java.io.File;
+import java.io.FileReader;
+import java.io.Reader;
+import javax.script.Bindings;
+import javax.script.ScriptContext;
+import javax.script.ScriptEngine;
+import javax.script.ScriptEngineManager;
+import javax.script.SimpleBindings;
+import javax.script.SimpleScriptContext;
public class Test5 {
public static void main(String[] args) throws Exception {
diff --git a/jdk/test/javax/script/Test6.java b/jdk/test/javax/script/Test6.java
index fadff34bc08..949b3af67a3 100644
--- a/jdk/test/javax/script/Test6.java
+++ b/jdk/test/javax/script/Test6.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2016, 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,10 +26,16 @@
* @bug 6249843 6705893
* @summary Test basic script compilation. Value eval'ed from
* compiled and interpreted scripts should be same.
+ * @modules jdk.scripting.nashorn
*/
-import java.io.*;
-import javax.script.*;
+import java.io.File;
+import java.io.FileReader;
+import java.io.Reader;
+import javax.script.Compilable;
+import javax.script.CompiledScript;
+import javax.script.ScriptEngine;
+import javax.script.ScriptEngineManager;
public class Test6 {
public static void main(String[] args) throws Exception {
diff --git a/jdk/test/javax/script/Test7.java b/jdk/test/javax/script/Test7.java
index dbe1890df5c..fd7402fbb66 100644
--- a/jdk/test/javax/script/Test7.java
+++ b/jdk/test/javax/script/Test7.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2005, 2008, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2016, 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
@@ -25,10 +25,14 @@
* @test
* @bug 6249843 6705893
* @summary Tests importPackage and java access in script
+ * @modules jdk.scripting.nashorn
*/
-import java.io.*;
-import javax.script.*;
+import java.io.File;
+import java.io.FileReader;
+import java.io.Reader;
+import javax.script.ScriptEngine;
+import javax.script.ScriptEngineManager;
public class Test7 {
public static void main(String[] args) throws Exception {
diff --git a/jdk/test/javax/script/Test8.java b/jdk/test/javax/script/Test8.java
index f83cd1c3a0f..3848e434750 100644
--- a/jdk/test/javax/script/Test8.java
+++ b/jdk/test/javax/script/Test8.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2005, 2008, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2016, 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
@@ -25,10 +25,14 @@
* @test
* @bug 6249843 6705893
* @summary Test invoking script function or method from Java
+ * @modules jdk.scripting.nashorn
*/
-import javax.script.*;
-import java.io.*;
+import java.io.File;
+import java.io.FileReader;
+import javax.script.Invocable;
+import javax.script.ScriptEngine;
+import javax.script.ScriptEngineManager;
public class Test8 {
public static void main(String[] args) throws Exception {
diff --git a/jdk/test/jdk/internal/util/jar/TestVersionedStream.java b/jdk/test/jdk/internal/util/jar/TestVersionedStream.java
new file mode 100644
index 00000000000..12e45f03b77
--- /dev/null
+++ b/jdk/test/jdk/internal/util/jar/TestVersionedStream.java
@@ -0,0 +1,214 @@
+/*
+ * Copyright (c) 2016, 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 8163798
+ * @summary basic tests for multi-release jar versioned streams
+ * @modules jdk.jartool/sun.tools.jar java.base/jdk.internal.util.jar
+ * @run testng TestVersionedStream
+ */
+
+import org.testng.Assert;
+import org.testng.annotations.AfterClass;
+import org.testng.annotations.BeforeClass;
+import org.testng.annotations.DataProvider;
+import org.testng.annotations.Test;
+
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.UncheckedIOException;
+import java.net.URI;
+import java.nio.file.FileVisitResult;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.nio.file.SimpleFileVisitor;
+import java.nio.file.attribute.BasicFileAttributes;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.jar.JarEntry;
+import java.util.jar.JarFile;
+import java.util.stream.Collectors;
+import java.util.stream.Stream;
+import java.util.zip.ZipFile;
+
+public class TestVersionedStream {
+ private String userdir;
+
+ @BeforeClass
+ public void initialize() {
+ userdir = System.getProperty("user.dir", ".");
+
+ // These are not real class files even though they end with .class.
+ // They are resource files so jar tool validation won't reject them.
+ // But they are what we want to test, especially q/Bar.class that
+ // could be in a concealed package if this was a modular multi-release
+ // jar.
+ createFiles(
+ "base/p/Foo.class",
+ "base/p/Main.class",
+ "v9/p/Foo.class",
+ "v10/p/Foo.class",
+ "v10/q/Bar.class",
+ "v11/p/Foo.class"
+ );
+
+ jar("cf mmr.jar -C base . --release 9 -C v9 . --release 10 -C v10 . --release 11 -C v11 .");
+
+ System.out.println("Contents of mmr.jar\n=======");
+ jar("tf mmr.jar");
+ System.out.println("=======");
+ }
+
+ @AfterClass
+ public void close() throws IOException {
+ Path root = Paths.get(userdir);
+ Files.walkFileTree(root, new SimpleFileVisitor<>() {
+ @Override
+ public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException {
+ Files.delete(file);
+ return FileVisitResult.CONTINUE;
+ }
+
+ @Override
+ public FileVisitResult postVisitDirectory(Path dir, IOException exc) throws IOException {
+ if (!dir.equals(root)) {
+ Files.delete(dir);
+ }
+ return FileVisitResult.CONTINUE;
+ }
+ });
+ }
+
+ @DataProvider
+ public Object[][] data() {
+ List p = List.of(
+ "META-INF/",
+ "META-INF/MANIFEST.MF",
+ "p/",
+ "p/Foo.class",
+ "p/Main.class"
+ );
+ List q = List.of(
+ "META-INF/",
+ "META-INF/MANIFEST.MF",
+ "p/",
+ "p/Foo.class",
+ "p/Main.class",
+ "q/",
+ "q/Bar.class"
+ );
+ Runtime.Version rt = JarFile.runtimeVersion();
+ return new Object[][] {
+ {Runtime.Version.parse("8"), p},
+ {Runtime.Version.parse("9"), p},
+ {Runtime.Version.parse("10"), q},
+ {Runtime.Version.parse("11"), q},
+ {JarFile.baseVersion(), p},
+ {rt, rt.major() > 9 ? q : p}
+ };
+ }
+
+ @Test(dataProvider="data")
+ public void test(Runtime.Version version, List names) throws Exception {
+ try (JarFile jf = new JarFile(new File("mmr.jar"), false, ZipFile.OPEN_READ, version);
+ Stream jes = jdk.internal.util.jar.VersionedStream.stream(jf))
+ {
+ Assert.assertNotNull(jes);
+
+ List entries = jes.collect(Collectors.toList());
+
+ // verify the correct order
+ List enames = entries.stream()
+ .map(je -> je.getName())
+ .collect(Collectors.toList());
+ Assert.assertEquals(enames, names);
+
+ // verify the contents
+ Map contents = new HashMap<>();
+ contents.put("p/Main.class", "base/p/Main.class\n");
+ if (version.major() > 9) {
+ contents.put("q/Bar.class", "v10/q/Bar.class\n");
+ }
+ switch (version.major()) {
+ case 8:
+ contents.put("p/Foo.class", "base/p/Foo.class\n");
+ break;
+ case 9:
+ contents.put("p/Foo.class", "v9/p/Foo.class\n");
+ break;
+ case 10:
+ contents.put("p/Foo.class", "v10/p/Foo.class\n");
+ break;
+ case 11:
+ contents.put("p/Foo.class", "v11/p/Foo.class\n");
+ break;
+ default:
+ Assert.fail("Test out of date, please add more cases");
+ }
+
+ contents.entrySet().stream().forEach(e -> {
+ String name = e.getKey();
+ int i = enames.indexOf(name);
+ Assert.assertTrue(i != -1, name + " not in enames");
+ JarEntry je = entries.get(i);
+ try (InputStream is = jf.getInputStream(je)) {
+ String s = new String(is.readAllBytes());
+ Assert.assertTrue(s.endsWith(e.getValue()), s);
+ } catch (IOException x) {
+ throw new UncheckedIOException(x);
+ }
+ });
+ }
+ }
+
+ private void createFiles(String... files) {
+ ArrayList list = new ArrayList();
+ Arrays.stream(files)
+ .map(f -> "file:///" + userdir + "/" + f)
+ .map(f -> URI.create(f))
+ .filter(u -> u != null)
+ .map(u -> Paths.get(u))
+ .forEach(p -> {
+ try {
+ Files.createDirectories(p.getParent());
+ Files.createFile(p);
+ list.clear();
+ list.add(p.toString());
+ Files.write(p, list);
+ } catch (IOException x) {
+ throw new UncheckedIOException(x);
+ }});
+ }
+
+ private void jar(String args) {
+ new sun.tools.jar.Main(System.out, System.err, "jar")
+ .run(args.split(" +"));
+ }
+
+}
diff --git a/jdk/test/lib/testlibrary/java/util/jar/CreateMultiReleaseTestJars.java b/jdk/test/lib/testlibrary/java/util/jar/CreateMultiReleaseTestJars.java
index 672b7c2d205..504472f1f7e 100644
--- a/jdk/test/lib/testlibrary/java/util/jar/CreateMultiReleaseTestJars.java
+++ b/jdk/test/lib/testlibrary/java/util/jar/CreateMultiReleaseTestJars.java
@@ -88,31 +88,35 @@ public class CreateMultiReleaseTestJars {
}
public void buildMultiReleaseJar() throws IOException {
- buildCustomMultiReleaseJar("multi-release.jar", "true");
- }
-
- public void buildCustomMultiReleaseJar(String filename, String multiReleaseValue) throws IOException {
- JarBuilder jb = new JarBuilder(filename);
- jb.addAttribute("Multi-Release", multiReleaseValue);
- jb.addEntry("README", readme8.getBytes());
- jb.addEntry("version/Main.java", main.getBytes());
- jb.addEntry("version/Main.class", rootClasses.get("version.Main"));
- jb.addEntry("version/Version.java", java8.getBytes());
- jb.addEntry("version/Version.class", rootClasses.get("version.Version"));
- jb.addEntry("META-INF/versions/9/README", readme9.getBytes());
- jb.addEntry("META-INF/versions/9/version/Version.java", java9.getBytes());
- jb.addEntry("META-INF/versions/9/version/PackagePrivate.java", ppjava9.getBytes());
+ JarBuilder jb = customMultiReleaseJar("multi-release.jar", "true");
+ addEntries(jb);
jb.addEntry("META-INF/versions/9/version/Version.class", version9Classes.get("version.Version"));
- jb.addEntry("META-INF/versions/9/version/PackagePrivate.class", version9Classes.get("version.PackagePrivate"));
- jb.addEntry("META-INF/versions/10/README", readme10.getBytes());
- jb.addEntry("META-INF/versions/10/version/Version.java", java10.getBytes());
- jb.addEntry("META-INF/versions/10/version/Version.class", version10Classes.get("version.Version"));
jb.build();
}
public void buildShortMultiReleaseJar() throws IOException {
- JarBuilder jb = new JarBuilder("short-multi-release.jar");
- jb.addAttribute("Multi-Release", "true");
+ JarBuilder jb = customMultiReleaseJar("short-multi-release.jar", "true");
+ addEntries(jb);
+ jb.build();
+ }
+
+ private JarBuilder customMultiReleaseJar(String filename, String multiReleaseValue)
+ throws IOException {
+ JarBuilder jb = new JarBuilder(filename);
+ jb.addAttribute("Multi-Release", multiReleaseValue);
+ return jb;
+ }
+
+ public void buildCustomMultiReleaseJar(String filename, String multiReleaseValue,
+ Map extraAttributes) throws IOException {
+ JarBuilder jb = new JarBuilder(filename);
+ extraAttributes.entrySet()
+ .forEach(entry -> jb.addAttribute(entry.getKey(), entry.getValue()));
+ jb.addAttribute("Multi-Release", multiReleaseValue);
+ jb.build();
+ }
+
+ private void addEntries(JarBuilder jb) {
jb.addEntry("README", readme8.getBytes());
jb.addEntry("version/Main.java", main.getBytes());
jb.addEntry("version/Main.class", rootClasses.get("version.Main"));
@@ -121,12 +125,10 @@ public class CreateMultiReleaseTestJars {
jb.addEntry("META-INF/versions/9/README", readme9.getBytes());
jb.addEntry("META-INF/versions/9/version/Version.java", java9.getBytes());
jb.addEntry("META-INF/versions/9/version/PackagePrivate.java", ppjava9.getBytes());
- // no entry for META-INF/versions/9/version/Version.class
jb.addEntry("META-INF/versions/9/version/PackagePrivate.class", version9Classes.get("version.PackagePrivate"));
jb.addEntry("META-INF/versions/10/README", readme10.getBytes());
jb.addEntry("META-INF/versions/10/version/Version.java", java10.getBytes());
jb.addEntry("META-INF/versions/10/version/Version.class", version10Classes.get("version.Version"));
- jb.build();
}
public void buildSignedMultiReleaseJar() throws Exception {
diff --git a/jdk/test/sun/net/www/protocol/jar/JarURLConnectionUseCaches.java b/jdk/test/sun/net/www/protocol/jar/JarURLConnectionUseCaches.java
new file mode 100644
index 00000000000..b623618a595
--- /dev/null
+++ b/jdk/test/sun/net/www/protocol/jar/JarURLConnectionUseCaches.java
@@ -0,0 +1,63 @@
+/*
+ * Copyright (c) 2016, 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 6947916
+ * @summary JarURLConnection does not handle useCaches correctly
+ * @run main JarURLConnectionUseCaches
+ */
+
+import java.io.*;
+import java.net.JarURLConnection;
+import java.net.URL;
+import java.util.jar.*;
+
+public class JarURLConnectionUseCaches {
+ public static void main( String[] args ) throws IOException {
+ JarOutputStream out = new JarOutputStream(
+ new FileOutputStream("usecache.jar"));
+ out.putNextEntry(new JarEntry("test.txt"));
+ out.write("Test txt file".getBytes());
+ out.closeEntry();
+ out.close();
+
+ URL url = new URL("jar:"
+ + new File(".").toURI().toString()
+ + "/usecache.jar!/test.txt");
+
+ JarURLConnection c1 = (JarURLConnection)url.openConnection();
+ c1.setDefaultUseCaches( false );
+ c1.setUseCaches( true );
+ c1.connect();
+
+ JarURLConnection c2 = (JarURLConnection)url.openConnection();
+ c2.setDefaultUseCaches( false );
+ c2.setUseCaches( true );
+ c2.connect();
+
+ c1.getInputStream().close();
+ c2.getInputStream().read();
+ c2.getInputStream().close();
+ }
+}
diff --git a/jdk/test/sun/security/pkcs11/PKCS11Test.java b/jdk/test/sun/security/pkcs11/PKCS11Test.java
index f3e14c7d213..3752baba8da 100644
--- a/jdk/test/sun/security/pkcs11/PKCS11Test.java
+++ b/jdk/test/sun/security/pkcs11/PKCS11Test.java
@@ -82,8 +82,6 @@ public abstract class PKCS11Test {
System.setProperty("closed.base", CLOSED_BASE);
}
- static String NSPR_PREFIX = "";
-
// NSS version info
public static enum ECCState { None, Basic, Extended };
static double nss_version = -1;
@@ -294,7 +292,6 @@ public abstract class PKCS11Test {
String osName = props.getProperty("os.name");
if (osName.startsWith("Win")) {
osName = "Windows";
- NSPR_PREFIX = "lib";
} else if (osName.equals("Mac OS X")) {
osName = "MacOSX";
}
@@ -342,9 +339,9 @@ public abstract class PKCS11Test {
static boolean loadNSPR(String libdir) throws Exception {
// load NSS softoken dependencies in advance to avoid resolver issues
- safeReload(libdir + System.mapLibraryName(NSPR_PREFIX + "nspr4"));
- safeReload(libdir + System.mapLibraryName(NSPR_PREFIX + "plc4"));
- safeReload(libdir + System.mapLibraryName(NSPR_PREFIX + "plds4"));
+ safeReload(libdir + System.mapLibraryName("nspr4"));
+ safeReload(libdir + System.mapLibraryName("plc4"));
+ safeReload(libdir + System.mapLibraryName("plds4"));
safeReload(libdir + System.mapLibraryName("sqlite3"));
safeReload(libdir + System.mapLibraryName("nssutil3"));
return true;
diff --git a/jdk/test/sun/security/pkcs11/nss/lib/windows-amd64/freebl3.chk b/jdk/test/sun/security/pkcs11/nss/lib/windows-amd64/freebl3.chk
index 7ea34d02d97..60c46169a6b 100644
Binary files a/jdk/test/sun/security/pkcs11/nss/lib/windows-amd64/freebl3.chk and b/jdk/test/sun/security/pkcs11/nss/lib/windows-amd64/freebl3.chk differ
diff --git a/jdk/test/sun/security/pkcs11/nss/lib/windows-amd64/freebl3.dll b/jdk/test/sun/security/pkcs11/nss/lib/windows-amd64/freebl3.dll
index 6c03f7d54e5..bb662ad9e82 100644
Binary files a/jdk/test/sun/security/pkcs11/nss/lib/windows-amd64/freebl3.dll and b/jdk/test/sun/security/pkcs11/nss/lib/windows-amd64/freebl3.dll differ
diff --git a/jdk/test/sun/security/pkcs11/nss/lib/windows-amd64/libnspr4.dll b/jdk/test/sun/security/pkcs11/nss/lib/windows-amd64/libnspr4.dll
deleted file mode 100644
index fc573be7d36..00000000000
Binary files a/jdk/test/sun/security/pkcs11/nss/lib/windows-amd64/libnspr4.dll and /dev/null differ
diff --git a/jdk/test/sun/security/pkcs11/nss/lib/windows-amd64/libnspr4.lib b/jdk/test/sun/security/pkcs11/nss/lib/windows-amd64/libnspr4.lib
deleted file mode 100644
index 64aa29695e1..00000000000
Binary files a/jdk/test/sun/security/pkcs11/nss/lib/windows-amd64/libnspr4.lib and /dev/null differ
diff --git a/jdk/test/sun/security/pkcs11/nss/lib/windows-amd64/libplc4.dll b/jdk/test/sun/security/pkcs11/nss/lib/windows-amd64/libplc4.dll
deleted file mode 100644
index 519c80e3e09..00000000000
Binary files a/jdk/test/sun/security/pkcs11/nss/lib/windows-amd64/libplc4.dll and /dev/null differ
diff --git a/jdk/test/sun/security/pkcs11/nss/lib/windows-amd64/libplc4.lib b/jdk/test/sun/security/pkcs11/nss/lib/windows-amd64/libplc4.lib
deleted file mode 100644
index 1df6f28c331..00000000000
Binary files a/jdk/test/sun/security/pkcs11/nss/lib/windows-amd64/libplc4.lib and /dev/null differ
diff --git a/jdk/test/sun/security/pkcs11/nss/lib/windows-amd64/libplds4.dll b/jdk/test/sun/security/pkcs11/nss/lib/windows-amd64/libplds4.dll
deleted file mode 100644
index dc56672cb02..00000000000
Binary files a/jdk/test/sun/security/pkcs11/nss/lib/windows-amd64/libplds4.dll and /dev/null differ
diff --git a/jdk/test/sun/security/pkcs11/nss/lib/windows-amd64/libplds4.lib b/jdk/test/sun/security/pkcs11/nss/lib/windows-amd64/libplds4.lib
deleted file mode 100644
index b424eefcce1..00000000000
Binary files a/jdk/test/sun/security/pkcs11/nss/lib/windows-amd64/libplds4.lib and /dev/null differ
diff --git a/jdk/test/sun/security/pkcs11/nss/lib/windows-amd64/nspr4.dll b/jdk/test/sun/security/pkcs11/nss/lib/windows-amd64/nspr4.dll
new file mode 100644
index 00000000000..5b65fc625f2
Binary files /dev/null and b/jdk/test/sun/security/pkcs11/nss/lib/windows-amd64/nspr4.dll differ
diff --git a/jdk/test/sun/security/pkcs11/nss/lib/windows-amd64/nspr4.lib b/jdk/test/sun/security/pkcs11/nss/lib/windows-amd64/nspr4.lib
new file mode 100644
index 00000000000..f6026ecc84e
Binary files /dev/null and b/jdk/test/sun/security/pkcs11/nss/lib/windows-amd64/nspr4.lib differ
diff --git a/jdk/test/sun/security/pkcs11/nss/lib/windows-amd64/nss3.dll b/jdk/test/sun/security/pkcs11/nss/lib/windows-amd64/nss3.dll
index 67f06d47bd1..18248a2b928 100644
Binary files a/jdk/test/sun/security/pkcs11/nss/lib/windows-amd64/nss3.dll and b/jdk/test/sun/security/pkcs11/nss/lib/windows-amd64/nss3.dll differ
diff --git a/jdk/test/sun/security/pkcs11/nss/lib/windows-amd64/nss3.lib b/jdk/test/sun/security/pkcs11/nss/lib/windows-amd64/nss3.lib
index c73d3efa1ad..278fd95ed9d 100644
Binary files a/jdk/test/sun/security/pkcs11/nss/lib/windows-amd64/nss3.lib and b/jdk/test/sun/security/pkcs11/nss/lib/windows-amd64/nss3.lib differ
diff --git a/jdk/test/sun/security/pkcs11/nss/lib/windows-amd64/nssckbi.dll b/jdk/test/sun/security/pkcs11/nss/lib/windows-amd64/nssckbi.dll
index 28c84743adb..20b011561fe 100644
Binary files a/jdk/test/sun/security/pkcs11/nss/lib/windows-amd64/nssckbi.dll and b/jdk/test/sun/security/pkcs11/nss/lib/windows-amd64/nssckbi.dll differ
diff --git a/jdk/test/sun/security/pkcs11/nss/lib/windows-amd64/nssdbm3.chk b/jdk/test/sun/security/pkcs11/nss/lib/windows-amd64/nssdbm3.chk
index e8e9b94fb10..797ec741495 100644
Binary files a/jdk/test/sun/security/pkcs11/nss/lib/windows-amd64/nssdbm3.chk and b/jdk/test/sun/security/pkcs11/nss/lib/windows-amd64/nssdbm3.chk differ
diff --git a/jdk/test/sun/security/pkcs11/nss/lib/windows-amd64/nssdbm3.dll b/jdk/test/sun/security/pkcs11/nss/lib/windows-amd64/nssdbm3.dll
index f1a722cd983..8eb93e01e6d 100644
Binary files a/jdk/test/sun/security/pkcs11/nss/lib/windows-amd64/nssdbm3.dll and b/jdk/test/sun/security/pkcs11/nss/lib/windows-amd64/nssdbm3.dll differ
diff --git a/jdk/test/sun/security/pkcs11/nss/lib/windows-amd64/nssutil3.dll b/jdk/test/sun/security/pkcs11/nss/lib/windows-amd64/nssutil3.dll
index 3eeca26f262..80f3ad0ad88 100644
Binary files a/jdk/test/sun/security/pkcs11/nss/lib/windows-amd64/nssutil3.dll and b/jdk/test/sun/security/pkcs11/nss/lib/windows-amd64/nssutil3.dll differ
diff --git a/jdk/test/sun/security/pkcs11/nss/lib/windows-amd64/nssutil3.lib b/jdk/test/sun/security/pkcs11/nss/lib/windows-amd64/nssutil3.lib
index 9f6ea2dee6c..819ade0768c 100644
Binary files a/jdk/test/sun/security/pkcs11/nss/lib/windows-amd64/nssutil3.lib and b/jdk/test/sun/security/pkcs11/nss/lib/windows-amd64/nssutil3.lib differ
diff --git a/jdk/test/sun/security/pkcs11/nss/lib/windows-amd64/plc4.dll b/jdk/test/sun/security/pkcs11/nss/lib/windows-amd64/plc4.dll
new file mode 100644
index 00000000000..94da505ad6a
Binary files /dev/null and b/jdk/test/sun/security/pkcs11/nss/lib/windows-amd64/plc4.dll differ
diff --git a/jdk/test/sun/security/pkcs11/nss/lib/windows-amd64/plc4.lib b/jdk/test/sun/security/pkcs11/nss/lib/windows-amd64/plc4.lib
new file mode 100644
index 00000000000..e319cd3873d
Binary files /dev/null and b/jdk/test/sun/security/pkcs11/nss/lib/windows-amd64/plc4.lib differ
diff --git a/jdk/test/sun/security/pkcs11/nss/lib/windows-amd64/plds4.dll b/jdk/test/sun/security/pkcs11/nss/lib/windows-amd64/plds4.dll
new file mode 100644
index 00000000000..be9c1cf1691
Binary files /dev/null and b/jdk/test/sun/security/pkcs11/nss/lib/windows-amd64/plds4.dll differ
diff --git a/jdk/test/sun/security/pkcs11/nss/lib/windows-amd64/plds4.lib b/jdk/test/sun/security/pkcs11/nss/lib/windows-amd64/plds4.lib
new file mode 100644
index 00000000000..7a93bec3cb9
Binary files /dev/null and b/jdk/test/sun/security/pkcs11/nss/lib/windows-amd64/plds4.lib differ
diff --git a/jdk/test/sun/security/pkcs11/nss/lib/windows-amd64/softokn3.chk b/jdk/test/sun/security/pkcs11/nss/lib/windows-amd64/softokn3.chk
index f002c3468fe..85e7b4a5f64 100644
Binary files a/jdk/test/sun/security/pkcs11/nss/lib/windows-amd64/softokn3.chk and b/jdk/test/sun/security/pkcs11/nss/lib/windows-amd64/softokn3.chk differ
diff --git a/jdk/test/sun/security/pkcs11/nss/lib/windows-amd64/softokn3.dll b/jdk/test/sun/security/pkcs11/nss/lib/windows-amd64/softokn3.dll
index 6293c7d1f20..7fb079f61ea 100644
Binary files a/jdk/test/sun/security/pkcs11/nss/lib/windows-amd64/softokn3.dll and b/jdk/test/sun/security/pkcs11/nss/lib/windows-amd64/softokn3.dll differ
diff --git a/jdk/test/sun/security/pkcs11/nss/lib/windows-amd64/sqlite3.dll b/jdk/test/sun/security/pkcs11/nss/lib/windows-amd64/sqlite3.dll
index 18c8fca90cb..288025baf05 100644
Binary files a/jdk/test/sun/security/pkcs11/nss/lib/windows-amd64/sqlite3.dll and b/jdk/test/sun/security/pkcs11/nss/lib/windows-amd64/sqlite3.dll differ
diff --git a/jdk/test/sun/security/pkcs11/nss/lib/windows-amd64/ssl3.dll b/jdk/test/sun/security/pkcs11/nss/lib/windows-amd64/ssl3.dll
index 5e06d337e68..c00687e37b2 100644
Binary files a/jdk/test/sun/security/pkcs11/nss/lib/windows-amd64/ssl3.dll and b/jdk/test/sun/security/pkcs11/nss/lib/windows-amd64/ssl3.dll differ
diff --git a/jdk/test/sun/security/pkcs11/nss/lib/windows-amd64/ssl3.lib b/jdk/test/sun/security/pkcs11/nss/lib/windows-amd64/ssl3.lib
index 21e83def697..e96c9185843 100644
Binary files a/jdk/test/sun/security/pkcs11/nss/lib/windows-amd64/ssl3.lib and b/jdk/test/sun/security/pkcs11/nss/lib/windows-amd64/ssl3.lib differ
diff --git a/jdk/test/sun/security/pkcs11/nss/lib/windows-i586/freebl3.chk b/jdk/test/sun/security/pkcs11/nss/lib/windows-i586/freebl3.chk
index 7f4e14757a5..a716ed40f75 100644
Binary files a/jdk/test/sun/security/pkcs11/nss/lib/windows-i586/freebl3.chk and b/jdk/test/sun/security/pkcs11/nss/lib/windows-i586/freebl3.chk differ
diff --git a/jdk/test/sun/security/pkcs11/nss/lib/windows-i586/freebl3.dll b/jdk/test/sun/security/pkcs11/nss/lib/windows-i586/freebl3.dll
index eea9e978e04..e5934cf33d1 100644
Binary files a/jdk/test/sun/security/pkcs11/nss/lib/windows-i586/freebl3.dll and b/jdk/test/sun/security/pkcs11/nss/lib/windows-i586/freebl3.dll differ
diff --git a/jdk/test/sun/security/pkcs11/nss/lib/windows-i586/libnspr4.dll b/jdk/test/sun/security/pkcs11/nss/lib/windows-i586/libnspr4.dll
deleted file mode 100644
index f073dc911bd..00000000000
Binary files a/jdk/test/sun/security/pkcs11/nss/lib/windows-i586/libnspr4.dll and /dev/null differ
diff --git a/jdk/test/sun/security/pkcs11/nss/lib/windows-i586/libnspr4.lib b/jdk/test/sun/security/pkcs11/nss/lib/windows-i586/libnspr4.lib
deleted file mode 100644
index 7351a9ebceb..00000000000
Binary files a/jdk/test/sun/security/pkcs11/nss/lib/windows-i586/libnspr4.lib and /dev/null differ
diff --git a/jdk/test/sun/security/pkcs11/nss/lib/windows-i586/libplc4.dll b/jdk/test/sun/security/pkcs11/nss/lib/windows-i586/libplc4.dll
deleted file mode 100644
index 0e74aec020e..00000000000
Binary files a/jdk/test/sun/security/pkcs11/nss/lib/windows-i586/libplc4.dll and /dev/null differ
diff --git a/jdk/test/sun/security/pkcs11/nss/lib/windows-i586/libplc4.lib b/jdk/test/sun/security/pkcs11/nss/lib/windows-i586/libplc4.lib
deleted file mode 100644
index cff555e3826..00000000000
Binary files a/jdk/test/sun/security/pkcs11/nss/lib/windows-i586/libplc4.lib and /dev/null differ
diff --git a/jdk/test/sun/security/pkcs11/nss/lib/windows-i586/libplds4.dll b/jdk/test/sun/security/pkcs11/nss/lib/windows-i586/libplds4.dll
deleted file mode 100644
index 3247b929767..00000000000
Binary files a/jdk/test/sun/security/pkcs11/nss/lib/windows-i586/libplds4.dll and /dev/null differ
diff --git a/jdk/test/sun/security/pkcs11/nss/lib/windows-i586/libplds4.lib b/jdk/test/sun/security/pkcs11/nss/lib/windows-i586/libplds4.lib
deleted file mode 100644
index 876979f6473..00000000000
Binary files a/jdk/test/sun/security/pkcs11/nss/lib/windows-i586/libplds4.lib and /dev/null differ
diff --git a/jdk/test/sun/security/pkcs11/nss/lib/windows-i586/nspr4.dll b/jdk/test/sun/security/pkcs11/nss/lib/windows-i586/nspr4.dll
new file mode 100644
index 00000000000..4ec833a7e35
Binary files /dev/null and b/jdk/test/sun/security/pkcs11/nss/lib/windows-i586/nspr4.dll differ
diff --git a/jdk/test/sun/security/pkcs11/nss/lib/windows-i586/nspr4.lib b/jdk/test/sun/security/pkcs11/nss/lib/windows-i586/nspr4.lib
new file mode 100644
index 00000000000..e6195bdae33
Binary files /dev/null and b/jdk/test/sun/security/pkcs11/nss/lib/windows-i586/nspr4.lib differ
diff --git a/jdk/test/sun/security/pkcs11/nss/lib/windows-i586/nss3.dll b/jdk/test/sun/security/pkcs11/nss/lib/windows-i586/nss3.dll
index 0411891b692..053aaa3ad93 100644
Binary files a/jdk/test/sun/security/pkcs11/nss/lib/windows-i586/nss3.dll and b/jdk/test/sun/security/pkcs11/nss/lib/windows-i586/nss3.dll differ
diff --git a/jdk/test/sun/security/pkcs11/nss/lib/windows-i586/nss3.lib b/jdk/test/sun/security/pkcs11/nss/lib/windows-i586/nss3.lib
index 1d8272ff195..a07111d38d4 100644
Binary files a/jdk/test/sun/security/pkcs11/nss/lib/windows-i586/nss3.lib and b/jdk/test/sun/security/pkcs11/nss/lib/windows-i586/nss3.lib differ
diff --git a/jdk/test/sun/security/pkcs11/nss/lib/windows-i586/nssckbi.dll b/jdk/test/sun/security/pkcs11/nss/lib/windows-i586/nssckbi.dll
index 123a8bf6536..9013e5cf072 100644
Binary files a/jdk/test/sun/security/pkcs11/nss/lib/windows-i586/nssckbi.dll and b/jdk/test/sun/security/pkcs11/nss/lib/windows-i586/nssckbi.dll differ
diff --git a/jdk/test/sun/security/pkcs11/nss/lib/windows-i586/nssdbm3.chk b/jdk/test/sun/security/pkcs11/nss/lib/windows-i586/nssdbm3.chk
index bc51e406988..cf0c1048d57 100644
Binary files a/jdk/test/sun/security/pkcs11/nss/lib/windows-i586/nssdbm3.chk and b/jdk/test/sun/security/pkcs11/nss/lib/windows-i586/nssdbm3.chk differ
diff --git a/jdk/test/sun/security/pkcs11/nss/lib/windows-i586/nssdbm3.dll b/jdk/test/sun/security/pkcs11/nss/lib/windows-i586/nssdbm3.dll
index 0572b4ecfdf..eedb562e31d 100644
Binary files a/jdk/test/sun/security/pkcs11/nss/lib/windows-i586/nssdbm3.dll and b/jdk/test/sun/security/pkcs11/nss/lib/windows-i586/nssdbm3.dll differ
diff --git a/jdk/test/sun/security/pkcs11/nss/lib/windows-i586/nssutil3.dll b/jdk/test/sun/security/pkcs11/nss/lib/windows-i586/nssutil3.dll
index f4dba08eeaf..a679872b0b7 100644
Binary files a/jdk/test/sun/security/pkcs11/nss/lib/windows-i586/nssutil3.dll and b/jdk/test/sun/security/pkcs11/nss/lib/windows-i586/nssutil3.dll differ
diff --git a/jdk/test/sun/security/pkcs11/nss/lib/windows-i586/nssutil3.lib b/jdk/test/sun/security/pkcs11/nss/lib/windows-i586/nssutil3.lib
index 7cd24f33feb..088c3960372 100644
Binary files a/jdk/test/sun/security/pkcs11/nss/lib/windows-i586/nssutil3.lib and b/jdk/test/sun/security/pkcs11/nss/lib/windows-i586/nssutil3.lib differ
diff --git a/jdk/test/sun/security/pkcs11/nss/lib/windows-i586/plc4.dll b/jdk/test/sun/security/pkcs11/nss/lib/windows-i586/plc4.dll
new file mode 100644
index 00000000000..d9b31663f3d
Binary files /dev/null and b/jdk/test/sun/security/pkcs11/nss/lib/windows-i586/plc4.dll differ
diff --git a/jdk/test/sun/security/pkcs11/nss/lib/windows-i586/plc4.lib b/jdk/test/sun/security/pkcs11/nss/lib/windows-i586/plc4.lib
new file mode 100644
index 00000000000..7f2ad9b9298
Binary files /dev/null and b/jdk/test/sun/security/pkcs11/nss/lib/windows-i586/plc4.lib differ
diff --git a/jdk/test/sun/security/pkcs11/nss/lib/windows-i586/plds4.dll b/jdk/test/sun/security/pkcs11/nss/lib/windows-i586/plds4.dll
new file mode 100644
index 00000000000..07c08735491
Binary files /dev/null and b/jdk/test/sun/security/pkcs11/nss/lib/windows-i586/plds4.dll differ
diff --git a/jdk/test/sun/security/pkcs11/nss/lib/windows-i586/plds4.lib b/jdk/test/sun/security/pkcs11/nss/lib/windows-i586/plds4.lib
new file mode 100644
index 00000000000..0f8854e72a2
Binary files /dev/null and b/jdk/test/sun/security/pkcs11/nss/lib/windows-i586/plds4.lib differ
diff --git a/jdk/test/sun/security/pkcs11/nss/lib/windows-i586/softokn3.chk b/jdk/test/sun/security/pkcs11/nss/lib/windows-i586/softokn3.chk
index 84ea2e2d5ac..7f18d4830f1 100644
Binary files a/jdk/test/sun/security/pkcs11/nss/lib/windows-i586/softokn3.chk and b/jdk/test/sun/security/pkcs11/nss/lib/windows-i586/softokn3.chk differ
diff --git a/jdk/test/sun/security/pkcs11/nss/lib/windows-i586/softokn3.dll b/jdk/test/sun/security/pkcs11/nss/lib/windows-i586/softokn3.dll
index 615e7c0a100..16eb7cc8227 100644
Binary files a/jdk/test/sun/security/pkcs11/nss/lib/windows-i586/softokn3.dll and b/jdk/test/sun/security/pkcs11/nss/lib/windows-i586/softokn3.dll differ
diff --git a/jdk/test/sun/security/pkcs11/nss/lib/windows-i586/sqlite3.dll b/jdk/test/sun/security/pkcs11/nss/lib/windows-i586/sqlite3.dll
index 9a130aa5606..08f0d702380 100644
Binary files a/jdk/test/sun/security/pkcs11/nss/lib/windows-i586/sqlite3.dll and b/jdk/test/sun/security/pkcs11/nss/lib/windows-i586/sqlite3.dll differ
diff --git a/jdk/test/sun/security/pkcs11/nss/lib/windows-i586/ssl3.dll b/jdk/test/sun/security/pkcs11/nss/lib/windows-i586/ssl3.dll
index 41f962ae861..73d69a3512f 100644
Binary files a/jdk/test/sun/security/pkcs11/nss/lib/windows-i586/ssl3.dll and b/jdk/test/sun/security/pkcs11/nss/lib/windows-i586/ssl3.dll differ
diff --git a/jdk/test/sun/security/pkcs11/nss/lib/windows-i586/ssl3.lib b/jdk/test/sun/security/pkcs11/nss/lib/windows-i586/ssl3.lib
index 72400591d64..99e29e2baec 100644
Binary files a/jdk/test/sun/security/pkcs11/nss/lib/windows-i586/ssl3.lib and b/jdk/test/sun/security/pkcs11/nss/lib/windows-i586/ssl3.lib differ
diff --git a/jdk/test/sun/security/pkcs11/nss/src/nss-3.16-with-nspr-4.10.4.tar.gz b/jdk/test/sun/security/pkcs11/nss/src/nss-3.16-with-nspr-4.10.4.tar.gz
new file mode 100644
index 00000000000..63fa5feb510
Binary files /dev/null and b/jdk/test/sun/security/pkcs11/nss/src/nss-3.16-with-nspr-4.10.4.tar.gz differ
diff --git a/jdk/test/sun/security/pkcs11/nss/src/nss-3.16-with-nspr-4.10.4.tar.gz.sha256 b/jdk/test/sun/security/pkcs11/nss/src/nss-3.16-with-nspr-4.10.4.tar.gz.sha256
new file mode 100644
index 00000000000..e4802dc7dea
--- /dev/null
+++ b/jdk/test/sun/security/pkcs11/nss/src/nss-3.16-with-nspr-4.10.4.tar.gz.sha256
@@ -0,0 +1 @@
+9d23633683ab3cea14519a22a997bc7f5d8d9664b6342df492c194966184ce0d nss-3.16-with-nspr-4.10.4.tar.gz
diff --git a/jdk/test/sun/security/pkcs11/nss/src/nss-3.16_nspr-4.10_src.tar.gz b/jdk/test/sun/security/pkcs11/nss/src/nss-3.16_nspr-4.10_src.tar.gz
deleted file mode 100644
index 09273547484..00000000000
Binary files a/jdk/test/sun/security/pkcs11/nss/src/nss-3.16_nspr-4.10_src.tar.gz and /dev/null differ
diff --git a/jdk/test/sun/security/pkcs11/nss/src/nss-3.16_nspr-4.10_src.tar.gz.sha256 b/jdk/test/sun/security/pkcs11/nss/src/nss-3.16_nspr-4.10_src.tar.gz.sha256
deleted file mode 100644
index 6ea9a98fef8..00000000000
--- a/jdk/test/sun/security/pkcs11/nss/src/nss-3.16_nspr-4.10_src.tar.gz.sha256
+++ /dev/null
@@ -1 +0,0 @@
-d2374795528f9cf36de07bf7c77d8c8414bb5b4da12ee7c78a57ec90d68e3706 nss-3.16_nspr-4.10_src.tar.gz
diff --git a/jdk/test/tools/jlink/IntegrationTest.java b/jdk/test/tools/jlink/IntegrationTest.java
index ad0a01bd541..970e1371131 100644
--- a/jdk/test/tools/jlink/IntegrationTest.java
+++ b/jdk/test/tools/jlink/IntegrationTest.java
@@ -210,25 +210,29 @@ public class IntegrationTest {
props.load(reader);
}
- if (props.getProperty("JAVA_VERSION") == null) {
- throw new AssertionError("release file does not contain JAVA_VERSION");
- }
-
- if (props.getProperty("OS_NAME") == null) {
- throw new AssertionError("release file does not contain OS_NAME");
- }
-
- if (props.getProperty("OS_ARCH") == null) {
- throw new AssertionError("release file does not contain OS_ARCH");
- }
-
- if (props.getProperty("OS_VERSION") == null) {
- throw new AssertionError("release file does not contain OS_VERSION");
- }
+ checkReleaseProperty(props, "JAVA_VERSION");
+ checkReleaseProperty(props, "JAVA_FULL_VERSION");
+ checkReleaseProperty(props, "OS_NAME");
+ checkReleaseProperty(props, "OS_ARCH");
+ checkReleaseProperty(props, "OS_VERSION");
if (!Files.exists(output.resolve("toto.txt"))) {
throw new AssertionError("Post processing not called");
}
}
+
+ static void checkReleaseProperty(Properties props, String name) {
+ if (! props.containsKey(name)) {
+ throw new AssertionError("release file does not contain property : " + name);
+ }
+
+ // property value is of min. length 3 and double quoted at the ends.
+ String value = props.getProperty(name);
+ if (value.length() < 3 ||
+ value.charAt(0) != '"' ||
+ value.charAt(value.length() - 1) != '"') {
+ throw new AssertionError("release property " + name + " is not quoted property");
+ }
+ }
}
diff --git a/jdk/test/tools/jlink/plugins/IncludeLocalesPluginTest.java b/jdk/test/tools/jlink/plugins/IncludeLocalesPluginTest.java
index deb65ca13f8..4298e48d84d 100644
--- a/jdk/test/tools/jlink/plugins/IncludeLocalesPluginTest.java
+++ b/jdk/test/tools/jlink/plugins/IncludeLocalesPluginTest.java
@@ -126,11 +126,10 @@ public class IncludeLocalesPluginTest {
"/jdk.localedata/sun/text/resources/cldr/ext/FormatData_es_419.class",
"/jdk.localedata/sun/text/resources/cldr/ext/FormatData_es_AR.class"),
List.of(
- "/jdk.localedata/sun/text/resources/LineBreakIteratorData_th",
- "/jdk.localedata/sun/text/resources/thai_dict",
- "/jdk.localedata/sun/text/resources/WordBreakIteratorData_th",
+ "/jdk.localedata/sun/text/resources/ext/LineBreakIteratorData_th",
+ "/jdk.localedata/sun/text/resources/ext/thai_dict",
+ "/jdk.localedata/sun/text/resources/ext/WordBreakIteratorData_th",
"/jdk.localedata/sun/text/resources/ext/BreakIteratorInfo_th.class",
- "/jdk.localedata/sun/text/resources/ext/BreakIteratorRules_th.class",
"/jdk.localedata/sun/text/resources/ext/FormatData_ja.class",
"/jdk.localedata/sun/text/resources/ext/FormatData_th.class",
"/jdk.localedata/sun/text/resources/cldr/ext/FormatData_ja.class",
@@ -165,11 +164,10 @@ public class IncludeLocalesPluginTest {
"/jdk.localedata/sun/text/resources/cldr/ext/FormatData_en_001.class",
"/jdk.localedata/sun/text/resources/cldr/ext/FormatData_ja.class"),
List.of(
- "/jdk.localedata/sun/text/resources/LineBreakIteratorData_th",
- "/jdk.localedata/sun/text/resources/thai_dict",
- "/jdk.localedata/sun/text/resources/WordBreakIteratorData_th",
+ "/jdk.localedata/sun/text/resources/ext/LineBreakIteratorData_th",
+ "/jdk.localedata/sun/text/resources/ext/thai_dict",
+ "/jdk.localedata/sun/text/resources/ext/WordBreakIteratorData_th",
"/jdk.localedata/sun/text/resources/ext/BreakIteratorInfo_th.class",
- "/jdk.localedata/sun/text/resources/ext/BreakIteratorRules_th.class",
"/jdk.localedata/sun/text/resources/ext/FormatData_th.class",
"/jdk.localedata/sun/text/resources/ext/FormatData_zh.class",
"/jdk.localedata/sun/text/resources/cldr/ext/FormatData_th.class",
@@ -206,11 +204,10 @@ public class IncludeLocalesPluginTest {
"/jdk.localedata/sun/text/resources/cldr/ext/FormatData_en_150.class",
"/jdk.localedata/sun/text/resources/cldr/ext/FormatData_en_AT.class"),
List.of(
- "/jdk.localedata/sun/text/resources/LineBreakIteratorData_th",
- "/jdk.localedata/sun/text/resources/thai_dict",
- "/jdk.localedata/sun/text/resources/WordBreakIteratorData_th",
+ "/jdk.localedata/sun/text/resources/ext/LineBreakIteratorData_th",
+ "/jdk.localedata/sun/text/resources/ext/thai_dict",
+ "/jdk.localedata/sun/text/resources/ext/WordBreakIteratorData_th",
"/jdk.localedata/sun/text/resources/ext/BreakIteratorInfo_th.class",
- "/jdk.localedata/sun/text/resources/ext/BreakIteratorRules_th.class",
"/jdk.localedata/sun/text/resources/ext/FormatData_en_GB.class",
"/jdk.localedata/sun/text/resources/ext/FormatData_ja.class",
"/jdk.localedata/sun/text/resources/ext/FormatData_th.class",
@@ -235,11 +232,10 @@ public class IncludeLocalesPluginTest {
"/jdk.localedata/sun/util/resources/cldr/ext/CalendarData_kok_IN.class",
"/jdk.localedata/sun/util/resources/cldr/ext/CalendarData_pa_Guru_IN.class"),
List.of(
- "/jdk.localedata/sun/text/resources/LineBreakIteratorData_th",
- "/jdk.localedata/sun/text/resources/thai_dict",
- "/jdk.localedata/sun/text/resources/WordBreakIteratorData_th",
+ "/jdk.localedata/sun/text/resources/ext/LineBreakIteratorData_th",
+ "/jdk.localedata/sun/text/resources/ext/thai_dict",
+ "/jdk.localedata/sun/text/resources/ext/WordBreakIteratorData_th",
"/jdk.localedata/sun/text/resources/ext/BreakIteratorInfo_th.class",
- "/jdk.localedata/sun/text/resources/ext/BreakIteratorRules_th.class",
"/jdk.localedata/sun/text/resources/ext/FormatData_en_GB.class",
"/jdk.localedata/sun/text/resources/ext/FormatData_ja.class",
"/jdk.localedata/sun/text/resources/ext/FormatData_th.class",
@@ -261,11 +257,10 @@ public class IncludeLocalesPluginTest {
"--include-locales=th",
"jdk.localedata",
List.of(
- "/jdk.localedata/sun/text/resources/LineBreakIteratorData_th",
- "/jdk.localedata/sun/text/resources/thai_dict",
- "/jdk.localedata/sun/text/resources/WordBreakIteratorData_th",
+ "/jdk.localedata/sun/text/resources/ext/LineBreakIteratorData_th",
+ "/jdk.localedata/sun/text/resources/ext/thai_dict",
+ "/jdk.localedata/sun/text/resources/ext/WordBreakIteratorData_th",
"/jdk.localedata/sun/text/resources/ext/BreakIteratorInfo_th.class",
- "/jdk.localedata/sun/text/resources/ext/BreakIteratorRules_th.class",
"/jdk.localedata/sun/text/resources/ext/FormatData_th.class"),
List.of(
"/jdk.localedata/sun/text/resources/ext/FormatData_en_GB.class",
@@ -290,11 +285,10 @@ public class IncludeLocalesPluginTest {
"/jdk.localedata/sun/text/resources/ext/FormatData_zh_TW.class",
"/jdk.localedata/sun/text/resources/cldr/ext/FormatData_zh.class"),
List.of(
- "/jdk.localedata/sun/text/resources/LineBreakIteratorData_th",
- "/jdk.localedata/sun/text/resources/thai_dict",
- "/jdk.localedata/sun/text/resources/WordBreakIteratorData_th",
+ "/jdk.localedata/sun/text/resources/ext/LineBreakIteratorData_th",
+ "/jdk.localedata/sun/text/resources/ext/thai_dict",
+ "/jdk.localedata/sun/text/resources/ext/WordBreakIteratorData_th",
"/jdk.localedata/sun/text/resources/ext/BreakIteratorInfo_th.class",
- "/jdk.localedata/sun/text/resources/ext/BreakIteratorRules_th.class",
"/jdk.localedata/sun/text/resources/ext/FormatData_en_GB.class",
"/jdk.localedata/sun/text/resources/ext/FormatData_ja.class",
"/jdk.localedata/sun/text/resources/ext/FormatData_th.class",
@@ -318,11 +312,10 @@ public class IncludeLocalesPluginTest {
"/jdk.localedata/sun/text/resources/ext/FormatData_zh_SG.class",
"/jdk.localedata/sun/text/resources/cldr/ext/FormatData_zh.class"),
List.of(
- "/jdk.localedata/sun/text/resources/LineBreakIteratorData_th",
- "/jdk.localedata/sun/text/resources/thai_dict",
- "/jdk.localedata/sun/text/resources/WordBreakIteratorData_th",
+ "/jdk.localedata/sun/text/resources/ext/LineBreakIteratorData_th",
+ "/jdk.localedata/sun/text/resources/ext/thai_dict",
+ "/jdk.localedata/sun/text/resources/ext/WordBreakIteratorData_th",
"/jdk.localedata/sun/text/resources/ext/BreakIteratorInfo_th.class",
- "/jdk.localedata/sun/text/resources/ext/BreakIteratorRules_th.class",
"/jdk.localedata/sun/text/resources/ext/FormatData_en_GB.class",
"/jdk.localedata/sun/text/resources/ext/FormatData_ja.class",
"/jdk.localedata/sun/text/resources/ext/FormatData_th.class",
@@ -346,11 +339,10 @@ public class IncludeLocalesPluginTest {
"/jdk.localedata/sun/text/resources/cldr/ext/FormatData_nb.class",
"/jdk.localedata/sun/text/resources/cldr/ext/FormatData_nn.class"),
List.of(
- "/jdk.localedata/sun/text/resources/LineBreakIteratorData_th",
- "/jdk.localedata/sun/text/resources/thai_dict",
- "/jdk.localedata/sun/text/resources/WordBreakIteratorData_th",
+ "/jdk.localedata/sun/text/resources/ext/LineBreakIteratorData_th",
+ "/jdk.localedata/sun/text/resources/ext/thai_dict",
+ "/jdk.localedata/sun/text/resources/ext/WordBreakIteratorData_th",
"/jdk.localedata/sun/text/resources/ext/BreakIteratorInfo_th.class",
- "/jdk.localedata/sun/text/resources/ext/BreakIteratorRules_th.class",
"/jdk.localedata/sun/text/resources/ext/FormatData_en_GB.class",
"/jdk.localedata/sun/text/resources/ext/FormatData_ja.class",
"/jdk.localedata/sun/text/resources/ext/FormatData_th.class",
@@ -376,11 +368,10 @@ public class IncludeLocalesPluginTest {
"/jdk.localedata/sun/text/resources/cldr/ext/FormatData_iw.class",
"/jdk.localedata/sun/text/resources/cldr/ext/FormatData_ji.class"),
List.of(
- "/jdk.localedata/sun/text/resources/LineBreakIteratorData_th",
- "/jdk.localedata/sun/text/resources/thai_dict",
- "/jdk.localedata/sun/text/resources/WordBreakIteratorData_th",
+ "/jdk.localedata/sun/text/resources/ext/LineBreakIteratorData_th",
+ "/jdk.localedata/sun/text/resources/ext/thai_dict",
+ "/jdk.localedata/sun/text/resources/ext/WordBreakIteratorData_th",
"/jdk.localedata/sun/text/resources/ext/BreakIteratorInfo_th.class",
- "/jdk.localedata/sun/text/resources/ext/BreakIteratorRules_th.class",
"/jdk.localedata/sun/text/resources/ext/FormatData_en_GB.class",
"/jdk.localedata/sun/text/resources/ext/FormatData_ja.class",
"/jdk.localedata/sun/text/resources/ext/FormatData_th.class",
diff --git a/langtools/.hgtags b/langtools/.hgtags
index f4500a88ff0..cddf72d74e6 100644
--- a/langtools/.hgtags
+++ b/langtools/.hgtags
@@ -377,3 +377,4 @@ aebfafc43714d5a27d5064d8a0011eaccde633cf jdk-9+131
2c17b65a37a8d7afdb9f96d5f11b28a3f21c78f2 jdk-9+132
7efa4b3477b2b93edbdb4abf827b74c6391f056e jdk-9+133
f08683786207a48b652266b3b7b908e6c863c3fc jdk-9+134
+af5eb8f3ffd21288305a54ea177ffad75021a741 jdk-9+135
diff --git a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/main/JavaCompiler.java b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/main/JavaCompiler.java
index a8e79f79928..e9a423ffd95 100644
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/main/JavaCompiler.java
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/main/JavaCompiler.java
@@ -426,8 +426,8 @@ public class JavaCompiler {
verboseCompilePolicy = options.isSet("verboseCompilePolicy");
- if (options.isSet("shouldstop.at") &&
- CompileState.valueOf(options.get("shouldstop.at")) == CompileState.ATTR)
+ if (options.isSet("should-stop.at") &&
+ CompileState.valueOf(options.get("should-stop.at")) == CompileState.ATTR)
compilePolicy = CompilePolicy.ATTR_ONLY;
else
compilePolicy = CompilePolicy.decode(options.get("compilePolicy"));
@@ -440,14 +440,14 @@ public class JavaCompiler {
: null;
shouldStopPolicyIfError =
- options.isSet("shouldstop.at") // backwards compatible
- ? CompileState.valueOf(options.get("shouldstop.at"))
- : options.isSet("shouldstop.ifError")
- ? CompileState.valueOf(options.get("shouldstop.ifError"))
+ options.isSet("should-stop.at") // backwards compatible
+ ? CompileState.valueOf(options.get("should-stop.at"))
+ : options.isSet("should-stop.ifError")
+ ? CompileState.valueOf(options.get("should-stop.ifError"))
: CompileState.INIT;
shouldStopPolicyIfNoError =
- options.isSet("shouldstop.ifNoError")
- ? CompileState.valueOf(options.get("shouldstop.ifNoError"))
+ options.isSet("should-stop.ifNoError")
+ ? CompileState.valueOf(options.get("should-stop.ifNoError"))
: CompileState.GENERATE;
if (options.isUnset("diags.legacy"))
diff --git a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/main/Option.java b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/main/Option.java
index 6d39408b095..03327387b47 100644
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/main/Option.java
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/main/Option.java
@@ -509,33 +509,21 @@ public enum Option {
XDIAGS("-Xdiags:", "opt.diags", EXTENDED, BASIC, ONEOF, "compact", "verbose"),
- XDEBUG("-Xdebug:", null, HIDDEN, BASIC) {
+ DEBUG("--debug:", null, HIDDEN, BASIC) {
@Override
public boolean process(OptionHelper helper, String option) {
- String p = option.substring(option.indexOf(':') + 1).trim();
- String[] subOptions = p.split(";");
- for (String subOption : subOptions) {
- subOption = "debug." + subOption.trim();
- XD.process(helper, subOption, subOption);
- }
- return false;
+ return HiddenGroup.DEBUG.process(helper, option);
}
},
- XSHOULDSTOP("-Xshouldstop:", null, HIDDEN, BASIC) {
+ SHOULDSTOP("--should-stop:", null, HIDDEN, BASIC) {
@Override
public boolean process(OptionHelper helper, String option) {
- String p = option.substring(option.indexOf(':') + 1).trim();
- String[] subOptions = p.split(";");
- for (String subOption : subOptions) {
- subOption = "shouldstop." + subOption.trim();
- XD.process(helper, subOption, subOption);
- }
- return false;
+ return HiddenGroup.SHOULDSTOP.process(helper, option);
}
},
- DIAGS("-diags:", null, HIDDEN, BASIC) {
+ DIAGS("--diags:", null, HIDDEN, BASIC) {
@Override
public boolean process(OptionHelper helper, String option) {
return HiddenGroup.DIAGS.process(helper, option);
@@ -754,7 +742,12 @@ public enum Option {
}
enum HiddenGroup {
- DIAGS("diags");
+ DIAGS("diags"),
+ DEBUG("debug"),
+ SHOULDSTOP("should-stop");
+
+ static final Set skipSet = new java.util.HashSet<>(
+ Arrays.asList("--diags:", "--debug:", "--should-stop:"));
final String text;
@@ -771,6 +764,10 @@ public enum Option {
}
return false;
}
+
+ static boolean skip(String name) {
+ return skipSet.contains(name);
+ }
}
/**
@@ -930,7 +927,7 @@ public enum Option {
}
private boolean matches(String option, String name) {
- if (name.startsWith("--")) {
+ if (name.startsWith("--") && !HiddenGroup.skip(name)) {
return option.equals(name)
|| hasArg() && option.startsWith(name + "=");
}
diff --git a/langtools/src/jdk.compiler/share/classes/com/sun/tools/sjavac/options/Options.java b/langtools/src/jdk.compiler/share/classes/com/sun/tools/sjavac/options/Options.java
index a6299916709..4f212a86a19 100644
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/sjavac/options/Options.java
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/sjavac/options/Options.java
@@ -313,7 +313,7 @@ public class Options {
}
// Enable dependency generation
- args.add("-Xdebug:completionDeps=source,class");
+ args.add("--debug:completionDeps=source,class");
// This can't be anything but 'none'. Enforced by sjavac main method.
args.add("-implicit:" + implicitPolicy);
diff --git a/langtools/src/jdk.jshell/share/classes/jdk/jshell/ReplParser.java b/langtools/src/jdk.jshell/share/classes/jdk/jshell/ReplParser.java
index 5712a2202fe..7b9d73c1a66 100644
--- a/langtools/src/jdk.jshell/share/classes/jdk/jshell/ReplParser.java
+++ b/langtools/src/jdk.jshell/share/classes/jdk/jshell/ReplParser.java
@@ -95,24 +95,6 @@ class ReplParser extends JavacParser {
mods = modifiersOpt();
}
- if (token.kind == PACKAGE) {
- int packagePos = token.pos;
- List annotations = List.nil();
- seenPackage = true;
- if (mods != null) {
- checkNoMods(mods.flags);
- annotations = mods.annotations;
- mods = null;
- }
- nextToken();
- JCExpression pid = qualident(false);
- accept(SEMI);
- JCPackageDecl pd = F.at(packagePos).PackageDecl(annotations, pid);
- attach(pd, firstToken.comment(CommentStyle.JAVADOC));
- storeEnd(pd, token.pos);
- defs.append(pd);
- }
-
boolean firstTypeDecl = true;
while (token.kind != EOF) {
if (token.pos > 0 && token.pos <= endPosTable.errorEndPos) {
diff --git a/langtools/src/jdk.jshell/share/classes/jdk/jshell/SourceCodeAnalysisImpl.java b/langtools/src/jdk.jshell/share/classes/jdk/jshell/SourceCodeAnalysisImpl.java
index 090bfb6d969..309f4b4ba09 100644
--- a/langtools/src/jdk.jshell/share/classes/jdk/jshell/SourceCodeAnalysisImpl.java
+++ b/langtools/src/jdk.jshell/share/classes/jdk/jshell/SourceCodeAnalysisImpl.java
@@ -838,8 +838,31 @@ class SourceCodeAnalysisImpl extends SourceCodeAnalysis {
}
private Stream localElements(Scope scope) {
- @SuppressWarnings("unchecked")
- Stream elements = Util.stream((Iterable)scope.getLocalElements());
+ //workaround for: JDK-8024687
+ Iterable elementsIt = () -> new Iterator() {
+ Iterator extends Element> it = scope.getLocalElements().iterator();
+ @Override
+ public boolean hasNext() {
+ while (true) {
+ try {
+ return it.hasNext();
+ } catch (CompletionFailure cf) {
+ //ignore...
+ }
+ }
+ }
+ @Override
+ public Element next() {
+ while (true) {
+ try {
+ return it.next();
+ } catch (CompletionFailure cf) {
+ //ignore...
+ }
+ }
+ }
+ };
+ Stream elements = Util.stream(elementsIt);
if (scope.getEnclosingScope() != null &&
scope.getEnclosingClass() != scope.getEnclosingScope().getEnclosingClass()) {
diff --git a/langtools/src/jdk.jshell/share/classes/jdk/jshell/TaskFactory.java b/langtools/src/jdk.jshell/share/classes/jdk/jshell/TaskFactory.java
index 191d43cc088..28ed2d2acb8 100644
--- a/langtools/src/jdk.jshell/share/classes/jdk/jshell/TaskFactory.java
+++ b/langtools/src/jdk.jshell/share/classes/jdk/jshell/TaskFactory.java
@@ -222,7 +222,7 @@ class TaskFactory {
this(wraps.stream(),
new WrapSourceHandler(),
Util.join(new String[] {
- "-Xshouldstop:at=FLOW", "-Xlint:unchecked",
+ "--should-stop:at=FLOW", "-Xlint:unchecked",
"-proc:none"
}, extraArgs));
}
diff --git a/langtools/test/jdk/jshell/CompletionSuggestionTest.java b/langtools/test/jdk/jshell/CompletionSuggestionTest.java
index 8c2c723bc1e..b3a40be8e87 100644
--- a/langtools/test/jdk/jshell/CompletionSuggestionTest.java
+++ b/langtools/test/jdk/jshell/CompletionSuggestionTest.java
@@ -23,7 +23,7 @@
/*
* @test
- * @bug 8141092 8153761
+ * @bug 8131025 8141092 8153761
* @summary Test Completion
* @modules jdk.compiler/com.sun.tools.javac.api
* jdk.compiler/com.sun.tools.javac.main
@@ -610,4 +610,26 @@ public class CompletionSuggestionTest extends KullaTesting {
keepParameterNames.setAccessible(true);
keepParameterNames.set(getAnalysis(), new String[0]);
}
+
+ public void testBrokenClassFile2() throws IOException {
+ Path broken = outDir.resolve("broken");
+ compiler.compile(broken,
+ "package p;\n" +
+ "public class BrokenA {\n" +
+ "}",
+ "package p.q;\n" +
+ "public class BrokenB {\n" +
+ "}",
+ "package p;\n" +
+ "public class BrokenC {\n" +
+ "}");
+ Path cp = compiler.getPath(broken);
+ Path target = cp.resolve("p").resolve("BrokenB.class");
+ Files.deleteIfExists(target);
+ Files.move(cp.resolve("p").resolve("q").resolve("BrokenB.class"), target);
+ addToClasspath(cp);
+
+ assertEval("import p.*;");
+ assertCompletion("Broke|", "BrokenA", "BrokenC");
+ }
}
diff --git a/langtools/test/jdk/jshell/RejectedFailedTest.java b/langtools/test/jdk/jshell/RejectedFailedTest.java
index b9d8bece7cb..5411d5d8aee 100644
--- a/langtools/test/jdk/jshell/RejectedFailedTest.java
+++ b/langtools/test/jdk/jshell/RejectedFailedTest.java
@@ -22,7 +22,7 @@
*/
/*
- * @test
+ * @test 8080352
* @summary Tests for hard errors, like syntax errors
* @build KullaTesting
* @run testng RejectedFailedTest
@@ -81,6 +81,7 @@ public class RejectedFailedTest extends KullaTesting {
" a b c",
")",
"class interface A",
+ "package foo;"
};
checkByKind(inputsErroneous, Kind.ERRONEOUS);
}
diff --git a/langtools/test/tools/javac/ClassFileModifiers/ClassModifiers.java b/langtools/test/tools/javac/ClassFileModifiers/ClassModifiers.java
index 728ddbda217..77bf387f7e7 100644
--- a/langtools/test/tools/javac/ClassFileModifiers/ClassModifiers.java
+++ b/langtools/test/tools/javac/ClassFileModifiers/ClassModifiers.java
@@ -28,7 +28,7 @@
* file are correct, including those within InnerClasses attributes.
* @author John Rose (jrose). Entered as a regression test by Bill Maddox (maddox).
*
- * @compile/ref=ClassModifiers.out -Xdebug:dumpmodifiers=ci ClassModifiers.java
+ * @compile/ref=ClassModifiers.out --debug:dumpmodifiers=ci ClassModifiers.java
*
*/
diff --git a/langtools/test/tools/javac/ClassFileModifiers/MemberModifiers.java b/langtools/test/tools/javac/ClassFileModifiers/MemberModifiers.java
index b6697d0afa0..fa134f816ae 100644
--- a/langtools/test/tools/javac/ClassFileModifiers/MemberModifiers.java
+++ b/langtools/test/tools/javac/ClassFileModifiers/MemberModifiers.java
@@ -26,7 +26,7 @@
* @bug 4249112 4785453
* @summary Verify that implicit member modifiers are set correctly.
*
- * @compile/ref=MemberModifiers.out -Xdebug:dumpmodifiers=cfm MemberModifiers.java
+ * @compile/ref=MemberModifiers.out --debug:dumpmodifiers=cfm MemberModifiers.java
*/
// Currently, we check only that members of final classes are not final.
diff --git a/langtools/test/tools/javac/Diagnostics/6722234/T6722234a.java b/langtools/test/tools/javac/Diagnostics/6722234/T6722234a.java
index 0d48df3d2a4..04008efcfb3 100644
--- a/langtools/test/tools/javac/Diagnostics/6722234/T6722234a.java
+++ b/langtools/test/tools/javac/Diagnostics/6722234/T6722234a.java
@@ -3,8 +3,8 @@
* @bug 6722234
* @summary javac diagnostics need better integration with the type-system
* @author mcimadamore
- * @compile/fail/ref=T6722234a_1.out -XDrawDiagnostics -diags:formatterOptions=disambiguateTvars T6722234a.java
- * @compile/fail/ref=T6722234a_2.out -XDrawDiagnostics -diags:formatterOptions=disambiguateTvars,where T6722234a.java
+ * @compile/fail/ref=T6722234a_1.out -XDrawDiagnostics --diags:formatterOptions=disambiguateTvars T6722234a.java
+ * @compile/fail/ref=T6722234a_2.out -XDrawDiagnostics --diags:formatterOptions=disambiguateTvars,where T6722234a.java
*/
class T6722234a {
diff --git a/langtools/test/tools/javac/Diagnostics/6722234/T6722234b.java b/langtools/test/tools/javac/Diagnostics/6722234/T6722234b.java
index 6c58f552b56..47a1716cf2a 100644
--- a/langtools/test/tools/javac/Diagnostics/6722234/T6722234b.java
+++ b/langtools/test/tools/javac/Diagnostics/6722234/T6722234b.java
@@ -3,8 +3,8 @@
* @bug 6722234 8078024
* @summary javac diagnostics need better integration with the type-system
* @author mcimadamore
- * @compile/fail/ref=T6722234b_1.out -XDrawDiagnostics -diags:formatterOptions=simpleNames T6722234b.java
- * @compile/fail/ref=T6722234b_2.out -XDrawDiagnostics -diags:formatterOptions=simpleNames,where T6722234b.java
+ * @compile/fail/ref=T6722234b_1.out -XDrawDiagnostics --diags:formatterOptions=simpleNames T6722234b.java
+ * @compile/fail/ref=T6722234b_2.out -XDrawDiagnostics --diags:formatterOptions=simpleNames,where T6722234b.java
*/
import java.util.*;
diff --git a/langtools/test/tools/javac/Diagnostics/6722234/T6722234c.java b/langtools/test/tools/javac/Diagnostics/6722234/T6722234c.java
index 443e53b921f..4b12953003d 100644
--- a/langtools/test/tools/javac/Diagnostics/6722234/T6722234c.java
+++ b/langtools/test/tools/javac/Diagnostics/6722234/T6722234c.java
@@ -3,7 +3,7 @@
* @bug 6722234
* @summary javac diagnostics need better integration with the type-system
* @author mcimadamore
- * @compile/fail/ref=T6722234c.out -XDrawDiagnostics -diags:formatterOptions=simpleNames T6722234c.java
+ * @compile/fail/ref=T6722234c.out -XDrawDiagnostics --diags:formatterOptions=simpleNames T6722234c.java
*/
class T6722234c {
diff --git a/langtools/test/tools/javac/Diagnostics/6722234/T6722234d.java b/langtools/test/tools/javac/Diagnostics/6722234/T6722234d.java
index 7cdcbf7c26f..95fa4fb24ab 100644
--- a/langtools/test/tools/javac/Diagnostics/6722234/T6722234d.java
+++ b/langtools/test/tools/javac/Diagnostics/6722234/T6722234d.java
@@ -3,8 +3,8 @@
* @bug 6722234 8078024
* @summary javac diagnostics need better integration with the type-system
* @author mcimadamore
- * @compile/fail/ref=T6722234d_1.out -XDrawDiagnostics -diags:formatterOptions=where T6722234d.java
- * @compile/fail/ref=T6722234d_2.out -XDrawDiagnostics -diags:formatterOptions=where,simpleNames T6722234d.java
+ * @compile/fail/ref=T6722234d_1.out -XDrawDiagnostics --diags:formatterOptions=where T6722234d.java
+ * @compile/fail/ref=T6722234d_2.out -XDrawDiagnostics --diags:formatterOptions=where,simpleNames T6722234d.java
*/
class T6722234d {
diff --git a/langtools/test/tools/javac/Diagnostics/6862608/T6862608a.java b/langtools/test/tools/javac/Diagnostics/6862608/T6862608a.java
index 2117363a939..1713c05e202 100644
--- a/langtools/test/tools/javac/Diagnostics/6862608/T6862608a.java
+++ b/langtools/test/tools/javac/Diagnostics/6862608/T6862608a.java
@@ -3,7 +3,7 @@
* @bug 6862608
* @summary rich diagnostic sometimes contain wrong type variable numbering
* @author mcimadamore
- * @compile/fail/ref=T6862608a.out -XDrawDiagnostics -diags:formatterOptions=disambiguateTvars,where T6862608a.java
+ * @compile/fail/ref=T6862608a.out -XDrawDiagnostics --diags:formatterOptions=disambiguateTvars,where T6862608a.java
*/
diff --git a/langtools/test/tools/javac/Diagnostics/6862608/T6862608b.java b/langtools/test/tools/javac/Diagnostics/6862608/T6862608b.java
index 9889b3bc8c9..14c61a33142 100644
--- a/langtools/test/tools/javac/Diagnostics/6862608/T6862608b.java
+++ b/langtools/test/tools/javac/Diagnostics/6862608/T6862608b.java
@@ -3,7 +3,7 @@
* @bug 6862608
* @summary rich diagnostic sometimes contain wrong type variable numbering
* @author mcimadamore
- * @compile/fail/ref=T6862608b.out -XDrawDiagnostics -diags:formatterOptions=disambiguateTvars,where T6862608b.java
+ * @compile/fail/ref=T6862608b.out -XDrawDiagnostics --diags:formatterOptions=disambiguateTvars,where T6862608b.java
*/
class T66862608b {
diff --git a/langtools/test/tools/javac/Diagnostics/7010608/Test.java b/langtools/test/tools/javac/Diagnostics/7010608/Test.java
index 9265995685e..332d26a0d9d 100644
--- a/langtools/test/tools/javac/Diagnostics/7010608/Test.java
+++ b/langtools/test/tools/javac/Diagnostics/7010608/Test.java
@@ -46,9 +46,9 @@ public class Test {
try {
test(Arrays.asList(),
"myfo://test:1: error: cannot find symbol");
- test(Arrays.asList("-diags:layout=OLD"),
+ test(Arrays.asList("--diags:layout=OLD"),
"myfo://test:1: cannot find symbol");
- test(Arrays.asList("-diags:legacy"),
+ test(Arrays.asList("--diags:legacy"),
"myfo://test:1: cannot find symbol");
} finally {
Locale.setDefault(prev);
diff --git a/langtools/test/tools/javac/Diagnostics/8010387/T8010387.java b/langtools/test/tools/javac/Diagnostics/8010387/T8010387.java
index 0ab5f0229c9..74a664cd160 100644
--- a/langtools/test/tools/javac/Diagnostics/8010387/T8010387.java
+++ b/langtools/test/tools/javac/Diagnostics/8010387/T8010387.java
@@ -2,7 +2,7 @@
* @test /nodynamiccopyright/
* @bug 8010387
* @summary rich diagnostic sometimes contain wrong type variable numbering
- * @compile/fail/ref=T8010387.out -XDrawDiagnostics -diags:formatterOptions=disambiguateTvars,where T8010387.java
+ * @compile/fail/ref=T8010387.out -XDrawDiagnostics --diags:formatterOptions=disambiguateTvars,where T8010387.java
*/
abstract class T8010387 {
diff --git a/langtools/test/tools/javac/InterfaceMemberClassModifiers.java b/langtools/test/tools/javac/InterfaceMemberClassModifiers.java
index 638cb731ff9..bb5fd1367e6 100644
--- a/langtools/test/tools/javac/InterfaceMemberClassModifiers.java
+++ b/langtools/test/tools/javac/InterfaceMemberClassModifiers.java
@@ -4,7 +4,7 @@
* @summary Verify that invalid access modifiers on interface members don't cause crash.
* @author maddox
*
- * @compile/fail/ref=InterfaceMemberClassModifiers.out -diags:layout=%b:%l:%_%m InterfaceMemberClassModifiers.java
+ * @compile/fail/ref=InterfaceMemberClassModifiers.out --diags:layout=%b:%l:%_%m InterfaceMemberClassModifiers.java
*/
public interface InterfaceMemberClassModifiers {
diff --git a/langtools/test/tools/javac/T5003235/T5003235a.java b/langtools/test/tools/javac/T5003235/T5003235a.java
index f30ad7a8ebf..1eea9628b3b 100644
--- a/langtools/test/tools/javac/T5003235/T5003235a.java
+++ b/langtools/test/tools/javac/T5003235/T5003235a.java
@@ -3,7 +3,7 @@
* @bug 5003235
* @summary Private inner class accessible from subclasses
* @author Peter von der Ah\u00e9
- * @compile/fail/ref=T5003235a.out -diags:layout=%b:%l:%_%m T5003235a.java
+ * @compile/fail/ref=T5003235a.out --diags:layout=%b:%l:%_%m T5003235a.java
*/
class Super {
diff --git a/langtools/test/tools/javac/T5003235/T5003235b.java b/langtools/test/tools/javac/T5003235/T5003235b.java
index 3384f909b6c..629e077dba5 100644
--- a/langtools/test/tools/javac/T5003235/T5003235b.java
+++ b/langtools/test/tools/javac/T5003235/T5003235b.java
@@ -3,7 +3,7 @@
* @bug 5003235
* @summary Accessibility of private inner class
* @author Peter von der Ah\u00e9
- * @compile/fail/ref=T5003235b.out -diags:layout=%b:%l:%_%m T5003235b.java
+ * @compile/fail/ref=T5003235b.out --diags:layout=%b:%l:%_%m T5003235b.java
*/
class Outer {
diff --git a/langtools/test/tools/javac/T6214885.java b/langtools/test/tools/javac/T6214885.java
index 73fff2c10a9..f79b752ecbc 100644
--- a/langtools/test/tools/javac/T6214885.java
+++ b/langtools/test/tools/javac/T6214885.java
@@ -2,8 +2,8 @@
* @test /nodynamiccopyright/
* @bug 6214885
* @summary This test exercises features provided by the new internal Diagnostics API
- * @compile/fail/ref=T6214885a.out -diags:layout=%b:%l%_%t%m|%p%m T6214885.java
- * @compile/fail/ref=T6214885b.out -diags:layout=%b:%l:%c%_%t%m|%p%m T6214885.java
+ * @compile/fail/ref=T6214885a.out --diags:layout=%b:%l%_%t%m|%p%m T6214885.java
+ * @compile/fail/ref=T6214885b.out --diags:layout=%b:%l:%c%_%t%m|%p%m T6214885.java
*/
class T6214885
{
diff --git a/langtools/test/tools/javac/T8026963/TypeAnnotationsCrashWithErroneousTreeTest.java b/langtools/test/tools/javac/T8026963/TypeAnnotationsCrashWithErroneousTreeTest.java
index 83707369e62..49fd4d46cf7 100644
--- a/langtools/test/tools/javac/T8026963/TypeAnnotationsCrashWithErroneousTreeTest.java
+++ b/langtools/test/tools/javac/T8026963/TypeAnnotationsCrashWithErroneousTreeTest.java
@@ -2,7 +2,7 @@
* @test /nodynamiccopyright/
* @bug 8026963
* @summary type annotations code crashes for lambdas with void argument
- * @compile/fail/ref=TypeAnnotationsCrashWithErroneousTreeTest.out -XDrawDiagnostics -Xshouldstop:at=FLOW TypeAnnotationsCrashWithErroneousTreeTest.java
+ * @compile/fail/ref=TypeAnnotationsCrashWithErroneousTreeTest.out -XDrawDiagnostics --should-stop:at=FLOW TypeAnnotationsCrashWithErroneousTreeTest.java
*/
public class TypeAnnotationsCrashWithErroneousTreeTest {
diff --git a/langtools/test/tools/javac/annotations/neg/8022765/VerifyErroneousAnnotationsAttributed.java b/langtools/test/tools/javac/annotations/neg/8022765/VerifyErroneousAnnotationsAttributed.java
index 61809f98a25..263a145af38 100644
--- a/langtools/test/tools/javac/annotations/neg/8022765/VerifyErroneousAnnotationsAttributed.java
+++ b/langtools/test/tools/javac/annotations/neg/8022765/VerifyErroneousAnnotationsAttributed.java
@@ -237,7 +237,7 @@ public class VerifyErroneousAnnotationsAttributed {
JavacTask task = tool.getTask(null,
fm,
devNull,
- Arrays.asList("-Xshouldstop:at=FLOW"),
+ Arrays.asList("--should-stop:at=FLOW"),
null,
Arrays.asList(new MyFileObject(code)));
diff --git a/langtools/test/tools/javac/annotations/typeAnnotations/newlocations/AfterMethodTypeParams.java b/langtools/test/tools/javac/annotations/typeAnnotations/newlocations/AfterMethodTypeParams.java
index 0fae6e01d5d..bea25e934c8 100644
--- a/langtools/test/tools/javac/annotations/typeAnnotations/newlocations/AfterMethodTypeParams.java
+++ b/langtools/test/tools/javac/annotations/typeAnnotations/newlocations/AfterMethodTypeParams.java
@@ -54,7 +54,7 @@ public class AfterMethodTypeParams {
String test = TEMPLATE.replace("CONTENT", tc.snippet);
List files = Arrays.asList(new MyFileObject(test));
StringWriter out = new StringWriter();
- List options = Arrays.asList("-XDrawDiagnostics", "-Xshouldstop:at=FLOW");
+ List options = Arrays.asList("-XDrawDiagnostics", "--should-stop:at=FLOW");
JavacTask task = (JavacTask) compiler.getTask(out, null, null, options, null, files);
new TreePathScanner() {
diff --git a/langtools/test/tools/javac/api/6731573/T6731573.java b/langtools/test/tools/javac/api/6731573/T6731573.java
index 141cc9d7234..435e2b26f98 100644
--- a/langtools/test/tools/javac/api/6731573/T6731573.java
+++ b/langtools/test/tools/javac/api/6731573/T6731573.java
@@ -62,8 +62,8 @@ public class T6731573 extends ToolTester {
enum SourceLine {
STANDARD(null),
- ENABLED("-diags:showSource=true"),
- DISABLED("-diags:showSource=false");
+ ENABLED("--diags:showSource=true"),
+ DISABLED("--diags:showSource=false");
String optValue;
diff --git a/langtools/test/tools/javac/api/taskListeners/EventsBalancedTest.java b/langtools/test/tools/javac/api/taskListeners/EventsBalancedTest.java
index 1b51e2af078..b55053c7a81 100644
--- a/langtools/test/tools/javac/api/taskListeners/EventsBalancedTest.java
+++ b/langtools/test/tools/javac/api/taskListeners/EventsBalancedTest.java
@@ -63,11 +63,11 @@ public class EventsBalancedTest {
test(null, Arrays.asList(b, a));
for (CompileState stop : CompileState.values()) {
- test(Arrays.asList("-Xshouldstop:ifNoError=" + stop,
- "-Xshouldstop:ifError=" + stop),
+ test(Arrays.asList("--should-stop:ifNoError=" + stop,
+ "--should-stop:ifError=" + stop),
Arrays.asList(a, b));
- test(Arrays.asList("-Xshouldstop:ifNoError=" + stop,
- "-Xshouldstop:ifError=" + stop),
+ test(Arrays.asList("--should-stop:ifNoError=" + stop,
+ "--should-stop:ifError=" + stop),
Arrays.asList(b, a));
}
}
diff --git a/langtools/test/tools/javac/completionDeps/DepsAndAnno.java b/langtools/test/tools/javac/completionDeps/DepsAndAnno.java
index 072010bc40e..8ba7f54e183 100644
--- a/langtools/test/tools/javac/completionDeps/DepsAndAnno.java
+++ b/langtools/test/tools/javac/completionDeps/DepsAndAnno.java
@@ -47,7 +47,7 @@ public class DepsAndAnno {
public static void main(String[] args) {
ToolBox toolBox = new ToolBox();
new JavacTask(toolBox, Task.Mode.CMDLINE)
- .options("-Xdebug:completionDeps")
+ .options("--debug:completionDeps")
.outdir(".")
.files(ToolBox.testSrc + "/DepsAndAnno.java")
.run();
diff --git a/langtools/test/tools/javac/completionDeps/DepsAndDocLint.java b/langtools/test/tools/javac/completionDeps/DepsAndDocLint.java
index 86501ea091d..95912f01c52 100644
--- a/langtools/test/tools/javac/completionDeps/DepsAndDocLint.java
+++ b/langtools/test/tools/javac/completionDeps/DepsAndDocLint.java
@@ -25,7 +25,7 @@
* @test
* @bug 8078389
* @summary Make sure there is no interference between completionDeps and doclint
- * @compile -Xdebug:completionDeps -Xdoclint DepsAndDocLint.java
+ * @compile --debug:completionDeps -Xdoclint DepsAndDocLint.java
*/
public class DepsAndDocLint {
diff --git a/langtools/test/tools/javac/diags/CheckResourceKeys.java b/langtools/test/tools/javac/diags/CheckResourceKeys.java
index dfd43d6e9c2..dde2681054b 100644
--- a/langtools/test/tools/javac/diags/CheckResourceKeys.java
+++ b/langtools/test/tools/javac/diags/CheckResourceKeys.java
@@ -260,8 +260,8 @@ public class CheckResourceKeys {
// ignore debug flag names
if (cs.startsWith("debug."))
continue;
- // ignore shouldstop flag names
- if (cs.startsWith("shouldstop."))
+ // ignore should-stop flag names
+ if (cs.startsWith("should-stop."))
continue;
// ignore diagsformat flag names
if (cs.startsWith("diags."))
diff --git a/langtools/test/tools/javac/diags/examples/ApplicableMethodFound.java b/langtools/test/tools/javac/diags/examples/ApplicableMethodFound.java
index 8eb43ad566a..bb324afa790 100644
--- a/langtools/test/tools/javac/diags/examples/ApplicableMethodFound.java
+++ b/langtools/test/tools/javac/diags/examples/ApplicableMethodFound.java
@@ -23,7 +23,7 @@
// key: compiler.misc.applicable.method.found
// key: compiler.note.verbose.resolve.multi
-// options: -Xdebug:verboseResolution=applicable,success
+// options: --debug:verboseResolution=applicable,success
class ApplicableMethodFound {
diff --git a/langtools/test/tools/javac/diags/examples/ApplicableMethodFound1.java b/langtools/test/tools/javac/diags/examples/ApplicableMethodFound1.java
index 67e70c3423e..5ecca3a329f 100644
--- a/langtools/test/tools/javac/diags/examples/ApplicableMethodFound1.java
+++ b/langtools/test/tools/javac/diags/examples/ApplicableMethodFound1.java
@@ -24,7 +24,7 @@
// key: compiler.misc.applicable.method.found.1
// key: compiler.note.verbose.resolve.multi
// key: compiler.misc.partial.inst.sig
-// options: -Xdebug:verboseResolution=applicable,success
+// options: --debug:verboseResolution=applicable,success
class ApplicableMethodFound1 {
diff --git a/langtools/test/tools/javac/diags/examples/DeferredMethodInst.java b/langtools/test/tools/javac/diags/examples/DeferredMethodInst.java
index f0c2c853dad..59bfd4c37f8 100644
--- a/langtools/test/tools/javac/diags/examples/DeferredMethodInst.java
+++ b/langtools/test/tools/javac/diags/examples/DeferredMethodInst.java
@@ -25,7 +25,7 @@
// key: compiler.note.verbose.resolve.multi
// key: compiler.note.deferred.method.inst
// key: compiler.misc.partial.inst.sig
-// options: -Xdebug:verboseResolution=applicable,success,deferred-inference
+// options: --debug:verboseResolution=applicable,success,deferred-inference
class DeferredMethodInst {
diff --git a/langtools/test/tools/javac/diags/examples/LambdaStat.java b/langtools/test/tools/javac/diags/examples/LambdaStat.java
index a57b4e33778..c3ee38d6f8e 100644
--- a/langtools/test/tools/javac/diags/examples/LambdaStat.java
+++ b/langtools/test/tools/javac/diags/examples/LambdaStat.java
@@ -22,7 +22,7 @@
*/
// key: compiler.note.lambda.stat
-// options: -Xdebug:dumpLambdaToMethodStats
+// options: --debug:dumpLambdaToMethodStats
class LambdaStat {
Runnable r = ()->{};
diff --git a/langtools/test/tools/javac/diags/examples/MrefStat.java b/langtools/test/tools/javac/diags/examples/MrefStat.java
index 5d79977c1f1..7f84baa8ca0 100644
--- a/langtools/test/tools/javac/diags/examples/MrefStat.java
+++ b/langtools/test/tools/javac/diags/examples/MrefStat.java
@@ -22,7 +22,7 @@
*/
// key: compiler.note.mref.stat
-// options: -Xdebug:dumpLambdaToMethodStats
+// options: --debug:dumpLambdaToMethodStats
class MrefStat {
Runnable r = MrefStat::m;
diff --git a/langtools/test/tools/javac/diags/examples/MrefStat1.java b/langtools/test/tools/javac/diags/examples/MrefStat1.java
index b3128eedbe7..c4bdf4cff2d 100644
--- a/langtools/test/tools/javac/diags/examples/MrefStat1.java
+++ b/langtools/test/tools/javac/diags/examples/MrefStat1.java
@@ -22,7 +22,7 @@
*/
// key: compiler.note.mref.stat.1
-// options: -Xdebug:dumpLambdaToMethodStats
+// options: --debug:dumpLambdaToMethodStats
class MrefStat1 {
diff --git a/langtools/test/tools/javac/diags/examples/NotApplicableMethodFound.java b/langtools/test/tools/javac/diags/examples/NotApplicableMethodFound.java
index edbaabe8c6e..dc199bc3e38 100644
--- a/langtools/test/tools/javac/diags/examples/NotApplicableMethodFound.java
+++ b/langtools/test/tools/javac/diags/examples/NotApplicableMethodFound.java
@@ -26,7 +26,7 @@
// key: compiler.err.cant.apply.symbol
// key: compiler.misc.no.conforming.assignment.exists
// key: compiler.misc.inconvertible.types
-// options: -Xdebug:verboseResolution=inapplicable,failure
+// options: --debug:verboseResolution=inapplicable,failure
class NotApplicableMethodFound {
diff --git a/langtools/test/tools/javac/diags/examples/PartialInstSig.java b/langtools/test/tools/javac/diags/examples/PartialInstSig.java
index e2a9c8e0aa0..4a56058856f 100644
--- a/langtools/test/tools/javac/diags/examples/PartialInstSig.java
+++ b/langtools/test/tools/javac/diags/examples/PartialInstSig.java
@@ -24,7 +24,7 @@
// key: compiler.misc.applicable.method.found.1
// key: compiler.note.verbose.resolve.multi
// key: compiler.misc.partial.inst.sig
-// options: -Xdebug:verboseResolution=applicable,success
+// options: --debug:verboseResolution=applicable,success
class PartialInstSig {
diff --git a/langtools/test/tools/javac/diags/examples/VerboseResolveMulti.java b/langtools/test/tools/javac/diags/examples/VerboseResolveMulti.java
index 40108785d0e..c097c74085a 100644
--- a/langtools/test/tools/javac/diags/examples/VerboseResolveMulti.java
+++ b/langtools/test/tools/javac/diags/examples/VerboseResolveMulti.java
@@ -23,7 +23,7 @@
// key: compiler.misc.applicable.method.found
// key: compiler.note.verbose.resolve.multi
-// options: -Xdebug:verboseResolution=applicable,success
+// options: --debug:verboseResolution=applicable,success
class VerboseResolveMulti {
diff --git a/langtools/test/tools/javac/diags/examples/VerboseResolveMulti1.java b/langtools/test/tools/javac/diags/examples/VerboseResolveMulti1.java
index d9a5b8bcc3e..33e7a2deef4 100644
--- a/langtools/test/tools/javac/diags/examples/VerboseResolveMulti1.java
+++ b/langtools/test/tools/javac/diags/examples/VerboseResolveMulti1.java
@@ -26,7 +26,7 @@
// key: compiler.err.cant.apply.symbol
// key: compiler.misc.no.conforming.assignment.exists
// key: compiler.misc.inconvertible.types
-// options: -Xdebug:verboseResolution=inapplicable,failure
+// options: --debug:verboseResolution=inapplicable,failure
class VerboseResolveMulti1 {
diff --git a/langtools/test/tools/javac/diags/examples/WhereCaptured.java b/langtools/test/tools/javac/diags/examples/WhereCaptured.java
index 5ea17aea1ed..22fc86530dd 100644
--- a/langtools/test/tools/javac/diags/examples/WhereCaptured.java
+++ b/langtools/test/tools/javac/diags/examples/WhereCaptured.java
@@ -28,7 +28,7 @@
// key: compiler.err.cant.apply.symbol
// key: compiler.misc.incompatible.eq.bounds
// key: compiler.misc.captured.type
-// options: -diags:formatterOptions=where,simpleNames
+// options: --diags:formatterOptions=where,simpleNames
// run: simple
import java.util.*;
diff --git a/langtools/test/tools/javac/diags/examples/WhereCaptured1.java b/langtools/test/tools/javac/diags/examples/WhereCaptured1.java
index f5ce62e2188..26fdf3e8f5b 100644
--- a/langtools/test/tools/javac/diags/examples/WhereCaptured1.java
+++ b/langtools/test/tools/javac/diags/examples/WhereCaptured1.java
@@ -29,7 +29,7 @@
// key: compiler.misc.incompatible.eq.bounds
// key: compiler.misc.captured.type
// key: compiler.misc.type.null
-// options: -diags:formatterOptions=where,simpleNames
+// options: --diags:formatterOptions=where,simpleNames
// run: simple
import java.util.*;
diff --git a/langtools/test/tools/javac/diags/examples/WhereFreshTvar.java b/langtools/test/tools/javac/diags/examples/WhereFreshTvar.java
index eb894a9f2cb..fb060c89c1e 100644
--- a/langtools/test/tools/javac/diags/examples/WhereFreshTvar.java
+++ b/langtools/test/tools/javac/diags/examples/WhereFreshTvar.java
@@ -25,7 +25,7 @@
// key: compiler.misc.where.description.typevar
// key: compiler.err.prob.found.req
// key: compiler.misc.inconvertible.types
-// options: -diags:formatterOptions=where,simpleNames
+// options: --diags:formatterOptions=where,simpleNames
// run: simple
import java.util.*;
diff --git a/langtools/test/tools/javac/diags/examples/WhereIntersection.java b/langtools/test/tools/javac/diags/examples/WhereIntersection.java
index 8b8a6fbd612..beec1d7cd6e 100644
--- a/langtools/test/tools/javac/diags/examples/WhereIntersection.java
+++ b/langtools/test/tools/javac/diags/examples/WhereIntersection.java
@@ -26,7 +26,7 @@
// key: compiler.misc.where.description.intersection.1
// key: compiler.misc.where.intersection
// key: compiler.err.prob.found.req
-// options: -diags:formatterOptions=where
+// options: --diags:formatterOptions=where
// run: simple
class WhereIntersection {
diff --git a/langtools/test/tools/javac/diags/examples/WhereIntersection2.java b/langtools/test/tools/javac/diags/examples/WhereIntersection2.java
index 6850627db88..91cab029c46 100644
--- a/langtools/test/tools/javac/diags/examples/WhereIntersection2.java
+++ b/langtools/test/tools/javac/diags/examples/WhereIntersection2.java
@@ -29,7 +29,7 @@
// key: compiler.misc.where.description.intersection
// key: compiler.misc.where.intersection
// key: compiler.err.prob.found.req
-// options: -diags:formatterOptions=where
+// options: --diags:formatterOptions=where
// run: simple
class WhereIntersection2 {
diff --git a/langtools/test/tools/javac/diags/examples/WhereTypeVar.java b/langtools/test/tools/javac/diags/examples/WhereTypeVar.java
index 9adca945a28..55097a8ce6a 100644
--- a/langtools/test/tools/javac/diags/examples/WhereTypeVar.java
+++ b/langtools/test/tools/javac/diags/examples/WhereTypeVar.java
@@ -27,7 +27,7 @@
// key: compiler.err.cant.apply.symbol
// key: compiler.misc.no.conforming.assignment.exists
// key: compiler.misc.inconvertible.types
-// options: -diags:formatterOptions=where,disambiguateTvars
+// options: --diags:formatterOptions=where,disambiguateTvars
// run: simple
class WhereTypeVar {
diff --git a/langtools/test/tools/javac/diags/examples/WhereTypeVar2.java b/langtools/test/tools/javac/diags/examples/WhereTypeVar2.java
index 41341f68275..1f6f51b9431 100644
--- a/langtools/test/tools/javac/diags/examples/WhereTypeVar2.java
+++ b/langtools/test/tools/javac/diags/examples/WhereTypeVar2.java
@@ -25,7 +25,7 @@
// key: compiler.misc.where.description.typevar
// key: compiler.misc.where.typevar
// key: compiler.err.prob.found.req
-// options: -diags:formatterOptions=where
+// options: --diags:formatterOptions=where
// run: simple
class WhereTypeVar2 {
diff --git a/langtools/test/tools/javac/failover/CheckAttributedTree.java b/langtools/test/tools/javac/failover/CheckAttributedTree.java
index b9bb22bac2d..6c2d2cbc60d 100644
--- a/langtools/test/tools/javac/failover/CheckAttributedTree.java
+++ b/langtools/test/tools/javac/failover/CheckAttributedTree.java
@@ -311,7 +311,7 @@ public class CheckAttributedTree {
final List trees = new ArrayList<>();
Iterable extends Element> elems = newCompilationTask()
.withWriter(pw)
- .withOption("-Xshouldstop:at=ATTR")
+ .withOption("--should-stop:at=ATTR")
.withOption("-XDverboseCompilePolicy")
.withSource(files.iterator().next())
.withListener(new TaskListener() {
diff --git a/langtools/test/tools/javac/failover/FailOver01.java b/langtools/test/tools/javac/failover/FailOver01.java
index 473adfd4759..e8d4da79272 100644
--- a/langtools/test/tools/javac/failover/FailOver01.java
+++ b/langtools/test/tools/javac/failover/FailOver01.java
@@ -4,7 +4,7 @@
* @summary Flow.java should be more error-friendly
* @author mcimadamore
*
- * @compile/fail/ref=FailOver01.out -XDrawDiagnostics -Xshouldstop:at=FLOW -XDdev FailOver01.java
+ * @compile/fail/ref=FailOver01.out -XDrawDiagnostics --should-stop:at=FLOW -XDdev FailOver01.java
*/
class Test { { x = "" } }
diff --git a/langtools/test/tools/javac/failover/FailOver02.java b/langtools/test/tools/javac/failover/FailOver02.java
index 75c44665418..0aac6fa4546 100644
--- a/langtools/test/tools/javac/failover/FailOver02.java
+++ b/langtools/test/tools/javac/failover/FailOver02.java
@@ -4,7 +4,7 @@
* @summary Flow.java should be more error-friendly
* @author mcimadamore
*
- * @compile/fail/ref=FailOver02.out -XDrawDiagnostics -Xshouldstop:at=FLOW -XDdev FailOver02.java
+ * @compile/fail/ref=FailOver02.out -XDrawDiagnostics --should-stop:at=FLOW -XDdev FailOver02.java
*/
class Test implements AutoCloseable {
diff --git a/langtools/test/tools/javac/failover/FailOver03.java b/langtools/test/tools/javac/failover/FailOver03.java
index 268f8acd044..cdfe3a8d81c 100644
--- a/langtools/test/tools/javac/failover/FailOver03.java
+++ b/langtools/test/tools/javac/failover/FailOver03.java
@@ -4,7 +4,7 @@
* @summary Flow.java should be more error-friendly
* @author mcimadamore
*
- * @compile/fail/ref=FailOver03.out -XDrawDiagnostics -Xshouldstop:at=FLOW -XDdev FailOver03.java
+ * @compile/fail/ref=FailOver03.out -XDrawDiagnostics --should-stop:at=FLOW -XDdev FailOver03.java
*/
class Test extends Test {
diff --git a/langtools/test/tools/javac/failover/FailOver04.java b/langtools/test/tools/javac/failover/FailOver04.java
index e8b72ddd521..e9a723d1a19 100644
--- a/langtools/test/tools/javac/failover/FailOver04.java
+++ b/langtools/test/tools/javac/failover/FailOver04.java
@@ -4,7 +4,7 @@
* @summary Flow.java should be more error-friendly
* @author mcimadamore
*
- * @compile/fail/ref=FailOver04.out -XDrawDiagnostics -Xshouldstop:at=FLOW -XDdev FailOver04.java
+ * @compile/fail/ref=FailOver04.out -XDrawDiagnostics --should-stop:at=FLOW -XDdev FailOver04.java
*/
class Test {
diff --git a/langtools/test/tools/javac/failover/FailOver05.java b/langtools/test/tools/javac/failover/FailOver05.java
index 5209373272a..cbbbc222b7c 100644
--- a/langtools/test/tools/javac/failover/FailOver05.java
+++ b/langtools/test/tools/javac/failover/FailOver05.java
@@ -4,7 +4,7 @@
* @summary Flow.java should be more error-friendly
* @author mcimadamore
*
- * @compile/fail/ref=FailOver05.out -XDrawDiagnostics -Xshouldstop:at=FLOW -XDdev FailOver05.java
+ * @compile/fail/ref=FailOver05.out -XDrawDiagnostics --should-stop:at=FLOW -XDdev FailOver05.java
*/
class Test extends Test {
diff --git a/langtools/test/tools/javac/failover/FailOver06.java b/langtools/test/tools/javac/failover/FailOver06.java
index fb28274cde7..14f7fa34f97 100644
--- a/langtools/test/tools/javac/failover/FailOver06.java
+++ b/langtools/test/tools/javac/failover/FailOver06.java
@@ -4,7 +4,7 @@
* @summary Flow.java should be more error-friendly
* @author mcimadamore
*
- * @compile/fail/ref=FailOver06.out -XDrawDiagnostics -Xshouldstop:at=FLOW -XDdev FailOver06.java
+ * @compile/fail/ref=FailOver06.out -XDrawDiagnostics --should-stop:at=FLOW -XDdev FailOver06.java
*/
class Test extends Test {
diff --git a/langtools/test/tools/javac/failover/FailOver07.java b/langtools/test/tools/javac/failover/FailOver07.java
index 216c462d50a..a73037a0e99 100644
--- a/langtools/test/tools/javac/failover/FailOver07.java
+++ b/langtools/test/tools/javac/failover/FailOver07.java
@@ -4,7 +4,7 @@
* @summary Flow.java should be more error-friendly
* @author mcimadamore
*
- * @compile/fail/ref=FailOver07.out -XDrawDiagnostics -Xshouldstop:at=FLOW -XDdev FailOver07.java
+ * @compile/fail/ref=FailOver07.out -XDrawDiagnostics --should-stop:at=FLOW -XDdev FailOver07.java
*/
class Test extends Test {
diff --git a/langtools/test/tools/javac/failover/FailOver08.java b/langtools/test/tools/javac/failover/FailOver08.java
index e993f3dee09..d2446ae59af 100644
--- a/langtools/test/tools/javac/failover/FailOver08.java
+++ b/langtools/test/tools/javac/failover/FailOver08.java
@@ -4,7 +4,7 @@
* @summary Flow.java should be more error-friendly
* @author mcimadamore
*
- * @compile/fail/ref=FailOver08.out -XDrawDiagnostics -Xshouldstop:at=FLOW -XDdev FailOver08.java
+ * @compile/fail/ref=FailOver08.out -XDrawDiagnostics --should-stop:at=FLOW -XDdev FailOver08.java
*/
class Test extends Test {
diff --git a/langtools/test/tools/javac/failover/FailOver09.java b/langtools/test/tools/javac/failover/FailOver09.java
index ca4976895fb..bc126e140f6 100644
--- a/langtools/test/tools/javac/failover/FailOver09.java
+++ b/langtools/test/tools/javac/failover/FailOver09.java
@@ -4,7 +4,7 @@
* @summary Flow.java should be more error-friendly
* @author mcimadamore
*
- * @compile/fail/ref=FailOver09.out -XDrawDiagnostics -Xshouldstop:at=FLOW -XDdev FailOver09.java
+ * @compile/fail/ref=FailOver09.out -XDrawDiagnostics --should-stop:at=FLOW -XDdev FailOver09.java
*/
class Test extends Test {
diff --git a/langtools/test/tools/javac/failover/FailOver10.java b/langtools/test/tools/javac/failover/FailOver10.java
index 2265de57442..5d32c85437d 100644
--- a/langtools/test/tools/javac/failover/FailOver10.java
+++ b/langtools/test/tools/javac/failover/FailOver10.java
@@ -4,7 +4,7 @@
* @summary Flow.java should be more error-friendly
* @author mcimadamore
*
- * @compile/fail/ref=FailOver10.out -XDrawDiagnostics -Xshouldstop:at=FLOW -XDdev FailOver10.java
+ * @compile/fail/ref=FailOver10.out -XDrawDiagnostics --should-stop:at=FLOW -XDdev FailOver10.java
*/
class Test extends Test {
diff --git a/langtools/test/tools/javac/failover/FailOver11.java b/langtools/test/tools/javac/failover/FailOver11.java
index aaad2800747..863053982bc 100644
--- a/langtools/test/tools/javac/failover/FailOver11.java
+++ b/langtools/test/tools/javac/failover/FailOver11.java
@@ -4,7 +4,7 @@
* @summary Flow.java should be more error-friendly
* @author mcimadamore
*
- * @compile/fail/ref=FailOver11.out -XDrawDiagnostics -Xshouldstop:at=FLOW -XDdev FailOver11.java
+ * @compile/fail/ref=FailOver11.out -XDrawDiagnostics --should-stop:at=FLOW -XDdev FailOver11.java
*/
class Test extends Test {
diff --git a/langtools/test/tools/javac/failover/FailOver12.java b/langtools/test/tools/javac/failover/FailOver12.java
index da1e126ffeb..ed8699e039c 100644
--- a/langtools/test/tools/javac/failover/FailOver12.java
+++ b/langtools/test/tools/javac/failover/FailOver12.java
@@ -4,7 +4,7 @@
* @summary Flow.java should be more error-friendly
* @author mcimadamore
*
- * @compile/fail/ref=FailOver12.out -XDrawDiagnostics -Xshouldstop:at=FLOW -XDdev FailOver12.java
+ * @compile/fail/ref=FailOver12.out -XDrawDiagnostics --should-stop:at=FLOW -XDdev FailOver12.java
*/
class Test extends Test {
diff --git a/langtools/test/tools/javac/failover/FailOver13.java b/langtools/test/tools/javac/failover/FailOver13.java
index 03cf4259011..f85249d0833 100644
--- a/langtools/test/tools/javac/failover/FailOver13.java
+++ b/langtools/test/tools/javac/failover/FailOver13.java
@@ -4,7 +4,7 @@
* @summary Flow.java should be more error-friendly
* @author mcimadamore
*
- * @compile/fail/ref=FailOver13.out -XDrawDiagnostics -Xshouldstop:at=FLOW -XDdev FailOver13.java
+ * @compile/fail/ref=FailOver13.out -XDrawDiagnostics --should-stop:at=FLOW -XDdev FailOver13.java
*/
class Test extends Test {
diff --git a/langtools/test/tools/javac/failover/FailOver14.java b/langtools/test/tools/javac/failover/FailOver14.java
index 6f24ff3e558..c0d3ab78abd 100644
--- a/langtools/test/tools/javac/failover/FailOver14.java
+++ b/langtools/test/tools/javac/failover/FailOver14.java
@@ -4,7 +4,7 @@
* @summary Flow.java should be more error-friendly
* @author mcimadamore
*
- * @compile/fail/ref=FailOver14.out -XDrawDiagnostics -Xshouldstop:at=FLOW -XDdev FailOver14.java
+ * @compile/fail/ref=FailOver14.out -XDrawDiagnostics --should-stop:at=FLOW -XDdev FailOver14.java
*/
class Test extends Test {
diff --git a/langtools/test/tools/javac/failover/FailOver15.java b/langtools/test/tools/javac/failover/FailOver15.java
index 6fe5e5ae485..619cfd3a5ac 100644
--- a/langtools/test/tools/javac/failover/FailOver15.java
+++ b/langtools/test/tools/javac/failover/FailOver15.java
@@ -3,7 +3,7 @@
* @bug 6970584 7060926
* @summary Attr.PostAttrAnalyzer misses a case
*
- * @compile/fail/ref=FailOver15.out -XDrawDiagnostics -Xshouldstop:at=FLOW -XDdev FailOver15.java
+ * @compile/fail/ref=FailOver15.out -XDrawDiagnostics --should-stop:at=FLOW -XDdev FailOver15.java
*/
class Test {
diff --git a/langtools/test/tools/javac/generics/inference/8158355/T8158355.java b/langtools/test/tools/javac/generics/inference/8158355/T8158355.java
index a123a33ab91..edc6fe95254 100644
--- a/langtools/test/tools/javac/generics/inference/8158355/T8158355.java
+++ b/langtools/test/tools/javac/generics/inference/8158355/T8158355.java
@@ -27,7 +27,7 @@
* @test
* @bug 8158355
* @summary Inference graph dot support broken
- * @compile -Xdebug:dumpInferenceGraphsTo=. T8158355.java
+ * @compile --debug:dumpInferenceGraphsTo=. T8158355.java
*/
import java.util.List;
diff --git a/langtools/test/tools/javac/lambda/MostSpecific09.java b/langtools/test/tools/javac/lambda/MostSpecific09.java
index 311af8d7b1a..82e12d69839 100644
--- a/langtools/test/tools/javac/lambda/MostSpecific09.java
+++ b/langtools/test/tools/javac/lambda/MostSpecific09.java
@@ -2,7 +2,7 @@
* @test /nodynamiccopyright/
* @bug 8029718
* @summary Should always use lambda body structure to disambiguate overload resolution
- * @compile/fail/ref=MostSpecific09.out -XDrawDiagnostics -Xshouldstop:at=ATTR -Xdebug:verboseResolution=applicable,success MostSpecific09.java
+ * @compile/fail/ref=MostSpecific09.out -XDrawDiagnostics --should-stop:at=ATTR --debug:verboseResolution=applicable,success MostSpecific09.java
*/
class MostSpecific09 {
diff --git a/langtools/test/tools/javac/lambda/MostSpecific09.out b/langtools/test/tools/javac/lambda/MostSpecific09.out
index 75330535ba0..5359cb7f3bf 100644
--- a/langtools/test/tools/javac/lambda/MostSpecific09.out
+++ b/langtools/test/tools/javac/lambda/MostSpecific09.out
@@ -3,7 +3,7 @@ MostSpecific09.java:26:9: compiler.note.verbose.resolve.multi: foo, MostSpecific
MostSpecific09.java:27:9: compiler.note.verbose.resolve.multi: foo, MostSpecific09, 0, BASIC, compiler.misc.type.none, compiler.misc.no.args,{(compiler.misc.applicable.method.found: 0, foo(MostSpecific09.J), null)}
MostSpecific09.java:27:32: compiler.note.verbose.resolve.multi: println, java.io.PrintStream, 1, BASIC, java.lang.String, compiler.misc.no.args,{(compiler.misc.applicable.method.found: 0, println(java.lang.Object), null),(compiler.misc.applicable.method.found: 1, println(java.lang.String), null)}
MostSpecific09.java:28:13: compiler.err.lambda.body.neither.value.nor.void.compatible
-MostSpecific09.java:28:9: compiler.err.cant.apply.symbols: kindname.method, foo, @681,{(compiler.misc.inapplicable.method: kindname.method, MostSpecific09, foo(MostSpecific09.I), (compiler.misc.no.conforming.assignment.exists: (compiler.misc.incompatible.ret.type.in.lambda: (compiler.misc.missing.ret.val: java.lang.String)))),(compiler.misc.inapplicable.method: kindname.method, MostSpecific09, foo(MostSpecific09.J), (compiler.misc.no.conforming.assignment.exists: (compiler.misc.unexpected.ret.val)))}
+MostSpecific09.java:28:9: compiler.err.cant.apply.symbols: kindname.method, foo, @682,{(compiler.misc.inapplicable.method: kindname.method, MostSpecific09, foo(MostSpecific09.I), (compiler.misc.no.conforming.assignment.exists: (compiler.misc.incompatible.ret.type.in.lambda: (compiler.misc.missing.ret.val: java.lang.String)))),(compiler.misc.inapplicable.method: kindname.method, MostSpecific09, foo(MostSpecific09.J), (compiler.misc.no.conforming.assignment.exists: (compiler.misc.unexpected.ret.val)))}
MostSpecific09.java:28:43: compiler.note.verbose.resolve.multi: println, java.io.PrintStream, 1, BASIC, java.lang.String, compiler.misc.no.args,{(compiler.misc.applicable.method.found: 0, println(java.lang.Object), null),(compiler.misc.applicable.method.found: 1, println(java.lang.String), null)}
MostSpecific09.java:29:9: compiler.err.ref.ambiguous: foo, kindname.method, foo(MostSpecific09.I), MostSpecific09, kindname.method, foo(MostSpecific09.J), MostSpecific09
MostSpecific09.java:29:28: compiler.note.verbose.resolve.multi: , java.lang.RuntimeException, 0, BASIC, compiler.misc.no.args, compiler.misc.no.args,{(compiler.misc.applicable.method.found: 0, java.lang.RuntimeException(), null)}
@@ -11,7 +11,7 @@ MostSpecific09.java:30:9: compiler.err.ref.ambiguous: foo, kindname.method, foo(
MostSpecific09.java:32:9: compiler.err.ref.ambiguous: foo, kindname.method, foo(MostSpecific09.I), MostSpecific09, kindname.method, foo(MostSpecific09.J), MostSpecific09
MostSpecific09.java:33:9: compiler.note.verbose.resolve.multi: foo, MostSpecific09, 0, BASIC, compiler.misc.type.none, compiler.misc.no.args,{(compiler.misc.applicable.method.found: 0, foo(MostSpecific09.I), null)}
MostSpecific09.java:42:13: compiler.err.lambda.body.neither.value.nor.void.compatible
-MostSpecific09.java:42:9: compiler.err.cant.apply.symbols: kindname.method, foo, @1130,{(compiler.misc.inapplicable.method: kindname.method, MostSpecific09, foo(MostSpecific09.I), (compiler.misc.no.conforming.assignment.exists: (compiler.misc.incompatible.ret.type.in.lambda: (compiler.misc.missing.ret.val: java.lang.String)))),(compiler.misc.inapplicable.method: kindname.method, MostSpecific09, foo(MostSpecific09.J), (compiler.misc.no.conforming.assignment.exists: (compiler.misc.unexpected.ret.val)))}
+MostSpecific09.java:42:9: compiler.err.cant.apply.symbols: kindname.method, foo, @1131,{(compiler.misc.inapplicable.method: kindname.method, MostSpecific09, foo(MostSpecific09.I), (compiler.misc.no.conforming.assignment.exists: (compiler.misc.incompatible.ret.type.in.lambda: (compiler.misc.missing.ret.val: java.lang.String)))),(compiler.misc.inapplicable.method: kindname.method, MostSpecific09, foo(MostSpecific09.J), (compiler.misc.no.conforming.assignment.exists: (compiler.misc.unexpected.ret.val)))}
MostSpecific09.java:46:23: compiler.note.verbose.resolve.multi: println, java.io.PrintStream, 1, BASIC, java.lang.String, compiler.misc.no.args,{(compiler.misc.applicable.method.found: 0, println(java.lang.Object), null),(compiler.misc.applicable.method.found: 1, println(java.lang.String), null)}
MostSpecific09.java:49:9: compiler.note.verbose.resolve.multi: foo, MostSpecific09, 0, BASIC, compiler.misc.type.none, compiler.misc.no.args,{(compiler.misc.applicable.method.found: 0, foo(MostSpecific09.J), null)}
MostSpecific09.java:56:25: compiler.note.verbose.resolve.multi: , Bar, 0, BASIC, compiler.misc.no.args, compiler.misc.no.args,{(compiler.misc.applicable.method.found: 0, Bar(), null)}
diff --git a/langtools/test/tools/javac/lambda/TestLambdaToMethodStats.java b/langtools/test/tools/javac/lambda/TestLambdaToMethodStats.java
index b7d2e0f9f6d..6546f3ddf26 100644
--- a/langtools/test/tools/javac/lambda/TestLambdaToMethodStats.java
+++ b/langtools/test/tools/javac/lambda/TestLambdaToMethodStats.java
@@ -122,7 +122,7 @@ public class TestLambdaToMethodStats extends ComboInstance sources = new ArrayList<>();
sources.add(src);
diff --git a/langtools/test/tools/javac/protectedAccess/ProtectedMemberAccess2.java b/langtools/test/tools/javac/protectedAccess/ProtectedMemberAccess2.java
index 0963135bf37..5910eaa73c4 100644
--- a/langtools/test/tools/javac/protectedAccess/ProtectedMemberAccess2.java
+++ b/langtools/test/tools/javac/protectedAccess/ProtectedMemberAccess2.java
@@ -4,7 +4,7 @@
* @summary Verify correct implementation of JLS2e 6.6.2.1
* @author maddox
*
- * @compile/fail/ref=ProtectedMemberAccess2.out -diags:formatterOptions=-simpleNames;layout=%b:%l:%_%m ProtectedMemberAccess2.java
+ * @compile/fail/ref=ProtectedMemberAccess2.out --diags:formatterOptions=-simpleNames;layout=%b:%l:%_%m ProtectedMemberAccess2.java
*/
// 71 errors expected.
diff --git a/langtools/test/tools/javac/protectedAccess/ProtectedMemberAccess3.java b/langtools/test/tools/javac/protectedAccess/ProtectedMemberAccess3.java
index eacc53e8280..82b8d1b51a1 100644
--- a/langtools/test/tools/javac/protectedAccess/ProtectedMemberAccess3.java
+++ b/langtools/test/tools/javac/protectedAccess/ProtectedMemberAccess3.java
@@ -4,7 +4,7 @@
* @summary Verify correct implementation of JLS2e 6.6.2.1
* @author maddox
*
- * @compile/fail/ref=ProtectedMemberAccess3.out -diags:formatterOptions=-simpleNames;layout=%b:%l:%_%m ProtectedMemberAccess3.java
+ * @compile/fail/ref=ProtectedMemberAccess3.out --diags:formatterOptions=-simpleNames;layout=%b:%l:%_%m ProtectedMemberAccess3.java
*/
// 46 errors expected.
diff --git a/langtools/test/tools/javac/protectedAccess/ProtectedMemberAccess4.java b/langtools/test/tools/javac/protectedAccess/ProtectedMemberAccess4.java
index 695ccf46b29..d8a55813524 100644
--- a/langtools/test/tools/javac/protectedAccess/ProtectedMemberAccess4.java
+++ b/langtools/test/tools/javac/protectedAccess/ProtectedMemberAccess4.java
@@ -4,7 +4,7 @@
* @summary Verify correct implementation of JLS2e 6.6.2.1
* @author maddox
*
- * @compile/fail/ref=ProtectedMemberAccess4.out -diags:formatterOptions=-simpleNames;layout=%b:%l:%_%m ProtectedMemberAccess4.java
+ * @compile/fail/ref=ProtectedMemberAccess4.out --diags:formatterOptions=-simpleNames;layout=%b:%l:%_%m ProtectedMemberAccess4.java
*/
// 33 errors expected.
diff --git a/langtools/test/tools/javac/resolve/ResolveHarness.java b/langtools/test/tools/javac/resolve/ResolveHarness.java
index 099fa4989ef..8de0a6b2432 100644
--- a/langtools/test/tools/javac/resolve/ResolveHarness.java
+++ b/langtools/test/tools/javac/resolve/ResolveHarness.java
@@ -132,8 +132,8 @@ public class ResolveHarness implements javax.tools.DiagnosticListener 0 && methodType.parameterType(parameterCount - 1).isArray();
+
+ if (parameterCount < 2) {
+ return methodHandle; // method does not have enough parameters
+ }
+ final boolean isVarArg = methodType.parameterType(parameterCount - 1).isArray();
if (isVarArg) {
return MH.filterArguments(methodHandle, 1, MH.insertArguments(ADD_ZEROTH_ELEMENT, 1, bindName));
diff --git a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/ScriptObject.java b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/ScriptObject.java
index 059cf1d80e1..df348e148b5 100644
--- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/ScriptObject.java
+++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/ScriptObject.java
@@ -2172,6 +2172,21 @@ public abstract class ScriptObject implements PropertyAccess, Cloneable {
return switchPoints.toArray(new SwitchPoint[0]);
}
+ // Similar to getProtoSwitchPoints method above, but used for additional prototype switchpoints of
+ // properties that are known not to exist, e.g. the original property name in a __noSuchProperty__ invocation.
+ private SwitchPoint getProtoSwitchPoint(final String name) {
+ if (getProto() == null) {
+ return null;
+ }
+
+ for (ScriptObject obj = this; obj.getProto() != null; obj = obj.getProto()) {
+ final ScriptObject parent = obj.getProto();
+ parent.getMap().addListener(name, obj.getMap());
+ }
+
+ return getMap().getSwitchPoint(name);
+ }
+
private void checkSharedProtoMap() {
// Check if our map has an expected shared prototype property map. If it has, make sure that
// the prototype map has not been invalidated, and that it does match the actual map of the prototype.
@@ -2343,7 +2358,9 @@ public abstract class ScriptObject implements PropertyAccess, Cloneable {
final boolean scopeCall = isScope() && NashornCallSiteDescriptor.isScope(desc);
if (find == null) {
- return noSuchProperty(desc, request);
+ return noSuchProperty(desc, request)
+ // Add proto switchpoint to switch from no-such-property to no-such-method if it is ever defined.
+ .addSwitchPoint(getProtoSwitchPoint(NO_SUCH_METHOD_NAME));
}
final boolean explicitInstanceOfCheck = explicitInstanceOfCheck(desc, request);
@@ -2366,7 +2383,9 @@ public abstract class ScriptObject implements PropertyAccess, Cloneable {
Object.class),
NashornGuards.combineGuards(
NashornGuards.getIdentityGuard(this),
- NashornGuards.getMapGuard(getMap(), true)));
+ NashornGuards.getMapGuard(getMap(), true)))
+ // Add a protoype switchpoint for the original name so this gets invalidated if it is ever defined.
+ .addSwitchPoint(getProtoSwitchPoint(name));
}
/**
@@ -2412,7 +2431,9 @@ public abstract class ScriptObject implements PropertyAccess, Cloneable {
func),
getProtoSwitchPoints(NO_SUCH_PROPERTY_NAME, find.getOwner()),
//TODO this doesn't need a ClassCastException as guard always checks script object
- null);
+ null)
+ // Add a protoype switchpoint for the original name so this gets invalidated if it is ever defined.
+ .addSwitchPoint(getProtoSwitchPoint(name));
}
}
diff --git a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/SharedPropertyMap.java b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/SharedPropertyMap.java
index 215d0c85ad8..5277c4faad4 100644
--- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/SharedPropertyMap.java
+++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/SharedPropertyMap.java
@@ -29,7 +29,7 @@ import java.lang.invoke.SwitchPoint;
/**
* This class represents a property map that can be shared among multiple prototype objects, allowing all inheriting
- * top-level objects to also share one property map. This is class is only used for prototype objects, the
+ * top-level objects to also share one property map. This class is only used for prototype objects, the
* top-level objects use ordinary {@link PropertyMap}s with the {@link PropertyMap#sharedProtoMap} field
* set to the expected shared prototype map.
*
diff --git a/jdk/src/java.base/share/classes/sun/text/resources/BreakIteratorRulesProvider.java b/nashorn/test/script/basic/JDK-8077149.js
similarity index 58%
rename from jdk/src/java.base/share/classes/sun/text/resources/BreakIteratorRulesProvider.java
rename to nashorn/test/script/basic/JDK-8077149.js
index 4bbb1cec212..b980ff81027 100644
--- a/jdk/src/java.base/share/classes/sun/text/resources/BreakIteratorRulesProvider.java
+++ b/nashorn/test/script/basic/JDK-8077149.js
@@ -1,12 +1,10 @@
/*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2016, 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. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
+ * 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
@@ -23,13 +21,33 @@
* questions.
*/
-package sun.text.resources;
-
-import java.util.spi.ResourceBundleProvider;
-
/**
- * An interface for the internal locale data provider for which {@code ResourceBundle}
- * searches.
+ * JDK-8077149: __noSuchProperty__ and __noSuchMethod__ invocations are not properly guarded
+ *
+ * @test
+ * @run
*/
-public interface BreakIteratorRulesProvider extends ResourceBundleProvider {
+
+var o = {};
+
+function invoke() {
+ return o._();
}
+
+Object.prototype.__noSuchProperty__ = function() {
+ return function() { return "no such property" };
+};
+
+Assert.assertEquals(invoke(), "no such property");
+
+Object.prototype.__noSuchMethod__ = function() {
+ return "no such method";
+};
+
+Assert.assertEquals(invoke(), "no such method");
+
+Object.prototype._ = function() {
+ return "underscore method";
+};
+
+Assert.assertEquals(invoke(), "underscore method");