allServices = new HashSet<>(Arrays.asList(expectedAllServices));
if (!allServices.equals(xml.getDescriptor().uses()))
@@ -46,7 +44,7 @@ public class Main {
+ xml.getDescriptor().uses());
long violationCount = Stream.of(args)
- .map(xmlProviderName -> Layer.boot().findModule(xmlProviderName).get())
+ .map(xmlProviderName -> ModuleLayer.boot().findModule(xmlProviderName).get())
.mapToLong(
// services provided by the implementation in provider module
provider -> provider.getDescriptor().provides().stream()
diff --git a/jaxws/.hgtags b/jaxws/.hgtags
index 28e7cfd0e75..5c41c8f221d 100644
--- a/jaxws/.hgtags
+++ b/jaxws/.hgtags
@@ -411,3 +411,4 @@ e53b322357382209fb553b9a1541ccfd12cbcb6c jdk-9+158
b8aebe5292f23689f97cb8e66a9f327834dd43e6 jdk-9+162
3890f96e8995be8c84f330d1f65269b03ac36b24 jdk-9+163
1a52de2da827459e866fd736f9e9c62eb2ecd6bb jdk-9+164
+a987401bac0d528475e57732c9d5d93f4405804c jdk-9+165
diff --git a/jaxws/src/java.xml.ws/share/classes/com/sun/xml/internal/ws/addressing/EPRSDDocumentFilter.java b/jaxws/src/java.xml.ws/share/classes/com/sun/xml/internal/ws/addressing/EPRSDDocumentFilter.java
index e1f39b91ea9..6321da30dcb 100644
--- a/jaxws/src/java.xml.ws/share/classes/com/sun/xml/internal/ws/addressing/EPRSDDocumentFilter.java
+++ b/jaxws/src/java.xml.ws/share/classes/com/sun/xml/internal/ws/addressing/EPRSDDocumentFilter.java
@@ -26,6 +26,7 @@
package com.sun.xml.internal.ws.addressing;
import com.sun.xml.internal.ws.api.server.*;
+import com.sun.xml.internal.ws.api.server.Module;
import com.sun.xml.internal.ws.api.addressing.WSEndpointReference;
import com.sun.xml.internal.ws.api.addressing.AddressingVersion;
import com.sun.xml.internal.ws.api.streaming.XMLStreamReaderFactory;
diff --git a/jaxws/src/java.xml.ws/share/classes/com/sun/xml/internal/ws/api/server/SDDocumentSource.java b/jaxws/src/java.xml.ws/share/classes/com/sun/xml/internal/ws/api/server/SDDocumentSource.java
index 59a18fe7992..3ba900a13da 100644
--- a/jaxws/src/java.xml.ws/share/classes/com/sun/xml/internal/ws/api/server/SDDocumentSource.java
+++ b/jaxws/src/java.xml.ws/share/classes/com/sun/xml/internal/ws/api/server/SDDocumentSource.java
@@ -155,12 +155,10 @@ public abstract class SDDocumentSource {
}
private InputStream inputStream() throws IOException {
- java.lang.reflect.Module module = resolvingClass.getModule();
- if (module != null) {
- InputStream stream = module.getResourceAsStream(path);
- if (stream != null) {
- return stream;
- }
+ java.lang.Module module = resolvingClass.getModule();
+ InputStream stream = module.getResourceAsStream(path);
+ if (stream != null) {
+ return stream;
}
throw new ServerRtException("cannot.load.wsdl", path);
}
diff --git a/jaxws/src/java.xml.ws/share/classes/com/sun/xml/internal/ws/util/HandlerAnnotationProcessor.java b/jaxws/src/java.xml.ws/share/classes/com/sun/xml/internal/ws/util/HandlerAnnotationProcessor.java
index 42385239f3f..53d37f3dee8 100644
--- a/jaxws/src/java.xml.ws/share/classes/com/sun/xml/internal/ws/util/HandlerAnnotationProcessor.java
+++ b/jaxws/src/java.xml.ws/share/classes/com/sun/xml/internal/ws/util/HandlerAnnotationProcessor.java
@@ -234,17 +234,15 @@ public class HandlerAnnotationProcessor {
}
private static InputStream moduleResource(Class resolvingClass, String name) {
- java.lang.reflect.Module module = resolvingClass.getModule();
- if (module != null) {
- try {
- InputStream stream = module.getResourceAsStream(name);
- if (stream != null) {
- return stream;
- }
- } catch(IOException e) {
- throw new UtilException("util.failed.to.find.handlerchain.file",
- resolvingClass.getName(), name);
+ Module module = resolvingClass.getModule();
+ try {
+ InputStream stream = module.getResourceAsStream(name);
+ if (stream != null) {
+ return stream;
}
+ } catch(IOException e) {
+ throw new UtilException("util.failed.to.find.handlerchain.file",
+ resolvingClass.getName(), name);
}
return null;
}
diff --git a/jaxws/src/jdk.xml.bind/share/legal/relaxngdatatype.md b/jaxws/src/jdk.xml.bind/share/legal/relaxngdatatype.md
index 54343b7483d..2555613c67c 100644
--- a/jaxws/src/jdk.xml.bind/share/legal/relaxngdatatype.md
+++ b/jaxws/src/jdk.xml.bind/share/legal/relaxngdatatype.md
@@ -3,7 +3,7 @@
### RelaxNG Datatype License
-Copyright (c) 2001, Thai Open Source Software Center Ltd, Sun Microsystems.
+Copyright (c) 2005, 2010 Thai Open Source Software Center Ltd
All rights reserved.
Redistribution and use in source and binary forms, with or without
diff --git a/jdk/.hgtags b/jdk/.hgtags
index 6258e69f4f7..1991f548496 100644
--- a/jdk/.hgtags
+++ b/jdk/.hgtags
@@ -408,3 +408,4 @@ cac788454598b95d8b0153c021a7fae3cd7e6fda jdk-9+160
f6bf027e88e9a4dd19f721001a7af00157af42c4 jdk-9+162
50171f8c47961710cbf87aead6f03fa431d8d240 jdk-9+163
6dea581453d7c0e767e3169cfec8b423a381e71d jdk-9+164
+a7942c3b1e59495dbf51dc7c41aab355fcd253d7 jdk-9+165
diff --git a/jdk/make/data/tzdata/VERSION b/jdk/make/data/tzdata/VERSION
index afe013e29f4..eb5b4595f3e 100644
--- a/jdk/make/data/tzdata/VERSION
+++ b/jdk/make/data/tzdata/VERSION
@@ -21,4 +21,4 @@
# or visit www.oracle.com if you need additional information or have any
# questions.
#
-tzdata2017a
+tzdata2017b
diff --git a/jdk/make/data/tzdata/africa b/jdk/make/data/tzdata/africa
index f2fc2bbcdcf..d3de96d1431 100644
--- a/jdk/make/data/tzdata/africa
+++ b/jdk/make/data/tzdata/africa
@@ -443,18 +443,25 @@ Link Africa/Nairobi Indian/Mayotte
# See Africa/Johannesburg.
# Liberia
-# From Paul Eggert (2006-03-22):
-# In 1972 Liberia was the last country to switch
-# from a UTC offset that was not a multiple of 15 or 20 minutes.
-# Howse reports that it was in honor of their president's birthday.
-# Shank & Pottenger report the date as May 1, whereas Howse reports Jan;
-# go with Shanks & Pottenger.
-# For Liberia before 1972, Shanks & Pottenger report -0:44, whereas Howse and
-# Whitman each report -0:44:30; go with the more precise figure.
+#
+# From Paul Eggert (2017-03-02):
+#
+# The Nautical Almanac for the Year 1970, p 264, is the source for -0:44:30.
+#
+# In 1972 Liberia was the last country to switch from a UTC offset
+# that was not a multiple of 15 or 20 minutes. The 1972 change was on
+# 1972-01-07, according to an entry dated 1972-01-04 on p 330 of:
+# Presidential Papers: First year of the administration of
+# President William R. Tolbert, Jr., July 23, 1971-July 31, 1972.
+# Monrovia: Executive Mansion.
+#
+# Use the abbreviation "MMT" before 1972, as the more-accurate numeric
+# abbreviation "-004430" would be one byte over the POSIX limit.
+#
# Zone NAME GMTOFF RULES FORMAT [UNTIL]
Zone Africa/Monrovia -0:43:08 - LMT 1882
-0:43:08 - MMT 1919 Mar # Monrovia Mean Time
- -0:44:30 - -004430 1972 May
+ -0:44:30 - MMT 1972 Jan 7 # approximately MMT
0:00 - GMT
###############################################################################
diff --git a/jdk/make/data/tzdata/iso3166.tab b/jdk/make/data/tzdata/iso3166.tab
index 004a4a70556..38a3a1ed52b 100644
--- a/jdk/make/data/tzdata/iso3166.tab
+++ b/jdk/make/data/tzdata/iso3166.tab
@@ -32,8 +32,8 @@
# All text uses UTF-8 encoding. The columns of the table are as follows:
#
# 1. ISO 3166-1 alpha-2 country code, current as of
-# ISO 3166-1 Newsletter VI-16 (2013-07-11). See: Updates on ISO 3166
-# http://www.iso.org/iso/home/standards/country_codes/updates_on_iso_3166.htm
+# ISO 3166-1 N905 (2016-11-15). See: Updates on ISO 3166-1
+# http://isotc.iso.org/livelink/livelink/Open/16944257
# 2. The usual English name for the coded region,
# chosen so that alphabetic sorting of subsets produces helpful lists.
# This is not the same as the English name in the ISO 3166 tables.
diff --git a/jdk/make/data/tzdata/northamerica b/jdk/make/data/tzdata/northamerica
index 85a5bb44414..d59d2705b99 100644
--- a/jdk/make/data/tzdata/northamerica
+++ b/jdk/make/data/tzdata/northamerica
@@ -3162,6 +3162,12 @@ Zone America/Guatemala -6:02:04 - LMT 1918 Oct 5
# http://www.vantbefinfo.com/changement-dheure-pas-pour-haiti/
# http://news.anmwe.com/haiti-lheure-nationale-ne-sera-ni-avancee-ni-reculee-cette-annee/
+# From Steffen Thorsen (2017-03-12):
+# We have received 4 mails from different people telling that Haiti
+# has started DST again today, and this source seems to confirm that,
+# I have not been able to find a more authoritative source:
+# https://www.haitilibre.com/en/news-20319-haiti-notices-time-change-in-haiti.html
+
# Rule NAME FROM TO TYPE IN ON AT SAVE LETTER/S
Rule Haiti 1983 only - May 8 0:00 1:00 D
Rule Haiti 1984 1987 - Apr lastSun 0:00 1:00 D
@@ -3174,6 +3180,8 @@ Rule Haiti 2005 2006 - Apr Sun>=1 0:00 1:00 D
Rule Haiti 2005 2006 - Oct lastSun 0:00 0 S
Rule Haiti 2012 2015 - Mar Sun>=8 2:00 1:00 D
Rule Haiti 2012 2015 - Nov Sun>=1 2:00 0 S
+Rule Haiti 2017 max - Mar Sun>=8 2:00 1:00 D
+Rule Haiti 2017 max - Nov Sun>=1 2:00 0 S
# Zone NAME GMTOFF RULES FORMAT [UNTIL]
Zone America/Port-au-Prince -4:49:20 - LMT 1890
-4:49 - PPMT 1917 Jan 24 12:00 # P-a-P MT
diff --git a/jdk/make/mapfiles/libjava/mapfile-vers b/jdk/make/mapfiles/libjava/mapfile-vers
index b7773925154..31395f7ee23 100644
--- a/jdk/make/mapfiles/libjava/mapfile-vers
+++ b/jdk/make/mapfiles/libjava/mapfile-vers
@@ -273,12 +273,12 @@ SUNWprivate_1.1 {
Java_jdk_internal_misc_VM_getRuntimeArguments;
Java_jdk_internal_misc_VM_initialize;
- Java_java_lang_reflect_Module_defineModule0;
- Java_java_lang_reflect_Module_addReads0;
- Java_java_lang_reflect_Module_addExports0;
- Java_java_lang_reflect_Module_addExportsToAll0;
- Java_java_lang_reflect_Module_addExportsToAllUnnamed0;
- Java_java_lang_reflect_Module_addPackage0;
+ Java_java_lang_Module_defineModule0;
+ Java_java_lang_Module_addReads0;
+ Java_java_lang_Module_addExports0;
+ Java_java_lang_Module_addExportsToAll0;
+ Java_java_lang_Module_addExportsToAllUnnamed0;
+ Java_java_lang_Module_addPackage0;
Java_jdk_internal_loader_BootLoader_getSystemPackageLocation;
Java_jdk_internal_loader_BootLoader_getSystemPackageNames;
diff --git a/jdk/src/java.base/macosx/classes/java/net/DefaultInterface.java b/jdk/src/java.base/macosx/classes/java/net/DefaultInterface.java
index 573de6986f8..b68e3aa0034 100644
--- a/jdk/src/java.base/macosx/classes/java/net/DefaultInterface.java
+++ b/jdk/src/java.base/macosx/classes/java/net/DefaultInterface.java
@@ -50,10 +50,11 @@ class DefaultInterface {
}
/**
- * Choose a default interface. This method returns an interface that is
- * both "up" and supports multicast. This method choses an interface in
+ * Choose a default interface. This method returns the first interface that
+ * is both "up" and supports multicast. This method chooses an interface in
* order of preference:
* 1. neither loopback nor point to point
+ * ( prefer interfaces with dual IP support )
* 2. point to point
* 3. loopback
*
@@ -66,32 +67,56 @@ class DefaultInterface {
try {
nifs = NetworkInterface.getNetworkInterfaces();
} catch (IOException ignore) {
- // unable to enumate network interfaces
+ // unable to enumerate network interfaces
return null;
}
+ NetworkInterface preferred = null;
NetworkInterface ppp = null;
NetworkInterface loopback = null;
while (nifs.hasMoreElements()) {
NetworkInterface ni = nifs.nextElement();
try {
- if (ni.isUp() && ni.supportsMulticast()) {
- boolean isLoopback = ni.isLoopback();
- boolean isPPP = ni.isPointToPoint();
- if (!isLoopback && !isPPP) {
- // found an interface that is not the loopback or a
- // point-to-point interface
+ if (!ni.isUp() || !ni.supportsMulticast())
+ continue;
+
+ boolean ip4 = false, ip6 = false;
+ Enumeration addrs = ni.getInetAddresses();
+ while (addrs.hasMoreElements()) {
+ InetAddress addr = addrs.nextElement();
+ if (!addr.isAnyLocalAddress()) {
+ if (addr instanceof Inet4Address) {
+ ip4 = true;
+ } else if (addr instanceof Inet6Address) {
+ ip6 = true;
+ }
+ }
+ }
+
+ boolean isLoopback = ni.isLoopback();
+ boolean isPPP = ni.isPointToPoint();
+ if (!isLoopback && !isPPP) {
+ // found an interface that is not the loopback or a
+ // point-to-point interface
+ if (preferred == null) {
+ preferred = ni;
+ } else if (ip4 && ip6){
return ni;
}
- if (ppp == null && isPPP)
- ppp = ni;
- if (loopback == null && isLoopback)
- loopback = ni;
}
+ if (ppp == null && isPPP)
+ ppp = ni;
+ if (loopback == null && isLoopback)
+ loopback = ni;
+
} catch (IOException skip) { }
}
- return (ppp != null) ? ppp : loopback;
+ if (preferred != null) {
+ return preferred;
+ } else {
+ return (ppp != null) ? ppp : loopback;
+ }
}
}
diff --git a/jdk/src/java.base/share/classes/com/sun/crypto/provider/DESKey.java b/jdk/src/java.base/share/classes/com/sun/crypto/provider/DESKey.java
index d4493808167..d3f1c99df2a 100644
--- a/jdk/src/java.base/share/classes/com/sun/crypto/provider/DESKey.java
+++ b/jdk/src/java.base/share/classes/com/sun/crypto/provider/DESKey.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2017, 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
@@ -149,6 +149,7 @@ final class DESKey implements SecretKey {
* Ensures that the bytes of this key are
* set to zero when there are no more references to it.
*/
+ @SuppressWarnings("deprecation")
protected void finalize() throws Throwable {
try {
if (this.key != null) {
diff --git a/jdk/src/java.base/share/classes/com/sun/crypto/provider/DESedeKey.java b/jdk/src/java.base/share/classes/com/sun/crypto/provider/DESedeKey.java
index a0de5dc059c..9695ba39e6f 100644
--- a/jdk/src/java.base/share/classes/com/sun/crypto/provider/DESedeKey.java
+++ b/jdk/src/java.base/share/classes/com/sun/crypto/provider/DESedeKey.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2017, 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
@@ -150,6 +150,7 @@ final class DESedeKey implements SecretKey {
* Ensures that the bytes of this key are
* set to zero when there are no more references to it.
*/
+ @SuppressWarnings("deprecation")
protected void finalize() throws Throwable {
try {
if (this.key != null) {
diff --git a/jdk/src/java.base/share/classes/com/sun/crypto/provider/PBEKey.java b/jdk/src/java.base/share/classes/com/sun/crypto/provider/PBEKey.java
index 3331f787429..72e7452ace0 100644
--- a/jdk/src/java.base/share/classes/com/sun/crypto/provider/PBEKey.java
+++ b/jdk/src/java.base/share/classes/com/sun/crypto/provider/PBEKey.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2017, 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
@@ -145,6 +145,7 @@ final class PBEKey implements SecretKey {
* Ensures that the password bytes of this key are
* set to zero when there are no more references to it.
*/
+ @SuppressWarnings("deprecation")
protected void finalize() throws Throwable {
try {
if (this.key != null) {
diff --git a/jdk/src/java.base/share/classes/com/sun/crypto/provider/PBKDF2KeyImpl.java b/jdk/src/java.base/share/classes/com/sun/crypto/provider/PBKDF2KeyImpl.java
index 9d82ebb6ff2..1bf51566165 100644
--- a/jdk/src/java.base/share/classes/com/sun/crypto/provider/PBKDF2KeyImpl.java
+++ b/jdk/src/java.base/share/classes/com/sun/crypto/provider/PBKDF2KeyImpl.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2005, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2017, 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
@@ -267,6 +267,7 @@ final class PBKDF2KeyImpl implements javax.crypto.interfaces.PBEKey {
* Ensures that the password bytes of this key are
* erased when there are no more references to it.
*/
+ @SuppressWarnings("deprecation")
protected void finalize() throws Throwable {
try {
if (this.passwd != null) {
diff --git a/jdk/src/java.base/share/classes/java/io/BufferedReader.java b/jdk/src/java.base/share/classes/java/io/BufferedReader.java
index 1f6a66490cd..8cb4f73e597 100644
--- a/jdk/src/java.base/share/classes/java/io/BufferedReader.java
+++ b/jdk/src/java.base/share/classes/java/io/BufferedReader.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1996, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1996, 2017, 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
@@ -297,14 +297,15 @@ public class BufferedReader extends Reader {
/**
* Reads a line of text. A line is considered to be terminated by any one
- * of a line feed ('\n'), a carriage return ('\r'), or a carriage return
- * followed immediately by a linefeed.
+ * of a line feed ('\n'), a carriage return ('\r'), a carriage return
+ * followed immediately by a line feed, or by reaching the end-of-file
+ * (EOF).
*
* @param ignoreLF If true, the next '\n' will be skipped
*
* @return A String containing the contents of the line, not including
* any line-termination characters, or null if the end of the
- * stream has been reached
+ * stream has been reached without reading any characters
*
* @see java.io.LineNumberReader#readLine()
*
@@ -375,12 +376,13 @@ public class BufferedReader extends Reader {
/**
* Reads a line of text. A line is considered to be terminated by any one
- * of a line feed ('\n'), a carriage return ('\r'), or a carriage return
- * followed immediately by a linefeed.
+ * of a line feed ('\n'), a carriage return ('\r'), a carriage return
+ * followed immediately by a line feed, or by reaching the end-of-file
+ * (EOF).
*
* @return A String containing the contents of the line, not including
* any line-termination characters, or null if the end of the
- * stream has been reached
+ * stream has been reached without reading any characters
*
* @exception IOException If an I/O error occurs
*
diff --git a/jdk/src/java.base/share/classes/java/io/FileInputStream.java b/jdk/src/java.base/share/classes/java/io/FileInputStream.java
index a321c61ae41..0d8401128ff 100644
--- a/jdk/src/java.base/share/classes/java/io/FileInputStream.java
+++ b/jdk/src/java.base/share/classes/java/io/FileInputStream.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1994, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1994, 2017, 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
@@ -413,9 +413,19 @@ class FileInputStream extends InputStream
* Ensures that the close method of this file input stream is
* called when there are no more references to it.
*
+ * @deprecated The {@code finalize} method has been deprecated.
+ * Subclasses that override {@code finalize} in order to perform cleanup
+ * should be modified to use alternative cleanup mechanisms and
+ * to remove the overriding {@code finalize} method.
+ * When overriding the {@code finalize} method, its implementation must explicitly
+ * ensure that {@code super.finalize()} is invoked as described in {@link Object#finalize}.
+ * See the specification for {@link Object#finalize()} for further
+ * information about migration options.
+ *
* @exception IOException if an I/O error occurs.
* @see java.io.FileInputStream#close()
*/
+ @Deprecated(since="9")
protected void finalize() throws IOException {
if ((fd != null) && (fd != FileDescriptor.in)) {
/* if fd is shared, the references in FileDescriptor
diff --git a/jdk/src/java.base/share/classes/java/io/FileOutputStream.java b/jdk/src/java.base/share/classes/java/io/FileOutputStream.java
index f6bdb1f3b5f..634ca1ed481 100644
--- a/jdk/src/java.base/share/classes/java/io/FileOutputStream.java
+++ b/jdk/src/java.base/share/classes/java/io/FileOutputStream.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1994, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1994, 2017, 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
@@ -427,9 +427,18 @@ class FileOutputStream extends OutputStream
* close method of this file output stream is
* called when there are no more references to this stream.
*
+ * @deprecated The {@code finalize} method has been deprecated.
+ * Subclasses that override {@code finalize} in order to perform cleanup
+ * should be modified to use alternative cleanup mechanisms and
+ * to remove the overriding {@code finalize} method.
+ * When overriding the {@code finalize} method, its implementation must explicitly
+ * ensure that {@code super.finalize()} is invoked as described in {@link Object#finalize}.
+ * See the specification for {@link Object#finalize()} for further
+ * information about migration options.
* @exception IOException if an I/O error occurs.
* @see java.io.FileInputStream#close()
*/
+ @Deprecated(since="9")
protected void finalize() throws IOException {
if (fd != null) {
if (fd == FileDescriptor.out || fd == FileDescriptor.err) {
diff --git a/jdk/src/java.base/share/classes/java/io/ObjectInputFilter.java b/jdk/src/java.base/share/classes/java/io/ObjectInputFilter.java
index f9bbf1178ec..534e1b2b8de 100644
--- a/jdk/src/java.base/share/classes/java/io/ObjectInputFilter.java
+++ b/jdk/src/java.base/share/classes/java/io/ObjectInputFilter.java
@@ -322,7 +322,7 @@ public interface ObjectInputFilter {
* Other patterns match or reject class or package name
* as returned from {@link Class#getName() Class.getName()} and
* if an optional module name is present
- * {@link java.lang.reflect.Module#getName() class.getModule().getName()}.
+ * {@link Module#getName() class.getModule().getName()}.
* Note that for arrays the element type is used in the pattern,
* not the array type.
*
diff --git a/jdk/src/java.base/share/classes/java/lang/Class.java b/jdk/src/java.base/share/classes/java/lang/Class.java
index 14026931c97..733c76a2a2c 100644
--- a/jdk/src/java.base/share/classes/java/lang/Class.java
+++ b/jdk/src/java.base/share/classes/java/lang/Class.java
@@ -43,7 +43,6 @@ import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Member;
import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
-import java.lang.reflect.Module;
import java.lang.reflect.Proxy;
import java.lang.reflect.Type;
import java.lang.reflect.TypeVariable;
@@ -2561,21 +2560,16 @@ public final class Class implements java.io.Serializable,
public InputStream getResourceAsStream(String name) {
name = resolveName(name);
- Module module = getModule();
- if (module.isNamed()) {
- if (Resources.canEncapsulate(name)) {
- Module caller = Reflection.getCallerClass().getModule();
- if (caller != module) {
- Set packages = module.getDescriptor().packages();
- String pn = Resources.toPackageName(name);
- if (packages.contains(pn) && !module.isOpen(pn, caller)) {
- // resource is in package not open to caller
- return null;
- }
- }
+ Module thisModule = getModule();
+ if (thisModule.isNamed()) {
+ // check if resource can be located by caller
+ if (Resources.canEncapsulate(name)
+ && !isOpenToCaller(name, Reflection.getCallerClass())) {
+ return null;
}
- String mn = module.getName();
+ // resource not encapsulated or in package open to caller
+ String mn = thisModule.getName();
ClassLoader cl = getClassLoader0();
try {
@@ -2663,20 +2657,16 @@ public final class Class implements java.io.Serializable,
public URL getResource(String name) {
name = resolveName(name);
- Module module = getModule();
- if (module.isNamed()) {
- if (Resources.canEncapsulate(name)) {
- Module caller = Reflection.getCallerClass().getModule();
- if (caller != module) {
- Set packages = module.getDescriptor().packages();
- String pn = Resources.toPackageName(name);
- if (packages.contains(pn) && !module.isOpen(pn, caller)) {
- // resource is in package not open to caller
- return null;
- }
- }
+ Module thisModule = getModule();
+ if (thisModule.isNamed()) {
+ // check if resource can be located by caller
+ if (Resources.canEncapsulate(name)
+ && !isOpenToCaller(name, Reflection.getCallerClass())) {
+ return null;
}
- String mn = getModule().getName();
+
+ // resource not encapsulated or in package open to caller
+ String mn = thisModule.getName();
ClassLoader cl = getClassLoader0();
try {
if (cl == null) {
@@ -2698,10 +2688,36 @@ public final class Class implements java.io.Serializable,
}
}
+ /**
+ * Returns true if a resource with the given name can be located by the
+ * given caller. All resources in a module can be located by code in
+ * the module. For other callers, then the package needs to be open to
+ * the caller.
+ */
+ private boolean isOpenToCaller(String name, Class> caller) {
+ // assert getModule().isNamed();
+ Module thisModule = getModule();
+ Module callerModule = (caller != null) ? caller.getModule() : null;
+ if (callerModule != thisModule) {
+ String pn = Resources.toPackageName(name);
+ if (thisModule.getDescriptor().packages().contains(pn)) {
+ if (callerModule == null && !thisModule.isOpen(pn)) {
+ // no caller, package not open
+ return false;
+ }
+ if (!thisModule.isOpen(pn, callerModule)) {
+ // package not open to caller
+ return false;
+ }
+ }
+ }
+ return true;
+ }
+
+
/** protection domain returned when the internal domain is null */
private static java.security.ProtectionDomain allPermDomain;
-
/**
* Returns the {@code ProtectionDomain} of this class. If there is a
* security manager installed, this method first calls the security
diff --git a/jdk/src/java.base/share/classes/java/lang/ClassLoader.java b/jdk/src/java.base/share/classes/java/lang/ClassLoader.java
index a6817746cdc..ddce2879e2e 100644
--- a/jdk/src/java.base/share/classes/java/lang/ClassLoader.java
+++ b/jdk/src/java.base/share/classes/java/lang/ClassLoader.java
@@ -31,7 +31,6 @@ import java.io.UncheckedIOException;
import java.io.File;
import java.lang.reflect.Constructor;
import java.lang.reflect.Field;
-import java.lang.reflect.Module;
import java.net.URL;
import java.security.AccessController;
import java.security.AccessControlContext;
@@ -352,9 +351,7 @@ public abstract class ClassLoader {
private ClassLoader(Void unused, String name, ClassLoader parent) {
this.name = name;
this.parent = parent;
- this.unnamedModule
- = SharedSecrets.getJavaLangReflectModuleAccess()
- .defineUnnamedModule(this);
+ this.unnamedModule = new Module(this);
if (ParallelLoaders.isRegistered(this.getClass())) {
parallelLockMap = new ConcurrentHashMap<>();
package2certs = new ConcurrentHashMap<>();
@@ -2348,6 +2345,7 @@ public abstract class ClassLoader {
this.isBuiltin = isBuiltin;
}
+ @SuppressWarnings("deprecation")
protected void finalize() {
synchronized (loadedLibraryNames) {
if (fromClass.getClassLoader() != null && loaded) {
diff --git a/jdk/src/java.base/share/classes/java/lang/Comparable.java b/jdk/src/java.base/share/classes/java/lang/Comparable.java
index ff8892caacf..b1c27f1911d 100644
--- a/jdk/src/java.base/share/classes/java/lang/Comparable.java
+++ b/jdk/src/java.base/share/classes/java/lang/Comparable.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2017, 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
@@ -124,7 +124,7 @@ public interface Comparable {
* {@code sgn(}expression {@code )} designates the mathematical
* signum function, which is defined to return one of {@code -1},
* {@code 0}, or {@code 1} according to whether the value of
- * expression is negative, zero or positive.
+ * expression is negative, zero, or positive, respectively.
*
* @param o the object to be compared.
* @return a negative integer, zero, or a positive integer as this object
diff --git a/jdk/src/java.base/share/classes/java/lang/Enum.java b/jdk/src/java.base/share/classes/java/lang/Enum.java
index 9a98f30bbbd..ac912f5ca65 100644
--- a/jdk/src/java.base/share/classes/java/lang/Enum.java
+++ b/jdk/src/java.base/share/classes/java/lang/Enum.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2003, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2017, 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
@@ -243,6 +243,7 @@ public abstract class Enum>
/**
* enum classes cannot have finalize methods.
*/
+ @SuppressWarnings("deprecation")
protected final void finalize() { }
/**
diff --git a/jdk/src/java.base/share/classes/java/lang/reflect/LayerInstantiationException.java b/jdk/src/java.base/share/classes/java/lang/LayerInstantiationException.java
similarity index 93%
rename from jdk/src/java.base/share/classes/java/lang/reflect/LayerInstantiationException.java
rename to jdk/src/java.base/share/classes/java/lang/LayerInstantiationException.java
index fbd0de0ac85..4c64fe071a8 100644
--- a/jdk/src/java.base/share/classes/java/lang/reflect/LayerInstantiationException.java
+++ b/jdk/src/java.base/share/classes/java/lang/LayerInstantiationException.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -23,13 +23,12 @@
* questions.
*/
-package java.lang.reflect;
+package java.lang;
/**
- * Thrown when creating a Layer fails.
- *
- * @see Layer
+ * Thrown when creating a {@linkplain ModuleLayer module layer} fails.
*
+ * @see ModuleLayer
* @since 9
* @spec JPMS
*/
diff --git a/jdk/src/java.base/share/classes/java/lang/reflect/Module.java b/jdk/src/java.base/share/classes/java/lang/Module.java
similarity index 89%
rename from jdk/src/java.base/share/classes/java/lang/reflect/Module.java
rename to jdk/src/java.base/share/classes/java/lang/Module.java
index 23fddfaa557..26337d86beb 100644
--- a/jdk/src/java.base/share/classes/java/lang/reflect/Module.java
+++ b/jdk/src/java.base/share/classes/java/lang/Module.java
@@ -23,7 +23,7 @@
* questions.
*/
-package java.lang.reflect;
+package java.lang;
import java.io.IOException;
import java.io.InputStream;
@@ -35,6 +35,7 @@ import java.lang.module.ModuleDescriptor.Exports;
import java.lang.module.ModuleDescriptor.Opens;
import java.lang.module.ModuleDescriptor.Version;
import java.lang.module.ResolvedModule;
+import java.lang.reflect.AnnotatedElement;
import java.net.URI;
import java.net.URL;
import java.security.AccessController;
@@ -49,12 +50,12 @@ import java.util.Optional;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
import java.util.function.Function;
+import java.util.stream.Collectors;
import java.util.stream.Stream;
import jdk.internal.loader.BuiltinClassLoader;
import jdk.internal.loader.BootLoader;
import jdk.internal.misc.JavaLangAccess;
-import jdk.internal.misc.JavaLangReflectModuleAccess;
import jdk.internal.misc.SharedSecrets;
import jdk.internal.module.ServicesCatalog;
import jdk.internal.module.Resources;
@@ -73,7 +74,7 @@ import sun.security.util.SecurityConstants;
*
* Named modules have a {@link #getName() name} and are constructed by the
* Java Virtual Machine when a graph of modules is defined to the Java virtual
- * machine to create a module {@link Layer Layer}.
+ * machine to create a {@linkplain ModuleLayer module layer}.
*
* An unnamed module does not have a name. There is an unnamed module for
* each {@link ClassLoader ClassLoader}, obtained by invoking its {@link
@@ -92,13 +93,13 @@ import sun.security.util.SecurityConstants;
*
* @since 9
* @spec JPMS
- * @see java.lang.Class#getModule
+ * @see Class#getModule()
*/
public final class Module implements AnnotatedElement {
// the layer that contains this module, can be null
- private final Layer layer;
+ private final ModuleLayer layer;
// module name and loader, these fields are read by VM
private final String name;
@@ -113,10 +114,10 @@ public final class Module implements AnnotatedElement {
* VM but will not read any other modules, will not have any exports setup
* and will not be registered in the service catalog.
*/
- private Module(Layer layer,
- ClassLoader loader,
- ModuleDescriptor descriptor,
- URI uri)
+ Module(ModuleLayer layer,
+ ClassLoader loader,
+ ModuleDescriptor descriptor,
+ URI uri)
{
this.layer = layer;
this.name = descriptor.name();
@@ -139,7 +140,7 @@ public final class Module implements AnnotatedElement {
*
* @see ClassLoader#getUnnamedModule
*/
- private Module(ClassLoader loader) {
+ Module(ClassLoader loader) {
this.layer = null;
this.name = null;
this.loader = loader;
@@ -217,29 +218,28 @@ public final class Module implements AnnotatedElement {
* Returns the layer that contains this module or {@code null} if this
* module is not in a layer.
*
- * A module {@code Layer} contains named modules and therefore this
- * method always returns {@code null} when invoked on an unnamed module.
+ * A module layer contains named modules and therefore this method always
+ * returns {@code null} when invoked on an unnamed module.
*
- *
Dynamic modules are named
- * modules that are generated at runtime. A dynamic module may or may
- * not be in a module Layer.
+ * Dynamic modules are
+ * named modules that are generated at runtime. A dynamic module may or may
+ * not be in a module layer.
*
- * @return The layer that contains this module
+ * @return The module layer that contains this module
*
- * @see Proxy
+ * @see java.lang.reflect.Proxy
*/
- public Layer getLayer() {
+ public ModuleLayer getLayer() {
if (isNamed()) {
- Layer layer = this.layer;
+ ModuleLayer layer = this.layer;
if (layer != null)
return layer;
- // special-case java.base as it is created before the boot Layer
+ // special-case java.base as it is created before the boot layer
if (loader == null && name.equals("java.base")) {
- return SharedSecrets.getJavaLangAccess().getBootLayer();
+ return ModuleLayer.boot();
}
}
-
return null;
}
@@ -338,7 +338,7 @@ public final class Module implements AnnotatedElement {
public Module addReads(Module other) {
Objects.requireNonNull(other);
if (this.isNamed()) {
- Module caller = Reflection.getCallerClass().getModule();
+ Module caller = getCallerModule(Reflection.getCallerClass());
if (caller != this) {
throw new IllegalCallerException(caller + " != " + this);
}
@@ -350,12 +350,21 @@ public final class Module implements AnnotatedElement {
/**
* Updates this module to read another module.
*
- * @apiNote This method is for Proxy use and white-box testing.
+ * @apiNote Used by the --add-reads command line option.
*/
void implAddReads(Module other) {
implAddReads(other, true);
}
+ /**
+ * Updates this module to read all unnamed modules.
+ *
+ * @apiNote Used by the --add-reads command line option.
+ */
+ void implAddReadsAllUnnamed() {
+ implAddReads(Module.ALL_UNNAMED_MODULE, true);
+ }
+
/**
* Updates this module to read another module without notifying the VM.
*
@@ -371,6 +380,7 @@ public final class Module implements AnnotatedElement {
* If {@code syncVM} is {@code true} then the VM is notified.
*/
private void implAddReads(Module other, boolean syncVM) {
+ Objects.requireNonNull(other);
if (!canRead(other)) {
// update VM first, just in case it fails
if (syncVM) {
@@ -659,7 +669,7 @@ public final class Module implements AnnotatedElement {
Objects.requireNonNull(other);
if (isNamed()) {
- Module caller = Reflection.getCallerClass().getModule();
+ Module caller = getCallerModule(Reflection.getCallerClass());
if (caller != this) {
throw new IllegalCallerException(caller + " != " + this);
}
@@ -706,8 +716,8 @@ public final class Module implements AnnotatedElement {
Objects.requireNonNull(other);
if (isNamed()) {
- Module caller = Reflection.getCallerClass().getModule();
- if (caller != this && !isOpen(pn, caller))
+ Module caller = getCallerModule(Reflection.getCallerClass());
+ if (caller != this && (caller == null || !isOpen(pn, caller)))
throw new IllegalCallerException(pn + " is not open to " + caller);
implAddExportsOrOpens(pn, other, /*open*/true, /*syncVM*/true);
}
@@ -717,36 +727,80 @@ public final class Module implements AnnotatedElement {
/**
- * Updates the exports so that package {@code pn} is exported to module
- * {@code other} but without notifying the VM.
+ * Updates this module to export a package unconditionally.
*
- * @apiNote This method is for VM white-box testing.
+ * @apiNote This method is for JDK tests only.
*/
- void implAddExportsNoSync(String pn, Module other) {
- if (other == null)
- other = EVERYONE_MODULE;
- implAddExportsOrOpens(pn.replace('/', '.'), other, false, false);
+ void implAddExports(String pn) {
+ implAddExportsOrOpens(pn, Module.EVERYONE_MODULE, false, true);
}
/**
- * Updates the exports so that package {@code pn} is exported to module
- * {@code other}.
+ * Updates this module to export a package to another module.
*
- * @apiNote This method is for white-box testing.
+ * @apiNote Used by Instrumentation::redefineModule and --add-exports
*/
void implAddExports(String pn, Module other) {
implAddExportsOrOpens(pn, other, false, true);
}
/**
- * Updates the module to open package {@code pn} to module {@code other}.
+ * Updates this module to export a package to all unnamed modules.
*
- * @apiNote This method is for white-box tests and jtreg
+ * @apiNote Used by the --add-exports command line option.
+ */
+ void implAddExportsToAllUnnamed(String pn) {
+ implAddExportsOrOpens(pn, Module.ALL_UNNAMED_MODULE, false, true);
+ }
+
+ /**
+ * Updates this export to export a package unconditionally without
+ * notifying the VM.
+ *
+ * @apiNote This method is for VM white-box testing.
+ */
+ void implAddExportsNoSync(String pn) {
+ implAddExportsOrOpens(pn.replace('/', '.'), Module.EVERYONE_MODULE, false, false);
+ }
+
+ /**
+ * Updates a module to export a package to another module without
+ * notifying the VM.
+ *
+ * @apiNote This method is for VM white-box testing.
+ */
+ void implAddExportsNoSync(String pn, Module other) {
+ implAddExportsOrOpens(pn.replace('/', '.'), other, false, false);
+ }
+
+ /**
+ * Updates this module to open a package unconditionally.
+ *
+ * @apiNote This method is for JDK tests only.
+ */
+ void implAddOpens(String pn) {
+ implAddExportsOrOpens(pn, Module.EVERYONE_MODULE, true, true);
+ }
+
+ /**
+ * Updates this module to open a package to another module.
+ *
+ * @apiNote Used by Instrumentation::redefineModule and --add-opens
*/
void implAddOpens(String pn, Module other) {
implAddExportsOrOpens(pn, other, true, true);
}
+ /**
+ * Updates this module to export a package to all unnamed modules.
+ *
+ * @apiNote Used by the --add-opens command line option.
+ */
+ void implAddOpensToAllUnnamed(String pn) {
+ implAddExportsOrOpens(pn, Module.ALL_UNNAMED_MODULE, true, true);
+ }
+
+
/**
* Updates a module to export or open a module to another module.
*
@@ -831,7 +885,7 @@ public final class Module implements AnnotatedElement {
Objects.requireNonNull(service);
if (isNamed() && !descriptor.isAutomatic()) {
- Module caller = Reflection.getCallerClass().getModule();
+ Module caller = getCallerModule(Reflection.getCallerClass());
if (caller != this) {
throw new IllegalCallerException(caller + " != " + this);
}
@@ -899,33 +953,28 @@ public final class Module implements AnnotatedElement {
/**
- * Returns an array of the package names of the packages in this module.
+ * Returns the set of package names for the packages in this module.
*
- * For named modules, the returned array contains an element for each
+ *
For named modules, the returned set contains an element for each
* package in the module.
*
* For unnamed modules, this method is the equivalent to invoking the
* {@link ClassLoader#getDefinedPackages() getDefinedPackages} method of
- * this module's class loader and returning the array of package names.
+ * this module's class loader and returning the set of package names.
*
- * A package name appears at most once in the returned array.
- *
- * @apiNote This method returns an array rather than a {@code Set} for
- * consistency with other {@code java.lang.reflect} types.
- *
- * @return an array of the package names of the packages in this module
+ * @return the set of the package names of the packages in this module
*/
- public String[] getPackages() {
+ public Set getPackages() {
if (isNamed()) {
Set packages = descriptor.packages();
Map extraPackages = this.extraPackages;
if (extraPackages == null) {
- return packages.toArray(new String[0]);
+ return packages;
} else {
return Stream.concat(packages.stream(),
extraPackages.keySet().stream())
- .toArray(String[]::new);
+ .collect(Collectors.toSet());
}
} else {
@@ -936,7 +985,7 @@ public final class Module implements AnnotatedElement {
} else {
packages = SharedSecrets.getJavaLangAccess().packages(loader);
}
- return packages.map(Package::getName).toArray(String[]::new);
+ return packages.map(Package::getName).collect(Collectors.toSet());
}
}
@@ -1013,12 +1062,12 @@ public final class Module implements AnnotatedElement {
*/
static Map defineModules(Configuration cf,
Function clf,
- Layer layer)
+ ModuleLayer layer)
{
Map nameToModule = new HashMap<>();
Map moduleToLoader = new HashMap<>();
- boolean isBootLayer = (Layer.boot() == null);
+ boolean isBootLayer = (ModuleLayer.boot() == null);
Set loaders = new HashSet<>();
// map each module to a class loader
@@ -1074,7 +1123,7 @@ public final class Module implements AnnotatedElement {
assert m2 != null;
} else {
// parent layer
- for (Layer parent: layer.parents()) {
+ for (ModuleLayer parent: layer.parents()) {
m2 = findModule(parent, other);
if (m2 != null)
break;
@@ -1133,7 +1182,8 @@ public final class Module implements AnnotatedElement {
* Find the runtime Module corresponding to the given ResolvedModule
* in the given parent layer (or its parents).
*/
- private static Module findModule(Layer parent, ResolvedModule resolvedModule) {
+ private static Module findModule(ModuleLayer parent,
+ ResolvedModule resolvedModule) {
Configuration cf = resolvedModule.configuration();
String dn = resolvedModule.name();
return parent.layers()
@@ -1156,7 +1206,7 @@ public final class Module implements AnnotatedElement {
private static void initExportsAndOpens(Module m,
Map nameToSource,
Map nameToModule,
- List parents) {
+ List parents) {
// The VM doesn't special case open or automatic modules so need to
// export all packages
ModuleDescriptor descriptor = m.getDescriptor();
@@ -1246,12 +1296,12 @@ public final class Module implements AnnotatedElement {
private static Module findModule(String target,
Map nameToSource,
Map nameToModule,
- List parents) {
+ List parents) {
Module m = nameToSource.get(target);
if (m == null) {
m = nameToModule.get(target);
if (m == null) {
- for (Layer parent : parents) {
+ for (ModuleLayer parent : parents) {
m = parent.findModule(target).orElse(null);
if (m != null) break;
}
@@ -1445,14 +1495,18 @@ public final class Module implements AnnotatedElement {
}
if (isNamed() && Resources.canEncapsulate(name)) {
- Module caller = Reflection.getCallerClass().getModule();
+ Module caller = getCallerModule(Reflection.getCallerClass());
if (caller != this && caller != Object.class.getModule()) {
- // ignore packages added for proxies via addPackage
- Set packages = getDescriptor().packages();
String pn = Resources.toPackageName(name);
- if (packages.contains(pn) && !isOpen(pn, caller)) {
- // resource is in package not open to caller
- return null;
+ if (getPackages().contains(pn)) {
+ if (caller == null && !isOpen(pn)) {
+ // no caller, package not open
+ return null;
+ }
+ if (!isOpen(pn, caller)) {
+ // package not open to caller
+ return null;
+ }
}
}
}
@@ -1497,6 +1551,14 @@ public final class Module implements AnnotatedElement {
}
}
+ /**
+ * Returns the module that a given caller class is a member of. Returns
+ * {@code null} if the caller is {@code null}.
+ */
+ private Module getCallerModule(Class> caller) {
+ return (caller != null) ? caller.getModule() : null;
+ }
+
// -- native methods --
@@ -1521,71 +1583,4 @@ public final class Module implements AnnotatedElement {
// JVM_AddModulePackage
private static native void addPackage0(Module m, String pn);
-
- /**
- * Register shared secret to provide access to package-private methods
- */
- static {
- SharedSecrets.setJavaLangReflectModuleAccess(
- new JavaLangReflectModuleAccess() {
- @Override
- public Module defineUnnamedModule(ClassLoader loader) {
- return new Module(loader);
- }
- @Override
- public Module defineModule(ClassLoader loader,
- ModuleDescriptor descriptor,
- URI uri) {
- return new Module(null, loader, descriptor, uri);
- }
- @Override
- public void addReads(Module m1, Module m2) {
- m1.implAddReads(m2, true);
- }
- @Override
- public void addReadsAllUnnamed(Module m) {
- m.implAddReads(Module.ALL_UNNAMED_MODULE);
- }
- @Override
- public void addExports(Module m, String pn) {
- m.implAddExportsOrOpens(pn, Module.EVERYONE_MODULE, false, true);
- }
- @Override
- public void addExports(Module m, String pn, Module other) {
- m.implAddExportsOrOpens(pn, other, false, true);
- }
- @Override
- public void addExportsToAllUnnamed(Module m, String pn) {
- m.implAddExportsOrOpens(pn, Module.ALL_UNNAMED_MODULE, false, true);
- }
- @Override
- public void addOpens(Module m, String pn) {
- m.implAddExportsOrOpens(pn, Module.EVERYONE_MODULE, true, true);
- }
- @Override
- public void addOpens(Module m, String pn, Module other) {
- m.implAddExportsOrOpens(pn, other, true, true);
- }
- @Override
- public void addOpensToAllUnnamed(Module m, String pn) {
- m.implAddExportsOrOpens(pn, Module.ALL_UNNAMED_MODULE, true, true);
- }
- @Override
- public void addUses(Module m, Class> service) {
- m.implAddUses(service);
- }
- @Override
- public ServicesCatalog getServicesCatalog(Layer layer) {
- return layer.getServicesCatalog();
- }
- @Override
- public Stream layers(Layer layer) {
- return layer.layers();
- }
- @Override
- public Stream layers(ClassLoader loader) {
- return Layer.layers(loader);
- }
- });
- }
}
diff --git a/jdk/src/java.base/share/classes/java/lang/reflect/Layer.java b/jdk/src/java.base/share/classes/java/lang/ModuleLayer.java
similarity index 88%
rename from jdk/src/java.base/share/classes/java/lang/reflect/Layer.java
rename to jdk/src/java.base/share/classes/java/lang/ModuleLayer.java
index bd0036d7de3..549662ff9c0 100644
--- a/jdk/src/java.base/share/classes/java/lang/reflect/Layer.java
+++ b/jdk/src/java.base/share/classes/java/lang/ModuleLayer.java
@@ -23,7 +23,7 @@
* questions.
*/
-package java.lang.reflect;
+package java.lang;
import java.lang.module.Configuration;
import java.lang.module.ModuleDescriptor;
@@ -47,8 +47,6 @@ import java.util.stream.Stream;
import jdk.internal.loader.ClassLoaderValue;
import jdk.internal.loader.Loader;
import jdk.internal.loader.LoaderPool;
-import jdk.internal.misc.SharedSecrets;
-import jdk.internal.module.Modules;
import jdk.internal.module.ServicesCatalog;
import sun.security.util.SecurityConstants;
@@ -70,15 +68,16 @@ import sun.security.util.SecurityConstants;
*
* The {@link #defineModulesWithOneLoader defineModulesWithOneLoader} and
* {@link #defineModulesWithManyLoaders defineModulesWithManyLoaders} methods
- * provide convenient ways to create a {@code Layer} where all modules are
+ * provide convenient ways to create a module layer where all modules are
* mapped to a single class loader or where each module is mapped to its own
* class loader. The {@link #defineModules defineModules} method is for more
* advanced cases where modules are mapped to custom class loaders by means of
* a function specified to the method. Each of these methods has an instance
* and static variant. The instance methods create a layer with the receiver
* as the parent layer. The static methods are for more advanced cases where
- * there can be more than one parent layer or where a {@link Layer.Controller
- * Controller} is needed to control modules in the layer.
+ * there can be more than one parent layer or where a {@link
+ * ModuleLayer.Controller Controller} is needed to control modules in the layer
+ *
*
* A Java virtual machine has at least one non-empty layer, the {@link
* #boot() boot} layer, that is created when the Java virtual machine is
@@ -131,13 +130,13 @@ import sun.security.util.SecurityConstants;
*
{@code
* ModuleFinder finder = ModuleFinder.of(dir1, dir2, dir3);
*
- * Layer parent = Layer.boot();
+ * ModuleLayer parent = ModuleLayer.boot();
*
* Configuration cf = parent.configuration().resolve(finder, ModuleFinder.of(), Set.of("myapp"));
*
* ClassLoader scl = ClassLoader.getSystemClassLoader();
*
- * Layer layer = parent.defineModulesWithOneLoader(cf, scl);
+ * ModuleLayer layer = parent.defineModulesWithOneLoader(cf, scl);
*
* Class> c = layer.findLoader("myapp").loadClass("app.Main");
* }
@@ -147,27 +146,27 @@ import sun.security.util.SecurityConstants;
* @see Module#getLayer()
*/
-public final class Layer {
+public final class ModuleLayer {
- // the empty Layer
- private static final Layer EMPTY_LAYER
- = new Layer(Configuration.empty(), List.of(), null);
+ // the empty layer
+ private static final ModuleLayer EMPTY_LAYER
+ = new ModuleLayer(Configuration.empty(), List.of(), null);
- // the configuration from which this Layer was created
+ // the configuration from which this ;ayer was created
private final Configuration cf;
// parent layers, empty in the case of the empty layer
- private final List parents;
+ private final List parents;
// maps module name to jlr.Module
private final Map nameToModule;
/**
- * Creates a new Layer from the modules in the given configuration.
+ * Creates a new module layer from the modules in the given configuration.
*/
- private Layer(Configuration cf,
- List parents,
- Function clf)
+ private ModuleLayer(Configuration cf,
+ List parents,
+ Function clf)
{
this.cf = cf;
this.parents = parents; // no need to do defensive copy
@@ -182,9 +181,9 @@ public final class Layer {
}
/**
- * Controls a layer. The static methods defined by {@link Layer} to create
- * module layers return a {@code Controller} that can be used to control
- * modules in the layer.
+ * Controls a module layer. The static methods defined by {@link ModuleLayer}
+ * to create module layers return a {@code Controller} that can be used to
+ * control modules in the layer.
*
* Unless otherwise specified, passing a {@code null} argument to a
* method in this class causes a {@link NullPointerException
@@ -197,18 +196,18 @@ public final class Layer {
* @spec JPMS
*/
public static final class Controller {
- private final Layer layer;
+ private final ModuleLayer layer;
- Controller(Layer layer) {
+ Controller(ModuleLayer layer) {
this.layer = layer;
}
/**
* Returns the layer that this object controls.
*
- * @return the layer
+ * @return the module layer
*/
- public Layer layer() {
+ public ModuleLayer layer() {
return layer;
}
@@ -235,14 +234,13 @@ public final class Layer {
* @return This controller
*
* @throws IllegalArgumentException
- * If {@code source} is not in the layer
+ * If {@code source} is not in the module layer
*
* @see Module#addReads
*/
public Controller addReads(Module source, Module target) {
ensureInLayer(source);
- Objects.requireNonNull(target);
- Modules.addReads(source, target);
+ source.implAddReads(target);
return this;
}
@@ -261,23 +259,21 @@ public final class Layer {
* @return This controller
*
* @throws IllegalArgumentException
- * If {@code source} is not in the layer or the package is not
- * in the source module
+ * If {@code source} is not in the module layer or the package
+ * is not in the source module
*
* @see Module#addOpens
*/
public Controller addOpens(Module source, String pn, Module target) {
ensureInLayer(source);
- Objects.requireNonNull(pn);
- Objects.requireNonNull(target);
- Modules.addOpens(source, pn, target);
+ source.implAddOpens(pn, target);
return this;
}
}
/**
- * Creates a new layer, with this layer as its parent, by defining the
+ * Creates a new module layer, with this layer as its parent, by defining the
* modules in the given {@code Configuration} to the Java virtual machine.
* This method creates one class loader and defines all modules to that
* class loader. The {@link ClassLoader#getParent() parent} of each class
@@ -288,7 +284,7 @@ public final class Layer {
* parent. In other words, if this layer is {@code thisLayer} then this
* method is equivalent to invoking:
*
{@code
- * Layer.defineModulesWithOneLoader(cf, List.of(thisLayer), parentLoader).layer();
+ * ModuleLayer.defineModulesWithOneLoader(cf, List.of(thisLayer), parentLoader).layer();
* }
*
* @param cf
@@ -312,14 +308,14 @@ public final class Layer {
*
* @see #findLoader
*/
- public Layer defineModulesWithOneLoader(Configuration cf,
- ClassLoader parentLoader) {
+ public ModuleLayer defineModulesWithOneLoader(Configuration cf,
+ ClassLoader parentLoader) {
return defineModulesWithOneLoader(cf, List.of(this), parentLoader).layer();
}
/**
- * Creates a new layer, with this layer as its parent, by defining the
+ * Creates a new module layer, with this layer as its parent, by defining the
* modules in the given {@code Configuration} to the Java virtual machine.
* Each module is defined to its own {@link ClassLoader} created by this
* method. The {@link ClassLoader#getParent() parent} of each class loader
@@ -330,7 +326,7 @@ public final class Layer {
* parent. In other words, if this layer is {@code thisLayer} then this
* method is equivalent to invoking:
* {@code
- * Layer.defineModulesWithManyLoaders(cf, List.of(thisLayer), parentLoader).layer();
+ * ModuleLayer.defineModulesWithManyLoaders(cf, List.of(thisLayer), parentLoader).layer();
* }
*
* @param cf
@@ -354,14 +350,14 @@ public final class Layer {
*
* @see #findLoader
*/
- public Layer defineModulesWithManyLoaders(Configuration cf,
- ClassLoader parentLoader) {
+ public ModuleLayer defineModulesWithManyLoaders(Configuration cf,
+ ClassLoader parentLoader) {
return defineModulesWithManyLoaders(cf, List.of(this), parentLoader).layer();
}
/**
- * Creates a new layer, with this layer as its parent, by defining the
+ * Creates a new module layer, with this layer as its parent, by defining the
* modules in the given {@code Configuration} to the Java virtual machine.
* Each module is mapped, by name, to its class loader by means of the
* given function. This method works exactly as specified by the static
@@ -370,7 +366,7 @@ public final class Layer {
* this layer is {@code thisLayer} then this method is equivalent to
* invoking:
* {@code
- * Layer.defineModules(cf, List.of(thisLayer), clf).layer();
+ * ModuleLayer.defineModules(cf, List.of(thisLayer), clf).layer();
* }
*
* @param cf
@@ -390,13 +386,13 @@ public final class Layer {
* If {@code RuntimePermission("getClassLoader")} is denied by
* the security manager
*/
- public Layer defineModules(Configuration cf,
- Function clf) {
+ public ModuleLayer defineModules(Configuration cf,
+ Function clf) {
return defineModules(cf, List.of(this), clf).layer();
}
/**
- * Creates a new layer by defining the modules in the given {@code
+ * Creates a new module layer by defining the modules in the given {@code
* Configuration} to the Java virtual machine. This method creates one
* class loader and defines all modules to that class loader.
*
@@ -458,10 +454,10 @@ public final class Layer {
* @see #findLoader
*/
public static Controller defineModulesWithOneLoader(Configuration cf,
- List parentLayers,
+ List parentLayers,
ClassLoader parentLoader)
{
- List parents = new ArrayList<>(parentLayers);
+ List parents = new ArrayList<>(parentLayers);
checkConfiguration(cf, parents);
checkCreateClassLoaderPermission();
@@ -470,7 +466,7 @@ public final class Layer {
try {
Loader loader = new Loader(cf.modules(), parentLoader);
loader.initRemotePackageMap(cf, parents);
- Layer layer = new Layer(cf, parents, mn -> loader);
+ ModuleLayer layer = new ModuleLayer(cf, parents, mn -> loader);
return new Controller(layer);
} catch (IllegalArgumentException | IllegalStateException e) {
throw new LayerInstantiationException(e.getMessage());
@@ -478,7 +474,7 @@ public final class Layer {
}
/**
- * Creates a new layer by defining the modules in the given {@code
+ * Creates a new module layer by defining the modules in the given {@code
* Configuration} to the Java virtual machine. Each module is defined to
* its own {@link ClassLoader} created by this method. The {@link
* ClassLoader#getParent() parent} of each class loader is the given parent
@@ -528,10 +524,10 @@ public final class Layer {
* @see #findLoader
*/
public static Controller defineModulesWithManyLoaders(Configuration cf,
- List parentLayers,
+ List parentLayers,
ClassLoader parentLoader)
{
- List parents = new ArrayList<>(parentLayers);
+ List parents = new ArrayList<>(parentLayers);
checkConfiguration(cf, parents);
checkCreateClassLoaderPermission();
@@ -539,7 +535,7 @@ public final class Layer {
LoaderPool pool = new LoaderPool(cf, parents, parentLoader);
try {
- Layer layer = new Layer(cf, parents, pool::loaderFor);
+ ModuleLayer layer = new ModuleLayer(cf, parents, pool::loaderFor);
return new Controller(layer);
} catch (IllegalArgumentException | IllegalStateException e) {
throw new LayerInstantiationException(e.getMessage());
@@ -547,7 +543,7 @@ public final class Layer {
}
/**
- * Creates a new layer by defining the modules in the given {@code
+ * Creates a new module layer by defining the modules in the given {@code
* Configuration} to the Java virtual machine. The given function maps each
* module in the configuration, by name, to a class loader. Creating the
* layer informs the Java virtual machine about the classes that may be
@@ -562,7 +558,7 @@ public final class Layer {
* ready to load from these modules before there are any attempts to load
* classes or resources.
*
- * Creating a {@code Layer} can fail for the following reasons:
+ * Creating a layer can fail for the following reasons:
*
*
*
@@ -589,7 +585,7 @@ public final class Layer {
* or runtime exception then it is propagated to the caller of this method.
*
*
- * @apiNote It is implementation specific as to whether creating a Layer
+ * @apiNote It is implementation specific as to whether creating a layer
* with this method is an atomic operation or not. Consequentially it is
* possible for this method to fail with some modules, but not all, defined
* to the Java virtual machine.
@@ -613,10 +609,10 @@ public final class Layer {
* the security manager
*/
public static Controller defineModules(Configuration cf,
- List parentLayers,
+ List parentLayers,
Function clf)
{
- List parents = new ArrayList<>(parentLayers);
+ List parents = new ArrayList<>(parentLayers);
checkConfiguration(cf, parents);
Objects.requireNonNull(clf);
@@ -628,7 +624,7 @@ public final class Layer {
}
try {
- Layer layer = new Layer(cf, parents, clf);
+ ModuleLayer layer = new ModuleLayer(cf, parents, clf);
return new Controller(layer);
} catch (IllegalArgumentException | IllegalStateException e) {
throw new LayerInstantiationException(e.getMessage());
@@ -641,7 +637,7 @@ public final class Layer {
* the parent layers.
*/
private static void checkConfiguration(Configuration cf,
- List parentLayers)
+ List parentLayers)
{
Objects.requireNonNull(cf);
@@ -650,7 +646,7 @@ public final class Layer {
throw new IllegalArgumentException("wrong number of parents");
int index = 0;
- for (Layer parent : parentLayers) {
+ for (ModuleLayer parent : parentLayers) {
if (parent.configuration() != parentConfigurations.get(index)) {
throw new IllegalArgumentException(
"Parent of configuration != configuration of this Layer");
@@ -727,7 +723,7 @@ public final class Layer {
*
* @return The list of this layer's parents
*/
- public List parents() {
+ public List parents() {
return parents;
}
@@ -739,24 +735,24 @@ public final class Layer {
* @implNote For now, the assumption is that the number of elements will
* be very low and so this method does not use a specialized spliterator.
*/
- Stream layers() {
- List allLayers = this.allLayers;
+ Stream layers() {
+ List allLayers = this.allLayers;
if (allLayers != null)
return allLayers.stream();
allLayers = new ArrayList<>();
- Set visited = new HashSet<>();
- Deque stack = new ArrayDeque<>();
+ Set visited = new HashSet<>();
+ Deque stack = new ArrayDeque<>();
visited.add(this);
stack.push(this);
while (!stack.isEmpty()) {
- Layer layer = stack.pop();
+ ModuleLayer layer = stack.pop();
allLayers.add(layer);
// push in reverse order
for (int i = layer.parents.size() - 1; i >= 0; i--) {
- Layer parent = layer.parents.get(i);
+ ModuleLayer parent = layer.parents.get(i);
if (!visited.contains(parent)) {
visited.add(parent);
stack.push(parent);
@@ -768,7 +764,7 @@ public final class Layer {
return allLayers.stream();
}
- private volatile List allLayers;
+ private volatile List allLayers;
/**
* Returns the set of the modules in this layer.
@@ -856,9 +852,9 @@ public final class Layer {
}
/**
- * Returns a string describing this layer.
+ * Returns a string describing this module layer.
*
- * @return A possibly empty string describing this layer
+ * @return A possibly empty string describing this module layer
*/
@Override
public String toString() {
@@ -873,7 +869,7 @@ public final class Layer {
*
* @return The empty layer
*/
- public static Layer empty() {
+ public static ModuleLayer empty() {
return EMPTY_LAYER;
}
@@ -887,11 +883,10 @@ public final class Layer {
*
* @return The boot layer
*/
- public static Layer boot() {
- return SharedSecrets.getJavaLangAccess().getBootLayer();
+ public static ModuleLayer boot() {
+ return System.bootLayer;
}
-
/**
* Returns the ServicesCatalog for this Layer, creating it if not
* already created.
@@ -922,10 +917,10 @@ public final class Layer {
*/
void bindToLoader(ClassLoader loader) {
// CLV.computeIfAbsent(loader, (cl, clv) -> new CopyOnWriteArrayList<>())
- List list = CLV.get(loader);
+ List list = CLV.get(loader);
if (list == null) {
list = new CopyOnWriteArrayList<>();
- List previous = CLV.putIfAbsent(loader, list);
+ List previous = CLV.putIfAbsent(loader, list);
if (previous != null) list = previous;
}
list.add(this);
@@ -935,8 +930,8 @@ public final class Layer {
* Returns a stream of the layers that have at least one module defined to
* the given class loader.
*/
- static Stream layers(ClassLoader loader) {
- List list = CLV.get(loader);
+ static Stream layers(ClassLoader loader) {
+ List list = CLV.get(loader);
if (list != null) {
return list.stream();
} else {
@@ -945,5 +940,5 @@ public final class Layer {
}
// the list of layers with modules defined to a class loader
- private static final ClassLoaderValue> CLV = new ClassLoaderValue<>();
+ private static final ClassLoaderValue> CLV = new ClassLoaderValue<>();
}
diff --git a/jdk/src/java.base/share/classes/java/lang/NamedPackage.java b/jdk/src/java.base/share/classes/java/lang/NamedPackage.java
index 5d86cc7fd9c..6234b949e65 100644
--- a/jdk/src/java.base/share/classes/java/lang/NamedPackage.java
+++ b/jdk/src/java.base/share/classes/java/lang/NamedPackage.java
@@ -26,7 +26,6 @@ package java.lang;
import java.lang.module.Configuration;
import java.lang.module.ModuleReference;
-import java.lang.reflect.Module;
import java.net.URI;
/**
diff --git a/jdk/src/java.base/share/classes/java/lang/Object.java b/jdk/src/java.base/share/classes/java/lang/Object.java
index 0677aa5d234..e1cb6e0246d 100644
--- a/jdk/src/java.base/share/classes/java/lang/Object.java
+++ b/jdk/src/java.base/share/classes/java/lang/Object.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1994, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1994, 2017, 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
@@ -561,10 +561,53 @@ public class Object {
* the finalization of this object to be halted, but is otherwise
* ignored.
*
+ * @apiNote
+ * Classes that embed non-heap resources have many options
+ * for cleanup of those resources. The class must ensure that the
+ * lifetime of each instance is longer than that of any resource it embeds.
+ * {@link java.lang.ref.Reference#reachabilityFence} can be used to ensure that
+ * objects remain reachable while resources embedded in the object are in use.
+ *
+ * A subclass should avoid overriding the {@code finalize} method
+ * unless the subclass embeds non-heap resources that must be cleaned up
+ * before the instance is collected.
+ * Finalizer invocations are not automatically chained, unlike constructors.
+ * If a subclass overrides {@code finalize} it must invoke the superclass
+ * finalizer explicitly.
+ * To guard against exceptions prematurely terminating the finalize chain,
+ * the subclass should use a {@code try-finally} block to ensure
+ * {@code super.finalize()} is always invoked. For example,
+ *
{@code @Override
+ * protected void finalize() throws Throwable {
+ * try {
+ * ... // cleanup subclass state
+ * } finally {
+ * super.finalize();
+ * }
+ * }
+ * }
+ *
+ * @deprecated The finalization mechanism is inherently problematic.
+ * Finalization can lead to performance issues, deadlocks, and hangs.
+ * Errors in finalizers can lead to resource leaks; there is no way to cancel
+ * finalization if it is no longer necessary; and no ordering is specified
+ * among calls to {@code finalize} methods of different objects.
+ * Furthermore, there are no guarantees regarding the timing of finalization.
+ * The {@code finalize} method might be called on a finalizable object
+ * only after an indefinite delay, if at all.
+ *
+ * Classes whose instances hold non-heap resources should provide a method
+ * to enable explicit release of those resources, and they should also
+ * implement {@link AutoCloseable} if appropriate.
+ * The {@link java.lang.ref.Cleaner} and {@link java.lang.ref.PhantomReference}
+ * provide more flexible and efficient ways to release resources when an object
+ * becomes unreachable.
+ *
* @throws Throwable the {@code Exception} raised by this method
* @see java.lang.ref.WeakReference
* @see java.lang.ref.PhantomReference
* @jls 12.6 Finalization of Class Instances
*/
+ @Deprecated(since="9")
protected void finalize() throws Throwable { }
}
diff --git a/jdk/src/java.base/share/classes/java/lang/Package.java b/jdk/src/java.base/share/classes/java/lang/Package.java
index 0dcc5e1c12c..25bf4a751fd 100644
--- a/jdk/src/java.base/share/classes/java/lang/Package.java
+++ b/jdk/src/java.base/share/classes/java/lang/Package.java
@@ -27,7 +27,6 @@ package java.lang;
import java.lang.annotation.Annotation;
import java.lang.reflect.AnnotatedElement;
-import java.lang.reflect.Module;
import java.net.MalformedURLException;
import java.net.URI;
import java.net.URL;
diff --git a/jdk/src/java.base/share/classes/java/lang/SecurityManager.java b/jdk/src/java.base/share/classes/java/lang/SecurityManager.java
index 084d4661700..098e8626525 100644
--- a/jdk/src/java.base/share/classes/java/lang/SecurityManager.java
+++ b/jdk/src/java.base/share/classes/java/lang/SecurityManager.java
@@ -29,9 +29,7 @@ import java.lang.RuntimePermission;
import java.lang.module.ModuleDescriptor;
import java.lang.module.ModuleDescriptor.Exports;
import java.lang.module.ModuleDescriptor.Opens;
-import java.lang.reflect.Layer;
import java.lang.reflect.Member;
-import java.lang.reflect.Module;
import java.io.FileDescriptor;
import java.io.File;
import java.io.FilePermission;
@@ -1441,7 +1439,7 @@ class SecurityManager {
static {
// Get the modules in the boot layer
- Stream bootLayerModules = Layer.boot().modules().stream();
+ Stream bootLayerModules = ModuleLayer.boot().modules().stream();
// Filter out the modules loaded by the boot or platform loader
PrivilegedAction> pa = () ->
diff --git a/jdk/src/java.base/share/classes/java/lang/StackTraceElement.java b/jdk/src/java.base/share/classes/java/lang/StackTraceElement.java
index 79b4c7299f6..b96fb363559 100644
--- a/jdk/src/java.base/share/classes/java/lang/StackTraceElement.java
+++ b/jdk/src/java.base/share/classes/java/lang/StackTraceElement.java
@@ -33,8 +33,6 @@ import jdk.internal.module.ModuleReferenceImpl;
import java.lang.module.ModuleDescriptor.Version;
import java.lang.module.ModuleReference;
import java.lang.module.ResolvedModule;
-import java.lang.reflect.Layer;
-import java.lang.reflect.Module;
import java.util.HashSet;
import java.util.Objects;
import java.util.Optional;
@@ -191,7 +189,7 @@ public final class StackTraceElement implements java.io.Serializable {
* if the module name is not available.
* @since 9
* @spec JPMS
- * @see java.lang.reflect.Module#getName()
+ * @see Module#getName()
*/
public String getModuleName() {
return moduleName;
@@ -480,7 +478,7 @@ public final class StackTraceElement implements java.io.Serializable {
if (!VM.isModuleSystemInited())
return true;
- return Layer.boot() == m.getLayer() && HashedModules.contains(m);
+ return ModuleLayer.boot() == m.getLayer() && HashedModules.contains(m);
}
/*
@@ -492,7 +490,7 @@ public final class StackTraceElement implements java.io.Serializable {
static Set hashedModules() {
- Optional resolvedModule = Layer.boot()
+ Optional resolvedModule = ModuleLayer.boot()
.configuration()
.findModule("java.base");
assert resolvedModule.isPresent();
diff --git a/jdk/src/java.base/share/classes/java/lang/System.java b/jdk/src/java.base/share/classes/java/lang/System.java
index de9054d2929..1105865d2f2 100644
--- a/jdk/src/java.base/share/classes/java/lang/System.java
+++ b/jdk/src/java.base/share/classes/java/lang/System.java
@@ -35,33 +35,32 @@ import java.io.InputStream;
import java.io.PrintStream;
import java.io.UnsupportedEncodingException;
import java.lang.annotation.Annotation;
+import java.lang.module.ModuleDescriptor;
import java.lang.reflect.Constructor;
import java.lang.reflect.Executable;
-import java.lang.reflect.Layer;
import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
-import java.lang.reflect.Module;
+import java.net.URI;
import java.net.URL;
import java.security.AccessControlContext;
import java.security.ProtectionDomain;
-import java.util.Properties;
-import java.util.PropertyPermission;
-import java.util.Map;
import java.security.AccessController;
import java.security.PrivilegedAction;
import java.nio.channels.Channel;
import java.nio.channels.spi.SelectorProvider;
+import java.util.Map;
+import java.util.Objects;
+import java.util.Properties;
+import java.util.PropertyPermission;
+import java.util.ResourceBundle;
+import java.util.function.Supplier;
import java.util.concurrent.ConcurrentHashMap;
import java.util.stream.Stream;
-import java.util.Objects;
-import java.util.ResourceBundle;
-import java.util.function.Supplier;
-import sun.nio.ch.Interruptible;
+import jdk.internal.module.ModuleBootstrap;
+import jdk.internal.module.ServicesCatalog;
import jdk.internal.reflect.CallerSensitive;
import jdk.internal.reflect.Reflection;
-import sun.security.util.SecurityConstants;
-import sun.reflect.annotation.AnnotationType;
import jdk.internal.HotSpotIntrinsicCandidate;
import jdk.internal.misc.JavaLangAccess;;
import jdk.internal.misc.SharedSecrets;;
@@ -69,8 +68,9 @@ import jdk.internal.misc.VM;
import jdk.internal.logger.LoggerFinderLoader;
import jdk.internal.logger.LazyLoggers;
import jdk.internal.logger.LocalizedLoggerWrapper;
-
-import jdk.internal.module.ModuleBootstrap;
+import sun.reflect.annotation.AnnotationType;
+import sun.nio.ch.Interruptible;
+import sun.security.util.SecurityConstants;
/**
* The System class contains several useful class fields
@@ -1162,7 +1162,7 @@ public final class System {
* @param msg the string message (or a key in the message catalog, if
* this logger is a {@link
* LoggerFinder#getLocalizedLogger(java.lang.String,
- * java.util.ResourceBundle, java.lang.reflect.Module) localized logger});
+ * java.util.ResourceBundle, java.lang.Module) localized logger});
* can be {@code null}.
*
* @throws NullPointerException if {@code level} is {@code null}.
@@ -1230,7 +1230,7 @@ public final class System {
* @param msg the string message (or a key in the message catalog, if
* this logger is a {@link
* LoggerFinder#getLocalizedLogger(java.lang.String,
- * java.util.ResourceBundle, java.lang.reflect.Module) localized logger});
+ * java.util.ResourceBundle, java.lang.Module) localized logger});
* can be {@code null}.
* @param thrown a {@code Throwable} associated with the log message;
* can be {@code null}.
@@ -1279,7 +1279,7 @@ public final class System {
* java.text.MessageFormat} format, (or a key in the message
* catalog, if this logger is a {@link
* LoggerFinder#getLocalizedLogger(java.lang.String,
- * java.util.ResourceBundle, java.lang.reflect.Module) localized logger});
+ * java.util.ResourceBundle, java.lang.Module) localized logger});
* can be {@code null}.
* @param params an optional list of parameters to the message (may be
* none).
@@ -1484,7 +1484,7 @@ public final class System {
* message localization.
*
* @implSpec By default, this method calls {@link
- * #getLogger(java.lang.String, java.lang.reflect.Module)
+ * #getLogger(java.lang.String, java.lang.Module)
* this.getLogger(name, module)} to obtain a logger, then wraps that
* logger in a {@link Logger} instance where all methods that do not
* take a {@link ResourceBundle} as parameter are redirected to one
@@ -1568,7 +1568,7 @@ public final class System {
* @implSpec
* Instances returned by this method route messages to loggers
* obtained by calling {@link LoggerFinder#getLogger(java.lang.String,
- * java.lang.reflect.Module) LoggerFinder.getLogger(name, module)}, where
+ * java.lang.Module) LoggerFinder.getLogger(name, module)}, where
* {@code module} is the caller's module.
* In cases where {@code System.getLogger} is called from a context where
* there is no caller frame on the stack (e.g when called directly
@@ -1581,7 +1581,7 @@ public final class System {
*
* @apiNote
* This method may defer calling the {@link
- * LoggerFinder#getLogger(java.lang.String, java.lang.reflect.Module)
+ * LoggerFinder#getLogger(java.lang.String, java.lang.Module)
* LoggerFinder.getLogger} method to create an actual logger supplied by
* the logging backend, for instance, to allow loggers to be obtained during
* the system initialization time.
@@ -1614,7 +1614,7 @@ public final class System {
* @implSpec
* The returned logger will perform message localization as specified
* by {@link LoggerFinder#getLocalizedLogger(java.lang.String,
- * java.util.ResourceBundle, java.lang.reflect.Module)
+ * java.util.ResourceBundle, java.lang.Module)
* LoggerFinder.getLocalizedLogger(name, bundle, module)}, where
* {@code module} is the caller's module.
* In cases where {@code System.getLogger} is called from a context where
@@ -1979,7 +1979,7 @@ public final class System {
}
// @see #initPhase2()
- private static Layer bootLayer;
+ static ModuleLayer bootLayer;
/*
* Invoked by VM. Phase 2 module system initialization.
@@ -2099,12 +2099,10 @@ public final class System {
public Thread newThreadWithAcc(Runnable target, AccessControlContext acc) {
return new Thread(target, acc);
}
+ @SuppressWarnings("deprecation")
public void invokeFinalize(Object o) throws Throwable {
o.finalize();
}
- public Layer getBootLayer() {
- return bootLayer;
- }
public ConcurrentHashMap, ?> createOrGetClassLoaderValueMap(ClassLoader cl) {
return cl.createOrGetClassLoaderValueMap();
}
@@ -2129,6 +2127,44 @@ public final class System {
public void invalidatePackageAccessCache() {
SecurityManager.invalidatePackageAccessCache();
}
+ public Module defineModule(ClassLoader loader,
+ ModuleDescriptor descriptor,
+ URI uri) {
+ return new Module(null, loader, descriptor, uri);
+ }
+ public Module defineUnnamedModule(ClassLoader loader) {
+ return new Module(loader);
+ }
+ public void addReads(Module m1, Module m2) {
+ m1.implAddReads(m2);
+ }
+ public void addReadsAllUnnamed(Module m) {
+ m.implAddReadsAllUnnamed();
+ }
+ public void addExports(Module m, String pn, Module other) {
+ m.implAddExports(pn, other);
+ }
+ public void addExportsToAllUnnamed(Module m, String pn) {
+ m.implAddExportsToAllUnnamed(pn);
+ }
+ public void addOpens(Module m, String pn, Module other) {
+ m.implAddOpens(pn, other);
+ }
+ public void addOpensToAllUnnamed(Module m, String pn) {
+ m.implAddOpensToAllUnnamed(pn);
+ }
+ public void addUses(Module m, Class> service) {
+ m.implAddUses(service);
+ }
+ public ServicesCatalog getServicesCatalog(ModuleLayer layer) {
+ return layer.getServicesCatalog();
+ }
+ public Stream layers(ModuleLayer layer) {
+ return layer.layers();
+ }
+ public Stream layers(ClassLoader loader) {
+ return ModuleLayer.layers(loader);
+ }
});
}
}
diff --git a/jdk/src/java.base/share/classes/java/lang/Thread.java b/jdk/src/java.base/share/classes/java/lang/Thread.java
index a7fc391d540..8ecc90dd964 100644
--- a/jdk/src/java.base/share/classes/java/lang/Thread.java
+++ b/jdk/src/java.base/share/classes/java/lang/Thread.java
@@ -927,7 +927,7 @@ class Thread implements Runnable {
* for example), the interrupt method should be used to
* interrupt the wait.
* For more information, see
- * Why
+ * Why
* are Thread.stop, Thread.suspend and Thread.resume Deprecated? .
*/
@Deprecated(since="1.2")
@@ -960,7 +960,7 @@ class Thread implements Runnable {
* could be used to generate exceptions that the target thread was
* not prepared to handle.
* For more information, see
- * Why
+ * Why
* are Thread.stop, Thread.suspend and Thread.resume Deprecated? .
* This method is subject to removal in a future version of Java SE.
*/
@@ -1082,7 +1082,7 @@ class Thread implements Runnable {
* If another thread ever attempted to lock this resource, deadlock
* would result. Such deadlocks typically manifest themselves as
* "frozen" processes. For more information, see
- *
+ *
* Why are Thread.stop, Thread.suspend and Thread.resume Deprecated? .
* This method is subject to removal in a future version of Java SE.
* @throws NoSuchMethodError always
@@ -1122,7 +1122,7 @@ class Thread implements Runnable {
* monitor prior to calling resume, deadlock results. Such
* deadlocks typically manifest themselves as "frozen" processes.
* For more information, see
- * Why
+ * Why
* are Thread.stop, Thread.suspend and Thread.resume Deprecated? .
*/
@Deprecated(since="1.2")
@@ -1148,7 +1148,7 @@ class Thread implements Runnable {
* @deprecated This method exists solely for use with {@link #suspend},
* which has been deprecated because it is deadlock-prone.
* For more information, see
- * Why
+ * Why
* are Thread.stop, Thread.suspend and Thread.resume Deprecated? .
*/
@Deprecated(since="1.2")
diff --git a/jdk/src/java.base/share/classes/java/lang/reflect/WeakPairMap.java b/jdk/src/java.base/share/classes/java/lang/WeakPairMap.java
similarity index 99%
rename from jdk/src/java.base/share/classes/java/lang/reflect/WeakPairMap.java
rename to jdk/src/java.base/share/classes/java/lang/WeakPairMap.java
index 39a623a4704..1e4e12767b3 100644
--- a/jdk/src/java.base/share/classes/java/lang/reflect/WeakPairMap.java
+++ b/jdk/src/java.base/share/classes/java/lang/WeakPairMap.java
@@ -22,7 +22,7 @@
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
-package java.lang.reflect;
+package java.lang;
import java.lang.ref.Reference;
import java.lang.ref.ReferenceQueue;
diff --git a/jdk/src/java.base/share/classes/java/lang/annotation/ElementType.java b/jdk/src/java.base/share/classes/java/lang/annotation/ElementType.java
index 14780fe6827..bbab9cdacc2 100644
--- a/jdk/src/java.base/share/classes/java/lang/annotation/ElementType.java
+++ b/jdk/src/java.base/share/classes/java/lang/annotation/ElementType.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2017, 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,7 +28,7 @@ package java.lang.annotation;
/**
* The constants of this enumerated type provide a simple classification of the
* syntactic locations where annotations may appear in a Java program. These
- * constants are used in {@link Target java.lang.annotation.Target}
+ * constants are used in {@link java.lang.annotation.Target Target}
* meta-annotations to specify where it is legal to write annotations of a
* given type.
*
diff --git a/jdk/src/java.base/share/classes/java/lang/doc-files/threadPrimitiveDeprecation.html b/jdk/src/java.base/share/classes/java/lang/doc-files/threadPrimitiveDeprecation.html
new file mode 100644
index 00000000000..aa6ba4981f4
--- /dev/null
+++ b/jdk/src/java.base/share/classes/java/lang/doc-files/threadPrimitiveDeprecation.html
@@ -0,0 +1,364 @@
+
+
+
+
+ Java Thread Primitive Deprecation
+
+
+
+Java Thread Primitive Deprecation
+
+Why is Thread.stop deprecated?
+Because it is inherently unsafe. Stopping a thread causes it to
+unlock all the monitors that it has locked. (The monitors are
+unlocked as the ThreadDeath exception propagates up
+the stack.) If any of the objects previously protected by these
+monitors were in an inconsistent state, other threads may now view
+these objects in an inconsistent state. Such objects are said to be
+damaged . When threads operate on damaged objects, arbitrary
+behavior can result. This behavior may be subtle and difficult to
+detect, or it may be pronounced. Unlike other unchecked exceptions,
+ThreadDeath kills threads silently; thus, the user has
+no warning that his program may be corrupted. The corruption can
+manifest itself at any time after the actual damage occurs, even
+hours or days in the future.
+
+Couldn't I just catch the ThreadDeath exception
+and fix the damaged object?
+In theory, perhaps, but it would vastly complicate the
+task of writing correct multithreaded code. The task would be
+nearly insurmountable for two reasons:
+
+A thread can throw a ThreadDeath exception
+almost anywhere . All synchronized methods and blocks would
+have to be studied in great detail, with this in mind.
+A thread can throw a second ThreadDeath exception
+while cleaning up from the first (in the catch or
+finally clause). Cleanup would have to be repeated till
+it succeeded. The code to ensure this would be quite complex.
+
+In sum, it just isn't practical.
+
+What about Thread.stop(Throwable)?
+In addition to all of the problems noted above, this method may
+be used to generate exceptions that its target thread is unprepared
+to handle (including checked exceptions that the thread could not
+possibly throw, were it not for this method). For example, the
+following method is behaviorally identical to Java's
+throw operation, but circumvents the compiler's
+attempts to guarantee that the calling method has declared all of
+the checked exceptions that it may throw:
+
+ static void sneakyThrow(Throwable t) {
+ Thread.currentThread().stop(t);
+ }
+
+
+What should I use instead of Thread.stop?
+Most uses of stop should be replaced by code that
+simply modifies some variable to indicate that the target thread
+should stop running. The target thread should check this variable
+regularly, and return from its run method in an orderly fashion if
+the variable indicates that it is to stop running. To ensure prompt
+communication of the stop-request, the variable must be
+volatile (or access to the variable must be
+synchronized).
+For example, suppose your applet contains the following
+start, stop and run
+methods:
+
+ private Thread blinker;
+
+ public void start() {
+ blinker = new Thread(this);
+ blinker.start();
+ }
+
+ public void stop() {
+ blinker.stop(); // UNSAFE!
+ }
+
+ public void run() {
+ while (true) {
+ try {
+ Thread.sleep(interval);
+ } catch (InterruptedException e){
+ }
+ repaint();
+ }
+ }
+
+You can avoid the use of Thread.stop by replacing the
+applet's stop and run methods with:
+
+ private volatile Thread blinker;
+
+ public void stop() {
+ blinker = null;
+ }
+
+ public void run() {
+ Thread thisThread = Thread.currentThread();
+ while (blinker == thisThread) {
+ try {
+ Thread.sleep(interval);
+ } catch (InterruptedException e){
+ }
+ repaint();
+ }
+ }
+
+
+How do I stop a thread that waits for long periods (e.g., for
+input)?
+That's what the Thread.interrupt method is for. The
+same "state based" signaling mechanism shown above can be used, but
+the state change (blinker = null, in the previous
+example) can be followed by a call to
+Thread.interrupt, to interrupt the wait:
+
+ public void stop() {
+ Thread moribund = waiter;
+ waiter = null;
+ moribund.interrupt();
+ }
+
+For this technique to work, it's critical that any method that
+catches an interrupt exception and is not prepared to deal with it
+immediately reasserts the exception. We say reasserts
+rather than rethrows , because it is not always possible to
+rethrow the exception. If the method that catches the
+InterruptedException is not declared to throw this
+(checked) exception, then it should "reinterrupt itself" with the
+following incantation:
+
+ Thread.currentThread().interrupt();
+
+This ensures that the Thread will reraise the
+InterruptedException as soon as it is able.
+
+What if a thread doesn't respond to
+Thread.interrupt?
+In some cases, you can use application specific tricks. For
+example, if a thread is waiting on a known socket, you can close
+the socket to cause the thread to return immediately.
+Unfortunately, there really isn't any technique that works in
+general. It should be noted that in all situations where a
+waiting thread doesn't respond to Thread.interrupt, it
+wouldn't respond to Thread.stop either. Such
+cases include deliberate denial-of-service attacks, and I/O
+operations for which thread.stop and thread.interrupt do not work
+properly.
+
+Why are Thread.suspend and
+Thread.resume deprecated?
+Thread.suspend is inherently deadlock-prone. If the
+target thread holds a lock on the monitor protecting a critical
+system resource when it is suspended, no thread can access this
+resource until the target thread is resumed. If the thread that
+would resume the target thread attempts to lock this monitor prior
+to calling resume, deadlock results. Such deadlocks
+typically manifest themselves as "frozen" processes.
+
+What should I use instead of Thread.suspend and
+Thread.resume?
+As with Thread.stop, the prudent approach is to
+have the "target thread" poll a variable indicating the desired
+state of the thread (active or suspended). When the desired state
+is suspended, the thread waits using Object.wait. When
+the thread is resumed, the target thread is notified using
+Object.notify.
+For example, suppose your applet contains the following
+mousePressed event handler, which toggles the state of a thread
+called blinker:
+
+ private boolean threadSuspended;
+
+ Public void mousePressed(MouseEvent e) {
+ e.consume();
+
+ if (threadSuspended)
+ blinker.resume();
+ else
+ blinker.suspend(); // DEADLOCK-PRONE!
+
+ threadSuspended = !threadSuspended;
+ }
+
+You can avoid the use of Thread.suspend and
+Thread.resume by replacing the event handler above
+with:
+
+ public synchronized void mousePressed(MouseEvent e) {
+ e.consume();
+
+ threadSuspended = !threadSuspended;
+
+ if (!threadSuspended)
+ notify();
+ }
+
+and adding the following code to the "run loop":
+
+ synchronized(this) {
+ while (threadSuspended)
+ wait();
+ }
+
+The wait method throws the
+InterruptedException, so it must be inside a try
+... catch clause. It's fine to put it in the same clause as
+the sleep. The check should follow (rather than
+precede) the sleep so the window is immediately
+repainted when the thread is "resumed." The resulting
+run method follows:
+
+ public void run() {
+ while (true) {
+ try {
+ Thread.sleep(interval);
+
+ synchronized(this) {
+ while (threadSuspended)
+ wait();
+ }
+ } catch (InterruptedException e){
+ }
+ repaint();
+ }
+ }
+
+Note that the notify in the mousePressed
+method and the wait in the run method are
+inside synchronized blocks. This is required by the
+language, and ensures that wait and
+notify are properly serialized. In practical terms,
+this eliminates race conditions that could cause the "suspended"
+thread to miss a notify and remain suspended
+indefinitely.
+While the cost of synchronization in Java is decreasing as the
+platform matures, it will never be free. A simple trick can be used
+to remove the synchronization that we've added to each iteration of
+the "run loop." The synchronized block that was added is replaced
+by a slightly more complex piece of code that enters a synchronized
+block only if the thread has actually been suspended:
+
+ if (threadSuspended) {
+ synchronized(this) {
+ while (threadSuspended)
+ wait();
+ }
+ }
+
+In the absence of explicit synchronization,
+threadSuspended must be made volatile to ensure
+prompt communication of the suspend-request.
+The resulting run method is:
+
+ private volatile boolean threadSuspended;
+
+ public void run() {
+ while (true) {
+ try {
+ Thread.sleep(interval);
+
+ if (threadSuspended) {
+ synchronized(this) {
+ while (threadSuspended)
+ wait();
+ }
+ }
+ } catch (InterruptedException e){
+ }
+ repaint();
+ }
+ }
+
+
+Can I combine the two techniques to produce a thread that may
+be safely "stopped" or "suspended"?
+Yes, it's reasonably straightforward. The one subtlety is that the
+target thread may already be suspended at the time that another
+thread tries to stop it. If the stop method merely sets
+the state variable (blinker ) to null, the target thread
+will remain suspended (waiting on the monitor), rather than exiting
+gracefully as it should. If the applet is restarted, multiple
+threads could end up waiting on the monitor at the same time,
+resulting in erratic behavior.
+To rectify this situation, the stop method must ensure
+that the target thread resumes immediately if it is suspended. Once
+the target thread resumes, it must recognize immediately that it
+has been stopped, and exit gracefully. Here's how the resulting
+run and stop methods look:
+
+ public void run() {
+ Thread thisThread = Thread.currentThread();
+ while (blinker == thisThread) {
+ try {
+ Thread.sleep(interval);
+
+ synchronized(this) {
+ while (threadSuspended && blinker==thisThread)
+ wait();
+ }
+ } catch (InterruptedException e){
+ }
+ repaint();
+ }
+ }
+
+ public synchronized void stop() {
+ blinker = null;
+ notify();
+ }
+
+If the stop method calls Thread.interrupt , as
+described above, it needn't call notify as well, but it
+still must be synchronized. This ensures that the target thread
+won't miss an interrupt due to a race condition.
+
+What about Thread.destroy?
+Thread.destroy was never implemented and has been
+deprecated. If it were implemented, it would be deadlock-prone in
+the manner of Thread.suspend. (In fact, it is roughly
+equivalent to Thread.suspend without the possibility
+of a subsequent Thread.resume.)
+
+Why is Runtime.runFinalizersOnExit
+deprecated?
+Because it is inherently unsafe. It may result in finalizers being
+called on live objects while other threads are concurrently
+manipulating those objects, resulting in erratic behavior or
+deadlock. While this problem could be prevented if the class whose
+objects are being finalized were coded to "defend against" this
+call, most programmers do not defend against it. They assume
+that an object is dead at the time that its finalizer is called.
+Further, the call is not "thread-safe" in the sense that it sets
+a VM-global flag. This forces every class with a finalizer
+to defend against the finalization of live objects!
+
+
+
diff --git a/jdk/src/java.base/share/classes/java/lang/invoke/BoundMethodHandle.java b/jdk/src/java.base/share/classes/java/lang/invoke/BoundMethodHandle.java
index cec436690b9..f4675e15905 100644
--- a/jdk/src/java.base/share/classes/java/lang/invoke/BoundMethodHandle.java
+++ b/jdk/src/java.base/share/classes/java/lang/invoke/BoundMethodHandle.java
@@ -450,32 +450,29 @@ import static jdk.internal.org.objectweb.asm.Opcodes.*;
*/
static class Factory {
- static final String JLO_SIG = "Ljava/lang/Object;";
- static final String JLS_SIG = "Ljava/lang/String;";
- static final String JLC_SIG = "Ljava/lang/Class;";
- static final String MH = "java/lang/invoke/MethodHandle";
- static final String MH_SIG = "L"+MH+";";
- static final String BMH = "java/lang/invoke/BoundMethodHandle";
- static final String BMH_SIG = "L"+BMH+";";
- static final String SPECIES_DATA = "java/lang/invoke/BoundMethodHandle$SpeciesData";
- static final String SPECIES_DATA_SIG = "L"+SPECIES_DATA+";";
- static final String STABLE_SIG = "Ljdk/internal/vm/annotation/Stable;";
+ private static final String JLO_SIG = "Ljava/lang/Object;";
+ private static final String MH = "java/lang/invoke/MethodHandle";
+ private static final String MH_SIG = "L"+MH+";";
+ private static final String BMH = "java/lang/invoke/BoundMethodHandle";
+ private static final String BMH_NAME = "java.lang.invoke.BoundMethodHandle";
+ private static final String BMH_SIG = "L"+BMH+";";
+ private static final String SPECIES_DATA = "java/lang/invoke/BoundMethodHandle$SpeciesData";
+ private static final String SPECIES_DATA_SIG = "L"+SPECIES_DATA+";";
+ private static final String STABLE_SIG = "Ljdk/internal/vm/annotation/Stable;";
- static final String SPECIES_PREFIX_NAME = "Species_";
- static final String SPECIES_PREFIX_PATH = BMH + "$" + SPECIES_PREFIX_NAME;
- static final String SPECIES_CLASS_PREFIX = SPECIES_PREFIX_PATH.replace('/', '.');
+ private static final String SPECIES_PREFIX_NAME = "Species_";
+ private static final String SPECIES_PREFIX_PATH = BMH + "$" + SPECIES_PREFIX_NAME;
+ private static final String SPECIES_CLASS_PREFIX = BMH_NAME + "$" + SPECIES_PREFIX_NAME;
- static final String BMHSPECIES_DATA_EWI_SIG = "(B)" + SPECIES_DATA_SIG;
- static final String BMHSPECIES_DATA_GFC_SIG = "(" + JLS_SIG + JLC_SIG + ")" + SPECIES_DATA_SIG;
- static final String MYSPECIES_DATA_SIG = "()" + SPECIES_DATA_SIG;
- static final String VOID_SIG = "()V";
- static final String INT_SIG = "()I";
+ private static final String BMHSPECIES_DATA_EWI_SIG = "(B)" + SPECIES_DATA_SIG;
+ private static final String MYSPECIES_DATA_SIG = "()" + SPECIES_DATA_SIG;
+ private static final String INT_SIG = "()I";
- static final String SIG_INCIPIT = "(Ljava/lang/invoke/MethodType;Ljava/lang/invoke/LambdaForm;";
+ private static final String SIG_INCIPIT = "(Ljava/lang/invoke/MethodType;Ljava/lang/invoke/LambdaForm;";
- static final String[] E_THROWABLE = new String[] { "java/lang/Throwable" };
+ private static final String[] E_THROWABLE = new String[] { "java/lang/Throwable" };
- static final ConcurrentMap> CLASS_CACHE = new ConcurrentHashMap<>();
+ private static final ConcurrentMap> CLASS_CACHE = new ConcurrentHashMap<>();
/**
* Get a concrete subclass of BMH for a given combination of bound types.
@@ -830,15 +827,27 @@ import static jdk.internal.org.objectweb.asm.Opcodes.*;
private static String makeSignature(String types, boolean ctor) {
StringBuilder buf = new StringBuilder(SIG_INCIPIT);
- for (char c : types.toCharArray()) {
- buf.append(typeSig(c));
+ int len = types.length();
+ for (int i = 0; i < len; i++) {
+ buf.append(typeSig(types.charAt(i)));
}
return buf.append(')').append(ctor ? "V" : BMH_SIG).toString();
}
+ private static MethodType makeConstructorType(String types) {
+ int length = types.length();
+ Class> ptypes[] = new Class>[length + 2];
+ ptypes[0] = MethodType.class;
+ ptypes[1] = LambdaForm.class;
+ for (int i = 0; i < length; i++) {
+ ptypes[i + 2] = BasicType.basicType(types.charAt(i)).basicTypeClass();
+ }
+ return MethodType.makeImpl(BoundMethodHandle.class, ptypes, true);
+ }
+
static MethodHandle makeCbmhCtor(Class extends BoundMethodHandle> cbmh, String types) {
try {
- return LOOKUP.findStatic(cbmh, "make", MethodType.fromDescriptor(makeSignature(types, false), null));
+ return LOOKUP.findStatic(cbmh, "make", makeConstructorType(types));
} catch (NoSuchMethodException | IllegalAccessException | IllegalArgumentException | TypeNotPresentException e) {
throw newInternalError(e);
}
diff --git a/jdk/src/java.base/share/classes/java/lang/invoke/DirectMethodHandle.java b/jdk/src/java.base/share/classes/java/lang/invoke/DirectMethodHandle.java
index 0b4bd58b624..bd06ffa5348 100644
--- a/jdk/src/java.base/share/classes/java/lang/invoke/DirectMethodHandle.java
+++ b/jdk/src/java.base/share/classes/java/lang/invoke/DirectMethodHandle.java
@@ -224,12 +224,12 @@ class DirectMethodHandle extends MethodHandle {
assert(names.length == nameCursor);
if (doesAlloc) {
// names = { argx,y,z,... new C, init method }
- names[NEW_OBJ] = new Name(NF_allocateInstance, names[DMH_THIS]);
- names[GET_MEMBER] = new Name(NF_constructorMethod, names[DMH_THIS]);
+ names[NEW_OBJ] = new Name(getFunction(NF_allocateInstance), names[DMH_THIS]);
+ names[GET_MEMBER] = new Name(getFunction(NF_constructorMethod), names[DMH_THIS]);
} else if (needsInit) {
- names[GET_MEMBER] = new Name(NF_internalMemberNameEnsureInit, names[DMH_THIS]);
+ names[GET_MEMBER] = new Name(getFunction(NF_internalMemberNameEnsureInit), names[DMH_THIS]);
} else {
- names[GET_MEMBER] = new Name(NF_internalMemberName, names[DMH_THIS]);
+ names[GET_MEMBER] = new Name(getFunction(NF_internalMemberName), names[DMH_THIS]);
}
assert(findDirectMethodHandle(names[GET_MEMBER]) == names[DMH_THIS]);
Object[] outArgs = Arrays.copyOfRange(names, ARG_BASE, GET_MEMBER+1, Object[].class);
@@ -249,10 +249,10 @@ class DirectMethodHandle extends MethodHandle {
return lform;
}
- static Object findDirectMethodHandle(Name name) {
- if (name.function == NF_internalMemberName ||
- name.function == NF_internalMemberNameEnsureInit ||
- name.function == NF_constructorMethod) {
+ /* assert */ static Object findDirectMethodHandle(Name name) {
+ if (name.function.equals(getFunction(NF_internalMemberName)) ||
+ name.function.equals(getFunction(NF_internalMemberNameEnsureInit)) ||
+ name.function.equals(getFunction(NF_constructorMethod))) {
assert(name.arguments.length == 1);
return name.arguments[0];
}
@@ -674,18 +674,18 @@ class DirectMethodHandle extends MethodHandle {
final int RESULT = nameCursor-1; // either the call or the cast
Name[] names = arguments(nameCursor - ARG_LIMIT, mtype.invokerType());
if (needsInit)
- names[INIT_BAR] = new Name(NF_ensureInitialized, names[DMH_THIS]);
+ names[INIT_BAR] = new Name(getFunction(NF_ensureInitialized), names[DMH_THIS]);
if (needsCast && !isGetter)
- names[PRE_CAST] = new Name(NF_checkCast, names[DMH_THIS], names[SET_VALUE]);
+ names[PRE_CAST] = new Name(getFunction(NF_checkCast), names[DMH_THIS], names[SET_VALUE]);
Object[] outArgs = new Object[1 + linkerType.parameterCount()];
assert(outArgs.length == (isGetter ? 3 : 4));
- outArgs[0] = names[U_HOLDER] = new Name(NF_UNSAFE);
+ outArgs[0] = names[U_HOLDER] = new Name(getFunction(NF_UNSAFE));
if (isStatic) {
- outArgs[1] = names[F_HOLDER] = new Name(NF_staticBase, names[DMH_THIS]);
- outArgs[2] = names[F_OFFSET] = new Name(NF_staticOffset, names[DMH_THIS]);
+ outArgs[1] = names[F_HOLDER] = new Name(getFunction(NF_staticBase), names[DMH_THIS]);
+ outArgs[2] = names[F_OFFSET] = new Name(getFunction(NF_staticOffset), names[DMH_THIS]);
} else {
- outArgs[1] = names[OBJ_CHECK] = new Name(NF_checkBase, names[OBJ_BASE]);
- outArgs[2] = names[F_OFFSET] = new Name(NF_fieldOffset, names[DMH_THIS]);
+ outArgs[1] = names[OBJ_CHECK] = new Name(getFunction(NF_checkBase), names[OBJ_BASE]);
+ outArgs[2] = names[F_OFFSET] = new Name(getFunction(NF_fieldOffset), names[DMH_THIS]);
}
if (!isGetter) {
outArgs[3] = (needsCast ? names[PRE_CAST] : names[SET_VALUE]);
@@ -693,7 +693,7 @@ class DirectMethodHandle extends MethodHandle {
for (Object a : outArgs) assert(a != null);
names[LINKER_CALL] = new Name(linker, outArgs);
if (needsCast && isGetter)
- names[POST_CAST] = new Name(NF_checkCast, names[DMH_THIS], names[LINKER_CALL]);
+ names[POST_CAST] = new Name(getFunction(NF_checkCast), names[DMH_THIS], names[LINKER_CALL]);
for (Name n : names) assert(n != null);
LambdaForm form;
@@ -726,48 +726,72 @@ class DirectMethodHandle extends MethodHandle {
/**
* Pre-initialized NamedFunctions for bootstrapping purposes.
- * Factored in an inner class to delay initialization until first usage.
*/
- static final NamedFunction
- NF_internalMemberName,
- NF_internalMemberNameEnsureInit,
- NF_ensureInitialized,
- NF_fieldOffset,
- NF_checkBase,
- NF_staticBase,
- NF_staticOffset,
- NF_checkCast,
- NF_allocateInstance,
- NF_constructorMethod,
- NF_UNSAFE;
- static {
+ static final byte NF_internalMemberName = 0,
+ NF_internalMemberNameEnsureInit = 1,
+ NF_ensureInitialized = 2,
+ NF_fieldOffset = 3,
+ NF_checkBase = 4,
+ NF_staticBase = 5,
+ NF_staticOffset = 6,
+ NF_checkCast = 7,
+ NF_allocateInstance = 8,
+ NF_constructorMethod = 9,
+ NF_UNSAFE = 10,
+ NF_LIMIT = 11;
+
+ private static final @Stable NamedFunction[] NFS = new NamedFunction[NF_LIMIT];
+
+ private static NamedFunction getFunction(byte func) {
+ NamedFunction nf = NFS[func];
+ if (nf != null) {
+ return nf;
+ }
+ // Each nf must be statically invocable or we get tied up in our bootstraps.
+ nf = NFS[func] = createFunction(func);
+ assert(InvokerBytecodeGenerator.isStaticallyInvocable(nf));
+ return nf;
+ }
+
+ private static NamedFunction createFunction(byte func) {
try {
- NamedFunction nfs[] = {
- NF_internalMemberName = new NamedFunction(DirectMethodHandle.class
- .getDeclaredMethod("internalMemberName", Object.class)),
- NF_internalMemberNameEnsureInit = new NamedFunction(DirectMethodHandle.class
- .getDeclaredMethod("internalMemberNameEnsureInit", Object.class)),
- NF_ensureInitialized = new NamedFunction(DirectMethodHandle.class
- .getDeclaredMethod("ensureInitialized", Object.class)),
- NF_fieldOffset = new NamedFunction(DirectMethodHandle.class
- .getDeclaredMethod("fieldOffset", Object.class)),
- NF_checkBase = new NamedFunction(DirectMethodHandle.class
- .getDeclaredMethod("checkBase", Object.class)),
- NF_staticBase = new NamedFunction(DirectMethodHandle.class
- .getDeclaredMethod("staticBase", Object.class)),
- NF_staticOffset = new NamedFunction(DirectMethodHandle.class
- .getDeclaredMethod("staticOffset", Object.class)),
- NF_checkCast = new NamedFunction(DirectMethodHandle.class
- .getDeclaredMethod("checkCast", Object.class, Object.class)),
- NF_allocateInstance = new NamedFunction(DirectMethodHandle.class
- .getDeclaredMethod("allocateInstance", Object.class)),
- NF_constructorMethod = new NamedFunction(DirectMethodHandle.class
- .getDeclaredMethod("constructorMethod", Object.class)),
- NF_UNSAFE = new NamedFunction(new MemberName(MethodHandleStatics.class
- .getDeclaredField("UNSAFE")))
- };
- // Each nf must be statically invocable or we get tied up in our bootstraps.
- assert(InvokerBytecodeGenerator.isStaticallyInvocable(nfs));
+ switch (func) {
+ case NF_internalMemberName:
+ return new NamedFunction(DirectMethodHandle.class
+ .getDeclaredMethod("internalMemberName", Object.class));
+ case NF_internalMemberNameEnsureInit:
+ return new NamedFunction(DirectMethodHandle.class
+ .getDeclaredMethod("internalMemberNameEnsureInit", Object.class));
+ case NF_ensureInitialized:
+ return new NamedFunction(DirectMethodHandle.class
+ .getDeclaredMethod("ensureInitialized", Object.class));
+ case NF_fieldOffset:
+ return new NamedFunction(DirectMethodHandle.class
+ .getDeclaredMethod("fieldOffset", Object.class));
+ case NF_checkBase:
+ return new NamedFunction(DirectMethodHandle.class
+ .getDeclaredMethod("checkBase", Object.class));
+ case NF_staticBase:
+ return new NamedFunction(DirectMethodHandle.class
+ .getDeclaredMethod("staticBase", Object.class));
+ case NF_staticOffset:
+ return new NamedFunction(DirectMethodHandle.class
+ .getDeclaredMethod("staticOffset", Object.class));
+ case NF_checkCast:
+ return new NamedFunction(DirectMethodHandle.class
+ .getDeclaredMethod("checkCast", Object.class, Object.class));
+ case NF_allocateInstance:
+ return new NamedFunction(DirectMethodHandle.class
+ .getDeclaredMethod("allocateInstance", Object.class));
+ case NF_constructorMethod:
+ return new NamedFunction(DirectMethodHandle.class
+ .getDeclaredMethod("constructorMethod", Object.class));
+ case NF_UNSAFE:
+ return new NamedFunction(new MemberName(MethodHandleStatics.class
+ .getDeclaredField("UNSAFE")));
+ default:
+ throw newInternalError("Unknown function: " + func);
+ }
} catch (ReflectiveOperationException ex) {
throw newInternalError(ex);
}
diff --git a/jdk/src/java.base/share/classes/java/lang/invoke/InvokerBytecodeGenerator.java b/jdk/src/java.base/share/classes/java/lang/invoke/InvokerBytecodeGenerator.java
index ec81f5093b6..7349ea2bec4 100644
--- a/jdk/src/java.base/share/classes/java/lang/invoke/InvokerBytecodeGenerator.java
+++ b/jdk/src/java.base/share/classes/java/lang/invoke/InvokerBytecodeGenerator.java
@@ -73,6 +73,7 @@ class InvokerBytecodeGenerator {
private static final String LL_SIG = "(L" + OBJ + ";)L" + OBJ + ";";
private static final String LLV_SIG = "(L" + OBJ + ";L" + OBJ + ";)V";
private static final String CLASS_PREFIX = LF + "$";
+ private static final String SOURCE_PREFIX = "LambdaForm$";
/** Name of its super class*/
static final String INVOKER_SUPER_NAME = OBJ;
@@ -80,9 +81,6 @@ class InvokerBytecodeGenerator {
/** Name of new class */
private final String className;
- /** Name of the source file (for stack trace printing). */
- private final String sourceFile;
-
private final LambdaForm lambdaForm;
private final String invokerName;
private final MethodType invokerType;
@@ -109,8 +107,7 @@ class InvokerBytecodeGenerator {
if (DUMP_CLASS_FILES) {
className = makeDumpableClassName(className);
}
- this.className = CLASS_PREFIX + className;
- this.sourceFile = "LambdaForm$" + className;
+ this.className = className;
this.lambdaForm = lambdaForm;
this.invokerName = invokerName;
this.invokerType = invokerType;
@@ -173,6 +170,13 @@ class InvokerBytecodeGenerator {
}
}
+ private void maybeDump(final byte[] classFile) {
+ if (DUMP_CLASS_FILES) {
+ maybeDump(CLASS_PREFIX + className, classFile);
+ }
+ }
+
+ // Also used from BoundMethodHandle
static void maybeDump(final String className, final byte[] classFile) {
if (DUMP_CLASS_FILES) {
java.security.AccessController.doPrivileged(
@@ -306,8 +310,9 @@ class InvokerBytecodeGenerator {
private ClassWriter classFilePrologue() {
final int NOT_ACC_PUBLIC = 0; // not ACC_PUBLIC
cw = new ClassWriter(ClassWriter.COMPUTE_MAXS + ClassWriter.COMPUTE_FRAMES);
- cw.visit(Opcodes.V1_8, NOT_ACC_PUBLIC + Opcodes.ACC_FINAL + Opcodes.ACC_SUPER, className, null, INVOKER_SUPER_NAME, null);
- cw.visitSource(sourceFile, null);
+ cw.visit(Opcodes.V1_8, NOT_ACC_PUBLIC + Opcodes.ACC_FINAL + Opcodes.ACC_SUPER,
+ CLASS_PREFIX + className, null, INVOKER_SUPER_NAME, null);
+ cw.visitSource(SOURCE_PREFIX + className, null);
return cw;
}
@@ -617,12 +622,11 @@ class InvokerBytecodeGenerator {
return resolvedMember;
}
- private static MemberName lookupPregenerated(LambdaForm form) {
+ private static MemberName lookupPregenerated(LambdaForm form, MethodType invokerType) {
if (form.customized != null) {
// No pre-generated version for customized LF
return null;
}
- MethodType invokerType = form.methodType();
String name = form.kind.methodName;
switch (form.kind) {
case BOUND_REINVOKER: {
@@ -670,7 +674,7 @@ class InvokerBytecodeGenerator {
* Generate customized bytecode for a given LambdaForm.
*/
static MemberName generateCustomizedCode(LambdaForm form, MethodType invokerType) {
- MemberName pregenerated = lookupPregenerated(form);
+ MemberName pregenerated = lookupPregenerated(form, invokerType);
if (pregenerated != null) return pregenerated; // pre-generated bytecode
InvokerBytecodeGenerator g = new InvokerBytecodeGenerator("MH", form, invokerType);
@@ -720,7 +724,7 @@ class InvokerBytecodeGenerator {
bogusMethod(lambdaForm);
final byte[] classFile = toByteArray();
- maybeDump(className, classFile);
+ maybeDump(classFile);
return classFile;
}
@@ -908,7 +912,7 @@ class InvokerBytecodeGenerator {
//MethodHandle.class already covered
};
- static boolean isStaticallyInvocable(NamedFunction[] functions) {
+ static boolean isStaticallyInvocable(NamedFunction ... functions) {
for (NamedFunction nf : functions) {
if (!isStaticallyInvocable(nf.member())) {
return false;
@@ -1761,7 +1765,7 @@ class InvokerBytecodeGenerator {
bogusMethod(invokerType);
final byte[] classFile = cw.toByteArray();
- maybeDump(className, classFile);
+ maybeDump(classFile);
return classFile;
}
@@ -1829,7 +1833,7 @@ class InvokerBytecodeGenerator {
bogusMethod(dstType);
final byte[] classFile = cw.toByteArray();
- maybeDump(className, classFile);
+ maybeDump(classFile);
return classFile;
}
diff --git a/jdk/src/java.base/share/classes/java/lang/invoke/Invokers.java b/jdk/src/java.base/share/classes/java/lang/invoke/Invokers.java
index a221af7e086..8eeb4c3954e 100644
--- a/jdk/src/java.base/share/classes/java/lang/invoke/Invokers.java
+++ b/jdk/src/java.base/share/classes/java/lang/invoke/Invokers.java
@@ -313,15 +313,15 @@ class Invokers {
Object[] outArgs = Arrays.copyOfRange(names, CALL_MH, OUTARG_LIMIT, Object[].class);
Object mtypeArg = (customized ? mtype : names[MTYPE_ARG]);
if (!isGeneric) {
- names[CHECK_TYPE] = new Name(NF_checkExactType, names[CALL_MH], mtypeArg);
+ names[CHECK_TYPE] = new Name(getFunction(NF_checkExactType), names[CALL_MH], mtypeArg);
// mh.invokeExact(a*):R => checkExactType(mh, TYPEOF(a*:R)); mh.invokeBasic(a*)
} else {
- names[CHECK_TYPE] = new Name(NF_checkGenericType, names[CALL_MH], mtypeArg);
+ names[CHECK_TYPE] = new Name(getFunction(NF_checkGenericType), names[CALL_MH], mtypeArg);
// mh.invokeGeneric(a*):R => checkGenericType(mh, TYPEOF(a*:R)).invokeBasic(a*)
outArgs[0] = names[CHECK_TYPE];
}
if (CHECK_CUSTOM != -1) {
- names[CHECK_CUSTOM] = new Name(NF_checkCustomized, outArgs[0]);
+ names[CHECK_CUSTOM] = new Name(getFunction(NF_checkCustomized), outArgs[0]);
}
names[LINKER_CALL] = new Name(outCallType, outArgs);
if (customized) {
@@ -368,7 +368,7 @@ class Invokers {
}
names[VAD_ARG] = new Name(ARG_LIMIT, BasicType.basicType(Object.class));
- names[CHECK_TYPE] = new Name(NF_checkVarHandleGenericType, names[THIS_VH], names[VAD_ARG]);
+ names[CHECK_TYPE] = new Name(getFunction(NF_checkVarHandleGenericType), names[THIS_VH], names[VAD_ARG]);
Object[] outArgs = new Object[ARG_LIMIT + 1];
outArgs[0] = names[CHECK_TYPE];
@@ -377,7 +377,7 @@ class Invokers {
}
if (CHECK_CUSTOM != -1) {
- names[CHECK_CUSTOM] = new Name(NF_checkCustomized, outArgs[0]);
+ names[CHECK_CUSTOM] = new Name(getFunction(NF_checkCustomized), outArgs[0]);
}
MethodType outCallType = mtype.insertParameterTypes(0, VarHandle.class)
@@ -420,9 +420,9 @@ class Invokers {
names[VAD_ARG] = new Name(getter, names[THIS_MH]);
if (isExact) {
- names[CHECK_TYPE] = new Name(NF_checkVarHandleExactType, names[CALL_VH], names[VAD_ARG]);
+ names[CHECK_TYPE] = new Name(getFunction(NF_checkVarHandleExactType), names[CALL_VH], names[VAD_ARG]);
} else {
- names[CHECK_TYPE] = new Name(NF_checkVarHandleGenericType, names[CALL_VH], names[VAD_ARG]);
+ names[CHECK_TYPE] = new Name(getFunction(NF_checkVarHandleGenericType), names[CALL_VH], names[VAD_ARG]);
}
Object[] outArgs = new Object[ARG_LIMIT];
outArgs[0] = names[CHECK_TYPE];
@@ -543,7 +543,7 @@ class Invokers {
assert(names.length == nameCursor);
assert(names[APPENDIX_ARG] != null);
if (!skipCallSite)
- names[CALL_MH] = new Name(NF_getCallSiteTarget, names[CSITE_ARG]);
+ names[CALL_MH] = new Name(getFunction(NF_getCallSiteTarget), names[CSITE_ARG]);
// (site.)invokedynamic(a*):R => mh = site.getTarget(); mh.invokeBasic(a*)
final int PREPEND_MH = 0, PREPEND_COUNT = 1;
Object[] outArgs = Arrays.copyOfRange(names, ARG_BASE, OUTARG_LIMIT + PREPEND_COUNT, Object[].class);
@@ -586,31 +586,51 @@ class Invokers {
}
// Local constant functions:
- private static final NamedFunction
- NF_checkExactType,
- NF_checkGenericType,
- NF_getCallSiteTarget,
- NF_checkCustomized,
- NF_checkVarHandleGenericType,
- NF_checkVarHandleExactType;
- static {
+ private static final byte NF_checkExactType = 0,
+ NF_checkGenericType = 1,
+ NF_getCallSiteTarget = 2,
+ NF_checkCustomized = 3,
+ NF_checkVarHandleGenericType = 4,
+ NF_checkVarHandleExactType = 5,
+ NF_LIMIT = 6;
+
+ private static final @Stable NamedFunction[] NFS = new NamedFunction[NF_LIMIT];
+
+ private static NamedFunction getFunction(byte func) {
+ NamedFunction nf = NFS[func];
+ if (nf != null) {
+ return nf;
+ }
+ NFS[func] = nf = createFunction(func);
+ // Each nf must be statically invocable or we get tied up in our bootstraps.
+ assert(InvokerBytecodeGenerator.isStaticallyInvocable(nf));
+ return nf;
+ }
+
+ private static NamedFunction createFunction(byte func) {
try {
- NamedFunction nfs[] = {
- NF_checkExactType = new NamedFunction(Invokers.class
- .getDeclaredMethod("checkExactType", MethodHandle.class, MethodType.class)),
- NF_checkGenericType = new NamedFunction(Invokers.class
- .getDeclaredMethod("checkGenericType", MethodHandle.class, MethodType.class)),
- NF_getCallSiteTarget = new NamedFunction(Invokers.class
- .getDeclaredMethod("getCallSiteTarget", CallSite.class)),
- NF_checkCustomized = new NamedFunction(Invokers.class
- .getDeclaredMethod("checkCustomized", MethodHandle.class)),
- NF_checkVarHandleGenericType = new NamedFunction(Invokers.class
- .getDeclaredMethod("checkVarHandleGenericType", VarHandle.class, VarHandle.AccessDescriptor.class)),
- NF_checkVarHandleExactType = new NamedFunction(Invokers.class
- .getDeclaredMethod("checkVarHandleExactType", VarHandle.class, VarHandle.AccessDescriptor.class)),
- };
- // Each nf must be statically invocable or we get tied up in our bootstraps.
- assert(InvokerBytecodeGenerator.isStaticallyInvocable(nfs));
+ switch (func) {
+ case NF_checkExactType:
+ return new NamedFunction(Invokers.class
+ .getDeclaredMethod("checkExactType", MethodHandle.class, MethodType.class));
+ case NF_checkGenericType:
+ return new NamedFunction(Invokers.class
+ .getDeclaredMethod("checkGenericType", MethodHandle.class, MethodType.class));
+ case NF_getCallSiteTarget:
+ return new NamedFunction(Invokers.class
+ .getDeclaredMethod("getCallSiteTarget", CallSite.class));
+ case NF_checkCustomized:
+ return new NamedFunction(Invokers.class
+ .getDeclaredMethod("checkCustomized", MethodHandle.class));
+ case NF_checkVarHandleGenericType:
+ return new NamedFunction(Invokers.class
+ .getDeclaredMethod("checkVarHandleGenericType", VarHandle.class, VarHandle.AccessDescriptor.class));
+ case NF_checkVarHandleExactType:
+ return new NamedFunction(Invokers.class
+ .getDeclaredMethod("checkVarHandleExactType", VarHandle.class, VarHandle.AccessDescriptor.class));
+ default:
+ throw newInternalError("Unknown function: " + func);
+ }
} catch (ReflectiveOperationException ex) {
throw newInternalError(ex);
}
diff --git a/jdk/src/java.base/share/classes/java/lang/invoke/LambdaForm.java b/jdk/src/java.base/share/classes/java/lang/invoke/LambdaForm.java
index 0048afbfd9e..bde94381ddc 100644
--- a/jdk/src/java.base/share/classes/java/lang/invoke/LambdaForm.java
+++ b/jdk/src/java.base/share/classes/java/lang/invoke/LambdaForm.java
@@ -270,21 +270,21 @@ class LambdaForm {
GENERIC("invoke"),
ZERO("zero"),
IDENTITY("identity"),
- BOUND_REINVOKER("BMH.reinvoke"),
- REINVOKER("MH.reinvoke"),
- DELEGATE("MH.delegate"),
- EXACT_LINKER("MH.invokeExact_MT"),
- EXACT_INVOKER("MH.exactInvoker"),
- GENERIC_LINKER("MH.invoke_MT"),
- GENERIC_INVOKER("MH.invoker"),
+ BOUND_REINVOKER("BMH.reinvoke", "reinvoke"),
+ REINVOKER("MH.reinvoke", "reinvoke"),
+ DELEGATE("MH.delegate", "delegate"),
+ EXACT_LINKER("MH.invokeExact_MT", "invokeExact_MT"),
+ EXACT_INVOKER("MH.exactInvoker", "exactInvoker"),
+ GENERIC_LINKER("MH.invoke_MT", "invoke_MT"),
+ GENERIC_INVOKER("MH.invoker", "invoker"),
LINK_TO_TARGET_METHOD("linkToTargetMethod"),
LINK_TO_CALL_SITE("linkToCallSite"),
- DIRECT_INVOKE_VIRTUAL("DMH.invokeVirtual"),
- DIRECT_INVOKE_SPECIAL("DMH.invokeSpecial"),
- DIRECT_INVOKE_STATIC("DMH.invokeStatic"),
- DIRECT_NEW_INVOKE_SPECIAL("DMH.newInvokeSpecial"),
- DIRECT_INVOKE_INTERFACE("DMH.invokeInterface"),
- DIRECT_INVOKE_STATIC_INIT("DMH.invokeStaticInit"),
+ DIRECT_INVOKE_VIRTUAL("DMH.invokeVirtual", "invokeVirtual"),
+ DIRECT_INVOKE_SPECIAL("DMH.invokeSpecial", "invokeSpecial"),
+ DIRECT_INVOKE_STATIC("DMH.invokeStatic", "invokeStatic"),
+ DIRECT_NEW_INVOKE_SPECIAL("DMH.newInvokeSpecial", "newInvokeSpecial"),
+ DIRECT_INVOKE_INTERFACE("DMH.invokeInterface", "invokeInterface"),
+ DIRECT_INVOKE_STATIC_INIT("DMH.invokeStaticInit", "invokeStaticInit"),
GET_OBJECT("getObject"),
PUT_OBJECT("putObject"),
GET_OBJECT_VOLATILE("getObjectVolatile"),
@@ -330,20 +330,19 @@ class LambdaForm {
GUARD("guard"),
GUARD_WITH_CATCH("guardWithCatch"),
VARHANDLE_EXACT_INVOKER("VH.exactInvoker"),
- VARHANDLE_INVOKER("VH.invoker"),
- VARHANDLE_LINKER("VH.invoke_MT");
+ VARHANDLE_INVOKER("VH.invoker", "invoker"),
+ VARHANDLE_LINKER("VH.invoke_MT", "invoke_MT");
final String defaultLambdaName;
final String methodName;
private Kind(String defaultLambdaName) {
+ this(defaultLambdaName, defaultLambdaName);
+ }
+
+ private Kind(String defaultLambdaName, String methodName) {
this.defaultLambdaName = defaultLambdaName;
- int p = defaultLambdaName.indexOf('.');
- if (p > -1) {
- this.methodName = defaultLambdaName.substring(p + 1);
- } else {
- this.methodName = defaultLambdaName;
- }
+ this.methodName = methodName;
}
}
@@ -642,7 +641,7 @@ class LambdaForm {
for (int i = 0; i < arity; ++i) {
ptypes[i] = parameterType(i).btClass;
}
- return MethodType.methodType(returnType().btClass, ptypes);
+ return MethodType.makeImpl(returnType().btClass, ptypes, true);
}
/** Return ABC_Z, where the ABC are parameter type characters, and Z is the return type character. */
@@ -678,7 +677,7 @@ class LambdaForm {
for (int i = 0; i < ptypes.length; i++)
ptypes[i] = basicType(sig.charAt(i)).btClass;
Class> rtype = signatureReturn(sig).btClass;
- return MethodType.methodType(rtype, ptypes);
+ return MethodType.makeImpl(rtype, ptypes, true);
}
/**
@@ -848,6 +847,10 @@ class LambdaForm {
if (vmentry != null && isCompiled) {
return; // already compiled somehow
}
+
+ // Obtain the invoker MethodType outside of the following try block.
+ // This ensures that an IllegalArgumentException is directly thrown if the
+ // type would have 256 or more parameters
MethodType invokerType = methodType();
assert(vmentry == null || vmentry.getMethodType().basicType().equals(invokerType));
try {
@@ -902,10 +905,6 @@ class LambdaForm {
}
return true;
}
- private static boolean returnTypesMatch(String sig, Object[] av, Object res) {
- MethodHandle mh = (MethodHandle) av[0];
- return valueMatches(signatureReturn(sig), mh.type().returnType(), res);
- }
private static boolean checkInt(Class> type, Object x) {
assert(x instanceof Integer);
if (type == int.class) return true;
@@ -1180,7 +1179,6 @@ class LambdaForm {
// If we have a cached invoker, call it right away.
// NOTE: The invoker always returns a reference value.
if (TRACE_INTERPRETER) return invokeWithArgumentsTracing(arguments);
- assert(checkArgumentTypes(arguments, methodType()));
return invoker().invokeBasic(resolvedHandle(), arguments);
}
@@ -1198,7 +1196,6 @@ class LambdaForm {
traceInterpreter("| resolve", this);
resolvedHandle();
}
- assert(checkArgumentTypes(arguments, methodType()));
rval = invoker().invokeBasic(resolvedHandle(), arguments);
} catch (Throwable ex) {
traceInterpreter("] throw =>", ex);
@@ -1214,23 +1211,6 @@ class LambdaForm {
return invoker = computeInvoker(methodType().form());
}
- private static boolean checkArgumentTypes(Object[] arguments, MethodType methodType) {
- if (true) return true; // FIXME
- MethodType dstType = methodType.form().erasedType();
- MethodType srcType = dstType.basicType().wrap();
- Class>[] ptypes = new Class>[arguments.length];
- for (int i = 0; i < arguments.length; i++) {
- Object arg = arguments[i];
- Class> ptype = arg == null ? Object.class : arg.getClass();
- // If the dest. type is a primitive we keep the
- // argument type.
- ptypes[i] = dstType.parameterType(i).isPrimitive() ? ptype : Object.class;
- }
- MethodType argType = MethodType.methodType(srcType.returnType(), ptypes).wrap();
- assert(argType.isConvertibleTo(srcType)) : "wrong argument types: cannot convert " + argType + " to " + srcType;
- return true;
- }
-
MethodType methodType() {
if (resolvedHandle != null)
return resolvedHandle.type();
@@ -1726,7 +1706,7 @@ class LambdaForm {
boolean isVoid = (type == V_TYPE);
Class> btClass = type.btClass;
MethodType zeType = MethodType.methodType(btClass);
- MethodType idType = (isVoid) ? zeType : zeType.appendParameterTypes(btClass);
+ MethodType idType = (isVoid) ? zeType : MethodType.methodType(btClass, btClass);
// Look up symbolic names. It might not be necessary to have these,
// but if we need to emit direct references to bytecodes, it helps.
diff --git a/jdk/src/java.base/share/classes/java/lang/invoke/LambdaFormEditor.java b/jdk/src/java.base/share/classes/java/lang/invoke/LambdaFormEditor.java
index 2d9c87ad0d4..e066a60838c 100644
--- a/jdk/src/java.base/share/classes/java/lang/invoke/LambdaFormEditor.java
+++ b/jdk/src/java.base/share/classes/java/lang/invoke/LambdaFormEditor.java
@@ -532,7 +532,8 @@ class LambdaFormEditor {
assert(pos > 0); // cannot spread the MH arg itself
Name spreadParam = new Name(L_TYPE);
- Name checkSpread = new Name(MethodHandleImpl.NF_checkSpreadArgument, spreadParam, arrayLength);
+ Name checkSpread = new Name(MethodHandleImpl.getFunction(MethodHandleImpl.NF_checkSpreadArgument),
+ spreadParam, arrayLength);
// insert the new expressions
int exprPos = lambdaForm.arity();
@@ -932,14 +933,14 @@ class LambdaFormEditor {
// replace the null entry in the MHImpl.loop invocation with localTypes
Name invokeLoop = lambdaForm.names[pos + 1];
- assert(invokeLoop.function == NF_loop);
+ assert(invokeLoop.function.equals(MethodHandleImpl.getFunction(NF_loop)));
Object[] args = Arrays.copyOf(invokeLoop.arguments, invokeLoop.arguments.length);
assert(args[0] == null);
args[0] = localTypes;
LambdaFormBuffer buf = buffer();
buf.startEdit();
- buf.changeName(pos + 1, new Name(NF_loop, args));
+ buf.changeName(pos + 1, new Name(MethodHandleImpl.getFunction(NF_loop), args));
form = buf.endEdit();
return putInCache(key, form);
diff --git a/jdk/src/java.base/share/classes/java/lang/invoke/MemberName.java b/jdk/src/java.base/share/classes/java/lang/invoke/MemberName.java
index 97efa4f1066..41a4545d6bb 100644
--- a/jdk/src/java.base/share/classes/java/lang/invoke/MemberName.java
+++ b/jdk/src/java.base/share/classes/java/lang/invoke/MemberName.java
@@ -33,7 +33,6 @@ import java.lang.reflect.Field;
import java.lang.reflect.Member;
import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
-import java.lang.reflect.Module;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Iterator;
@@ -149,7 +148,7 @@ import static java.lang.invoke.MethodHandleStatics.newInternalError;
Object[] typeInfo = (Object[]) type;
Class>[] ptypes = (Class>[]) typeInfo[1];
Class> rtype = (Class>) typeInfo[0];
- MethodType res = MethodType.methodType(rtype, ptypes);
+ MethodType res = MethodType.makeImpl(rtype, ptypes, true);
type = res;
}
// Make sure type is a MethodType for racing threads.
diff --git a/jdk/src/java.base/share/classes/java/lang/invoke/MethodHandleImpl.java b/jdk/src/java.base/share/classes/java/lang/invoke/MethodHandleImpl.java
index 8ea5553fccc..a12fa138252 100644
--- a/jdk/src/java.base/share/classes/java/lang/invoke/MethodHandleImpl.java
+++ b/jdk/src/java.base/share/classes/java/lang/invoke/MethodHandleImpl.java
@@ -589,7 +589,7 @@ import static jdk.internal.org.objectweb.asm.Opcodes.*;
// Spread the array.
MethodHandle aload = MethodHandles.arrayElementGetter(spreadArgType);
Name array = names[argIndex];
- names[nameCursor++] = new Name(NF_checkSpreadArgument, array, spreadArgCount);
+ names[nameCursor++] = new Name(getFunction(NF_checkSpreadArgument), array, spreadArgCount);
for (int j = 0; j < spreadArgCount; i++, j++) {
indexes[i] = nameCursor;
names[nameCursor++] = new Name(aload, array, j);
@@ -934,7 +934,7 @@ import static jdk.internal.org.objectweb.asm.Opcodes.*;
// profile branch
if (PROFILE != -1) {
- names[PROFILE] = new Name(NF_profileBoolean, names[CALL_TEST], names[GET_COUNTERS]);
+ names[PROFILE] = new Name(getFunction(NF_profileBoolean), names[CALL_TEST], names[GET_COUNTERS]);
}
// call selectAlternative
names[SELECT_ALT] = new Name(getConstantHandle(MH_selectAlternative), names[TEST], names[GET_TARGET], names[GET_FALLBACK]);
@@ -1012,7 +1012,7 @@ import static jdk.internal.org.objectweb.asm.Opcodes.*;
// t_{i+1}:L=MethodHandleImpl.guardWithCatch(target:L,exType:L,catcher:L,t_{i}:L);
Object[] gwcArgs = new Object[] {names[GET_TARGET], names[GET_CLASS], names[GET_CATCHER], names[BOXED_ARGS]};
- names[TRY_CATCH] = new Name(NF_guardWithCatch, gwcArgs);
+ names[TRY_CATCH] = new Name(getFunction(NF_guardWithCatch), gwcArgs);
// t_{i+2}:I=MethodHandle.invokeBasic(unbox:L,t_{i+1}:L);
MethodHandle invokeBasicUnbox = MethodHandles.basicInvoker(MethodType.methodType(basicType.rtype(), Object.class));
@@ -1085,7 +1085,7 @@ import static jdk.internal.org.objectweb.asm.Opcodes.*;
mh = MethodHandles.dropArguments(mh, 1, Arrays.copyOfRange(type.parameterArray(), 1, arity));
return mh;
}
- return makePairwiseConvert(NF_throwException.resolvedHandle(), type, false, true);
+ return makePairwiseConvert(getFunction(NF_throwException).resolvedHandle(), type, false, true);
}
static Empty throwException(T t) throws T { throw t; }
@@ -1673,33 +1673,57 @@ import static jdk.internal.org.objectweb.asm.Opcodes.*;
}
// Local constant functions:
- /*non-public*/ static final NamedFunction
- NF_checkSpreadArgument,
- NF_guardWithCatch,
- NF_throwException,
- NF_tryFinally,
- NF_loop,
- NF_profileBoolean;
- static {
+ /* non-public */
+ static final byte NF_checkSpreadArgument = 0,
+ NF_guardWithCatch = 1,
+ NF_throwException = 2,
+ NF_tryFinally = 3,
+ NF_loop = 4,
+ NF_profileBoolean = 5,
+ NF_LIMIT = 6;
+
+ private static final @Stable NamedFunction[] NFS = new NamedFunction[NF_LIMIT];
+
+ static NamedFunction getFunction(byte func) {
+ NamedFunction nf = NFS[func];
+ if (nf != null) {
+ return nf;
+ }
+ return NFS[func] = createFunction(func);
+ }
+
+ private static NamedFunction createFunction(byte func) {
try {
- NF_checkSpreadArgument = new NamedFunction(MethodHandleImpl.class
- .getDeclaredMethod("checkSpreadArgument", Object.class, int.class));
- NF_guardWithCatch = new NamedFunction(MethodHandleImpl.class
- .getDeclaredMethod("guardWithCatch", MethodHandle.class, Class.class,
- MethodHandle.class, Object[].class));
- NF_tryFinally = new NamedFunction(MethodHandleImpl.class
- .getDeclaredMethod("tryFinally", MethodHandle.class, MethodHandle.class, Object[].class));
- NF_loop = new NamedFunction(MethodHandleImpl.class
- .getDeclaredMethod("loop", BasicType[].class, LoopClauses.class, Object[].class));
- NF_throwException = new NamedFunction(MethodHandleImpl.class
- .getDeclaredMethod("throwException", Throwable.class));
- NF_profileBoolean = new NamedFunction(MethodHandleImpl.class
- .getDeclaredMethod("profileBoolean", boolean.class, int[].class));
+ switch (func) {
+ case NF_checkSpreadArgument:
+ return new NamedFunction(MethodHandleImpl.class
+ .getDeclaredMethod("checkSpreadArgument", Object.class, int.class));
+ case NF_guardWithCatch:
+ return new NamedFunction(MethodHandleImpl.class
+ .getDeclaredMethod("guardWithCatch", MethodHandle.class, Class.class,
+ MethodHandle.class, Object[].class));
+ case NF_tryFinally:
+ return new NamedFunction(MethodHandleImpl.class
+ .getDeclaredMethod("tryFinally", MethodHandle.class, MethodHandle.class, Object[].class));
+ case NF_loop:
+ return new NamedFunction(MethodHandleImpl.class
+ .getDeclaredMethod("loop", BasicType[].class, LoopClauses.class, Object[].class));
+ case NF_throwException:
+ return new NamedFunction(MethodHandleImpl.class
+ .getDeclaredMethod("throwException", Throwable.class));
+ case NF_profileBoolean:
+ return new NamedFunction(MethodHandleImpl.class
+ .getDeclaredMethod("profileBoolean", boolean.class, int[].class));
+ default:
+ throw new InternalError("Undefined function: " + func);
+ }
} catch (ReflectiveOperationException ex) {
throw newInternalError(ex);
}
+ }
+ static {
SharedSecrets.setJavaLangInvokeAccess(new JavaLangInvokeAccess() {
@Override
public Object newMemberName() {
@@ -1878,7 +1902,7 @@ import static jdk.internal.org.objectweb.asm.Opcodes.*;
Object[] lArgs =
new Object[]{null, // placeholder for BasicType[] localTypes - will be added by LambdaFormEditor
names[GET_CLAUSE_DATA], names[BOXED_ARGS]};
- names[LOOP] = new Name(NF_loop, lArgs);
+ names[LOOP] = new Name(getFunction(NF_loop), lArgs);
// t_{i+2}:I=MethodHandle.invokeBasic(unbox:L,t_{i+1}:L);
MethodHandle invokeBasicUnbox = MethodHandles.basicInvoker(MethodType.methodType(basicType.rtype(), Object.class));
@@ -2113,7 +2137,7 @@ import static jdk.internal.org.objectweb.asm.Opcodes.*;
// t_{i+1}:L=MethodHandleImpl.tryFinally(target:L,exType:L,catcher:L,t_{i}:L);
Object[] tfArgs = new Object[] {names[GET_TARGET], names[GET_CLEANUP], names[BOXED_ARGS]};
- names[TRY_FINALLY] = new Name(NF_tryFinally, tfArgs);
+ names[TRY_FINALLY] = new Name(getFunction(NF_tryFinally), tfArgs);
// t_{i+2}:I=MethodHandle.invokeBasic(unbox:L,t_{i+1}:L);
MethodHandle invokeBasicUnbox = MethodHandles.basicInvoker(MethodType.methodType(basicType.rtype(), Object.class));
diff --git a/jdk/src/java.base/share/classes/java/lang/invoke/MethodHandles.java b/jdk/src/java.base/share/classes/java/lang/invoke/MethodHandles.java
index 8f7059ec47e..afd8d9b2819 100644
--- a/jdk/src/java.base/share/classes/java/lang/invoke/MethodHandles.java
+++ b/jdk/src/java.base/share/classes/java/lang/invoke/MethodHandles.java
@@ -43,7 +43,6 @@ import java.lang.reflect.Field;
import java.lang.reflect.Member;
import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
-import java.lang.reflect.Module;
import java.lang.reflect.ReflectPermission;
import java.nio.ByteOrder;
import java.security.AccessController;
@@ -668,11 +667,11 @@ public class MethodHandles {
* The value is {@code 0x20}, which does not correspond meaningfully to
* any particular {@linkplain java.lang.reflect.Modifier modifier bit}.
* A {@code Lookup} with this lookup mode assumes {@linkplain
- * java.lang.reflect.Module#canRead(java.lang.reflect.Module) readability}.
+ * java.lang.Module#canRead(java.lang.Module) readability}.
* In conjunction with the {@code PUBLIC} modifier bit, a {@code Lookup}
* with this lookup mode can access all public members of public types
* of all modules where the type is in a package that is {@link
- * java.lang.reflect.Module#isExported(String) exported unconditionally}.
+ * java.lang.Module#isExported(String) exported unconditionally}.
* @since 9
* @spec JPMS
* @see #publicLookup()
diff --git a/jdk/src/java.base/share/classes/java/lang/invoke/MethodType.java b/jdk/src/java.base/share/classes/java/lang/invoke/MethodType.java
index 860ef23f019..df7904de00d 100644
--- a/jdk/src/java.base/share/classes/java/lang/invoke/MethodType.java
+++ b/jdk/src/java.base/share/classes/java/lang/invoke/MethodType.java
@@ -95,7 +95,7 @@ class MethodType implements java.io.Serializable {
private static final long serialVersionUID = 292L; // {rtype, {ptype...}}
// The rtype and ptypes fields define the structural identity of the method type:
- private final Class> rtype;
+ private final @Stable Class> rtype;
private final @Stable Class>[] ptypes;
// The remaining fields are caches of various sorts:
@@ -117,7 +117,8 @@ class MethodType implements java.io.Serializable {
/**
* Construct a temporary unchecked instance of MethodType for use only as a key to the intern table.
- * Does not check the given parameters for validity, and must be discarded after it is used as a searching key.
+ * Does not check the given parameters for validity, and must discarded (if untrusted) or checked
+ * (if trusted) after it has been used as a searching key.
* The parameters are reversed for this constructor, so that it is not accidentally used.
*/
private MethodType(Class>[] ptypes, Class> rtype) {
@@ -181,6 +182,7 @@ class MethodType implements java.io.Serializable {
checkSlotCount(ptypes.length + slots);
return slots;
}
+
static {
// MAX_JVM_ARITY must be power of 2 minus 1 for following code trick to work:
assert((MAX_JVM_ARITY & (MAX_JVM_ARITY+1)) == 0);
@@ -303,18 +305,26 @@ class MethodType implements java.io.Serializable {
*/
/*trusted*/ static
MethodType makeImpl(Class> rtype, Class>[] ptypes, boolean trusted) {
- MethodType mt = internTable.get(new MethodType(ptypes, rtype));
- if (mt != null)
- return mt;
if (ptypes.length == 0) {
ptypes = NO_PTYPES; trusted = true;
}
- mt = new MethodType(rtype, ptypes, trusted);
+ MethodType primordialMT = new MethodType(ptypes, rtype);
+ MethodType mt = internTable.get(primordialMT);
+ if (mt != null)
+ return mt;
+
// promote the object to the Real Thing, and reprobe
+ if (trusted) {
+ MethodType.checkRtype(rtype);
+ MethodType.checkPtypes(ptypes);
+ mt = primordialMT;
+ } else {
+ mt = new MethodType(rtype, ptypes, false);
+ }
mt.form = MethodTypeForm.findForm(mt);
return internTable.add(mt);
}
- private static final MethodType[] objectOnlyTypes = new MethodType[20];
+ private static final @Stable MethodType[] objectOnlyTypes = new MethodType[20];
/**
* Finds or creates a method type whose components are {@code Object} with an optional trailing {@code Object[]} array.
@@ -398,9 +408,14 @@ class MethodType implements java.io.Serializable {
checkSlotCount(parameterSlotCount() + ptypesToInsert.length + ins);
int ilen = ptypesToInsert.length;
if (ilen == 0) return this;
- Class>[] nptypes = Arrays.copyOfRange(ptypes, 0, len+ilen);
- System.arraycopy(nptypes, num, nptypes, num+ilen, len-num);
+ Class>[] nptypes = new Class>[len + ilen];
+ if (num > 0) {
+ System.arraycopy(ptypes, 0, nptypes, 0, num);
+ }
System.arraycopy(ptypesToInsert, 0, nptypes, num, ilen);
+ if (num < len) {
+ System.arraycopy(ptypes, num, nptypes, num+ilen, len-num);
+ }
return makeImpl(rtype, nptypes, true);
}
@@ -636,11 +651,14 @@ class MethodType implements java.io.Serializable {
return form.basicType();
}
+ private static final @Stable Class>[] METHOD_HANDLE_ARRAY
+ = new Class>[] { MethodHandle.class };
+
/**
* @return a version of the original type with MethodHandle prepended as the first argument
*/
/*non-public*/ MethodType invokerType() {
- return insertParameterTypes(0, MethodHandle.class);
+ return insertParameterTypes(0, METHOD_HANDLE_ARRAY);
}
/**
diff --git a/jdk/src/java.base/share/classes/java/lang/module/Configuration.java b/jdk/src/java.base/share/classes/java/lang/module/Configuration.java
index dfd5fe87b7e..d5fc16c1ef6 100644
--- a/jdk/src/java.base/share/classes/java/lang/module/Configuration.java
+++ b/jdk/src/java.base/share/classes/java/lang/module/Configuration.java
@@ -64,11 +64,11 @@ import java.util.stream.Stream;
* with the receiver as the parent configuration. The static methods are for
* more advanced cases where there can be more than one parent configuration.
*
- * Each {@link java.lang.reflect.Layer layer} of modules in the Java virtual
+ *
Each {@link java.lang.ModuleLayer layer} of modules in the Java virtual
* machine is created from a configuration. The configuration for the {@link
- * java.lang.reflect.Layer#boot() boot} layer is obtained by invoking {@code
- * Layer.boot().configuration()}. The configuration for the boot layer will
- * often be the parent when creating new configurations.
+ * java.lang.ModuleLayer#boot() boot} layer is obtained by invoking {@code
+ * ModuleLayer.boot().configuration()}. The configuration for the boot layer
+ * will often be the parent when creating new configurations.
*
* Example
*
@@ -81,7 +81,7 @@ import java.util.stream.Stream;
* {@code
* ModuleFinder finder = ModuleFinder.of(dir1, dir2, dir3);
*
- * Configuration parent = Layer.boot().configuration();
+ * Configuration parent = ModuleLayer.boot().configuration();
*
* Configuration cf = parent.resolve(finder, ModuleFinder.of(), Set.of("myapp"));
* cf.modules().forEach(m -> {
@@ -95,7 +95,7 @@ import java.util.stream.Stream;
*
* @since 9
* @spec JPMS
- * @see java.lang.reflect.Layer
+ * @see java.lang.ModuleLayer
*/
public final class Configuration {
diff --git a/jdk/src/java.base/share/classes/java/lang/module/ModuleDescriptor.java b/jdk/src/java.base/share/classes/java/lang/module/ModuleDescriptor.java
index e2438d718df..01b4316fa20 100644
--- a/jdk/src/java.base/share/classes/java/lang/module/ModuleDescriptor.java
+++ b/jdk/src/java.base/share/classes/java/lang/module/ModuleDescriptor.java
@@ -60,7 +60,7 @@ import jdk.internal.module.ModuleInfo;
* A module descriptor describes a named module and defines methods to
* obtain each of its components. The module descriptor for a named module
* in the Java virtual machine is obtained by invoking the {@link
- * java.lang.reflect.Module Module}'s {@link java.lang.reflect.Module#getDescriptor
+ * java.lang.Module Module}'s {@link java.lang.Module#getDescriptor
* getDescriptor} method. Module descriptors can also be created using the
* {@link ModuleDescriptor.Builder} class or by reading the binary form of a
* module declaration ({@code module-info.class}) using the {@link
@@ -85,7 +85,7 @@ import jdk.internal.module.ModuleInfo;
*
{@code ModuleDescriptor} objects are immutable and safe for use by
* multiple concurrent threads.
*
- * @see java.lang.reflect.Module
+ * @see java.lang.Module
* @since 9
* @spec JPMS
*/
@@ -2110,7 +2110,9 @@ public class ModuleDescriptor
/**
* Sets the module main class. The package for the main class is added
- * to the module if not already added.
+ * to the module if not already added. In other words, this method is
+ * equivalent to first invoking this builder's {@link #packages(Set)
+ * packages} method to add the package name of the main class.
*
* @param mc
* The module main class
@@ -2134,8 +2136,8 @@ public class ModuleDescriptor
throw new IllegalArgumentException(mc + ": unnamed package");
}
}
- mainClass = mc;
packages.add(pn);
+ mainClass = mc;
return this;
}
diff --git a/jdk/src/java.base/share/classes/java/lang/module/ModuleFinder.java b/jdk/src/java.base/share/classes/java/lang/module/ModuleFinder.java
index 97c74f64209..0be9d8d9eff 100644
--- a/jdk/src/java.base/share/classes/java/lang/module/ModuleFinder.java
+++ b/jdk/src/java.base/share/classes/java/lang/module/ModuleFinder.java
@@ -228,14 +228,14 @@ public interface ModuleFinder {
* directory is treated as an exploded module rather than a directory of
* modules.
*
- * The module finder returned by this method supports modules that are
- * packaged as JAR files. A JAR file with a {@code module-info.class} in
- * the top-level directory of the JAR file (or overridden by a versioned
- * entry in a {@link java.util.jar.JarFile#isMultiRelease() multi-release}
- * JAR file) is a modular JAR and is an explicit module .
- * A JAR file that does not have a {@code module-info.class} in the
- * top-level directory is created as an automatic module. The components
- * for the automatic module are derived as follows:
+ *
The module finder returned by this method
+ * supports modules packaged as JAR files. A JAR file with a {@code
+ * module-info.class} in its top-level directory, or in a versioned entry
+ * in a {@linkplain java.util.jar.JarFile#isMultiRelease() multi-release}
+ * JAR file, is a modular JAR file and thus defines an explicit
+ * module. A JAR file that does not have a {@code module-info.class} in its
+ * top-level directory defines an automatic module , as follows:
+ *
*
*
*
@@ -254,16 +254,16 @@ public interface ModuleFinder {
* ModuleDescriptor.Version} and ignored if it cannot be parsed as
* a {@code Version}.
*
- * For the module name, then any trailing digits and dots
- * are removed, all non-alphanumeric characters ({@code [^A-Za-z0-9]})
- * are replaced with a dot ({@code "."}), all repeating dots are
- * replaced with one dot, and all leading and trailing dots are
- * removed.
+ * All non-alphanumeric characters ({@code [^A-Za-z0-9]})
+ * in the module name are replaced with a dot ({@code "."}), all
+ * repeating dots are replaced with one dot, and all leading and
+ * trailing dots are removed.
*
* As an example, a JAR file named {@code foo-bar.jar} will
* derive a module name {@code foo.bar} and no version. A JAR file
- * named {@code foo-1.2.3-SNAPSHOT.jar} will derive a module name
- * {@code foo} and {@code 1.2.3-SNAPSHOT} as the version.
+ * named {@code foo-bar-1.2.3-SNAPSHOT.jar} will derive a module
+ * name {@code foo.bar} and {@code 1.2.3-SNAPSHOT} as the version.
+ *
*
*
*
@@ -312,7 +312,9 @@ public interface ModuleFinder {
*
* As with automatic modules, the contents of a packaged or exploded
* module may need to be scanned in order to determine the packages
- * in the module. If a {@code .class} file (other than {@code
+ * in the module. Whether {@linkplain java.nio.file.Files#isHidden(Path)
+ * hidden files} are ignored or not is implementation specific and therefore
+ * not specified. If a {@code .class} file (other than {@code
* module-info.class}) is found in the top-level directory then it is
* assumed to be a class in the unnamed package and so {@code FindException}
* is thrown.
diff --git a/jdk/src/java.base/share/classes/java/lang/module/Resolver.java b/jdk/src/java.base/share/classes/java/lang/module/Resolver.java
index b585ac63165..6adf93f8317 100644
--- a/jdk/src/java.base/share/classes/java/lang/module/Resolver.java
+++ b/jdk/src/java.base/share/classes/java/lang/module/Resolver.java
@@ -28,7 +28,6 @@ package java.lang.module;
import java.io.PrintStream;
import java.lang.module.ModuleDescriptor.Provides;
import java.lang.module.ModuleDescriptor.Requires.Modifier;
-import java.lang.reflect.Layer;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
@@ -67,6 +66,9 @@ final class Resolver {
// maps module name to module reference
private final Map nameToReference = new HashMap<>();
+ // true if all automatic modules have been found
+ private boolean haveAllAutomaticModules;
+
// module constraints on target platform
private String osName;
private String osArch;
@@ -171,6 +173,21 @@ final class Resolver {
ModuleDescriptor descriptor = q.poll();
assert nameToReference.containsKey(descriptor.name());
+ // if the module is an automatic module then all automatic
+ // modules need to be resolved
+ if (descriptor.isAutomatic() && !haveAllAutomaticModules) {
+ addFoundAutomaticModules().forEach(mref -> {
+ ModuleDescriptor other = mref.descriptor();
+ q.offer(other);
+ if (isTracing()) {
+ trace("Automatic module %s located, required by %s",
+ other.name(), descriptor.name());
+ mref.location().ifPresent(uri -> trace(" (%s)", uri));
+ }
+ });
+ haveAllAutomaticModules = true;
+ }
+
// process dependences
for (ModuleDescriptor.Requires requires : descriptor.requires()) {
@@ -199,10 +216,15 @@ final class Resolver {
if (!nameToReference.containsKey(dn)) {
addFoundModule(mref);
q.offer(mref.descriptor());
- resolved.add(mref.descriptor());
if (isTracing()) {
- trace("Module %s located, required by %s",
+ String prefix;
+ if (mref.descriptor().isAutomatic()) {
+ prefix = "Automatic module";
+ } else {
+ prefix = "Module";
+ }
+ trace(prefix + " %s located, required by %s",
dn, descriptor.name());
mref.location().ifPresent(uri -> trace(" (%s)", uri));
}
@@ -250,7 +272,7 @@ final class Resolver {
// the initial set of modules that may use services
Set initialConsumers;
- if (Layer.boot() == null) {
+ if (ModuleLayer.boot() == null) {
initialConsumers = new HashSet<>();
} else {
initialConsumers = parents.stream()
@@ -301,6 +323,21 @@ final class Resolver {
return this;
}
+ /**
+ * Add all automatic modules that have not already been found to the
+ * nameToReference map.
+ */
+ private Set addFoundAutomaticModules() {
+ Set result = new HashSet<>();
+ findAll().forEach(mref -> {
+ String mn = mref.descriptor().name();
+ if (mref.descriptor().isAutomatic() && !nameToReference.containsKey(mn)) {
+ addFoundModule(mref);
+ result.add(mref);
+ }
+ });
+ return result;
+ }
/**
* Add the module to the nameToReference map. Also check any constraints on
@@ -534,7 +571,7 @@ final class Resolver {
// need "requires transitive" from the modules in parent configurations
// as there may be selected modules that have a dependency on modules in
// the parent configuration.
- if (Layer.boot() == null) {
+ if (ModuleLayer.boot() == null) {
g2 = new HashMap<>(capacity);
} else {
g2 = parents.stream()
diff --git a/jdk/src/java.base/share/classes/java/lang/module/package-info.java b/jdk/src/java.base/share/classes/java/lang/module/package-info.java
index 1d830079cab..b531f13748c 100644
--- a/jdk/src/java.base/share/classes/java/lang/module/package-info.java
+++ b/jdk/src/java.base/share/classes/java/lang/module/package-info.java
@@ -70,7 +70,7 @@
* }
*
* If module {@code m1} is resolved with the configuration for the {@link
- * java.lang.reflect.Layer#boot() boot} layer as the parent then the resulting
+ * java.lang.ModuleLayer#boot() boot} layer as the parent then the resulting
* configuration contains two modules ({@code m1}, {@code m2}). The edges in
* its readability graph are:
*
{@code
@@ -92,10 +92,10 @@
*
* {@link java.lang.module.ModuleDescriptor#isAutomatic() Automatic} modules
* receive special treatment during resolution. Each automatic module is resolved
- * so that it reads all other modules in the configuration and all parent
- * configurations. Each automatic module is also resolved as if it
- * "{@code requires transitive}" all other automatic modules in the configuration
- * (and all automatic modules in parent configurations).
+ * as if it "{@code requires transitive}" all observable automatic modules and
+ * all automatic modules in the parent configurations. Each automatic module is
+ * resolved so that it reads all other modules in the resulting configuration and
+ * all modules in parent configurations.
*
*
*
diff --git a/jdk/src/java.base/share/classes/java/lang/reflect/Proxy.java b/jdk/src/java.base/share/classes/java/lang/reflect/Proxy.java
index b4b4a07c807..c47caad95a5 100644
--- a/jdk/src/java.base/share/classes/java/lang/reflect/Proxy.java
+++ b/jdk/src/java.base/share/classes/java/lang/reflect/Proxy.java
@@ -227,11 +227,11 @@ import static java.lang.module.ModuleDescriptor.Modifier.SYNTHETIC;
* {@code Proxy.newProxyInstance} method should be used instead.
*
*
- * A dynamic module can read the modules of all of the superinterfaces of a proxy class
- * and the modules of the types referenced by all public method signatures
+ * A dynamic module can read the modules of all of the superinterfaces of a proxy
+ * class and the modules of the types referenced by all public method signatures
* of a proxy class. If a superinterface or a referenced type, say {@code T},
- * is in a non-exported package, the {@linkplain java.lang.reflect.Module module}
- * of {@code T} is updated to export the package of {@code T} to the dynamic module.
+ * is in a non-exported package, the {@linkplain Module module} of {@code T} is
+ * updated to export the package of {@code T} to the dynamic module.
*
*
Methods Duplicated in Multiple Proxy Interfaces
*
diff --git a/jdk/src/java.base/share/classes/java/lang/reflect/package-info.java b/jdk/src/java.base/share/classes/java/lang/reflect/package-info.java
index 97800b1ce13..e771f31cea1 100644
--- a/jdk/src/java.base/share/classes/java/lang/reflect/package-info.java
+++ b/jdk/src/java.base/share/classes/java/lang/reflect/package-info.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1998, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1998, 2017, 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,10 @@
/**
* Provides classes and interfaces for obtaining reflective information about
- * modules, classes and objects. Reflection allows programmatic access to
- * information about modules and to the fields, methods and constructors of
- * loaded classes, and the use of reflected fields, methods, and constructors
- * to operate on their underlying counterparts, within encapsulation and
- * security restrictions.
+ * classes and objects. Reflection allows programmatic access to information
+ * about the fields, methods and constructors of loaded classes, and the use
+ * of reflected fields, methods, and constructors to operate on their underlying
+ * counterparts, within encapsulation and security restrictions.
*
* {@code AccessibleObject} allows suppression of access checks if
* the necessary {@code ReflectPermission} is available.
diff --git a/jdk/src/java.base/share/classes/java/net/AbstractPlainDatagramSocketImpl.java b/jdk/src/java.base/share/classes/java/net/AbstractPlainDatagramSocketImpl.java
index 4945713e228..d4414560fe6 100644
--- a/jdk/src/java.base/share/classes/java/net/AbstractPlainDatagramSocketImpl.java
+++ b/jdk/src/java.base/share/classes/java/net/AbstractPlainDatagramSocketImpl.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1996, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1996, 2017, 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
@@ -275,6 +275,7 @@ abstract class AbstractPlainDatagramSocketImpl extends DatagramSocketImpl
return (fd == null) ? true : false;
}
+ @SuppressWarnings("deprecation")
protected void finalize() {
close();
}
diff --git a/jdk/src/java.base/share/classes/java/net/AbstractPlainSocketImpl.java b/jdk/src/java.base/share/classes/java/net/AbstractPlainSocketImpl.java
index 465ec01cc37..e66bbdc61aa 100644
--- a/jdk/src/java.base/share/classes/java/net/AbstractPlainSocketImpl.java
+++ b/jdk/src/java.base/share/classes/java/net/AbstractPlainSocketImpl.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1995, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1995, 2017, 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
@@ -646,6 +646,7 @@ abstract class AbstractPlainSocketImpl extends SocketImpl
/**
* Cleans up if the user forgets to close it.
*/
+ @SuppressWarnings("deprecation")
protected void finalize() throws IOException {
close();
}
diff --git a/jdk/src/java.base/share/classes/java/net/ContentHandler.java b/jdk/src/java.base/share/classes/java/net/ContentHandler.java
index bea0391b1ea..119af89fed4 100644
--- a/jdk/src/java.base/share/classes/java/net/ContentHandler.java
+++ b/jdk/src/java.base/share/classes/java/net/ContentHandler.java
@@ -37,10 +37,10 @@ import java.io.IOException;
* application calls the {@code getContent} method in class
* {@code URL} or in {@code URLConnection}.
* The application's content handler factory (an instance of a class that
- * implements the interface {@code ContentHandlerFactory} set
- * up by a call to {@code setContentHandler}) is
- * called with a {@code String} giving the MIME type of the
- * object being received on the socket. The factory returns an
+ * implements the interface {@code ContentHandlerFactory} set up by a call to
+ * {@link URLConnection#setContentHandlerFactory(ContentHandlerFactory)
+ * setContentHandlerFactory} is called with a {@code String} giving the
+ * MIME type of the object being received on the socket. The factory returns an
* instance of a subclass of {@code ContentHandler}, and its
* {@code getContent} method is called to create the object.
*
@@ -99,7 +99,8 @@ public abstract class ContentHandler {
* representation of an object, this method reads that stream and
* creates an object that matches one of the types specified.
*
- * The default implementation of this method should call getContent()
+ * The default implementation of this method should call
+ * {@link #getContent(URLConnection)}
* and screen the return type for a match of the suggested types.
*
* @param urlc a URL connection.
diff --git a/jdk/src/java.base/share/classes/java/net/SocketInputStream.java b/jdk/src/java.base/share/classes/java/net/SocketInputStream.java
index 2f54d344659..04ee3378eaa 100644
--- a/jdk/src/java.base/share/classes/java/net/SocketInputStream.java
+++ b/jdk/src/java.base/share/classes/java/net/SocketInputStream.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1995, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1995, 2017, 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
@@ -283,6 +283,7 @@ class SocketInputStream extends FileInputStream
/**
* Overrides finalize, the fd is closed by the Socket.
*/
+ @SuppressWarnings("deprecation")
protected void finalize() {}
/**
diff --git a/jdk/src/java.base/share/classes/java/net/SocketOutputStream.java b/jdk/src/java.base/share/classes/java/net/SocketOutputStream.java
index 9cbe056066f..0ba877bf56e 100644
--- a/jdk/src/java.base/share/classes/java/net/SocketOutputStream.java
+++ b/jdk/src/java.base/share/classes/java/net/SocketOutputStream.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1995, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1995, 2017, 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
@@ -175,6 +175,7 @@ class SocketOutputStream extends FileOutputStream
/**
* Overrides finalize, the fd is closed by the Socket.
*/
+ @SuppressWarnings("deprecation")
protected void finalize() {}
/**
diff --git a/jdk/src/java.base/share/classes/java/net/URLConnection.java b/jdk/src/java.base/share/classes/java/net/URLConnection.java
index e2ed0cfcbdd..f834d1255f0 100644
--- a/jdk/src/java.base/share/classes/java/net/URLConnection.java
+++ b/jdk/src/java.base/share/classes/java/net/URLConnection.java
@@ -876,7 +876,7 @@ public abstract class URLConnection {
* Sets the value of the {@code doInput} field for this
* {@code URLConnection} to the specified value.
*
- * A URL connection can be used for input and/or output. Set the DoInput
+ * A URL connection can be used for input and/or output. Set the doInput
* flag to true if you intend to use the URL connection for input,
* false if not. The default is true.
*
@@ -906,7 +906,7 @@ public abstract class URLConnection {
* Sets the value of the {@code doOutput} field for this
* {@code URLConnection} to the specified value.
*
- * A URL connection can be used for input and/or output. Set the DoOutput
+ * A URL connection can be used for input and/or output. Set the doOutput
* flag to true if you intend to use the URL connection for output,
* false if not. The default is false.
*
@@ -972,7 +972,7 @@ public abstract class URLConnection {
* Returns the default value of the {@code allowUserInteraction}
* field.
*
- * Ths default is "sticky", being a part of the static state of all
+ * This default is "sticky", being a part of the static state of all
* URLConnections. This flag applies to the next, and all following
* URLConnections that are created.
*
@@ -993,7 +993,7 @@ public abstract class URLConnection {
* "reload" button in a browser). If the UseCaches flag on a connection
* is true, the connection is allowed to use whatever caches it can.
* If false, caches are to be ignored.
- * The default value comes from DefaultUseCaches, which defaults to
+ * The default value comes from defaultUseCaches, which defaults to
* true. A default value can also be set per-protocol using
* {@link #setDefaultUseCaches(String,boolean)}.
*
@@ -1252,7 +1252,7 @@ public abstract class URLConnection {
* application. It can be called at most once by an application.
*
* The {@code ContentHandlerFactory} instance is used to
- * construct a content handler from a content type
+ * construct a content handler from a content type.
*
* If there is a security manager, this method first calls
* the security manager's {@code checkSetFactory} method
diff --git a/jdk/src/java.base/share/classes/java/time/chrono/AbstractChronology.java b/jdk/src/java.base/share/classes/java/time/chrono/AbstractChronology.java
index c2e91d7f5f8..a32ecb78da1 100644
--- a/jdk/src/java.base/share/classes/java/time/chrono/AbstractChronology.java
+++ b/jdk/src/java.base/share/classes/java/time/chrono/AbstractChronology.java
@@ -126,36 +126,6 @@ import sun.util.logging.PlatformLogger;
*/
public abstract class AbstractChronology implements Chronology {
- /**
- * ChronoLocalDate order constant.
- */
- static final Comparator DATE_ORDER =
- (Comparator & Serializable) (date1, date2) -> {
- return Long.compare(date1.toEpochDay(), date2.toEpochDay());
- };
- /**
- * ChronoLocalDateTime order constant.
- */
- static final Comparator> DATE_TIME_ORDER =
- (Comparator> & Serializable) (dateTime1, dateTime2) -> {
- int cmp = Long.compare(dateTime1.toLocalDate().toEpochDay(), dateTime2.toLocalDate().toEpochDay());
- if (cmp == 0) {
- cmp = Long.compare(dateTime1.toLocalTime().toNanoOfDay(), dateTime2.toLocalTime().toNanoOfDay());
- }
- return cmp;
- };
- /**
- * ChronoZonedDateTime order constant.
- */
- static final Comparator> INSTANT_ORDER =
- (Comparator> & Serializable) (dateTime1, dateTime2) -> {
- int cmp = Long.compare(dateTime1.toEpochSecond(), dateTime2.toEpochSecond());
- if (cmp == 0) {
- cmp = Long.compare(dateTime1.toLocalTime().getNano(), dateTime2.toLocalTime().getNano());
- }
- return cmp;
- };
-
/**
* Map of available calendars by ID.
*/
diff --git a/jdk/src/java.base/share/classes/java/time/chrono/ChronoLocalDate.java b/jdk/src/java.base/share/classes/java/time/chrono/ChronoLocalDate.java
index 03a7a48d209..fb6938664ec 100644
--- a/jdk/src/java.base/share/classes/java/time/chrono/ChronoLocalDate.java
+++ b/jdk/src/java.base/share/classes/java/time/chrono/ChronoLocalDate.java
@@ -66,6 +66,7 @@ import static java.time.temporal.ChronoField.ERA;
import static java.time.temporal.ChronoField.YEAR;
import static java.time.temporal.ChronoUnit.DAYS;
+import java.io.Serializable;
import java.time.DateTimeException;
import java.time.LocalDate;
import java.time.LocalTime;
@@ -256,7 +257,9 @@ public interface ChronoLocalDate
* @see #isEqual
*/
static Comparator timeLineOrder() {
- return AbstractChronology.DATE_ORDER;
+ return (Comparator & Serializable) (date1, date2) -> {
+ return Long.compare(date1.toEpochDay(), date2.toEpochDay());
+ };
}
//-----------------------------------------------------------------------
diff --git a/jdk/src/java.base/share/classes/java/time/chrono/ChronoLocalDateTime.java b/jdk/src/java.base/share/classes/java/time/chrono/ChronoLocalDateTime.java
index b211a52ff84..d8411961697 100644
--- a/jdk/src/java.base/share/classes/java/time/chrono/ChronoLocalDateTime.java
+++ b/jdk/src/java.base/share/classes/java/time/chrono/ChronoLocalDateTime.java
@@ -66,6 +66,7 @@ import static java.time.temporal.ChronoField.NANO_OF_DAY;
import static java.time.temporal.ChronoUnit.FOREVER;
import static java.time.temporal.ChronoUnit.NANOS;
+import java.io.Serializable;
import java.time.DateTimeException;
import java.time.Instant;
import java.time.LocalDateTime;
@@ -136,7 +137,13 @@ public interface ChronoLocalDateTime
* @see #isEqual
*/
static Comparator> timeLineOrder() {
- return AbstractChronology.DATE_TIME_ORDER;
+ return (Comparator> & Serializable) (dateTime1, dateTime2) -> {
+ int cmp = Long.compare(dateTime1.toLocalDate().toEpochDay(), dateTime2.toLocalDate().toEpochDay());
+ if (cmp == 0) {
+ cmp = Long.compare(dateTime1.toLocalTime().toNanoOfDay(), dateTime2.toLocalTime().toNanoOfDay());
+ }
+ return cmp;
+ };
}
//-----------------------------------------------------------------------
diff --git a/jdk/src/java.base/share/classes/java/time/chrono/ChronoZonedDateTime.java b/jdk/src/java.base/share/classes/java/time/chrono/ChronoZonedDateTime.java
index 8227c482831..eadcf9df958 100644
--- a/jdk/src/java.base/share/classes/java/time/chrono/ChronoZonedDateTime.java
+++ b/jdk/src/java.base/share/classes/java/time/chrono/ChronoZonedDateTime.java
@@ -66,6 +66,7 @@ import static java.time.temporal.ChronoField.OFFSET_SECONDS;
import static java.time.temporal.ChronoUnit.FOREVER;
import static java.time.temporal.ChronoUnit.NANOS;
+import java.io.Serializable;
import java.time.DateTimeException;
import java.time.Instant;
import java.time.LocalTime;
@@ -137,7 +138,13 @@ public interface ChronoZonedDateTime
* @see #isEqual
*/
static Comparator> timeLineOrder() {
- return AbstractChronology.INSTANT_ORDER;
+ return (Comparator> & Serializable) (dateTime1, dateTime2) -> {
+ int cmp = Long.compare(dateTime1.toEpochSecond(), dateTime2.toEpochSecond());
+ if (cmp == 0) {
+ cmp = Long.compare(dateTime1.toLocalTime().getNano(), dateTime2.toLocalTime().getNano());
+ }
+ return cmp;
+ };
}
//-----------------------------------------------------------------------
diff --git a/jdk/src/java.base/share/classes/java/util/Comparator.java b/jdk/src/java.base/share/classes/java/util/Comparator.java
index ade582dbd3b..85f25beaf63 100644
--- a/jdk/src/java.base/share/classes/java/util/Comparator.java
+++ b/jdk/src/java.base/share/classes/java/util/Comparator.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2017, 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
@@ -112,12 +112,6 @@ public interface Comparator {
* zero, or a positive integer as the first argument is less than, equal
* to, or greater than the second.
*
- * In the foregoing description, the notation
- * {@code sgn(}expression {@code )} designates the mathematical
- * signum function, which is defined to return one of {@code -1},
- * {@code 0}, or {@code 1} according to whether the value of
- * expression is negative, zero or positive.
- *
* The implementor must ensure that {@code sgn(compare(x, y)) ==
* -sgn(compare(y, x))} for all {@code x} and {@code y}. (This
* implies that {@code compare(x, y)} must throw an exception if and only
@@ -135,7 +129,13 @@ public interface Comparator {
* {@code (compare(x, y)==0) == (x.equals(y))}. Generally speaking,
* any comparator that violates this condition should clearly indicate
* this fact. The recommended language is "Note: this comparator
- * imposes orderings that are inconsistent with equals."
+ * imposes orderings that are inconsistent with equals."
+ *
+ * In the foregoing description, the notation
+ * {@code sgn(}expression {@code )} designates the mathematical
+ * signum function, which is defined to return one of {@code -1},
+ * {@code 0}, or {@code 1} according to whether the value of
+ * expression is negative, zero, or positive, respectively.
*
* @param o1 the first object to be compared.
* @param o2 the second object to be compared.
diff --git a/jdk/src/java.base/share/classes/java/util/ResourceBundle.java b/jdk/src/java.base/share/classes/java/util/ResourceBundle.java
index b587da9b9e3..c25888463f1 100644
--- a/jdk/src/java.base/share/classes/java/util/ResourceBundle.java
+++ b/jdk/src/java.base/share/classes/java/util/ResourceBundle.java
@@ -50,7 +50,6 @@ import java.lang.ref.WeakReference;
import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Modifier;
-import java.lang.reflect.Module;
import java.net.JarURLConnection;
import java.net.URL;
import java.net.URLConnection;
@@ -1836,7 +1835,7 @@ public abstract class ResourceBundle {
cacheKey.setFormat(format);
break;
}
- } catch (Exception e) {
+ } catch (LinkageError|Exception e) {
cacheKey.setCause(e);
}
}
diff --git a/jdk/src/java.base/share/classes/java/util/ServiceLoader.java b/jdk/src/java.base/share/classes/java/util/ServiceLoader.java
index b84139ca307..db4ff4e78ec 100644
--- a/jdk/src/java.base/share/classes/java/util/ServiceLoader.java
+++ b/jdk/src/java.base/share/classes/java/util/ServiceLoader.java
@@ -31,10 +31,8 @@ import java.io.InputStream;
import java.io.InputStreamReader;
import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Layer;
import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
-import java.lang.reflect.Module;
import java.net.URL;
import java.net.URLConnection;
import java.security.AccessControlContext;
@@ -50,7 +48,6 @@ import java.util.stream.StreamSupport;
import jdk.internal.loader.BootLoader;
import jdk.internal.loader.ClassLoaders;
import jdk.internal.misc.JavaLangAccess;
-import jdk.internal.misc.JavaLangReflectModuleAccess;
import jdk.internal.misc.SharedSecrets;
import jdk.internal.misc.VM;
import jdk.internal.module.ServicesCatalog;
@@ -160,7 +157,7 @@ import jdk.internal.reflect.Reflection;
*
Locating providers
*
* The {@code load} methods locate providers using a class loader or module
- * {@link Layer layer}. When locating providers using a class loader then
+ * {@link ModuleLayer layer}. When locating providers using a class loader then
* providers in both named and unnamed modules may be located. When locating
* providers using a module layer then only providers in named modules in
* the layer (or parent layers) are located.
@@ -168,11 +165,11 @@ import jdk.internal.reflect.Reflection;
*
When locating providers using a class loader then any providers in named
* modules defined to the class loader, or any class loader that is reachable
* via parent delegation, are located. Additionally, providers in module layers
- * other than the {@link Layer#boot() boot} layer, where the module layer
+ * other than the {@link ModuleLayer#boot() boot} layer, where the module layer
* contains modules defined to the class loader, or any class loader reachable
* via parent delegation, are also located. For example, suppose there is a
* module layer where each module is defined to its own class loader (see {@link
- * Layer#defineModulesWithManyLoaders defineModulesWithManyLoaders}). If the
+ * ModuleLayer#defineModulesWithManyLoaders defineModulesWithManyLoaders}). If the
* {@code load} method is invoked to locate providers using any of these class
* loaders for this layer then it will locate all of the providers in that
* layer, irrespective of their defining class loader.
@@ -198,7 +195,7 @@ import jdk.internal.reflect.Reflection;
* will locate providers in modules defined to the class loader, then its
* parent class loader, its parent parent, and so on to the bootstrap class
* loader. If a {@code ClassLoader}, or any class loader in the parent
- * delegation chain, defines modules in a custom module {@link Layer} then
+ * delegation chain, defines modules in a custom module {@link ModuleLayer} then
* all providers in that layer are located, irrespective of their class
* loader. The ordering of modules defined to the same class loader, or the
* ordering of modules in a layer, is not defined.
@@ -216,11 +213,11 @@ import jdk.internal.reflect.Reflection;
* method finds the service configuration files.
*
*
- *
Service loaders created to locate providers in a module {@link Layer}
- * will first locate providers in the layer, before locating providers in
- * parent layers. Traversal of parent layers is depth-first with each layer
- * visited at most once. For example, suppose L0 is the boot layer, L1 and
- * L2 are custom layers with L0 as their parent. Now suppose that L3 is
+ *
Service loaders created to locate providers in a {@linkplain ModuleLayer
+ * module layer} will first locate providers in the layer, before locating
+ * providers in parent layers. Traversal of parent layers is depth-first with
+ * each layer visited at most once. For example, suppose L0 is the boot layer,
+ * L1 and L2 are custom layers with L0 as their parent. Now suppose that L3 is
* created with L1 and L2 as the parents (in that order). Using a service
* loader to locate providers with L3 as the content will locate providers
* in the following order: L3, L1, L0, L2. The ordering of modules in a layer
@@ -352,12 +349,12 @@ public final class ServiceLoader
// The class of the service type
private final String serviceName;
- // The module Layer used to locate providers; null when locating
+ // The module layer used to locate providers; null when locating
// providers using a class loader
- private final Layer layer;
+ private final ModuleLayer layer;
// The class loader used to locate, load, and instantiate providers;
- // null when locating provider using a module Layer
+ // null when locating provider using a module layer
private final ClassLoader loader;
// The access control context taken when the ServiceLoader is created
@@ -376,10 +373,8 @@ public final class ServiceLoader
private int reloadCount;
private static JavaLangAccess LANG_ACCESS;
- private static JavaLangReflectModuleAccess JLRM_ACCESS;
static {
LANG_ACCESS = SharedSecrets.getJavaLangAccess();
- JLRM_ACCESS = SharedSecrets.getJavaLangReflectModuleAccess();
}
/**
@@ -425,13 +420,13 @@ public final class ServiceLoader
/**
* Initializes a new instance of this class for locating service providers
- * in a module Layer.
+ * in a module layer.
*
* @throws ServiceConfigurationError
* If {@code svc} is not accessible to {@code caller} or the caller
* module does not use the service type.
*/
- private ServiceLoader(Class> caller, Layer layer, Class svc) {
+ private ServiceLoader(Class> caller, ModuleLayer layer, Class svc) {
Objects.requireNonNull(caller);
Objects.requireNonNull(layer);
Objects.requireNonNull(svc);
@@ -512,12 +507,15 @@ public final class ServiceLoader
/**
* Checks that the given service type is accessible to types in the given
- * module, and check that the module declare that it uses the service type. ??
+ * module, and check that the module declares that it uses the service type.
*/
private static void checkCaller(Class> caller, Class> svc) {
- Module callerModule = caller.getModule();
+ if (caller == null) {
+ fail(svc, "no caller to check if it declares `uses`");
+ }
// Check access to the service type
+ Module callerModule = caller.getModule();
int mods = svc.getModifiers();
if (!Reflection.verifyMemberAccess(caller, svc, null, mods)) {
fail(svc, "service type not accessible to " + callerModule);
@@ -826,13 +824,13 @@ public final class ServiceLoader
/**
* Implements lazy service provider lookup of service providers that
- * are provided by modules in a module Layer (or parent layers)
+ * are provided by modules in a module layer (or parent layers)
*/
private final class LayerLookupIterator
implements Iterator>
{
- Deque stack = new ArrayDeque<>();
- Set visited = new HashSet<>();
+ Deque stack = new ArrayDeque<>();
+ Set visited = new HashSet<>();
Iterator iterator;
ServiceProvider next; // next provider to load
@@ -841,8 +839,8 @@ public final class ServiceLoader
stack.push(layer);
}
- private Iterator providers(Layer layer) {
- ServicesCatalog catalog = JLRM_ACCESS.getServicesCatalog(layer);
+ private Iterator providers(ModuleLayer layer) {
+ ServicesCatalog catalog = LANG_ACCESS.getServicesCatalog(layer);
return catalog.findServices(serviceName).iterator();
}
@@ -864,10 +862,10 @@ public final class ServiceLoader
if (stack.isEmpty())
return false;
- Layer layer = stack.pop();
- List parents = layer.parents();
+ ModuleLayer layer = stack.pop();
+ List parents = layer.parents();
for (int i = parents.size() - 1; i >= 0; i--) {
- Layer parent = parents.get(i);
+ ModuleLayer parent = parents.get(i);
if (!visited.contains(parent)) {
visited.add(parent);
stack.push(parent);
@@ -915,8 +913,8 @@ public final class ServiceLoader
* Returns iterator to iterate over the implementations of {@code
* service} in the given layer.
*/
- private List providers(Layer layer) {
- ServicesCatalog catalog = JLRM_ACCESS.getServicesCatalog(layer);
+ private List providers(ModuleLayer layer) {
+ ServicesCatalog catalog = LANG_ACCESS.getServicesCatalog(layer);
return catalog.findServices(serviceName);
}
@@ -946,10 +944,10 @@ public final class ServiceLoader
return providers.iterator();
} else {
List allProviders = new ArrayList<>(providers);
- Layer bootLayer = Layer.boot();
- Iterator iterator = JLRM_ACCESS.layers(loader).iterator();
+ ModuleLayer bootLayer = ModuleLayer.boot();
+ Iterator iterator = LANG_ACCESS.layers(loader).iterator();
while (iterator.hasNext()) {
- Layer layer = iterator.next();
+ ModuleLayer layer = iterator.next();
if (layer != bootLayer) {
allProviders.addAll(providers(layer));
}
@@ -1535,7 +1533,7 @@ public final class ServiceLoader
/**
* Creates a new service loader for the given service type that loads
- * service providers from modules in the given {@code Layer} and its
+ * service providers from modules in the given {@code ModuleLayer} and its
* ancestors.
*
* @apiNote Unlike the other load methods defined here, the service type
@@ -1545,7 +1543,7 @@ public final class ServiceLoader
* @param the class of the service type
*
* @param layer
- * The module Layer
+ * The module layer
*
* @param service
* The interface or abstract class representing the service
@@ -1561,7 +1559,7 @@ public final class ServiceLoader
* @spec JPMS
*/
@CallerSensitive
- public static ServiceLoader load(Layer layer, Class service) {
+ public static ServiceLoader load(ModuleLayer layer, Class service) {
return new ServiceLoader<>(Reflection.getCallerClass(), layer, service);
}
diff --git a/jdk/src/java.base/share/classes/java/util/Timer.java b/jdk/src/java.base/share/classes/java/util/Timer.java
index 770d9f9df8b..7c47d0c7135 100644
--- a/jdk/src/java.base/share/classes/java/util/Timer.java
+++ b/jdk/src/java.base/share/classes/java/util/Timer.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1999, 2008, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2017, 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
@@ -108,6 +108,7 @@ public class Timer {
* finalizer forgetting to call it.
*/
private final Object threadReaper = new Object() {
+ @SuppressWarnings("deprecation")
protected void finalize() throws Throwable {
synchronized(queue) {
thread.newTasksMayBeScheduled = false;
diff --git a/jdk/src/java.base/share/classes/java/util/concurrent/ConcurrentHashMap.java b/jdk/src/java.base/share/classes/java/util/concurrent/ConcurrentHashMap.java
index 1d80077b58c..8ebdae0e1cc 100644
--- a/jdk/src/java.base/share/classes/java/util/concurrent/ConcurrentHashMap.java
+++ b/jdk/src/java.base/share/classes/java/util/concurrent/ConcurrentHashMap.java
@@ -1032,9 +1032,10 @@ public class ConcurrentHashMap extends AbstractMap
}
else if ((fh = f.hash) == MOVED)
tab = helpTransfer(tab, f);
- else if (onlyIfAbsent && fh == hash && // check first node
- ((fk = f.key) == key || fk != null && key.equals(fk)) &&
- (fv = f.val) != null)
+ else if (onlyIfAbsent // check first node without acquiring lock
+ && fh == hash
+ && ((fk = f.key) == key || (fk != null && key.equals(fk)))
+ && (fv = f.val) != null)
return fv;
else {
V oldVal = null;
@@ -1728,9 +1729,9 @@ public class ConcurrentHashMap extends AbstractMap
}
else if ((fh = f.hash) == MOVED)
tab = helpTransfer(tab, f);
- else if (fh == h && // check first node
- ((fk = f.key) == key || fk != null && key.equals(fk)) &&
- (fv = f.val) != null)
+ else if (fh == h // check first node without acquiring lock
+ && ((fk = f.key) == key || (fk != null && key.equals(fk)))
+ && (fv = f.val) != null)
return fv;
else {
boolean added = false;
@@ -3468,9 +3469,9 @@ public class ConcurrentHashMap extends AbstractMap
static final class KeyIterator extends BaseIterator
implements Iterator, Enumeration {
- KeyIterator(Node[] tab, int index, int size, int limit,
+ KeyIterator(Node[] tab, int size, int index, int limit,
ConcurrentHashMap map) {
- super(tab, index, size, limit, map);
+ super(tab, size, index, limit, map);
}
public final K next() {
@@ -3488,9 +3489,9 @@ public class ConcurrentHashMap extends AbstractMap
static final class ValueIterator extends BaseIterator
implements Iterator, Enumeration {
- ValueIterator(Node[] tab, int index, int size, int limit,
+ ValueIterator(Node[] tab, int size, int index, int limit,
ConcurrentHashMap map) {
- super(tab, index, size, limit, map);
+ super(tab, size, index, limit, map);
}
public final V next() {
@@ -3508,9 +3509,9 @@ public class ConcurrentHashMap extends AbstractMap
static final class EntryIterator extends BaseIterator
implements Iterator> {
- EntryIterator(Node[] tab, int index, int size, int limit,
+ EntryIterator(Node[] tab, int size, int index, int limit,
ConcurrentHashMap map) {
- super(tab, index, size, limit, map);
+ super(tab, size, index, limit, map);
}
public final Map.Entry next() {
diff --git a/jdk/src/java.base/share/classes/java/util/concurrent/ConcurrentSkipListMap.java b/jdk/src/java.base/share/classes/java/util/concurrent/ConcurrentSkipListMap.java
index 2ae29aa42f3..d34c74cd9a9 100644
--- a/jdk/src/java.base/share/classes/java/util/concurrent/ConcurrentSkipListMap.java
+++ b/jdk/src/java.base/share/classes/java/util/concurrent/ConcurrentSkipListMap.java
@@ -48,7 +48,6 @@ import java.util.Comparator;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
-import java.util.NavigableMap;
import java.util.NavigableSet;
import java.util.NoSuchElementException;
import java.util.Set;
diff --git a/jdk/src/java.base/share/classes/java/util/concurrent/ConcurrentSkipListSet.java b/jdk/src/java.base/share/classes/java/util/concurrent/ConcurrentSkipListSet.java
index 86be622c78b..ccd7f647d83 100644
--- a/jdk/src/java.base/share/classes/java/util/concurrent/ConcurrentSkipListSet.java
+++ b/jdk/src/java.base/share/classes/java/util/concurrent/ConcurrentSkipListSet.java
@@ -43,7 +43,6 @@ import java.util.Collections;
import java.util.Comparator;
import java.util.Iterator;
import java.util.Map;
-import java.util.NavigableMap;
import java.util.NavigableSet;
import java.util.Set;
import java.util.SortedSet;
diff --git a/jdk/src/java.base/share/classes/java/util/concurrent/Executors.java b/jdk/src/java.base/share/classes/java/util/concurrent/Executors.java
index a31e3a1ebac..00fdf25772c 100644
--- a/jdk/src/java.base/share/classes/java/util/concurrent/Executors.java
+++ b/jdk/src/java.base/share/classes/java/util/concurrent/Executors.java
@@ -713,6 +713,7 @@ public class Executors {
FinalizableDelegatedExecutorService(ExecutorService executor) {
super(executor);
}
+ @SuppressWarnings("deprecation")
protected void finalize() {
super.shutdown();
}
diff --git a/jdk/src/java.base/share/classes/java/util/concurrent/ForkJoinPool.java b/jdk/src/java.base/share/classes/java/util/concurrent/ForkJoinPool.java
index 330f4fb78a3..d8697970586 100644
--- a/jdk/src/java.base/share/classes/java/util/concurrent/ForkJoinPool.java
+++ b/jdk/src/java.base/share/classes/java/util/concurrent/ForkJoinPool.java
@@ -2354,7 +2354,7 @@ public class ForkJoinPool extends AbstractExecutorService {
checkPermission();
}
- private Object newInstanceFromSystemProperty(String property)
+ private static Object newInstanceFromSystemProperty(String property)
throws ReflectiveOperationException {
String className = System.getProperty(property);
return (className == null)
@@ -2524,15 +2524,13 @@ public class ForkJoinPool extends AbstractExecutorService {
* @throws RejectedExecutionException if the task cannot be
* scheduled for execution
*/
+ @SuppressWarnings("unchecked")
public ForkJoinTask> submit(Runnable task) {
if (task == null)
throw new NullPointerException();
- ForkJoinTask> job;
- if (task instanceof ForkJoinTask>) // avoid re-wrap
- job = (ForkJoinTask>) task;
- else
- job = new ForkJoinTask.AdaptedRunnableAction(task);
- return externalSubmit(job);
+ return externalSubmit((task instanceof ForkJoinTask>)
+ ? (ForkJoinTask) task // avoid re-wrap
+ : new ForkJoinTask.AdaptedRunnableAction(task));
}
/**
diff --git a/jdk/src/java.base/share/classes/java/util/concurrent/ForkJoinWorkerThread.java b/jdk/src/java.base/share/classes/java/util/concurrent/ForkJoinWorkerThread.java
index a3054b865ba..b1550f9f648 100644
--- a/jdk/src/java.base/share/classes/java/util/concurrent/ForkJoinWorkerThread.java
+++ b/jdk/src/java.base/share/classes/java/util/concurrent/ForkJoinWorkerThread.java
@@ -203,21 +203,19 @@ public class ForkJoinWorkerThread extends Thread {
static final class InnocuousForkJoinWorkerThread extends ForkJoinWorkerThread {
/** The ThreadGroup for all InnocuousForkJoinWorkerThreads */
private static final ThreadGroup innocuousThreadGroup =
- java.security.AccessController.doPrivileged(
- new java.security.PrivilegedAction<>() {
- public ThreadGroup run() {
- ThreadGroup group = Thread.currentThread().getThreadGroup();
- for (ThreadGroup p; (p = group.getParent()) != null; )
- group = p;
- return new ThreadGroup(group, "InnocuousForkJoinWorkerThreadGroup");
- }});
+ AccessController.doPrivileged(new PrivilegedAction<>() {
+ public ThreadGroup run() {
+ ThreadGroup group = Thread.currentThread().getThreadGroup();
+ for (ThreadGroup p; (p = group.getParent()) != null; )
+ group = p;
+ return new ThreadGroup(
+ group, "InnocuousForkJoinWorkerThreadGroup");
+ }});
/** An AccessControlContext supporting no privileges */
private static final AccessControlContext INNOCUOUS_ACC =
new AccessControlContext(
- new ProtectionDomain[] {
- new ProtectionDomain(null, null)
- });
+ new ProtectionDomain[] { new ProtectionDomain(null, null) });
InnocuousForkJoinWorkerThread(ForkJoinPool pool) {
super(pool,
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 0016bfffe87..ceb9bf2022f 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
@@ -1490,7 +1490,17 @@ public class ThreadPoolExecutor extends AbstractExecutorService {
/**
* Invokes {@code shutdown} when this executor is no longer
* referenced and it has no threads.
+ *
+ * @deprecated The {@code finalize} method has been deprecated.
+ * Subclasses that override {@code finalize} in order to perform cleanup
+ * should be modified to use alternative cleanup mechanisms and
+ * to remove the overriding {@code finalize} method.
+ * When overriding the {@code finalize} method, its implementation must explicitly
+ * ensure that {@code super.finalize()} is invoked as described in {@link Object#finalize}.
+ * See the specification for {@link Object#finalize()} for further
+ * information about migration options.
*/
+ @Deprecated(since="9")
protected void finalize() {
shutdown();
}
diff --git a/jdk/src/java.base/share/classes/java/util/concurrent/locks/ReentrantReadWriteLock.java b/jdk/src/java.base/share/classes/java/util/concurrent/locks/ReentrantReadWriteLock.java
index ab43971e84d..4f093bf5631 100644
--- a/jdk/src/java.base/share/classes/java/util/concurrent/locks/ReentrantReadWriteLock.java
+++ b/jdk/src/java.base/share/classes/java/util/concurrent/locks/ReentrantReadWriteLock.java
@@ -444,7 +444,7 @@ public class ReentrantReadWriteLock
}
}
- private IllegalMonitorStateException unmatchedUnlockException() {
+ private static IllegalMonitorStateException unmatchedUnlockException() {
return new IllegalMonitorStateException(
"attempt to unlock read lock, not locked by current thread");
}
diff --git a/jdk/src/java.base/share/classes/java/util/spi/AbstractResourceBundleProvider.java b/jdk/src/java.base/share/classes/java/util/spi/AbstractResourceBundleProvider.java
index b0cba4f4915..4a3ef27e13a 100644
--- a/jdk/src/java.base/share/classes/java/util/spi/AbstractResourceBundleProvider.java
+++ b/jdk/src/java.base/share/classes/java/util/spi/AbstractResourceBundleProvider.java
@@ -31,7 +31,6 @@ import jdk.internal.misc.SharedSecrets;
import java.io.IOException;
import java.io.InputStream;
import java.io.UncheckedIOException;
-import java.lang.reflect.Module;
import java.security.AccessController;
import java.security.PrivilegedAction;
import java.util.Locale;
diff --git a/jdk/src/java.base/share/classes/java/util/zip/Deflater.java b/jdk/src/java.base/share/classes/java/util/zip/Deflater.java
index bf70f4dd8a1..6eb5065040e 100644
--- a/jdk/src/java.base/share/classes/java/util/zip/Deflater.java
+++ b/jdk/src/java.base/share/classes/java/util/zip/Deflater.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1996, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1996, 2017, 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
@@ -551,7 +551,17 @@ class Deflater {
/**
* Closes the compressor when garbage is collected.
+ *
+ * @deprecated The {@code finalize} method has been deprecated.
+ * Subclasses that override {@code finalize} in order to perform cleanup
+ * should be modified to use alternative cleanup mechanisms and
+ * to remove the overriding {@code finalize} method.
+ * When overriding the {@code finalize} method, its implementation must explicitly
+ * ensure that {@code super.finalize()} is invoked as described in {@link Object#finalize}.
+ * See the specification for {@link Object#finalize()} for further
+ * information about migration options.
*/
+ @Deprecated(since="9")
protected void finalize() {
end();
}
diff --git a/jdk/src/java.base/share/classes/java/util/zip/Inflater.java b/jdk/src/java.base/share/classes/java/util/zip/Inflater.java
index 94c05e1d315..2aab545f2a1 100644
--- a/jdk/src/java.base/share/classes/java/util/zip/Inflater.java
+++ b/jdk/src/java.base/share/classes/java/util/zip/Inflater.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1996, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1996, 2017, 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
@@ -378,7 +378,17 @@ class Inflater {
/**
* Closes the decompressor when garbage is collected.
+ *
+ * @deprecated The {@code finalize} method has been deprecated.
+ * Subclasses that override {@code finalize} in order to perform cleanup
+ * should be modified to use alternative cleanup mechanisms and
+ * to remove the overriding {@code finalize} method.
+ * When overriding the {@code finalize} method, its implementation must explicitly
+ * ensure that {@code super.finalize()} is invoked as described in {@link Object#finalize}.
+ * See the specification for {@link Object#finalize()} for further
+ * information about migration options.
*/
+ @Deprecated(since="9")
protected void finalize() {
end();
}
diff --git a/jdk/src/java.base/share/classes/java/util/zip/ZipFile.java b/jdk/src/java.base/share/classes/java/util/zip/ZipFile.java
index ecd002bc340..83ce2441eeb 100644
--- a/jdk/src/java.base/share/classes/java/util/zip/ZipFile.java
+++ b/jdk/src/java.base/share/classes/java/util/zip/ZipFile.java
@@ -420,6 +420,7 @@ class ZipFile implements ZipConstants, Closeable {
Integer.MAX_VALUE : (int) avail);
}
+ @SuppressWarnings("deprecation")
protected void finalize() throws Throwable {
close();
}
@@ -641,9 +642,18 @@ class ZipFile implements ZipConstants, Closeable {
* This will prevent holding up system resources for an undetermined
* length of time.
*
+ * @deprecated The {@code finalize} method has been deprecated.
+ * Subclasses that override {@code finalize} in order to perform cleanup
+ * should be modified to use alternative cleanup mechanisms and
+ * to remove the overriding {@code finalize} method.
+ * When overriding the {@code finalize} method, its implementation must explicitly
+ * ensure that {@code super.finalize()} is invoked as described in {@link Object#finalize}.
+ * See the specification for {@link Object#finalize()} for further
+ * information about migration options.
* @throws IOException if an I/O error has occurred
* @see java.util.zip.ZipFile#close()
*/
+ @Deprecated(since="9")
protected void finalize() throws IOException {
close();
}
@@ -813,6 +823,7 @@ class ZipFile implements ZipConstants, Closeable {
}
}
+ @SuppressWarnings("deprecation")
protected void finalize() {
close();
}
diff --git a/jdk/src/java.base/share/classes/javax/crypto/JceSecurityManager.java b/jdk/src/java.base/share/classes/javax/crypto/JceSecurityManager.java
index 60a1c9d3aa2..16b7903cd8e 100644
--- a/jdk/src/java.base/share/classes/javax/crypto/JceSecurityManager.java
+++ b/jdk/src/java.base/share/classes/javax/crypto/JceSecurityManager.java
@@ -25,7 +25,6 @@
package javax.crypto;
-import java.lang.reflect.Module;
import java.security.*;
import java.net.*;
import java.util.*;
diff --git a/jdk/src/java.base/share/classes/jdk/internal/jrtfs/JrtFileSystem.java b/jdk/src/java.base/share/classes/jdk/internal/jrtfs/JrtFileSystem.java
index 49285b31dfb..d544e4c0deb 100644
--- a/jdk/src/java.base/share/classes/jdk/internal/jrtfs/JrtFileSystem.java
+++ b/jdk/src/java.base/share/classes/jdk/internal/jrtfs/JrtFileSystem.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2017, 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
@@ -106,6 +106,7 @@ class JrtFileSystem extends FileSystem {
}
@Override
+ @SuppressWarnings("deprecation")
protected void finalize() throws Throwable {
try {
cleanup();
diff --git a/jdk/src/java.base/share/classes/jdk/internal/loader/BootLoader.java b/jdk/src/java.base/share/classes/jdk/internal/loader/BootLoader.java
index 72148adb5bd..07b5173e726 100644
--- a/jdk/src/java.base/share/classes/jdk/internal/loader/BootLoader.java
+++ b/jdk/src/java.base/share/classes/jdk/internal/loader/BootLoader.java
@@ -27,8 +27,6 @@ package jdk.internal.loader;
import java.io.IOException;
import java.io.InputStream;
import java.lang.module.ModuleReference;
-import java.lang.reflect.Layer;
-import java.lang.reflect.Module;
import java.net.MalformedURLException;
import java.net.URI;
import java.net.URL;
@@ -62,8 +60,7 @@ public class BootLoader {
private static final String JAVA_HOME = System.getProperty("java.home");
static {
- UNNAMED_MODULE
- = SharedSecrets.getJavaLangReflectModuleAccess().defineUnnamedModule(null);
+ UNNAMED_MODULE = SharedSecrets.getJavaLangAccess().defineUnnamedModule(null);
setBootLoaderUnnamedModule0(UNNAMED_MODULE);
}
@@ -255,7 +252,7 @@ public class BootLoader {
if (mn != null) {
// named module from runtime image or exploded module
- Optional om = Layer.boot().findModule(mn);
+ Optional om = ModuleLayer.boot().findModule(mn);
if (!om.isPresent())
throw new InternalError(mn + " not in boot layer");
return om.get();
diff --git a/jdk/src/java.base/share/classes/jdk/internal/loader/ClassLoaders.java b/jdk/src/java.base/share/classes/jdk/internal/loader/ClassLoaders.java
index 64492508dc0..972902651fe 100644
--- a/jdk/src/java.base/share/classes/jdk/internal/loader/ClassLoaders.java
+++ b/jdk/src/java.base/share/classes/jdk/internal/loader/ClassLoaders.java
@@ -27,7 +27,6 @@ package jdk.internal.loader;
import java.io.File;
import java.io.IOException;
-import java.lang.reflect.Module;
import java.net.URL;
import java.nio.file.InvalidPathException;
import java.nio.file.Paths;
diff --git a/jdk/src/java.base/share/classes/jdk/internal/loader/Loader.java b/jdk/src/java.base/share/classes/jdk/internal/loader/Loader.java
index ca90e80a1ea..0eb249de0d9 100644
--- a/jdk/src/java.base/share/classes/jdk/internal/loader/Loader.java
+++ b/jdk/src/java.base/share/classes/jdk/internal/loader/Loader.java
@@ -33,7 +33,6 @@ import java.lang.module.ModuleDescriptor;
import java.lang.module.ModuleReader;
import java.lang.module.ModuleReference;
import java.lang.module.ResolvedModule;
-import java.lang.reflect.Layer;
import java.net.MalformedURLException;
import java.net.URI;
import java.net.URL;
@@ -80,8 +79,8 @@ import jdk.internal.module.Resources;
* loader. This allows automatic modules (for example) to link to types in the
* unnamed module of the parent class loader.
*
- * @see Layer#defineModulesWithOneLoader
- * @see Layer#defineModulesWithManyLoaders
+ * @see ModuleModuleLayer#defineModulesWithOneLoader
+ * @see ModuleModuleLayer#defineModulesWithManyLoaders
*/
public final class Loader extends SecureClassLoader {
@@ -207,10 +206,10 @@ public final class Loader extends SecureClassLoader {
* @param cf the Configuration containing at least modules to be defined to
* this class loader
*
- * @param parentLayers the parent Layers
+ * @param parentModuleLayers the parent ModuleLayers
*/
public Loader initRemotePackageMap(Configuration cf,
- List parentLayers)
+ List parentModuleLayers)
{
for (String name : nameToModule.keySet()) {
ResolvedModule resolvedModule = cf.findModule(name).get();
@@ -236,8 +235,8 @@ public final class Loader extends SecureClassLoader {
} else {
// find the layer for the target module
- Layer layer = parentLayers.stream()
- .map(parent -> findLayer(parent, other.configuration()))
+ ModuleLayer layer = parentModuleLayers.stream()
+ .map(parent -> findModuleLayer(parent, other.configuration()))
.flatMap(Optional::stream)
.findAny()
.orElseThrow(() ->
@@ -286,8 +285,8 @@ public final class Loader extends SecureClassLoader {
* Find the layer corresponding to the given configuration in the tree
* of layers rooted at the given parent.
*/
- private Optional findLayer(Layer parent, Configuration cf) {
- return SharedSecrets.getJavaLangReflectModuleAccess().layers(parent)
+ private Optional findModuleLayer(ModuleLayer parent, Configuration cf) {
+ return SharedSecrets.getJavaLangAccess().layers(parent)
.filter(l -> l.configuration() == cf)
.findAny();
}
diff --git a/jdk/src/java.base/share/classes/jdk/internal/loader/LoaderPool.java b/jdk/src/java.base/share/classes/jdk/internal/loader/LoaderPool.java
index 14b088c14a9..a16f2447947 100644
--- a/jdk/src/java.base/share/classes/jdk/internal/loader/LoaderPool.java
+++ b/jdk/src/java.base/share/classes/jdk/internal/loader/LoaderPool.java
@@ -27,7 +27,6 @@ package jdk.internal.loader;
import java.lang.module.Configuration;
import java.lang.module.ResolvedModule;
-import java.lang.reflect.Layer;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -36,7 +35,7 @@ import java.util.stream.Stream;
/**
* A pool of class loaders.
*
- * @see Layer#defineModulesWithManyLoaders
+ * @see ModuleLayer#defineModulesWithManyLoaders
*/
public final class LoaderPool {
@@ -51,7 +50,7 @@ public final class LoaderPool {
* created with the given parent class loader as its parent.
*/
public LoaderPool(Configuration cf,
- List parentLayers,
+ List parentLayers,
ClassLoader parentLoader)
{
Map loaders = new HashMap<>();
diff --git a/jdk/src/java.base/share/classes/jdk/internal/logger/DefaultLoggerFinder.java b/jdk/src/java.base/share/classes/jdk/internal/logger/DefaultLoggerFinder.java
index 18ccc33442e..5ffd8fd7af4 100644
--- a/jdk/src/java.base/share/classes/jdk/internal/logger/DefaultLoggerFinder.java
+++ b/jdk/src/java.base/share/classes/jdk/internal/logger/DefaultLoggerFinder.java
@@ -34,7 +34,6 @@ import java.util.Objects;
import java.lang.System.LoggerFinder;
import java.lang.System.Logger;
import java.lang.ref.ReferenceQueue;
-import java.lang.reflect.Module;
import java.security.AccessController;
import java.security.PrivilegedAction;
import java.util.Collection;
diff --git a/jdk/src/java.base/share/classes/jdk/internal/logger/LazyLoggers.java b/jdk/src/java.base/share/classes/jdk/internal/logger/LazyLoggers.java
index 6c65426ca8e..c266caac684 100644
--- a/jdk/src/java.base/share/classes/jdk/internal/logger/LazyLoggers.java
+++ b/jdk/src/java.base/share/classes/jdk/internal/logger/LazyLoggers.java
@@ -31,7 +31,6 @@ import java.util.function.BiFunction;
import java.lang.System.LoggerFinder;
import java.lang.System.Logger;
import java.lang.ref.WeakReference;
-import java.lang.reflect.Module;
import java.util.Objects;
import jdk.internal.misc.VM;
import sun.util.logging.PlatformLogger;
@@ -402,10 +401,10 @@ public final class LazyLoggers {
* @param module The module on behalf of which the logger is created.
* If the module is not loaded from the Boot ClassLoader,
* the LoggerFinder is accessed and the logger returned
- * by {@link LoggerFinder#getLogger(java.lang.String, java.lang.reflect.Module)}
+ * by {@link LoggerFinder#getLogger(java.lang.String, java.lang.Module)}
* is returned to the caller directly.
* Otherwise, the logger returned by
- * {@link #getLazyLogger(java.lang.String, java.lang.reflect.Module)}
+ * {@link #getLazyLogger(java.lang.String, java.lang.Module)}
* is returned to the caller.
*
* @return a (possibly lazy) Logger instance.
diff --git a/jdk/src/java.base/share/classes/jdk/internal/misc/JavaLangAccess.java b/jdk/src/java.base/share/classes/jdk/internal/misc/JavaLangAccess.java
index 5d5e27d3e2b..ece20d827a4 100644
--- a/jdk/src/java.base/share/classes/jdk/internal/misc/JavaLangAccess.java
+++ b/jdk/src/java.base/share/classes/jdk/internal/misc/JavaLangAccess.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2017, 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
@@ -27,10 +27,10 @@ package jdk.internal.misc;
import java.io.IOException;
import java.lang.annotation.Annotation;
+import java.lang.module.ModuleDescriptor;
import java.lang.reflect.Executable;
-import java.lang.reflect.Layer;
import java.lang.reflect.Method;
-import java.lang.reflect.Module;
+import java.net.URI;
import java.net.URL;
import java.security.AccessControlContext;
import java.security.ProtectionDomain;
@@ -38,6 +38,7 @@ import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import java.util.stream.Stream;
+import jdk.internal.module.ServicesCatalog;
import jdk.internal.reflect.ConstantPool;
import sun.reflect.annotation.AnnotationType;
import sun.nio.ch.Interruptible;
@@ -139,11 +140,6 @@ public interface JavaLangAccess {
*/
void invokeFinalize(Object o) throws Throwable;
- /**
- * Returns the boot Layer
- */
- Layer getBootLayer();
-
/**
* Returns the ConcurrentHashMap used as a storage for ClassLoaderValue(s)
* associated with the given class loader, creating it if it doesn't already exist.
@@ -185,4 +181,74 @@ public interface JavaLangAccess {
* Invalidate package access cache
*/
void invalidatePackageAccessCache();
+
+ /**
+ * Defines a new module to the Java virtual machine. The module
+ * is defined to the given class loader.
+ *
+ * The URI is for information purposes only, it can be {@code null}.
+ */
+ Module defineModule(ClassLoader loader, ModuleDescriptor descriptor, URI uri);
+
+ /**
+ * Defines the unnamed module for the given class loader.
+ */
+ Module defineUnnamedModule(ClassLoader loader);
+
+ /**
+ * Updates the readability so that module m1 reads m2. The new read edge
+ * does not result in a strong reference to m2 (m2 can be GC'ed).
+ *
+ * This method is the same as m1.addReads(m2) but without a permission check.
+ */
+ void addReads(Module m1, Module m2);
+
+ /**
+ * Updates module m to read all unnamed modules.
+ */
+ void addReadsAllUnnamed(Module m);
+
+ /**
+ * Updates module m1 to export a package to module m2. The export does
+ * not result in a strong reference to m2 (m2 can be GC'ed).
+ */
+ void addExports(Module m1, String pkg, Module m2);
+
+ /**
+ * Updates a module m to export a package to all unnamed modules.
+ */
+ void addExportsToAllUnnamed(Module m, String pkg);
+
+ /**
+ * Updates module m1 to open a package to module m2. Opening the
+ * package does not result in a strong reference to m2 (m2 can be GC'ed).
+ */
+ void addOpens(Module m1, String pkg, Module m2);
+
+ /**
+ * Updates a module m to open a package to all unnamed modules.
+ */
+ void addOpensToAllUnnamed(Module m, String pkg);
+
+ /**
+ * Updates a module m to use a service.
+ */
+ void addUses(Module m, Class> service);
+
+ /**
+ * Returns the ServicesCatalog for the given Layer.
+ */
+ ServicesCatalog getServicesCatalog(ModuleLayer layer);
+
+ /**
+ * Returns an ordered stream of layers. The first element is is the
+ * given layer, the remaining elements are its parents, in DFS order.
+ */
+ Stream layers(ModuleLayer layer);
+
+ /**
+ * Returns a stream of the layers that have modules defined to the
+ * given class loader.
+ */
+ Stream layers(ClassLoader loader);
}
diff --git a/jdk/src/java.base/share/classes/jdk/internal/misc/JavaLangReflectModuleAccess.java b/jdk/src/java.base/share/classes/jdk/internal/misc/JavaLangReflectModuleAccess.java
deleted file mode 100644
index c8a2039d3ce..00000000000
--- a/jdk/src/java.base/share/classes/jdk/internal/misc/JavaLangReflectModuleAccess.java
+++ /dev/null
@@ -1,121 +0,0 @@
-/*
- * Copyright (c) 2014, 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.misc;
-
-import java.lang.module.ModuleDescriptor;
-import java.lang.reflect.Layer;
-import java.lang.reflect.Module;
-import java.net.URI;
-import java.util.stream.Stream;
-
-import jdk.internal.module.ServicesCatalog;
-
-/**
- * Provides access to non-public methods in java.lang.reflect.Module
- */
-
-public interface JavaLangReflectModuleAccess {
-
- /**
- * Defines the unnamed module for the given class loader.
- */
- Module defineUnnamedModule(ClassLoader loader);
-
- /**
- * Defines a new module to the Java virtual machine. The module
- * is defined to the given class loader.
- *
- * The URI is for information purposes only, it can be {@code null}.
- */
- Module defineModule(ClassLoader loader, ModuleDescriptor descriptor, URI uri);
-
- /**
- * Updates the readability so that module m1 reads m2. The new read edge
- * does not result in a strong reference to m2 (m2 can be GC'ed).
- *
- * This method is the same as m1.addReads(m2) but without a permission check.
- */
- void addReads(Module m1, Module m2);
-
- /**
- * Updates module m to read all unnamed modules.
- */
- void addReadsAllUnnamed(Module m);
-
- /**
- * Update module m to export a package to all modules.
- */
- void addExports(Module m, String pn);
-
- /**
- * Updates module m1 to export a package to module m2. The export does
- * not result in a strong reference to m2 (m2 can be GC'ed).
- */
- void addExports(Module m1, String pkg, Module m2);
-
- /**
- * Updates a module m to export a package to all unnamed modules.
- */
- void addExportsToAllUnnamed(Module m, String pkg);
-
- /**
- * Updates a module m to open a package to all modules.
- */
- void addOpens(Module m, String pkg);
-
- /**
- * Updates module m1 to open a package to module m2. Opening the
- * package does not result in a strong reference to m2 (m2 can be GC'ed).
- */
- void addOpens(Module m1, String pkg, Module m2);
-
- /**
- * Updates a module m to open a package to all unnamed modules.
- */
- void addOpensToAllUnnamed(Module m, String pkg);
-
- /**
- * Updates a module m to use a service.
- */
- void addUses(Module m, Class> service);
-
- /**
- * Returns the ServicesCatalog for the given Layer.
- */
- ServicesCatalog getServicesCatalog(Layer layer);
-
- /**
- * Returns an ordered stream of layers. The first element is is the
- * given layer, the remaining elements are its parents, in DFS order.
- */
- Stream layers(Layer layer);
-
- /**
- * Returns a stream of the layers that have modules defined to the
- * given class loader.
- */
- Stream layers(ClassLoader loader);
-}
\ No newline at end of file
diff --git a/jdk/src/java.base/share/classes/jdk/internal/misc/JavaUtilResourceBundleAccess.java b/jdk/src/java.base/share/classes/jdk/internal/misc/JavaUtilResourceBundleAccess.java
index b137c3d48c4..c0eb99d7dbf 100644
--- a/jdk/src/java.base/share/classes/jdk/internal/misc/JavaUtilResourceBundleAccess.java
+++ b/jdk/src/java.base/share/classes/jdk/internal/misc/JavaUtilResourceBundleAccess.java
@@ -25,7 +25,6 @@
package jdk.internal.misc;
-import java.lang.reflect.Module;
import java.util.Locale;
import java.util.ResourceBundle;
diff --git a/jdk/src/java.base/share/classes/jdk/internal/misc/SharedSecrets.java b/jdk/src/java.base/share/classes/jdk/internal/misc/SharedSecrets.java
index 321a4ca1fb2..cd54d422c21 100644
--- a/jdk/src/java.base/share/classes/jdk/internal/misc/SharedSecrets.java
+++ b/jdk/src/java.base/share/classes/jdk/internal/misc/SharedSecrets.java
@@ -50,7 +50,6 @@ public class SharedSecrets {
private static JavaUtilJarAccess javaUtilJarAccess;
private static JavaLangAccess javaLangAccess;
private static JavaLangModuleAccess javaLangModuleAccess;
- private static JavaLangReflectModuleAccess javaLangReflectModuleAccess;
private static JavaLangInvokeAccess javaLangInvokeAccess;
private static JavaLangRefAccess javaLangRefAccess;
private static JavaIOAccess javaIOAccess;
@@ -119,16 +118,6 @@ public class SharedSecrets {
return javaLangModuleAccess;
}
- public static void setJavaLangReflectModuleAccess(JavaLangReflectModuleAccess jlrma) {
- javaLangReflectModuleAccess = jlrma;
- }
-
- public static JavaLangReflectModuleAccess getJavaLangReflectModuleAccess() {
- if (javaLangReflectModuleAccess == null)
- unsafe.ensureClassInitialized(java.lang.reflect.Module.class);
- return javaLangReflectModuleAccess;
- }
-
public static void setJavaLangRefAccess(JavaLangRefAccess jlra) {
javaLangRefAccess = jlra;
}
diff --git a/jdk/src/java.base/share/classes/jdk/internal/module/IllegalAccessLogger.java b/jdk/src/java.base/share/classes/jdk/internal/module/IllegalAccessLogger.java
index a502cd0c762..3914ce923fc 100644
--- a/jdk/src/java.base/share/classes/jdk/internal/module/IllegalAccessLogger.java
+++ b/jdk/src/java.base/share/classes/jdk/internal/module/IllegalAccessLogger.java
@@ -27,7 +27,6 @@ package jdk.internal.module;
import java.io.PrintStream;
import java.lang.invoke.MethodHandles;
-import java.lang.reflect.Module;
import java.net.URL;
import java.security.AccessController;
import java.security.CodeSource;
diff --git a/jdk/src/java.base/share/classes/jdk/internal/module/ModuleBootstrap.java b/jdk/src/java.base/share/classes/jdk/internal/module/ModuleBootstrap.java
index 98f5cf0db2e..061b2294158 100644
--- a/jdk/src/java.base/share/classes/jdk/internal/module/ModuleBootstrap.java
+++ b/jdk/src/java.base/share/classes/jdk/internal/module/ModuleBootstrap.java
@@ -32,9 +32,6 @@ import java.lang.module.ModuleDescriptor;
import java.lang.module.ModuleFinder;
import java.lang.module.ModuleReference;
import java.lang.module.ResolvedModule;
-import java.lang.reflect.Layer;
-import java.lang.reflect.LayerInstantiationException;
-import java.lang.reflect.Module;
import java.net.URI;
import java.nio.file.Path;
import java.nio.file.Paths;
@@ -61,7 +58,7 @@ import jdk.internal.perf.PerfCounter;
* resolving a set of module names specified via the launcher (or equivalent)
* -m and --add-modules options. The modules are located on a module path that
* is constructed from the upgrade module path, system modules, and application
- * module path. The Configuration is instantiated as the boot Layer with each
+ * module path. The Configuration is instantiated as the boot layer with each
* module in the the configuration defined to one of the built-in class loaders.
*/
@@ -106,11 +103,11 @@ public final class ModuleBootstrap {
}
/**
- * Initialize the module system, returning the boot Layer.
+ * Initialize the module system, returning the boot layer.
*
* @see java.lang.System#initPhase2()
*/
- public static Layer boot() {
+ public static ModuleLayer boot() {
long t0 = System.nanoTime();
@@ -237,7 +234,6 @@ public final class ModuleBootstrap {
ModuleFinder f = finder; // observable modules
systemModules.findAll()
.stream()
- .filter(mref -> !ModuleResolution.doNotResolveByDefault(mref))
.map(ModuleReference::descriptor)
.map(ModuleDescriptor::name)
.filter(mn -> f.find(mn).isPresent()) // observable
@@ -321,8 +317,7 @@ public final class ModuleBootstrap {
if (SystemModules.hasSplitPackages() || needPostResolutionChecks) {
Map packageToModule = new HashMap<>();
for (ResolvedModule resolvedModule : cf.modules()) {
- ModuleDescriptor descriptor =
- resolvedModule.reference().descriptor();
+ ModuleDescriptor descriptor = resolvedModule.reference().descriptor();
String name = descriptor.name();
for (String p : descriptor.packages()) {
String other = packageToModule.putIfAbsent(p, name);
@@ -338,7 +333,7 @@ public final class ModuleBootstrap {
long t4 = System.nanoTime();
// define modules to VM/runtime
- Layer bootLayer = Layer.empty().defineModules(cf, clf);
+ ModuleLayer bootLayer = ModuleLayer.empty().defineModules(cf, clf);
PerfCounters.layerCreateTime.addElapsedTimeFrom(t4);
@@ -476,7 +471,7 @@ public final class ModuleBootstrap {
* Process the --add-reads options to add any additional read edges that
* are specified on the command-line.
*/
- private static void addExtraReads(Layer bootLayer) {
+ private static void addExtraReads(ModuleLayer bootLayer) {
// decode the command line options
Map> map = decode("jdk.module.addreads.");
@@ -514,7 +509,7 @@ public final class ModuleBootstrap {
* Process the --add-exports and --add-opens options to export/open
* additional packages specified on the command-line.
*/
- private static void addExtraExportsAndOpens(Layer bootLayer) {
+ private static void addExtraExportsAndOpens(ModuleLayer bootLayer) {
// --add-exports
String prefix = "jdk.module.addexports.";
Map> extraExports = decode(prefix);
@@ -548,7 +543,7 @@ public final class ModuleBootstrap {
}
}
- private static void addExtraExportsOrOpens(Layer bootLayer,
+ private static void addExtraExportsOrOpens(ModuleLayer bootLayer,
Map> map,
boolean opens)
{
diff --git a/jdk/src/java.base/share/classes/jdk/internal/module/ModulePatcher.java b/jdk/src/java.base/share/classes/jdk/internal/module/ModulePatcher.java
index 5321d2a36d3..3f5827bfc54 100644
--- a/jdk/src/java.base/share/classes/jdk/internal/module/ModulePatcher.java
+++ b/jdk/src/java.base/share/classes/jdk/internal/module/ModulePatcher.java
@@ -135,8 +135,9 @@ public final class ModulePatcher {
Path top = file;
Files.find(top, Integer.MAX_VALUE,
((path, attrs) -> attrs.isRegularFile()))
- .filter(path -> !isAutomatic
+ .filter(path -> (!isAutomatic
|| path.toString().endsWith(".class"))
+ && !isHidden(path))
.map(path -> toPackageName(top, path))
.filter(Checks::isPackageName)
.forEach(packages::add);
@@ -177,11 +178,13 @@ public final class ModulePatcher {
ModuleTarget target = null;
ModuleHashes recordedHashes = null;
+ ModuleHashes.HashSupplier hasher = null;
ModuleResolution mres = null;
if (mref instanceof ModuleReferenceImpl) {
ModuleReferenceImpl impl = (ModuleReferenceImpl)mref;
target = impl.moduleTarget();
recordedHashes = impl.recordedHashes();
+ hasher = impl.hasher();
mres = impl.moduleResolution();
}
@@ -191,7 +194,7 @@ public final class ModulePatcher {
this,
target,
recordedHashes,
- null,
+ hasher,
mres);
}
@@ -556,7 +559,7 @@ public final class ModulePatcher {
/**
- * Derives a package name from a file path to a .class file.
+ * Derives a package name from the file path of an entry in an exploded patch
*/
private static String toPackageName(Path top, Path file) {
Path entry = top.relativize(file);
@@ -568,6 +571,17 @@ public final class ModulePatcher {
}
}
+ /**
+ * Returns true if the given file exists and is a hidden file
+ */
+ private boolean isHidden(Path file) {
+ try {
+ return Files.isHidden(file);
+ } catch (IOException ioe) {
+ return false;
+ }
+ }
+
/**
* Derives a package name from the name of an entry in a JAR file.
*/
diff --git a/jdk/src/java.base/share/classes/jdk/internal/module/ModulePath.java b/jdk/src/java.base/share/classes/jdk/internal/module/ModulePath.java
index 89e81d178f7..75a76b0858f 100644
--- a/jdk/src/java.base/share/classes/jdk/internal/module/ModulePath.java
+++ b/jdk/src/java.base/share/classes/jdk/internal/module/ModulePath.java
@@ -547,7 +547,6 @@ public class ModulePath implements ModuleFinder {
*/
private static class Patterns {
static final Pattern DASH_VERSION = Pattern.compile("-(\\d+(\\.|$))");
- static final Pattern TRAILING_VERSION = Pattern.compile("(\\.|\\d)*$");
static final Pattern NON_ALPHANUM = Pattern.compile("[^A-Za-z0-9]");
static final Pattern REPEATING_DOTS = Pattern.compile("(\\.)(\\1)+");
static final Pattern LEADING_DOTS = Pattern.compile("^\\.");
@@ -558,9 +557,6 @@ public class ModulePath implements ModuleFinder {
* Clean up candidate module name derived from a JAR file name.
*/
private static String cleanModuleName(String mn) {
- // drop trailing version from name
- mn = Patterns.TRAILING_VERSION.matcher(mn).replaceAll("");
-
// replace non-alphanumeric
mn = Patterns.NON_ALPHANUM.matcher(mn).replaceAll(".");
@@ -630,7 +626,7 @@ public class ModulePath implements ModuleFinder {
private Set explodedPackages(Path dir) {
try {
return Files.find(dir, Integer.MAX_VALUE,
- ((path, attrs) -> attrs.isRegularFile()))
+ ((path, attrs) -> attrs.isRegularFile() && !isHidden(path)))
.map(path -> dir.relativize(path))
.map(this::toPackageName)
.flatMap(Optional::stream)
@@ -726,6 +722,17 @@ public class ModulePath implements ModuleFinder {
}
}
+ /**
+ * Returns true if the given file exists and is a hidden file
+ */
+ private boolean isHidden(Path file) {
+ try {
+ return Files.isHidden(file);
+ } catch (IOException ioe) {
+ return false;
+ }
+ }
+
private static final PerfCounter scanTime
= PerfCounter.newPerfCounter("jdk.module.finder.modulepath.scanTime");
private static final PerfCounter moduleCount
diff --git a/jdk/src/java.base/share/classes/jdk/internal/module/Modules.java b/jdk/src/java.base/share/classes/jdk/internal/module/Modules.java
index 696aa64b3a5..62288625b76 100644
--- a/jdk/src/java.base/share/classes/jdk/internal/module/Modules.java
+++ b/jdk/src/java.base/share/classes/jdk/internal/module/Modules.java
@@ -26,15 +26,13 @@
package jdk.internal.module;
import java.lang.module.ModuleDescriptor;
-import java.lang.reflect.Layer;
-import java.lang.reflect.Module;
import java.net.URI;
import java.security.AccessController;
import java.security.PrivilegedAction;
import jdk.internal.loader.BootLoader;
import jdk.internal.loader.ClassLoaders;
-import jdk.internal.misc.JavaLangReflectModuleAccess;
+import jdk.internal.misc.JavaLangAccess;
import jdk.internal.misc.SharedSecrets;
/**
@@ -51,8 +49,7 @@ import jdk.internal.misc.SharedSecrets;
public class Modules {
private Modules() { }
- private static final JavaLangReflectModuleAccess JLRMA
- = SharedSecrets.getJavaLangReflectModuleAccess();
+ private static final JavaLangAccess JLA = SharedSecrets.getJavaLangAccess();
/**
* Creates a new Module. The module has the given ModuleDescriptor and
@@ -67,7 +64,7 @@ public class Modules {
ModuleDescriptor descriptor,
URI uri)
{
- return JLRMA.defineModule(loader, descriptor, uri);
+ return JLA.defineModule(loader, descriptor, uri);
}
/**
@@ -75,23 +72,14 @@ public class Modules {
* Same as m1.addReads(m2) but without a caller check.
*/
public static void addReads(Module m1, Module m2) {
- JLRMA.addReads(m1, m2);
+ JLA.addReads(m1, m2);
}
/**
* Update module m to read all unnamed modules.
*/
public static void addReadsAllUnnamed(Module m) {
- JLRMA.addReadsAllUnnamed(m);
- }
-
- /**
- * Update module m to export a package to all modules.
- *
- * This method is for intended for use by tests only.
- */
- public static void addExports(Module m, String pn) {
- JLRMA.addExports(m, pn);
+ JLA.addReadsAllUnnamed(m);
}
/**
@@ -99,23 +87,14 @@ public class Modules {
* Same as m1.addExports(pn, m2) but without a caller check
*/
public static void addExports(Module m1, String pn, Module m2) {
- JLRMA.addExports(m1, pn, m2);
+ JLA.addExports(m1, pn, m2);
}
/**
* Updates module m to export a package to all unnamed modules.
*/
public static void addExportsToAllUnnamed(Module m, String pn) {
- JLRMA.addExportsToAllUnnamed(m, pn);
- }
-
- /**
- * Update module m to open a package to all modules.
- *
- * This method is for intended for use by tests only.
- */
- public static void addOpens(Module m, String pn) {
- JLRMA.addOpens(m, pn);
+ JLA.addExportsToAllUnnamed(m, pn);
}
/**
@@ -123,14 +102,14 @@ public class Modules {
* Same as m1.addOpens(pn, m2) but without a caller check.
*/
public static void addOpens(Module m1, String pn, Module m2) {
- JLRMA.addOpens(m1, pn, m2);
+ JLA.addOpens(m1, pn, m2);
}
/**
* Updates module m to open a package to all unnamed modules.
*/
public static void addOpensToAllUnnamed(Module m, String pn) {
- JLRMA.addOpensToAllUnnamed(m, pn);
+ JLA.addOpensToAllUnnamed(m, pn);
}
/**
@@ -138,16 +117,16 @@ public class Modules {
* Same as m2.addUses(service) but without a caller check.
*/
public static void addUses(Module m, Class> service) {
- JLRMA.addUses(m, service);
+ JLA.addUses(m, service);
}
/**
* Updates module m to provide a service
*/
public static void addProvides(Module m, Class> service, Class> impl) {
- Layer layer = m.getLayer();
+ ModuleLayer layer = m.getLayer();
- if (layer == null || layer == Layer.boot()) {
+ if (layer == null || layer == ModuleLayer.boot()) {
// update ClassLoader catalog
PrivilegedAction pa = m::getClassLoader;
ClassLoader loader = AccessController.doPrivileged(pa);
@@ -162,9 +141,7 @@ public class Modules {
if (layer != null) {
// update Layer catalog
- SharedSecrets.getJavaLangReflectModuleAccess()
- .getServicesCatalog(layer)
- .addProvider(m, service, impl);
+ JLA.getServicesCatalog(layer).addProvider(m, service, impl);
}
}
diff --git a/jdk/src/java.base/share/classes/jdk/internal/module/ServicesCatalog.java b/jdk/src/java.base/share/classes/jdk/internal/module/ServicesCatalog.java
index d4425aadbb8..f0d7126adc8 100644
--- a/jdk/src/java.base/share/classes/jdk/internal/module/ServicesCatalog.java
+++ b/jdk/src/java.base/share/classes/jdk/internal/module/ServicesCatalog.java
@@ -25,7 +25,6 @@
package jdk.internal.module;
-import java.lang.reflect.Module;
import java.lang.module.ModuleDescriptor;
import java.lang.module.ModuleDescriptor.Provides;
import java.util.ArrayList;
diff --git a/jdk/src/java.base/share/classes/sun/invoke/util/VerifyAccess.java b/jdk/src/java.base/share/classes/sun/invoke/util/VerifyAccess.java
index c3633ff8aab..758d59aa0c0 100644
--- a/jdk/src/java.base/share/classes/sun/invoke/util/VerifyAccess.java
+++ b/jdk/src/java.base/share/classes/sun/invoke/util/VerifyAccess.java
@@ -27,7 +27,6 @@ package sun.invoke.util;
import java.lang.reflect.Modifier;
import static java.lang.reflect.Modifier.*;
-import java.lang.reflect.Module;
import java.util.Objects;
import jdk.internal.reflect.Reflection;
@@ -297,10 +296,13 @@ public class VerifyAccess {
* @param refc the class attempting to make the reference
*/
public static boolean isTypeVisible(java.lang.invoke.MethodType type, Class> refc) {
- for (int n = -1, max = type.parameterCount(); n < max; n++) {
- Class> ptype = (n < 0 ? type.returnType() : type.parameterType(n));
- if (!isTypeVisible(ptype, refc))
+ if (!isTypeVisible(type.returnType(), refc)) {
+ return false;
+ }
+ for (int n = 0, max = type.parameterCount(); n < max; n++) {
+ if (!isTypeVisible(type.parameterType(n), refc)) {
return false;
+ }
}
return true;
}
diff --git a/jdk/src/java.base/share/classes/sun/invoke/util/Wrapper.java b/jdk/src/java.base/share/classes/sun/invoke/util/Wrapper.java
index f22eda0ea45..9f1f31218b4 100644
--- a/jdk/src/java.base/share/classes/sun/invoke/util/Wrapper.java
+++ b/jdk/src/java.base/share/classes/sun/invoke/util/Wrapper.java
@@ -26,20 +26,20 @@
package sun.invoke.util;
public enum Wrapper {
- // wrapperType primitiveType char emptyArray format
- BOOLEAN( Boolean.class, boolean.class, 'Z', new boolean[0], Format.unsigned( 1)),
+ // wrapperType simple primitiveType simple char emptyArray format
+ BOOLEAN( Boolean.class, "Boolean", boolean.class, "boolean", 'Z', new boolean[0], Format.unsigned( 1)),
// These must be in the order defined for widening primitive conversions in JLS 5.1.2
// Avoid boxing integral types here to defer initialization of internal caches
- BYTE ( Byte.class, byte.class, 'B', new byte[0], Format.signed( 8)),
- SHORT ( Short.class, short.class, 'S', new short[0], Format.signed( 16)),
- CHAR (Character.class, char.class, 'C', new char[0], Format.unsigned(16)),
- INT ( Integer.class, int.class, 'I', new int[0], Format.signed( 32)),
- LONG ( Long.class, long.class, 'J', new long[0], Format.signed( 64)),
- FLOAT ( Float.class, float.class, 'F', new float[0], Format.floating(32)),
- DOUBLE ( Double.class, double.class, 'D', new double[0], Format.floating(64)),
- OBJECT ( Object.class, Object.class, 'L', new Object[0], Format.other( 1)),
+ BYTE ( Byte.class, "Byte", byte.class, "byte", 'B', new byte[0], Format.signed( 8)),
+ SHORT ( Short.class, "Short", short.class, "short", 'S', new short[0], Format.signed( 16)),
+ CHAR (Character.class, "Character", char.class, "char", 'C', new char[0], Format.unsigned(16)),
+ INT ( Integer.class, "Integer", int.class, "int", 'I', new int[0], Format.signed( 32)),
+ LONG ( Long.class, "Long", long.class, "long", 'J', new long[0], Format.signed( 64)),
+ FLOAT ( Float.class, "Float", float.class, "float", 'F', new float[0], Format.floating(32)),
+ DOUBLE ( Double.class, "Double", double.class, "double", 'D', new double[0], Format.floating(64)),
+ OBJECT ( Object.class, "Object", Object.class, "Object", 'L', new Object[0], Format.other( 1)),
// VOID must be the last type, since it is "assignable" from any other type:
- VOID ( Void.class, void.class, 'V', null, Format.other( 0)),
+ VOID ( Void.class, "Void", void.class, "void", 'V', null, Format.other( 0)),
;
public static final int COUNT = 10;
@@ -52,14 +52,14 @@ public enum Wrapper {
private final String wrapperSimpleName;
private final String primitiveSimpleName;
- private Wrapper(Class> wtype, Class> ptype, char tchar, Object emptyArray, int format) {
+ private Wrapper(Class> wtype, String wtypeName, Class> ptype, String ptypeName, char tchar, Object emptyArray, int format) {
this.wrapperType = wtype;
this.primitiveType = ptype;
this.basicTypeChar = tchar;
this.emptyArray = emptyArray;
this.format = format;
- this.wrapperSimpleName = wtype.getSimpleName();
- this.primitiveSimpleName = ptype.getSimpleName();
+ this.wrapperSimpleName = wtypeName;
+ this.primitiveSimpleName = ptypeName;
}
/** For debugging, give the details of this wrapper. */
@@ -518,12 +518,6 @@ public enum Wrapper {
* If the target type is a primitive, change it to a wrapper.
*/
static Class forceType(Class> type, Class exampleType) {
- boolean z = (type == exampleType ||
- type.isPrimitive() && forPrimitiveType(type) == findWrapperType(exampleType) ||
- exampleType.isPrimitive() && forPrimitiveType(exampleType) == findWrapperType(type) ||
- type == Object.class && !exampleType.isPrimitive());
- if (!z)
- System.out.println(type+" <= "+exampleType);
assert(type == exampleType ||
type.isPrimitive() && forPrimitiveType(type) == findWrapperType(exampleType) ||
exampleType.isPrimitive() && forPrimitiveType(exampleType) == findWrapperType(type) ||
diff --git a/jdk/src/java.base/share/classes/sun/launcher/LauncherHelper.java b/jdk/src/java.base/share/classes/sun/launcher/LauncherHelper.java
index c86075a260b..d6cc3661d00 100644
--- a/jdk/src/java.base/share/classes/sun/launcher/LauncherHelper.java
+++ b/jdk/src/java.base/share/classes/sun/launcher/LauncherHelper.java
@@ -50,10 +50,8 @@ import java.lang.module.ModuleDescriptor.Requires;
import java.lang.module.ModuleDescriptor.Exports;
import java.lang.module.ModuleDescriptor.Opens;
import java.lang.module.ModuleDescriptor.Provides;
-import java.lang.reflect.Layer;
import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
-import java.lang.reflect.Module;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.net.URI;
@@ -467,7 +465,7 @@ public final class LauncherHelper {
String mn = s[0];
String pn = s[1];
- Layer.boot().findModule(mn).ifPresent(m -> {
+ ModuleLayer.boot().findModule(mn).ifPresent(m -> {
if (m.getDescriptor().packages().contains(pn)) {
if (open) {
Modules.addOpensToAllUnnamed(m, pn);
@@ -564,7 +562,7 @@ public final class LauncherHelper {
}
// main module is in the boot layer
- Layer layer = Layer.boot();
+ ModuleLayer layer = ModuleLayer.boot();
Optional om = layer.findModule(mainModule);
if (!om.isPresent()) {
// should not happen
@@ -854,7 +852,7 @@ public final class LauncherHelper {
private static void setFXLaunchParameters(String what, int mode) {
// find the module with the FX launcher
- Optional om = Layer.boot().findModule(JAVAFX_GRAPHICS_MODULE_NAME);
+ Optional om = ModuleLayer.boot().findModule(JAVAFX_GRAPHICS_MODULE_NAME);
if (!om.isPresent()) {
abort(null, "java.launcher.cls.error5");
}
@@ -938,8 +936,7 @@ public final class LauncherHelper {
* Called by the launcher to list the observable modules.
* If called without any sub-options then the output is a simple list of
* the modules. If called with sub-options then the sub-options are the
- * names of the modules to list (-listmods:java.base,java.desktop for
- * example).
+ * names of the modules to list (e.g. --list-modules java.base,java.desktop)
*/
static void listModules(boolean printToStderr, String optionFlag)
throws IOException, ClassNotFoundException
@@ -947,89 +944,97 @@ public final class LauncherHelper {
initOutput(printToStderr);
ModuleFinder finder = jdk.internal.module.ModuleBootstrap.finder();
-
int colon = optionFlag.indexOf('=');
if (colon == -1) {
finder.findAll().stream()
- .sorted(Comparator.comparing(ModuleReference::descriptor))
- .forEach(md -> {
- ostream.println(midAndLocation(md.descriptor(),
- md.location()));
- });
+ .sorted(Comparator.comparing(ModuleReference::descriptor))
+ .forEach(mref -> describeModule(finder, mref, false));
} else {
String[] names = optionFlag.substring(colon+1).split(",");
for (String name: names) {
ModuleReference mref = finder.find(name).orElse(null);
if (mref == null) {
- System.err.format("%s not observable!%n", name);
+ System.err.format("%s not found%n", name);
continue;
}
-
- ModuleDescriptor md = mref.descriptor();
- if (md.isOpen())
- ostream.print("open ");
- if (md.isAutomatic())
- ostream.print("automatic ");
- if (md.modifiers().contains(ModuleDescriptor.Modifier.SYNTHETIC))
- ostream.print("synthetic ");
- if (md.modifiers().contains(ModuleDescriptor.Modifier.MANDATED))
- ostream.print("mandated ");
- ostream.println("module " + midAndLocation(md, mref.location()));
-
- // unqualified exports (sorted by package)
- Set exports = new TreeSet<>(Comparator.comparing(Exports::source));
- md.exports().stream().filter(e -> !e.isQualified()).forEach(exports::add);
- for (Exports e : exports) {
- String modsAndSource = Stream.concat(toStringStream(e.modifiers()),
- Stream.of(e.source()))
- .collect(Collectors.joining(" "));
- ostream.format(" exports %s%n", modsAndSource);
- }
-
- for (Requires d : md.requires()) {
- ostream.format(" requires %s%n", d);
- }
- for (String s : md.uses()) {
- ostream.format(" uses %s%n", s);
- }
-
- for (Provides ps : md.provides()) {
- ostream.format(" provides %s with %s%n", ps.service(),
- ps.providers().stream().collect(Collectors.joining(", ")));
- }
-
- // qualified exports
- for (Exports e : md.exports()) {
- if (e.isQualified()) {
- String modsAndSource = Stream.concat(toStringStream(e.modifiers()),
- Stream.of(e.source()))
- .collect(Collectors.joining(" "));
- ostream.format(" exports %s", modsAndSource);
- formatCommaList(ostream, " to", e.targets());
- }
- }
-
- // open packages
- for (Opens obj: md.opens()) {
- String modsAndSource = Stream.concat(toStringStream(obj.modifiers()),
- Stream.of(obj.source()))
- .collect(Collectors.joining(" "));
- ostream.format(" opens %s", modsAndSource);
- if (obj.isQualified())
- formatCommaList(ostream, " to", obj.targets());
- else
- ostream.println();
- }
-
- // non-exported/non-open packages
- Set concealed = new TreeSet<>(md.packages());
- md.exports().stream().map(Exports::source).forEach(concealed::remove);
- md.opens().stream().map(Opens::source).forEach(concealed::remove);
- concealed.forEach(p -> ostream.format(" contains %s%n", p));
+ describeModule(finder, mref, true);
}
}
}
+ /**
+ * Describes the given module.
+ */
+ static void describeModule(ModuleFinder finder,
+ ModuleReference mref,
+ boolean verbose)
+ {
+ ModuleDescriptor md = mref.descriptor();
+ ostream.print("module " + midAndLocation(md, mref.location()));
+ if (md.isAutomatic())
+ ostream.print(" automatic");
+ ostream.println();
+
+ if (!verbose)
+ return;
+
+ // unqualified exports (sorted by package)
+ Set exports = new TreeSet<>(Comparator.comparing(Exports::source));
+ md.exports().stream().filter(e -> !e.isQualified()).forEach(exports::add);
+ for (Exports e : exports) {
+ String modsAndSource = Stream.concat(toStringStream(e.modifiers()),
+ Stream.of(e.source()))
+ .collect(Collectors.joining(" "));
+ ostream.format(" exports %s%n", modsAndSource);
+ }
+
+ for (Requires d : md.requires()) {
+ ostream.format(" requires %s", d);
+ String suffix = finder.find(d.name())
+ .map(ModuleReference::descriptor)
+ .map(any -> any.isAutomatic() ? " automatic" : "")
+ .orElse(" not found");
+ ostream.println(suffix);
+ }
+ for (String s : md.uses()) {
+ ostream.format(" uses %s%n", s);
+ }
+
+ for (Provides ps : md.provides()) {
+ ostream.format(" provides %s with %s%n", ps.service(),
+ ps.providers().stream().collect(Collectors.joining(", ")));
+ }
+
+ // qualified exports
+ for (Exports e : md.exports()) {
+ if (e.isQualified()) {
+ String modsAndSource = Stream.concat(toStringStream(e.modifiers()),
+ Stream.of(e.source()))
+ .collect(Collectors.joining(" "));
+ ostream.format(" exports %s", modsAndSource);
+ formatCommaList(ostream, " to", e.targets());
+ }
+ }
+
+ // open packages
+ for (Opens obj: md.opens()) {
+ String modsAndSource = Stream.concat(toStringStream(obj.modifiers()),
+ Stream.of(obj.source()))
+ .collect(Collectors.joining(" "));
+ ostream.format(" opens %s", modsAndSource);
+ if (obj.isQualified())
+ formatCommaList(ostream, " to", obj.targets());
+ else
+ ostream.println();
+ }
+
+ // non-exported/non-open packages
+ Set concealed = new TreeSet<>(md.packages());
+ md.exports().stream().map(Exports::source).forEach(concealed::remove);
+ md.opens().stream().map(Opens::source).forEach(concealed::remove);
+ concealed.forEach(p -> ostream.format(" contains %s%n", p));
+ }
+
static String toString(Set s) {
return toStringStream(s).collect(Collectors.joining(" "));
}
diff --git a/jdk/src/java.base/share/classes/sun/launcher/resources/launcher.properties b/jdk/src/java.base/share/classes/sun/launcher/resources/launcher.properties
index e65926dc2a4..7816cc058cc 100644
--- a/jdk/src/java.base/share/classes/sun/launcher/resources/launcher.properties
+++ b/jdk/src/java.base/share/classes/sun/launcher/resources/launcher.properties
@@ -39,7 +39,8 @@ java.launcher.opt.vmselect =\ {0}\t to select the "{1}" VM\n
java.launcher.opt.hotspot =\ {0}\t is a synonym for the "{1}" VM [deprecated]\n
# Translators please note do not translate the options themselves
-java.launcher.opt.footer =\ -cp \n\
+java.launcher.opt.footer = \
+\ -cp \n\
\ -classpath \n\
\ --class-path \n\
\ A {0} separated list of directories, JAR archives,\n\
@@ -101,8 +102,11 @@ java.launcher.opt.footer =\ -cp read options from the specified file\n\n\
+\ See the SplashScreen API documentation for more information\n\
+\ @argument files\n\
+\ one or more argument files containing options\n\
+\ -disable-@files\n\
+\ prevent further argument file expansion\n\
\To specify an argument for a long option, you can use --= or\n\
\-- .\n
diff --git a/jdk/src/java.base/share/classes/sun/net/www/MeteredStream.java b/jdk/src/java.base/share/classes/sun/net/www/MeteredStream.java
index 29b998a5e70..08ff179457a 100644
--- a/jdk/src/java.base/share/classes/sun/net/www/MeteredStream.java
+++ b/jdk/src/java.base/share/classes/sun/net/www/MeteredStream.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1994, 2004, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1994, 2017, 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
@@ -203,6 +203,7 @@ public class MeteredStream extends FilterInputStream {
return super.markSupported();
}
+ @SuppressWarnings("deprecation")
protected void finalize() throws Throwable {
try {
close();
diff --git a/jdk/src/java.base/share/classes/sun/net/www/protocol/https/DelegateHttpsURLConnection.java b/jdk/src/java.base/share/classes/sun/net/www/protocol/https/DelegateHttpsURLConnection.java
index b6ff7b417ac..2b5e5115cf3 100644
--- a/jdk/src/java.base/share/classes/sun/net/www/protocol/https/DelegateHttpsURLConnection.java
+++ b/jdk/src/java.base/share/classes/sun/net/www/protocol/https/DelegateHttpsURLConnection.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2001, 2005, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2001, 2017, 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
@@ -77,6 +77,7 @@ public class DelegateHttpsURLConnection extends AbstractDelegateHttpsURLConnecti
* Called by layered delegator's finalize() method to handle closing
* the underlying object.
*/
+ @SuppressWarnings("deprecation")
protected void dispose() throws Throwable {
super.finalize();
}
diff --git a/jdk/src/java.base/share/classes/sun/net/www/protocol/https/HttpsURLConnectionImpl.java b/jdk/src/java.base/share/classes/sun/net/www/protocol/https/HttpsURLConnectionImpl.java
index 1b2a584a79b..792af78675c 100644
--- a/jdk/src/java.base/share/classes/sun/net/www/protocol/https/HttpsURLConnectionImpl.java
+++ b/jdk/src/java.base/share/classes/sun/net/www/protocol/https/HttpsURLConnectionImpl.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2001, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2001, 2017, 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
@@ -478,6 +478,7 @@ public class HttpsURLConnectionImpl
* sun.net.www.protocol.http.HttpURLConnection's finalize()
* would have to be made public.
*/
+ @SuppressWarnings("deprecation")
protected void finalize() throws Throwable {
delegate.dispose();
}
diff --git a/jdk/src/java.base/share/classes/sun/nio/ch/DatagramChannelImpl.java b/jdk/src/java.base/share/classes/sun/nio/ch/DatagramChannelImpl.java
index 7f63ec88264..c4d508070d4 100644
--- a/jdk/src/java.base/share/classes/sun/nio/ch/DatagramChannelImpl.java
+++ b/jdk/src/java.base/share/classes/sun/nio/ch/DatagramChannelImpl.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2001, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2001, 2017, 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
@@ -1034,6 +1034,7 @@ class DatagramChannelImpl
}
}
+ @SuppressWarnings("deprecation")
protected void finalize() throws IOException {
// fd is null if constructor threw exception
if (fd != null)
diff --git a/jdk/src/java.base/share/classes/sun/reflect/misc/MethodUtil.java b/jdk/src/java.base/share/classes/sun/reflect/misc/MethodUtil.java
index d3d34da4967..8cb5ca08fcb 100644
--- a/jdk/src/java.base/share/classes/sun/reflect/misc/MethodUtil.java
+++ b/jdk/src/java.base/share/classes/sun/reflect/misc/MethodUtil.java
@@ -25,7 +25,6 @@
package sun.reflect.misc;
-import java.lang.reflect.Module;
import java.io.EOFException;
import java.security.AllPermission;
import java.security.AccessController;
diff --git a/jdk/src/java.base/share/classes/sun/security/provider/KeyProtector.java b/jdk/src/java.base/share/classes/sun/security/provider/KeyProtector.java
index ef7a1f43ffb..bffa1f5b283 100644
--- a/jdk/src/java.base/share/classes/sun/security/provider/KeyProtector.java
+++ b/jdk/src/java.base/share/classes/sun/security/provider/KeyProtector.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1997, 2006, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2017, 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
@@ -147,6 +147,7 @@ final class KeyProtector {
* Ensures that the password bytes of this key protector are
* set to zero when there are no more references to it.
*/
+ @SuppressWarnings("deprecation")
protected void finalize() {
if (passwdBytes != null) {
Arrays.fill(passwdBytes, (byte)0x00);
diff --git a/jdk/src/java.base/share/classes/sun/security/ssl/BaseSSLSocketImpl.java b/jdk/src/java.base/share/classes/sun/security/ssl/BaseSSLSocketImpl.java
index a09932d94e5..51560f5872d 100644
--- a/jdk/src/java.base/share/classes/sun/security/ssl/BaseSSLSocketImpl.java
+++ b/jdk/src/java.base/share/classes/sun/security/ssl/BaseSSLSocketImpl.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2002, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2002, 2017, 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
@@ -265,6 +265,7 @@ abstract class BaseSSLSocketImpl extends SSLSocket {
* the penalty of prematurly killing SSL sessions.
*/
@Override
+ @SuppressWarnings("deprecation")
protected final void finalize() throws Throwable {
try {
close();
diff --git a/jdk/src/java.base/share/classes/sun/security/ssl/SunJSSE.java b/jdk/src/java.base/share/classes/sun/security/ssl/SunJSSE.java
index 3ef37b798a1..0bb89fbc3ca 100644
--- a/jdk/src/java.base/share/classes/sun/security/ssl/SunJSSE.java
+++ b/jdk/src/java.base/share/classes/sun/security/ssl/SunJSSE.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1999, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2017, 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
@@ -247,6 +247,7 @@ public abstract class SunJSSE extends java.security.Provider {
}
@Override
+ @SuppressWarnings("deprecation")
protected final void finalize() throws Throwable {
// empty
super.finalize();
diff --git a/jdk/src/java.base/share/classes/sun/security/tools/keytool/Main.java b/jdk/src/java.base/share/classes/sun/security/tools/keytool/Main.java
index 53ea9706207..6208565c74b 100644
--- a/jdk/src/java.base/share/classes/sun/security/tools/keytool/Main.java
+++ b/jdk/src/java.base/share/classes/sun/security/tools/keytool/Main.java
@@ -485,7 +485,9 @@ public final class Main {
if (c != null) {
command = c;
- } else if (collator.compare(flags, "-help") == 0) {
+ } else if (collator.compare(flags, "-help") == 0 ||
+ collator.compare(flags, "-h") == 0 ||
+ collator.compare(flags, "-?") == 0) {
help = true;
} else if (collator.compare(flags, "-conf") == 0) {
i++;
diff --git a/jdk/src/java.base/share/native/libjava/Module.c b/jdk/src/java.base/share/native/libjava/Module.c
index 083671da206..f396b8dfc49 100644
--- a/jdk/src/java.base/share/native/libjava/Module.c
+++ b/jdk/src/java.base/share/native/libjava/Module.c
@@ -29,12 +29,12 @@
#include "jni_util.h"
#include "jvm.h"
-#include "java_lang_reflect_Module.h"
+#include "java_lang_Module.h"
/*
* Gets the UTF-8 chars for the string and translates '.' to '/'. Does no
* further validation, assumption being that both calling code in
- * java.lang.reflect.Module and VM will do deeper validation.
+ * java.lang.Module and VM will do deeper validation.
*/
static char*
GetInternalPackageName(JNIEnv *env, jstring pkg, char* buf, jsize buf_size)
@@ -68,7 +68,7 @@ GetInternalPackageName(JNIEnv *env, jstring pkg, char* buf, jsize buf_size)
}
JNIEXPORT void JNICALL
-Java_java_lang_reflect_Module_defineModule0(JNIEnv *env, jclass cls, jobject module,
+Java_java_lang_Module_defineModule0(JNIEnv *env, jclass cls, jobject module,
jboolean is_open, jstring version,
jstring location, jobjectArray packages)
{
@@ -109,14 +109,14 @@ Java_java_lang_reflect_Module_defineModule0(JNIEnv *env, jclass cls, jobject mod
}
JNIEXPORT void JNICALL
-Java_java_lang_reflect_Module_addReads0(JNIEnv *env, jclass cls, jobject from, jobject to)
+Java_java_lang_Module_addReads0(JNIEnv *env, jclass cls, jobject from, jobject to)
{
JVM_AddReadsModule(env, from, to);
}
JNIEXPORT void JNICALL
-Java_java_lang_reflect_Module_addExports0(JNIEnv *env, jclass cls, jobject from,
- jstring pkg, jobject to)
+Java_java_lang_Module_addExports0(JNIEnv *env, jclass cls, jobject from,
+ jstring pkg, jobject to)
{
char buf[128];
char* pkg_name;
@@ -136,8 +136,8 @@ Java_java_lang_reflect_Module_addExports0(JNIEnv *env, jclass cls, jobject from,
}
JNIEXPORT void JNICALL
-Java_java_lang_reflect_Module_addExportsToAll0(JNIEnv *env, jclass cls, jobject from,
- jstring pkg)
+Java_java_lang_Module_addExportsToAll0(JNIEnv *env, jclass cls, jobject from,
+ jstring pkg)
{
char buf[128];
char* pkg_name;
@@ -157,8 +157,8 @@ Java_java_lang_reflect_Module_addExportsToAll0(JNIEnv *env, jclass cls, jobject
}
JNIEXPORT void JNICALL
-Java_java_lang_reflect_Module_addExportsToAllUnnamed0(JNIEnv *env, jclass cls,
- jobject from, jstring pkg)
+Java_java_lang_Module_addExportsToAllUnnamed0(JNIEnv *env, jclass cls,
+ jobject from, jstring pkg)
{
char buf[128];
char* pkg_name;
@@ -178,7 +178,7 @@ Java_java_lang_reflect_Module_addExportsToAllUnnamed0(JNIEnv *env, jclass cls,
}
JNIEXPORT void JNICALL
-Java_java_lang_reflect_Module_addPackage0(JNIEnv *env, jclass cls, jobject m, jstring pkg)
+Java_java_lang_Module_addPackage0(JNIEnv *env, jclass cls, jobject m, jstring pkg)
{
char buf[128];
char* pkg_name;
diff --git a/jdk/src/java.desktop/macosx/classes/apple/laf/JRSUIControl.java b/jdk/src/java.desktop/macosx/classes/apple/laf/JRSUIControl.java
index 115002b5825..e3579449b75 100644
--- a/jdk/src/java.desktop/macosx/classes/apple/laf/JRSUIControl.java
+++ b/jdk/src/java.desktop/macosx/classes/apple/laf/JRSUIControl.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 2017, 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
@@ -114,6 +114,7 @@ public final class JRSUIControl {
changes.putAll(other.changes);
}
+ @SuppressWarnings("deprecation")
protected synchronized void finalize() throws Throwable {
if (cfDictionaryPtr == 0) return;
disposeCFDictionary(cfDictionaryPtr);
diff --git a/jdk/src/java.desktop/macosx/classes/sun/awt/CGraphicsEnvironment.java b/jdk/src/java.desktop/macosx/classes/sun/awt/CGraphicsEnvironment.java
index f0db13f9567..ce5ed8b141e 100644
--- a/jdk/src/java.desktop/macosx/classes/sun/awt/CGraphicsEnvironment.java
+++ b/jdk/src/java.desktop/macosx/classes/sun/awt/CGraphicsEnvironment.java
@@ -124,6 +124,7 @@ public final class CGraphicsEnvironment extends SunGraphicsEnvironment {
}
@Override
+ @SuppressWarnings("deprecation")
protected void finalize() throws Throwable {
try {
super.finalize();
diff --git a/jdk/src/java.desktop/macosx/classes/sun/font/CFont.java b/jdk/src/java.desktop/macosx/classes/sun/font/CFont.java
index c8c3f5b1fae..15abdda711d 100644
--- a/jdk/src/java.desktop/macosx/classes/sun/font/CFont.java
+++ b/jdk/src/java.desktop/macosx/classes/sun/font/CFont.java
@@ -250,6 +250,7 @@ public final class CFont extends PhysicalFont implements FontSubstitution {
return compFont;
}
+ @SuppressWarnings("deprecation")
protected synchronized void finalize() {
if (nativeFontPtr != 0) {
disposeNativeFont(nativeFontPtr);
diff --git a/jdk/src/java.desktop/macosx/classes/sun/font/CStrike.java b/jdk/src/java.desktop/macosx/classes/sun/font/CStrike.java
index ed3838886c9..7eba9678020 100644
--- a/jdk/src/java.desktop/macosx/classes/sun/font/CStrike.java
+++ b/jdk/src/java.desktop/macosx/classes/sun/font/CStrike.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 2017, 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
@@ -127,6 +127,7 @@ public final class CStrike extends PhysicalStrike {
return nativeStrikePtr;
}
+ @SuppressWarnings("deprecation")
protected synchronized void finalize() throws Throwable {
if (nativeStrikePtr != 0) {
disposeNativeStrikePtr(nativeStrikePtr);
diff --git a/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CFRetainedResource.java b/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CFRetainedResource.java
index f69ad201ef8..e53f23a304b 100644
--- a/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CFRetainedResource.java
+++ b/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CFRetainedResource.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 2017, 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
@@ -135,6 +135,7 @@ public class CFRetainedResource {
}
@Override
+ @SuppressWarnings("deprecation")
protected final void finalize() throws Throwable {
dispose();
}
diff --git a/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CPrinterJob.java b/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CPrinterJob.java
index 2d54d62b799..e54e1532666 100644
--- a/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CPrinterJob.java
+++ b/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CPrinterJob.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2011, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 2017, 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
@@ -556,6 +556,7 @@ public final class CPrinterJob extends RasterPrinterJob {
// The following methods are CPrinterJob specific.
@Override
+ @SuppressWarnings("deprecation")
protected void finalize() {
synchronized (fNSPrintInfoLock) {
if (fNSPrintInfo != -1) {
diff --git a/jdk/src/java.desktop/share/classes/com/sun/imageio/plugins/common/SubImageInputStream.java b/jdk/src/java.desktop/share/classes/com/sun/imageio/plugins/common/SubImageInputStream.java
index cdcb68dd90d..8ddffc522f1 100644
--- a/jdk/src/java.desktop/share/classes/com/sun/imageio/plugins/common/SubImageInputStream.java
+++ b/jdk/src/java.desktop/share/classes/com/sun/imageio/plugins/common/SubImageInputStream.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2000, 2005, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 2017, 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
@@ -72,6 +72,7 @@ public final class SubImageInputStream extends ImageInputStreamImpl {
streamPos = pos;
}
+ @SuppressWarnings("deprecation")
protected void finalize() throws Throwable {
// Empty finalizer (for improved performance; no need to call
// super.finalize() in this case)
diff --git a/jdk/src/java.desktop/share/classes/com/sun/imageio/plugins/png/PNGImageWriter.java b/jdk/src/java.desktop/share/classes/com/sun/imageio/plugins/png/PNGImageWriter.java
index f1660f8a159..3fbc55c82b9 100644
--- a/jdk/src/java.desktop/share/classes/com/sun/imageio/plugins/png/PNGImageWriter.java
+++ b/jdk/src/java.desktop/share/classes/com/sun/imageio/plugins/png/PNGImageWriter.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 2017, 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
@@ -143,6 +143,7 @@ final class ChunkStream extends ImageOutputStreamImpl {
}
@Override
+ @SuppressWarnings("deprecation")
protected void finalize() throws Throwable {
// Empty finalizer (for improved performance; no need to call
// super.finalize() in this case)
@@ -279,6 +280,7 @@ final class IDATOutputStream extends ImageOutputStreamImpl {
}
@Override
+ @SuppressWarnings("deprecation")
protected void finalize() throws Throwable {
// Empty finalizer (for improved performance; no need to call
// super.finalize() in this case)
diff --git a/jdk/src/java.desktop/share/classes/com/sun/imageio/plugins/tiff/TIFFBaseJPEGCompressor.java b/jdk/src/java.desktop/share/classes/com/sun/imageio/plugins/tiff/TIFFBaseJPEGCompressor.java
index 46185618913..2adc479411c 100644
--- a/jdk/src/java.desktop/share/classes/com/sun/imageio/plugins/tiff/TIFFBaseJPEGCompressor.java
+++ b/jdk/src/java.desktop/share/classes/com/sun/imageio/plugins/tiff/TIFFBaseJPEGCompressor.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2005, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2017, 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
@@ -435,6 +435,7 @@ public abstract class TIFFBaseJPEGCompressor extends TIFFCompressor {
return compDataLength;
}
+ @SuppressWarnings("deprecation")
protected void finalize() throws Throwable {
super.finalize();
if(JPEGWriter != null) {
diff --git a/jdk/src/java.desktop/share/classes/com/sun/imageio/plugins/tiff/TIFFJPEGDecompressor.java b/jdk/src/java.desktop/share/classes/com/sun/imageio/plugins/tiff/TIFFJPEGDecompressor.java
index 966ca9575d9..384687f8344 100644
--- a/jdk/src/java.desktop/share/classes/com/sun/imageio/plugins/tiff/TIFFJPEGDecompressor.java
+++ b/jdk/src/java.desktop/share/classes/com/sun/imageio/plugins/tiff/TIFFJPEGDecompressor.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2005, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2017, 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
@@ -139,6 +139,7 @@ public class TIFFJPEGDecompressor extends TIFFDecompressor {
JPEGReader.read(0, JPEGParam);
}
+ @SuppressWarnings("deprecation")
protected void finalize() throws Throwable {
super.finalize();
JPEGReader.dispose();
diff --git a/jdk/src/java.desktop/share/classes/com/sun/imageio/plugins/tiff/TIFFOldJPEGDecompressor.java b/jdk/src/java.desktop/share/classes/com/sun/imageio/plugins/tiff/TIFFOldJPEGDecompressor.java
index 2837754ddb2..67dd60f8a79 100644
--- a/jdk/src/java.desktop/share/classes/com/sun/imageio/plugins/tiff/TIFFOldJPEGDecompressor.java
+++ b/jdk/src/java.desktop/share/classes/com/sun/imageio/plugins/tiff/TIFFOldJPEGDecompressor.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2005, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2017, 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
@@ -610,6 +610,7 @@ public class TIFFOldJPEGDecompressor extends TIFFJPEGDecompressor {
JPEGReader.read(0, JPEGParam);
}
+ @SuppressWarnings("deprecation")
protected void finalize() throws Throwable {
super.finalize();
JPEGReader.dispose();
diff --git a/jdk/src/java.desktop/share/classes/com/sun/imageio/stream/StreamFinalizer.java b/jdk/src/java.desktop/share/classes/com/sun/imageio/stream/StreamFinalizer.java
index 36954988f1b..be1e659ee6e 100644
--- a/jdk/src/java.desktop/share/classes/com/sun/imageio/stream/StreamFinalizer.java
+++ b/jdk/src/java.desktop/share/classes/com/sun/imageio/stream/StreamFinalizer.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2005, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2017, 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
@@ -60,6 +60,7 @@ public class StreamFinalizer {
this.stream = stream;
}
+ @SuppressWarnings("deprecation")
protected void finalize() throws Throwable {
try {
stream.close();
diff --git a/jdk/src/java.desktop/share/classes/com/sun/media/sound/AbstractMidiDevice.java b/jdk/src/java.desktop/share/classes/com/sun/media/sound/AbstractMidiDevice.java
index 672b76f926b..bea9f5daf24 100644
--- a/jdk/src/java.desktop/share/classes/com/sun/media/sound/AbstractMidiDevice.java
+++ b/jdk/src/java.desktop/share/classes/com/sun/media/sound/AbstractMidiDevice.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1999, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2017, 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
@@ -444,6 +444,7 @@ abstract class AbstractMidiDevice implements MidiDevice, ReferenceCountingDevice
* close this device if discarded by the garbage collector.
*/
@Override
+ @SuppressWarnings("deprecation")
protected final void finalize() {
close();
}
diff --git a/jdk/src/java.desktop/share/classes/java/awt/Graphics.java b/jdk/src/java.desktop/share/classes/java/awt/Graphics.java
index 932a89d5ade..317a93fad22 100644
--- a/jdk/src/java.desktop/share/classes/java/awt/Graphics.java
+++ b/jdk/src/java.desktop/share/classes/java/awt/Graphics.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1995, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1995, 2017, 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
@@ -1159,8 +1159,18 @@ public abstract class Graphics {
/**
* Disposes of this graphics context once it is no longer referenced.
+ *
+ * @deprecated The {@code finalize} method has been deprecated.
+ * Subclasses that override {@code finalize} in order to perform cleanup
+ * should be modified to use alternative cleanup mechanisms and
+ * to remove the overriding {@code finalize} method.
+ * When overriding the {@code finalize} method, its implementation must explicitly
+ * ensure that {@code super.finalize()} is invoked as described in {@link Object#finalize}.
+ * See the specification for {@link Object#finalize()} for further
+ * information about migration options.
* @see #dispose
*/
+ @Deprecated(since="9")
public void finalize() {
dispose();
}
diff --git a/jdk/src/java.desktop/share/classes/java/awt/PrintJob.java b/jdk/src/java.desktop/share/classes/java/awt/PrintJob.java
index fcc6afebf2a..9012608584f 100644
--- a/jdk/src/java.desktop/share/classes/java/awt/PrintJob.java
+++ b/jdk/src/java.desktop/share/classes/java/awt/PrintJob.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1996, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1996, 2017, 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
@@ -79,8 +79,18 @@ public abstract class PrintJob {
/**
* Ends this print job once it is no longer referenced.
+ *
+ * @deprecated The {@code finalize} method has been deprecated.
+ * Subclasses that override {@code finalize} in order to perform cleanup
+ * should be modified to use alternative cleanup mechanisms and
+ * to remove the overriding {@code finalize} method.
+ * When overriding the {@code finalize} method, its implementation must explicitly
+ * ensure that {@code super.finalize()} is invoked as described in {@link Object#finalize}.
+ * See the specification for {@link Object#finalize()} for further
+ * information about migration options.
* @see #end
*/
+ @Deprecated(since="9")
public void finalize() {
end();
}
diff --git a/jdk/src/java.desktop/share/classes/java/awt/color/ICC_Profile.java b/jdk/src/java.desktop/share/classes/java/awt/color/ICC_Profile.java
index 3adc80fa59f..625664f41d0 100644
--- a/jdk/src/java.desktop/share/classes/java/awt/color/ICC_Profile.java
+++ b/jdk/src/java.desktop/share/classes/java/awt/color/ICC_Profile.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2017, 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
@@ -751,7 +751,17 @@ public class ICC_Profile implements Serializable {
/**
* Frees the resources associated with an ICC_Profile object.
+ *
+ * @deprecated The {@code finalize} method has been deprecated.
+ * Subclasses that override {@code finalize} in order to perform cleanup
+ * should be modified to use alternative cleanup mechanisms and
+ * to remove the overriding {@code finalize} method.
+ * When overriding the {@code finalize} method, its implementation must explicitly
+ * ensure that {@code super.finalize()} is invoked as described in {@link Object#finalize}.
+ * See the specification for {@link Object#finalize()} for further
+ * information about migration options.
*/
+ @Deprecated(since="9")
protected void finalize () {
if (cmmProfile != null) {
CMSManager.getModule().freeProfile(cmmProfile);
diff --git a/jdk/src/java.desktop/share/classes/java/awt/image/ColorModel.java b/jdk/src/java.desktop/share/classes/java/awt/image/ColorModel.java
index 07e823ce6aa..2be7f7e844f 100644
--- a/jdk/src/java.desktop/share/classes/java/awt/image/ColorModel.java
+++ b/jdk/src/java.desktop/share/classes/java/awt/image/ColorModel.java
@@ -1620,7 +1620,17 @@ public abstract class ColorModel implements Transparency{
* Disposes of system resources associated with this
* {@code ColorModel} once this {@code ColorModel} is no
* longer referenced.
+ *
+ * @deprecated The {@code finalize} method has been deprecated.
+ * Subclasses that override {@code finalize} in order to perform cleanup
+ * should be modified to use alternative cleanup mechanisms and
+ * to remove the overriding {@code finalize} method.
+ * When overriding the {@code finalize} method, its implementation must explicitly
+ * ensure that {@code super.finalize()} is invoked as described in {@link Object#finalize}.
+ * See the specification for {@link Object#finalize()} for further
+ * information about migration options.
*/
+ @Deprecated(since="9")
public void finalize() {
}
@@ -1952,4 +1962,4 @@ public abstract class ColorModel implements Transparency{
return lg16Toog16LUT;
}
-}
\ No newline at end of file
+}
diff --git a/jdk/src/java.desktop/share/classes/java/awt/image/IndexColorModel.java b/jdk/src/java.desktop/share/classes/java/awt/image/IndexColorModel.java
index 3a172c142e2..81aab994178 100644
--- a/jdk/src/java.desktop/share/classes/java/awt/image/IndexColorModel.java
+++ b/jdk/src/java.desktop/share/classes/java/awt/image/IndexColorModel.java
@@ -1514,7 +1514,17 @@ public class IndexColorModel extends ColorModel {
* Disposes of system resources associated with this
* {@code ColorModel} once this {@code ColorModel} is no
* longer referenced.
+ *
+ * @deprecated The {@code finalize} method has been deprecated.
+ * Subclasses that override {@code finalize} in order to perform cleanup
+ * should be modified to use alternative cleanup mechanisms and
+ * to remove the overriding {@code finalize} method.
+ * When overriding the {@code finalize} method, its implementation must explicitly
+ * ensure that {@code super.finalize()} is invoked as described in {@link Object#finalize}.
+ * See the specification for {@link Object#finalize()} for further
+ * information about migration options.
*/
+ @Deprecated(since="9")
public void finalize() {
}
@@ -1630,4 +1640,4 @@ public class IndexColorModel extends ColorModel {
}
return result;
}
-}
\ No newline at end of file
+}
diff --git a/jdk/src/java.desktop/share/classes/javax/imageio/metadata/IIOMetadata.java b/jdk/src/java.desktop/share/classes/javax/imageio/metadata/IIOMetadata.java
index c9ac7374a00..08f31278c28 100644
--- a/jdk/src/java.desktop/share/classes/javax/imageio/metadata/IIOMetadata.java
+++ b/jdk/src/java.desktop/share/classes/javax/imageio/metadata/IIOMetadata.java
@@ -28,7 +28,6 @@ package javax.imageio.metadata;
import org.w3c.dom.Node;
import java.lang.reflect.Method;
-import java.lang.reflect.Module;
import java.security.AccessController;
import java.security.PrivilegedAction;
diff --git a/jdk/src/java.desktop/share/classes/javax/imageio/spi/ImageReaderWriterSpi.java b/jdk/src/java.desktop/share/classes/javax/imageio/spi/ImageReaderWriterSpi.java
index e5961b90e4a..dc2f2322100 100644
--- a/jdk/src/java.desktop/share/classes/javax/imageio/spi/ImageReaderWriterSpi.java
+++ b/jdk/src/java.desktop/share/classes/javax/imageio/spi/ImageReaderWriterSpi.java
@@ -28,7 +28,6 @@ package javax.imageio.spi;
import java.io.IOException;
import java.lang.reflect.Constructor;
import java.lang.reflect.Method;
-import java.lang.reflect.Module;
import java.security.AccessController;
import java.security.PrivilegedAction;
import java.util.Arrays;
diff --git a/jdk/src/java.desktop/share/classes/javax/imageio/spi/ServiceRegistry.java b/jdk/src/java.desktop/share/classes/javax/imageio/spi/ServiceRegistry.java
index 465f155374e..2df6e1ba03b 100644
--- a/jdk/src/java.desktop/share/classes/javax/imageio/spi/ServiceRegistry.java
+++ b/jdk/src/java.desktop/share/classes/javax/imageio/spi/ServiceRegistry.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 2017, 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
@@ -706,7 +706,17 @@ public class ServiceRegistry {
*
* @exception Throwable if an error occurs during superclass
* finalization.
+ *
+ * @deprecated The {@code finalize} method has been deprecated.
+ * Subclasses that override {@code finalize} in order to perform cleanup
+ * should be modified to use alternative cleanup mechanisms and
+ * to remove the overriding {@code finalize} method.
+ * When overriding the {@code finalize} method, its implementation must explicitly
+ * ensure that {@code super.finalize()} is invoked as described in {@link Object#finalize}.
+ * See the specification for {@link Object#finalize()} for further
+ * information about migration options.
*/
+ @Deprecated(since="9")
public void finalize() throws Throwable {
deregisterAll();
super.finalize();
@@ -846,6 +856,7 @@ class SubRegistry {
poset.clear();
}
+ @SuppressWarnings("deprecation")
public synchronized void finalize() {
clear();
}
diff --git a/jdk/src/java.desktop/share/classes/javax/imageio/stream/FileCacheImageInputStream.java b/jdk/src/java.desktop/share/classes/javax/imageio/stream/FileCacheImageInputStream.java
index f354f7a113a..e5974900161 100644
--- a/jdk/src/java.desktop/share/classes/javax/imageio/stream/FileCacheImageInputStream.java
+++ b/jdk/src/java.desktop/share/classes/javax/imageio/stream/FileCacheImageInputStream.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 2017, 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
@@ -260,7 +260,17 @@ public class FileCacheImageInputStream extends ImageInputStreamImpl {
/**
* {@inheritDoc}
+ *
+ * @deprecated The {@code finalize} method has been deprecated.
+ * Subclasses that override {@code finalize} in order to perform cleanup
+ * should be modified to use alternative cleanup mechanisms and
+ * to remove the overriding {@code finalize} method.
+ * When overriding the {@code finalize} method, its implementation must explicitly
+ * ensure that {@code super.finalize()} is invoked as described in {@link Object#finalize}.
+ * See the specification for {@link Object#finalize()} for further
+ * information about migration options.
*/
+ @Deprecated(since="9")
protected void finalize() throws Throwable {
// Empty finalizer: for performance reasons we instead use the
// Disposer mechanism for ensuring that the underlying
diff --git a/jdk/src/java.desktop/share/classes/javax/imageio/stream/FileImageInputStream.java b/jdk/src/java.desktop/share/classes/javax/imageio/stream/FileImageInputStream.java
index b7129085317..7ecc28767a0 100644
--- a/jdk/src/java.desktop/share/classes/javax/imageio/stream/FileImageInputStream.java
+++ b/jdk/src/java.desktop/share/classes/javax/imageio/stream/FileImageInputStream.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2000, 2007, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 2017, 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
@@ -155,7 +155,17 @@ public class FileImageInputStream extends ImageInputStreamImpl {
/**
* {@inheritDoc}
+ *
+ * @deprecated The {@code finalize} method has been deprecated.
+ * Subclasses that override {@code finalize} in order to perform cleanup
+ * should be modified to use alternative cleanup mechanisms and
+ * to remove the overriding {@code finalize} method.
+ * When overriding the {@code finalize} method, its implementation must explicitly
+ * ensure that {@code super.finalize()} is invoked as described in {@link Object#finalize}.
+ * See the specification for {@link Object#finalize()} for further
+ * information about migration options.
*/
+ @Deprecated(since="9")
protected void finalize() throws Throwable {
// Empty finalizer: for performance reasons we instead use the
// Disposer mechanism for ensuring that the underlying
diff --git a/jdk/src/java.desktop/share/classes/javax/imageio/stream/FileImageOutputStream.java b/jdk/src/java.desktop/share/classes/javax/imageio/stream/FileImageOutputStream.java
index c76d09f4b71..e75c40396d8 100644
--- a/jdk/src/java.desktop/share/classes/javax/imageio/stream/FileImageOutputStream.java
+++ b/jdk/src/java.desktop/share/classes/javax/imageio/stream/FileImageOutputStream.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2000, 2007, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 2017, 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
@@ -163,7 +163,17 @@ public class FileImageOutputStream extends ImageOutputStreamImpl {
/**
* {@inheritDoc}
+ *
+ * @deprecated The {@code finalize} method has been deprecated.
+ * Subclasses that override {@code finalize} in order to perform cleanup
+ * should be modified to use alternative cleanup mechanisms and
+ * to remove the overriding {@code finalize} method.
+ * When overriding the {@code finalize} method, its implementation must explicitly
+ * ensure that {@code super.finalize()} is invoked as described in {@link Object#finalize}.
+ * See the specification for {@link Object#finalize()} for further
+ * information about migration options.
*/
+ @Deprecated(since="9")
protected void finalize() throws Throwable {
// Empty finalizer: for performance reasons we instead use the
// Disposer mechanism for ensuring that the underlying
diff --git a/jdk/src/java.desktop/share/classes/javax/imageio/stream/ImageInputStreamImpl.java b/jdk/src/java.desktop/share/classes/javax/imageio/stream/ImageInputStreamImpl.java
index 3d17e278e99..c7cdc47cdaf 100644
--- a/jdk/src/java.desktop/share/classes/javax/imageio/stream/ImageInputStreamImpl.java
+++ b/jdk/src/java.desktop/share/classes/javax/imageio/stream/ImageInputStreamImpl.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 2017, 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
@@ -867,7 +867,17 @@ public abstract class ImageInputStreamImpl implements ImageInputStream {
*
* @exception Throwable if an error occurs during superclass
* finalization.
+ *
+ * @deprecated The {@code finalize} method has been deprecated.
+ * Subclasses that override {@code finalize} in order to perform cleanup
+ * should be modified to use alternative cleanup mechanisms and
+ * to remove the overriding {@code finalize} method.
+ * When overriding the {@code finalize} method, its implementation must explicitly
+ * ensure that {@code super.finalize()} is invoked as described in {@link Object#finalize}.
+ * See the specification for {@link Object#finalize()} for further
+ * information about migration options.
*/
+ @Deprecated(since="9")
protected void finalize() throws Throwable {
if (!isClosed) {
try {
diff --git a/jdk/src/java.desktop/share/classes/javax/imageio/stream/MemoryCacheImageInputStream.java b/jdk/src/java.desktop/share/classes/javax/imageio/stream/MemoryCacheImageInputStream.java
index 87774c1d94f..4fcb0f40b81 100644
--- a/jdk/src/java.desktop/share/classes/javax/imageio/stream/MemoryCacheImageInputStream.java
+++ b/jdk/src/java.desktop/share/classes/javax/imageio/stream/MemoryCacheImageInputStream.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2000, 2007, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 2017, 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
@@ -178,7 +178,17 @@ public class MemoryCacheImageInputStream extends ImageInputStreamImpl {
/**
* {@inheritDoc}
+ *
+ * @deprecated The {@code finalize} method has been deprecated.
+ * Subclasses that override {@code finalize} in order to perform cleanup
+ * should be modified to use alternative cleanup mechanisms and
+ * to remove the overriding {@code finalize} method.
+ * When overriding the {@code finalize} method, its implementation must explicitly
+ * ensure that {@code super.finalize()} is invoked as described in {@link Object#finalize}.
+ * See the specification for {@link Object#finalize()} for further
+ * information about migration options.
*/
+ @Deprecated(since="9")
protected void finalize() throws Throwable {
// Empty finalizer: for performance reasons we instead use the
// Disposer mechanism for ensuring that the underlying
diff --git a/jdk/src/java.desktop/share/classes/javax/swing/text/PlainView.java b/jdk/src/java.desktop/share/classes/javax/swing/text/PlainView.java
index 4430b4e1c89..d3a0a35b932 100644
--- a/jdk/src/java.desktop/share/classes/javax/swing/text/PlainView.java
+++ b/jdk/src/java.desktop/share/classes/javax/swing/text/PlainView.java
@@ -31,7 +31,6 @@ import java.security.AccessController;
import java.security.PrivilegedAction;
import java.util.Objects;
import javax.swing.event.*;
-import java.lang.reflect.Module;
import java.lang.ref.SoftReference;
import java.util.HashMap;
diff --git a/jdk/src/java.desktop/share/classes/javax/swing/text/StringContent.java b/jdk/src/java.desktop/share/classes/javax/swing/text/StringContent.java
index d6b897fd93f..4f26f54d8b8 100644
--- a/jdk/src/java.desktop/share/classes/javax/swing/text/StringContent.java
+++ b/jdk/src/java.desktop/share/classes/javax/swing/text/StringContent.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2017, 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
@@ -351,6 +351,7 @@ public final class StringContent implements AbstractDocument.Content, Serializab
return rec.offset;
}
+ @SuppressWarnings("deprecation")
protected void finalize() throws Throwable {
// schedule the record to be removed later
// on another thread.
diff --git a/jdk/src/java.desktop/share/classes/sun/awt/image/BufImgSurfaceData.java b/jdk/src/java.desktop/share/classes/sun/awt/image/BufImgSurfaceData.java
index 8d37a2d6a1d..ac42b424152 100644
--- a/jdk/src/java.desktop/share/classes/sun/awt/image/BufImgSurfaceData.java
+++ b/jdk/src/java.desktop/share/classes/sun/awt/image/BufImgSurfaceData.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2017, 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
@@ -472,6 +472,7 @@ public class BufImgSurfaceData extends SurfaceData {
this.pData = pData;
}
+ @SuppressWarnings("deprecation")
public void finalize() {
if (pData != 0L) {
BufImgSurfaceData.freeNativeICMData(pData);
diff --git a/jdk/src/java.desktop/share/classes/sun/java2d/SunGraphics2D.java b/jdk/src/java.desktop/share/classes/sun/java2d/SunGraphics2D.java
index 4c0abc9eec8..d2ae86ef3b4 100644
--- a/jdk/src/java.desktop/share/classes/sun/java2d/SunGraphics2D.java
+++ b/jdk/src/java.desktop/share/classes/sun/java2d/SunGraphics2D.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1996, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1996, 2017, 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
@@ -3633,6 +3633,7 @@ public final class SunGraphics2D
* enough to know that if our override is empty then it should not
* mark us as finalizeable.
*/
+ @SuppressWarnings("deprecation")
public void finalize() {
// DO NOT REMOVE THIS METHOD
}
diff --git a/jdk/src/java.desktop/share/classes/sun/java2d/pipe/RegionClipSpanIterator.java b/jdk/src/java.desktop/share/classes/sun/java2d/pipe/RegionClipSpanIterator.java
index 69bba24c2a6..cf8193f0c42 100644
--- a/jdk/src/java.desktop/share/classes/sun/java2d/pipe/RegionClipSpanIterator.java
+++ b/jdk/src/java.desktop/share/classes/sun/java2d/pipe/RegionClipSpanIterator.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1999, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2017, 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
@@ -383,6 +383,7 @@ public class RegionClipSpanIterator implements SpanIterator {
*/
//public native void dispose();
+ @SuppressWarnings("deprecation")
protected void finalize() {
//dispose();
}
diff --git a/jdk/src/java.desktop/share/classes/sun/print/PeekGraphics.java b/jdk/src/java.desktop/share/classes/sun/print/PeekGraphics.java
index b76321d84a3..c273ca1d071 100644
--- a/jdk/src/java.desktop/share/classes/sun/print/PeekGraphics.java
+++ b/jdk/src/java.desktop/share/classes/sun/print/PeekGraphics.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1998, 2006, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1998, 2017, 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
@@ -1336,6 +1336,7 @@ public class PeekGraphics extends Graphics2D
/**
* Empty finalizer as no clean up needed here.
*/
+ @SuppressWarnings("deprecation")
public void finalize() {
}
diff --git a/jdk/src/java.desktop/share/classes/sun/print/PrintJob2D.java b/jdk/src/java.desktop/share/classes/sun/print/PrintJob2D.java
index b62c4eb1298..9d9b2009af3 100644
--- a/jdk/src/java.desktop/share/classes/sun/print/PrintJob2D.java
+++ b/jdk/src/java.desktop/share/classes/sun/print/PrintJob2D.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 2017, 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
@@ -942,6 +942,7 @@ public class PrintJob2D extends PrintJob implements Printable, Runnable {
* Ends this print job once it is no longer referenced.
* @see #end
*/
+ @SuppressWarnings("deprecation")
public void finalize() {
end();
}
diff --git a/jdk/src/java.desktop/share/classes/sun/print/ProxyGraphics.java b/jdk/src/java.desktop/share/classes/sun/print/ProxyGraphics.java
index eefb49ee75a..5d50ab8ba9d 100644
--- a/jdk/src/java.desktop/share/classes/sun/print/ProxyGraphics.java
+++ b/jdk/src/java.desktop/share/classes/sun/print/ProxyGraphics.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2000, 2007, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 2017, 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
@@ -1099,6 +1099,7 @@ public class ProxyGraphics extends Graphics {
/**
* Empty finalizer as no clean up needed here.
*/
+ @SuppressWarnings("deprecation")
public void finalize() {
}
diff --git a/jdk/src/java.desktop/share/classes/sun/print/ProxyGraphics2D.java b/jdk/src/java.desktop/share/classes/sun/print/ProxyGraphics2D.java
index 6ded8e98eab..2fc626721e2 100644
--- a/jdk/src/java.desktop/share/classes/sun/print/ProxyGraphics2D.java
+++ b/jdk/src/java.desktop/share/classes/sun/print/ProxyGraphics2D.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1998, 2006, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1998, 2017, 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
@@ -1264,6 +1264,7 @@ public class ProxyGraphics2D extends Graphics2D implements PrinterGraphics {
/**
* Empty finalizer as no clean up needed here.
*/
+ @SuppressWarnings("deprecation")
public void finalize() {
}
diff --git a/jdk/src/java.desktop/share/legal/jpeg.md b/jdk/src/java.desktop/share/legal/jpeg.md
index 91f27bd838a..da64b2f7683 100644
--- a/jdk/src/java.desktop/share/legal/jpeg.md
+++ b/jdk/src/java.desktop/share/legal/jpeg.md
@@ -1,4 +1,4 @@
-## JPEG release 6b
+## Independent JPEG Group: JPEG release 6b
### JPEG License
diff --git a/jdk/src/java.desktop/unix/classes/sun/awt/X11InputMethod.java b/jdk/src/java.desktop/unix/classes/sun/awt/X11InputMethod.java
index 0ac2a16243a..2e570129f84 100644
--- a/jdk/src/java.desktop/unix/classes/sun/awt/X11InputMethod.java
+++ b/jdk/src/java.desktop/unix/classes/sun/awt/X11InputMethod.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2017, 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
@@ -181,6 +181,7 @@ public abstract class X11InputMethod extends InputMethodAdapter {
}
}
+ @SuppressWarnings("deprecation")
protected void finalize() throws Throwable {
dispose();
super.finalize();
diff --git a/jdk/src/java.desktop/windows/classes/sun/awt/windows/WInputMethod.java b/jdk/src/java.desktop/windows/classes/sun/awt/windows/WInputMethod.java
index 4bd8f7b5e98..1d3a176388c 100644
--- a/jdk/src/java.desktop/windows/classes/sun/awt/windows/WInputMethod.java
+++ b/jdk/src/java.desktop/windows/classes/sun/awt/windows/WInputMethod.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2017, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -132,6 +132,7 @@ final class WInputMethod extends InputMethodAdapter
}
@Override
+ @SuppressWarnings("deprecation")
protected void finalize() throws Throwable
{
// Release the resources used by the native input context.
diff --git a/jdk/src/java.instrument/share/classes/java/lang/instrument/ClassFileTransformer.java b/jdk/src/java.instrument/share/classes/java/lang/instrument/ClassFileTransformer.java
index e0e0309468e..896f30904de 100644
--- a/jdk/src/java.instrument/share/classes/java/lang/instrument/ClassFileTransformer.java
+++ b/jdk/src/java.instrument/share/classes/java/lang/instrument/ClassFileTransformer.java
@@ -25,7 +25,6 @@
package java.lang.instrument;
-import java.lang.reflect.Module;
import java.security.AccessController;
import java.security.PrivilegedAction;
import java.security.ProtectionDomain;
diff --git a/jdk/src/java.instrument/share/classes/java/lang/instrument/Instrumentation.java b/jdk/src/java.instrument/share/classes/java/lang/instrument/Instrumentation.java
index bc4170d3af2..65d1569d0a0 100644
--- a/jdk/src/java.instrument/share/classes/java/lang/instrument/Instrumentation.java
+++ b/jdk/src/java.instrument/share/classes/java/lang/instrument/Instrumentation.java
@@ -25,7 +25,6 @@
package java.lang.instrument;
-import java.lang.reflect.Module;
import java.security.ProtectionDomain;
import java.util.List;
import java.util.Map;
@@ -346,7 +345,7 @@ public interface Instrumentation {
/**
- * Determines whether a class is modifiable by
+ * Tests whether a class is modifiable by
* {@linkplain #retransformClasses retransformation}
* or {@linkplain #redefineClasses redefinition}.
* If a class is modifiable then this method returns true.
@@ -711,8 +710,11 @@ public interface Instrumentation {
* {@code extraProvides} map contains a service provider type that
* is not a member of the module or an implementation of the service;
* or {@code extraProvides} maps a key to an empty list
+ * @throws UnmodifiableModuleException if the module cannot be modified
* @throws NullPointerException if any of the arguments are {@code null} or
* any of the Sets or Maps contains a {@code null} key or value
+ *
+ * @see #isModifiableModule(Module)
* @since 9
* @spec JPMS
*/
@@ -722,4 +724,19 @@ public interface Instrumentation {
Map> extraOpens,
Set> extraUses,
Map, List>> extraProvides);
+
+ /**
+ * Tests whether a module can be modified with {@link #redefineModule
+ * redefineModule}. If a module is modifiable then this method returns
+ * {@code true}. If a module is not modifiable then this method returns
+ * {@code false}.
+ *
+ * @param module the module to test if it can be modified
+ * @return {@code true} if the module is modifiable, otherwise {@code false}
+ * @throws NullPointerException if the module is {@code null}
+ *
+ * @since 9
+ * @spec JPMS
+ */
+ boolean isModifiableModule(Module module);
}
diff --git a/jdk/src/java.instrument/share/classes/java/lang/instrument/UnmodifiableModuleException.java b/jdk/src/java.instrument/share/classes/java/lang/instrument/UnmodifiableModuleException.java
new file mode 100644
index 00000000000..be037b21cf6
--- /dev/null
+++ b/jdk/src/java.instrument/share/classes/java/lang/instrument/UnmodifiableModuleException.java
@@ -0,0 +1,56 @@
+/*
+ * Copyright (c) 2017, 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 java.lang.instrument;
+
+/**
+ * Thrown to indicate that a module cannot be modified.
+ *
+ * @see Instrumentation#redefineModule
+ * @since 9
+ * @spec JPMS
+ */
+
+public class UnmodifiableModuleException extends RuntimeException {
+ private static final long serialVersionUID = 6912511912351080644L;
+
+ /**
+ * Constructs an {@code UnmodifiableModuleException} with no
+ * detail message.
+ */
+ public UnmodifiableModuleException() {
+ super();
+ }
+
+ /**
+ * Constructs an {@code UnmodifiableModuleException} with the
+ * specified detail message.
+ *
+ * @param msg the detail message.
+ */
+ public UnmodifiableModuleException(String msg) {
+ super(msg);
+ }
+}
diff --git a/jdk/src/java.instrument/share/classes/sun/instrument/InstrumentationImpl.java b/jdk/src/java.instrument/share/classes/sun/instrument/InstrumentationImpl.java
index b2c2a24e50d..f31a007443e 100644
--- a/jdk/src/java.instrument/share/classes/sun/instrument/InstrumentationImpl.java
+++ b/jdk/src/java.instrument/share/classes/sun/instrument/InstrumentationImpl.java
@@ -23,11 +23,10 @@
* questions.
*/
-
package sun.instrument;
+import java.lang.instrument.UnmodifiableModuleException;
import java.lang.reflect.Method;
-import java.lang.reflect.Module;
import java.lang.reflect.AccessibleObject;
import java.lang.instrument.ClassFileTransformer;
import java.lang.instrument.ClassDefinition;
@@ -132,6 +131,13 @@ public class InstrumentationImpl implements Instrumentation {
return isModifiableClass0(mNativeAgent, theClass);
}
+ public boolean isModifiableModule(Module module) {
+ if (module == null) {
+ throw new NullPointerException("'module' is null");
+ }
+ return true;
+ }
+
public boolean
isRetransformClassesSupported() {
// ask lazily since there is some overhead
@@ -243,6 +249,9 @@ public class InstrumentationImpl implements Instrumentation {
if (!module.isNamed())
return;
+ if (!isModifiableModule(module))
+ throw new UnmodifiableModuleException(module.getName());
+
// copy and check reads
extraReads = new HashSet<>(extraReads);
if (extraReads.contains(null))
@@ -312,7 +321,7 @@ public class InstrumentationImpl implements Instrumentation {
return Collections.emptyMap();
Map> result = new HashMap<>();
- Set packages = Set.of(module.getPackages());
+ Set packages = module.getPackages();
for (Map.Entry> e : map.entrySet()) {
String pkg = e.getKey();
if (pkg == null)
diff --git a/jdk/src/java.instrument/share/classes/sun/instrument/TransformerManager.java b/jdk/src/java.instrument/share/classes/sun/instrument/TransformerManager.java
index dcac4b7ad8f..29665440f9f 100644
--- a/jdk/src/java.instrument/share/classes/sun/instrument/TransformerManager.java
+++ b/jdk/src/java.instrument/share/classes/sun/instrument/TransformerManager.java
@@ -25,10 +25,8 @@
package sun.instrument;
-
import java.lang.instrument.Instrumentation;
import java.lang.instrument.ClassFileTransformer;
-import java.lang.reflect.Module;
import java.security.ProtectionDomain;
/*
diff --git a/jdk/src/java.instrument/share/native/libinstrument/JPLISAgent.h b/jdk/src/java.instrument/share/native/libinstrument/JPLISAgent.h
index 008b2fabc6a..08d61636839 100644
--- a/jdk/src/java.instrument/share/native/libinstrument/JPLISAgent.h
+++ b/jdk/src/java.instrument/share/native/libinstrument/JPLISAgent.h
@@ -66,7 +66,7 @@ typedef struct _JPLISEnvironment JPLISEnvironment;
#define JPLIS_INSTRUMENTIMPL_AGENTMAININVOKER_METHODSIGNATURE "(Ljava/lang/String;Ljava/lang/String;)V"
#define JPLIS_INSTRUMENTIMPL_TRANSFORM_METHODNAME "transform"
#define JPLIS_INSTRUMENTIMPL_TRANSFORM_METHODSIGNATURE \
- "(Ljava/lang/reflect/Module;Ljava/lang/ClassLoader;Ljava/lang/String;Ljava/lang/Class;Ljava/security/ProtectionDomain;[BZ)[B"
+ "(Ljava/lang/Module;Ljava/lang/ClassLoader;Ljava/lang/String;Ljava/lang/Class;Ljava/security/ProtectionDomain;[BZ)[B"
/*
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 526161bafa9..2af2c6d83d6 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
@@ -24,10 +24,10 @@
*/
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;
diff --git a/jdk/src/java.logging/share/classes/java/util/logging/LogManager.java b/jdk/src/java.logging/share/classes/java/util/logging/LogManager.java
index cb03b2af40e..bb408fd919b 100644
--- a/jdk/src/java.logging/share/classes/java/util/logging/LogManager.java
+++ b/jdk/src/java.logging/share/classes/java/util/logging/LogManager.java
@@ -23,7 +23,6 @@
* questions.
*/
-
package java.util.logging;
import java.io.*;
@@ -43,7 +42,6 @@ import java.util.stream.Stream;
import jdk.internal.misc.JavaAWTAccess;
import jdk.internal.misc.SharedSecrets;
import sun.util.logging.internal.LoggingProviderImpl;
-import java.lang.reflect.Module;
import static jdk.internal.logger.DefaultLoggerFinder.isSystem;
/**
diff --git a/jdk/src/java.logging/share/classes/java/util/logging/Logger.java b/jdk/src/java.logging/share/classes/java/util/logging/Logger.java
index 1cfd6f98659..dea269302d2 100644
--- a/jdk/src/java.logging/share/classes/java/util/logging/Logger.java
+++ b/jdk/src/java.logging/share/classes/java/util/logging/Logger.java
@@ -23,11 +23,9 @@
* questions.
*/
-
package java.util.logging;
import java.lang.ref.WeakReference;
-import java.lang.reflect.Module;
import java.security.AccessController;
import java.security.PrivilegedAction;
import java.util.ArrayList;
@@ -664,7 +662,7 @@ public class Logger {
* a new logger is created.
*
* If a new logger is created its log level will be configured
- * based on the LogManager configuration and it will configured
+ * based on the LogManager configuration and it will be configured
* to also send logging output to its parent's Handlers. It will
* be registered in the LogManager global namespace.
*
@@ -726,7 +724,7 @@ public class Logger {
*
*
* If a new logger is created its log level will be configured
- * based on the LogManager and it will configured to also send logging
+ * based on the LogManager and it will be configured to also send logging
* output to its parent's Handlers. It will be registered in
* the LogManager global namespace.
*
diff --git a/jdk/src/java.logging/share/classes/sun/util/logging/internal/LoggingProviderImpl.java b/jdk/src/java.logging/share/classes/sun/util/logging/internal/LoggingProviderImpl.java
index 1ccf2cf7c92..432228a88d0 100644
--- a/jdk/src/java.logging/share/classes/sun/util/logging/internal/LoggingProviderImpl.java
+++ b/jdk/src/java.logging/share/classes/sun/util/logging/internal/LoggingProviderImpl.java
@@ -32,7 +32,6 @@ import java.util.ResourceBundle;
import java.util.function.Supplier;
import java.lang.System.LoggerFinder;
import java.lang.System.Logger;
-import java.lang.reflect.Module;
import java.util.Objects;
import java.util.logging.LogManager;
import jdk.internal.logger.DefaultLoggerFinder;
diff --git a/jdk/src/java.management.rmi/share/classes/javax/management/remote/rmi/RMIConnector.java b/jdk/src/java.management.rmi/share/classes/javax/management/remote/rmi/RMIConnector.java
index 7c5cd32811f..16eeff47d4b 100644
--- a/jdk/src/java.management.rmi/share/classes/javax/management/remote/rmi/RMIConnector.java
+++ b/jdk/src/java.management.rmi/share/classes/javax/management/remote/rmi/RMIConnector.java
@@ -43,7 +43,6 @@ import java.lang.ref.WeakReference;
import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationHandler;
import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Module;
import java.lang.reflect.Proxy;
import java.net.MalformedURLException;
import java.rmi.MarshalledObject;
diff --git a/jdk/src/java.management/share/classes/java/lang/management/LockInfo.java b/jdk/src/java.management/share/classes/java/lang/management/LockInfo.java
index 7ad4760a869..91e5545e387 100644
--- a/jdk/src/java.management/share/classes/java/lang/management/LockInfo.java
+++ b/jdk/src/java.management/share/classes/java/lang/management/LockInfo.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2017, 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
@@ -38,8 +38,8 @@ import sun.management.LockInfoCompositeData;
* a synchronizer that may be exclusively owned by a thread and uses
* {@link AbstractOwnableSynchronizer AbstractOwnableSynchronizer}
* (or its subclass) to implement its synchronization property.
- * {@link ReentrantLock ReentrantLock} and
- * {@link ReentrantReadWriteLock ReentrantReadWriteLock} are
+ * {@link ReentrantLock ReentrantLock} and the write-lock (but not
+ * the read-lock) of {@link ReentrantReadWriteLock ReentrantReadWriteLock} are
* two examples of ownable synchronizers provided by the platform.
*
*
diff --git a/jdk/src/java.management/share/classes/javax/management/remote/JMXConnectorFactory.java b/jdk/src/java.management/share/classes/javax/management/remote/JMXConnectorFactory.java
index 580829c834c..5b0b6ac7695 100644
--- a/jdk/src/java.management/share/classes/javax/management/remote/JMXConnectorFactory.java
+++ b/jdk/src/java.management/share/classes/javax/management/remote/JMXConnectorFactory.java
@@ -28,7 +28,6 @@ package javax.management.remote;
import com.sun.jmx.mbeanserver.Util;
import java.io.IOException;
import java.io.UncheckedIOException;
-import java.lang.reflect.Module;
import java.net.MalformedURLException;
import java.util.Collections;
import java.util.HashMap;
diff --git a/jdk/src/java.management/share/classes/sun/management/ManagementFactoryHelper.java b/jdk/src/java.management/share/classes/sun/management/ManagementFactoryHelper.java
index 4eb5742b2ba..5336177ba50 100644
--- a/jdk/src/java.management/share/classes/sun/management/ManagementFactoryHelper.java
+++ b/jdk/src/java.management/share/classes/sun/management/ManagementFactoryHelper.java
@@ -45,7 +45,6 @@ import jdk.internal.misc.SharedSecrets;
import java.util.ArrayList;
import java.util.List;
-import java.lang.reflect.Module;
import java.lang.reflect.UndeclaredThrowableException;
import java.security.PrivilegedAction;
import java.util.Collections;
@@ -181,8 +180,7 @@ public class ManagementFactoryHelper {
return AccessController.doPrivileged(new PrivilegedAction<>() {
@Override
public Class> run() {
- Optional logging = java.lang.reflect.Layer.boot()
- .findModule("java.logging");
+ Optional logging = ModuleLayer.boot().findModule("java.logging");
if (logging.isPresent()) {
return Class.forName(logging.get(), className);
}
diff --git a/jdk/src/java.naming/share/classes/com/sun/jndi/ldap/AbstractLdapNamingEnumeration.java b/jdk/src/java.naming/share/classes/com/sun/jndi/ldap/AbstractLdapNamingEnumeration.java
index 8bef0da95ca..31b9c5c87d0 100644
--- a/jdk/src/java.naming/share/classes/com/sun/jndi/ldap/AbstractLdapNamingEnumeration.java
+++ b/jdk/src/java.naming/share/classes/com/sun/jndi/ldap/AbstractLdapNamingEnumeration.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2017, 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
@@ -382,6 +382,7 @@ abstract class AbstractLdapNamingEnumeration
listArg = ne.listArg;
}
+ @SuppressWarnings("deprecation")
protected final void finalize() {
cleanup();
}
diff --git a/jdk/src/java.naming/share/classes/com/sun/jndi/ldap/LdapClient.java b/jdk/src/java.naming/share/classes/com/sun/jndi/ldap/LdapClient.java
index f6b42d341fb..c6159711d13 100644
--- a/jdk/src/java.naming/share/classes/com/sun/jndi/ldap/LdapClient.java
+++ b/jdk/src/java.naming/share/classes/com/sun/jndi/ldap/LdapClient.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1999, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2017, 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
@@ -474,6 +474,7 @@ public final class LdapClient implements PooledConnection {
}
}
+ @SuppressWarnings("deprecation")
protected void finalize() {
if (debug > 0) System.err.println("LdapClient: finalize " + this);
forceClose(pooled);
diff --git a/jdk/src/java.naming/share/classes/com/sun/jndi/ldap/LdapCtx.java b/jdk/src/java.naming/share/classes/com/sun/jndi/ldap/LdapCtx.java
index 5308478c9f9..6484c3945ab 100644
--- a/jdk/src/java.naming/share/classes/com/sun/jndi/ldap/LdapCtx.java
+++ b/jdk/src/java.naming/share/classes/com/sun/jndi/ldap/LdapCtx.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1999, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2017, 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
@@ -2609,6 +2609,7 @@ final public class LdapCtx extends ComponentDirContext
// ----------------- Connection ---------------------
+ @SuppressWarnings("deprecation")
protected void finalize() {
try {
close();
diff --git a/jdk/src/java.naming/share/classes/com/sun/jndi/ldap/sasl/DefaultCallbackHandler.java b/jdk/src/java.naming/share/classes/com/sun/jndi/ldap/sasl/DefaultCallbackHandler.java
index a1d53b277f2..e5e04a12ee2 100644
--- a/jdk/src/java.naming/share/classes/com/sun/jndi/ldap/sasl/DefaultCallbackHandler.java
+++ b/jdk/src/java.naming/share/classes/com/sun/jndi/ldap/sasl/DefaultCallbackHandler.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2017, 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
@@ -129,6 +129,7 @@ final class DefaultCallbackHandler implements CallbackHandler {
}
}
+ @SuppressWarnings("deprecation")
protected void finalize() throws Throwable {
clearPassword();
}
diff --git a/jdk/src/java.naming/share/classes/com/sun/naming/internal/VersionHelper.java b/jdk/src/java.naming/share/classes/com/sun/naming/internal/VersionHelper.java
index c29a88dc40c..43dbc075138 100644
--- a/jdk/src/java.naming/share/classes/com/sun/naming/internal/VersionHelper.java
+++ b/jdk/src/java.naming/share/classes/com/sun/naming/internal/VersionHelper.java
@@ -176,7 +176,7 @@ public final class VersionHelper {
InputStream getResourceAsStream(Class> c, String name) {
PrivilegedAction act = () -> {
try {
- java.lang.reflect.Module m = c.getModule();
+ Module m = c.getModule();
return c.getModule().getResourceAsStream(resolveName(c,name));
} catch (IOException x) {
return null;
diff --git a/jdk/src/java.rmi/share/classes/java/rmi/activation/ActivationInstantiator.java b/jdk/src/java.rmi/share/classes/java/rmi/activation/ActivationInstantiator.java
index 4e100fb9abb..2cd4733fb25 100644
--- a/jdk/src/java.rmi/share/classes/java/rmi/activation/ActivationInstantiator.java
+++ b/jdk/src/java.rmi/share/classes/java/rmi/activation/ActivationInstantiator.java
@@ -67,11 +67,11 @@ public interface ActivationInstantiator extends Remote {
*
* The class to be activated and the special activation constructor are both public,
* and the class resides in a package that is
- * {@linkplain java.lang.reflect.Module#isExported(String,java.lang.reflect.Module) exported}
+ * {@linkplain Module#isExported(String,Module) exported}
* to at least the {@code java.rmi} module; or
*
* The class to be activated resides in a package that is
- * {@linkplain java.lang.reflect.Module#isOpen(String,java.lang.reflect.Module) open}
+ * {@linkplain Module#isOpen(String,Module) open}
* to at least the {@code java.rmi} module.
*
*
diff --git a/jdk/src/java.rmi/share/classes/java/rmi/server/UnicastRemoteObject.java b/jdk/src/java.rmi/share/classes/java/rmi/server/UnicastRemoteObject.java
index ecc1b6590bd..74d3c24fb3d 100644
--- a/jdk/src/java.rmi/share/classes/java/rmi/server/UnicastRemoteObject.java
+++ b/jdk/src/java.rmi/share/classes/java/rmi/server/UnicastRemoteObject.java
@@ -135,9 +135,9 @@ import sun.rmi.transport.LiveRef;
* remote object's class.
*
* Each remote interface must either be public and reside in a package that is
- * {@linkplain java.lang.reflect.Module#isExported(String,java.lang.reflect.Module) exported}
+ * {@linkplain Module#isExported(String,Module) exported}
* to at least the {@code java.rmi} module, or it must reside in a package that is
- * {@linkplain java.lang.reflect.Module#isOpen(String,java.lang.reflect.Module) open}
+ * {@linkplain Module#isOpen(String,Module) open}
* to at least the {@code java.rmi} module.
*
* The proxy's invocation handler is a {@link
diff --git a/jdk/src/java.rmi/share/classes/sun/rmi/log/LogInputStream.java b/jdk/src/java.rmi/share/classes/sun/rmi/log/LogInputStream.java
index 319e9741155..649fa22516d 100644
--- a/jdk/src/java.rmi/share/classes/sun/rmi/log/LogInputStream.java
+++ b/jdk/src/java.rmi/share/classes/sun/rmi/log/LogInputStream.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1997, 1999, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2017, 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
@@ -128,6 +128,7 @@ class LogInputStream extends InputStream {
/**
* Closes the stream when garbage is collected.
*/
+ @SuppressWarnings("deprecation")
protected void finalize() throws IOException {
close();
}
diff --git a/jdk/src/java.rmi/share/classes/sun/rmi/transport/tcp/ConnectionMultiplexer.java b/jdk/src/java.rmi/share/classes/sun/rmi/transport/tcp/ConnectionMultiplexer.java
index fae0e36570b..42857ec967c 100644
--- a/jdk/src/java.rmi/share/classes/sun/rmi/transport/tcp/ConnectionMultiplexer.java
+++ b/jdk/src/java.rmi/share/classes/sun/rmi/transport/tcp/ConnectionMultiplexer.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1996, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1996, 2017, 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
@@ -440,6 +440,7 @@ final class ConnectionMultiplexer {
/**
* Shut down connection upon finalization.
*/
+ @SuppressWarnings("deprecation")
protected void finalize() throws Throwable
{
super.finalize();
diff --git a/jdk/src/java.security.jgss/share/classes/sun/security/jgss/wrapper/GSSCredElement.java b/jdk/src/java.security.jgss/share/classes/sun/security/jgss/wrapper/GSSCredElement.java
index 3b06c7a0da9..019fa6f8052 100644
--- a/jdk/src/java.security.jgss/share/classes/sun/security/jgss/wrapper/GSSCredElement.java
+++ b/jdk/src/java.security.jgss/share/classes/sun/security/jgss/wrapper/GSSCredElement.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2005, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2017, 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
@@ -130,6 +130,7 @@ public class GSSCredElement implements GSSCredentialSpi {
return "N/A";
}
+ @SuppressWarnings("deprecation")
protected void finalize() throws Throwable {
dispose();
}
diff --git a/jdk/src/java.security.jgss/share/classes/sun/security/jgss/wrapper/GSSNameElement.java b/jdk/src/java.security.jgss/share/classes/sun/security/jgss/wrapper/GSSNameElement.java
index 3463fd69dfa..88274c1601b 100644
--- a/jdk/src/java.security.jgss/share/classes/sun/security/jgss/wrapper/GSSNameElement.java
+++ b/jdk/src/java.security.jgss/share/classes/sun/security/jgss/wrapper/GSSNameElement.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2017, 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
@@ -289,6 +289,7 @@ public class GSSNameElement implements GSSNameSpi {
}
}
+ @SuppressWarnings("deprecation")
protected void finalize() throws Throwable {
dispose();
}
diff --git a/jdk/src/java.security.jgss/share/classes/sun/security/jgss/wrapper/NativeGSSContext.java b/jdk/src/java.security.jgss/share/classes/sun/security/jgss/wrapper/NativeGSSContext.java
index 271fcfb896b..d2d5367f1b8 100644
--- a/jdk/src/java.security.jgss/share/classes/sun/security/jgss/wrapper/NativeGSSContext.java
+++ b/jdk/src/java.security.jgss/share/classes/sun/security/jgss/wrapper/NativeGSSContext.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2005, 2009, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2017, 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
@@ -618,6 +618,7 @@ class NativeGSSContext implements GSSContextSpi {
return isInitiator;
}
+ @SuppressWarnings("deprecation")
protected void finalize() throws Throwable {
dispose();
}
diff --git a/jdk/src/java.security.sasl/share/classes/com/sun/security/sasl/CramMD5Base.java b/jdk/src/java.security.sasl/share/classes/com/sun/security/sasl/CramMD5Base.java
index 88ddb7fb42c..0d521bf5a00 100644
--- a/jdk/src/java.security.sasl/share/classes/com/sun/security/sasl/CramMD5Base.java
+++ b/jdk/src/java.security.sasl/share/classes/com/sun/security/sasl/CramMD5Base.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2003, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2017, 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
@@ -136,6 +136,7 @@ abstract class CramMD5Base {
}
}
+ @SuppressWarnings("deprecation")
protected void finalize() {
clearPassword();
}
diff --git a/jdk/src/java.security.sasl/share/classes/com/sun/security/sasl/PlainClient.java b/jdk/src/java.security.sasl/share/classes/com/sun/security/sasl/PlainClient.java
index ce92c2939a1..7d561542d8f 100644
--- a/jdk/src/java.security.sasl/share/classes/com/sun/security/sasl/PlainClient.java
+++ b/jdk/src/java.security.sasl/share/classes/com/sun/security/sasl/PlainClient.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2000, 2006, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 2017, 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
@@ -199,6 +199,7 @@ final class PlainClient implements SaslClient {
}
}
+ @SuppressWarnings("deprecation")
protected void finalize() {
clearPassword();
}
diff --git a/jdk/src/java.smartcardio/share/classes/sun/security/smartcardio/CardImpl.java b/jdk/src/java.smartcardio/share/classes/sun/security/smartcardio/CardImpl.java
index f3a01511a29..d7e8f49fa83 100644
--- a/jdk/src/java.smartcardio/share/classes/sun/security/smartcardio/CardImpl.java
+++ b/jdk/src/java.smartcardio/share/classes/sun/security/smartcardio/CardImpl.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2017, 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
@@ -274,6 +274,7 @@ final class CardImpl extends Card {
+ ", protocol " + getProtocol() + ", state " + state;
}
+ @SuppressWarnings("deprecation")
protected void finalize() throws Throwable {
try {
if (state == State.OK) {
diff --git a/jdk/src/java.sql/share/classes/java/sql/Connection.java b/jdk/src/java.sql/share/classes/java/sql/Connection.java
index 944042aeb65..446f63c0f36 100644
--- a/jdk/src/java.sql/share/classes/java/sql/Connection.java
+++ b/jdk/src/java.sql/share/classes/java/sql/Connection.java
@@ -1535,8 +1535,9 @@ throws SQLException;
* The connection pool caches {@code PooledConnection} objects
* Returns a logical connection handle when {@code getConnection} is
* called by the application
- * The pool manager calls {@code Connection.close} on the logical connection handle
- * prior to returning the {@code PooledConnection} back to the cache
+ * The logical {@code Connection} is closed by calling
+ * {@code Connection.close} prior to returning the {@code PooledConnection}
+ * to the cache.
*
* @throws SQLException if an error occurs
* @since 9
@@ -1577,8 +1578,9 @@ throws SQLException;
* The connection pool caches {@code PooledConnection} objects
* Returns a logical connection handle when {@code getConnection} is
* called by the application
- * The pool manager calls {@code Connection.close} on the logical connection handle
- * prior to returning the {@code PooledConnection} back to the cache
+ * The logical {@code Connection} is closed by calling
+ * {@code Connection.close} prior to returning the {@code PooledConnection}
+ * to the cache.
*
* @throws SQLException if an error occurs
* @since 9
@@ -1590,7 +1592,10 @@ throws SQLException;
}
/**
- * Sets and validates the sharding keys for this connection.
+ * Sets and validates the sharding keys for this connection. A {@code null}
+ * value may be specified for the sharding Key. The validity
+ * of a {@code null} sharding key is vendor-specific. Consult your vendor's
+ * documentation for additional information.
* @implSpec
* The default implementation will throw a
* {@code SQLFeatureNotSupportedException}.
@@ -1600,7 +1605,8 @@ throws SQLException;
* {@code Connection}. The timeout value indicates how long the driver
* should wait for the {@code Connection} to verify that the sharding key
* is valid before {@code setShardingKeyIfValid} returns false.
- * @param shardingKey the sharding key to be validated against this connection
+ * @param shardingKey the sharding key to be validated against this connection.
+ * The sharding key may be {@code null}
* @param superShardingKey the super sharding key to be validated against this
* connection. The super sharding key may be {@code null}.
* @param timeout time in seconds before which the validation process is expected to
@@ -1610,10 +1616,10 @@ throws SQLException;
* and set on this connection; false if the sharding keys are not valid or
* the timeout period expires before the operation completes.
* @throws SQLException if an error occurs while performing this validation;
- * the {@code shardingkey} is {@code null}; a {@code superSharedingKey} is specified
+ * a {@code superSharedingKey} is specified
* without a {@code shardingKey};
* this method is called on a closed {@code connection}; or
- * the {@code timeout} value is less than 0.
+ * the {@code timeout} value is negative.
* @throws SQLFeatureNotSupportedException if the driver does not support sharding
* @since 9
* @see ShardingKey
@@ -1626,7 +1632,10 @@ throws SQLException;
}
/**
- * Sets and validates the sharding key for this connection.
+ * Sets and validates the sharding key for this connection. A {@code null}
+ * value may be specified for the sharding Key. The validity
+ * of a {@code null} sharding key is vendor-specific. Consult your vendor's
+ * documentation for additional information.
* @implSpec
* The default implementation will throw a
* {@code SQLFeatureNotSupportedException}.
@@ -1635,7 +1644,8 @@ throws SQLException;
* {@code Connection}. The timeout value indicates how long the driver
* should wait for the {@code Connection} to verify that the sharding key
* is valid before {@code setShardingKeyIfValid} returns false.
- * @param shardingKey the sharding key to be validated against this connection
+ * @param shardingKey the sharding key to be validated against this connection.
+ * The sharding key may be {@code null}
* @param timeout time in seconds before which the validation process is expected to
* be completed,else the validation process is aborted. A value of 0 indicates
* the validation process will not time out.
@@ -1643,8 +1653,8 @@ throws SQLException;
* set on this connection; false if the sharding key is not valid or
* the timeout period expires before the operation completes.
* @throws SQLException if there is an error while performing this validation;
- * this method is called on a closed {@code connection}; the {@code shardingkey}
- * is {@code null}; or the {@code timeout} value is less than 0.
+ * this method is called on a closed {@code connection};
+ * or the {@code timeout} value is negative.
* @throws SQLFeatureNotSupportedException if the driver does not support sharding
* @since 9
* @see ShardingKey
@@ -1664,12 +1674,12 @@ throws SQLException;
* This method sets the specified sharding keys but does not require a
* round trip to the database to validate that the sharding keys are valid
* for the {@code Connection}.
- * @param shardingKey the sharding key to set on this connection.
+ * @param shardingKey the sharding key to set on this connection. The sharding
+ * key may be {@code null}
* @param superShardingKey the super sharding key to set on this connection.
* The super sharding key may be {@code null}
* @throws SQLException if an error occurs setting the sharding keys;
- * this method is called on a closed {@code connection};
- * the {@code shardingkey} is {@code null}; or
+ * this method is called on a closed {@code connection}; or
* a {@code superSharedingKey} is specified without a {@code shardingKey}
* @throws SQLFeatureNotSupportedException if the driver does not support sharding
* @since 9
@@ -1690,10 +1700,10 @@ throws SQLException;
* This method sets the specified sharding key but does not require a
* round trip to the database to validate that the sharding key is valid
* for the {@code Connection}.
- * @param shardingKey the sharding key to set on this connection.
- * @throws SQLException if an error occurs setting the sharding key;
- * this method is called on a closed {@code connection}; or the
- * {@code shardkingKey} is {@code null}
+ * @param shardingKey the sharding key to set on this connection. The sharding
+ * key may be {@code null}
+ * @throws SQLException if an error occurs setting the sharding key; or
+ * this method is called on a closed {@code connection}
* @throws SQLFeatureNotSupportedException if the driver does not support sharding
* @since 9
* @see ShardingKey
diff --git a/jdk/src/jdk.accessibility/share/classes/module-info.java b/jdk/src/jdk.accessibility/share/classes/module-info.java
index 97834b9460c..4df2da0bf5e 100644
--- a/jdk/src/jdk.accessibility/share/classes/module-info.java
+++ b/jdk/src/jdk.accessibility/share/classes/module-info.java
@@ -26,6 +26,7 @@
/**
* Defines JDK utility classes used by implementors of Assistive Technologies.
*
+ * @moduleGraph
* @since 9
*/
module jdk.accessibility {
diff --git a/jdk/src/jdk.crypto.cryptoki/share/classes/sun/security/pkcs11/P11KeyStore.java b/jdk/src/jdk.crypto.cryptoki/share/classes/sun/security/pkcs11/P11KeyStore.java
index c630598f199..d26976655c4 100644
--- a/jdk/src/jdk.crypto.cryptoki/share/classes/sun/security/pkcs11/P11KeyStore.java
+++ b/jdk/src/jdk.crypto.cryptoki/share/classes/sun/security/pkcs11/P11KeyStore.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2003, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2017, 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
@@ -241,6 +241,7 @@ final class P11KeyStore extends KeyStoreSpi {
pc.setPassword(password); // this clones the password if not null
}
+ @SuppressWarnings("deprecation")
protected void finalize() throws Throwable {
if (password != null) {
Arrays.fill(password, ' ');
@@ -1022,7 +1023,7 @@ final class P11KeyStore extends KeyStoreSpi {
("trusted certificates may only be set by " +
"token initialization application"));
}
- Module module = token.provider.nssModule;
+ Secmod.Module module = token.provider.nssModule;
if ((module.type != ModuleType.KEYSTORE) && (module.type != ModuleType.FIPS)) {
// XXX allow TRUSTANCHOR module
throw new KeyStoreException("Trusted certificates can only be "
diff --git a/jdk/src/jdk.crypto.cryptoki/share/classes/sun/security/pkcs11/SunPKCS11.java b/jdk/src/jdk.crypto.cryptoki/share/classes/sun/security/pkcs11/SunPKCS11.java
index a9b6de30d82..9e3ffe773e7 100644
--- a/jdk/src/jdk.crypto.cryptoki/share/classes/sun/security/pkcs11/SunPKCS11.java
+++ b/jdk/src/jdk.crypto.cryptoki/share/classes/sun/security/pkcs11/SunPKCS11.java
@@ -77,7 +77,7 @@ public final class SunPKCS11 extends AuthProvider {
final boolean removable;
- final Module nssModule;
+ final Secmod.Module nssModule;
final boolean nssUseSecmodTrust;
@@ -148,7 +148,7 @@ public final class SunPKCS11 extends AuthProvider {
boolean useSecmod = config.getNssUseSecmod();
boolean nssUseSecmodTrust = config.getNssUseSecmodTrust();
- Module nssModule = null;
+ Secmod.Module nssModule = null;
//
// Initialization via Secmod. The way this works is as follows:
@@ -217,7 +217,7 @@ public final class SunPKCS11 extends AuthProvider {
// XXX which exception to throw
throw new ProviderException("Could not initialize NSS", e);
}
- List modules = secmod.getModules();
+ List modules = secmod.getModules();
if (config.getShowInfo()) {
System.out.println("NSS modules: " + modules);
}
@@ -258,7 +258,7 @@ public final class SunPKCS11 extends AuthProvider {
("Invalid external module: " + moduleName);
}
int k = 0;
- for (Module module : modules) {
+ for (Secmod.Module module : modules) {
if (module.getType() == ModuleType.EXTERNAL) {
if (++k == moduleIndex) {
nssModule = module;
diff --git a/jdk/src/jdk.crypto.cryptoki/share/classes/sun/security/pkcs11/wrapper/PKCS11.java b/jdk/src/jdk.crypto.cryptoki/share/classes/sun/security/pkcs11/wrapper/PKCS11.java
index 0b3c7a089d6..554f4d5bb6e 100644
--- a/jdk/src/jdk.crypto.cryptoki/share/classes/sun/security/pkcs11/wrapper/PKCS11.java
+++ b/jdk/src/jdk.crypto.cryptoki/share/classes/sun/security/pkcs11/wrapper/PKCS11.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2003, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2017, Oracle and/or its affiliates. All rights reserved.
*/
/* Copyright (c) 2002 Graz University of Technology. All rights reserved.
@@ -1531,6 +1531,7 @@ public class PKCS11 {
*
* @exception Throwable If finalization fails.
*/
+ @SuppressWarnings("deprecation")
protected void finalize() throws Throwable {
disconnect();
}
diff --git a/jdk/src/jdk.crypto.ec/share/legal/ecc.md b/jdk/src/jdk.crypto.ec/share/legal/ecc.md
index 2ce66e448b1..300b7d4ebca 100644
--- a/jdk/src/jdk.crypto.ec/share/legal/ecc.md
+++ b/jdk/src/jdk.crypto.ec/share/legal/ecc.md
@@ -6,7 +6,8 @@
This notice is provided with respect to Elliptic Curve Cryptography,
which is included with JRE, JDK, and OpenJDK.
-You are receiving a copy of the Elliptic Curve Cryptography library in source
+You are receiving a [copy](http://hg.openjdk.java.net/jdk9/jdk9/jdk/file/tip/src/jdk.crypto.ec/share/native/libsunec/impl)
+of the Elliptic Curve Cryptography library in source
form with the JDK and OpenJDK source distributions, and as object code in
the JRE & JDK runtimes.
diff --git a/jdk/src/jdk.crypto.mscapi/windows/classes/sun/security/mscapi/Key.java b/jdk/src/jdk.crypto.mscapi/windows/classes/sun/security/mscapi/Key.java
index 8154c489a95..a36656f4521 100644
--- a/jdk/src/jdk.crypto.mscapi/windows/classes/sun/security/mscapi/Key.java
+++ b/jdk/src/jdk.crypto.mscapi/windows/classes/sun/security/mscapi/Key.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2005, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2017, 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
@@ -52,6 +52,7 @@ abstract class Key implements java.security.Key, Length
/**
* Finalization method
*/
+ @SuppressWarnings("deprecation")
protected void finalize() throws Throwable
{
try {
diff --git a/jdk/src/jdk.editpad/share/classes/module-info.java b/jdk/src/jdk.editpad/share/classes/module-info.java
index 0d674bbae56..57077ed9008 100644
--- a/jdk/src/jdk.editpad/share/classes/module-info.java
+++ b/jdk/src/jdk.editpad/share/classes/module-info.java
@@ -26,6 +26,7 @@
/**
* Implementation of the edit pad service.
*
+ * @moduleGraph
* @since 9
*/
module jdk.editpad {
diff --git a/jdk/src/jdk.incubator.httpclient/share/classes/module-info.java b/jdk/src/jdk.incubator.httpclient/share/classes/module-info.java
index a9a16dfe3d1..a3fb16abbd4 100644
--- a/jdk/src/jdk.incubator.httpclient/share/classes/module-info.java
+++ b/jdk/src/jdk.incubator.httpclient/share/classes/module-info.java
@@ -27,6 +27,7 @@
* Defines the high-level HTTP and WebSocket API.
* {@Incubating}
*
+ * @moduleGraph
* @since 9
*/
module jdk.incubator.httpclient {
diff --git a/jdk/src/jdk.internal.le/share/classes/jdk/internal/jline/console/ConsoleReader.java b/jdk/src/jdk.internal.le/share/classes/jdk/internal/jline/console/ConsoleReader.java
index a7f26871f28..6a9fb3b9db9 100644
--- a/jdk/src/jdk.internal.le/share/classes/jdk/internal/jline/console/ConsoleReader.java
+++ b/jdk/src/jdk.internal.le/share/classes/jdk/internal/jline/console/ConsoleReader.java
@@ -306,6 +306,7 @@ public class ConsoleReader
* Shuts down the ConsoleReader if the JVM attempts to clean it up.
*/
@Override
+ @SuppressWarnings("deprecation")
protected void finalize() throws Throwable {
try {
shutdown();
diff --git a/jdk/src/jdk.internal.le/share/classes/jdk/internal/jline/extra/EditingHistory.java b/jdk/src/jdk.internal.le/share/classes/jdk/internal/jline/extra/EditingHistory.java
index 394d0eb4096..fcccd9d2523 100644
--- a/jdk/src/jdk.internal.le/share/classes/jdk/internal/jline/extra/EditingHistory.java
+++ b/jdk/src/jdk.internal.le/share/classes/jdk/internal/jline/extra/EditingHistory.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2017, 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
@@ -74,7 +74,7 @@ public abstract class EditingHistory implements History {
//in.resetPromptLine(in.getPrompt(), in.getHistory().current().toString(), -1);
//but that would mean more re-writing on the screen, (and prints an additional
//empty line), so using setBuffer directly:
- Method setBuffer = in.getClass().getDeclaredMethod("setBuffer", String.class);
+ Method setBuffer = ConsoleReader.class.getDeclaredMethod("setBuffer", String.class);
setBuffer.setAccessible(true);
setBuffer.invoke(in, in.getHistory().current().toString());
diff --git a/jdk/src/jdk.jartool/share/classes/sun/security/tools/jarsigner/Main.java b/jdk/src/jdk.jartool/share/classes/sun/security/tools/jarsigner/Main.java
index a42dfe21882..cb86682f7da 100644
--- a/jdk/src/jdk.jartool/share/classes/sun/security/tools/jarsigner/Main.java
+++ b/jdk/src/jdk.jartool/share/classes/sun/security/tools/jarsigner/Main.java
@@ -444,6 +444,7 @@ public class Main {
} else if (collator.compare(flags, "-strict") ==0) {
strict = true;
} else if (collator.compare(flags, "-h") == 0 ||
+ collator.compare(flags, "-?") == 0 ||
collator.compare(flags, "-help") == 0) {
fullusage();
} else {
diff --git a/jdk/src/jdk.jcmd/share/classes/sun/tools/common/ProcessArgumentMatcher.java b/jdk/src/jdk.jcmd/share/classes/sun/tools/common/ProcessArgumentMatcher.java
index 7e1da1c8d92..d8e44d385ab 100644
--- a/jdk/src/jdk.jcmd/share/classes/sun/tools/common/ProcessArgumentMatcher.java
+++ b/jdk/src/jdk.jcmd/share/classes/sun/tools/common/ProcessArgumentMatcher.java
@@ -25,7 +25,6 @@
package sun.tools.common;
-import java.lang.reflect.Module;
import java.net.URISyntaxException;
import java.util.ArrayList;
import java.util.Collection;
diff --git a/jdk/src/jdk.jdwp.agent/share/native/libjdwp/ModuleReferenceImpl.c b/jdk/src/jdk.jdwp.agent/share/native/libjdwp/ModuleReferenceImpl.c
index 047796421a7..88df2d9603d 100644
--- a/jdk/src/jdk.jdwp.agent/share/native/libjdwp/ModuleReferenceImpl.c
+++ b/jdk/src/jdk.jdwp.agent/share/native/libjdwp/ModuleReferenceImpl.c
@@ -29,8 +29,8 @@
#include "ModuleReferenceImpl.h"
-static jclass jlrM(JNIEnv *env) {
- return findClass(env, "Ljava/lang/reflect/Module;");
+static jclass jlM(JNIEnv *env) {
+ return findClass(env, "Ljava/lang/Module;");
}
static jboolean
@@ -43,7 +43,7 @@ getName(PacketInputStream *in, PacketOutputStream *out)
jobject module;
if (method == NULL) {
- method = getMethod(env, jlrM(env), "getName", "()Ljava/lang/String;");
+ method = getMethod(env, jlM(env), "getName", "()Ljava/lang/String;");
}
module = inStream_readModuleRef(getEnv(), in);
if (inStream_error(in)) {
@@ -71,7 +71,7 @@ getClassLoader(PacketInputStream *in, PacketOutputStream *out)
jobject module;
if (method == NULL) {
- method = getMethod(env, jlrM(env), "getClassLoader", "()Ljava/lang/ClassLoader;");
+ method = getMethod(env, jlM(env), "getClassLoader", "()Ljava/lang/ClassLoader;");
}
module = inStream_readModuleRef(env, in);
if (inStream_error(in)) {
diff --git a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/Jlink.java b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/Jlink.java
index 5ab1bfca53a..5a0d3f223d9 100644
--- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/Jlink.java
+++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/Jlink.java
@@ -26,7 +26,6 @@ package jdk.tools.jlink.internal;
import java.lang.module.Configuration;
import java.lang.module.ModuleFinder;
-import java.lang.reflect.Layer;
import java.nio.ByteOrder;
import java.nio.file.Path;
import java.util.ArrayList;
@@ -55,10 +54,10 @@ public final class Jlink {
* @return A new plugin or null if plugin is unknown.
*/
public static Plugin newPlugin(String name,
- Map configuration, Layer pluginsLayer) {
+ Map configuration, ModuleLayer pluginsLayer) {
Objects.requireNonNull(name);
Objects.requireNonNull(configuration);
- pluginsLayer = pluginsLayer == null ? Layer.boot() : pluginsLayer;
+ pluginsLayer = pluginsLayer == null ? ModuleLayer.boot() : pluginsLayer;
return PluginRepository.newPlugin(configuration, name, pluginsLayer);
}
@@ -330,7 +329,7 @@ public final class Jlink {
private PluginsConfiguration addAutoEnabledPlugins(PluginsConfiguration pluginsConfig) {
List plugins = new ArrayList<>(pluginsConfig.getPlugins());
- List bootPlugins = PluginRepository.getPlugins(Layer.boot());
+ List bootPlugins = PluginRepository.getPlugins(ModuleLayer.boot());
for (Plugin bp : bootPlugins) {
if (Utils.isAutoEnabled(bp)) {
try {
diff --git a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/PluginRepository.java b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/PluginRepository.java
index 1d39c2cbfeb..b12bf00df96 100644
--- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/PluginRepository.java
+++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/PluginRepository.java
@@ -24,7 +24,6 @@
*/
package jdk.tools.jlink.internal;
-import java.lang.reflect.Layer;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
@@ -56,7 +55,7 @@ public final class PluginRepository {
* @return A provider or null if not found.
*/
public static Plugin getPlugin(String name,
- Layer pluginsLayer) {
+ ModuleLayer pluginsLayer) {
return getPlugin(Plugin.class, name, pluginsLayer);
}
@@ -69,7 +68,7 @@ public final class PluginRepository {
* @return A plugin or null if no plugin found.
*/
public static Plugin newPlugin(Map config, String name,
- Layer pluginsLayer) {
+ ModuleLayer pluginsLayer) {
Objects.requireNonNull(name);
Objects.requireNonNull(pluginsLayer);
Plugin plugin = getPlugin(name, pluginsLayer);
@@ -107,12 +106,12 @@ public final class PluginRepository {
registeredPlugins.remove(name);
}
- public static List getPlugins(Layer pluginsLayer) {
+ public static List getPlugins(ModuleLayer pluginsLayer) {
return getPlugins(Plugin.class, pluginsLayer);
}
private static T getPlugin(Class clazz, String name,
- Layer pluginsLayer) {
+ ModuleLayer pluginsLayer) {
Objects.requireNonNull(name);
Objects.requireNonNull(pluginsLayer);
@SuppressWarnings("unchecked")
@@ -136,7 +135,7 @@ public final class PluginRepository {
* @param pluginsLayer
* @return The list of plugins.
*/
- private static List getPlugins(Class clazz, Layer pluginsLayer) {
+ private static List getPlugins(Class clazz, ModuleLayer pluginsLayer) {
Objects.requireNonNull(pluginsLayer);
List factories = new ArrayList<>();
try {
diff --git a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/TaskHelper.java b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/TaskHelper.java
index 4535f9cfe7e..f5a312de8aa 100644
--- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/TaskHelper.java
+++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/TaskHelper.java
@@ -29,7 +29,6 @@ import java.io.IOException;
import java.io.PrintWriter;
import java.lang.module.Configuration;
import java.lang.module.ModuleFinder;
-import java.lang.reflect.Layer;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
@@ -211,7 +210,7 @@ public final class TaskHelper {
private final class PluginsHelper {
- private Layer pluginsLayer = Layer.boot();
+ private ModuleLayer pluginsLayer = ModuleLayer.boot();
private final List plugins;
private String lastSorter;
private boolean listPlugins;
@@ -655,7 +654,7 @@ public final class TaskHelper {
return defaults;
}
- public Layer getPluginsLayer() {
+ public ModuleLayer getPluginsLayer() {
return pluginOptions.pluginsLayer;
}
}
@@ -725,18 +724,18 @@ public final class TaskHelper {
return System.getProperty("java.version");
}
- static Layer createPluginsLayer(List paths) {
+ static ModuleLayer createPluginsLayer(List paths) {
Path[] dirs = paths.toArray(new Path[0]);
ModuleFinder finder = ModulePath.of(Runtime.version(), true, dirs);
- Configuration bootConfiguration = Layer.boot().configuration();
+ Configuration bootConfiguration = ModuleLayer.boot().configuration();
try {
Configuration cf = bootConfiguration
.resolveAndBind(ModuleFinder.of(),
finder,
Collections.emptySet());
ClassLoader scl = ClassLoader.getSystemClassLoader();
- return Layer.boot().defineModulesWithOneLoader(cf, scl);
+ return ModuleLayer.boot().defineModulesWithOneLoader(cf, scl);
} catch (Exception ex) {
// Malformed plugin modules (e.g.: same package in multiple modules).
throw new PluginException("Invalid modules in the plugins path: " + ex);
diff --git a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/Utils.java b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/Utils.java
index ef8fb392086..fd0dc135263 100644
--- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/Utils.java
+++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/Utils.java
@@ -24,7 +24,6 @@
*/
package jdk.tools.jlink.internal;
-import java.lang.reflect.Module;
import java.net.URI;
import java.nio.file.FileSystem;
import java.nio.file.FileSystems;
diff --git a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/ReleaseInfoPlugin.java b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/ReleaseInfoPlugin.java
index e778733cd06..bcdb1e90a0c 100644
--- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/ReleaseInfoPlugin.java
+++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/ReleaseInfoPlugin.java
@@ -27,6 +27,7 @@ package jdk.tools.jlink.internal.plugins;
import java.io.ByteArrayOutputStream;
import java.io.FileInputStream;
import java.io.IOException;
+import java.io.PrintWriter;
import java.io.UncheckedIOException;
import java.lang.module.ModuleDescriptor;
import java.util.EnumSet;
@@ -43,8 +44,6 @@ import jdk.tools.jlink.plugin.ResourcePool;
import jdk.tools.jlink.plugin.ResourcePoolBuilder;
import jdk.tools.jlink.plugin.ResourcePoolEntry;
import jdk.tools.jlink.plugin.ResourcePoolModule;
-import jdk.tools.jlink.plugin.Plugin.Category;
-import jdk.tools.jlink.plugin.Plugin.State;
import jdk.tools.jlink.plugin.Plugin;
/**
@@ -101,9 +100,9 @@ public final class ReleaseInfoPlugin implements Plugin {
// --release-info add:build_type=fastdebug,source=openjdk,java_version=9
// and put whatever value that was passed in command line.
- config.keySet().stream().
- filter(s -> !NAME.equals(s)).
- forEach(s -> release.put(s, config.get(s)));
+ config.keySet().stream()
+ .filter(s -> !NAME.equals(s))
+ .forEach(s -> release.put(s, config.get(s)));
}
break;
@@ -148,8 +147,8 @@ public final class ReleaseInfoPlugin implements Plugin {
// put topological sorted module names separated by space
release.put("MODULES", new ModuleSorter(in.moduleView())
- .sorted().map(ResourcePoolModule::name)
- .collect(Collectors.joining(" ", "\"", "\"")));
+ .sorted().map(ResourcePoolModule::name)
+ .collect(Collectors.joining(" ", "\"", "\"")));
// create a TOP level ResourcePoolEntry for "release" file.
out.add(ResourcePoolEntry.create("/java.base/release",
@@ -160,11 +159,11 @@ public final class ReleaseInfoPlugin implements Plugin {
// 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("."));
+ return Runtime.Version.parse(str)
+ .version()
+ .stream()
+ .map(Object::toString)
+ .collect(Collectors.joining("."));
}
private static String quote(String str) {
@@ -172,14 +171,12 @@ public final class ReleaseInfoPlugin implements Plugin {
}
private byte[] releaseFileContent() {
- Properties props = new Properties();
- props.putAll(release);
ByteArrayOutputStream baos = new ByteArrayOutputStream();
- try {
- props.store(baos, "");
- return baos.toByteArray();
- } catch (IOException ex) {
- throw new UncheckedIOException(ex);
+ try (PrintWriter pw = new PrintWriter(baos)) {
+ release.entrySet().stream()
+ .sorted(Map.Entry.comparingByKey())
+ .forEach(e -> pw.format("%s=%s%n", e.getKey(), e.getValue()));
}
+ return baos.toByteArray();
}
}
diff --git a/jdk/src/jdk.naming.dns/share/classes/com/sun/jndi/dns/DnsClient.java b/jdk/src/jdk.naming.dns/share/classes/com/sun/jndi/dns/DnsClient.java
index 6820eee580b..90ed8ef965c 100644
--- a/jdk/src/jdk.naming.dns/share/classes/com/sun/jndi/dns/DnsClient.java
+++ b/jdk/src/jdk.naming.dns/share/classes/com/sun/jndi/dns/DnsClient.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 2017, 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
@@ -142,6 +142,7 @@ public class DnsClient {
resps = Collections.synchronizedMap(new HashMap());
}
+ @SuppressWarnings("deprecation")
protected void finalize() {
close();
}
diff --git a/jdk/src/jdk.naming.rmi/share/classes/com/sun/jndi/rmi/registry/RegistryContext.java b/jdk/src/jdk.naming.rmi/share/classes/com/sun/jndi/rmi/registry/RegistryContext.java
index 874d6872af5..81a348f013f 100644
--- a/jdk/src/jdk.naming.rmi/share/classes/com/sun/jndi/rmi/registry/RegistryContext.java
+++ b/jdk/src/jdk.naming.rmi/share/classes/com/sun/jndi/rmi/registry/RegistryContext.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1999, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2017, 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
@@ -119,6 +119,7 @@ public class RegistryContext implements Context, Referenceable {
reference = ctx.reference;
}
+ @SuppressWarnings("deprecation")
protected void finalize() {
close();
}
@@ -593,6 +594,7 @@ class BindingEnumeration implements NamingEnumeration {
nextName = 0;
}
+ @SuppressWarnings("deprecation")
protected void finalize() {
ctx.close();
}
@@ -633,6 +635,7 @@ class BindingEnumeration implements NamingEnumeration {
}
}
+ @SuppressWarnings("deprecation")
public void close () {
finalize();
}
diff --git a/jdk/src/jdk.security.jgss/share/classes/com/sun/security/sasl/gsskerb/GssKrb5Base.java b/jdk/src/jdk.security.jgss/share/classes/com/sun/security/sasl/gsskerb/GssKrb5Base.java
index 7a7dc52a26c..bb7a4e4ad41 100644
--- a/jdk/src/jdk.security.jgss/share/classes/com/sun/security/sasl/gsskerb/GssKrb5Base.java
+++ b/jdk/src/jdk.security.jgss/share/classes/com/sun/security/sasl/gsskerb/GssKrb5Base.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2017, 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
@@ -158,6 +158,7 @@ abstract class GssKrb5Base extends AbstractSaslImpl {
}
}
+ @SuppressWarnings("deprecation")
protected void finalize() throws Throwable {
dispose();
}
diff --git a/jdk/src/jdk.zipfs/share/classes/jdk/nio/zipfs/ZipFileSystem.java b/jdk/src/jdk.zipfs/share/classes/jdk/nio/zipfs/ZipFileSystem.java
index 498a93dc902..2b9891b8e15 100644
--- a/jdk/src/jdk.zipfs/share/classes/jdk/nio/zipfs/ZipFileSystem.java
+++ b/jdk/src/jdk.zipfs/share/classes/jdk/nio/zipfs/ZipFileSystem.java
@@ -936,6 +936,7 @@ class ZipFileSystem extends FileSystem {
return zc.toString(name);
}
+ @SuppressWarnings("deprecation")
protected void finalize() throws IOException {
close();
}
diff --git a/jdk/test/ProblemList.txt b/jdk/test/ProblemList.txt
index f40c073f126..377595bdaf1 100644
--- a/jdk/test/ProblemList.txt
+++ b/jdk/test/ProblemList.txt
@@ -289,8 +289,6 @@ com/sun/jdi/sde/SourceDebugExtensionTest.java 8158066 windows-
java/util/BitSet/BitSetStreamTest.java 8079538 generic-all
-jdk/internal/util/jar/TestVersionedStream.java 8177640 windows-all
-
############################################################################
# jdk_instrument
diff --git a/jdk/test/TEST.ROOT b/jdk/test/TEST.ROOT
index e822c4f2aae..f79fb4e6e5d 100644
--- a/jdk/test/TEST.ROOT
+++ b/jdk/test/TEST.ROOT
@@ -26,8 +26,8 @@ groups=TEST.groups [closed/TEST.groups]
# Allow querying of various System properties in @requires clauses
requires.properties=sun.arch.data.model java.runtime.name
-# Tests using jtreg 4.2 b05 features
-requiredVersion=4.2 b05
+# Tests using jtreg 4.2 b07 features
+requiredVersion=4.2 b07
# Path to libraries in the topmost test directory. This is needed so @library
# does not need ../../ notation to reach them
diff --git a/jdk/test/com/sun/jdi/ArgumentValuesTest.java b/jdk/test/com/sun/jdi/ArgumentValuesTest.java
index 13c6b2a48fb..bcce51bc562 100644
--- a/jdk/test/com/sun/jdi/ArgumentValuesTest.java
+++ b/jdk/test/com/sun/jdi/ArgumentValuesTest.java
@@ -1,13 +1,38 @@
-/** hard coded linenumbers in other tests - DO NOT CHANGE
- * @test/nodynamiccopyright/
- * @bug 4490824
- * @summary JDI: provide arguments when no debug attributes present
+/*
+ * Copyright (c) 2007, 2017, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
- * @author jjh
+ * 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.
*
- * @run build TestScaffold VMConnection TargetListener TargetAdapter
- * @run compile ArgumentValuesTest.java
- * @run driver ArgumentValuesTest
+ * 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.
+ */
+
+// THIS TEST IS LINE NUMBER SENSITIVE
+
+/**
+ * @test
+ * @bug 4490824
+ * @summary JDI: provide arguments when no debug attributes present
+ *
+ * @author jjh
+ *
+ * @run build TestScaffold VMConnection TargetListener TargetAdapter
+ * @run compile ArgumentValuesTest.java
+ * @run driver ArgumentValuesTest
*/
import com.sun.jdi.*;
import com.sun.jdi.event.*;
@@ -35,26 +60,26 @@ class ArgumentValuesTarg {
static List intList;
public static void noArgs() {
- int index = 0; // line 38
+ int index = 0; // line NO_ARGS_LINE_1
}
public static void allArgs(char p_char, byte p_byte, short p_short,
int p_int, long p_long, float p_float,
double p_double, int p_iarray[], int p_marray[][],
String p_sarray1[], String p_string) {
- int index = 0; // line 45
+ int index = 0; // line ALL_ARGS_LINE_1
}
public static void varArgs(String ... p1) {
- int index = 0; // line 49
+ int index = 0; // line VAR_ARGS_LINE_1
}
public static void genericArgs(List p1) {
- int index = 0; // line 53
+ int index = 0; // line GENERIC_ARGS_LINE_1
}
public void instanceMethod(char p_char, byte p_byte) {
- int index = 0; // line 57
+ int index = 0; // line INSTANCE_METHOD_LINE_1
}
public static void main(String[] args) {
@@ -81,6 +106,12 @@ class ArgumentValuesTarg {
/********** test program **********/
public class ArgumentValuesTest extends TestScaffold {
+ static final int NO_ARGS_LINE_1 = 63;
+ static final int ALL_ARGS_LINE_1 = 70;
+ static final int VAR_ARGS_LINE_1 = 74;
+ static final int GENERIC_ARGS_LINE_1 = 78;
+ static final int INSTANCE_METHOD_LINE_1 = 82;
+
// Must be in same order as args to allArgs(....)
String fieldNames[] = {"s_char1", "s_byte1", "s_short1", "s_int1",
"s_long1", "s_float1", "s_double1", "s_iarray1",
@@ -118,7 +149,7 @@ public class ArgumentValuesTest extends TestScaffold {
{
System.out.println("----- Testing each type of arg");
- bpe = resumeTo("ArgumentValuesTarg", 45);
+ bpe = resumeTo("ArgumentValuesTarg", ALL_ARGS_LINE_1);
StackFrame frame = bpe.thread().frame(0);
Method mmm = frame.location().method();
@@ -147,7 +178,7 @@ public class ArgumentValuesTest extends TestScaffold {
// a method with no params
{
System.out.println("----- Testing no args");
- bpe = resumeTo("ArgumentValuesTarg", 38);
+ bpe = resumeTo("ArgumentValuesTarg", NO_ARGS_LINE_1);
StackFrame frame = bpe.thread().frame(0);
Method mmm = frame.location().method();
@@ -165,7 +196,7 @@ public class ArgumentValuesTest extends TestScaffold {
// as a String[3] in the method.
{
System.out.println("----- Testing var args");
- bpe = resumeTo("ArgumentValuesTarg", 49);
+ bpe = resumeTo("ArgumentValuesTarg", VAR_ARGS_LINE_1);
StackFrame frame = bpe.thread().frame(0);
Method mmm = frame.location().method();
@@ -199,7 +230,7 @@ public class ArgumentValuesTest extends TestScaffold {
// a method with with one generic param
{
System.out.println("----- Testing generic args");
- bpe = resumeTo("ArgumentValuesTarg", 53);
+ bpe = resumeTo("ArgumentValuesTarg", GENERIC_ARGS_LINE_1);
StackFrame frame = bpe.thread().frame(0);
Method mmm = frame.location().method();
@@ -224,7 +255,7 @@ public class ArgumentValuesTest extends TestScaffold {
// test instance method call
{
System.out.println("----- Testing instance method call");
- bpe = resumeTo("ArgumentValuesTarg", 57);
+ bpe = resumeTo("ArgumentValuesTarg", INSTANCE_METHOD_LINE_1);
StackFrame frame = bpe.thread().frame(0);
Method mmm = frame.location().method();
diff --git a/jdk/test/com/sun/jdi/BreakpointTest.java b/jdk/test/com/sun/jdi/BreakpointTest.java
index 1266f0a274b..9012c1c2033 100644
--- a/jdk/test/com/sun/jdi/BreakpointTest.java
+++ b/jdk/test/com/sun/jdi/BreakpointTest.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2001, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2001, 2017, 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
@@ -21,19 +21,20 @@
* questions.
*/
+// THIS TEST IS LINE NUMBER SENSITIVE
+
/**
- * @test
- * @bug 6496524
- * @summary Setting breakpoint in jdb crashes Hotspot JVM
+ * @test
+ * @bug 6496524
+ * @key intermittent
+ * @summary Setting breakpoint in jdb crashes Hotspot JVM
+ * @author jjh
*
- * @author jjh
- *
- * @key intermittent
- * @modules jdk.jdi
- * @run build TestScaffold VMConnection TargetListener TargetAdapter
- * @run compile -g BreakpointTest.java
- * @run driver BreakpointTest
+ * @run build TestScaffold VMConnection TargetListener TargetAdapter
+ * @run compile -g BreakpointTest.java
+ * @run driver BreakpointTest
*/
+
import com.sun.jdi.*;
import com.sun.jdi.event.*;
import com.sun.jdi.request.*;
@@ -47,7 +48,6 @@ import java.util.*;
class BreakpointTarg {
public final static int BKPT_LINE = 56;
- // LINE NUMBER SENSITIVE
public static long count;
static void doit() {
diff --git a/jdk/test/com/sun/jdi/FetchLocals.java b/jdk/test/com/sun/jdi/FetchLocals.java
index 67d865d9c32..1195a8db14d 100644
--- a/jdk/test/com/sun/jdi/FetchLocals.java
+++ b/jdk/test/com/sun/jdi/FetchLocals.java
@@ -1,13 +1,37 @@
-/** hard coded linenumbers in test - DO NOT CHANGE
- * @test/nodynamiccopyright/
- * @bug 4386002 4429245
- * @summary Test fix for: Incorrect values reported for some locals of type long
+/*
+ * Copyright (c) 2013, 2017, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
- * @author Tim Bell
+ * 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.
*
- * @run build TestScaffold VMConnection TargetListener TargetAdapter
- * @run compile -g FetchLocals.java
- * @run driver FetchLocals
+ * 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.
+ */
+
+// THIS TEST IS LINE NUMBER SENSITIVE
+
+/**
+ * @test
+ * @bug 4386002 4429245
+ * @summary Test fix for: Incorrect values reported for some locals of type long
+ * @author Tim Bell
+ *
+ * @run build TestScaffold VMConnection TargetListener TargetAdapter
+ * @run compile -g FetchLocals.java
+ * @run driver FetchLocals
*/
import com.sun.jdi.*;
import com.sun.jdi.event.*;
@@ -59,7 +83,7 @@ class FetchLocalsDebugee {
System.out.println(f);
System.out.print("d is: ");
System.out.println(d);
- System.out.println(); // Thie is Line 63...
+ System.out.println(); // This is FetchLocals::LINE
if (w == 0xde00ad00be00ef00L) {
System.out.print ("The debugger was here. w modified to: 0x");
System.out.println(Long.toHexString(w));
@@ -87,6 +111,7 @@ class FetchLocalsDebugee {
}
public class FetchLocals extends TestScaffold {
+ static final int LINE = 86;
FetchLocals (String args[]) {
super(args);
@@ -355,7 +380,7 @@ public class FetchLocals extends TestScaffold {
* Get to the bottom of testMethod():
*/
try {
- BreakpointEvent bpe = resumeTo("FetchLocalsDebugee", 63);
+ BreakpointEvent bpe = resumeTo("FetchLocalsDebugee", LINE);
/*
* Fetch values from fields; what did we get?
*/
diff --git a/jdk/test/com/sun/jdi/GetLocalVariables.java b/jdk/test/com/sun/jdi/GetLocalVariables.java
index bc21ffde62d..866048f92f0 100644
--- a/jdk/test/com/sun/jdi/GetLocalVariables.java
+++ b/jdk/test/com/sun/jdi/GetLocalVariables.java
@@ -1,14 +1,39 @@
-/** hard coded linenumbers in this test - DO NOT CHANGE
- * @test/nodynamiccopyright/
- * @bug 4359312 4450091
- * @summary Test PTR 1421 JVM exceptions making a call to LocalVariable.type().name()
+/*
+ * Copyright (c) 2007, 2017, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
- * @author Tim Bell (based on the PTR 1421 report submitted by IBM).
+ * 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.
*
- * @run build TestScaffold VMConnection TargetListener TargetAdapter
- * @run compile -g GetLocalVariables.java
- * @run driver GetLocalVariables
+ * 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.
*/
+
+// THIS TEST IS LINE NUMBER SENSITIVE
+
+/**
+ * @test
+ * @bug 4359312 4450091
+ * @summary Test PTR 1421 JVM exceptions making a call to LocalVariable.type().name()
+ * @author Tim Bell (based on the PTR 1421 report submitted by IBM).
+ *
+ * @run build TestScaffold VMConnection TargetListener TargetAdapter
+ * @run compile -g GetLocalVariables.java
+ * @run driver GetLocalVariables
+ */
+
import com.sun.jdi.*;
import com.sun.jdi.event.*;
import com.sun.jdi.request.*;
@@ -194,7 +219,7 @@ class GetLocalVariablesTarg {
l_long, l_float, l_double, l_iarray,
l_marray, l_string);
- e1.test_1(); // <-- this is line 197
+ e1.test_1(); // RESUME_TO_LINE
e3.test_1();
e4.test_1();
e5.test_1();
@@ -231,6 +256,7 @@ class GetLocalVariablesTarg {
/********** test program **********/
public class GetLocalVariables extends TestScaffold {
+ static final int RESUME_TO_LINE = 222;
ReferenceType targetClass;
ThreadReference mainThread;
@@ -257,7 +283,7 @@ public class GetLocalVariables extends TestScaffold {
mainThread = bpe.thread();
EventRequestManager erm = vm().eventRequestManager();
- bpe = resumeTo("GetLocalVariablesTarg", 197);
+ bpe = resumeTo("GetLocalVariablesTarg", RESUME_TO_LINE);
/*
* We've arrived. Look around at some variables.
*/
diff --git a/jdk/test/com/sun/jdi/GetSetLocalTest.java b/jdk/test/com/sun/jdi/GetSetLocalTest.java
index deaa0b4ac80..e4420e94af2 100644
--- a/jdk/test/com/sun/jdi/GetSetLocalTest.java
+++ b/jdk/test/com/sun/jdi/GetSetLocalTest.java
@@ -1,13 +1,37 @@
-/** hard coded linenumbers in other tests - DO NOT CHANGE
- * @test/nodynamiccopyright/
- * @bug 4300412
- * @summary Test GetLocal* and SetLocal* functions
+/*
+ * Copyright (c) 2007, 2017, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
- * @author Serguei Spitsyn
+ * 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.
*
- * @run build TestScaffold VMConnection TargetListener TargetAdapter
- * @run compile -g GetSetLocalTest.java
- * @run driver GetSetLocalTest
+ * 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.
+ */
+
+// THIS TEST IS LINE NUMBER SENSITIVE
+
+/**
+ * @test
+ * @bug 4300412
+ * @summary Test GetLocal* and SetLocal* functions
+ * @author Serguei Spitsyn
+ *
+ * @run build TestScaffold VMConnection TargetListener TargetAdapter
+ * @run compile -g GetSetLocalTest.java
+ * @run driver GetSetLocalTest
*/
import com.sun.jdi.*;
import com.sun.jdi.event.*;
@@ -35,7 +59,7 @@ class GetSetLocalTarg {
int result;
{
{ boolean bool_1 = false;
- intArg++;
+ intArg++; // START_LINE
}
boolean bool_2 = true;
@@ -111,7 +135,7 @@ class GetSetLocalTarg {
}
Object obj_2 = new Object();
- intArg++; // <-- Last stop is at this point.
+ intArg++; // STOP_LINE. Last stop is at this point.
// Only obj_2 and intArg are valid
// Note: even result is not valid here!
}
@@ -125,6 +149,8 @@ class GetSetLocalTarg {
/********** test program **********/
public class GetSetLocalTest extends TestScaffold {
+ static final int START_LINE = 62;
+ static final int STOP_LINE = 138;
ReferenceType targetClass;
ThreadReference mainThread;
@@ -635,7 +661,7 @@ public class GetSetLocalTest extends TestScaffold {
println("EventRequestManager");
StackFrame frame = null;
- for (int line = 38; line < 118; line += 4) {
+ for (int line = START_LINE; line <= STOP_LINE; line += 4) {
println("\n resumeTo(GetSetLocalTarg, " + line + ")");
bpe = resumeTo("GetSetLocalTarg", line);
frame = bpe.thread().frame(0);
diff --git a/jdk/test/com/sun/jdi/LambdaBreakpointTest.java b/jdk/test/com/sun/jdi/LambdaBreakpointTest.java
index 2423b737e47..c0a31bead1b 100644
--- a/jdk/test/com/sun/jdi/LambdaBreakpointTest.java
+++ b/jdk/test/com/sun/jdi/LambdaBreakpointTest.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 2017, 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
@@ -21,19 +21,18 @@
* questions.
*/
-/********** LINE NUMBER SENSITIVE! *****************************************************************/
+// THIS TEST IS LINE NUMBER SENSITIVE
/**
- * @test
- * @summary Test setting breakpoints on lambda calls
+ * @test
+ * @summary Test setting breakpoints on lambda calls
+ * @author Staffan Larsen
*
- * @author Staffan Larsen
- *
- * @modules jdk.jdi
- * @run build TestScaffold VMConnection TargetListener TargetAdapter
- * @run compile -g LambdaBreakpointTest.java
- * @run driver LambdaBreakpointTest
+ * @run build TestScaffold VMConnection TargetListener TargetAdapter
+ * @run compile -g LambdaBreakpointTest.java
+ * @run driver LambdaBreakpointTest
*/
+
import java.util.List;
import com.sun.jdi.LocalVariable;
@@ -50,22 +49,17 @@ import com.sun.jdi.event.StepEvent;
/********** target program **********/
class LambdaBreakpointTestTarg {
-
- static int[] breakpointLines = {
- 63, 67, 64, 65, 66, 68
- };
-
public static void main(String[] args) {
test();
}
private static void test() {
- Runnable r = () -> { // B1: L62
- String from = "lambda"; // B3: L63
- System.out.println("Hello from " + from); // B4: L64
- }; // B5: L65
- r.run(); // B2: L66
- System.out.println("Goodbye."); // B6: L67
+ Runnable r = () -> { // LambdaBreakpointTest::TEST_LINE_1, BKPT_LINES[0]
+ String from = "lambda"; // LambdaBreakpointTest::TEST_LINE_2, BKPT_LINES[2]
+ System.out.println("Hello from " + from); // LambdaBreakpointTest::TEST_LINE_3, BKPT_LINES[3]
+ }; // LambdaBreakpointTest::TEST_LINE_4, BKPT_LINES[4]
+ r.run(); // LambdaBreakpointTest::TEST_LINE_5, BKPT_LINES[1]
+ System.out.println("Goodbye."); // LambdaBreakpointTest::TEST_LINE_6, BKPT_LINES[5]
}
}
@@ -73,6 +67,21 @@ class LambdaBreakpointTestTarg {
/********** test program **********/
public class LambdaBreakpointTest extends TestScaffold {
+ private static final int TEST_LINE_1 = 57;
+ private static final int TEST_LINE_2 = TEST_LINE_1 + 1;
+ private static final int TEST_LINE_3 = TEST_LINE_1 + 2;
+ private static final int TEST_LINE_4 = TEST_LINE_1 + 3;
+ private static final int TEST_LINE_5 = TEST_LINE_1 + 4;
+ private static final int TEST_LINE_6 = TEST_LINE_1 + 5;
+
+ private static final int[] BKPT_LINES = {
+ TEST_LINE_1,
+ TEST_LINE_5,
+ TEST_LINE_2,
+ TEST_LINE_3,
+ TEST_LINE_4,
+ TEST_LINE_6,
+ };
LambdaBreakpointTest (String args[]) {
super(args);
@@ -92,7 +101,7 @@ public class LambdaBreakpointTest extends TestScaffold {
startToMain("LambdaBreakpointTestTarg");
// Put a breakpoint on each location in the order they should happen
- for (int line : LambdaBreakpointTestTarg.breakpointLines) {
+ for (int line : BKPT_LINES) {
System.out.println("Running to line: " + line);
BreakpointEvent be = resumeTo("LambdaBreakpointTestTarg", line);
int stoppedAt = be.location().lineNumber();
diff --git a/jdk/test/com/sun/jdi/LineNumberOnBraceTest.java b/jdk/test/com/sun/jdi/LineNumberOnBraceTest.java
index 49b558c76cd..413ea98270f 100644
--- a/jdk/test/com/sun/jdi/LineNumberOnBraceTest.java
+++ b/jdk/test/com/sun/jdi/LineNumberOnBraceTest.java
@@ -1,13 +1,37 @@
+/*
+ * Copyright (c) 2007, 2017, 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.
+ */
+
+// THIS TEST IS LINE NUMBER SENSITIVE
+
/**
- * @test/nodynamiccopyright/
- * @bug 4952629 4870514
- * @summary REGRESSION: javac generates a spurious line number entry on } else {
+ * @test
+ * @bug 4952629 4870514
+ * @summary REGRESSION: javac generates a spurious line number entry on } else {
+ * @author jjh
*
- * @author jjh
- *
- * @run build VMConnection TargetListener TargetAdapter
- * @run compile -g LineNumberOnBraceTest.java
- * @run driver LineNumberOnBraceTest
+ * @run build VMConnection TargetListener TargetAdapter
+ * @run compile -g LineNumberOnBraceTest.java
+ * @run driver LineNumberOnBraceTest
*/
import com.sun.jdi.*;
import com.sun.jdi.event.*;
@@ -15,29 +39,27 @@ import com.sun.jdi.request.*;
import java.util.*;
- /********** LINE NUMBER SENSITIVE! *****************************************************************/
class LineNumberOnBraceTarg {
- public final static int stopLine = 29; // THIS MUST BE THE LINE NUMBER OF THE // stopline LINE
- public final static int stopLine2 = 35; // THIS MUST BE THE LINE NUMBER OF THE // stopline2 LINE
-
+ public final static int STOP_LINE = 50; // THIS MUST BE THE LINE NUMBER OF // STOP_LINE LINE
+ public final static int STOP_LINE_2 = 56; // THIS MUST BE THE LINE NUMBER OF // STOP_LINE_2 LINE
public static void main(String[] args){
System.out.println("Howdy!");
if (args.length == 0) {
- System.out.println("No args to debuggee"); // stopLine
+ System.out.println("No args to debuggee"); // STOP_LINE
} else {
System.out.println("Some args to debuggee");
}
- if (args.length == 0) {
+ if (args.length == 0) { // STOP_LINE + 4
boolean b1 = false;
- if (b1) { // stopLine2
+ if (b1) { // STOP_LINE_2
System.out.println("In 2nd else"); // bug 4870514 is that we stop here.
}
} else {
System.out.println("In 2nd else");
}
- System.out.println("Goodbye from LineNumberOnBraceTarg!"); // stopLine2 + 6
+ System.out.println("Goodbye from LineNumberOnBraceTarg!");
}
// This isn't part of the test; it is just here
@@ -78,7 +100,7 @@ public class LineNumberOnBraceTest extends TestScaffold {
targetClass = bpe.location().declaringType();
mainThread = bpe.thread();
- resumeTo("LineNumberOnBraceTarg", LineNumberOnBraceTarg.stopLine);
+ resumeTo("LineNumberOnBraceTarg", LineNumberOnBraceTarg.STOP_LINE);
StepEvent stepev = stepOverLine(mainThread); // step to 2nd if (args.length
// Bug 4952629 is that javac outputs a line number
@@ -87,24 +109,23 @@ public class LineNumberOnBraceTest extends TestScaffold {
int ln = stepev.location().lineNumber();
System.out.println("Debuggee is stopped at line " + ln);
- if (ln != LineNumberOnBraceTarg.stopLine + 4) {
+ if (ln != LineNumberOnBraceTarg.STOP_LINE + 4) {
failure("FAIL: Bug 4952629: Should be at line " +
- (LineNumberOnBraceTarg.stopLine + 4) +
+ (LineNumberOnBraceTarg.STOP_LINE + 4) +
", am at " + ln);
} else {
System.out.println("Passed test for 4952629");
}
// Test for bug 4870514
- System.out.println("Resuming to " + LineNumberOnBraceTarg.stopLine2);
- resumeTo("LineNumberOnBraceTarg", LineNumberOnBraceTarg.stopLine2);
- System.out.println("Stopped at " + LineNumberOnBraceTarg.stopLine2);
+ System.out.println("Resuming to " + LineNumberOnBraceTarg.STOP_LINE_2);
+ resumeTo("LineNumberOnBraceTarg", LineNumberOnBraceTarg.STOP_LINE_2);
+ System.out.println("Stopped at " + LineNumberOnBraceTarg.STOP_LINE_2);
stepev = stepOverLine(mainThread);
ln = stepev.location().lineNumber();
System.out.println("Debuggee is stopped at line " + ln);
- if (ln == LineNumberOnBraceTarg.stopLine2 + 1) {
- failure("FAIL: bug 4870514: Incorrectly stopped at " +
- (LineNumberOnBraceTarg.stopLine2 + 1));
+ if (ln <= LineNumberOnBraceTarg.STOP_LINE_2 + 1) {
+ failure("FAIL: bug 4870514: Incorrectly stopped at " + ln);
} else {
System.out.println("Passed test for 4870514");
}
diff --git a/jdk/test/com/sun/jdi/PopAndStepTest.java b/jdk/test/com/sun/jdi/PopAndStepTest.java
index a0150fae110..598a78bf34c 100644
--- a/jdk/test/com/sun/jdi/PopAndStepTest.java
+++ b/jdk/test/com/sun/jdi/PopAndStepTest.java
@@ -1,17 +1,39 @@
-/* /nodynamiccopyright/ */ // DO NOT DELETE ANY LINES!!!!
+/*
+ * Copyright (c) 2007, 2017, 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.
+ */
+
// THIS TEST IS LINE NUMBER SENSITIVE
+
/**
- * @test
- * @bug 4530424
- * @summary Hin says that doing a step over after a popframe acts like a resume.
+ * @test
+ * @bug 4530424
+ * @summary Hin says that doing a step over after a popframe acts like a resume.
+ * @author jjh
*
- * @author jjh
+ * @library ..
*
- * @library ..
- * @modules jdk.jdi
- * @run build TestScaffold VMConnection TargetListener TargetAdapter
- * @run compile -g PopAndStepTest.java
- * @run driver PopAndStepTest
+ * @run build TestScaffold VMConnection TargetListener TargetAdapter
+ * @run compile -g PopAndStepTest.java
+ * @run driver PopAndStepTest
*/
import com.sun.jdi.*;
import com.sun.jdi.event.*;
@@ -19,25 +41,23 @@ import com.sun.jdi.request.*;
import java.util.*;
- /********** LINE NUMBER SENSITIVE! *****************************************************************/
-
class PopAndStepTarg {
public void B() {
- System.out.println("debuggee: in B");
- System.out.println("debuggee: in B, back to A"); // add line breakpoint here line 27 !!!
+ System.out.println("debuggee: in B"); // B_LINE_1
+ System.out.println("debuggee: in B, back to A"); // B_LINE_2
}
public void A() {
- System.out.println("debuggee: in A, about to call B"); // line 31
- B();
- System.out.println("debuggee: in A, back from B"); // line 33
- throw new RuntimeException("debuggee: Got to line 34");
+ System.out.println("debuggee: in A, about to call B"); // A_LINE_1
+ B(); // A_LINE_2
+ System.out.println("debuggee: in A, back from B"); // A_LINE_3
+ throw new RuntimeException("debuggee: Got to line A_LINE_4:" + PopAndStepTest.A_LINE_4); // A_LINE_4
}
public static void main(String[] args) {
- System.out.println("debuggee: Howdy!"); // line 38
- PopAndStepTarg xxx = new PopAndStepTarg(); // line 40
- xxx.A(); // line 41
+ System.out.println("debuggee: Howdy!"); // MAIN_LINE_1
+ PopAndStepTarg xxx = new PopAndStepTarg(); // MAIN_LINE_2
+ xxx.A(); // MAIN_LINE_3
System.out.println("debugee: Goodbye from PopAndStepTarg!");
}
}
@@ -46,6 +66,18 @@ class PopAndStepTarg {
/********** test program **********/
public class PopAndStepTest extends TestScaffold {
+ static final int B_LINE_1 = 46;
+ static final int B_LINE_2 = B_LINE_1 + 1;
+
+ static final int A_LINE_1 = 51;
+ static final int A_LINE_2 = A_LINE_1 + 1;
+ static final int A_LINE_3 = A_LINE_1 + 2;
+ static final int A_LINE_4 = A_LINE_1 + 3;
+
+ static final int MAIN_LINE_1 = 58;
+ static final int MAIN_LINE_2 = MAIN_LINE_1 + 1;
+ static final int MAIN_LINE_3 = MAIN_LINE_1 + 2;
+
ReferenceType targetClass;
ThreadReference mainThread;
@@ -116,10 +148,10 @@ public class PopAndStepTest extends TestScaffold {
BreakpointEvent bpe = startToMain("PopAndStepTarg");
targetClass = bpe.location().declaringType();
mainThread = bpe.thread();
- getDebuggeeLineNum(38);
+ getDebuggeeLineNum(MAIN_LINE_1);
- println("Resuming to line 27");
- bpe = resumeTo("PopAndStepTarg", 27); getDebuggeeLineNum(27);
+ println("Resuming to line B_LINE_2 : " + B_LINE_2);
+ bpe = resumeTo("PopAndStepTarg", B_LINE_2); getDebuggeeLineNum(B_LINE_2);
// The failure is this:
// create step request
@@ -141,21 +173,21 @@ public class PopAndStepTest extends TestScaffold {
srInto.enable(); // This fails
mainThread.popFrames(frameFor("A"));
//srInto.enable(); // if the enable is moved here, it passes
- println("Popped back to line 41 in main, the call to A()");
- println("Stepping into line 31");
- waitForRequestedEvent(srInto); // println
+ println("Popped back to line MAIN_LINE_3(" + MAIN_LINE_3 + ") in main, the call to A()");
+ println("Stepping into line A_LINE_1:" + A_LINE_1);
+ waitForRequestedEvent(srInto); // println
srInto.disable();
- getDebuggeeLineNum(31);
+ getDebuggeeLineNum(A_LINE_1);
// The failure occurs here.
- println("Stepping over to line 32");
- stepOverLine(mainThread); // println
- getDebuggeeLineNum(32);
+ println("Stepping over to line A_LINE_2:" + A_LINE_2);
+ stepOverLine(mainThread); // println
+ getDebuggeeLineNum(A_LINE_2);
- println("Stepping over to line 33");
- stepOverLine(mainThread); // call to B()
- getDebuggeeLineNum(33);
+ println("Stepping over to line A_LINE_3:" + A_LINE_3);
+ stepOverLine(mainThread); // call to B()
+ getDebuggeeLineNum(A_LINE_3);
vm().exit(0);
diff --git a/jdk/test/java/awt/TrayIcon/SystemTrayIconHelper.java b/jdk/test/java/awt/TrayIcon/SystemTrayIconHelper.java
index 1fcf2813950..e8529a3b396 100644
--- a/jdk/test/java/awt/TrayIcon/SystemTrayIconHelper.java
+++ b/jdk/test/java/awt/TrayIcon/SystemTrayIconHelper.java
@@ -81,7 +81,7 @@ public class SystemTrayIconHelper {
try {
// sun.lwawt.macosx.CTrayIcon
Field f_peer = getField( java.awt.TrayIcon.class, "peer");
- Method m_addExports = Class.forName("java.awt.Helper").getDeclaredMethod("addExports", String.class, java.lang.reflect.Module.class);
+ Method m_addExports = Class.forName("java.awt.Helper").getDeclaredMethod("addExports", String.class, java.lang.Module.class);
m_addExports.invoke(null, "sun.lwawt.macosx", robot.getClass().getModule());
@@ -105,7 +105,7 @@ public class SystemTrayIconHelper {
} else {
try {
// sun.awt.X11.XTrayIconPeer
- Method m_addExports = Class.forName("java.awt.Helper").getDeclaredMethod("addExports", String.class, java.lang.reflect.Module.class);
+ Method m_addExports = Class.forName("java.awt.Helper").getDeclaredMethod("addExports", String.class, java.lang.Module.class);
m_addExports.invoke(null, "sun.awt.X11", robot.getClass().getModule());
Field f_peer = getField(java.awt.TrayIcon.class, "peer");
diff --git a/jdk/test/java/awt/patchlib/java.desktop/java/awt/Helper.java b/jdk/test/java/awt/patchlib/java.desktop/java/awt/Helper.java
index 6d8dbc4b227..d599833cb70 100644
--- a/jdk/test/java/awt/patchlib/java.desktop/java/awt/Helper.java
+++ b/jdk/test/java/awt/patchlib/java.desktop/java/awt/Helper.java
@@ -22,7 +22,6 @@
*/
package java.awt;
-import java.lang.reflect.Module;
public class Helper {
private Helper() { }
public static void addExports(String pn, Module target) {
diff --git a/jdk/test/java/awt/regtesthelpers/Util.java b/jdk/test/java/awt/regtesthelpers/Util.java
index 62feee23489..dde65574460 100644
--- a/jdk/test/java/awt/regtesthelpers/Util.java
+++ b/jdk/test/java/awt/regtesthelpers/Util.java
@@ -445,7 +445,7 @@ public final class Util {
try {
final Class _clazz = clazz;
- Method m_addExports = Class.forName("java.awt.Helper").getDeclaredMethod("addExports", String.class, java.lang.reflect.Module.class);
+ Method m_addExports = Class.forName("java.awt.Helper").getDeclaredMethod("addExports", String.class, java.lang.Module.class);
// No MToolkit anymore: nothing to do about it.
// We may be called from non-X11 system, and this permission cannot be delegated to a test.
m_addExports.invoke(null, "sun.awt.X11", Util.class.getModule());
diff --git a/jdk/test/java/lang/Class/GetModuleTest.java b/jdk/test/java/lang/Class/GetModuleTest.java
index f0d7477c074..4059a216c02 100644
--- a/jdk/test/java/lang/Class/GetModuleTest.java
+++ b/jdk/test/java/lang/Class/GetModuleTest.java
@@ -31,7 +31,6 @@
*/
import java.awt.Component;
-import java.lang.reflect.Module;
import jdk.internal.org.objectweb.asm.ClassWriter;
import static jdk.internal.org.objectweb.asm.Opcodes.*;
diff --git a/jdk/test/java/lang/Class/forName/modules/TestLayer.java b/jdk/test/java/lang/Class/forName/modules/TestLayer.java
index ff9a772ceeb..45460d19d32 100644
--- a/jdk/test/java/lang/Class/forName/modules/TestLayer.java
+++ b/jdk/test/java/lang/Class/forName/modules/TestLayer.java
@@ -23,9 +23,7 @@
import java.lang.module.Configuration;
import java.lang.module.ModuleFinder;
-import java.lang.reflect.Layer;
import java.lang.reflect.Method;
-import java.lang.reflect.Module;
import java.net.URL;
import java.net.URLClassLoader;
import java.nio.file.Path;
@@ -45,13 +43,13 @@ public class TestLayer {
ModuleFinder finder = ModuleFinder.of(MODS_DIR);
- Configuration parent = Layer.boot().configuration();
+ Configuration parent = ModuleLayer.boot().configuration();
Configuration cf = parent.resolveAndBind(ModuleFinder.of(),
finder,
modules);
ClassLoader scl = ClassLoader.getSystemClassLoader();
- Layer layer = Layer.boot().defineModulesWithManyLoaders(cf, scl);
+ ModuleLayer layer = ModuleLayer.boot().defineModulesWithManyLoaders(cf, scl);
Module m1 = layer.findModule("m1").get();
Module m2 = layer.findModule("m2").get();
diff --git a/jdk/test/java/lang/Class/forName/modules/TestMain.java b/jdk/test/java/lang/Class/forName/modules/TestMain.java
index 0da5136622c..aa821a1d08d 100644
--- a/jdk/test/java/lang/Class/forName/modules/TestMain.java
+++ b/jdk/test/java/lang/Class/forName/modules/TestMain.java
@@ -21,13 +21,11 @@
* questions.
*/
-import java.lang.reflect.Layer;
import java.lang.reflect.Method;
-import java.lang.reflect.Module;
public class TestMain {
public static void main(String[] args) throws Exception {
- Layer boot = Layer.boot();
+ ModuleLayer boot = ModuleLayer.boot();
Module m1 = boot.findModule("m1").get();
Module m2 = boot.findModule("m2").get();
diff --git a/jdk/test/java/lang/Class/forName/modules/src/m2/p2/test/Main.java b/jdk/test/java/lang/Class/forName/modules/src/m2/p2/test/Main.java
index 56cec626fa0..8febc9515a9 100644
--- a/jdk/test/java/lang/Class/forName/modules/src/m2/p2/test/Main.java
+++ b/jdk/test/java/lang/Class/forName/modules/src/m2/p2/test/Main.java
@@ -23,12 +23,9 @@
package p2.test;
-import java.lang.reflect.Layer;
-import java.lang.reflect.Module;
-
public class Main {
public static void main(String... args) throws Exception {
- Layer boot = Layer.boot();
+ ModuleLayer boot = ModuleLayer.boot();
Module m1 = boot.findModule("m1").get();
Module m2 = Main.class.getModule();
diff --git a/jdk/test/java/lang/Class/forName/modules/src/m3/p3/NoAccess.java b/jdk/test/java/lang/Class/forName/modules/src/m3/p3/NoAccess.java
index 25e8779ab48..92002a613e1 100644
--- a/jdk/test/java/lang/Class/forName/modules/src/m3/p3/NoAccess.java
+++ b/jdk/test/java/lang/Class/forName/modules/src/m3/p3/NoAccess.java
@@ -26,8 +26,6 @@ package p3;
import java.io.FilePermission;
import java.lang.module.Configuration;
import java.lang.module.ModuleFinder;
-import java.lang.reflect.Layer;
-import java.lang.reflect.Module;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.security.AccessControlException;
@@ -47,7 +45,7 @@ public class NoAccess {
ModuleFinder finder = ModuleFinder.of(Paths.get("mods1"), Paths.get("mods2"));
- Layer bootLayer = Layer.boot();
+ ModuleLayer bootLayer = ModuleLayer.boot();
Configuration parent = bootLayer.configuration();
Configuration cf = parent.resolveAndBind(finder,
@@ -55,7 +53,7 @@ public class NoAccess {
Set.of("m1", "m2"));
ClassLoader scl = ClassLoader.getSystemClassLoader();
- Layer layer = bootLayer.defineModulesWithManyLoaders(cf, scl);
+ ModuleLayer layer = bootLayer.defineModulesWithManyLoaders(cf, scl);
if (sm != null) {
System.setSecurityManager(sm);
diff --git a/jdk/test/java/lang/Class/forName/modules/src/m3/p3/NoGetClassLoaderAccess.java b/jdk/test/java/lang/Class/forName/modules/src/m3/p3/NoGetClassLoaderAccess.java
index 1c2ee70fcbc..aeed218ee5d 100644
--- a/jdk/test/java/lang/Class/forName/modules/src/m3/p3/NoGetClassLoaderAccess.java
+++ b/jdk/test/java/lang/Class/forName/modules/src/m3/p3/NoGetClassLoaderAccess.java
@@ -23,8 +23,6 @@
package p3;
-import java.lang.reflect.Layer;
-import java.lang.reflect.Module;
import java.security.AccessControlException;
import java.security.Permission;
@@ -37,7 +35,7 @@ public class NoGetClassLoaderAccess {
private static final Permission GET_CLASSLOADER_PERMISSION = new RuntimePermission("getClassLoader");
public static void main(String[] args) throws Exception {
- Layer boot = Layer.boot();
+ ModuleLayer boot = ModuleLayer.boot();
System.setSecurityManager(new SecurityManager());
Module m1 = boot.findModule("m1").get();
diff --git a/jdk/test/java/lang/Class/getDeclaredField/FieldSetAccessibleTest.java b/jdk/test/java/lang/Class/getDeclaredField/FieldSetAccessibleTest.java
index 5ea706de1ee..35e6ede16db 100644
--- a/jdk/test/java/lang/Class/getDeclaredField/FieldSetAccessibleTest.java
+++ b/jdk/test/java/lang/Class/getDeclaredField/FieldSetAccessibleTest.java
@@ -26,10 +26,8 @@ import java.io.IOException;
import java.io.UncheckedIOException;
import java.lang.reflect.AccessibleObject;
import java.lang.reflect.Field;
-import java.lang.reflect.Module;
import java.lang.reflect.Modifier;
import java.lang.reflect.InaccessibleObjectException;
-import java.lang.reflect.Layer;
import java.lang.reflect.ReflectPermission;
import java.net.URI;
import java.nio.file.FileSystem;
@@ -269,7 +267,7 @@ public class FieldSetAccessibleTest {
try {
return Files.walk(root)
.filter(p -> p.getNameCount() > 2)
- .filter(p -> Layer.boot().findModule(p.getName(1).toString()).isPresent())
+ .filter(p -> ModuleLayer.boot().findModule(p.getName(1).toString()).isPresent())
.map(p -> p.subpath(2, p.getNameCount()))
.map(p -> p.toString())
.filter(s -> s.endsWith(".class") && !s.endsWith("module-info.class"))
diff --git a/jdk/test/java/lang/Class/getResource/Main.java b/jdk/test/java/lang/Class/getResource/Main.java
index 96d4e68ac15..efd50262be2 100644
--- a/jdk/test/java/lang/Class/getResource/Main.java
+++ b/jdk/test/java/lang/Class/getResource/Main.java
@@ -23,7 +23,6 @@
import java.lang.module.Configuration;
import java.lang.module.ResolvedModule;
-import java.lang.reflect.Layer;
import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
@@ -256,7 +255,7 @@ public class Main {
* Returns the directory for the given module (by name).
*/
static Path directoryFor(String name) {
- Configuration cf = Layer.boot().configuration();
+ Configuration cf = ModuleLayer.boot().configuration();
ResolvedModule resolvedModule = cf.findModule(name).orElse(null);
if (resolvedModule == null)
throw new RuntimeException("not found: " + name);
diff --git a/jdk/test/java/lang/ClassLoader/getResource/automaticmodules/Main.java b/jdk/test/java/lang/ClassLoader/getResource/automaticmodules/Main.java
index afde3d56bf5..8141e9977bc 100644
--- a/jdk/test/java/lang/ClassLoader/getResource/automaticmodules/Main.java
+++ b/jdk/test/java/lang/ClassLoader/getResource/automaticmodules/Main.java
@@ -26,7 +26,6 @@ import java.io.InputStream;
import java.lang.module.ModuleReader;
import java.lang.module.ModuleReference;
import java.lang.module.ResolvedModule;
-import java.lang.reflect.Layer;
import java.net.URL;
import java.util.Enumeration;
@@ -74,7 +73,7 @@ public class Main {
public static void main(String[] args) throws Exception {
String mn = args[0];
- ModuleReference mref = Layer.boot()
+ ModuleReference mref = ModuleLayer.boot()
.configuration()
.findModule(mn)
.map(ResolvedModule::reference)
diff --git a/jdk/test/java/lang/ClassLoader/getResource/modules/Main.java b/jdk/test/java/lang/ClassLoader/getResource/modules/Main.java
index e816f31fc8b..405132067db 100644
--- a/jdk/test/java/lang/ClassLoader/getResource/modules/Main.java
+++ b/jdk/test/java/lang/ClassLoader/getResource/modules/Main.java
@@ -24,7 +24,6 @@
import java.io.InputStream;
import java.lang.module.Configuration;
import java.lang.module.ResolvedModule;
-import java.lang.reflect.Layer;
import java.io.IOException;
import java.net.URL;
import java.nio.file.Files;
@@ -309,7 +308,7 @@ public class Main {
* Returns the directory for the given module (by name).
*/
static Path directoryFor(String mn) {
- Configuration cf = Layer.boot().configuration();
+ Configuration cf = ModuleLayer.boot().configuration();
ResolvedModule resolvedModule = cf.findModule(mn).orElse(null);
if (resolvedModule == null)
throw new RuntimeException("not found: " + mn);
diff --git a/jdk/test/java/lang/reflect/Layer/BasicLayerTest.java b/jdk/test/java/lang/ModuleLayer/BasicLayerTest.java
similarity index 85%
rename from jdk/test/java/lang/reflect/Layer/BasicLayerTest.java
rename to jdk/test/java/lang/ModuleLayer/BasicLayerTest.java
index 9478cac7861..eb5eeb8a256 100644
--- a/jdk/test/java/lang/reflect/Layer/BasicLayerTest.java
+++ b/jdk/test/java/lang/ModuleLayer/BasicLayerTest.java
@@ -28,16 +28,13 @@
* @build BasicLayerTest ModuleUtils
* @compile layertest/Test.java
* @run testng BasicLayerTest
- * @summary Basic tests for java.lang.reflect.Layer
+ * @summary Basic tests for java.lang.ModuleLayer
*/
import java.lang.module.Configuration;
import java.lang.module.ModuleDescriptor;
import java.lang.module.ModuleDescriptor.Requires;
import java.lang.module.ModuleFinder;
-import java.lang.reflect.Layer;
-import java.lang.reflect.LayerInstantiationException;
-import java.lang.reflect.Module;
import java.util.HashMap;
import java.util.Map;
import java.util.Optional;
@@ -63,10 +60,10 @@ public class BasicLayerTest {
}
/**
- * Exercise Layer.empty()
+ * Exercise ModuleLayer.empty()
*/
public void testEmpty() {
- Layer emptyLayer = Layer.empty();
+ ModuleLayer emptyLayer = ModuleLayer.empty();
assertTrue(emptyLayer.parents().isEmpty());
@@ -84,10 +81,10 @@ public class BasicLayerTest {
/**
- * Exercise Layer.boot()
+ * Exercise ModuleLayer.boot()
*/
public void testBoot() {
- Layer bootLayer = Layer.boot();
+ ModuleLayer bootLayer = ModuleLayer.boot();
// configuration
Configuration cf = bootLayer.configuration();
@@ -114,12 +111,12 @@ public class BasicLayerTest {
// parents
assertTrue(bootLayer.parents().size() == 1);
- assertTrue(bootLayer.parents().get(0) == Layer.empty());
+ assertTrue(bootLayer.parents().get(0) == ModuleLayer.empty());
}
/**
- * Exercise Layer defineModules, created with empty layer as parent
+ * Exercise defineModules, created with empty layer as parent
*/
public void testLayerOnEmpty() {
ModuleDescriptor descriptor1 = newBuilder("m1")
@@ -148,7 +145,7 @@ public class BasicLayerTest {
map.put("m2", loader2);
map.put("m3", loader3);
- Layer layer = Layer.empty().defineModules(cf, map::get);
+ ModuleLayer layer = ModuleLayer.empty().defineModules(cf, map::get);
// configuration
assertTrue(layer.configuration() == cf);
@@ -193,12 +190,12 @@ public class BasicLayerTest {
// parents
assertTrue(layer.parents().size() == 1);
- assertTrue(layer.parents().get(0) == Layer.empty());
+ assertTrue(layer.parents().get(0) == ModuleLayer.empty());
}
/**
- * Exercise Layer defineModules, created with boot layer as parent
+ * Exercise defineModules, created with boot layer as parent
*/
public void testLayerOnBoot() {
ModuleDescriptor descriptor1 = newBuilder("m1")
@@ -214,12 +211,12 @@ public class BasicLayerTest {
ModuleFinder finder
= ModuleUtils.finderOf(descriptor1, descriptor2);
- Configuration parent = Layer.boot().configuration();
+ Configuration parent = ModuleLayer.boot().configuration();
Configuration cf = resolve(parent, finder, "m1");
ClassLoader loader = new ClassLoader() { };
- Layer layer = Layer.boot().defineModules(cf, mn -> loader);
+ ModuleLayer layer = ModuleLayer.boot().defineModules(cf, mn -> loader);
// configuration
assertTrue(layer.configuration() == cf);
@@ -255,12 +252,12 @@ public class BasicLayerTest {
// parents
assertTrue(layer.parents().size() == 1);
- assertTrue(layer.parents().get(0) == Layer.boot());
+ assertTrue(layer.parents().get(0) == ModuleLayer.boot());
}
/**
- * Exercise Layer defineModules with a configuration of two modules that
+ * Exercise defineModules with a configuration of two modules that
* have the same module-private package.
*/
public void testPackageContainedInSelfAndOther() {
@@ -280,19 +277,19 @@ public class BasicLayerTest {
assertTrue(cf.modules().size() == 2);
// one loader per module, should be okay
- Layer.empty().defineModules(cf, mn -> new ClassLoader() { });
+ ModuleLayer.empty().defineModules(cf, mn -> new ClassLoader() { });
// same class loader
try {
ClassLoader loader = new ClassLoader() { };
- Layer.empty().defineModules(cf, mn -> loader);
+ ModuleLayer.empty().defineModules(cf, mn -> loader);
assertTrue(false);
} catch (LayerInstantiationException expected) { }
}
/**
- * Exercise Layer defineModules with a configuration that is a partitioned
+ * Exercise defineModules with a configuration that is a partitioned
* graph. The same package is exported in both partitions.
*/
public void testSameExportInPartitionedGraph() {
@@ -323,7 +320,7 @@ public class BasicLayerTest {
assertTrue(cf.modules().size() == 4);
// one loader per module
- Layer.empty().defineModules(cf, mn -> new ClassLoader() { });
+ ModuleLayer.empty().defineModules(cf, mn -> new ClassLoader() { });
// m1 & m2 in one loader, m3 & m4 in another loader
ClassLoader loader1 = new ClassLoader() { };
@@ -333,19 +330,19 @@ public class BasicLayerTest {
map.put("m2", loader1);
map.put("m3", loader2);
map.put("m4", loader2);
- Layer.empty().defineModules(cf, map::get);
+ ModuleLayer.empty().defineModules(cf, map::get);
// same loader
try {
ClassLoader loader = new ClassLoader() { };
- Layer.empty().defineModules(cf, mn -> loader);
+ ModuleLayer.empty().defineModules(cf, mn -> loader);
assertTrue(false);
} catch (LayerInstantiationException expected) { }
}
/**
- * Exercise Layer defineModules with a configuration with a module that
+ * Exercise defineModules with a configuration with a module that
* contains a package that is the same name as a non-exported package in
* a parent layer.
*/
@@ -362,12 +359,12 @@ public class BasicLayerTest {
ModuleFinder finder = ModuleUtils.finderOf(descriptor);
- Configuration parent = Layer.boot().configuration();
+ Configuration parent = ModuleLayer.boot().configuration();
Configuration cf = parent.resolve(finder, ModuleFinder.of(), Set.of("m1"));
assertTrue(cf.modules().size() == 1);
ClassLoader loader = new ClassLoader() { };
- Layer layer = Layer.boot().defineModules(cf, mn -> loader);
+ ModuleLayer layer = ModuleLayer.boot().defineModules(cf, mn -> loader);
assertTrue(layer.modules().size() == 1);
}
@@ -395,7 +392,7 @@ public class BasicLayerTest {
Configuration cf1 = resolve(finder1, "m2");
ClassLoader cl1 = new ClassLoader() { };
- Layer layer1 = Layer.empty().defineModules(cf1, mn -> cl1);
+ ModuleLayer layer1 = ModuleLayer.empty().defineModules(cf1, mn -> cl1);
// cf2: m3, m3 requires m2
@@ -409,10 +406,10 @@ public class BasicLayerTest {
Configuration cf2 = resolve(cf1, finder2, "m3");
ClassLoader cl2 = new ClassLoader() { };
- Layer layer2 = layer1.defineModules(cf2, mn -> cl2);
+ ModuleLayer layer2 = layer1.defineModules(cf2, mn -> cl2);
assertTrue(layer1.parents().size() == 1);
- assertTrue(layer1.parents().get(0) == Layer.empty());
+ assertTrue(layer1.parents().get(0) == ModuleLayer.empty());
assertTrue(layer2.parents().size() == 1);
assertTrue(layer2.parents().get(0) == layer1);
@@ -461,7 +458,7 @@ public class BasicLayerTest {
Configuration cf1 = resolve(finder1, "m1");
ClassLoader cl1 = new ClassLoader() { };
- Layer layer1 = Layer.empty().defineModules(cf1, mn -> cl1);
+ ModuleLayer layer1 = ModuleLayer.empty().defineModules(cf1, mn -> cl1);
// cf2: m2, m3: m2 requires transitive m1, m3 requires m2
@@ -479,10 +476,10 @@ public class BasicLayerTest {
Configuration cf2 = resolve(cf1, finder2, "m3");
ClassLoader cl2 = new ClassLoader() { };
- Layer layer2 = layer1.defineModules(cf2, mn -> cl2);
+ ModuleLayer layer2 = layer1.defineModules(cf2, mn -> cl2);
assertTrue(layer1.parents().size() == 1);
- assertTrue(layer1.parents().get(0) == Layer.empty());
+ assertTrue(layer1.parents().get(0) == ModuleLayer.empty());
assertTrue(layer2.parents().size() == 1);
assertTrue(layer2.parents().get(0) == layer1);
@@ -528,7 +525,7 @@ public class BasicLayerTest {
Configuration cf1 = resolve(finder1, "m1");
ClassLoader cl1 = new ClassLoader() { };
- Layer layer1 = Layer.empty().defineModules(cf1, mn -> cl1);
+ ModuleLayer layer1 = ModuleLayer.empty().defineModules(cf1, mn -> cl1);
// cf2: m2 requires transitive m1
@@ -542,7 +539,7 @@ public class BasicLayerTest {
Configuration cf2 = resolve(cf1, finder2, "m2");
ClassLoader cl2 = new ClassLoader() { };
- Layer layer2 = layer1.defineModules(cf2, mn -> cl2);
+ ModuleLayer layer2 = layer1.defineModules(cf2, mn -> cl2);
// cf3: m3 requires m2
@@ -556,10 +553,10 @@ public class BasicLayerTest {
Configuration cf3 = resolve(cf2, finder3, "m3");
ClassLoader cl3 = new ClassLoader() { };
- Layer layer3 = layer2.defineModules(cf3, mn -> cl3);
+ ModuleLayer layer3 = layer2.defineModules(cf3, mn -> cl3);
assertTrue(layer1.parents().size() == 1);
- assertTrue(layer1.parents().get(0) == Layer.empty());
+ assertTrue(layer1.parents().get(0) == ModuleLayer.empty());
assertTrue(layer2.parents().size() == 1);
assertTrue(layer2.parents().get(0) == layer1);
@@ -612,7 +609,7 @@ public class BasicLayerTest {
Configuration cf1 = resolve(finder1, "m2");
ClassLoader cl1 = new ClassLoader() { };
- Layer layer1 = Layer.empty().defineModules(cf1, mn -> cl1);
+ ModuleLayer layer1 = ModuleLayer.empty().defineModules(cf1, mn -> cl1);
// cf2: m3 requires transitive m2, m4 requires m3
@@ -631,10 +628,10 @@ public class BasicLayerTest {
Configuration cf2 = resolve(cf1, finder2, "m3", "m4");
ClassLoader cl2 = new ClassLoader() { };
- Layer layer2 = layer1.defineModules(cf2, mn -> cl2);
+ ModuleLayer layer2 = layer1.defineModules(cf2, mn -> cl2);
assertTrue(layer1.parents().size() == 1);
- assertTrue(layer1.parents().get(0) == Layer.empty());
+ assertTrue(layer1.parents().get(0) == ModuleLayer.empty());
assertTrue(layer2.parents().size() == 1);
assertTrue(layer2.parents().get(0) == layer1);
@@ -691,7 +688,7 @@ public class BasicLayerTest {
Configuration cf = resolve(finder1, "m1", "m2");
ClassLoader cl = new ClassLoader() { };
- Layer layer = Layer.empty().defineModules(cf, mn -> cl);
+ ModuleLayer layer = ModuleLayer.empty().defineModules(cf, mn -> cl);
assertTrue(layer.modules().size() == 2);
Module m1 = layer.findModule("m1").get();
@@ -724,7 +721,7 @@ public class BasicLayerTest {
Configuration cf = resolve(finder1, "m2");
ClassLoader cl = new ClassLoader() { };
- Layer layer = Layer.empty().defineModules(cf, mn -> cl);
+ ModuleLayer layer = ModuleLayer.empty().defineModules(cf, mn -> cl);
assertTrue(layer.modules().size() == 2);
Module m1 = layer.findModule("m1").get();
@@ -750,7 +747,7 @@ public class BasicLayerTest {
ModuleFinder finder1 = ModuleUtils.finderOf(descriptor1);
Configuration cf1 = resolve(finder1, "m1");
ClassLoader cl1 = new ClassLoader() { };
- Layer layer1 = Layer.empty().defineModules(cf1, mn -> cl1);
+ ModuleLayer layer1 = ModuleLayer.empty().defineModules(cf1, mn -> cl1);
assertTrue(layer1.modules().size() == 1);
// create layer2 with m2
@@ -760,7 +757,7 @@ public class BasicLayerTest {
ModuleFinder finder2 = ModuleUtils.finderOf(descriptor2);
Configuration cf2 = resolve(cf1, finder2, "m2");
ClassLoader cl2 = new ClassLoader() { };
- Layer layer2 = layer1.defineModules(cf2, mn -> cl2);
+ ModuleLayer layer2 = layer1.defineModules(cf2, mn -> cl2);
assertTrue(layer2.modules().size() == 1);
Module m1 = layer1.findModule("m1").get();
@@ -786,7 +783,7 @@ public class BasicLayerTest {
ModuleFinder finder1 = ModuleUtils.finderOf(descriptor1);
Configuration cf1 = resolve(finder1, "m1");
ClassLoader cl1 = new ClassLoader() { };
- Layer layer1 = Layer.empty().defineModules(cf1, mn -> cl1);
+ ModuleLayer layer1 = ModuleLayer.empty().defineModules(cf1, mn -> cl1);
assertTrue(layer1.modules().size() == 1);
// create layer2 with m2
@@ -797,7 +794,7 @@ public class BasicLayerTest {
ModuleFinder finder2 = ModuleUtils.finderOf(descriptor2);
Configuration cf2 = resolve(cf1, finder2, "m2");
ClassLoader cl2 = new ClassLoader() { };
- Layer layer2 = layer1.defineModules(cf2, mn -> cl2);
+ ModuleLayer layer2 = layer1.defineModules(cf2, mn -> cl2);
assertTrue(layer2.modules().size() == 1);
Module m1 = layer1.findModule("m1").get();
@@ -822,7 +819,7 @@ public class BasicLayerTest {
ModuleFinder finder1 = ModuleUtils.finderOf(descriptor1);
Configuration cf1 = resolve(finder1, "m1");
ClassLoader cl1 = new ClassLoader() { };
- Layer layer1 = Layer.empty().defineModules(cf1, mn -> cl1);
+ ModuleLayer layer1 = ModuleLayer.empty().defineModules(cf1, mn -> cl1);
assertTrue(layer1.modules().size() == 1);
// create layer2 with m1 and m2
@@ -830,7 +827,7 @@ public class BasicLayerTest {
ModuleFinder finder2 = ModuleUtils.finderOf(descriptor1, descriptor2);
Configuration cf2 = resolve(cf1, finder2, "m1", "m2");
ClassLoader cl2 = new ClassLoader() { };
- Layer layer2 = layer1.defineModules(cf2, mn -> cl2);
+ ModuleLayer layer2 = layer1.defineModules(cf2, mn -> cl2);
assertTrue(layer2.modules().size() == 2);
Module m1_v1 = layer1.findModule("m1").get();
@@ -860,7 +857,7 @@ public class BasicLayerTest {
ModuleFinder finder1 = ModuleUtils.finderOf(descriptor1, descriptor2);
Configuration cf1 = resolve(finder1, "m2");
ClassLoader loader1 = new ClassLoader() { };
- Layer layer1 = Layer.empty().defineModules(cf1, mn -> loader1);
+ ModuleLayer layer1 = ModuleLayer.empty().defineModules(cf1, mn -> loader1);
assertTrue(layer1.modules().size() == 2);
// create layer2 with m1 and m3
@@ -871,7 +868,7 @@ public class BasicLayerTest {
ModuleFinder finder2 = ModuleUtils.finderOf(descriptor1, descriptor3);
Configuration cf2 = resolve(cf1, finder2, "m1", "m3");
ClassLoader loader2 = new ClassLoader() { };
- Layer layer2 = layer1.defineModules(cf2, mn -> loader2);
+ ModuleLayer layer2 = layer1.defineModules(cf2, mn -> loader2);
assertTrue(layer2.modules().size() == 2);
Module m1_v1 = layer1.findModule("m1").get();
@@ -902,7 +899,7 @@ public class BasicLayerTest {
ModuleFinder finder1 = ModuleUtils.finderOf(descriptor1);
Configuration cf1 = resolve(finder1, "m1");
ClassLoader cl1 = new ClassLoader() { };
- Layer layer1 = Layer.empty().defineModules(cf1, mn -> cl1);
+ ModuleLayer layer1 = ModuleLayer.empty().defineModules(cf1, mn -> cl1);
assertTrue(layer1.modules().size() == 1);
// create layer2 with m2
@@ -912,7 +909,7 @@ public class BasicLayerTest {
ModuleFinder finder2 = ModuleUtils.finderOf(descriptor2);
Configuration cf2 = resolve(cf1, finder2, "m2");
ClassLoader cl2 = new ClassLoader() { };
- Layer layer2 = layer1.defineModules(cf2, mn -> cl2);
+ ModuleLayer layer2 = layer1.defineModules(cf2, mn -> cl2);
assertTrue(layer2.modules().size() == 1);
Module m1 = layer1.findModule("m1").get();
@@ -924,9 +921,9 @@ public class BasicLayerTest {
}
/**
- * Attempt to use Layer defineModules to create a layer with a module
- * defined to a class loader that already has a module of the same name
- * defined to the class loader.
+ * Attempt to use defineModules to create a layer with a module defined
+ * to a class loader that already has a module of the same name defined
+ * to the class loader.
*/
@Test(expectedExceptions = { LayerInstantiationException.class })
public void testModuleAlreadyDefinedToLoader() {
@@ -937,24 +934,24 @@ public class BasicLayerTest {
ModuleFinder finder = ModuleUtils.finderOf(md);
- Configuration parent = Layer.boot().configuration();
+ Configuration parent = ModuleLayer.boot().configuration();
Configuration cf = parent.resolve(finder, ModuleFinder.of(), Set.of("m"));
ClassLoader loader = new ClassLoader() { };
- Layer.boot().defineModules(cf, mn -> loader);
+ ModuleLayer.boot().defineModules(cf, mn -> loader);
// should throw LayerInstantiationException as m1 already defined to loader
- Layer.boot().defineModules(cf, mn -> loader);
+ ModuleLayer.boot().defineModules(cf, mn -> loader);
}
/**
- * Attempt to use Layer defineModules to create a Layer with a module
- * containing package {@code p} where the class loader already has a module
- * defined to it containing package {@code p}.
+ * Attempt to use defineModules to create a layer with a module containing
+ * package {@code p} where the class loader already has a module defined
+ * to it containing package {@code p}.
*/
@Test(expectedExceptions = { LayerInstantiationException.class })
public void testPackageAlreadyInNamedModule() {
@@ -975,24 +972,24 @@ public class BasicLayerTest {
// define m1 containing package p to class loader
- Configuration parent = Layer.boot().configuration();
+ Configuration parent = ModuleLayer.boot().configuration();
Configuration cf1 = parent.resolve(finder, ModuleFinder.of(), Set.of("m1"));
- Layer layer1 = Layer.boot().defineModules(cf1, mn -> loader);
+ ModuleLayer layer1 = ModuleLayer.boot().defineModules(cf1, mn -> loader);
// attempt to define m2 containing package p to class loader
Configuration cf2 = parent.resolve(finder, ModuleFinder.of(), Set.of("m2"));
// should throw exception because p already in m1
- Layer layer2 = Layer.boot().defineModules(cf2, mn -> loader);
+ ModuleLayer layer2 = ModuleLayer.boot().defineModules(cf2, mn -> loader);
}
/**
- * Attempt to use Layer defineModules to create a Layer with a module
+ * Attempt to use defineModules to create a layer with a module
* containing a package in which a type is already loaded by the class
* loader.
*/
@@ -1009,15 +1006,15 @@ public class BasicLayerTest {
ModuleFinder finder = ModuleUtils.finderOf(md);
- Configuration parent = Layer.boot().configuration();
+ Configuration parent = ModuleLayer.boot().configuration();
Configuration cf = parent.resolve(finder, ModuleFinder.of(), Set.of("m"));
- Layer.boot().defineModules(cf, mn -> c.getClassLoader());
+ ModuleLayer.boot().defineModules(cf, mn -> c.getClassLoader());
}
/**
- * Attempt to create a Layer with a module named "java.base".
+ * Attempt to create a layer with a module named "java.base".
*/
public void testLayerWithJavaBase() {
ModuleDescriptor descriptor = newBuilder("java.base")
@@ -1026,7 +1023,7 @@ public class BasicLayerTest {
ModuleFinder finder = ModuleUtils.finderOf(descriptor);
- Configuration cf = Layer.boot()
+ Configuration cf = ModuleLayer.boot()
.configuration()
.resolve(finder, ModuleFinder.of(), Set.of("java.base"));
assertTrue(cf.modules().size() == 1);
@@ -1034,17 +1031,17 @@ public class BasicLayerTest {
ClassLoader scl = ClassLoader.getSystemClassLoader();
try {
- Layer.boot().defineModules(cf, mn -> new ClassLoader() { });
+ ModuleLayer.boot().defineModules(cf, mn -> new ClassLoader() { });
assertTrue(false);
} catch (LayerInstantiationException e) { }
try {
- Layer.boot().defineModulesWithOneLoader(cf, scl);
+ ModuleLayer.boot().defineModulesWithOneLoader(cf, scl);
assertTrue(false);
} catch (LayerInstantiationException e) { }
try {
- Layer.boot().defineModulesWithManyLoaders(cf, scl);
+ ModuleLayer.boot().defineModulesWithManyLoaders(cf, scl);
assertTrue(false);
} catch (LayerInstantiationException e) { }
}
@@ -1056,7 +1053,7 @@ public class BasicLayerTest {
}
/**
- * Attempt to create a Layer with a module containing a "java" package.
+ * Attempt to create a layer with a module containing a "java" package.
* This should only be allowed when the module is defined to the platform
* class loader.
*/
@@ -1065,7 +1062,7 @@ public class BasicLayerTest {
ModuleDescriptor descriptor = newBuilder(mn).packages(Set.of(pn)).build();
ModuleFinder finder = ModuleUtils.finderOf(descriptor);
- Configuration cf = Layer.boot()
+ Configuration cf = ModuleLayer.boot()
.configuration()
.resolve(finder, ModuleFinder.of(), Set.of(mn));
assertTrue(cf.modules().size() == 1);
@@ -1074,33 +1071,33 @@ public class BasicLayerTest {
ClassLoader scl = ClassLoader.getSystemClassLoader();
try {
- Layer.boot().defineModules(cf, _mn -> new ClassLoader() { });
+ ModuleLayer.boot().defineModules(cf, _mn -> new ClassLoader() { });
assertTrue(false);
} catch (LayerInstantiationException e) { }
try {
- Layer.boot().defineModulesWithOneLoader(cf, scl);
+ ModuleLayer.boot().defineModulesWithOneLoader(cf, scl);
assertTrue(false);
} catch (LayerInstantiationException e) { }
try {
- Layer.boot().defineModulesWithManyLoaders(cf, scl);
+ ModuleLayer.boot().defineModulesWithManyLoaders(cf, scl);
assertTrue(false);
} catch (LayerInstantiationException e) { }
// create layer with module defined to platform class loader
- Layer layer = Layer.boot().defineModules(cf, _mn -> pcl);
+ ModuleLayer layer = ModuleLayer.boot().defineModules(cf, _mn -> pcl);
Optional om = layer.findModule(mn);
assertTrue(om.isPresent());
Module foo = om.get();
assertTrue(foo.getClassLoader() == pcl);
- assertTrue(foo.getPackages().length == 1);
- assertTrue(foo.getPackages()[0].equals(pn));
+ assertTrue(foo.getPackages().size() == 1);
+ assertTrue(foo.getPackages().iterator().next().equals(pn));
}
/**
- * Attempt to create a Layer with a module defined to the boot loader
+ * Attempt to create a layer with a module defined to the boot loader
*/
@Test(expectedExceptions = { LayerInstantiationException.class })
public void testLayerWithBootLoader() {
@@ -1109,50 +1106,47 @@ public class BasicLayerTest {
ModuleFinder finder = ModuleUtils.finderOf(descriptor);
- Configuration cf = Layer.boot()
+ Configuration cf = ModuleLayer.boot()
.configuration()
.resolve(finder, ModuleFinder.of(), Set.of("m1"));
assertTrue(cf.modules().size() == 1);
- Layer.boot().defineModules(cf, mn -> null );
+ ModuleLayer.boot().defineModules(cf, mn -> null );
}
/**
- * Parent of configuration != configuration of parent Layer
+ * Parent of configuration != configuration of parent layer
*/
@Test(expectedExceptions = { IllegalArgumentException.class })
public void testIncorrectParent1() {
-
ModuleDescriptor descriptor1 = newBuilder("m1")
.requires("java.base")
.build();
ModuleFinder finder = ModuleUtils.finderOf(descriptor1);
- Configuration parent = Layer.boot().configuration();
+ Configuration parent = ModuleLayer.boot().configuration();
Configuration cf = parent.resolve(finder, ModuleFinder.of(), Set.of("m1"));
ClassLoader loader = new ClassLoader() { };
- Layer.empty().defineModules(cf, mn -> loader);
+ ModuleLayer.empty().defineModules(cf, mn -> loader);
}
/**
- * Parent of configuration != configuration of parent Layer
+ * Parent of configuration != configuration of parent layer
*/
@Test(expectedExceptions = { IllegalArgumentException.class })
public void testIncorrectParent2() {
-
- ModuleDescriptor descriptor1 = newBuilder("m1")
- .build();
+ ModuleDescriptor descriptor1 = newBuilder("m1").build();
ModuleFinder finder = ModuleUtils.finderOf(descriptor1);
Configuration cf = resolve(finder, "m1");
ClassLoader loader = new ClassLoader() { };
- Layer.boot().defineModules(cf, mn -> loader);
+ ModuleLayer.boot().defineModules(cf, mn -> loader);
}
@@ -1161,35 +1155,35 @@ public class BasicLayerTest {
@Test(expectedExceptions = { NullPointerException.class })
public void testCreateWithNull1() {
ClassLoader loader = new ClassLoader() { };
- Layer.empty().defineModules(null, mn -> loader);
+ ModuleLayer.empty().defineModules(null, mn -> loader);
}
@Test(expectedExceptions = { NullPointerException.class })
public void testCreateWithNull2() {
- Configuration cf = resolve(Layer.boot().configuration(), ModuleFinder.of());
- Layer.boot().defineModules(cf, null);
+ Configuration cf = resolve(ModuleLayer.boot().configuration(), ModuleFinder.of());
+ ModuleLayer.boot().defineModules(cf, null);
}
@Test(expectedExceptions = { NullPointerException.class })
public void testCreateWithNull3() {
ClassLoader scl = ClassLoader.getSystemClassLoader();
- Layer.empty().defineModulesWithOneLoader(null, scl);
+ ModuleLayer.empty().defineModulesWithOneLoader(null, scl);
}
@Test(expectedExceptions = { NullPointerException.class })
public void testCreateWithNull4() {
ClassLoader scl = ClassLoader.getSystemClassLoader();
- Layer.empty().defineModulesWithManyLoaders(null, scl);
+ ModuleLayer.empty().defineModulesWithManyLoaders(null, scl);
}
@Test(expectedExceptions = { NullPointerException.class })
public void testFindModuleWithNull() {
- Layer.boot().findModule(null);
+ ModuleLayer.boot().findModule(null);
}
@Test(expectedExceptions = { NullPointerException.class })
public void testFindLoaderWithNull() {
- Layer.boot().findLoader(null);
+ ModuleLayer.boot().findLoader(null);
}
@@ -1198,7 +1192,7 @@ public class BasicLayerTest {
@Test(expectedExceptions = { UnsupportedOperationException.class })
public void testImmutableSet() {
Module base = Object.class.getModule();
- Layer.boot().modules().add(base);
+ ModuleLayer.boot().modules().add(base);
}
diff --git a/jdk/test/java/lang/reflect/Layer/LayerAndLoadersTest.java b/jdk/test/java/lang/ModuleLayer/LayerAndLoadersTest.java
similarity index 88%
rename from jdk/test/java/lang/reflect/Layer/LayerAndLoadersTest.java
rename to jdk/test/java/lang/ModuleLayer/LayerAndLoadersTest.java
index ac6c035c297..a67555a47b1 100644
--- a/jdk/test/java/lang/reflect/Layer/LayerAndLoadersTest.java
+++ b/jdk/test/java/lang/ModuleLayer/LayerAndLoadersTest.java
@@ -27,7 +27,7 @@
* @modules jdk.compiler
* @build LayerAndLoadersTest CompilerUtils ModuleUtils
* @run testng LayerAndLoadersTest
- * @summary Tests for java.lang.reflect.Layer@createWithXXX methods
+ * @summary Tests for java.lang.ModuleLayer@defineModulesWithXXX methods
*/
import java.io.IOException;
@@ -36,10 +36,7 @@ import java.lang.module.Configuration;
import java.lang.module.ModuleDescriptor;
import java.lang.module.ModuleFinder;
import java.lang.module.ModuleReference;
-import java.lang.reflect.Layer;
-import java.lang.reflect.LayerInstantiationException;
import java.lang.reflect.Method;
-import java.lang.reflect.Module;
import java.net.URL;
import java.nio.file.Path;
import java.nio.file.Paths;
@@ -74,7 +71,7 @@ public class LayerAndLoadersTest {
/**
- * Basic test of Layer defineModulesWithOneLoader
+ * Basic test of ModuleLayer.defineModulesWithOneLoader
*
* Test scenario:
* m1 requires m2 and m3
@@ -85,7 +82,7 @@ public class LayerAndLoadersTest {
ClassLoader scl = ClassLoader.getSystemClassLoader();
- Layer layer = Layer.boot().defineModulesWithOneLoader(cf, scl);
+ ModuleLayer layer = ModuleLayer.boot().defineModulesWithOneLoader(cf, scl);
checkLayer(layer, "m1", "m2", "m3");
@@ -103,7 +100,7 @@ public class LayerAndLoadersTest {
/**
- * Basic test of Layer defineModulesWithManyLoaders
+ * Basic test of ModuleLayer.defineModulesWithManyLoaders
*
* Test scenario:
* m1 requires m2 and m3
@@ -114,7 +111,7 @@ public class LayerAndLoadersTest {
ClassLoader scl = ClassLoader.getSystemClassLoader();
- Layer layer = Layer.boot().defineModulesWithManyLoaders(cf, scl);
+ ModuleLayer layer = ModuleLayer.boot().defineModulesWithManyLoaders(cf, scl);
checkLayer(layer, "m1", "m2", "m3");
@@ -135,8 +132,8 @@ public class LayerAndLoadersTest {
/**
- * Basic test of Layer defineModulesWithOneLoader where one of the modules
- * is a service provider module.
+ * Basic test of ModuleLayer.defineModulesWithOneLoader where one of the
+ * modules is a service provider module.
*
* Test scenario:
* m1 requires m2 and m3
@@ -149,7 +146,7 @@ public class LayerAndLoadersTest {
ClassLoader scl = ClassLoader.getSystemClassLoader();
- Layer layer = Layer.boot().defineModulesWithOneLoader(cf, scl);
+ ModuleLayer layer = ModuleLayer.boot().defineModulesWithOneLoader(cf, scl);
checkLayer(layer, "m1", "m2", "m3", "m4");
@@ -176,7 +173,7 @@ public class LayerAndLoadersTest {
/**
- * Basic test of Layer defineModulesWithManyLoaders where one of the
+ * Basic test of ModuleLayer.defineModulesWithManyLoaders where one of the
* modules is a service provider module.
*
* Test scenario:
@@ -190,7 +187,7 @@ public class LayerAndLoadersTest {
ClassLoader scl = ClassLoader.getSystemClassLoader();
- Layer layer = Layer.boot().defineModulesWithManyLoaders(cf, scl);
+ ModuleLayer layer = ModuleLayer.boot().defineModulesWithManyLoaders(cf, scl);
checkLayer(layer, "m1", "m2", "m3", "m4");
@@ -239,19 +236,19 @@ public class LayerAndLoadersTest {
String cn = this.getClass().getName();
// one loader
- Layer layer = Layer.boot().defineModulesWithOneLoader(cf, parent);
+ ModuleLayer layer = ModuleLayer.boot().defineModulesWithOneLoader(cf, parent);
testLoad(layer, cn);
// one loader with boot loader as parent
- layer = Layer.boot().defineModulesWithOneLoader(cf, null);
+ layer = ModuleLayer.boot().defineModulesWithOneLoader(cf, null);
testLoadFail(layer, cn);
// many loaders
- layer = Layer.boot().defineModulesWithManyLoaders(cf, parent);
+ layer = ModuleLayer.boot().defineModulesWithManyLoaders(cf, parent);
testLoad(layer, cn);
// many loader with boot loader as parent
- layer = Layer.boot().defineModulesWithManyLoaders(cf, null);
+ layer = ModuleLayer.boot().defineModulesWithManyLoaders(cf, null);
testLoadFail(layer, cn);
}
@@ -274,25 +271,25 @@ public class LayerAndLoadersTest {
ModuleFinder finder = ModuleUtils.finderOf(descriptor1, descriptor2);
- Configuration cf = Layer.boot()
+ Configuration cf = ModuleLayer.boot()
.configuration()
.resolve(finder, ModuleFinder.of(), Set.of("m1", "m2"));
// cannot define both module m1 and m2 to the same class loader
try {
- Layer.boot().defineModulesWithOneLoader(cf, null);
+ ModuleLayer.boot().defineModulesWithOneLoader(cf, null);
assertTrue(false);
} catch (LayerInstantiationException expected) { }
// should be okay to have one module per class loader
- Layer layer = Layer.boot().defineModulesWithManyLoaders(cf, null);
+ ModuleLayer layer = ModuleLayer.boot().defineModulesWithManyLoaders(cf, null);
checkLayer(layer, "m1", "m2");
}
/**
- * Test Layer defineModulesWithXXX with split delegation.
+ * Test ModuleLayer.defineModulesWithXXX with split delegation.
*
* Test scenario:
* layer1: m1 exports p, m2 exports p
@@ -308,11 +305,11 @@ public class LayerAndLoadersTest {
ModuleFinder finder1 = ModuleUtils.finderOf(descriptor1, descriptor2);
- Configuration cf1 = Layer.boot()
+ Configuration cf1 = ModuleLayer.boot()
.configuration()
.resolve(finder1, ModuleFinder.of(), Set.of("m1", "m2"));
- Layer layer1 = Layer.boot().defineModulesWithManyLoaders(cf1, null);
+ ModuleLayer layer1 = ModuleLayer.boot().defineModulesWithManyLoaders(cf1, null);
checkLayer(layer1, "m1", "m2");
ModuleDescriptor descriptor3
@@ -333,14 +330,14 @@ public class LayerAndLoadersTest {
} catch (LayerInstantiationException expected) { }
// no split delegation when modules have their own class loader
- Layer layer2 = layer1.defineModulesWithManyLoaders(cf2, null);
+ ModuleLayer layer2 = layer1.defineModulesWithManyLoaders(cf2, null);
checkLayer(layer2, "m3", "m4");
}
/**
- * Test Layer defineModulesWithXXX when the modules that override same
+ * Test ModuleLayer.defineModulesWithXXX when the modules that override same
* named modules in the parent layer.
*
* Test scenario:
@@ -351,14 +348,14 @@ public class LayerAndLoadersTest {
Configuration cf1 = resolve("m1");
- Layer layer1 = Layer.boot().defineModulesWithOneLoader(cf1, null);
+ ModuleLayer layer1 = ModuleLayer.boot().defineModulesWithOneLoader(cf1, null);
checkLayer(layer1, "m1", "m2", "m3");
ModuleFinder finder = ModuleFinder.of(MODS_DIR);
Configuration cf2 = cf1.resolve(finder, ModuleFinder.of(),
Set.of("m1"));
- Layer layer2 = layer1.defineModulesWithOneLoader(cf2, null);
+ ModuleLayer layer2 = layer1.defineModulesWithOneLoader(cf2, null);
checkLayer(layer2, "m1", "m2", "m3");
invoke(layer1, "m1", "p.Main");
@@ -400,14 +397,14 @@ public class LayerAndLoadersTest {
Configuration cf1 = resolve("m1");
- Layer layer1 = Layer.boot().defineModulesWithManyLoaders(cf1, null);
+ ModuleLayer layer1 = ModuleLayer.boot().defineModulesWithManyLoaders(cf1, null);
checkLayer(layer1, "m1", "m2", "m3");
ModuleFinder finder = ModuleFinder.of(MODS_DIR);
Configuration cf2 = cf1.resolve(finder, ModuleFinder.of(),
Set.of("m1"));
- Layer layer2 = layer1.defineModulesWithManyLoaders(cf2, null);
+ ModuleLayer layer2 = layer1.defineModulesWithManyLoaders(cf2, null);
checkLayer(layer2, "m1", "m2", "m3");
invoke(layer1, "m1", "p.Main");
@@ -484,7 +481,7 @@ public class LayerAndLoadersTest {
/**
- * Test Layer defineModulesWithXXX when the modules that override same
+ * Test ModuleLayer.defineModulesWithXXX when the modules that override same
* named modules in the parent layer.
*
* layer1: m1, m2, m3 => same loader
@@ -494,7 +491,7 @@ public class LayerAndLoadersTest {
Configuration cf1 = resolve("m1");
- Layer layer1 = Layer.boot().defineModulesWithOneLoader(cf1, null);
+ ModuleLayer layer1 = ModuleLayer.boot().defineModulesWithOneLoader(cf1, null);
checkLayer(layer1, "m1", "m2", "m3");
ModuleFinder finder = finderFor("m1", "m3");
@@ -502,7 +499,7 @@ public class LayerAndLoadersTest {
Configuration cf2 = cf1.resolve(finder, ModuleFinder.of(),
Set.of("m1"));
- Layer layer2 = layer1.defineModulesWithOneLoader(cf2, null);
+ ModuleLayer layer2 = layer1.defineModulesWithOneLoader(cf2, null);
checkLayer(layer2, "m1", "m3");
invoke(layer1, "m1", "p.Main");
@@ -531,7 +528,7 @@ public class LayerAndLoadersTest {
Configuration cf1 = resolve("m1");
- Layer layer1 = Layer.boot().defineModulesWithManyLoaders(cf1, null);
+ ModuleLayer layer1 = ModuleLayer.boot().defineModulesWithManyLoaders(cf1, null);
checkLayer(layer1, "m1", "m2", "m3");
ModuleFinder finder = finderFor("m1", "m3");
@@ -539,7 +536,7 @@ public class LayerAndLoadersTest {
Configuration cf2 = cf1.resolve(finder, ModuleFinder.of(),
Set.of("m1"));
- Layer layer2 = layer1.defineModulesWithManyLoaders(cf2, null);
+ ModuleLayer layer2 = layer1.defineModulesWithManyLoaders(cf2, null);
checkLayer(layer2, "m1", "m3");
invoke(layer1, "m1", "p.Main");
@@ -579,7 +576,7 @@ public class LayerAndLoadersTest {
public void testResourcesOneLoader() throws Exception {
Configuration cf = resolve("m1");
ClassLoader scl = ClassLoader.getSystemClassLoader();
- Layer layer = Layer.boot().defineModulesWithOneLoader(cf, scl);
+ ModuleLayer layer = ModuleLayer.boot().defineModulesWithOneLoader(cf, scl);
ClassLoader loader = layer.findLoader("m1");
testResourceLoading(loader, "p/Main.class");
}
@@ -591,7 +588,7 @@ public class LayerAndLoadersTest {
public void testResourcesManyLoaders() throws Exception {
Configuration cf = resolve("m1");
ClassLoader scl = ClassLoader.getSystemClassLoader();
- Layer layer = Layer.boot().defineModulesWithManyLoaders(cf, scl);
+ ModuleLayer layer = ModuleLayer.boot().defineModulesWithManyLoaders(cf, scl);
ClassLoader loader = layer.findLoader("m1");
testResourceLoading(loader, "p/Main.class");
}
@@ -623,7 +620,7 @@ public class LayerAndLoadersTest {
*/
private static Configuration resolve(String... roots) {
ModuleFinder finder = ModuleFinder.of(MODS_DIR);
- return Layer.boot()
+ return ModuleLayer.boot()
.configuration()
.resolve(finder, ModuleFinder.of(), Set.of(roots));
}
@@ -634,7 +631,7 @@ public class LayerAndLoadersTest {
*/
private static Configuration resolveAndBind(String... roots) {
ModuleFinder finder = ModuleFinder.of(MODS_DIR);
- return Layer.boot()
+ return ModuleLayer.boot()
.configuration()
.resolveAndBind(finder, ModuleFinder.of(), Set.of(roots));
}
@@ -644,7 +641,7 @@ public class LayerAndLoadersTest {
* Invokes the static void main(String[]) method on the given class
* in the given module.
*/
- private static void invoke(Layer layer, String mn, String mc) throws Exception {
+ private static void invoke(ModuleLayer layer, String mn, String mc) throws Exception {
ClassLoader loader = layer.findLoader(mn);
Class> c = loader.loadClass(mc);
Method mainMethod = c.getMethod("main", String[].class);
@@ -656,7 +653,7 @@ public class LayerAndLoadersTest {
* Checks that the given layer contains exactly the expected modules
* (by name).
*/
- private void checkLayer(Layer layer, String ... expected) {
+ private void checkLayer(ModuleLayer layer, String ... expected) {
Set names = layer.modules().stream()
.map(Module::getName)
.collect(Collectors.toSet());
@@ -671,7 +668,7 @@ public class LayerAndLoadersTest {
* Test that a class can be loaded via the class loader of all modules
* in the given layer.
*/
- static void testLoad(Layer layer, String cn) throws Exception {
+ static void testLoad(ModuleLayer layer, String cn) throws Exception {
for (Module m : layer.modules()) {
ClassLoader l = m.getClassLoader();
l.loadClass(cn);
@@ -683,7 +680,7 @@ public class LayerAndLoadersTest {
* Test that a class cannot be loaded via any of the class loaders of
* the modules in the given layer.
*/
- static void testLoadFail(Layer layer, String cn) throws Exception {
+ static void testLoadFail(ModuleLayer layer, String cn) throws Exception {
for (Module m : layer.modules()) {
ClassLoader l = m.getClassLoader();
try {
diff --git a/jdk/test/java/lang/reflect/Layer/LayerControllerTest.java b/jdk/test/java/lang/ModuleLayer/LayerControllerTest.java
similarity index 88%
rename from jdk/test/java/lang/reflect/Layer/LayerControllerTest.java
rename to jdk/test/java/lang/ModuleLayer/LayerControllerTest.java
index 4e4a0dbd5bd..28246cf9b66 100644
--- a/jdk/test/java/lang/reflect/Layer/LayerControllerTest.java
+++ b/jdk/test/java/lang/ModuleLayer/LayerControllerTest.java
@@ -26,14 +26,12 @@
* @library /lib/testlibrary
* @build LayerControllerTest ModuleUtils
* @run testng LayerControllerTest
- * @summary Basic tests for java.lang.reflect.Layer.Controller
+ * @summary Basic tests for java.lang.ModuleLayer.Controller
*/
import java.lang.module.Configuration;
import java.lang.module.ModuleDescriptor;
import java.lang.module.ModuleFinder;
-import java.lang.reflect.Layer;
-import java.lang.reflect.Module;
import java.util.List;
import java.util.Set;
@@ -48,7 +46,7 @@ public class LayerControllerTest {
* Module m1 contains p1, reads java.base, does not export/open any package
* Module m2 contains p2, reads java.base, does not export/open any package
*/
- private Layer.Controller createTestLayer() {
+ private ModuleLayer.Controller createTestLayer() {
ModuleDescriptor descriptor1
= ModuleDescriptor.newModule("m1")
.packages(Set.of("p1"))
@@ -62,17 +60,17 @@ public class LayerControllerTest {
.build();
ModuleFinder finder = ModuleUtils.finderOf(descriptor1, descriptor2);
- Layer bootLayer = Layer.boot();
+ ModuleLayer bootLayer = ModuleLayer.boot();
Configuration cf = bootLayer.configuration()
.resolve(finder, ModuleFinder.of(), Set.of("m1", "m2"));
ClassLoader scl = ClassLoader.getSystemClassLoader();
- Layer.Controller controller
- = Layer.defineModulesWithOneLoader(cf, List.of(bootLayer), scl);
+ ModuleLayer.Controller controller
+ = ModuleLayer.defineModulesWithOneLoader(cf, List.of(bootLayer), scl);
- Layer layer = controller.layer();
+ ModuleLayer layer = controller.layer();
assertTrue(layer.modules().size() == 2);
assertTrue(layer.findModule("m1").isPresent());
@@ -82,12 +80,12 @@ public class LayerControllerTest {
}
/**
- * Basic test of Layer.Controller to update modules m1 and m2 to read and
+ * Basic test of Controller to update modules m1 and m2 to read and
* open packages to each other.
*/
public void testBasic() {
- Layer.Controller controller = createTestLayer();
- Layer layer = controller.layer();
+ ModuleLayer.Controller controller = createTestLayer();
+ ModuleLayer layer = controller.layer();
Module m1 = layer.findModule("m1").orElseThrow(RuntimeException::new);
Module m2 = layer.findModule("m2").orElseThrow(RuntimeException::new);
@@ -132,8 +130,8 @@ public class LayerControllerTest {
* Test invalid argument handling
*/
public void testBadArguments() {
- Layer.Controller controller = createTestLayer();
- Layer layer = controller.layer();
+ ModuleLayer.Controller controller = createTestLayer();
+ ModuleLayer layer = controller.layer();
Module m1 = layer.findModule("m1").orElseThrow(RuntimeException::new);
Module m2 = layer.findModule("m2").orElseThrow(RuntimeException::new);
Module base = Object.class.getModule();
@@ -161,8 +159,8 @@ public class LayerControllerTest {
* Test null handling
*/
public void testNulls() {
- Layer.Controller controller = createTestLayer();
- Layer layer = controller.layer();
+ ModuleLayer.Controller controller = createTestLayer();
+ ModuleLayer layer = controller.layer();
Module m1 = layer.findModule("m1").orElseThrow(RuntimeException::new);
Module m2 = layer.findModule("m2").orElseThrow(RuntimeException::new);
assertTrue(m1 != null);
diff --git a/jdk/test/java/lang/reflect/Layer/layertest/Test.java b/jdk/test/java/lang/ModuleLayer/layertest/Test.java
similarity index 95%
rename from jdk/test/java/lang/reflect/Layer/layertest/Test.java
rename to jdk/test/java/lang/ModuleLayer/layertest/Test.java
index f5c76ccbde5..5eac638e992 100644
--- a/jdk/test/java/lang/reflect/Layer/layertest/Test.java
+++ b/jdk/test/java/lang/ModuleLayer/layertest/Test.java
@@ -22,7 +22,7 @@
*/
/**
- * Supporting class for tests of java.lang.reflect.Layer.
+ * Supporting class for tests of java.lang.ModuleLayer.
*/
package layertest;
diff --git a/jdk/test/java/lang/reflect/Layer/src/m1/module-info.java b/jdk/test/java/lang/ModuleLayer/src/m1/module-info.java
similarity index 100%
rename from jdk/test/java/lang/reflect/Layer/src/m1/module-info.java
rename to jdk/test/java/lang/ModuleLayer/src/m1/module-info.java
diff --git a/jdk/test/java/lang/reflect/Layer/src/m1/p/Main.java b/jdk/test/java/lang/ModuleLayer/src/m1/p/Main.java
similarity index 100%
rename from jdk/test/java/lang/reflect/Layer/src/m1/p/Main.java
rename to jdk/test/java/lang/ModuleLayer/src/m1/p/Main.java
diff --git a/jdk/test/java/lang/reflect/Layer/src/m1/p/Service.java b/jdk/test/java/lang/ModuleLayer/src/m1/p/Service.java
similarity index 100%
rename from jdk/test/java/lang/reflect/Layer/src/m1/p/Service.java
rename to jdk/test/java/lang/ModuleLayer/src/m1/p/Service.java
diff --git a/jdk/test/java/lang/reflect/Layer/src/m2/module-info.java b/jdk/test/java/lang/ModuleLayer/src/m2/module-info.java
similarity index 100%
rename from jdk/test/java/lang/reflect/Layer/src/m2/module-info.java
rename to jdk/test/java/lang/ModuleLayer/src/m2/module-info.java
diff --git a/jdk/test/java/lang/reflect/Layer/src/m2/q/Hello.java b/jdk/test/java/lang/ModuleLayer/src/m2/q/Hello.java
similarity index 100%
rename from jdk/test/java/lang/reflect/Layer/src/m2/q/Hello.java
rename to jdk/test/java/lang/ModuleLayer/src/m2/q/Hello.java
diff --git a/jdk/test/java/lang/reflect/Layer/src/m3/module-info.java b/jdk/test/java/lang/ModuleLayer/src/m3/module-info.java
similarity index 100%
rename from jdk/test/java/lang/reflect/Layer/src/m3/module-info.java
rename to jdk/test/java/lang/ModuleLayer/src/m3/module-info.java
diff --git a/jdk/test/java/lang/reflect/Layer/src/m3/w/Hello.java b/jdk/test/java/lang/ModuleLayer/src/m3/w/Hello.java
similarity index 100%
rename from jdk/test/java/lang/reflect/Layer/src/m3/w/Hello.java
rename to jdk/test/java/lang/ModuleLayer/src/m3/w/Hello.java
diff --git a/jdk/test/java/lang/reflect/Layer/src/m4/impl/ServiceImpl.java b/jdk/test/java/lang/ModuleLayer/src/m4/impl/ServiceImpl.java
similarity index 100%
rename from jdk/test/java/lang/reflect/Layer/src/m4/impl/ServiceImpl.java
rename to jdk/test/java/lang/ModuleLayer/src/m4/impl/ServiceImpl.java
diff --git a/jdk/test/java/lang/reflect/Layer/src/m4/module-info.java b/jdk/test/java/lang/ModuleLayer/src/m4/module-info.java
similarity index 100%
rename from jdk/test/java/lang/reflect/Layer/src/m4/module-info.java
rename to jdk/test/java/lang/ModuleLayer/src/m4/module-info.java
diff --git a/jdk/test/java/lang/reflect/Module/AddExportsTest.java b/jdk/test/java/lang/ModuleTests/AddExportsTest.java
similarity index 97%
rename from jdk/test/java/lang/reflect/Module/AddExportsTest.java
rename to jdk/test/java/lang/ModuleTests/AddExportsTest.java
index 3f4453614e8..e1204615e74 100644
--- a/jdk/test/java/lang/reflect/Module/AddExportsTest.java
+++ b/jdk/test/java/lang/ModuleTests/AddExportsTest.java
@@ -30,8 +30,6 @@
* @summary Test Module isExported methods with exports changed by -AddExportsTest
*/
-import java.lang.reflect.Layer;
-import java.lang.reflect.Module;
import java.util.Optional;
import java.util.stream.Stream;
@@ -55,7 +53,7 @@ public class AddExportsTest {
assertTrue(oaddExports.isPresent());
- Layer bootLayer = Layer.boot();
+ ModuleLayer bootLayer = ModuleLayer.boot();
Module unnamedModule = AddExportsTest.class.getModule();
assertFalse(unnamedModule.isNamed());
diff --git a/jdk/test/java/lang/reflect/Module/AnnotationsTest.java b/jdk/test/java/lang/ModuleTests/AnnotationsTest.java
similarity index 95%
rename from jdk/test/java/lang/reflect/Module/AnnotationsTest.java
rename to jdk/test/java/lang/ModuleTests/AnnotationsTest.java
index d30a0c07779..b4319a7bb11 100644
--- a/jdk/test/java/lang/reflect/Module/AnnotationsTest.java
+++ b/jdk/test/java/lang/ModuleTests/AnnotationsTest.java
@@ -26,8 +26,6 @@ import java.io.InputStream;
import java.lang.annotation.Annotation;
import java.lang.module.Configuration;
import java.lang.module.ModuleFinder;
-import java.lang.reflect.Layer;
-import java.lang.reflect.Module;
import java.nio.file.Files;
import java.nio.file.Path;
@@ -102,7 +100,7 @@ public class AnnotationsTest {
boolean forRemoval,
String since,
Path output) throws IOException {
- Module module = Layer.boot().findModule(name).orElse(null);
+ Module module = ModuleLayer.boot().findModule(name).orElse(null);
assertNotNull(module, name + " not found");
InputStream in = module.getResourceAsStream("module-info.class");
@@ -141,13 +139,13 @@ public class AnnotationsTest {
static Module loadModule(Path dir, String name) throws IOException {
ModuleFinder finder = ModuleFinder.of(dir);
- Layer bootLayer = Layer.boot();
+ ModuleLayer bootLayer = ModuleLayer.boot();
Configuration cf = bootLayer.configuration()
.resolve(finder, ModuleFinder.of(), Set.of(name));
ClassLoader scl = ClassLoader.getSystemClassLoader();
- Layer layer = bootLayer.defineModulesWithOneLoader(cf, scl);
+ ModuleLayer layer = bootLayer.defineModulesWithOneLoader(cf, scl);
Module module = layer.findModule(name).orElse(null);
assertNotNull(module, name + " not loaded");
diff --git a/jdk/test/java/lang/reflect/Module/BasicModuleTest.java b/jdk/test/java/lang/ModuleTests/BasicModuleTest.java
similarity index 93%
rename from jdk/test/java/lang/reflect/Module/BasicModuleTest.java
rename to jdk/test/java/lang/ModuleTests/BasicModuleTest.java
index 90fb62b4a2e..b2f5eaa3a14 100644
--- a/jdk/test/java/lang/reflect/Module/BasicModuleTest.java
+++ b/jdk/test/java/lang/ModuleTests/BasicModuleTest.java
@@ -23,8 +23,6 @@
import java.lang.module.ModuleDescriptor.Exports;
import java.lang.module.ResolvedModule;
-import java.lang.reflect.Layer;
-import java.lang.reflect.Module;
import java.nio.file.spi.FileSystemProvider; // service type in java.base
import java.util.function.Predicate;
import java.util.stream.Stream;
@@ -35,7 +33,7 @@ import static org.testng.Assert.*;
/*
* @test
- * @summary Basic test of java.lang.reflect.Module
+ * @summary Basic test of java.lang.Module
* @modules java.desktop java.xml
* @run testng BasicModuleTest
*/
@@ -43,10 +41,10 @@ import static org.testng.Assert.*;
public class BasicModuleTest {
/**
- * Tests that the given module reads all modules in the boot Layer.
+ * Tests that the given module reads all modules in the boot layer.
*/
private void testReadsAllBootModules(Module m) {
- Layer bootLayer = Layer.boot();
+ ModuleLayer bootLayer = ModuleLayer.boot();
bootLayer.configuration()
.modules()
.stream()
@@ -55,13 +53,6 @@ public class BasicModuleTest {
.forEach(target -> assertTrue(m.canRead(target.get())));
}
- /**
- * Returns {@code true} if the array contains the given object.
- */
- private boolean contains(T[] array, T obj) {
- return Stream.of(array).anyMatch(obj::equals);
- }
-
/**
* Returns a {@code Predicate} to test if a package is exported.
*/
@@ -103,7 +94,7 @@ public class BasicModuleTest {
assertTrue(thisModule.isExported("p", baseModule));
// this test is in the unnamed package
- assertTrue(contains(thisModule.getPackages(), ""));
+ assertTrue(thisModule.getPackages().contains(""));
}
@@ -162,13 +153,13 @@ public class BasicModuleTest {
assertTrue(base.getClassLoader() == null);
// getLayer
- assertTrue(base.getLayer() == Layer.boot());
+ assertTrue(base.getLayer() == ModuleLayer.boot());
// toString
assertEquals(base.toString(), "module java.base");
// getPackages
- assertTrue(contains(base.getPackages(), "java.lang"));
+ assertTrue(base.getPackages().contains("java.lang"));
// canRead
assertTrue(base.canRead(base));
@@ -258,14 +249,14 @@ public class BasicModuleTest {
assertTrue(desktop.getClassLoader() == null);
// getLayer
- assertTrue(desktop.getLayer() == Layer.boot());
+ assertTrue(desktop.getLayer() == ModuleLayer.boot());
// toString
assertEquals(desktop.toString(), "module java.desktop");
// getPackages
- assertTrue(contains(desktop.getPackages(), "java.awt"));
- assertTrue(contains(desktop.getPackages(), "sun.awt"));
+ assertTrue(desktop.getPackages().contains("java.awt"));
+ assertTrue(desktop.getPackages().contains("sun.awt"));
// canRead
assertTrue(desktop.canRead(base));
diff --git a/jdk/test/java/lang/reflect/Module/WithSecurityManager.java b/jdk/test/java/lang/ModuleTests/WithSecurityManager.java
similarity index 92%
rename from jdk/test/java/lang/reflect/Module/WithSecurityManager.java
rename to jdk/test/java/lang/ModuleTests/WithSecurityManager.java
index 794ebf00e44..88813c859ac 100644
--- a/jdk/test/java/lang/reflect/Module/WithSecurityManager.java
+++ b/jdk/test/java/lang/ModuleTests/WithSecurityManager.java
@@ -24,7 +24,7 @@
/**
* @test
* @modules jdk.compiler
- * @summary Test java.lang.reflect.Module methods that specify permission checks
+ * @summary Test java.lang.Module methods that specify permission checks
* @run main/othervm -Djava.security.policy=${test.src}/allow.policy WithSecurityManager allow
* @run main/othervm WithSecurityManager deny
*/
@@ -34,14 +34,12 @@ import java.io.InputStream;
import java.lang.module.Configuration;
import java.lang.module.ModuleFinder;
import java.lang.module.ModuleReference;
-import java.lang.reflect.Layer;
-import java.lang.reflect.Module;
import java.util.Collections;
import java.util.Optional;
import java.util.Set;
/**
- * Test java.lang.reflect.Module methods that specify permission checks.
+ * Test java.lang.Module methods that specify permission checks.
*/
public class WithSecurityManager {
@@ -58,7 +56,7 @@ public class WithSecurityManager {
// another module, in a child layer
Module other = loadModuleInChildLayer(ANOTHER_MODULE);
- assertTrue(other.getLayer() != Layer.boot());
+ assertTrue(other.getLayer() != ModuleLayer.boot());
System.setSecurityManager(new SecurityManager());
@@ -123,11 +121,11 @@ public class WithSecurityManager {
};
// create a child configuration and layer with this module
- Layer bootLayer = Layer.boot();
+ ModuleLayer bootLayer = ModuleLayer.boot();
Configuration cf = bootLayer
.configuration()
.resolve(finder, ModuleFinder.of(), Set.of(ANOTHER_MODULE));
- Layer layer = bootLayer.defineModulesWithOneLoader(cf, null);
+ ModuleLayer layer = bootLayer.defineModulesWithOneLoader(cf, null);
Optional om = layer.findModule(mn);
assertTrue("module " + mn + " not in child layer", om.isPresent());
diff --git a/jdk/test/java/lang/reflect/Module/access/AccessTest.java b/jdk/test/java/lang/ModuleTests/access/AccessTest.java
similarity index 100%
rename from jdk/test/java/lang/reflect/Module/access/AccessTest.java
rename to jdk/test/java/lang/ModuleTests/access/AccessTest.java
diff --git a/jdk/test/java/lang/reflect/Module/access/src/target/module-info.java b/jdk/test/java/lang/ModuleTests/access/src/target/module-info.java
similarity index 100%
rename from jdk/test/java/lang/reflect/Module/access/src/target/module-info.java
rename to jdk/test/java/lang/ModuleTests/access/src/target/module-info.java
diff --git a/jdk/test/java/lang/reflect/Module/access/src/target/p1/Helper.java b/jdk/test/java/lang/ModuleTests/access/src/target/p1/Helper.java
similarity index 97%
rename from jdk/test/java/lang/reflect/Module/access/src/target/p1/Helper.java
rename to jdk/test/java/lang/ModuleTests/access/src/target/p1/Helper.java
index e0e45e82a06..cbed4fbaec7 100644
--- a/jdk/test/java/lang/reflect/Module/access/src/target/p1/Helper.java
+++ b/jdk/test/java/lang/ModuleTests/access/src/target/p1/Helper.java
@@ -23,8 +23,6 @@
package p1;
-import java.lang.reflect.Module;
-
/**
* Helper class in target module to allow test invoke addExports[Private]
*/
diff --git a/jdk/test/java/lang/reflect/Module/access/src/target/p1/Public.java b/jdk/test/java/lang/ModuleTests/access/src/target/p1/Public.java
similarity index 100%
rename from jdk/test/java/lang/reflect/Module/access/src/target/p1/Public.java
rename to jdk/test/java/lang/ModuleTests/access/src/target/p1/Public.java
diff --git a/jdk/test/java/lang/reflect/Module/access/src/target/p2/NonPublic.java b/jdk/test/java/lang/ModuleTests/access/src/target/p2/NonPublic.java
similarity index 100%
rename from jdk/test/java/lang/reflect/Module/access/src/target/p2/NonPublic.java
rename to jdk/test/java/lang/ModuleTests/access/src/target/p2/NonPublic.java
diff --git a/jdk/test/java/lang/reflect/Module/access/src/target/q1/Public.java b/jdk/test/java/lang/ModuleTests/access/src/target/q1/Public.java
similarity index 100%
rename from jdk/test/java/lang/reflect/Module/access/src/target/q1/Public.java
rename to jdk/test/java/lang/ModuleTests/access/src/target/q1/Public.java
diff --git a/jdk/test/java/lang/reflect/Module/access/src/target/q2/NonPublic.java b/jdk/test/java/lang/ModuleTests/access/src/target/q2/NonPublic.java
similarity index 100%
rename from jdk/test/java/lang/reflect/Module/access/src/target/q2/NonPublic.java
rename to jdk/test/java/lang/ModuleTests/access/src/target/q2/NonPublic.java
diff --git a/jdk/test/java/lang/reflect/Module/access/src/test/module-info.java b/jdk/test/java/lang/ModuleTests/access/src/test/module-info.java
similarity index 100%
rename from jdk/test/java/lang/reflect/Module/access/src/test/module-info.java
rename to jdk/test/java/lang/ModuleTests/access/src/test/module-info.java
diff --git a/jdk/test/java/lang/reflect/Module/access/src/test/test/Main.java b/jdk/test/java/lang/ModuleTests/access/src/test/test/Main.java
similarity index 99%
rename from jdk/test/java/lang/reflect/Module/access/src/test/test/Main.java
rename to jdk/test/java/lang/ModuleTests/access/src/test/test/Main.java
index c58b8e202dd..dc81f25a563 100644
--- a/jdk/test/java/lang/reflect/Module/access/src/test/test/Main.java
+++ b/jdk/test/java/lang/ModuleTests/access/src/test/test/Main.java
@@ -26,9 +26,7 @@ package test;
import java.lang.reflect.AccessibleObject;
import java.lang.reflect.Constructor;
import java.lang.reflect.Field;
-import java.lang.reflect.Layer;
import java.lang.reflect.Method;
-import java.lang.reflect.Module;
/**
* Test access to public/non-public members of public/non-public classes in
@@ -305,7 +303,7 @@ public class Main {
static Module getTargetModule() {
- return Layer.boot().findModule("target").get();
+ return ModuleLayer.boot().findModule("target").get();
}
static void tryAccessConstructor(Constructor> ctor, boolean shouldSucceed) {
diff --git a/jdk/test/java/lang/reflect/Module/addXXX/Driver.java b/jdk/test/java/lang/ModuleTests/addXXX/Driver.java
similarity index 100%
rename from jdk/test/java/lang/reflect/Module/addXXX/Driver.java
rename to jdk/test/java/lang/ModuleTests/addXXX/Driver.java
diff --git a/jdk/test/java/lang/reflect/Module/addXXX/m1/module-info.java b/jdk/test/java/lang/ModuleTests/addXXX/m1/module-info.java
similarity index 100%
rename from jdk/test/java/lang/reflect/Module/addXXX/m1/module-info.java
rename to jdk/test/java/lang/ModuleTests/addXXX/m1/module-info.java
diff --git a/jdk/test/java/lang/reflect/Module/addXXX/m1/p1/C.java b/jdk/test/java/lang/ModuleTests/addXXX/m1/p1/C.java
similarity index 100%
rename from jdk/test/java/lang/reflect/Module/addXXX/m1/p1/C.java
rename to jdk/test/java/lang/ModuleTests/addXXX/m1/p1/C.java
diff --git a/jdk/test/java/lang/reflect/Module/addXXX/m2/module-info.java b/jdk/test/java/lang/ModuleTests/addXXX/m2/module-info.java
similarity index 100%
rename from jdk/test/java/lang/reflect/Module/addXXX/m2/module-info.java
rename to jdk/test/java/lang/ModuleTests/addXXX/m2/module-info.java
diff --git a/jdk/test/java/lang/reflect/Module/addXXX/m2/p2/C.java b/jdk/test/java/lang/ModuleTests/addXXX/m2/p2/C.java
similarity index 97%
rename from jdk/test/java/lang/reflect/Module/addXXX/m2/p2/C.java
rename to jdk/test/java/lang/ModuleTests/addXXX/m2/p2/C.java
index 6a87a2eba87..d3c5f467250 100644
--- a/jdk/test/java/lang/reflect/Module/addXXX/m2/p2/C.java
+++ b/jdk/test/java/lang/ModuleTests/addXXX/m2/p2/C.java
@@ -22,8 +22,6 @@
*/
package p2;
-import java.lang.reflect.Module;
-
public class C {
public static void export(String pn, Module m) {
diff --git a/jdk/test/java/lang/reflect/Module/addXXX/m2/p2/internal/C.java b/jdk/test/java/lang/ModuleTests/addXXX/m2/p2/internal/C.java
similarity index 100%
rename from jdk/test/java/lang/reflect/Module/addXXX/m2/p2/internal/C.java
rename to jdk/test/java/lang/ModuleTests/addXXX/m2/p2/internal/C.java
diff --git a/jdk/test/java/lang/reflect/Module/addXXX/m3/module-info.java b/jdk/test/java/lang/ModuleTests/addXXX/m3/module-info.java
similarity index 100%
rename from jdk/test/java/lang/reflect/Module/addXXX/m3/module-info.java
rename to jdk/test/java/lang/ModuleTests/addXXX/m3/module-info.java
diff --git a/jdk/test/java/lang/reflect/Module/addXXX/m3/p3/C.java b/jdk/test/java/lang/ModuleTests/addXXX/m3/p3/C.java
similarity index 100%
rename from jdk/test/java/lang/reflect/Module/addXXX/m3/p3/C.java
rename to jdk/test/java/lang/ModuleTests/addXXX/m3/p3/C.java
diff --git a/jdk/test/java/lang/reflect/Module/addXXX/m4/module-info.java b/jdk/test/java/lang/ModuleTests/addXXX/m4/module-info.java
similarity index 100%
rename from jdk/test/java/lang/reflect/Module/addXXX/m4/module-info.java
rename to jdk/test/java/lang/ModuleTests/addXXX/m4/module-info.java
diff --git a/jdk/test/java/lang/reflect/Module/addXXX/m4/p4/C.java b/jdk/test/java/lang/ModuleTests/addXXX/m4/p4/C.java
similarity index 100%
rename from jdk/test/java/lang/reflect/Module/addXXX/m4/p4/C.java
rename to jdk/test/java/lang/ModuleTests/addXXX/m4/p4/C.java
diff --git a/jdk/test/java/lang/reflect/Module/addXXX/test/module-info.java b/jdk/test/java/lang/ModuleTests/addXXX/test/module-info.java
similarity index 100%
rename from jdk/test/java/lang/reflect/Module/addXXX/test/module-info.java
rename to jdk/test/java/lang/ModuleTests/addXXX/test/module-info.java
diff --git a/jdk/test/java/lang/reflect/Module/addXXX/test/test/C.java b/jdk/test/java/lang/ModuleTests/addXXX/test/test/C.java
similarity index 100%
rename from jdk/test/java/lang/reflect/Module/addXXX/test/test/C.java
rename to jdk/test/java/lang/ModuleTests/addXXX/test/test/C.java
diff --git a/jdk/test/java/lang/reflect/Module/addXXX/test/test/Main.java b/jdk/test/java/lang/ModuleTests/addXXX/test/test/Main.java
similarity index 99%
rename from jdk/test/java/lang/reflect/Module/addXXX/test/test/Main.java
rename to jdk/test/java/lang/ModuleTests/addXXX/test/test/Main.java
index 924f0a87de4..9a191a1dcfc 100644
--- a/jdk/test/java/lang/reflect/Module/addXXX/test/test/Main.java
+++ b/jdk/test/java/lang/ModuleTests/addXXX/test/test/Main.java
@@ -27,7 +27,6 @@ import java.lang.invoke.MethodHandle;
import java.lang.invoke.MethodHandles;
import java.lang.invoke.MethodType;
import java.lang.reflect.Constructor;
-import java.lang.reflect.Module;
import java.util.ServiceConfigurationError;
import java.util.ServiceLoader;
diff --git a/jdk/test/java/lang/reflect/Module/addXXX/test/test/Service.java b/jdk/test/java/lang/ModuleTests/addXXX/test/test/Service.java
similarity index 100%
rename from jdk/test/java/lang/reflect/Module/addXXX/test/test/Service.java
rename to jdk/test/java/lang/ModuleTests/addXXX/test/test/Service.java
diff --git a/jdk/test/java/lang/reflect/Module/allow.policy b/jdk/test/java/lang/ModuleTests/allow.policy
similarity index 100%
rename from jdk/test/java/lang/reflect/Module/allow.policy
rename to jdk/test/java/lang/ModuleTests/allow.policy
diff --git a/jdk/test/java/lang/reflect/Module/annotation/Basic.java b/jdk/test/java/lang/ModuleTests/annotation/Basic.java
similarity index 98%
rename from jdk/test/java/lang/reflect/Module/annotation/Basic.java
rename to jdk/test/java/lang/ModuleTests/annotation/Basic.java
index 43733782d58..dc17cbb5e4f 100644
--- a/jdk/test/java/lang/reflect/Module/annotation/Basic.java
+++ b/jdk/test/java/lang/ModuleTests/annotation/Basic.java
@@ -29,7 +29,6 @@
* @summary Basic test for annotations on modules
*/
-import java.lang.reflect.Module;
import java.util.Arrays;
import p.annotation.Foo;
diff --git a/jdk/test/java/lang/reflect/Module/annotation/src/m/module-info.java b/jdk/test/java/lang/ModuleTests/annotation/src/m/module-info.java
similarity index 100%
rename from jdk/test/java/lang/reflect/Module/annotation/src/m/module-info.java
rename to jdk/test/java/lang/ModuleTests/annotation/src/m/module-info.java
diff --git a/jdk/test/java/lang/reflect/Module/annotation/src/m/p/annotation/Bar.java b/jdk/test/java/lang/ModuleTests/annotation/src/m/p/annotation/Bar.java
similarity index 100%
rename from jdk/test/java/lang/reflect/Module/annotation/src/m/p/annotation/Bar.java
rename to jdk/test/java/lang/ModuleTests/annotation/src/m/p/annotation/Bar.java
diff --git a/jdk/test/java/lang/reflect/Module/annotation/src/m/p/annotation/Baz.java b/jdk/test/java/lang/ModuleTests/annotation/src/m/p/annotation/Baz.java
similarity index 100%
rename from jdk/test/java/lang/reflect/Module/annotation/src/m/p/annotation/Baz.java
rename to jdk/test/java/lang/ModuleTests/annotation/src/m/p/annotation/Baz.java
diff --git a/jdk/test/java/lang/reflect/Module/annotation/src/m/p/annotation/Foo.java b/jdk/test/java/lang/ModuleTests/annotation/src/m/p/annotation/Foo.java
similarity index 100%
rename from jdk/test/java/lang/reflect/Module/annotation/src/m/p/annotation/Foo.java
rename to jdk/test/java/lang/ModuleTests/annotation/src/m/p/annotation/Foo.java
diff --git a/jdk/test/java/lang/SecurityManager/CheckPackageAccess.java b/jdk/test/java/lang/SecurityManager/CheckPackageAccess.java
index 1df260bc412..8ecf21b964f 100644
--- a/jdk/test/java/lang/SecurityManager/CheckPackageAccess.java
+++ b/jdk/test/java/lang/SecurityManager/CheckPackageAccess.java
@@ -33,7 +33,6 @@
import java.lang.module.ModuleFinder;
import java.lang.module.ModuleReference;
-import java.lang.reflect.Layer;
import java.util.Arrays;
import java.util.List;
import java.util.Optional;
@@ -82,7 +81,7 @@ public class CheckPackageAccess {
void test() {
final boolean isModulePresent =
- Layer.boot().findModule(moduleName).isPresent();
+ ModuleLayer.boot().findModule(moduleName).isPresent();
System.out.format("Testing module: %1$s. Module is%2$s present.\n",
moduleName, isModulePresent ? "" : " NOT");
diff --git a/jdk/test/java/lang/SecurityManager/CheckSecurityProvider.java b/jdk/test/java/lang/SecurityManager/CheckSecurityProvider.java
index 6aa14ca9342..7034f114aa3 100644
--- a/jdk/test/java/lang/SecurityManager/CheckSecurityProvider.java
+++ b/jdk/test/java/lang/SecurityManager/CheckSecurityProvider.java
@@ -28,7 +28,6 @@
* @run main/othervm CheckSecurityProvider
*/
-import java.lang.reflect.Layer;
import java.security.Provider;
import java.security.Security;
import java.util.ArrayList;
@@ -45,7 +44,7 @@ import java.util.stream.Stream;
*/
public class CheckSecurityProvider {
public static void main(String[] args) throws Exception {
- Layer layer = Layer.boot();
+ ModuleLayer layer = ModuleLayer.boot();
System.setSecurityManager(new SecurityManager());
diff --git a/jdk/test/java/lang/SecurityManager/modules/Test.java b/jdk/test/java/lang/SecurityManager/modules/Test.java
index 81cf617aa79..db499ff6299 100644
--- a/jdk/test/java/lang/SecurityManager/modules/Test.java
+++ b/jdk/test/java/lang/SecurityManager/modules/Test.java
@@ -21,8 +21,6 @@
* questions.
*/
-import java.lang.reflect.Module;
-
public class Test {
public static void main(String... args) {
SecurityManager sm = System.getSecurityManager();
diff --git a/jdk/test/java/lang/StackTraceElement/PublicConstructor.java b/jdk/test/java/lang/StackTraceElement/PublicConstructor.java
index 254be7825f7..7deb732e4ce 100644
--- a/jdk/test/java/lang/StackTraceElement/PublicConstructor.java
+++ b/jdk/test/java/lang/StackTraceElement/PublicConstructor.java
@@ -29,7 +29,6 @@
*/
import java.lang.module.ModuleDescriptor;
-import java.lang.reflect.Module;
public class PublicConstructor {
public static void main(String... args) {
diff --git a/jdk/test/java/lang/StackTraceElement/lib/m1/com/app/Utils.java b/jdk/test/java/lang/StackTraceElement/lib/m1/com/app/Utils.java
index 4c571af6833..ef55672ef65 100644
--- a/jdk/test/java/lang/StackTraceElement/lib/m1/com/app/Utils.java
+++ b/jdk/test/java/lang/StackTraceElement/lib/m1/com/app/Utils.java
@@ -25,7 +25,6 @@ package com.app;
import java.lang.StackWalker.StackFrame;
import java.lang.module.ModuleDescriptor;
-import java.lang.reflect.Module;
import java.util.Objects;
public class Utils {
diff --git a/jdk/test/java/lang/System/Logger/custom/CustomLoggerTest.java b/jdk/test/java/lang/System/Logger/custom/CustomLoggerTest.java
index d1653ca5f1e..4e18babd0b0 100644
--- a/jdk/test/java/lang/System/Logger/custom/CustomLoggerTest.java
+++ b/jdk/test/java/lang/System/Logger/custom/CustomLoggerTest.java
@@ -46,7 +46,6 @@ import java.lang.System.LoggerFinder;
import java.lang.System.Logger;
import java.lang.System.Logger.Level;
import java.util.stream.Stream;
-import java.lang.reflect.Module;
import java.security.AllPermission;
/**
diff --git a/jdk/test/java/lang/System/LoggerFinder/BaseLoggerFinderTest/BaseLoggerFinder.java b/jdk/test/java/lang/System/LoggerFinder/BaseLoggerFinderTest/BaseLoggerFinder.java
index 3db7cef65f8..ae07c7096a7 100644
--- a/jdk/test/java/lang/System/LoggerFinder/BaseLoggerFinderTest/BaseLoggerFinder.java
+++ b/jdk/test/java/lang/System/LoggerFinder/BaseLoggerFinderTest/BaseLoggerFinder.java
@@ -25,7 +25,6 @@ import java.security.AccessController;
import java.security.PrivilegedAction;
import java.lang.System.LoggerFinder;
import java.lang.System.Logger;
-import java.lang.reflect.Module;
public class BaseLoggerFinder extends LoggerFinder implements TestLoggerFinder {
diff --git a/jdk/test/java/lang/System/LoggerFinder/BaseLoggerFinderTest/TestLoggerFinder.java b/jdk/test/java/lang/System/LoggerFinder/BaseLoggerFinderTest/TestLoggerFinder.java
index cb86e513f90..5e08f15db4b 100644
--- a/jdk/test/java/lang/System/LoggerFinder/BaseLoggerFinderTest/TestLoggerFinder.java
+++ b/jdk/test/java/lang/System/LoggerFinder/BaseLoggerFinderTest/TestLoggerFinder.java
@@ -30,7 +30,6 @@ import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.atomic.AtomicLong;
import java.util.function.Supplier;
import java.lang.System.Logger;
-import java.lang.reflect.Module;
/**
* What our test provider needs to implement.
diff --git a/jdk/test/java/lang/System/LoggerFinder/LoggerFinderAPI/LoggerFinderAPI.java b/jdk/test/java/lang/System/LoggerFinder/LoggerFinderAPI/LoggerFinderAPI.java
index ceab7f43be7..3c8944e437a 100644
--- a/jdk/test/java/lang/System/LoggerFinder/LoggerFinderAPI/LoggerFinderAPI.java
+++ b/jdk/test/java/lang/System/LoggerFinder/LoggerFinderAPI/LoggerFinderAPI.java
@@ -28,7 +28,6 @@ import java.io.PrintStream;
import java.lang.System.Logger;
import java.lang.System.Logger.Level;
import java.lang.System.LoggerFinder;
-import java.lang.reflect.Module;
import java.util.Enumeration;
import java.util.Locale;
import java.util.Objects;
diff --git a/jdk/test/java/lang/System/LoggerFinder/internal/BaseDefaultLoggerFinderTest/BaseDefaultLoggerFinderTest.java b/jdk/test/java/lang/System/LoggerFinder/internal/BaseDefaultLoggerFinderTest/BaseDefaultLoggerFinderTest.java
index ab80d0f8bc6..ce5e714d95f 100644
--- a/jdk/test/java/lang/System/LoggerFinder/internal/BaseDefaultLoggerFinderTest/BaseDefaultLoggerFinderTest.java
+++ b/jdk/test/java/lang/System/LoggerFinder/internal/BaseDefaultLoggerFinderTest/BaseDefaultLoggerFinderTest.java
@@ -55,7 +55,6 @@ import java.util.function.Function;
import jdk.internal.logger.DefaultLoggerFinder;
import jdk.internal.logger.SimpleConsoleLogger;
import sun.util.logging.PlatformLogger;
-import java.lang.reflect.Module;
/**
* @test
diff --git a/jdk/test/java/lang/System/LoggerFinder/internal/BaseLoggerBridgeTest/BaseLoggerBridgeTest.java b/jdk/test/java/lang/System/LoggerFinder/internal/BaseLoggerBridgeTest/BaseLoggerBridgeTest.java
index d28481c305f..98ecc69e3d1 100644
--- a/jdk/test/java/lang/System/LoggerFinder/internal/BaseLoggerBridgeTest/BaseLoggerBridgeTest.java
+++ b/jdk/test/java/lang/System/LoggerFinder/internal/BaseLoggerBridgeTest/BaseLoggerBridgeTest.java
@@ -47,7 +47,6 @@ import java.lang.System.LoggerFinder;
import java.lang.System.Logger;
import java.lang.System.Logger.Level;
import java.util.stream.Stream;
-import java.lang.reflect.Module;
/**
* @test
diff --git a/jdk/test/java/lang/System/LoggerFinder/internal/BasePlatformLoggerTest/BasePlatformLoggerTest.java b/jdk/test/java/lang/System/LoggerFinder/internal/BasePlatformLoggerTest/BasePlatformLoggerTest.java
index a9e441f9d7c..af15a51eba3 100644
--- a/jdk/test/java/lang/System/LoggerFinder/internal/BasePlatformLoggerTest/BasePlatformLoggerTest.java
+++ b/jdk/test/java/lang/System/LoggerFinder/internal/BasePlatformLoggerTest/BasePlatformLoggerTest.java
@@ -47,7 +47,6 @@ import java.lang.System.Logger.Level;
import java.security.AccessControlException;
import java.util.stream.Stream;
import sun.util.logging.PlatformLogger;
-import java.lang.reflect.Module;
/**
* @test
diff --git a/jdk/test/java/lang/System/LoggerFinder/internal/BootstrapLogger/BootstrapLoggerAPIsTest.java b/jdk/test/java/lang/System/LoggerFinder/internal/BootstrapLogger/BootstrapLoggerAPIsTest.java
index 1b6a5c6e145..19b100960e5 100644
--- a/jdk/test/java/lang/System/LoggerFinder/internal/BootstrapLogger/BootstrapLoggerAPIsTest.java
+++ b/jdk/test/java/lang/System/LoggerFinder/internal/BootstrapLogger/BootstrapLoggerAPIsTest.java
@@ -30,7 +30,6 @@ import java.util.Enumeration;
import java.util.List;
import java.util.ResourceBundle;
import java.util.Set;
-import java.lang.reflect.Module;
import jdk.internal.logger.BootstrapLogger;
import jdk.internal.logger.LazyLoggers;
diff --git a/jdk/test/java/lang/System/LoggerFinder/internal/BootstrapLogger/BootstrapLoggerTest.java b/jdk/test/java/lang/System/LoggerFinder/internal/BootstrapLogger/BootstrapLoggerTest.java
index f34ab76400b..8bc016b1223 100644
--- a/jdk/test/java/lang/System/LoggerFinder/internal/BootstrapLogger/BootstrapLoggerTest.java
+++ b/jdk/test/java/lang/System/LoggerFinder/internal/BootstrapLogger/BootstrapLoggerTest.java
@@ -43,7 +43,6 @@ import java.util.stream.Collectors;
import java.util.stream.Stream;
import jdk.internal.logger.BootstrapLogger;
import jdk.internal.logger.LazyLoggers;
-import java.lang.reflect.Module;
/*
* @test
diff --git a/jdk/test/java/lang/System/LoggerFinder/internal/LoggerBridgeTest/LoggerBridgeTest.java b/jdk/test/java/lang/System/LoggerFinder/internal/LoggerBridgeTest/LoggerBridgeTest.java
index be5ad125518..bd70d541a45 100644
--- a/jdk/test/java/lang/System/LoggerFinder/internal/LoggerBridgeTest/LoggerBridgeTest.java
+++ b/jdk/test/java/lang/System/LoggerFinder/internal/LoggerBridgeTest/LoggerBridgeTest.java
@@ -51,7 +51,6 @@ import java.lang.System.Logger;
import java.lang.System.Logger.Level;
import java.util.stream.Stream;
import sun.util.logging.PlatformLogger;
-import java.lang.reflect.Module;
/**
* @test
diff --git a/jdk/test/java/lang/System/LoggerFinder/internal/LoggerFinderLoaderTest/LoggerFinderLoaderTest.java b/jdk/test/java/lang/System/LoggerFinder/internal/LoggerFinderLoaderTest/LoggerFinderLoaderTest.java
index 6343a90312c..192be7f828f 100644
--- a/jdk/test/java/lang/System/LoggerFinder/internal/LoggerFinderLoaderTest/LoggerFinderLoaderTest.java
+++ b/jdk/test/java/lang/System/LoggerFinder/internal/LoggerFinderLoaderTest/LoggerFinderLoaderTest.java
@@ -53,7 +53,6 @@ import java.util.ServiceConfigurationError;
import java.util.ServiceLoader;
import java.util.concurrent.atomic.AtomicReference;
import jdk.internal.logger.SimpleConsoleLogger;
-import java.lang.reflect.Module;
/**
* @test
diff --git a/jdk/test/java/lang/System/LoggerFinder/internal/PlatformLoggerBridgeTest/PlatformLoggerBridgeTest.java b/jdk/test/java/lang/System/LoggerFinder/internal/PlatformLoggerBridgeTest/PlatformLoggerBridgeTest.java
index 9576e17bed6..c409c22a1a3 100644
--- a/jdk/test/java/lang/System/LoggerFinder/internal/PlatformLoggerBridgeTest/PlatformLoggerBridgeTest.java
+++ b/jdk/test/java/lang/System/LoggerFinder/internal/PlatformLoggerBridgeTest/PlatformLoggerBridgeTest.java
@@ -49,7 +49,6 @@ import java.lang.System.Logger;
import java.lang.System.Logger.Level;
import java.util.stream.Stream;
import sun.util.logging.PlatformLogger;
-import java.lang.reflect.Module;
/**
* @test
diff --git a/jdk/test/java/lang/System/LoggerFinder/internal/SystemLoggerInPlatformLoader/SystemLoggerInPlatformLoader.java b/jdk/test/java/lang/System/LoggerFinder/internal/SystemLoggerInPlatformLoader/SystemLoggerInPlatformLoader.java
index 25be130d8ec..fe0f9e53e3d 100644
--- a/jdk/test/java/lang/System/LoggerFinder/internal/SystemLoggerInPlatformLoader/SystemLoggerInPlatformLoader.java
+++ b/jdk/test/java/lang/System/LoggerFinder/internal/SystemLoggerInPlatformLoader/SystemLoggerInPlatformLoader.java
@@ -28,7 +28,6 @@ import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Layer;
import java.lang.reflect.Method;
/*
@@ -106,7 +105,7 @@ public class SystemLoggerInPlatformLoader {
}
Class> platformLoggerType = platformLogger.getClass();
System.out.println("platformLogger: " + platformLoggerType);
- boolean simpleConsoleOnly = !Layer.boot().findModule("java.logging").isPresent();
+ boolean simpleConsoleOnly = !ModuleLayer.boot().findModule("java.logging").isPresent();
if (simpleConsoleOnly) {
/* Happens if the test is called with custom JDK without java.logging module
or in case usage commandline option --limit-modules java.base */
diff --git a/jdk/test/java/lang/System/LoggerFinder/internal/backend/LoggerFinderBackendTest.java b/jdk/test/java/lang/System/LoggerFinder/internal/backend/LoggerFinderBackendTest.java
index 6abc3c58e73..d2e20b354da 100644
--- a/jdk/test/java/lang/System/LoggerFinder/internal/backend/LoggerFinderBackendTest.java
+++ b/jdk/test/java/lang/System/LoggerFinder/internal/backend/LoggerFinderBackendTest.java
@@ -78,7 +78,6 @@ import java.util.logging.LogManager;
import java.util.logging.LogRecord;
import java.util.logging.Logger;
import sun.util.logging.internal.LoggingProviderImpl;
-import java.lang.reflect.Module;
/**
* @author danielfuchs
diff --git a/jdk/test/java/lang/System/LoggerFinder/jdk/DefaultLoggerBridgeTest/DefaultLoggerBridgeTest.java b/jdk/test/java/lang/System/LoggerFinder/jdk/DefaultLoggerBridgeTest/DefaultLoggerBridgeTest.java
index cba6f7b1b44..d2348a2c9dd 100644
--- a/jdk/test/java/lang/System/LoggerFinder/jdk/DefaultLoggerBridgeTest/DefaultLoggerBridgeTest.java
+++ b/jdk/test/java/lang/System/LoggerFinder/jdk/DefaultLoggerBridgeTest/DefaultLoggerBridgeTest.java
@@ -48,7 +48,6 @@ import java.lang.System.LoggerFinder;
import java.lang.System.Logger;
import java.util.stream.Stream;
import sun.util.logging.internal.LoggingProviderImpl;
-import java.lang.reflect.Module;
/**
* @test
diff --git a/jdk/test/java/lang/reflect/WeakPairMap/Driver.java b/jdk/test/java/lang/WeakPairMap/Driver.java
similarity index 91%
rename from jdk/test/java/lang/reflect/WeakPairMap/Driver.java
rename to jdk/test/java/lang/WeakPairMap/Driver.java
index f84956d687e..4009561a8e2 100644
--- a/jdk/test/java/lang/reflect/WeakPairMap/Driver.java
+++ b/jdk/test/java/lang/WeakPairMap/Driver.java
@@ -25,11 +25,11 @@
* @test
* @bug 8888888
* @summary Functional test for WeakPairMap
- * @build java.base/java.lang.reflect.WeakPairMapTest
+ * @build java.base/java.lang.WeakPairMapTest
* @run main Driver
*/
public class Driver {
public static void main(String[] args) {
- java.lang.reflect.WeakPairMapTest.main(args);
+ java.lang.WeakPairMapTest.main(args);
}
}
diff --git a/jdk/test/java/lang/reflect/WeakPairMap/java.base/java/lang/reflect/WeakPairMapTest.java b/jdk/test/java/lang/WeakPairMap/java.base/java/lang/WeakPairMapTest.java
similarity index 99%
rename from jdk/test/java/lang/reflect/WeakPairMap/java.base/java/lang/reflect/WeakPairMapTest.java
rename to jdk/test/java/lang/WeakPairMap/java.base/java/lang/WeakPairMapTest.java
index 3247bb317ac..6267d537f06 100644
--- a/jdk/test/java/lang/reflect/WeakPairMap/java.base/java/lang/reflect/WeakPairMapTest.java
+++ b/jdk/test/java/lang/WeakPairMap/java.base/java/lang/WeakPairMapTest.java
@@ -21,7 +21,7 @@
* questions.
*/
-package java.lang.reflect;
+package java.lang;
import java.lang.ref.Reference;
import java.util.Objects;
diff --git a/jdk/test/java/lang/instrument/ATransformerManagementTestCase.java b/jdk/test/java/lang/instrument/ATransformerManagementTestCase.java
index 5f88d3c9ba5..00f3447ef6a 100644
--- a/jdk/test/java/lang/instrument/ATransformerManagementTestCase.java
+++ b/jdk/test/java/lang/instrument/ATransformerManagementTestCase.java
@@ -24,8 +24,6 @@
import java.io.*;
import java.lang.instrument.*;
-
-import java.lang.reflect.Module;
import java.security.ProtectionDomain;
import java.util.*;
diff --git a/jdk/test/java/lang/instrument/BootstrapClassPathAgent.java b/jdk/test/java/lang/instrument/BootstrapClassPathAgent.java
index 96d02bfa066..6b0c71aef94 100644
--- a/jdk/test/java/lang/instrument/BootstrapClassPathAgent.java
+++ b/jdk/test/java/lang/instrument/BootstrapClassPathAgent.java
@@ -26,7 +26,6 @@ package p;
import java.io.*;
import java.lang.instrument.ClassFileTransformer;
import java.lang.instrument.Instrumentation;
-import java.lang.reflect.Module;
import java.security.ProtectionDomain;
public class BootstrapClassPathAgent {
diff --git a/jdk/test/java/lang/instrument/BootstrapClassPathTest.java b/jdk/test/java/lang/instrument/BootstrapClassPathTest.java
index bee8602308e..9f60090506d 100644
--- a/jdk/test/java/lang/instrument/BootstrapClassPathTest.java
+++ b/jdk/test/java/lang/instrument/BootstrapClassPathTest.java
@@ -33,7 +33,6 @@
import java.io.*;
import java.lang.instrument.*;
-import java.lang.reflect.Module;
import java.security.ProtectionDomain;
public class BootstrapClassPathTest {
diff --git a/jdk/test/java/lang/instrument/RedefineClassWithNativeMethodAgent.java b/jdk/test/java/lang/instrument/RedefineClassWithNativeMethodAgent.java
index b1146712f30..704b85b062f 100644
--- a/jdk/test/java/lang/instrument/RedefineClassWithNativeMethodAgent.java
+++ b/jdk/test/java/lang/instrument/RedefineClassWithNativeMethodAgent.java
@@ -24,7 +24,6 @@
import java.io.InputStream;
import java.lang.instrument.ClassDefinition;
import java.lang.instrument.Instrumentation;
-import java.lang.reflect.Module;
import java.util.Timer;
import java.util.TimerTask;
diff --git a/jdk/test/java/lang/instrument/RedefineModuleAgent.java b/jdk/test/java/lang/instrument/RedefineModuleAgent.java
index 8d96db1c205..aa38d6b21c9 100644
--- a/jdk/test/java/lang/instrument/RedefineModuleAgent.java
+++ b/jdk/test/java/lang/instrument/RedefineModuleAgent.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2016, 2017, 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,7 +22,6 @@
*/
import java.lang.instrument.Instrumentation;
-import java.lang.reflect.Module;
import java.util.List;
import java.util.Map;
import java.util.Set;
@@ -47,4 +46,8 @@ public class RedefineModuleAgent {
Map, List>> extraProvides) {
inst.redefineModule(module, extraReads, extraExports, extraOpens, extraUses, extraProvides);
}
+
+ static boolean isModifiableModule(Module module) {
+ return inst.isModifiableModule(module);
+ }
}
diff --git a/jdk/test/java/lang/instrument/RedefineModuleTest.java b/jdk/test/java/lang/instrument/RedefineModuleTest.java
index b3f79ba4cd1..60ae18f7d09 100644
--- a/jdk/test/java/lang/instrument/RedefineModuleTest.java
+++ b/jdk/test/java/lang/instrument/RedefineModuleTest.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2016, 2017, 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
@@ -34,8 +34,6 @@
import java.lang.TestProvider;
import java.lang.instrument.Instrumentation;
-import java.lang.reflect.Layer;
-import java.lang.reflect.Module;
import java.net.URLStreamHandler;
import java.net.spi.URLStreamHandlerProvider;
import java.nio.file.FileSystems;
@@ -68,6 +66,10 @@ public class RedefineModuleTest {
extraProvides);
}
+ static boolean isModifiableModule(Module module) {
+ return RedefineModuleAgent.isModifiableModule(module);
+ }
+
/**
* Use redefineModule to update java.base to read java.instrument
@@ -138,13 +140,13 @@ public class RedefineModuleTest {
// pre-conditions
assertFalse(baseModule.canUse(service));
assertTrue(collect(ServiceLoader.load(service)).isEmpty());
- assertTrue(collect(ServiceLoader.load(Layer.boot(), service)).isEmpty());
+ assertTrue(collect(ServiceLoader.load(ModuleLayer.boot(), service)).isEmpty());
// update java.base to use TestProvider
redefineModule(baseModule, Set.of(), Map.of(), Map.of(), Set.of(service), Map.of());
assertTrue(baseModule.canUse(service));
assertTrue(collect(ServiceLoader.load(service)).isEmpty());
- assertTrue(collect(ServiceLoader.load(Layer.boot(), service)).isEmpty());
+ assertTrue(collect(ServiceLoader.load(ModuleLayer.boot(), service)).isEmpty());
// update java.base to provide an implementation of TestProvider
Class> type1 = Class.forName("jdk.internal.test.TestProviderImpl1");
@@ -162,7 +164,7 @@ public class RedefineModuleTest {
assertTrue(containsInstanceOf(collect(providers), type1));
// use ServiceLoader to load implementations in the boot layer
- providers = collect(ServiceLoader.load(Layer.boot(), service));
+ providers = collect(ServiceLoader.load(ModuleLayer.boot(), service));
assertTrue(collect(providers).size() == 1);
assertTrue(containsInstanceOf(collect(providers), type1));
@@ -184,7 +186,7 @@ public class RedefineModuleTest {
assertTrue(containsInstanceOf(providers, type2));
// use ServiceLoader to load implementations in the boot layer
- providers = collect(ServiceLoader.load(Layer.boot(), service));
+ providers = collect(ServiceLoader.load(ModuleLayer.boot(), service));
assertTrue(collect(providers).size() == 2);
assertTrue(containsInstanceOf(providers, type1));
assertTrue(containsInstanceOf(providers, type2));
@@ -278,6 +280,19 @@ public class RedefineModuleTest {
redefineModule(baseModule, Set.of(), Map.of(), Map.of(), Set.of(), extraProvides);
}
+ /**
+ * Exercise IsModifiableModule
+ */
+ @Test
+ public void testIsModifiableModule() {
+ ClassLoader pcl = ClassLoader.getPlatformClassLoader();
+ ClassLoader scl = ClassLoader.getSystemClassLoader();
+ assertTrue(isModifiableModule(pcl.getUnnamedModule()));
+ assertTrue(isModifiableModule(scl.getUnnamedModule()));
+ assertTrue(isModifiableModule(RedefineModuleTest.class.getModule()));
+ assertTrue(isModifiableModule(Object.class.getModule()));
+ }
+
/**
* Test redefineClass with null
*/
diff --git a/jdk/test/java/lang/instrument/RetransformAgent.java b/jdk/test/java/lang/instrument/RetransformAgent.java
index cdba17efc6d..698449cac14 100644
--- a/jdk/test/java/lang/instrument/RetransformAgent.java
+++ b/jdk/test/java/lang/instrument/RetransformAgent.java
@@ -34,7 +34,6 @@
*/
import java.lang.instrument.*;
-import java.lang.reflect.Module;
import java.security.ProtectionDomain;
import java.io.*;
import asmlib.*;
diff --git a/jdk/test/java/lang/instrument/SimpleIdentityTransformer.java b/jdk/test/java/lang/instrument/SimpleIdentityTransformer.java
index 78e05fcb41b..f25e679596a 100644
--- a/jdk/test/java/lang/instrument/SimpleIdentityTransformer.java
+++ b/jdk/test/java/lang/instrument/SimpleIdentityTransformer.java
@@ -24,7 +24,6 @@
import java.lang.instrument.Instrumentation;
import java.lang.instrument.ClassFileTransformer;
-import java.lang.reflect.Module;
import java.security.*;
/*
diff --git a/jdk/test/java/lang/invoke/MethodHandles/privateLookupIn/test/p/PrivateLookupInTests.java b/jdk/test/java/lang/invoke/MethodHandles/privateLookupIn/test/p/PrivateLookupInTests.java
index f2391743bd0..869a655d0e3 100644
--- a/jdk/test/java/lang/invoke/MethodHandles/privateLookupIn/test/p/PrivateLookupInTests.java
+++ b/jdk/test/java/lang/invoke/MethodHandles/privateLookupIn/test/p/PrivateLookupInTests.java
@@ -26,7 +26,6 @@ import java.lang.invoke.MethodHandle;
import java.lang.invoke.MethodHandles;
import java.lang.invoke.MethodHandles.Lookup;
import java.lang.reflect.Modifier;
-import java.lang.reflect.Module;
import static java.lang.invoke.MethodHandles.Lookup.*;
diff --git a/jdk/test/java/lang/invoke/modules/m1/p1/Main.java b/jdk/test/java/lang/invoke/modules/m1/p1/Main.java
index 7a10022d78f..d708d74aa50 100644
--- a/jdk/test/java/lang/invoke/modules/m1/p1/Main.java
+++ b/jdk/test/java/lang/invoke/modules/m1/p1/Main.java
@@ -27,8 +27,6 @@ import java.lang.invoke.MethodHandle;
import java.lang.invoke.MethodHandles;
import java.lang.invoke.MethodHandles.Lookup;
import java.lang.invoke.MethodType;
-import java.lang.reflect.Layer;
-import java.lang.reflect.Module;
import static java.lang.invoke.MethodHandles.Lookup.*;
@@ -64,14 +62,14 @@ public class Main {
}
// check setup
- Module m1 = Layer.boot().findModule("m1").orElse(null);
+ Module m1 = ModuleLayer.boot().findModule("m1").orElse(null);
assertNotNull(m1);
assertTrue(p1_Type1.getModule() == m1);
assertTrue(p2_Type2.getModule() == m1);
assertTrue(m1.isExported("p1"));
assertFalse(m1.isExported("p2"));
- Module m2 = Layer.boot().findModule("m2").orElse(null);
+ Module m2 = ModuleLayer.boot().findModule("m2").orElse(null);
assertNotNull(m2);
assertTrue(q1_Type1.getModule() == m2);
assertTrue(q2_Type2.getModule() == m2);
diff --git a/jdk/test/java/lang/module/AutomaticModulesTest.java b/jdk/test/java/lang/module/AutomaticModulesTest.java
index 81d68973ffe..4fce2beb558 100644
--- a/jdk/test/java/lang/module/AutomaticModulesTest.java
+++ b/jdk/test/java/lang/module/AutomaticModulesTest.java
@@ -38,8 +38,6 @@ import java.lang.module.ModuleFinder;
import java.lang.module.ModuleReference;
import java.lang.module.ResolutionException;
import java.lang.module.ResolvedModule;
-import java.lang.reflect.Layer;
-import java.lang.reflect.Module;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
@@ -69,13 +67,8 @@ public class AutomaticModulesTest {
{ "foo.jar", "foo" },
{ "foo4j.jar", "foo4j", },
- { "foo1.jar", "foo" },
- { "foo1.2.jar", "foo" },
- { "foo1.2.3.jar", "foo" },
-
- { "foo10.jar", "foo" },
- { "foo10.20.jar", "foo" },
- { "foo10.20.30.jar", "foo" },
+ { "foo1.jar", "foo1" },
+ { "foo10.jar", "foo10" },
{ "foo-1.jar", "foo/1" },
{ "foo-1.2.jar", "foo/1.2" },
@@ -93,6 +86,9 @@ public class AutomaticModulesTest {
{ "foo-bar-10.jar", "foo.bar/10" },
{ "foo-bar-10.20.jar", "foo.bar/10.20" },
+ { "foo.bar1.jar", "foo.bar1" },
+ { "foo.bar10.jar", "foo.bar10" },
+
{ "foo-1.2-SNAPSHOT.jar", "foo/1.2-SNAPSHOT" },
{ "foo-bar-1.2-SNAPSHOT.jar", "foo.bar/1.2-SNAPSHOT" },
@@ -108,8 +104,12 @@ public class AutomaticModulesTest {
public Object[][] createBadNames() {
return new Object[][]{
- { ".jar", null },
- { "_.jar", null }
+ { ".jar", null },
+ { "_.jar", null },
+
+ { "foo.1.jar", null },
+ { "1foo.jar", null },
+ { "foo.1bar.jar", null },
};
}
@@ -389,7 +389,7 @@ public class AutomaticModulesTest {
ModuleFinder finder = ModuleFinder.of(dir);
- Configuration parent = Layer.boot().configuration();
+ Configuration parent = ModuleLayer.boot().configuration();
Configuration cf = resolve(parent, finder, "m");
ModuleDescriptor descriptor = findDescriptor(cf, "m");
@@ -469,11 +469,11 @@ public class AutomaticModulesTest {
createDummyJarFile(dir.resolve("c.jar"), "q/T.class");
// module finder locates a and the modules in the directory
- ModuleFinder finder
- = ModuleFinder.compose(ModuleUtils.finderOf(descriptor1),
- ModuleFinder.of(dir));
+ ModuleFinder finder1 = ModuleUtils.finderOf(descriptor1);
+ ModuleFinder finder2 = ModuleFinder.of(dir);
+ ModuleFinder finder = ModuleFinder.compose(finder1, finder2);
- Configuration parent = Layer.boot().configuration();
+ Configuration parent = ModuleLayer.boot().configuration();
Configuration cf = resolve(parent, finder, "a");
assertTrue(cf.modules().size() == 3);
@@ -482,7 +482,7 @@ public class AutomaticModulesTest {
assertTrue(cf.findModule("c").isPresent());
ResolvedModule base = cf.findModule("java.base").get();
- assertTrue(base.configuration() == Layer.boot().configuration());
+ assertTrue(base.configuration() == ModuleLayer.boot().configuration());
ResolvedModule a = cf.findModule("a").get();
ResolvedModule b = cf.findModule("b").get();
ResolvedModule c = cf.findModule("c").get();
@@ -534,11 +534,11 @@ public class AutomaticModulesTest {
createDummyJarFile(dir.resolve("d.jar"), "q/T.class");
// module finder locates a and the modules in the directory
- ModuleFinder finder
- = ModuleFinder.compose(ModuleUtils.finderOf(descriptor1, descriptor2),
- ModuleFinder.of(dir));
+ ModuleFinder finder1 = ModuleUtils.finderOf(descriptor1, descriptor2);
+ ModuleFinder finder2 = ModuleFinder.of(dir);
+ ModuleFinder finder = ModuleFinder.compose(finder1, finder2);
- Configuration parent = Layer.boot().configuration();
+ Configuration parent = ModuleLayer.boot().configuration();
Configuration cf = resolve(parent, finder, "a", "d");
assertTrue(cf.modules().size() == 4);
@@ -554,7 +554,7 @@ public class AutomaticModulesTest {
// readability
ResolvedModule base = cf.findModule("java.base").get();
- assertTrue(base.configuration() == Layer.boot().configuration());
+ assertTrue(base.configuration() == ModuleLayer.boot().configuration());
ResolvedModule a = cf.findModule("a").get();
ResolvedModule b = cf.findModule("b").get();
ResolvedModule c = cf.findModule("c").get();
@@ -607,11 +607,11 @@ public class AutomaticModulesTest {
createDummyJarFile(dir.resolve("d.jar"), "q/T.class");
// module finder locates a and the modules in the directory
- ModuleFinder finder
- = ModuleFinder.compose(ModuleUtils.finderOf(descriptor1, descriptor2),
- ModuleFinder.of(dir));
+ ModuleFinder finder1 = ModuleUtils.finderOf(descriptor1, descriptor2);
+ ModuleFinder finder2 = ModuleFinder.of(dir);
+ ModuleFinder finder = ModuleFinder.compose(finder1, finder2);
- Configuration parent = Layer.boot().configuration();
+ Configuration parent = ModuleLayer.boot().configuration();
Configuration cf = resolve(parent, finder, "a", "d");
assertTrue(cf.modules().size() == 4);
@@ -621,7 +621,7 @@ public class AutomaticModulesTest {
assertTrue(cf.findModule("d").isPresent());
ResolvedModule base = cf.findModule("java.base").get();
- assertTrue(base.configuration() == Layer.boot().configuration());
+ assertTrue(base.configuration() == ModuleLayer.boot().configuration());
ResolvedModule a = cf.findModule("a").get();
ResolvedModule b = cf.findModule("b").get();
ResolvedModule c = cf.findModule("c").get();
@@ -660,6 +660,189 @@ public class AutomaticModulesTest {
}
+ /**
+ * Basic test to ensure that no automatic modules are resolved when
+ * an automatic module is not a root or required by other modules.
+ */
+ public void testInConfiguration4() throws IOException {
+ ModuleDescriptor descriptor1
+ = ModuleDescriptor.newModule("m1")
+ .requires("java.base")
+ .build();
+
+ // automatic modules
+ Path dir = Files.createTempDirectory(USER_DIR, "mods");
+ createDummyJarFile(dir.resolve("auto1.jar"), "p1/C.class");
+ createDummyJarFile(dir.resolve("auto2.jar"), "p2/C.class");
+ createDummyJarFile(dir.resolve("auto3.jar"), "p3/C.class");
+
+ // module finder locates m1 and the modules in the directory
+ ModuleFinder finder1 = ModuleUtils.finderOf(descriptor1);
+ ModuleFinder finder2 = ModuleFinder.of(dir);
+ ModuleFinder finder = ModuleFinder.compose(finder1, finder2);
+
+ Configuration parent = ModuleLayer.boot().configuration();
+ Configuration cf = resolve(parent, finder, "m1");
+
+ // ensure that no automatic module is resolved
+ assertTrue(cf.modules().size() == 1);
+ assertTrue(cf.findModule("m1").isPresent());
+ }
+
+
+ /**
+ * Basic test to ensure that if an automatic module is resolved then
+ * all observable automatic modules are resolved.
+ */
+ public void testInConfiguration5() throws IOException {
+ // m1 requires m2
+ ModuleDescriptor descriptor1
+ = ModuleDescriptor.newModule("m1")
+ .requires("m2").build();
+
+ // m2 requires automatic module
+ ModuleDescriptor descriptor2
+ = ModuleDescriptor.newModule("m2")
+ .requires("auto1")
+ .build();
+
+ // automatic modules
+ Path dir = Files.createTempDirectory(USER_DIR, "mods");
+ createDummyJarFile(dir.resolve("auto1.jar"), "p1/C.class");
+ createDummyJarFile(dir.resolve("auto2.jar"), "p2/C.class");
+ createDummyJarFile(dir.resolve("auto3.jar"), "p3/C.class");
+
+ // module finder locates m1, m2, and the modules in the directory
+ ModuleFinder finder1 = ModuleUtils.finderOf(descriptor1, descriptor2);
+ ModuleFinder finder2 = ModuleFinder.of(dir);
+ ModuleFinder finder = ModuleFinder.compose(finder1, finder2);
+
+ Configuration parent = ModuleLayer.boot().configuration();
+ Configuration cf = resolve(parent, finder, "m1");
+
+ // all automatic modules should be resolved
+ assertTrue(cf.modules().size() == 5);
+ assertTrue(cf.findModule("m1").isPresent());
+ assertTrue(cf.findModule("m2").isPresent());
+ assertTrue(cf.findModule("auto1").isPresent());
+ assertTrue(cf.findModule("auto2").isPresent());
+ assertTrue(cf.findModule("auto3").isPresent());
+
+ ResolvedModule base = parent.findModule("java.base")
+ .orElseThrow(() -> new RuntimeException());
+ ResolvedModule m1 = cf.findModule("m1").get();
+ ResolvedModule m2 = cf.findModule("m2").get();
+ ResolvedModule auto1 = cf.findModule("auto1").get();
+ ResolvedModule auto2 = cf.findModule("auto2").get();
+ ResolvedModule auto3 = cf.findModule("auto3").get();
+
+ // m1 does not read the automatic modules
+ assertTrue(m1.reads().size() == 2);
+ assertTrue(m1.reads().contains(m2));
+ assertTrue(m1.reads().contains(base));
+
+ // m2 should read all the automatic modules
+ assertTrue(m2.reads().size() == 4);
+ assertTrue(m2.reads().contains(auto1));
+ assertTrue(m2.reads().contains(auto2));
+ assertTrue(m2.reads().contains(auto3));
+ assertTrue(m2.reads().contains(base));
+
+ assertTrue(auto1.reads().contains(m1));
+ assertTrue(auto1.reads().contains(m2));
+ assertTrue(auto1.reads().contains(auto2));
+ assertTrue(auto1.reads().contains(auto3));
+ assertTrue(auto1.reads().contains(base));
+
+ assertTrue(auto2.reads().contains(m1));
+ assertTrue(auto2.reads().contains(m2));
+ assertTrue(auto2.reads().contains(auto1));
+ assertTrue(auto2.reads().contains(auto3));
+ assertTrue(auto2.reads().contains(base));
+
+ assertTrue(auto3.reads().contains(m1));
+ assertTrue(auto3.reads().contains(m2));
+ assertTrue(auto3.reads().contains(auto1));
+ assertTrue(auto3.reads().contains(auto2));
+ assertTrue(auto3.reads().contains(base));
+ }
+
+
+ /**
+ * Basic test of automatic modules in a child configuration. All automatic
+ * modules that are found with the before finder should be resolved. The
+ * automatic modules that are found by the after finder and not shadowed
+ * by the before finder, or parent configurations, should also be resolved.
+ */
+ public void testInConfiguration6() throws IOException {
+ // m1 requires auto1
+ ModuleDescriptor descriptor1
+ = ModuleDescriptor.newModule("m1")
+ .requires("auto1")
+ .build();
+
+ Path dir = Files.createTempDirectory(USER_DIR, "mods");
+ createDummyJarFile(dir.resolve("auto1.jar"), "p1/C.class");
+
+ // module finder locates m1 and auto1
+ ModuleFinder finder1 = ModuleUtils.finderOf(descriptor1);
+ ModuleFinder finder2 = ModuleFinder.of(dir);
+ ModuleFinder finder = ModuleFinder.compose(finder1, finder2);
+
+ Configuration parent = ModuleLayer.boot().configuration();
+ Configuration cf1 = resolve(parent, finder, "m1");
+
+ assertTrue(cf1.modules().size() == 2);
+ assertTrue(cf1.findModule("m1").isPresent());
+ assertTrue(cf1.findModule("auto1").isPresent());
+
+ ResolvedModule base = parent.findModule("java.base")
+ .orElseThrow(() -> new RuntimeException());
+ ResolvedModule m1 = cf1.findModule("m1").get();
+ ResolvedModule auto1 = cf1.findModule("auto1").get();
+
+ assertTrue(m1.reads().size() == 2);
+ assertTrue(m1.reads().contains(auto1));
+ assertTrue(m1.reads().contains(base));
+
+ assertTrue(auto1.reads().contains(m1));
+ assertTrue(auto1.reads().contains(base));
+
+
+ // create child configuration - the after finder locates auto1
+
+ dir = Files.createTempDirectory(USER_DIR, "mods");
+ createDummyJarFile(dir.resolve("auto2.jar"), "p2/C.class");
+ ModuleFinder beforeFinder = ModuleFinder.of(dir);
+
+ dir = Files.createTempDirectory(USER_DIR, "mods");
+ createDummyJarFile(dir.resolve("auto1.jar"), "p1/C.class");
+ createDummyJarFile(dir.resolve("auto2.jar"), "p2/C.class");
+ createDummyJarFile(dir.resolve("auto3.jar"), "p3/C.class");
+ ModuleFinder afterFinder = ModuleFinder.of(dir);
+
+ Configuration cf2 = cf1.resolve(beforeFinder, afterFinder, Set.of("auto2"));
+
+ // auto1 should be found in parent and should not be in cf2
+ assertTrue(cf2.modules().size() == 2);
+ assertTrue(cf2.findModule("auto2").isPresent());
+ assertTrue(cf2.findModule("auto3").isPresent());
+
+ ResolvedModule auto2 = cf2.findModule("auto2").get();
+ ResolvedModule auto3 = cf2.findModule("auto3").get();
+
+ assertTrue(auto2.reads().contains(m1));
+ assertTrue(auto2.reads().contains(auto1));
+ assertTrue(auto2.reads().contains(auto3));
+ assertTrue(auto2.reads().contains(base));
+
+ assertTrue(auto3.reads().contains(m1));
+ assertTrue(auto3.reads().contains(auto1));
+ assertTrue(auto3.reads().contains(auto2));
+ assertTrue(auto3.reads().contains(base));
+ }
+
+
/**
* Basic test of a configuration created with automatic modules
* a requires b* and c*
@@ -684,7 +867,7 @@ public class AutomaticModulesTest {
= ModuleFinder.compose(ModuleUtils.finderOf(descriptor),
ModuleFinder.of(dir));
- Configuration parent = Layer.boot().configuration();
+ Configuration parent = ModuleLayer.boot().configuration();
resolve(parent, finder, "a");
}
@@ -711,13 +894,13 @@ public class AutomaticModulesTest {
= ModuleFinder.compose(ModuleUtils.finderOf(descriptor),
ModuleFinder.of(dir));
- Configuration parent = Layer.boot().configuration();
+ Configuration parent = ModuleLayer.boot().configuration();
resolve(parent, finder, "a");
}
/**
- * Basic test of Layer containing automatic modules
+ * Basic test of layer containing automatic modules
*/
public void testInLayer() throws IOException {
ModuleDescriptor descriptor
@@ -736,12 +919,12 @@ public class AutomaticModulesTest {
= ModuleFinder.compose(ModuleUtils.finderOf(descriptor),
ModuleFinder.of(dir));
- Configuration parent = Layer.boot().configuration();
+ Configuration parent = ModuleLayer.boot().configuration();
Configuration cf = resolve(parent, finder, "a");
assertTrue(cf.modules().size() == 3);
// each module gets its own loader
- Layer layer = Layer.boot().defineModules(cf, mn -> new ClassLoader() { });
+ ModuleLayer layer = ModuleLayer.boot().defineModules(cf, mn -> new ClassLoader() { });
// an unnamed module
Module unnamed = (new ClassLoader() { }).getUnnamedModule();
@@ -804,7 +987,7 @@ public class AutomaticModulesTest {
*/
static void testReadAllBootModules(Configuration cf, String mn) {
- Set bootModules = Layer.boot().modules().stream()
+ Set bootModules = ModuleLayer.boot().modules().stream()
.map(Module::getName)
.collect(Collectors.toSet());
@@ -813,10 +996,10 @@ public class AutomaticModulesTest {
}
/**
- * Test that the given Module reads all module in the given Layer
- * and its parent Layers.
+ * Test that the given Module reads all module in the given layer
+ * and its parent layers.
*/
- static void testsReadsAll(Module m, Layer layer) {
+ static void testsReadsAll(Module m, ModuleLayer layer) {
// check that m reads all modules in the layer
layer.configuration().modules().stream()
.map(ResolvedModule::name)
diff --git a/jdk/test/java/lang/module/ConfigurationTest.java b/jdk/test/java/lang/module/ConfigurationTest.java
index d010ca30060..d59612d8638 100644
--- a/jdk/test/java/lang/module/ConfigurationTest.java
+++ b/jdk/test/java/lang/module/ConfigurationTest.java
@@ -40,7 +40,6 @@ import java.lang.module.ModuleDescriptor.Requires;
import java.lang.module.ModuleFinder;
import java.lang.module.ResolutionException;
import java.lang.module.ResolvedModule;
-import java.lang.reflect.Layer;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.List;
@@ -1708,7 +1707,7 @@ public class ConfigurationTest {
ModuleFinder finder = ModuleUtils.finderOf(descriptor);
- Configuration bootConfiguration = Layer.boot().configuration();
+ Configuration bootConfiguration = ModuleLayer.boot().configuration();
// m1 contains package java.lang, java.base exports package java.lang to m1
resolve(bootConfiguration, finder, "m1");
@@ -1989,14 +1988,14 @@ public class ConfigurationTest {
@Test(expectedExceptions = { NullPointerException.class })
public void testResolveRequiresWithNull5() {
- Configuration cf = Layer.boot().configuration();
+ Configuration cf = ModuleLayer.boot().configuration();
Configuration.resolve(ModuleFinder.of(), List.of(cf), null, Set.of());
}
@Test(expectedExceptions = { NullPointerException.class })
public void testResolveRequiresWithNull6() {
ModuleFinder empty = ModuleFinder.of();
- Configuration cf = Layer.boot().configuration();
+ Configuration cf = ModuleLayer.boot().configuration();
Configuration.resolve(empty, List.of(cf), empty, null);
}
@@ -2024,14 +2023,14 @@ public class ConfigurationTest {
@Test(expectedExceptions = { NullPointerException.class })
public void testResolveRequiresAndUsesWithNull5() {
- Configuration cf = Layer.boot().configuration();
+ Configuration cf = ModuleLayer.boot().configuration();
Configuration.resolveAndBind(ModuleFinder.of(), List.of(cf), null, Set.of());
}
@Test(expectedExceptions = { NullPointerException.class })
public void testResolveRequiresAndUsesWithNull6() {
ModuleFinder empty = ModuleFinder.of();
- Configuration cf = Layer.boot().configuration();
+ Configuration cf = ModuleLayer.boot().configuration();
Configuration.resolveAndBind(empty, List.of(cf), empty, null);
}
@@ -2044,14 +2043,14 @@ public class ConfigurationTest {
@Test(expectedExceptions = { UnsupportedOperationException.class })
public void testImmutableSet1() {
- Configuration cf = Layer.boot().configuration();
+ Configuration cf = ModuleLayer.boot().configuration();
ResolvedModule base = cf.findModule("java.base").get();
cf.modules().add(base);
}
@Test(expectedExceptions = { UnsupportedOperationException.class })
public void testImmutableSet2() {
- Configuration cf = Layer.boot().configuration();
+ Configuration cf = ModuleLayer.boot().configuration();
ResolvedModule base = cf.findModule("java.base").get();
base.reads().add(base);
}
diff --git a/jdk/test/java/lang/module/ModuleDescriptorTest.java b/jdk/test/java/lang/module/ModuleDescriptorTest.java
index 2bd63497141..f4726a59a2f 100644
--- a/jdk/test/java/lang/module/ModuleDescriptorTest.java
+++ b/jdk/test/java/lang/module/ModuleDescriptorTest.java
@@ -41,7 +41,6 @@ import java.lang.module.ModuleDescriptor.Requires;
import java.lang.module.ModuleDescriptor.Provides;
import java.lang.module.ModuleDescriptor.Requires.Modifier;
import java.lang.module.ModuleDescriptor.Version;
-import java.lang.reflect.Module;
import java.nio.ByteBuffer;
import java.util.ArrayList;
import java.util.Collections;
diff --git a/jdk/test/java/lang/module/ModuleFinderTest.java b/jdk/test/java/lang/module/ModuleFinderTest.java
index 3f87883277e..79feee5694b 100644
--- a/jdk/test/java/lang/module/ModuleFinderTest.java
+++ b/jdk/test/java/lang/module/ModuleFinderTest.java
@@ -528,6 +528,30 @@ public class ModuleFinderTest {
}
+ /**
+ * Test ModuleFinder.of with a directory containing hidden files
+ */
+ public void testOfWithHiddenFiles() throws Exception {
+ Path dir = Files.createTempDirectory(USER_DIR, "mods");
+ createExplodedModule(dir.resolve("m"), "m",
+ "com/.ignore",
+ "com/foo/.ignore",
+ "com/foo/foo.properties");
+
+ ModuleFinder finder = ModuleFinder.of(dir);
+ ModuleReference mref = finder.find("m").orElse(null);
+ assertNotNull(mref);
+
+ Set expectedPackages;
+ if (System.getProperty("os.name").startsWith("Windows")) {
+ expectedPackages = Set.of("com", "com.foo");
+ } else {
+ expectedPackages = Set.of("com.foo");
+ }
+ assertEquals(mref.descriptor().packages(), expectedPackages);
+ }
+
+
/**
* Test ModuleFinder.of with a truncated module-info.class
*/
diff --git a/jdk/test/java/lang/module/ModuleReader/ModuleReaderTest.java b/jdk/test/java/lang/module/ModuleReader/ModuleReaderTest.java
index 6e895354357..773b114f338 100644
--- a/jdk/test/java/lang/module/ModuleReader/ModuleReaderTest.java
+++ b/jdk/test/java/lang/module/ModuleReader/ModuleReaderTest.java
@@ -37,7 +37,6 @@ import java.io.InputStream;
import java.lang.module.ModuleFinder;
import java.lang.module.ModuleReader;
import java.lang.module.ModuleReference;
-import java.lang.reflect.Module;
import java.net.URI;
import java.net.URL;
import java.net.URLConnection;
diff --git a/jdk/test/java/lang/reflect/AccessibleObject/ModuleSetAccessibleTest.java b/jdk/test/java/lang/reflect/AccessibleObject/ModuleSetAccessibleTest.java
index 3e2bf3911c7..a287e6f6807 100644
--- a/jdk/test/java/lang/reflect/AccessibleObject/ModuleSetAccessibleTest.java
+++ b/jdk/test/java/lang/reflect/AccessibleObject/ModuleSetAccessibleTest.java
@@ -36,7 +36,6 @@ import java.lang.reflect.Field;
import java.lang.reflect.InaccessibleObjectException;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
-import java.lang.reflect.Module;
import jdk.internal.misc.Unsafe;
diff --git a/jdk/test/java/lang/reflect/Proxy/ProxyClassAccessTest.java b/jdk/test/java/lang/reflect/Proxy/ProxyClassAccessTest.java
index 3ef48cd79fa..da7b16938f0 100644
--- a/jdk/test/java/lang/reflect/Proxy/ProxyClassAccessTest.java
+++ b/jdk/test/java/lang/reflect/Proxy/ProxyClassAccessTest.java
@@ -23,7 +23,6 @@
import java.lang.module.Configuration;
import java.lang.module.ModuleFinder;
-import java.lang.reflect.Layer;
import java.lang.reflect.Proxy;
import java.nio.file.Path;
import java.nio.file.Paths;
@@ -88,12 +87,12 @@ public class ProxyClassAccessTest {
@Test
public void testNoReadAccess() throws Exception {
ModuleFinder finder = ModuleFinder.of(MODS_DIR);
- Layer bootLayer = Layer.boot();
+ ModuleLayer bootLayer = ModuleLayer.boot();
Configuration cf = bootLayer
.configuration()
.resolveAndBind(ModuleFinder.of(), finder, modules);
ClassLoader parentLoader = this.getClass().getClassLoader();
- Layer layer = bootLayer.defineModulesWithOneLoader(cf, parentLoader);
+ ModuleLayer layer = bootLayer.defineModulesWithOneLoader(cf, parentLoader);
ClassLoader loader = layer.findLoader("m1");
Class>[] interfaces = new Class>[] {
diff --git a/jdk/test/java/lang/reflect/Proxy/ProxyForMethodHandle.java b/jdk/test/java/lang/reflect/Proxy/ProxyForMethodHandle.java
index 1c45901783d..a5877018705 100644
--- a/jdk/test/java/lang/reflect/Proxy/ProxyForMethodHandle.java
+++ b/jdk/test/java/lang/reflect/Proxy/ProxyForMethodHandle.java
@@ -28,7 +28,6 @@ import java.lang.invoke.MethodType;
import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationHandler;
import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Module;
import org.testng.annotations.BeforeTest;
import org.testng.annotations.Test;
diff --git a/jdk/test/java/lang/reflect/Proxy/ProxyLayerTest.java b/jdk/test/java/lang/reflect/Proxy/ProxyLayerTest.java
index 767afd23323..c420ab4ee99 100644
--- a/jdk/test/java/lang/reflect/Proxy/ProxyLayerTest.java
+++ b/jdk/test/java/lang/reflect/Proxy/ProxyLayerTest.java
@@ -24,7 +24,6 @@
import java.lang.module.Configuration;
import java.lang.module.ModuleFinder;
import java.lang.reflect.InvocationHandler;
-import java.lang.reflect.Layer;
import java.lang.reflect.Proxy;
import java.nio.file.Path;
import java.nio.file.Paths;
@@ -70,18 +69,18 @@ public class ProxyLayerTest {
}
/**
- * Test proxy implementing interfaces in a Layer defined in
+ * Test proxy implementing interfaces in a layer defined in
* an unnamed module
*/
@Test
public void testProxyInUnnamed() throws Exception {
ModuleFinder finder = ModuleFinder.of(MODS_DIR);
- Layer bootLayer = Layer.boot();
+ ModuleLayer bootLayer = ModuleLayer.boot();
Configuration cf = bootLayer
.configuration()
.resolveAndBind(ModuleFinder.of(), finder, Arrays.asList(modules));
ClassLoader scl = ClassLoader.getSystemClassLoader();
- Layer layer = bootLayer.defineModulesWithOneLoader(cf, scl);
+ ModuleLayer layer = bootLayer.defineModulesWithOneLoader(cf, scl);
ClassLoader loader = layer.findLoader("m1");
@@ -110,12 +109,12 @@ public class ProxyLayerTest {
@Test
public void testProxyInDynamicModule() throws Exception {
ModuleFinder finder = ModuleFinder.of(MODS_DIR);
- Layer bootLayer = Layer.boot();
+ ModuleLayer bootLayer = ModuleLayer.boot();
Configuration cf = bootLayer
.configuration()
.resolveAndBind(ModuleFinder.of(), finder, Arrays.asList(modules));
ClassLoader scl = ClassLoader.getSystemClassLoader();
- Layer layer = bootLayer.defineModulesWithOneLoader(cf, scl);
+ ModuleLayer layer = bootLayer.defineModulesWithOneLoader(cf, scl);
ClassLoader loader = layer.findLoader("m1");
@@ -140,12 +139,12 @@ public class ProxyLayerTest {
@Test
public void testNoReadAccess() throws Exception {
ModuleFinder finder = ModuleFinder.of(MODS_DIR);
- Layer bootLayer = Layer.boot();
+ ModuleLayer bootLayer = ModuleLayer.boot();
Configuration cf = bootLayer
.configuration()
.resolveAndBind(ModuleFinder.of(), finder, Arrays.asList(modules));
ClassLoader scl = ClassLoader.getSystemClassLoader();
- Layer layer = bootLayer.defineModulesWithOneLoader(cf, scl);
+ ModuleLayer layer = bootLayer.defineModulesWithOneLoader(cf, scl);
ClassLoader loader = layer.findLoader("m1");
diff --git a/jdk/test/java/lang/reflect/Proxy/ProxyModuleMapping.java b/jdk/test/java/lang/reflect/Proxy/ProxyModuleMapping.java
index bd8d1b042b3..4985adf97ac 100644
--- a/jdk/test/java/lang/reflect/Proxy/ProxyModuleMapping.java
+++ b/jdk/test/java/lang/reflect/Proxy/ProxyModuleMapping.java
@@ -23,7 +23,6 @@
import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationHandler;
-import java.lang.reflect.Module;
import java.lang.reflect.Proxy;
/*
diff --git a/jdk/test/java/lang/reflect/Proxy/src/test/jdk/test/Main.java b/jdk/test/java/lang/reflect/Proxy/src/test/jdk/test/Main.java
index 188e3d9e084..0a342d25c78 100644
--- a/jdk/test/java/lang/reflect/Proxy/src/test/jdk/test/Main.java
+++ b/jdk/test/java/lang/reflect/Proxy/src/test/jdk/test/Main.java
@@ -25,7 +25,6 @@ package jdk.test;
import java.net.URL;
import java.net.URLClassLoader;
-import java.lang.reflect.Module;
import static jdk.test.ProxyTest.*;
public class Main {
diff --git a/jdk/test/java/lang/reflect/Proxy/src/test/jdk/test/ProxyTest.java b/jdk/test/java/lang/reflect/Proxy/src/test/jdk/test/ProxyTest.java
index bbe260bf159..ee5c0241bae 100644
--- a/jdk/test/java/lang/reflect/Proxy/src/test/jdk/test/ProxyTest.java
+++ b/jdk/test/java/lang/reflect/Proxy/src/test/jdk/test/ProxyTest.java
@@ -26,7 +26,6 @@ package jdk.test;
import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationHandler;
import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Module;
import java.lang.reflect.Proxy;
import java.util.Arrays;
diff --git a/jdk/test/java/nio/channels/SocketChannel/VectorIO.java b/jdk/test/java/nio/channels/SocketChannel/VectorIO.java
index 4242be4dfa2..907d1b21716 100644
--- a/jdk/test/java/nio/channels/SocketChannel/VectorIO.java
+++ b/jdk/test/java/nio/channels/SocketChannel/VectorIO.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 2017, 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,8 +22,10 @@
*/
/* @test
- * @summary Test socketchannel vector IO
- * @library ..
+ * @summary Test socketchannel vector IO (use -Dseed=X to set PRNG seed)
+ * @library .. /lib/testlibrary/
+ * @build jdk.testlibrary.RandomFactory
+ * @run main VectorIO
* @key randomness
*/
@@ -32,11 +34,11 @@ import java.net.*;
import java.nio.*;
import java.nio.channels.*;
import java.util.*;
-
+import jdk.testlibrary.RandomFactory;
public class VectorIO {
- static Random generator = new Random();
+ private static Random generator = RandomFactory.getRandom();
static int testSize;
@@ -100,8 +102,6 @@ public class VectorIO {
static class Server
extends TestThread
{
- static Random generator = new Random();
-
final int testSize;
final ServerSocketChannel ssc;
diff --git a/jdk/test/java/nio/channels/etc/AdaptorCloseAndInterrupt.java b/jdk/test/java/nio/channels/etc/AdaptorCloseAndInterrupt.java
index 3e48ace3274..368437a3803 100644
--- a/jdk/test/java/nio/channels/etc/AdaptorCloseAndInterrupt.java
+++ b/jdk/test/java/nio/channels/etc/AdaptorCloseAndInterrupt.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2012, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 2017, 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
@@ -36,6 +36,7 @@ import java.util.concurrent.Callable;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;
+import java.util.concurrent.atomic.AtomicBoolean;
import java.util.Random;
@@ -46,6 +47,9 @@ public class AdaptorCloseAndInterrupt {
final DatagramChannel peer;
final int port;
+ final AtomicBoolean isClosed = new AtomicBoolean();
+ final AtomicBoolean isInterrupted = new AtomicBoolean();
+
public AdaptorCloseAndInterrupt() {
listener = null;
peer = null;
@@ -96,6 +100,7 @@ public class AdaptorCloseAndInterrupt {
try {
sc.socket().getInputStream().read(new byte[100]);
+ System.err.format("close() was invoked: %s%n", isClosed.get());
throw new RuntimeException("read should not have completed");
} catch (ClosedChannelException expected) {}
@@ -119,7 +124,10 @@ public class AdaptorCloseAndInterrupt {
sc.socket().getInputStream().read(new byte[100]);
throw new RuntimeException("read should not have completed");
} catch (ClosedByInterruptException expected) {
- Thread.currentThread().interrupted();
+ System.out.format("interrupt() was invoked: %s%n",
+ isInterrupted.get());
+ System.out.format("scReadAsyncInterrupt was interrupted: %s%n",
+ Thread.currentThread().interrupted());
}
if (!sc.socket().isClosed())
@@ -140,6 +148,7 @@ public class AdaptorCloseAndInterrupt {
try {
dc.socket().receive(new DatagramPacket(new byte[100], 100));
+ System.err.format("close() was invoked: %s%n", isClosed.get());
throw new RuntimeException("receive should not have completed");
} catch (ClosedChannelException expected) {}
@@ -159,7 +168,16 @@ public class AdaptorCloseAndInterrupt {
dc.socket().receive(new DatagramPacket(new byte[100], 100));
throw new RuntimeException("receive should not have completed");
} catch (ClosedByInterruptException expected) {
- Thread.currentThread().interrupted();
+ System.out.format("interrupt() was invoked: %s%n",
+ isInterrupted.get());
+ System.out.format("dcReceiveAsyncInterrupt was interrupted: %s%n",
+ Thread.currentThread().interrupted());
+ } catch (SocketTimeoutException unexpected) {
+ System.err.format("Receive thread interrupt invoked: %s%n",
+ isInterrupted.get());
+ System.err.format("Receive thread was interrupted: %s%n",
+ Thread.currentThread().isInterrupted());
+ throw unexpected;
}
if (!dc.socket().isClosed())
@@ -175,6 +193,7 @@ public class AdaptorCloseAndInterrupt {
try {
ssc.socket().accept();
+ System.err.format("close() was invoked: %s%n", isClosed.get());
throw new RuntimeException("accept should not have completed");
} catch (ClosedChannelException expected) {}
@@ -193,7 +212,10 @@ public class AdaptorCloseAndInterrupt {
ssc.socket().accept();
throw new RuntimeException("accept should not have completed");
} catch (ClosedByInterruptException expected) {
- Thread.currentThread().interrupted();
+ System.out.format("interrupt() was invoked: %s%n",
+ isInterrupted.get());
+ System.out.format("ssAcceptAsyncInterrupt was interrupted: %s%n",
+ Thread.currentThread().interrupted());
}
if (!ssc.socket().isClosed())
@@ -204,6 +226,7 @@ public class AdaptorCloseAndInterrupt {
AdaptorCloseAndInterrupt.pool.schedule(new Callable() {
public Void call() throws Exception {
sc.close();
+ isClosed.set(true);
return null;
}
}, new Random().nextInt(1000), TimeUnit.MILLISECONDS);
@@ -214,6 +237,7 @@ public class AdaptorCloseAndInterrupt {
AdaptorCloseAndInterrupt.pool.schedule(new Callable() {
public Void call() throws Exception {
current.interrupt();
+ isInterrupted.set(true);
return null;
}
}, new Random().nextInt(1000), TimeUnit.MILLISECONDS);
diff --git a/jdk/test/java/security/Provider/DefaultProviderList.java b/jdk/test/java/security/Provider/DefaultProviderList.java
index 4aaeffeeacf..9a015b0b340 100644
--- a/jdk/test/java/security/Provider/DefaultProviderList.java
+++ b/jdk/test/java/security/Provider/DefaultProviderList.java
@@ -33,7 +33,6 @@ import java.security.Security;
import java.util.Arrays;
import java.util.Iterator;
import java.util.ServiceLoader;
-import java.lang.reflect.Module;
public class DefaultProviderList {
diff --git a/jdk/test/java/util/ResourceBundle/modules/cache/src/test/jdk/test/Main.java b/jdk/test/java/util/ResourceBundle/modules/cache/src/test/jdk/test/Main.java
index a6ae87208bd..234e841f691 100644
--- a/jdk/test/java/util/ResourceBundle/modules/cache/src/test/jdk/test/Main.java
+++ b/jdk/test/java/util/ResourceBundle/modules/cache/src/test/jdk/test/Main.java
@@ -23,7 +23,6 @@
package jdk.test;
-import java.lang.reflect.Module;
import java.util.MissingResourceException;
import java.util.ResourceBundle;
@@ -56,4 +55,4 @@ public class Main {
jdk.test.util.Bundles.getBundle();
}
}
-}
\ No newline at end of file
+}
diff --git a/jdk/test/java/util/ResourceBundle/modules/casesensitive/CaseInsensitiveNameClash.java b/jdk/test/java/util/ResourceBundle/modules/casesensitive/CaseInsensitiveNameClash.java
new file mode 100644
index 00000000000..b3eef5d3d6c
--- /dev/null
+++ b/jdk/test/java/util/ResourceBundle/modules/casesensitive/CaseInsensitiveNameClash.java
@@ -0,0 +1,72 @@
+/*
+ * Copyright (c) 2017, 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 8177980
+ * @library /lib/testlibrary
+ * @modules jdk.compiler
+ * @build CompilerUtils jdk.testlibrary.ProcessTools CaseInsensitiveNameClash
+ * @run testng CaseInsensitiveNameClash
+ */
+
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import jdk.testlibrary.ProcessTools;
+
+import org.testng.annotations.BeforeTest;
+import org.testng.annotations.Test;
+import static org.testng.Assert.*;
+
+public class CaseInsensitiveNameClash {
+
+ private static final String TEST_SRC = System.getProperty("test.src");
+
+ private static final Path SRC_DIR = Paths.get(TEST_SRC, "src");
+ private static final Path MODS_DIR = Paths.get("mods");
+
+ private static final String MODULE = "resbundle";
+ private static final String MAIN_CLASS = MODULE + "/jdk.test.Main";
+
+ /**
+ * Compiles the module used by the test
+ */
+ @BeforeTest
+ public void compileAll() throws Exception {
+ Path msrc = SRC_DIR.resolve(MODULE);
+ assertTrue(CompilerUtils.compile(msrc, MODS_DIR,
+ "--module-source-path", SRC_DIR.toString()));
+ Path propsFile = Paths.get("jdk", "test", "main.properties");
+ Files.copy(msrc.resolve(propsFile), MODS_DIR.resolve(MODULE).resolve(propsFile));
+ }
+
+ @Test
+ public void test() throws Exception {
+ assertTrue(ProcessTools.executeTestJava("--module-path", MODS_DIR.toString(),
+ "-m", MAIN_CLASS)
+ .outputTo(System.out)
+ .errorTo(System.out)
+ .getExitValue() == 0);
+ }
+}
diff --git a/jdk/test/java/util/ResourceBundle/modules/casesensitive/src/resbundle/jdk/test/Main.java b/jdk/test/java/util/ResourceBundle/modules/casesensitive/src/resbundle/jdk/test/Main.java
new file mode 100644
index 00000000000..73ff726bd3c
--- /dev/null
+++ b/jdk/test/java/util/ResourceBundle/modules/casesensitive/src/resbundle/jdk/test/Main.java
@@ -0,0 +1,35 @@
+/*
+ * Copyright (c) 2017, 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.
+ */
+
+package jdk.test;
+
+import java.util.ResourceBundle;
+
+public class Main {
+ public static void main(String[] args) throws Exception {
+ ResourceBundle bundle = ResourceBundle.getBundle("jdk.test.main");
+ if (!bundle.getString("key").equals("value")) {
+ throw new RuntimeException("Expected: value but get " + bundle.getString("key"));
+ }
+ }
+}
diff --git a/jdk/test/java/util/ResourceBundle/modules/casesensitive/src/resbundle/jdk/test/main.properties b/jdk/test/java/util/ResourceBundle/modules/casesensitive/src/resbundle/jdk/test/main.properties
new file mode 100644
index 00000000000..7b89edbafe4
--- /dev/null
+++ b/jdk/test/java/util/ResourceBundle/modules/casesensitive/src/resbundle/jdk/test/main.properties
@@ -0,0 +1 @@
+key=value
diff --git a/jdk/test/java/util/ResourceBundle/modules/casesensitive/src/resbundle/module-info.java b/jdk/test/java/util/ResourceBundle/modules/casesensitive/src/resbundle/module-info.java
new file mode 100644
index 00000000000..fdb2838915d
--- /dev/null
+++ b/jdk/test/java/util/ResourceBundle/modules/casesensitive/src/resbundle/module-info.java
@@ -0,0 +1,25 @@
+/*
+ * Copyright (c) 2017, 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.
+ */
+
+module resbundle {
+}
diff --git a/jdk/test/java/util/ResourceBundle/modules/security/src/test/jdk/test/Main.java b/jdk/test/java/util/ResourceBundle/modules/security/src/test/jdk/test/Main.java
index ecea6abd576..88b9222f137 100644
--- a/jdk/test/java/util/ResourceBundle/modules/security/src/test/jdk/test/Main.java
+++ b/jdk/test/java/util/ResourceBundle/modules/security/src/test/jdk/test/Main.java
@@ -24,7 +24,6 @@
package jdk.test;
import p1.Bundle;
-import java.lang.reflect.Module;
import java.util.ResourceBundle;
public class Main {
diff --git a/jdk/test/java/util/ResourceBundle/modules/visibility/src/embargo/jdk/embargo/TestWithNoModuleArg.java b/jdk/test/java/util/ResourceBundle/modules/visibility/src/embargo/jdk/embargo/TestWithNoModuleArg.java
index 5e100abc89b..1b7aef1ecdd 100644
--- a/jdk/test/java/util/ResourceBundle/modules/visibility/src/embargo/jdk/embargo/TestWithNoModuleArg.java
+++ b/jdk/test/java/util/ResourceBundle/modules/visibility/src/embargo/jdk/embargo/TestWithNoModuleArg.java
@@ -23,7 +23,6 @@
package jdk.embargo;
-import java.lang.reflect.Module;
import java.util.Locale;
import java.util.MissingResourceException;
import java.util.ResourceBundle;
diff --git a/jdk/test/java/util/ResourceBundle/modules/visibility/src/embargo/jdk/embargo/TestWithUnnamedModuleArg.java b/jdk/test/java/util/ResourceBundle/modules/visibility/src/embargo/jdk/embargo/TestWithUnnamedModuleArg.java
index 8f2ca8e1206..b2df284acfc 100644
--- a/jdk/test/java/util/ResourceBundle/modules/visibility/src/embargo/jdk/embargo/TestWithUnnamedModuleArg.java
+++ b/jdk/test/java/util/ResourceBundle/modules/visibility/src/embargo/jdk/embargo/TestWithUnnamedModuleArg.java
@@ -23,7 +23,6 @@
package jdk.embargo;
-import java.lang.reflect.Module;
import java.util.Locale;
import java.util.MissingResourceException;
import java.util.ResourceBundle;
diff --git a/jdk/test/java/util/ResourceBundle/modules/visibility/src/pkg/jdk/pkg/test/Main.java b/jdk/test/java/util/ResourceBundle/modules/visibility/src/pkg/jdk/pkg/test/Main.java
index 54ac2e7d686..8706ab2838b 100644
--- a/jdk/test/java/util/ResourceBundle/modules/visibility/src/pkg/jdk/pkg/test/Main.java
+++ b/jdk/test/java/util/ResourceBundle/modules/visibility/src/pkg/jdk/pkg/test/Main.java
@@ -23,7 +23,6 @@
package jdk.pkg.test;
-import java.lang.reflect.Module;
import java.util.Locale;
import java.util.MissingResourceException;
import java.util.ResourceBundle;
diff --git a/jdk/test/java/util/ResourceBundle/modules/visibility/src/test/jdk/test/TestWithNoModuleArg.java b/jdk/test/java/util/ResourceBundle/modules/visibility/src/test/jdk/test/TestWithNoModuleArg.java
index 19de28a8be1..3a16a412b1c 100644
--- a/jdk/test/java/util/ResourceBundle/modules/visibility/src/test/jdk/test/TestWithNoModuleArg.java
+++ b/jdk/test/java/util/ResourceBundle/modules/visibility/src/test/jdk/test/TestWithNoModuleArg.java
@@ -23,7 +23,6 @@
package jdk.test;
-import java.lang.reflect.Module;
import java.util.Locale;
import java.util.MissingResourceException;
import java.util.ResourceBundle;
diff --git a/jdk/test/java/util/ResourceBundle/modules/visibility/src/test/jdk/test/TestWithUnnamedModuleArg.java b/jdk/test/java/util/ResourceBundle/modules/visibility/src/test/jdk/test/TestWithUnnamedModuleArg.java
index d36b53f864a..fc6cd208f2c 100644
--- a/jdk/test/java/util/ResourceBundle/modules/visibility/src/test/jdk/test/TestWithUnnamedModuleArg.java
+++ b/jdk/test/java/util/ResourceBundle/modules/visibility/src/test/jdk/test/TestWithUnnamedModuleArg.java
@@ -23,7 +23,6 @@
package jdk.test;
-import java.lang.reflect.Module;
import java.util.Locale;
import java.util.MissingResourceException;
import java.util.ResourceBundle;
diff --git a/jdk/test/java/util/ServiceLoader/modules/BadProvidersTest.java b/jdk/test/java/util/ServiceLoader/modules/BadProvidersTest.java
index 8d3c2d27d3a..a1bf4abf099 100644
--- a/jdk/test/java/util/ServiceLoader/modules/BadProvidersTest.java
+++ b/jdk/test/java/util/ServiceLoader/modules/BadProvidersTest.java
@@ -33,7 +33,6 @@
import java.lang.module.Configuration;
import java.lang.module.ModuleFinder;
-import java.lang.reflect.Layer;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
@@ -87,14 +86,14 @@ public class BadProvidersTest {
private List loadProviders(Path mp, String moduleName) throws Exception {
ModuleFinder finder = ModuleFinder.of(mp);
- Layer bootLayer = Layer.boot();
+ ModuleLayer bootLayer = ModuleLayer.boot();
Configuration cf = bootLayer.configuration()
.resolveAndBind(finder, ModuleFinder.of(), Set.of(moduleName));
ClassLoader scl = ClassLoader.getSystemClassLoader();
- Layer layer = Layer.boot().defineModulesWithOneLoader(cf, scl);
+ ModuleLayer layer = ModuleLayer.boot().defineModulesWithOneLoader(cf, scl);
Class> service = layer.findLoader(moduleName).loadClass(TEST_SERVICE);
diff --git a/jdk/test/java/util/ServiceLoader/modules/Basic.java b/jdk/test/java/util/ServiceLoader/modules/Basic.java
index d697db6e993..75e30bc4413 100644
--- a/jdk/test/java/util/ServiceLoader/modules/Basic.java
+++ b/jdk/test/java/util/ServiceLoader/modules/Basic.java
@@ -34,7 +34,6 @@
import java.lang.module.Configuration;
import java.lang.module.ModuleFinder;
-import java.lang.reflect.Layer;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
@@ -229,7 +228,7 @@ public class Basic {
*/
@Test
public void testWithCustomLayer1() {
- Layer layer = createCustomLayer("bananascript");
+ ModuleLayer layer = createCustomLayer("bananascript");
ClassLoader loader = layer.findLoader("bananascript");
List providers
@@ -258,7 +257,7 @@ public class Basic {
*/
@Test
public void testWithCustomLayer2() {
- Layer layer = createCustomLayer("bananascript");
+ ModuleLayer layer = createCustomLayer("bananascript");
List factories
= collectAll(ServiceLoader.load(layer, ScriptEngineFactory.class));
@@ -293,7 +292,7 @@ public class Basic {
*/
@Test
public void testWithCustomLayer3() {
- Layer bootLayer = Layer.boot();
+ ModuleLayer bootLayer = ModuleLayer.boot();
Configuration cf0 = bootLayer.configuration();
// boot layer should contain "bananascript"
@@ -313,12 +312,12 @@ public class Basic {
// layer1
Configuration cf1 = cf0.resolveAndBind(finder, ModuleFinder.of(), Set.of());
- Layer layer1 = bootLayer.defineModulesWithOneLoader(cf1, scl);
+ ModuleLayer layer1 = bootLayer.defineModulesWithOneLoader(cf1, scl);
assertTrue(layer1.modules().size() == 1);
// layer2
Configuration cf2 = cf0.resolveAndBind(finder, ModuleFinder.of(), Set.of());
- Layer layer2 = bootLayer.defineModulesWithOneLoader(cf2, scl);
+ ModuleLayer layer2 = bootLayer.defineModulesWithOneLoader(cf2, scl);
assertTrue(layer2.modules().size() == 1);
// layer3 with layer1 and layer2 as parents
@@ -326,7 +325,8 @@ public class Basic {
List.of(cf1, cf2),
ModuleFinder.of(),
Set.of());
- Layer layer3 = Layer.defineModulesWithOneLoader(cf3, List.of(layer1, layer2), scl).layer();
+ ModuleLayer layer3
+ = ModuleLayer.defineModulesWithOneLoader(cf3, List.of(layer1, layer2), scl).layer();
assertTrue(layer3.modules().size() == 1);
@@ -390,12 +390,12 @@ public class Basic {
@Test(expectedExceptions = { NullPointerException.class })
public void testLoadNull3() {
class S { }
- ServiceLoader.load((Layer) null, S.class);
+ ServiceLoader.load((ModuleLayer) null, S.class);
}
@Test(expectedExceptions = { NullPointerException.class })
public void testLoadNull4() {
- ServiceLoader.load(Layer.empty(), null);
+ ServiceLoader.load(ModuleLayer.empty(), null);
}
@Test(expectedExceptions = { NullPointerException.class })
@@ -404,19 +404,19 @@ public class Basic {
}
/**
- * Create a custom Layer by resolving the given module names. The modules
+ * Create a custom layer by resolving the given module names. The modules
* are located in the {@code ${test.classes}/modules} directory.
*/
- private Layer createCustomLayer(String... modules) {
+ private ModuleLayer createCustomLayer(String... modules) {
Path dir = Paths.get(System.getProperty("test.classes", "."), "modules");
ModuleFinder finder = ModuleFinder.of(dir);
Set roots = new HashSet<>();
Collections.addAll(roots, modules);
- Layer bootLayer = Layer.boot();
+ ModuleLayer bootLayer = ModuleLayer.boot();
Configuration parent = bootLayer.configuration();
Configuration cf = parent.resolve(finder, ModuleFinder.of(), roots);
ClassLoader scl = ClassLoader.getSystemClassLoader();
- Layer layer = bootLayer.defineModulesWithOneLoader(cf, scl);
+ ModuleLayer layer = bootLayer.defineModulesWithOneLoader(cf, scl);
assertTrue(layer.modules().size() == 1);
return layer;
}
diff --git a/jdk/test/java/util/concurrent/tck/ArrayDeque8Test.java b/jdk/test/java/util/concurrent/tck/ArrayDeque8Test.java
index 0a7f26bfe64..c2079555218 100644
--- a/jdk/test/java/util/concurrent/tck/ArrayDeque8Test.java
+++ b/jdk/test/java/util/concurrent/tck/ArrayDeque8Test.java
@@ -37,7 +37,6 @@ import java.util.Collections;
import java.util.Spliterator;
import junit.framework.Test;
-import junit.framework.TestSuite;
public class ArrayDeque8Test extends JSR166TestCase {
public static void main(String[] args) {
diff --git a/jdk/test/java/util/concurrent/tck/ArrayDequeTest.java b/jdk/test/java/util/concurrent/tck/ArrayDequeTest.java
index 1bbd98106ac..344b63c9b79 100644
--- a/jdk/test/java/util/concurrent/tck/ArrayDequeTest.java
+++ b/jdk/test/java/util/concurrent/tck/ArrayDequeTest.java
@@ -35,7 +35,6 @@
import java.util.ArrayDeque;
import java.util.Arrays;
import java.util.Collection;
-import java.util.Collections;
import java.util.Deque;
import java.util.Iterator;
import java.util.NoSuchElementException;
@@ -44,7 +43,6 @@ import java.util.Random;
import java.util.concurrent.ThreadLocalRandom;
import junit.framework.Test;
-import junit.framework.TestSuite;
public class ArrayDequeTest extends JSR166TestCase {
public static void main(String[] args) {
diff --git a/jdk/test/java/util/concurrent/tck/ArrayListTest.java b/jdk/test/java/util/concurrent/tck/ArrayListTest.java
index 193b4af8aca..535f04d34b5 100644
--- a/jdk/test/java/util/concurrent/tck/ArrayListTest.java
+++ b/jdk/test/java/util/concurrent/tck/ArrayListTest.java
@@ -33,11 +33,9 @@
*/
import java.util.ArrayList;
-import java.util.Collection;
import java.util.List;
import junit.framework.Test;
-import junit.framework.TestSuite;
public class ArrayListTest extends JSR166TestCase {
public static void main(String[] args) {
diff --git a/jdk/test/java/util/concurrent/tck/AtomicReferenceFieldUpdaterTest.java b/jdk/test/java/util/concurrent/tck/AtomicReferenceFieldUpdaterTest.java
index fb50658ea91..5fdf279238c 100644
--- a/jdk/test/java/util/concurrent/tck/AtomicReferenceFieldUpdaterTest.java
+++ b/jdk/test/java/util/concurrent/tck/AtomicReferenceFieldUpdaterTest.java
@@ -75,7 +75,7 @@ public class AtomicReferenceFieldUpdaterTest extends JSR166TestCase {
assertTrue(a.compareAndSet(this, two, m4));
assertSame(m4, a.get(this));
assertFalse(a.compareAndSet(this, m5, seven));
- assertFalse(seven == a.get(this));
+ assertNotSame(seven, a.get(this));
assertTrue(a.compareAndSet(this, m4, seven));
assertSame(seven, a.get(this));
}
@@ -208,7 +208,7 @@ public class AtomicReferenceFieldUpdaterTest extends JSR166TestCase {
assertTrue(a.compareAndSet(this, two, m4));
assertSame(m4, a.get(this));
assertFalse(a.compareAndSet(this, m5, seven));
- assertFalse(seven == a.get(this));
+ assertNotSame(seven, a.get(this));
assertTrue(a.compareAndSet(this, m4, seven));
assertSame(seven, a.get(this));
}
diff --git a/jdk/test/java/util/concurrent/tck/AtomicReferenceTest.java b/jdk/test/java/util/concurrent/tck/AtomicReferenceTest.java
index 6242374ee89..eb8c0b7b565 100644
--- a/jdk/test/java/util/concurrent/tck/AtomicReferenceTest.java
+++ b/jdk/test/java/util/concurrent/tck/AtomicReferenceTest.java
@@ -153,7 +153,7 @@ public class AtomicReferenceTest extends JSR166TestCase {
AtomicReference z = serialClone(x);
assertNotSame(y, z);
assertEquals(one, x.get());
- assertEquals(null, y.get());
+ assertNull(y.get());
assertEquals(one, z.get());
}
diff --git a/jdk/test/java/util/concurrent/tck/CompletableFutureTest.java b/jdk/test/java/util/concurrent/tck/CompletableFutureTest.java
index 6def2fffb3a..6439a40fcb0 100644
--- a/jdk/test/java/util/concurrent/tck/CompletableFutureTest.java
+++ b/jdk/test/java/util/concurrent/tck/CompletableFutureTest.java
@@ -2589,28 +2589,28 @@ public class CompletableFutureTest extends JSR166TestCase {
// unspecified behavior - both source completions available
try {
- assertEquals(null, h0.join());
+ assertNull(h0.join());
rs[0].assertValue(v1);
} catch (CompletionException ok) {
checkCompletedWithWrappedException(h0, ex);
rs[0].assertNotInvoked();
}
try {
- assertEquals(null, h1.join());
+ assertNull(h1.join());
rs[1].assertValue(v1);
} catch (CompletionException ok) {
checkCompletedWithWrappedException(h1, ex);
rs[1].assertNotInvoked();
}
try {
- assertEquals(null, h2.join());
+ assertNull(h2.join());
rs[2].assertValue(v1);
} catch (CompletionException ok) {
checkCompletedWithWrappedException(h2, ex);
rs[2].assertNotInvoked();
}
try {
- assertEquals(null, h3.join());
+ assertNull(h3.join());
rs[3].assertValue(v1);
} catch (CompletionException ok) {
checkCompletedWithWrappedException(h3, ex);
@@ -2849,28 +2849,28 @@ public class CompletableFutureTest extends JSR166TestCase {
// unspecified behavior - both source completions available
try {
- assertEquals(null, h0.join());
+ assertNull(h0.join());
rs[0].assertInvoked();
} catch (CompletionException ok) {
checkCompletedWithWrappedException(h0, ex);
rs[0].assertNotInvoked();
}
try {
- assertEquals(null, h1.join());
+ assertNull(h1.join());
rs[1].assertInvoked();
} catch (CompletionException ok) {
checkCompletedWithWrappedException(h1, ex);
rs[1].assertNotInvoked();
}
try {
- assertEquals(null, h2.join());
+ assertNull(h2.join());
rs[2].assertInvoked();
} catch (CompletionException ok) {
checkCompletedWithWrappedException(h2, ex);
rs[2].assertNotInvoked();
}
try {
- assertEquals(null, h3.join());
+ assertNull(h3.join());
rs[3].assertInvoked();
} catch (CompletionException ok) {
checkCompletedWithWrappedException(h3, ex);
diff --git a/jdk/test/java/util/concurrent/tck/ConcurrentHashMap8Test.java b/jdk/test/java/util/concurrent/tck/ConcurrentHashMap8Test.java
index 00f8dc6bb28..e0d9f81a7f1 100644
--- a/jdk/test/java/util/concurrent/tck/ConcurrentHashMap8Test.java
+++ b/jdk/test/java/util/concurrent/tck/ConcurrentHashMap8Test.java
@@ -237,8 +237,8 @@ public class ConcurrentHashMap8Test extends JSR166TestCase {
Set set1 = map.keySet();
Set set2 = map.keySet(true);
set2.add(six);
- assertTrue(((ConcurrentHashMap.KeySetView)set2).getMap() == map);
- assertTrue(((ConcurrentHashMap.KeySetView)set1).getMap() == map);
+ assertSame(map, ((ConcurrentHashMap.KeySetView)set2).getMap());
+ assertSame(map, ((ConcurrentHashMap.KeySetView)set1).getMap());
assertEquals(set2.size(), map.size());
assertEquals(set1.size(), map.size());
assertTrue((Boolean)map.get(six));
@@ -332,10 +332,10 @@ public class ConcurrentHashMap8Test extends JSR166TestCase {
assertFalse(set.add(one));
assertTrue(set.add(six));
assertTrue(set.add(seven));
- assertTrue(set.getMappedValue() == one);
- assertTrue(map.get(one) != one);
- assertTrue(map.get(six) == one);
- assertTrue(map.get(seven) == one);
+ assertSame(one, set.getMappedValue());
+ assertNotSame(one, map.get(one));
+ assertSame(one, map.get(six));
+ assertSame(one, map.get(seven));
}
void checkSpliteratorCharacteristics(Spliterator> sp,
diff --git a/jdk/test/java/util/concurrent/tck/ConcurrentHashMapTest.java b/jdk/test/java/util/concurrent/tck/ConcurrentHashMapTest.java
index 1485d2c4dca..729a6e3d146 100644
--- a/jdk/test/java/util/concurrent/tck/ConcurrentHashMapTest.java
+++ b/jdk/test/java/util/concurrent/tck/ConcurrentHashMapTest.java
@@ -43,8 +43,6 @@ import java.util.Map;
import java.util.Random;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Executors;
import junit.framework.Test;
import junit.framework.TestSuite;
@@ -148,7 +146,7 @@ public class ConcurrentHashMapTest extends JSR166TestCase {
ConcurrentHashMap m =
new ConcurrentHashMap();
for (int i = 0; i < size; i++) {
- assertTrue(m.put(new CI(i), true) == null);
+ assertNull(m.put(new CI(i), true));
}
for (int i = 0; i < size; i++) {
assertTrue(m.containsKey(new CI(i)));
@@ -169,7 +167,7 @@ public class ConcurrentHashMapTest extends JSR166TestCase {
BS bs = new BS(String.valueOf(i));
LexicographicList bis = new LexicographicList(bi);
LexicographicList bss = new LexicographicList(bs);
- assertTrue(m.putIfAbsent(bis, true) == null);
+ assertNull(m.putIfAbsent(bis, true));
assertTrue(m.containsKey(bis));
if (m.putIfAbsent(bss, true) == null)
assertTrue(m.containsKey(bss));
diff --git a/jdk/test/java/util/concurrent/tck/ConcurrentLinkedDequeTest.java b/jdk/test/java/util/concurrent/tck/ConcurrentLinkedDequeTest.java
index aac0bb73910..8a8ffeb6ff9 100644
--- a/jdk/test/java/util/concurrent/tck/ConcurrentLinkedDequeTest.java
+++ b/jdk/test/java/util/concurrent/tck/ConcurrentLinkedDequeTest.java
@@ -43,7 +43,6 @@ import java.util.Random;
import java.util.concurrent.ConcurrentLinkedDeque;
import junit.framework.Test;
-import junit.framework.TestSuite;
public class ConcurrentLinkedDequeTest extends JSR166TestCase {
@@ -67,7 +66,7 @@ public class ConcurrentLinkedDequeTest extends JSR166TestCase {
* Returns a new deque of given size containing consecutive
* Integers 0 ... n - 1.
*/
- private ConcurrentLinkedDeque populatedDeque(int n) {
+ private static ConcurrentLinkedDeque populatedDeque(int n) {
ConcurrentLinkedDeque q = new ConcurrentLinkedDeque<>();
assertTrue(q.isEmpty());
for (int i = 0; i < n; ++i)
diff --git a/jdk/test/java/util/concurrent/tck/ConcurrentLinkedQueueTest.java b/jdk/test/java/util/concurrent/tck/ConcurrentLinkedQueueTest.java
index 57689cce48d..ee6827a660f 100644
--- a/jdk/test/java/util/concurrent/tck/ConcurrentLinkedQueueTest.java
+++ b/jdk/test/java/util/concurrent/tck/ConcurrentLinkedQueueTest.java
@@ -41,7 +41,6 @@ import java.util.Queue;
import java.util.concurrent.ConcurrentLinkedQueue;
import junit.framework.Test;
-import junit.framework.TestSuite;
public class ConcurrentLinkedQueueTest extends JSR166TestCase {
@@ -65,7 +64,7 @@ public class ConcurrentLinkedQueueTest extends JSR166TestCase {
* Returns a new queue of given size containing consecutive
* Integers 0 ... n - 1.
*/
- private ConcurrentLinkedQueue populatedQueue(int n) {
+ private static ConcurrentLinkedQueue populatedQueue(int n) {
ConcurrentLinkedQueue q = new ConcurrentLinkedQueue<>();
assertTrue(q.isEmpty());
for (int i = 0; i < n; ++i)
diff --git a/jdk/test/java/util/concurrent/tck/ConcurrentSkipListSetTest.java b/jdk/test/java/util/concurrent/tck/ConcurrentSkipListSetTest.java
index ae91219f622..cb28b6ae0e7 100644
--- a/jdk/test/java/util/concurrent/tck/ConcurrentSkipListSetTest.java
+++ b/jdk/test/java/util/concurrent/tck/ConcurrentSkipListSetTest.java
@@ -64,7 +64,7 @@ public class ConcurrentSkipListSetTest extends JSR166TestCase {
* Returns a new set of given size containing consecutive
* Integers 0 ... n - 1.
*/
- private ConcurrentSkipListSet populatedSet(int n) {
+ private static ConcurrentSkipListSet populatedSet(int n) {
ConcurrentSkipListSet q =
new ConcurrentSkipListSet();
assertTrue(q.isEmpty());
@@ -80,7 +80,7 @@ public class ConcurrentSkipListSetTest extends JSR166TestCase {
/**
* Returns a new set of first 5 ints.
*/
- private ConcurrentSkipListSet set5() {
+ private static ConcurrentSkipListSet set5() {
ConcurrentSkipListSet q = new ConcurrentSkipListSet();
assertTrue(q.isEmpty());
q.add(one);
@@ -229,7 +229,7 @@ public class ConcurrentSkipListSetTest extends JSR166TestCase {
} catch (ClassCastException success) {
assertTrue(q.size() < 2);
for (int i = 0, size = q.size(); i < size; i++)
- assertTrue(q.pollFirst().getClass() == Object.class);
+ assertSame(Object.class, q.pollFirst().getClass());
assertNull(q.pollFirst());
assertTrue(q.isEmpty());
assertEquals(0, q.size());
diff --git a/jdk/test/java/util/concurrent/tck/ConcurrentSkipListSubSetTest.java b/jdk/test/java/util/concurrent/tck/ConcurrentSkipListSubSetTest.java
index 4b299e74b83..19d34cc01e1 100644
--- a/jdk/test/java/util/concurrent/tck/ConcurrentSkipListSubSetTest.java
+++ b/jdk/test/java/util/concurrent/tck/ConcurrentSkipListSubSetTest.java
@@ -59,7 +59,7 @@ public class ConcurrentSkipListSubSetTest extends JSR166TestCase {
* Returns a new set of given size containing consecutive
* Integers 0 ... n - 1.
*/
- private NavigableSet populatedSet(int n) {
+ private static NavigableSet populatedSet(int n) {
ConcurrentSkipListSet q =
new ConcurrentSkipListSet();
assertTrue(q.isEmpty());
@@ -79,7 +79,7 @@ public class ConcurrentSkipListSubSetTest extends JSR166TestCase {
/**
* Returns a new set of first 5 ints.
*/
- private NavigableSet set5() {
+ private static NavigableSet set5() {
ConcurrentSkipListSet q = new ConcurrentSkipListSet();
assertTrue(q.isEmpty());
q.add(one);
@@ -97,7 +97,7 @@ public class ConcurrentSkipListSubSetTest extends JSR166TestCase {
/**
* Returns a new set of first 5 negative ints.
*/
- private NavigableSet dset5() {
+ private static NavigableSet dset5() {
ConcurrentSkipListSet q = new ConcurrentSkipListSet();
assertTrue(q.isEmpty());
q.add(m1);
diff --git a/jdk/test/java/util/concurrent/tck/CopyOnWriteArrayListTest.java b/jdk/test/java/util/concurrent/tck/CopyOnWriteArrayListTest.java
index 329010b308b..2b13e130701 100644
--- a/jdk/test/java/util/concurrent/tck/CopyOnWriteArrayListTest.java
+++ b/jdk/test/java/util/concurrent/tck/CopyOnWriteArrayListTest.java
@@ -44,7 +44,6 @@ import java.util.NoSuchElementException;
import java.util.concurrent.CopyOnWriteArrayList;
import junit.framework.Test;
-import junit.framework.TestSuite;
public class CopyOnWriteArrayListTest extends JSR166TestCase {
diff --git a/jdk/test/java/util/concurrent/tck/CountedCompleter8Test.java b/jdk/test/java/util/concurrent/tck/CountedCompleter8Test.java
index eb23564ed77..77e800c23b3 100644
--- a/jdk/test/java/util/concurrent/tck/CountedCompleter8Test.java
+++ b/jdk/test/java/util/concurrent/tck/CountedCompleter8Test.java
@@ -32,9 +32,6 @@
* http://creativecommons.org/publicdomain/zero/1.0/
*/
-import static java.util.concurrent.TimeUnit.MILLISECONDS;
-import static java.util.concurrent.TimeUnit.SECONDS;
-
import java.util.concurrent.CountedCompleter;
import java.util.concurrent.ThreadLocalRandom;
import java.util.concurrent.atomic.AtomicInteger;
diff --git a/jdk/test/java/util/concurrent/tck/CountedCompleterTest.java b/jdk/test/java/util/concurrent/tck/CountedCompleterTest.java
index 3113b57a563..66e5bd61761 100644
--- a/jdk/test/java/util/concurrent/tck/CountedCompleterTest.java
+++ b/jdk/test/java/util/concurrent/tck/CountedCompleterTest.java
@@ -40,7 +40,6 @@ 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;
diff --git a/jdk/test/java/util/concurrent/tck/ExchangerTest.java b/jdk/test/java/util/concurrent/tck/ExchangerTest.java
index ba6c5443623..36eacc7891e 100644
--- a/jdk/test/java/util/concurrent/tck/ExchangerTest.java
+++ b/jdk/test/java/util/concurrent/tck/ExchangerTest.java
@@ -160,12 +160,12 @@ public class ExchangerTest extends JSR166TestCase {
public void realRun() throws InterruptedException {
assertSame(one, e.exchange(two));
exchanged.countDown();
- interrupted.await();
+ await(interrupted);
assertSame(three, e.exchange(one));
}});
Thread t3 = newStartedThread(new CheckedRunnable() {
public void realRun() throws InterruptedException {
- interrupted.await();
+ await(interrupted);
assertSame(one, e.exchange(three));
}});
diff --git a/jdk/test/java/util/concurrent/tck/ExecutorCompletionService9Test.java b/jdk/test/java/util/concurrent/tck/ExecutorCompletionService9Test.java
index 4ca78a09a49..92e92478cbc 100644
--- a/jdk/test/java/util/concurrent/tck/ExecutorCompletionService9Test.java
+++ b/jdk/test/java/util/concurrent/tck/ExecutorCompletionService9Test.java
@@ -37,7 +37,6 @@ import java.util.Collection;
import java.util.Comparator;
import java.util.List;
import java.util.Set;
-import java.util.HashSet;
import java.util.concurrent.Callable;
import java.util.concurrent.CompletionService;
import java.util.concurrent.ExecutionException;
diff --git a/jdk/test/java/util/concurrent/tck/ExecutorCompletionServiceTest.java b/jdk/test/java/util/concurrent/tck/ExecutorCompletionServiceTest.java
index 0ab6084b978..9b7251e6865 100644
--- a/jdk/test/java/util/concurrent/tck/ExecutorCompletionServiceTest.java
+++ b/jdk/test/java/util/concurrent/tck/ExecutorCompletionServiceTest.java
@@ -172,7 +172,7 @@ public class ExecutorCompletionServiceTest extends JSR166TestCase {
CompletionService cs = new ExecutorCompletionService(cachedThreadPool);
final CountDownLatch proceed = new CountDownLatch(1);
cs.submit(new Callable() { public String call() throws Exception {
- proceed.await();
+ await(proceed);
return TEST_STRING;
}});
assertNull(cs.poll());
diff --git a/jdk/test/java/util/concurrent/tck/ExecutorsTest.java b/jdk/test/java/util/concurrent/tck/ExecutorsTest.java
index 441a52a5922..90764242502 100644
--- a/jdk/test/java/util/concurrent/tck/ExecutorsTest.java
+++ b/jdk/test/java/util/concurrent/tck/ExecutorsTest.java
@@ -333,16 +333,12 @@ public class ExecutorsTest extends JSR166TestCase {
public void realRun() {
try {
Thread current = Thread.currentThread();
- assertTrue(!current.isDaemon());
+ assertFalse(current.isDaemon());
assertTrue(current.getPriority() <= Thread.NORM_PRIORITY);
- ThreadGroup g = current.getThreadGroup();
SecurityManager s = System.getSecurityManager();
- if (s != null)
- assertTrue(g == s.getThreadGroup());
- else
- assertTrue(g == egroup);
- String name = current.getName();
- assertTrue(name.endsWith("thread-1"));
+ assertSame(current.getThreadGroup(),
+ (s == null) ? egroup : s.getThreadGroup());
+ assertTrue(current.getName().endsWith("thread-1"));
} catch (SecurityException ok) {
// Also pass if not allowed to change setting
}
@@ -370,16 +366,12 @@ public class ExecutorsTest extends JSR166TestCase {
Runnable r = new CheckedRunnable() {
public void realRun() {
Thread current = Thread.currentThread();
- assertTrue(!current.isDaemon());
+ assertFalse(current.isDaemon());
assertTrue(current.getPriority() <= Thread.NORM_PRIORITY);
- ThreadGroup g = current.getThreadGroup();
SecurityManager s = System.getSecurityManager();
- if (s != null)
- assertTrue(g == s.getThreadGroup());
- else
- assertTrue(g == egroup);
- String name = current.getName();
- assertTrue(name.endsWith("thread-1"));
+ assertSame(current.getThreadGroup(),
+ (s == null) ? egroup : s.getThreadGroup());
+ assertTrue(current.getName().endsWith("thread-1"));
assertSame(thisccl, current.getContextClassLoader());
assertEquals(thisacc, AccessController.getContext());
done.countDown();
diff --git a/jdk/test/java/util/concurrent/tck/ForkJoinPool8Test.java b/jdk/test/java/util/concurrent/tck/ForkJoinPool8Test.java
index b0fea9a0bfe..f24de8828dc 100644
--- a/jdk/test/java/util/concurrent/tck/ForkJoinPool8Test.java
+++ b/jdk/test/java/util/concurrent/tck/ForkJoinPool8Test.java
@@ -206,7 +206,7 @@ public class ForkJoinPool8Test extends JSR166TestCase {
public FJException(Throwable cause) { super(cause); }
}
- // A simple recursive action for testing
+ /** A simple recursive action for testing. */
final class FibAction extends CheckedRecursiveAction {
final int number;
int result;
@@ -224,7 +224,7 @@ public class ForkJoinPool8Test extends JSR166TestCase {
}
}
- // A recursive action failing in base case
+ /** A recursive action failing in base case. */
static final class FailingFibAction extends RecursiveAction {
final int number;
int result;
@@ -932,7 +932,7 @@ public class ForkJoinPool8Test extends JSR166TestCase {
}
}
- // Version of CCF with forced failure in left completions
+ /** Version of CCF with forced failure in left completions. */
abstract static class FailingCCF extends CountedCompleter {
int number;
int rnumber;
diff --git a/jdk/test/java/util/concurrent/tck/ForkJoinPool9Test.java b/jdk/test/java/util/concurrent/tck/ForkJoinPool9Test.java
index 8a87e473a6f..b4153481d61 100644
--- a/jdk/test/java/util/concurrent/tck/ForkJoinPool9Test.java
+++ b/jdk/test/java/util/concurrent/tck/ForkJoinPool9Test.java
@@ -32,8 +32,6 @@
* http://creativecommons.org/publicdomain/zero/1.0/
*/
-import static java.util.concurrent.TimeUnit.MILLISECONDS;
-
import java.lang.invoke.MethodHandles;
import java.lang.invoke.VarHandle;
import java.util.concurrent.CountDownLatch;
@@ -93,7 +91,7 @@ public class ForkJoinPool9Test extends JSR166TestCase {
Future> f = ForkJoinPool.commonPool().submit(runInCommonPool);
// Ensure runInCommonPool is truly running in the common pool,
// by giving this thread no opportunity to "help" on get().
- assertTrue(taskStarted.await(LONG_DELAY_MS, MILLISECONDS));
+ await(taskStarted);
assertNull(f.get());
}
diff --git a/jdk/test/java/util/concurrent/tck/ForkJoinPoolTest.java b/jdk/test/java/util/concurrent/tck/ForkJoinPoolTest.java
index bf5a3652f09..766e35081e3 100644
--- a/jdk/test/java/util/concurrent/tck/ForkJoinPoolTest.java
+++ b/jdk/test/java/util/concurrent/tck/ForkJoinPoolTest.java
@@ -244,7 +244,7 @@ public class ForkJoinPoolTest extends JSR166TestCase {
taskStarted.countDown();
assertEquals(1, p.getPoolSize());
assertEquals(1, p.getActiveThreadCount());
- done.await();
+ await(done);
}};
Future> future = p.submit(task);
await(taskStarted);
diff --git a/jdk/test/java/util/concurrent/tck/ForkJoinTask8Test.java b/jdk/test/java/util/concurrent/tck/ForkJoinTask8Test.java
index c1063da31aa..6415111510c 100644
--- a/jdk/test/java/util/concurrent/tck/ForkJoinTask8Test.java
+++ b/jdk/test/java/util/concurrent/tck/ForkJoinTask8Test.java
@@ -127,7 +127,8 @@ public class ForkJoinTask8Test extends JSR166TestCase {
assertNull(a.getException());
assertNull(a.getRawResult());
if (a instanceof BinaryAsyncAction)
- assertTrue(((BinaryAsyncAction)a).getForkJoinTaskTag() == INITIAL_STATE);
+ assertEquals(INITIAL_STATE,
+ ((BinaryAsyncAction)a).getForkJoinTaskTag());
try {
a.get(0L, SECONDS);
@@ -148,7 +149,8 @@ public class ForkJoinTask8Test extends JSR166TestCase {
assertNull(a.getException());
assertSame(expected, a.getRawResult());
if (a instanceof BinaryAsyncAction)
- assertTrue(((BinaryAsyncAction)a).getForkJoinTaskTag() == COMPLETE_STATE);
+ assertEquals(COMPLETE_STATE,
+ ((BinaryAsyncAction)a).getForkJoinTaskTag());
{
Thread.currentThread().interrupt();
diff --git a/jdk/test/java/util/concurrent/tck/JSR166TestCase.java b/jdk/test/java/util/concurrent/tck/JSR166TestCase.java
index 1037eb8f3e7..9625be26fea 100644
--- a/jdk/test/java/util/concurrent/tck/JSR166TestCase.java
+++ b/jdk/test/java/util/concurrent/tck/JSR166TestCase.java
@@ -26,8 +26,9 @@
* However, the following notice accompanied the original version of this
* file:
*
- * Written by Doug Lea with assistance from members of JCP JSR-166
- * Expert Group and released to the public domain, as explained at
+ * Written by Doug Lea and Martin Buchholz with assistance from
+ * members of JCP JSR-166 Expert Group and released to the public
+ * domain, as explained at
* http://creativecommons.org/publicdomain/zero/1.0/
* Other contributors include Andrew Wright, Jeffrey Hayes,
* Pat Fisher, Mike Judd.
@@ -35,32 +36,33 @@
/*
* @test
- * @summary JSR-166 tck tests (conformance testing mode)
+ * @summary JSR-166 tck tests, in a number of variations.
+ * The first is the conformance testing variant,
+ * while others also test implementation details.
* @build *
* @modules java.management
* @run junit/othervm/timeout=1000 JSR166TestCase
- */
-
-/*
- * @test
- * @summary JSR-166 tck tests (whitebox tests allowed)
- * @build *
- * @modules java.base/java.util.concurrent:open
- * java.base/java.lang:open
- * java.management
* @run junit/othervm/timeout=1000
+ * --add-opens java.base/java.util.concurrent=ALL-UNNAMED
+ * --add-opens java.base/java.lang=ALL-UNNAMED
* -Djsr166.testImplementationDetails=true
* JSR166TestCase
* @run junit/othervm/timeout=1000
+ * --add-opens java.base/java.util.concurrent=ALL-UNNAMED
+ * --add-opens java.base/java.lang=ALL-UNNAMED
* -Djsr166.testImplementationDetails=true
* -Djava.util.concurrent.ForkJoinPool.common.parallelism=0
* JSR166TestCase
* @run junit/othervm/timeout=1000
+ * --add-opens java.base/java.util.concurrent=ALL-UNNAMED
+ * --add-opens java.base/java.lang=ALL-UNNAMED
* -Djsr166.testImplementationDetails=true
* -Djava.util.concurrent.ForkJoinPool.common.parallelism=1
* -Djava.util.secureRandomSeed=true
* JSR166TestCase
* @run junit/othervm/timeout=1000/policy=tck.policy
+ * --add-opens java.base/java.util.concurrent=ALL-UNNAMED
+ * --add-opens java.base/java.lang=ALL-UNNAMED
* -Djsr166.testImplementationDetails=true
* JSR166TestCase
*/
@@ -79,8 +81,6 @@ import java.lang.management.ThreadMXBean;
import java.lang.reflect.Constructor;
import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
-import java.nio.file.Files;
-import java.nio.file.Paths;
import java.security.CodeSource;
import java.security.Permission;
import java.security.PermissionCollection;
@@ -118,7 +118,6 @@ import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeoutException;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicReference;
-import java.util.regex.Matcher;
import java.util.regex.Pattern;
import junit.framework.AssertionFailedError;
@@ -328,9 +327,11 @@ public class JSR166TestCase extends TestCase {
// public static String cpuModel() {
// try {
-// Matcher matcher = Pattern.compile("model name\\s*: (.*)")
+// java.util.regex.Matcher matcher
+// = Pattern.compile("model name\\s*: (.*)")
// .matcher(new String(
-// Files.readAllBytes(Paths.get("/proc/cpuinfo")), "UTF-8"));
+// java.nio.file.Files.readAllBytes(
+// java.nio.file.Paths.get("/proc/cpuinfo")), "UTF-8"));
// matcher.find();
// return matcher.group(1);
// } catch (Exception ex) { return null; }
diff --git a/jdk/test/java/util/concurrent/tck/LinkedBlockingDeque8Test.java b/jdk/test/java/util/concurrent/tck/LinkedBlockingDeque8Test.java
index 44dcedc0f01..cdcc7a27334 100644
--- a/jdk/test/java/util/concurrent/tck/LinkedBlockingDeque8Test.java
+++ b/jdk/test/java/util/concurrent/tck/LinkedBlockingDeque8Test.java
@@ -36,7 +36,6 @@ import java.util.concurrent.LinkedBlockingDeque;
import java.util.Spliterator;
import junit.framework.Test;
-import junit.framework.TestSuite;
public class LinkedBlockingDeque8Test extends JSR166TestCase {
public static void main(String[] args) {
diff --git a/jdk/test/java/util/concurrent/tck/LinkedBlockingDequeTest.java b/jdk/test/java/util/concurrent/tck/LinkedBlockingDequeTest.java
index 2559fdffe9d..00fbcc9734b 100644
--- a/jdk/test/java/util/concurrent/tck/LinkedBlockingDequeTest.java
+++ b/jdk/test/java/util/concurrent/tck/LinkedBlockingDequeTest.java
@@ -85,7 +85,7 @@ public class LinkedBlockingDequeTest extends JSR166TestCase {
* Returns a new deque of given size containing consecutive
* Integers 0 ... n - 1.
*/
- private LinkedBlockingDeque populatedDeque(int n) {
+ private static LinkedBlockingDeque populatedDeque(int n) {
LinkedBlockingDeque q =
new LinkedBlockingDeque(n);
assertTrue(q.isEmpty());
@@ -801,7 +801,7 @@ public class LinkedBlockingDequeTest extends JSR166TestCase {
}
}});
- aboutToWait.await();
+ await(aboutToWait);
waitForThreadToEnterWaitState(t);
t.interrupt();
awaitTermination(t);
diff --git a/jdk/test/java/util/concurrent/tck/LinkedBlockingQueue8Test.java b/jdk/test/java/util/concurrent/tck/LinkedBlockingQueue8Test.java
index 9900c33da70..2c3e498aeaa 100644
--- a/jdk/test/java/util/concurrent/tck/LinkedBlockingQueue8Test.java
+++ b/jdk/test/java/util/concurrent/tck/LinkedBlockingQueue8Test.java
@@ -36,7 +36,6 @@ import java.util.concurrent.LinkedBlockingQueue;
import java.util.Spliterator;
import junit.framework.Test;
-import junit.framework.TestSuite;
public class LinkedBlockingQueue8Test extends JSR166TestCase {
public static void main(String[] args) {
diff --git a/jdk/test/java/util/concurrent/tck/LinkedBlockingQueueTest.java b/jdk/test/java/util/concurrent/tck/LinkedBlockingQueueTest.java
index 153cbce667a..cdccb75ed87 100644
--- a/jdk/test/java/util/concurrent/tck/LinkedBlockingQueueTest.java
+++ b/jdk/test/java/util/concurrent/tck/LinkedBlockingQueueTest.java
@@ -85,7 +85,7 @@ public class LinkedBlockingQueueTest extends JSR166TestCase {
* Returns a new queue of given size containing consecutive
* Integers 0 ... n - 1.
*/
- private LinkedBlockingQueue populatedQueue(int n) {
+ private static LinkedBlockingQueue populatedQueue(int n) {
LinkedBlockingQueue q =
new LinkedBlockingQueue(n);
assertTrue(q.isEmpty());
diff --git a/jdk/test/java/util/concurrent/tck/LinkedListTest.java b/jdk/test/java/util/concurrent/tck/LinkedListTest.java
index 08a2ddd9dab..66dd8c02c7a 100644
--- a/jdk/test/java/util/concurrent/tck/LinkedListTest.java
+++ b/jdk/test/java/util/concurrent/tck/LinkedListTest.java
@@ -40,7 +40,6 @@ import java.util.LinkedList;
import java.util.NoSuchElementException;
import junit.framework.Test;
-import junit.framework.TestSuite;
public class LinkedListTest extends JSR166TestCase {
public static void main(String[] args) {
@@ -70,7 +69,7 @@ public class LinkedListTest extends JSR166TestCase {
* Returns a new queue of given size containing consecutive
* Integers 0 ... n - 1.
*/
- private LinkedList populatedQueue(int n) {
+ private static LinkedList populatedQueue(int n) {
LinkedList q = new LinkedList<>();
assertTrue(q.isEmpty());
for (int i = 0; i < n; ++i)
diff --git a/jdk/test/java/util/concurrent/tck/LinkedTransferQueueTest.java b/jdk/test/java/util/concurrent/tck/LinkedTransferQueueTest.java
index 6a22b0e20a9..7f38351a30a 100644
--- a/jdk/test/java/util/concurrent/tck/LinkedTransferQueueTest.java
+++ b/jdk/test/java/util/concurrent/tck/LinkedTransferQueueTest.java
@@ -321,7 +321,7 @@ public class LinkedTransferQueueTest extends JSR166TestCase {
assertTrue(millisElapsedSince(startTime) < LONG_DELAY_MS);
}});
- aboutToWait.await();
+ await(aboutToWait);
waitForThreadToEnterWaitState(t);
t.interrupt();
awaitTermination(t);
@@ -826,7 +826,7 @@ public class LinkedTransferQueueTest extends JSR166TestCase {
Thread first = newStartedThread(new CheckedRunnable() {
public void realRun() throws InterruptedException {
q.transfer(four);
- assertTrue(!q.contains(four));
+ assertFalse(q.contains(four));
assertEquals(1, q.size());
}});
diff --git a/jdk/test/java/util/concurrent/tck/PriorityBlockingQueueTest.java b/jdk/test/java/util/concurrent/tck/PriorityBlockingQueueTest.java
index 088c389b2cc..aa826b80f1b 100644
--- a/jdk/test/java/util/concurrent/tck/PriorityBlockingQueueTest.java
+++ b/jdk/test/java/util/concurrent/tck/PriorityBlockingQueueTest.java
@@ -93,7 +93,7 @@ public class PriorityBlockingQueueTest extends JSR166TestCase {
* Returns a new queue of given size containing consecutive
* Integers 0 ... n - 1.
*/
- private PriorityBlockingQueue populatedQueue(int n) {
+ private static PriorityBlockingQueue populatedQueue(int n) {
PriorityBlockingQueue q =
new PriorityBlockingQueue(n);
assertTrue(q.isEmpty());
@@ -445,7 +445,7 @@ public class PriorityBlockingQueueTest extends JSR166TestCase {
}
}});
- aboutToWait.await();
+ await(aboutToWait);
waitForThreadToEnterWaitState(t);
t.interrupt();
awaitTermination(t);
diff --git a/jdk/test/java/util/concurrent/tck/PriorityQueueTest.java b/jdk/test/java/util/concurrent/tck/PriorityQueueTest.java
index c1564730cdf..1c3984dd197 100644
--- a/jdk/test/java/util/concurrent/tck/PriorityQueueTest.java
+++ b/jdk/test/java/util/concurrent/tck/PriorityQueueTest.java
@@ -42,7 +42,6 @@ import java.util.PriorityQueue;
import java.util.Queue;
import junit.framework.Test;
-import junit.framework.TestSuite;
public class PriorityQueueTest extends JSR166TestCase {
public static void main(String[] args) {
@@ -70,7 +69,7 @@ public class PriorityQueueTest extends JSR166TestCase {
* Returns a new queue of given size containing consecutive
* Integers 0 ... n - 1.
*/
- private PriorityQueue populatedQueue(int n) {
+ private static PriorityQueue populatedQueue(int n) {
PriorityQueue q = new PriorityQueue<>(n);
assertTrue(q.isEmpty());
for (int i = n - 1; i >= 0; i -= 2)
diff --git a/jdk/test/java/util/concurrent/tck/RecursiveActionTest.java b/jdk/test/java/util/concurrent/tck/RecursiveActionTest.java
index 01bd92770b7..132b8dad7b0 100644
--- a/jdk/test/java/util/concurrent/tck/RecursiveActionTest.java
+++ b/jdk/test/java/util/concurrent/tck/RecursiveActionTest.java
@@ -195,7 +195,7 @@ public class RecursiveActionTest extends JSR166TestCase {
public FJException(Throwable cause) { super(cause); }
}
- // A simple recursive action for testing
+ /** A simple recursive action for testing. */
final class FibAction extends CheckedRecursiveAction {
final int number;
int result;
@@ -213,7 +213,7 @@ public class RecursiveActionTest extends JSR166TestCase {
}
}
- // A recursive action failing in base case
+ /** A recursive action failing in base case. */
static final class FailingFibAction extends RecursiveAction {
final int number;
int result;
diff --git a/jdk/test/java/util/concurrent/tck/RecursiveTaskTest.java b/jdk/test/java/util/concurrent/tck/RecursiveTaskTest.java
index ce13daa8e7b..49723adcff7 100644
--- a/jdk/test/java/util/concurrent/tck/RecursiveTaskTest.java
+++ b/jdk/test/java/util/concurrent/tck/RecursiveTaskTest.java
@@ -210,10 +210,10 @@ public class RecursiveTaskTest extends JSR166TestCase {
public FJException() { super(); }
}
- // An invalid return value for Fib
+ /** An invalid return value for Fib. */
static final Integer NoResult = Integer.valueOf(-17);
- // A simple recursive task for testing
+ /** A simple recursive task for testing. */
final class FibTask extends CheckedRecursiveTask {
final int number;
FibTask(int n) { number = n; }
@@ -231,7 +231,7 @@ public class RecursiveTaskTest extends JSR166TestCase {
}
}
- // A recursive action failing in base case
+ /** A recursive action failing in base case. */
final class FailingFibTask extends RecursiveTask {
final int number;
int result;
diff --git a/jdk/test/java/util/concurrent/tck/StampedLockTest.java b/jdk/test/java/util/concurrent/tck/StampedLockTest.java
index 65ef48d046b..5f44312c88c 100644
--- a/jdk/test/java/util/concurrent/tck/StampedLockTest.java
+++ b/jdk/test/java/util/concurrent/tck/StampedLockTest.java
@@ -518,7 +518,7 @@ public class StampedLockTest extends JSR166TestCase {
lock.unlockWrite(s);
}});
- aboutToLock.await();
+ await(aboutToLock);
waitForThreadToEnterWaitState(t);
assertFalse(lock.isWriteLocked());
assertTrue(lock.isReadLocked());
@@ -777,7 +777,7 @@ public class StampedLockTest extends JSR166TestCase {
lock.writeLockInterruptibly();
}});
- locked.await();
+ await(locked);
assertFalse(lock.validate(p));
assertEquals(0L, lock.tryOptimisticRead());
waitForThreadToEnterWaitState(t);
diff --git a/jdk/test/java/util/concurrent/tck/SubmissionPublisherTest.java b/jdk/test/java/util/concurrent/tck/SubmissionPublisherTest.java
index 102d1b5e3ef..ecd472f2cbe 100644
--- a/jdk/test/java/util/concurrent/tck/SubmissionPublisherTest.java
+++ b/jdk/test/java/util/concurrent/tck/SubmissionPublisherTest.java
@@ -519,7 +519,7 @@ public class SubmissionPublisherTest extends JSR166TestCase {
s1.request = false;
p.subscribe(s1);
s1.awaitSubscribe();
- assertTrue(p.estimateMinimumDemand() == 0);
+ assertEquals(0, p.estimateMinimumDemand());
TestSubscriber s2 = new TestSubscriber();
p.subscribe(s2);
p.submit(1);
diff --git a/jdk/test/java/util/concurrent/tck/SynchronousQueueTest.java b/jdk/test/java/util/concurrent/tck/SynchronousQueueTest.java
index 345ac9c7305..afa4f5c026c 100644
--- a/jdk/test/java/util/concurrent/tck/SynchronousQueueTest.java
+++ b/jdk/test/java/util/concurrent/tck/SynchronousQueueTest.java
@@ -596,7 +596,7 @@ public class SynchronousQueueTest extends JSR166TestCase {
fail("timed out");
Thread.yield();
}
- assertTrue(l.size() == 1);
+ assertEquals(1, l.size());
assertSame(one, l.get(0));
awaitTermination(t);
}
diff --git a/jdk/test/java/util/concurrent/tck/ThreadPoolExecutorSubclassTest.java b/jdk/test/java/util/concurrent/tck/ThreadPoolExecutorSubclassTest.java
index 38862ceee5d..90065c65790 100644
--- a/jdk/test/java/util/concurrent/tck/ThreadPoolExecutorSubclassTest.java
+++ b/jdk/test/java/util/concurrent/tck/ThreadPoolExecutorSubclassTest.java
@@ -265,7 +265,7 @@ public class ThreadPoolExecutorSubclassTest extends JSR166TestCase {
final Runnable task = new CheckedRunnable() {
public void realRun() { done.countDown(); }};
p.execute(task);
- assertTrue(done.await(LONG_DELAY_MS, MILLISECONDS));
+ await(done);
}
}
@@ -359,13 +359,13 @@ public class ThreadPoolExecutorSubclassTest extends JSR166TestCase {
public void realRun() throws InterruptedException {
threadStarted.countDown();
assertEquals(0, p.getCompletedTaskCount());
- threadProceed.await();
+ await(threadProceed);
threadDone.countDown();
}});
await(threadStarted);
assertEquals(0, p.getCompletedTaskCount());
threadProceed.countDown();
- threadDone.await();
+ await(threadDone);
long startTime = System.nanoTime();
while (p.getCompletedTaskCount() != 1) {
if (millisElapsedSince(startTime) > LONG_DELAY_MS)
@@ -1953,7 +1953,7 @@ public class ThreadPoolExecutorSubclassTest extends JSR166TestCase {
public void realRun() {
done.countDown();
}});
- assertTrue(done.await(LONG_DELAY_MS, MILLISECONDS));
+ await(done);
}
}
diff --git a/jdk/test/java/util/concurrent/tck/ThreadPoolExecutorTest.java b/jdk/test/java/util/concurrent/tck/ThreadPoolExecutorTest.java
index cf0b0971270..9cbb98562f6 100644
--- a/jdk/test/java/util/concurrent/tck/ThreadPoolExecutorTest.java
+++ b/jdk/test/java/util/concurrent/tck/ThreadPoolExecutorTest.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.FutureTask;
@@ -118,7 +117,7 @@ public class ThreadPoolExecutorTest extends JSR166TestCase {
final Runnable task = new CheckedRunnable() {
public void realRun() { done.countDown(); }};
p.execute(task);
- assertTrue(done.await(LONG_DELAY_MS, MILLISECONDS));
+ await(done);
}
}
@@ -212,13 +211,13 @@ public class ThreadPoolExecutorTest extends JSR166TestCase {
public void realRun() throws InterruptedException {
threadStarted.countDown();
assertEquals(0, p.getCompletedTaskCount());
- threadProceed.await();
+ await(threadProceed);
threadDone.countDown();
}});
await(threadStarted);
assertEquals(0, p.getCompletedTaskCount());
threadProceed.countDown();
- threadDone.await();
+ await(threadDone);
long startTime = System.nanoTime();
while (p.getCompletedTaskCount() != 1) {
if (millisElapsedSince(startTime) > LONG_DELAY_MS)
@@ -301,6 +300,20 @@ public class ThreadPoolExecutorTest extends JSR166TestCase {
}
}
+ /**
+ * The default rejected execution handler is AbortPolicy.
+ */
+ public void testDefaultRejectedExecutionHandler() {
+ final ThreadPoolExecutor p =
+ new ThreadPoolExecutor(1, 2,
+ LONG_DELAY_MS, MILLISECONDS,
+ new ArrayBlockingQueue(10));
+ try (PoolCleaner cleaner = cleaner(p)) {
+ assertTrue(p.getRejectedExecutionHandler()
+ instanceof ThreadPoolExecutor.AbortPolicy);
+ }
+ }
+
/**
* getRejectedExecutionHandler returns handler in constructor if not set
*/
@@ -1139,7 +1152,7 @@ public class ThreadPoolExecutorTest extends JSR166TestCase {
await(done);
}};
for (int i = 0; i < 2; ++i)
- p.submit(Executors.callable(task));
+ p.execute(task);
for (int i = 0; i < 2; ++i) {
try {
p.execute(task);
@@ -1955,7 +1968,7 @@ public class ThreadPoolExecutorTest extends JSR166TestCase {
public void realRun() {
done.countDown();
}});
- assertTrue(done.await(LONG_DELAY_MS, MILLISECONDS));
+ await(done);
}
}
@@ -2048,7 +2061,7 @@ public class ThreadPoolExecutorTest extends JSR166TestCase {
}
}
// enough time to run all tasks
- assertTrue(done.await(nTasks * SHORT_DELAY_MS, MILLISECONDS));
+ await(done, nTasks * SHORT_DELAY_MS);
}
}
diff --git a/jdk/test/java/util/concurrent/tck/ThreadTest.java b/jdk/test/java/util/concurrent/tck/ThreadTest.java
index 92b2aca52a6..1cd9f0fbce4 100644
--- a/jdk/test/java/util/concurrent/tck/ThreadTest.java
+++ b/jdk/test/java/util/concurrent/tck/ThreadTest.java
@@ -76,7 +76,7 @@ public class ThreadTest extends JSR166TestCase {
* setDefaultUncaughtExceptionHandler.
*/
public void testGetAndSetDefaultUncaughtExceptionHandler() {
- assertEquals(null, Thread.getDefaultUncaughtExceptionHandler());
+ assertNull(Thread.getDefaultUncaughtExceptionHandler());
// failure due to SecurityException is OK.
// Would be nice to explicitly test both ways, but cannot yet.
Thread.UncaughtExceptionHandler defaultHandler
diff --git a/jdk/test/java/util/concurrent/tck/TreeSetTest.java b/jdk/test/java/util/concurrent/tck/TreeSetTest.java
index a37922e525b..55b28d613d9 100644
--- a/jdk/test/java/util/concurrent/tck/TreeSetTest.java
+++ b/jdk/test/java/util/concurrent/tck/TreeSetTest.java
@@ -69,7 +69,7 @@ public class TreeSetTest extends JSR166TestCase {
* Returns a new set of given size containing consecutive
* Integers 0 ... n - 1.
*/
- private TreeSet populatedSet(int n) {
+ private static TreeSet populatedSet(int n) {
TreeSet