diff --git a/.hgtags b/.hgtags
index 477695408fd..f6400ee7a20 100644
--- a/.hgtags
+++ b/.hgtags
@@ -354,3 +354,4 @@ db483b34fa7148d257a429acddbde9c13687dcae jdk-9+105
c870cb782aca71093d2584376f27f0cfbfec0e3a jdk-9+109
4a95f4b1bd8bfce85dc02a593896749feab96c34 jdk-9+110
a6614ff7bf09da74be1d0ef3d9755090d244697a jdk-9+111
+7359994942f8d8e723b584d66a3a92c2e9e95e5c jdk-9+112
diff --git a/.hgtags-top-repo b/.hgtags-top-repo
index 5c5a9b77d7a..881d8460710 100644
--- a/.hgtags-top-repo
+++ b/.hgtags-top-repo
@@ -354,3 +354,4 @@ c7be2a78c31b3b6132f2f5e9e4b3d3bb1c20245c jdk-9+108
1787bdaabb2b6f4193406e25a50cb0419ea8e8f3 jdk-9+109
925be13b3740d07a5958ccb5ab3c0ae1baba7055 jdk-9+110
f900d5afd9c83a0df8f36161c27c5e4c86a66f4c jdk-9+111
+03543a758cd5890f2266e4b9678378a925dde22a jdk-9+112
diff --git a/common/conf/jib-profiles.js b/common/conf/jib-profiles.js
index d468605177d..a3372cf3fe2 100644
--- a/common/conf/jib-profiles.js
+++ b/common/conf/jib-profiles.js
@@ -241,8 +241,7 @@ var getJibProfilesProfiles = function (input, common) {
target_os: "linux",
target_cpu: "x64",
dependencies: concat(common.dependencies, "devkit"),
- configure_args: common.configure_args,
- configure_args: concat(common.configure_args, "--with-zlib=system"),
+ configure_args: concat(common.configure_args, "--with-zlib=system"),
make_args: common.make_args
},
@@ -251,8 +250,8 @@ var getJibProfilesProfiles = function (input, common) {
target_cpu: "x86",
build_cpu: "x64",
dependencies: concat(common.dependencies, "devkit"),
- configure_args: concat(common.configure_args, common.configure_args_32bit),
- configure_args: concat(common.configure_args, "--with-zlib=system"),
+ configure_args: concat(common.configure_args, common.configure_args_32bit,
+ "--with-zlib=system"),
make_args: common.make_args
},
@@ -260,8 +259,7 @@ var getJibProfilesProfiles = function (input, common) {
target_os: "macosx",
target_cpu: "x64",
dependencies: concat(common.dependencies, "devkit"),
- configure_args: common.configure_args,
- configure_args: concat(common.configure_args, "--with-zlib=system"),
+ configure_args: concat(common.configure_args, "--with-zlib=system"),
make_args: common.make_args
},
@@ -269,8 +267,7 @@ var getJibProfilesProfiles = function (input, common) {
target_os: "solaris",
target_cpu: "x64",
dependencies: concat(common.dependencies, "devkit", "cups"),
- configure_args: common.configure_args,
- configure_args: concat(common.configure_args, "--with-zlib=system"),
+ configure_args: concat(common.configure_args, "--with-zlib=system"),
make_args: common.make_args
},
@@ -278,8 +275,7 @@ var getJibProfilesProfiles = function (input, common) {
target_os: "solaris",
target_cpu: "sparcv9",
dependencies: concat(common.dependencies, "devkit", "cups"),
- configure_args: common.configure_args,
- configure_args: concat(common.configure_args, "--with-zlib=system"),
+ configure_args: concat(common.configure_args, "--with-zlib=system"),
make_args: common.make_args
},
diff --git a/corba/.hgtags b/corba/.hgtags
index ee4fd4f88d7..1d06c1f36bb 100644
--- a/corba/.hgtags
+++ b/corba/.hgtags
@@ -354,3 +354,4 @@ e385e95e6101711d5c63e7b1a827e99b6ec7a1cc jdk-9+104
b75afa17aefe480c23c616a6a2497063312f7189 jdk-9+109
9666775734fb6028ee86df9972626b3667b6a318 jdk-9+110
2bb92dd44275679edb29fdbffc3b7cbebc9a6bf0 jdk-9+111
+780d0620add32bf545471cf65038c9ac6d9c036d jdk-9+112
diff --git a/hotspot/.hgtags b/hotspot/.hgtags
index 85aeb41cf05..f7acd50ad2b 100644
--- a/hotspot/.hgtags
+++ b/hotspot/.hgtags
@@ -514,3 +514,4 @@ c5146d4da417f76edfc43097d2e2ced042a65b4e jdk-9+107
7e7e50ac4faf19899fc811569e32cfa478759ebb jdk-9+109
2f5d1578b24060ea06bd1f340a124db95d1475b2 jdk-9+110
c558850fac5750d8ca98a45180121980f57cdd28 jdk-9+111
+76582e8dc9e6374e4f99ab797c8d364b6e9449b4 jdk-9+112
diff --git a/hotspot/src/share/vm/classfile/vmSymbols.hpp b/hotspot/src/share/vm/classfile/vmSymbols.hpp
index cc47327a31b..90a95e75794 100644
--- a/hotspot/src/share/vm/classfile/vmSymbols.hpp
+++ b/hotspot/src/share/vm/classfile/vmSymbols.hpp
@@ -656,7 +656,7 @@
\
/* JVMTI/java.lang.instrument support and VM Attach mechanism */ \
template(jdk_internal_module_Modules, "jdk/internal/module/Modules") \
- template(sun_misc_VMSupport, "sun/misc/VMSupport") \
+ template(jdk_internal_vm_VMSupport, "jdk/internal/vm/VMSupport") \
template(transformedByAgent_name, "transformedByAgent") \
template(transformedByAgent_signature, "(Ljava/lang/reflect/Module;)V") \
template(appendToClassPathForInstrumentation_name, "appendToClassPathForInstrumentation") \
diff --git a/hotspot/src/share/vm/services/attachListener.cpp b/hotspot/src/share/vm/services/attachListener.cpp
index c412325ce18..0de704d6913 100644
--- a/hotspot/src/share/vm/services/attachListener.cpp
+++ b/hotspot/src/share/vm/services/attachListener.cpp
@@ -43,7 +43,7 @@ volatile bool AttachListener::_initialized;
// Implementation of "properties" command.
//
-// Invokes sun.misc.VMSupport.serializePropertiesToByteArray to serialize
+// Invokes VMSupport.serializePropertiesToByteArray to serialize
// the system properties into a byte array.
static Klass* load_and_initialize_klass(Symbol* sh, TRAPS) {
@@ -59,8 +59,8 @@ static jint get_properties(AttachOperation* op, outputStream* out, Symbol* seria
Thread* THREAD = Thread::current();
HandleMark hm;
- // load sun.misc.VMSupport
- Symbol* klass = vmSymbols::sun_misc_VMSupport();
+ // load VMSupport
+ Symbol* klass = vmSymbols::jdk_internal_vm_VMSupport();
Klass* k = load_and_initialize_klass(klass, THREAD);
if (HAS_PENDING_EXCEPTION) {
java_lang_Throwable::print(PENDING_EXCEPTION, out);
diff --git a/hotspot/src/share/vm/services/diagnosticCommand.cpp b/hotspot/src/share/vm/services/diagnosticCommand.cpp
index 3beb7786c16..dc2b2171408 100644
--- a/hotspot/src/share/vm/services/diagnosticCommand.cpp
+++ b/hotspot/src/share/vm/services/diagnosticCommand.cpp
@@ -316,8 +316,8 @@ int JVMTIAgentLoadDCmd::num_arguments() {
}
void PrintSystemPropertiesDCmd::execute(DCmdSource source, TRAPS) {
- // load sun.misc.VMSupport
- Symbol* klass = vmSymbols::sun_misc_VMSupport();
+ // load VMSupport
+ Symbol* klass = vmSymbols::jdk_internal_vm_VMSupport();
Klass* k = SystemDictionary::resolve_or_fail(klass, true, CHECK);
instanceKlassHandle ik (THREAD, k);
if (ik->should_be_initialized()) {
diff --git a/hotspot/test/compiler/gcbarriers/PreserveFPRegistersTest.java b/hotspot/test/compiler/gcbarriers/PreserveFPRegistersTest.java
index 279a11e9e85..cf63431a3e3 100644
--- a/hotspot/test/compiler/gcbarriers/PreserveFPRegistersTest.java
+++ b/hotspot/test/compiler/gcbarriers/PreserveFPRegistersTest.java
@@ -25,6 +25,7 @@
/**
* @test
* @bug 8148175
+ * @ignore 8153194
* @run main/othervm/timeout=300 -Xbatch -Xmx128m PreserveFPRegistersTest
*/
public class PreserveFPRegistersTest {
diff --git a/hotspot/test/gc/metaspace/TestMetaspacePerfCounters.java b/hotspot/test/gc/metaspace/TestMetaspacePerfCounters.java
index 6c0c48a239b..cd17215aaf9 100644
--- a/hotspot/test/gc/metaspace/TestMetaspacePerfCounters.java
+++ b/hotspot/test/gc/metaspace/TestMetaspacePerfCounters.java
@@ -37,6 +37,7 @@ import static jdk.test.lib.Asserts.*;
* java.compiler
* java.management
* jdk.jvmstat/sun.jvmstat.monitor
+ * @ignore 8151460
* @run main/othervm -XX:+IgnoreUnrecognizedVMOptions -XX:-UseCompressedOops -XX:-UseCompressedClassPointers -XX:+UsePerfData -XX:+UseSerialGC TestMetaspacePerfCounters
* @run main/othervm -XX:+IgnoreUnrecognizedVMOptions -XX:-UseCompressedOops -XX:-UseCompressedClassPointers -XX:+UsePerfData -XX:+UseParallelGC -XX:+UseParallelOldGC TestMetaspacePerfCounters
* @run main/othervm -XX:+IgnoreUnrecognizedVMOptions -XX:-UseCompressedOops -XX:-UseCompressedClassPointers -XX:+UsePerfData -XX:+UseG1GC TestMetaspacePerfCounters
diff --git a/hotspot/test/gc/metaspace/TestPerfCountersAndMemoryPools.java b/hotspot/test/gc/metaspace/TestPerfCountersAndMemoryPools.java
index 5d7d3852f43..a554d7b266f 100644
--- a/hotspot/test/gc/metaspace/TestPerfCountersAndMemoryPools.java
+++ b/hotspot/test/gc/metaspace/TestPerfCountersAndMemoryPools.java
@@ -36,6 +36,7 @@ import static jdk.test.lib.Asserts.*;
* @modules java.base/sun.misc
* java.management
* jdk.jvmstat/sun.jvmstat.monitor
+ * @ignore 8151460
* @run main/othervm -XX:+IgnoreUnrecognizedVMOptions -XX:-UseCompressedOops -XX:-UseCompressedKlassPointers -XX:+UseSerialGC -XX:+UsePerfData -Xint TestPerfCountersAndMemoryPools
* @run main/othervm -XX:+IgnoreUnrecognizedVMOptions -XX:+UseCompressedOops -XX:+UseCompressedKlassPointers -XX:+UseSerialGC -XX:+UsePerfData -Xint TestPerfCountersAndMemoryPools
*/
diff --git a/jaxp/.hgtags b/jaxp/.hgtags
index 425b9957bba..86444b4dd41 100644
--- a/jaxp/.hgtags
+++ b/jaxp/.hgtags
@@ -354,3 +354,4 @@ bdbf2342b21bd8ecad1b4e6499a0dfb314952bd7 jdk-9+103
24e247ee1fffaa625d480b2a4eef2d3a8a59f5cb jdk-9+109
1c1bb661d35b846dc04931bd5f687a0348f80345 jdk-9+110
27a3d65e1580386d060e0aa3a68ab52c1a9ab568 jdk-9+111
+36326537f929d20cc5885b93939f90c0efcc4681 jdk-9+112
diff --git a/jaxp/test/ProblemList.txt b/jaxp/test/ProblemList.txt
index e3dcd5e75b9..ba54cd68e61 100644
--- a/jaxp/test/ProblemList.txt
+++ b/jaxp/test/ProblemList.txt
@@ -23,4 +23,6 @@
#
###########################################################################
-# No jaxp tests are on the problem list.
+# 8147431
+javax/xml/jaxp/isolatedjdk/catalog/PropertiesTest.sh generic-all
+
diff --git a/jaxp/test/javax/xml/jaxp/isolatedjdk/catalog/PropertiesTest.sh b/jaxp/test/javax/xml/jaxp/isolatedjdk/catalog/PropertiesTest.sh
index c8adc173fc1..bf5ab027fdc 100644
--- a/jaxp/test/javax/xml/jaxp/isolatedjdk/catalog/PropertiesTest.sh
+++ b/jaxp/test/javax/xml/jaxp/isolatedjdk/catalog/PropertiesTest.sh
@@ -25,6 +25,7 @@
# @bug 8077931
# @summary This case tests if the properties FILES, DEFER, PREFER, RESOLVE in
# jaxp.properties and system properties could be used.
+# @key intermittent
# @library ../../libs/
# @build catalog.CatalogTestUtils
# @build PropertiesTest
diff --git a/jaxws/.hgtags b/jaxws/.hgtags
index 06ea93e50fb..b13e1e3f336 100644
--- a/jaxws/.hgtags
+++ b/jaxws/.hgtags
@@ -357,3 +357,4 @@ fafd694e801f0f5a7c737fb08630ced3ca8f772c jdk-9+107
4b0697e4ce8940b1599af274ff02296d7f59aded jdk-9+109
0db939c930f332dfa275cedfc7cf223ff1221ea4 jdk-9+110
4d5296e0920afe7ef8d4db1939b76f0d407a3812 jdk-9+111
+21274e7937bae291658d68143aca0e3ee9296db0 jdk-9+112
diff --git a/jdk/.hgignore b/jdk/.hgignore
index 1ed4344d03f..9710bc5d891 100644
--- a/jdk/.hgignore
+++ b/jdk/.hgignore
@@ -7,3 +7,5 @@
^make/netbeans/.*/dist/
^.hgtip
.DS_Store
+.*/JTreport/.*
+.*/JTwork/.*
diff --git a/jdk/.hgtags b/jdk/.hgtags
index 39a2f92aa26..2a4ecef2d92 100644
--- a/jdk/.hgtags
+++ b/jdk/.hgtags
@@ -354,3 +354,4 @@ eee1ced1d8e78293f2a004af818ca474387dbebf jdk-9+103
1c7bad0798900fe58f4db01ae7ffdc84f5baee8c jdk-9+109
9417e1bcded6af5532c3b26235437ab227758877 jdk-9+110
b2a69d66dc65ad1d3aeb3bd362cf5bb0deba040e jdk-9+111
+1565a0efe6f0ca411a6df277df1e069431c60988 jdk-9+112
diff --git a/jdk/make/gendata/GendataBreakIterator.gmk b/jdk/make/gendata/GendataBreakIterator.gmk
index 1aa4becefac..5ee97d77595 100644
--- a/jdk/make/gendata/GendataBreakIterator.gmk
+++ b/jdk/make/gendata/GendataBreakIterator.gmk
@@ -63,11 +63,9 @@ $(eval $(call SetupJavaCompilation,BUILD_BREAKITERATOR_LD, \
ifeq ($(BOOT_JDK_MODULAR), true)
BREAK_ITERATOR_BOOTCLASSPATH := -Xpatch:$(BREAK_ITERATOR_CLASSES) \
- -XaddExports:$(subst $(SPACE),$(COMMA),$(strip \
- java.base/sun.text=ALL-UNNAMED \
- java.base/sun.text.resources=ALL-UNNAMED \
- jdk.localedata/sun.text.resources.ext=ALL-UNNAMED \
- ))
+ -XaddExports:java.base/sun.text=ALL-UNNAMED \
+ -XaddExports:java.base/sun.text.resources=ALL-UNNAMED \
+ -XaddExports:jdk.localedata/sun.text.resources.ext=ALL-UNNAMED
else
BREAK_ITERATOR_BOOTCLASSPATH := -Xbootclasspath/p:$(call PathList, \
$(BREAK_ITERATOR_CLASSES)/java.base \
diff --git a/jdk/make/gensrc/Gensrc-java.base.gmk b/jdk/make/gensrc/Gensrc-java.base.gmk
index 1a188a9a786..9d3e3cf486e 100644
--- a/jdk/make/gensrc/Gensrc-java.base.gmk
+++ b/jdk/make/gensrc/Gensrc-java.base.gmk
@@ -55,7 +55,6 @@ GENSRC_JAVA_BASE += $(LIST_RESOURCE_BUNDLE) $(SUN_UTIL)
# copied to zh_HK locale.
$(eval $(call SetupCopy-zh_HK,COPY_ZH_HK, \
$(addprefix $(JDK_TOPDIR)/src/java.base/share/classes/, \
- sun/misc/resources/Messages_zh_TW.java \
sun/security/util/AuthResources_zh_TW.java \
sun/security/util/Resources_zh_TW.java)))
diff --git a/jdk/make/netbeans/client_sanity/README b/jdk/make/netbeans/client_sanity/README
new file mode 100644
index 00000000000..76d57db49c3
--- /dev/null
+++ b/jdk/make/netbeans/client_sanity/README
@@ -0,0 +1,15 @@
+This NetBeans project corresponds to client sanity test suite in jdk/test/sanity/client.
+
+It simplifies working on the suite in NetBeans.
+
+It also includes the following custom tasks:
+
+prepare-bundle creates dist/sanity.zip containing standalone bundle of the suite
+
+run-jemmy-browser runs Jemmy browser for the ButtonDemo (hardcoded in build.xml file)
+ The tool allows to explore the UI hierarchy.
+
+There is no task to run tests using JTReg. Please refer to corresponding README file
+in the client sanity test suite folder on how to run the tests.
+
+Contact alexander.kouznetsov@oracle.com in case of issues.
\ No newline at end of file
diff --git a/jdk/make/netbeans/client_sanity/build.xml b/jdk/make/netbeans/client_sanity/build.xml
new file mode 100644
index 00000000000..734fe10b036
--- /dev/null
+++ b/jdk/make/netbeans/client_sanity/build.xml
@@ -0,0 +1,94 @@
+
+
+
+
+
+
+
+
+
+
+ Builds, tests, and runs the project SanityTests.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/jdk/make/netbeans/client_sanity/manifest.mf b/jdk/make/netbeans/client_sanity/manifest.mf
new file mode 100644
index 00000000000..1574df4a2de
--- /dev/null
+++ b/jdk/make/netbeans/client_sanity/manifest.mf
@@ -0,0 +1,3 @@
+Manifest-Version: 1.0
+X-COMMENT: Main-Class will be added automatically by build
+
diff --git a/jdk/make/netbeans/client_sanity/nbproject/build-impl.xml b/jdk/make/netbeans/client_sanity/nbproject/build-impl.xml
new file mode 100644
index 00000000000..00073338957
--- /dev/null
+++ b/jdk/make/netbeans/client_sanity/nbproject/build-impl.xml
@@ -0,0 +1,1429 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Must set src.src3.dir
+ Must set src.src4.dir
+ Must set src.src2.dir
+ Must set src.src.dir
+ Must set build.dir
+ Must set dist.dir
+ Must set build.classes.dir
+ Must set dist.javadoc.dir
+ Must set build.test.classes.dir
+ Must set build.test.results.dir
+ Must set build.classes.excludes
+ Must set dist.jar
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Must set javac.includes
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ No tests executed.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Must set JVM to use for profiling in profiler.info.jvm
+ Must set profiler agent JVM arguments in profiler.info.jvmargs.agent
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Must select some files in the IDE or set javac.includes
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ To run this application from the command line without Ant, try:
+
+ java -jar "${dist.jar.resolved}"
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Must select one file in the IDE or set run.class
+
+
+
+ Must select one file in the IDE or set run.class
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Must select one file in the IDE or set debug.class
+
+
+
+
+ Must select one file in the IDE or set debug.class
+
+
+
+
+ Must set fix.includes
+
+
+
+
+
+
+
+
+
+ This target only works when run from inside the NetBeans IDE.
+
+
+
+
+
+
+
+
+ Must select one file in the IDE or set profile.class
+ This target only works when run from inside the NetBeans IDE.
+
+
+
+
+
+
+
+
+ This target only works when run from inside the NetBeans IDE.
+
+
+
+
+
+
+
+
+
+
+
+
+ This target only works when run from inside the NetBeans IDE.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Must select one file in the IDE or set run.class
+
+
+
+
+
+ Must select some files in the IDE or set test.includes
+
+
+
+
+ Must select one file in the IDE or set run.class
+
+
+
+
+ Must select one file in the IDE or set applet.url
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Must select some files in the IDE or set javac.includes
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Some tests failed; see details above.
+
+
+
+
+
+
+
+
+ Must select some files in the IDE or set test.includes
+
+
+
+ Some tests failed; see details above.
+
+
+
+ Must select some files in the IDE or set test.class
+ Must select some method in the IDE or set test.method
+
+
+
+ Some tests failed; see details above.
+
+
+
+
+ Must select one file in the IDE or set test.class
+
+
+
+ Must select one file in the IDE or set test.class
+ Must select some method in the IDE or set test.method
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Must select one file in the IDE or set applet.url
+
+
+
+
+
+
+
+
+ Must select one file in the IDE or set applet.url
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/jdk/make/netbeans/client_sanity/nbproject/genfiles.properties b/jdk/make/netbeans/client_sanity/nbproject/genfiles.properties
new file mode 100644
index 00000000000..fc956fd5f2e
--- /dev/null
+++ b/jdk/make/netbeans/client_sanity/nbproject/genfiles.properties
@@ -0,0 +1,8 @@
+build.xml.data.CRC32=0f9d9977
+build.xml.script.CRC32=f902e8b8
+build.xml.stylesheet.CRC32=8064a381@1.75.2.48
+# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml.
+# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you.
+nbproject/build-impl.xml.data.CRC32=55414227
+nbproject/build-impl.xml.script.CRC32=c12f9d04
+nbproject/build-impl.xml.stylesheet.CRC32=05530350@1.79.1.48
diff --git a/jdk/make/netbeans/client_sanity/nbproject/project.properties b/jdk/make/netbeans/client_sanity/nbproject/project.properties
new file mode 100644
index 00000000000..a43ee024fd8
--- /dev/null
+++ b/jdk/make/netbeans/client_sanity/nbproject/project.properties
@@ -0,0 +1,79 @@
+annotation.processing.enabled=true
+annotation.processing.enabled.in.editor=false
+annotation.processing.processors.list=
+annotation.processing.run.all.processors=true
+annotation.processing.source.output=${build.generated.sources.dir}/ap-source-output
+application.title=SanityTests
+application.vendor=akouznet
+build.classes.dir=${build.dir}/classes
+build.classes.excludes=**/*.java,**/*.form
+# This directory is removed when the project is cleaned:
+build.dir=build
+build.generated.dir=${build.dir}/generated
+build.generated.sources.dir=${build.dir}/generated-sources
+# Only compile against the classpath explicitly listed here:
+build.sysclasspath=ignore
+build.test.classes.dir=${build.dir}/test/classes
+build.test.results.dir=${build.dir}/test/results
+# Uncomment to specify the preferred debugger connection transport:
+#debug.transport=dt_socket
+debug.classpath=\
+ ${run.classpath}
+debug.test.classpath=\
+ ${run.test.classpath}
+# Files in build.classes.dir which should be excluded from distribution jar
+dist.archive.excludes=
+# This directory is removed when the project is cleaned:
+dist.dir=dist
+dist.jar=${dist.dir}/SanityTests.jar
+dist.javadoc.dir=${dist.dir}/javadoc
+endorsed.classpath=
+excludes=*.cfg
+includes=**
+jar.compress=false
+javac.classpath=\
+ ${libs.testng.classpath}
+# Space-separated list of extra javac options
+javac.compilerargs=-Xmaxwarns 9999 -Xlint:all -Xlint:-serial
+javac.deprecation=false
+javac.external.vm=false
+javac.processorpath=\
+ ${javac.classpath}
+javac.source=1.8
+javac.target=1.8
+javac.test.classpath=\
+ ${javac.classpath}:\
+ ${build.classes.dir}
+javac.test.processorpath=\
+ ${javac.test.classpath}
+javadoc.additionalparam=
+javadoc.author=false
+javadoc.encoding=${source.encoding}
+javadoc.noindex=false
+javadoc.nonavbar=false
+javadoc.notree=false
+javadoc.private=false
+javadoc.splitindex=true
+javadoc.use=true
+javadoc.version=false
+javadoc.windowtitle=
+main.class=
+manifest.file=manifest.mf
+meta.inf.dir=${src.dir}/META-INF
+mkdist.disabled=false
+platform.active=default_platform
+run.classpath=\
+ ${javac.classpath}:\
+ ${build.classes.dir}
+# Space-separated list of JVM arguments used when running the project.
+# You may also define separate properties like run-sys-prop.name=value instead of -Dname=value.
+# To set system properties for unit tests define test-sys-prop.name=value:
+run.jvmargs=-ea
+run.test.classpath=\
+ ${javac.test.classpath}:\
+ ${build.test.classes.dir}
+source.encoding=UTF-8
+src.src.dir=..\\..\\..\\test\\sanity\\client\\SwingSet\\src
+src.src2.dir=..\\..\\..\\test\\sanity\\client\\lib\\SwingSet3\\src
+src.src3.dir=..\\..\\..\\test\\sanity\\client\\lib\\jemmy\\src
+src.src4.dir=..\\..\\..\\test\\sanity\\client\\lib\\Jemmy2Ext\\src
diff --git a/jdk/make/netbeans/client_sanity/nbproject/project.xml b/jdk/make/netbeans/client_sanity/nbproject/project.xml
new file mode 100644
index 00000000000..fccac4ecf31
--- /dev/null
+++ b/jdk/make/netbeans/client_sanity/nbproject/project.xml
@@ -0,0 +1,17 @@
+
+
+ org.netbeans.modules.java.j2seproject
+
+
+ SanityTests
+
+
+
+
+
+
+
+
+
+
+
diff --git a/jdk/make/rmic/RmicCommon.gmk b/jdk/make/rmic/RmicCommon.gmk
index 45fd1de853f..e284054967f 100644
--- a/jdk/make/rmic/RmicCommon.gmk
+++ b/jdk/make/rmic/RmicCommon.gmk
@@ -31,7 +31,13 @@ include RMICompilation.gmk
##########################################################################################
-RMIC := $(JAVA) $(INTERIM_OVERRIDE_MODULES_ARGS) sun.rmi.rmic.Main
+ifeq ($(BOOT_JDK_MODULAR), true)
+ RMIC_MAIN_CLASS := -m jdk.rmic/sun.rmi.rmic.Main
+else
+ RMIC_MAIN_CLASS := sun.rmi.rmic.Main
+endif
+
+RMIC := $(JAVA) $(INTERIM_OVERRIDE_MODULES_ARGS) $(RMIC_MAIN_CLASS)
CLASSES_DIR := $(JDK_OUTPUTDIR)/modules
# NOTE: If the smart javac dependency management is reintroduced, these classes risk
diff --git a/jdk/make/src/classes/build/tools/module/GenModuleInfoSource.java b/jdk/make/src/classes/build/tools/module/GenModuleInfoSource.java
index 255e5ef64ca..f2f404e9a0b 100644
--- a/jdk/make/src/classes/build/tools/module/GenModuleInfoSource.java
+++ b/jdk/make/src/classes/build/tools/module/GenModuleInfoSource.java
@@ -25,25 +25,27 @@
package build.tools.module;
import java.io.BufferedWriter;
+import java.io.IOException;
+import java.io.PrintWriter;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.HashMap;
import java.util.HashSet;
+import java.util.List;
import java.util.Map;
+import java.util.Objects;
import java.util.Set;
+import java.util.stream.Collectors;
/**
- * A build tool to extend the module-info.java in the source tree
- * for platform-specific exports, uses, and provides and write
- * to the specified output file.
+ * A build tool to extend the module-info.java in the source tree for
+ * platform-specific exports, uses, and provides and write to the specified
+ * output file. Injecting platform-specific requires is not supported.
*
- * GenModulesList build tool currently generates the modules.list from
- * the module-info.java from the source tree that will be used for
- * the make target and dependences.
- *
- * The build currently invokes gensrc-$MODULE.gmk after modules.list
- * is generated. Hence, platform-specific requires is not supported.
+ * The extra exports, uses, provides can be specified in module-info.java.extra
+ * files and GenModuleInfoSource will be invoked for each module that has
+ * module-info.java.extra in the source directory.
*/
public class GenModuleInfoSource {
private final static String USAGE =
@@ -57,17 +59,32 @@ public class GenModuleInfoSource {
public static void main(String... args) throws Exception {
Path outfile = null;
Path moduleInfoJava = null;
- Map> options = new HashMap<>();
+ GenModuleInfoSource genModuleInfo = new GenModuleInfoSource();
// validate input arguments
for (int i = 0; i < args.length; i++){
String option = args[i];
if (option.startsWith("-")) {
String arg = args[++i];
- if (option.equals("-exports") ||
- option.equals("-uses") ||
- option.equals("-provides")) {
- options.computeIfAbsent(option, _k -> new HashSet<>()).add(arg);
+ if (option.equals("-exports")) {
+ int index = arg.indexOf('/');
+ if (index > 0) {
+ String pn = arg.substring(0, index);
+ String mn = arg.substring(index + 1, arg.length());
+ genModuleInfo.exportTo(pn, mn);
+ } else {
+ genModuleInfo.export(arg);
+ }
+ } else if (option.equals("-uses")) {
+ genModuleInfo.use(arg);
+ } else if (option.equals("-provides")) {
+ int index = arg.indexOf('/');
+ if (index <= 0) {
+ throw new IllegalArgumentException("invalid -provide argument: " + arg);
+ }
+ String service = arg.substring(0, index);
+ String impl = arg.substring(index + 1, arg.length());
+ genModuleInfo.provide(service, impl);
} else if (option.equals("-o")) {
outfile = Paths.get(arg);
} else {
@@ -87,48 +104,145 @@ public class GenModuleInfoSource {
System.err.println(USAGE);
System.exit(-1);
}
- // read module-info.java
- Module.Builder builder = ModuleInfoReader.builder(moduleInfoJava);
- augment(builder, options);
// generate new module-info.java
- Module module = builder.build();
+ genModuleInfo.generate(moduleInfoJava, outfile);
+ }
+
+ private final Set exports = new HashSet<>();
+ private final Map> exportsTo = new HashMap<>();
+ private final Set uses = new HashSet<>();
+ private final Map> provides = new HashMap<>();
+ GenModuleInfoSource() {
+ }
+
+ private void export(String p) {
+ Objects.requireNonNull(p);
+ if (exports.contains(p) || exportsTo.containsKey(p)) {
+ throw new RuntimeException("duplicated exports: " + p);
+ }
+ exports.add(p);
+ }
+ private void exportTo(String p, String mn) {
+ Objects.requireNonNull(p);
+ Objects.requireNonNull(mn);
+ if (exports.contains(p)) {
+ throw new RuntimeException("unqualified exports already exists: " + p);
+ }
+ exportsTo.computeIfAbsent(p, _k -> new HashSet<>()).add(mn);
+ }
+
+ private void use(String service) {
+ uses.add(service);
+ }
+
+ private void provide(String s, String impl) {
+ provides.computeIfAbsent(s, _k -> new HashSet<>()).add(impl);
+ }
+
+ private void generate(Path sourcefile, Path outfile) throws IOException {
Path parent = outfile.getParent();
if (parent != null)
Files.createDirectories(parent);
- try (BufferedWriter writer = Files.newBufferedWriter(outfile)) {
- writer.write(module.toString());
- }
- }
+ List lines = Files.readAllLines(sourcefile);
+ try (BufferedWriter bw = Files.newBufferedWriter(outfile);
+ PrintWriter writer = new PrintWriter(bw)) {
+ int lineNumber = 0;
+ for (String l : lines) {
+ lineNumber++;
+ String[] s = l.trim().split("\\s+");
+ String keyword = s[0].trim();
+ int nextIndex = keyword.length();
+ String exp = null;
+ int n = l.length();
+ switch (keyword) {
+ case "exports":
+ boolean inExportsTo = false;
+ // assume package name immediately after exports
+ exp = s[1].trim();
+ if (s.length >= 3) {
+ nextIndex = l.indexOf(exp, nextIndex) + exp.length();
+ if (s[2].trim().equals("to")) {
+ inExportsTo = true;
+ n = l.indexOf("to", nextIndex) + "to".length();
+ } else {
+ throw new RuntimeException(sourcefile + ", line " +
+ lineNumber + ", is malformed: " + s[2]);
+ }
+ }
- private static void augment(Module.Builder builder, Map> options) {
- for (String opt : options.keySet()) {
- if (opt.equals("-exports")) {
- for (String arg : options.get(opt)) {
- int index = arg.indexOf('/');
- if (index > 0) {
- String pn = arg.substring(0, index);
- String mn = arg.substring(index + 1, arg.length());
- builder.exportTo(pn, mn);
- } else {
- builder.export(arg);
- }
- }
- } else if (opt.equals("-uses")) {
- options.get(opt).stream()
- .forEach(builder::use);
- } else if (opt.equals("-provides")) {
- for (String arg : options.get(opt)) {
- int index = arg.indexOf('/');
- if (index <= 0) {
- throw new IllegalArgumentException("invalid -provide argument: " + arg);
- }
- String service = arg.substring(0, index);
- String impl = arg.substring(index + 1, arg.length());
- builder.provide(service, impl);
+ // inject the extra targets after "to"
+ if (inExportsTo) {
+ writer.println(injectExportTargets(exp, l, n));
+ } else {
+ writer.println(l);
+ }
+ break;
+ case "to":
+ if (exp == null) {
+ throw new RuntimeException(sourcefile + ", line " +
+ lineNumber + ", is malformed");
+ }
+ n = l.indexOf("to", nextIndex) + "to".length();
+ writer.println(injectExportTargets(exp, l, n));
+ break;
+ case "}":
+ doAugments(writer);
+ // fall through
+ default:
+ writer.println(l);
+ // reset exports
+ exp = null;
}
}
}
}
+
+ private String injectExportTargets(String pn, String exp, int pos) {
+ Set targets = exportsTo.remove(pn);
+ if (targets != null) {
+ StringBuilder sb = new StringBuilder();
+ // inject the extra targets after the given pos
+ sb.append(exp.substring(0, pos))
+ .append("\n\t")
+ .append(targets.stream()
+ .collect(Collectors.joining(",", "", ",")))
+ .append(" /* injected */");
+ if (pos < exp.length()) {
+ // print the remaining statement followed "to"
+ sb.append("\n\t")
+ .append(exp.substring(pos+1, exp.length()));
+ }
+ return sb.toString();
+ } else {
+ return exp;
+ }
+ }
+
+ private void doAugments(PrintWriter writer) {
+ if ((exports.size() + exportsTo.size() + uses.size() + provides.size()) == 0)
+ return;
+
+ writer.println(" // augmented from module-info.java.extra");
+ exports.stream()
+ .sorted()
+ .forEach(e -> writer.format(" exports %s;%n", e));
+ // remaining injected qualified exports
+ exportsTo.entrySet().stream()
+ .sorted(Map.Entry.comparingByKey())
+ .map(e -> String.format(" exports %s to%n%s;", e.getKey(),
+ e.getValue().stream().sorted()
+ .map(mn -> String.format(" %s", mn))
+ .collect(Collectors.joining(",\n"))))
+ .forEach(writer::println);
+ uses.stream().sorted()
+ .forEach(s -> writer.format(" uses %s;%n", s));
+ provides.entrySet().stream()
+ .sorted(Map.Entry.comparingByKey())
+ .flatMap(e -> e.getValue().stream().sorted()
+ .map(impl -> String.format(" provides %s with %s;",
+ e.getKey(), impl)))
+ .forEach(writer::println);
+ }
}
diff --git a/jdk/make/src/classes/build/tools/module/Module.java b/jdk/make/src/classes/build/tools/module/Module.java
deleted file mode 100644
index e553d92ace8..00000000000
--- a/jdk/make/src/classes/build/tools/module/Module.java
+++ /dev/null
@@ -1,280 +0,0 @@
-/*
- * Copyright (c) 2014, 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 build.tools.module;
-
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Map;
-import java.util.Objects;
-import java.util.Set;
-import java.util.stream.Collectors;
-import java.util.stream.Stream;
-
-public class Module {
- public static class Dependence implements Comparable {
- final String name;
- final boolean reexport;
- Dependence(String name) {
- this(name, false);
- }
- Dependence(String name, boolean reexport) {
- this.name = name;
- this.reexport = reexport;
- }
-
- public String name() {
- return name;
- }
-
- public boolean reexport(){
- return reexport;
- }
-
- @Override
- public int hashCode() {
- int hash = 5;
- hash = 11 * hash + Objects.hashCode(this.name);
- hash = 11 * hash + (this.reexport ? 1 : 0);
- return hash;
- }
-
- public boolean equals(Object o) {
- Dependence d = (Dependence)o;
- return this.name.equals(d.name) && this.reexport == d.reexport;
- }
-
- @Override
- public int compareTo(Dependence o) {
- int rc = this.name.compareTo(o.name);
- return rc != 0 ? rc : Boolean.compare(this.reexport, o.reexport);
- }
-
- @Override
- public String toString() {
- return String.format("requires %s%s;",
- reexport ? "public " : "", name);
- }
- }
- private final String moduleName;
- private final Set requires;
- private final Map> exports;
- private final Set uses;
- private final Map> provides;
-
- private Module(String name,
- Set requires,
- Map> exports,
- Set uses,
- Map> provides) {
- this.moduleName = name;
- this.requires = Collections.unmodifiableSet(requires);
- this.exports = Collections.unmodifiableMap(exports);
- this.uses = Collections.unmodifiableSet(uses);
- this.provides = Collections.unmodifiableMap(provides);
- }
-
- public String name() {
- return moduleName;
- }
-
- public Set requires() {
- return requires;
- }
-
- public Map> exports() {
- return exports;
- }
-
- public Set uses() {
- return uses;
- }
-
- public Map> provides() {
- return provides;
- }
-
- @Override
- public boolean equals(Object ob) {
- if (!(ob instanceof Module)) {
- return false;
- }
- Module that = (Module) ob;
- return (moduleName.equals(that.moduleName)
- && requires.equals(that.requires)
- && exports.equals(that.exports));
- }
-
- @Override
- public int hashCode() {
- int hc = moduleName.hashCode();
- hc = hc * 43 + requires.hashCode();
- hc = hc * 43 + exports.hashCode();
- return hc;
- }
-
- @Override
- public String toString() {
- StringBuilder sb = new StringBuilder();
- sb.append(String.format("module %s {%n", moduleName));
- requires.stream()
- .sorted()
- .map(d -> String.format(" requires %s%s;%n", d.reexport ? "public " : "", d.name))
- .forEach(sb::append);
- exports.entrySet().stream()
- .filter(e -> e.getValue().isEmpty())
- .sorted(Map.Entry.comparingByKey())
- .map(e -> String.format(" exports %s;%n", e.getKey()))
- .forEach(sb::append);
- exports.entrySet().stream()
- .filter(e -> !e.getValue().isEmpty())
- .sorted(Map.Entry.comparingByKey())
- .map(e -> String.format(" exports %s to%n%s;%n", e.getKey(),
- e.getValue().stream().sorted()
- .map(mn -> String.format(" %s", mn))
- .collect(Collectors.joining(",\n"))))
- .forEach(sb::append);
- uses.stream().sorted()
- .map(s -> String.format(" uses %s;%n", s))
- .forEach(sb::append);
- provides.entrySet().stream()
- .sorted(Map.Entry.comparingByKey())
- .flatMap(e -> e.getValue().stream().sorted()
- .map(impl -> String.format(" provides %s with %s;%n", e.getKey(), impl)))
- .forEach(sb::append);
- sb.append("}").append("\n");
- return sb.toString();
- }
-
- /**
- * Module Builder
- */
- static class Builder {
- private String name;
- final Set requires = new HashSet<>();
- final Map> exports = new HashMap<>();
- final Set uses = new HashSet<>();
- final Map> provides = new HashMap<>();
-
- public Builder() {
- }
-
- public Builder name(String n) {
- name = n;
- return this;
- }
-
- public Builder require(String d, boolean reexport) {
- requires.add(new Dependence(d, reexport));
- return this;
- }
-
- public Builder export(String p) {
- Objects.requireNonNull(p);
- if (exports.containsKey(p)) {
- throw new RuntimeException(name + " already exports " + p +
- " " + exports.get(p));
- }
- return exportTo(p, Collections.emptySet());
- }
-
- public Builder exportTo(String p, String mn) {
- Objects.requireNonNull(p);
- Objects.requireNonNull(mn);
- Set ms = exports.get(p);
- if (ms != null && ms.isEmpty()) {
- throw new RuntimeException(name + " already has unqualified exports " + p);
- }
- exports.computeIfAbsent(p, _k -> new HashSet<>()).add(mn);
- return this;
- }
-
- public Builder exportTo(String p, Set ms) {
- Objects.requireNonNull(p);
- Objects.requireNonNull(ms);
- if (exports.containsKey(p)) {
- throw new RuntimeException(name + " already exports " + p +
- " " + exports.get(p));
- }
- exports.put(p, new HashSet<>(ms));
- return this;
- }
-
- public Builder use(String cn) {
- uses.add(cn);
- return this;
- }
-
- public Builder provide(String s, String impl) {
- provides.computeIfAbsent(s, _k -> new HashSet<>()).add(impl);
- return this;
- }
-
- public Builder merge(Module m1, Module m2) {
- if (!m1.name().equals(m2.name())) {
- throw new IllegalArgumentException(m1.name() + " != " + m2.name());
- }
- name = m1.name();
- // ## reexports
- requires.addAll(m1.requires());
- requires.addAll(m2.requires());
- Stream.concat(m1.exports().keySet().stream(), m2.exports().keySet().stream())
- .distinct()
- .forEach(pn -> {
- Set s1 = m2.exports().get(pn);
- Set s2 = m2.exports().get(pn);
- if (s1 == null || s2 == null) {
- exportTo(pn, s1 != null ? s1 : s2);
- } else if (s1.isEmpty() || s2.isEmpty()) {
- // unqualified exports
- export(pn);
- } else {
- exportTo(pn, Stream.concat(s1.stream(), s2.stream())
- .collect(Collectors.toSet()));
- }
- });
- uses.addAll(m1.uses());
- uses.addAll(m2.uses());
- m1.provides().keySet().stream()
- .forEach(s -> m1.provides().get(s).stream()
- .forEach(impl -> provide(s, impl)));
- m2.provides().keySet().stream()
- .forEach(s -> m2.provides().get(s).stream()
- .forEach(impl -> provide(s, impl)));
- return this;
- }
-
- public Module build() {
- Module m = new Module(name, requires, exports, uses, provides);
- return m;
- }
-
- @Override
- public String toString() {
- return name != null ? name : "Unknown";
- }
- }
-}
diff --git a/jdk/make/src/classes/build/tools/module/ModuleInfoReader.java b/jdk/make/src/classes/build/tools/module/ModuleInfoReader.java
deleted file mode 100644
index 04ff42b39ba..00000000000
--- a/jdk/make/src/classes/build/tools/module/ModuleInfoReader.java
+++ /dev/null
@@ -1,357 +0,0 @@
-/*
- * Copyright (c) 2015, 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 build.tools.module;
-
-import java.io.IOException;
-import java.nio.file.Files;
-import java.nio.file.Path;
-import java.util.List;
-import java.util.function.Supplier;
-import java.util.regex.Pattern;
-import java.util.stream.Stream;
-
-import build.tools.module.Module.Builder;
-
-/**
- * Source reader of module-info.java
- */
-public class ModuleInfoReader {
- private final Path sourcefile;
- private final Builder builder;
- private ModuleInfoReader(Path file) {
- this.sourcefile = file;
- this.builder = new Builder();
- }
-
- public static Builder builder(Path file) throws IOException {
- ModuleInfoReader reader = new ModuleInfoReader(file);
- reader.readFile();
- return reader.builder;
- }
-
- /**
- * Reads the source file.
- */
- void readFile() throws IOException {
- List lines = Files.readAllLines(sourcefile);
- boolean done = false;
- int lineNumber = 0;
- boolean inBlockComment = false;
- boolean inRequires = false;
- boolean reexports = false;
- boolean inProvides = false;
- boolean inWith = false;
- String serviceIntf = null;
- String providerClass = null;
- boolean inUses = false;
- boolean inExports = false;
- boolean inExportsTo = false;
- String qualifiedExports = null;
- Counter counter = new Counter();
-
- for (String line : lines) {
- lineNumber++;
- if (inBlockComment) {
- int c = line.indexOf("*/");
- if (c >= 0) {
- line = line.substring(c + 2, line.length());
- inBlockComment = false;
- } else {
- // skip lines until end of comment block
- continue;
- }
- }
- inBlockComment = beginBlockComment(line);
-
- line = trimComment(line).trim();
- // ignore empty lines
- if (line.length() == 0) {
- continue;
- }
- String values;
- if (inRequires || inExports | inUses | (inWith && providerClass == null)) {
- values = line;
- } else {
- String[] s = line.split("\\s+");
- String keyword = s[0].trim();
- int nextIndex = keyword.length();
- switch (keyword) {
- case "module":
- if (s.length != 3 || !s[2].trim().equals("{")) {
- throw new RuntimeException(sourcefile + ", line " +
- lineNumber + ", is malformed");
- }
- builder.name(s[1].trim());
- continue; // next line
- case "requires":
- inRequires = true;
- counter.numRequires++;
- if (s.length >= 2) {
- String ss = s[1].trim();
- if (ss.equals("public")) {
- nextIndex = line.indexOf(ss) + ss.length();
- reexports = true;
- }
- }
- break;
- case "exports":
- inExports = true;
- inExportsTo = false;
- counter.numExports++;
- qualifiedExports = null;
- if (s.length >= 3) {
- qualifiedExports = s[1].trim();
- nextIndex = line.indexOf(qualifiedExports, nextIndex)
- + qualifiedExports.length();
- if (s[2].trim().equals("to")) {
- inExportsTo = true;
- nextIndex = line.indexOf("to", nextIndex) + "to".length();
- } else {
- throw new RuntimeException(sourcefile + ", line " +
- lineNumber + ", is malformed: " + s[2]);
- }
- }
- break;
- case "to":
- if (!inExports || qualifiedExports == null) {
- throw new RuntimeException(sourcefile + ", line " +
- lineNumber + ", is malformed");
- }
- inExportsTo = true;
- break;
- case "uses":
- inUses = true;
- counter.numUses++;
- break;
- case "provides":
- inProvides = true;
- inWith = false;
- counter.numProvides++;
- serviceIntf = null;
- providerClass = null;
- if (s.length >= 2) {
- serviceIntf = s[1].trim();
- nextIndex = line.indexOf(serviceIntf) + serviceIntf.length();
- }
- if (s.length >= 3) {
- if (s[2].trim().equals("with")) {
- inWith = true;
- nextIndex = line.indexOf("with") + "with".length();
- } else {
- throw new RuntimeException(sourcefile + ", line " +
- lineNumber + ", is malformed: " + s[2]);
- }
- }
- break;
- case "with":
- if (!inProvides || serviceIntf == null) {
- throw new RuntimeException(sourcefile + ", line " +
- lineNumber + ", is malformed");
- }
- inWith = true;
- nextIndex = line.indexOf("with") + "with".length();
- break;
- case "}":
- counter.validate(builder);
- done = true;
- continue; // next line
- default:
- throw new RuntimeException(sourcefile + ", \"" +
- keyword + "\" on line " +
- lineNumber + ", is not recognized");
- }
- values = line.substring(nextIndex, line.length()).trim();
- }
-
- int len = values.length();
- if (len == 0) {
- continue; // next line
- }
- char lastchar = values.charAt(len - 1);
- if (lastchar != ',' && lastchar != ';') {
- throw new RuntimeException(sourcefile + ", line " +
- lineNumber + ", is malformed:" +
- " ',' or ';' is missing.");
- }
-
- values = values.substring(0, len - 1).trim();
- // parse the values specified for a keyword specified
- for (String s : values.split(",")) {
- s = s.trim();
- if (s.length() > 0) {
- if (inRequires) {
- if (builder.requires.contains(s)) {
- throw new RuntimeException(sourcefile + ", line "
- + lineNumber + " duplicated requires: \"" + s + "\"");
- }
- builder.require(s, reexports);
- } else if (inExports) {
- if (!inExportsTo && qualifiedExports == null) {
- builder.export(s);
- } else {
- builder.exportTo(qualifiedExports, s);
- }
- } else if (inUses) {
- builder.use(s);
- } else if (inProvides) {
- if (!inWith) {
- serviceIntf = s;
- } else {
- providerClass = s;
- builder.provide(serviceIntf, providerClass);
- }
- }
- }
- }
- if (lastchar == ';') {
- inRequires = false;
- reexports = false;
- inExports = false;
- inExportsTo = false;
- inProvides = false;
- inWith = false;
- inUses = false;
- }
- }
-
- if (inBlockComment) {
- throw new RuntimeException(sourcefile + ", line " +
- lineNumber + ", missing \"*/\" to end a block comment");
- }
- if (!done) {
- throw new RuntimeException(sourcefile + ", line " +
- lineNumber + ", missing \"}\" to end module definition" +
- " for \"" + builder + "\"");
- }
- return;
- }
-
- // the naming convention for the module names without dashes
- private static final Pattern CLASS_NAME_PATTERN = Pattern.compile("[\\w\\.\\*_$/]+");
- private static boolean beginBlockComment(String line) {
- int pos = 0;
- while (pos >= 0 && pos < line.length()) {
- int c = line.indexOf("/*", pos);
- if (c < 0) {
- return false;
- }
-
- if (c > 0 && !Character.isWhitespace(line.charAt(c - 1))) {
- return false;
- }
-
- int c1 = line.indexOf("//", pos);
- if (c1 >= 0 && c1 < c) {
- return false;
- }
-
- int c2 = line.indexOf("*/", c + 2);
- if (c2 < 0) {
- return true;
- }
- pos = c + 2;
- }
- return false;
- }
- private static String trimComment(String line) {
- StringBuilder sb = new StringBuilder();
-
- int pos = 0;
- while (pos >= 0 && pos < line.length()) {
- int c1 = line.indexOf("//", pos);
- if (c1 > 0 && !Character.isWhitespace(line.charAt(c1 - 1))) {
- // not a comment
- c1 = -1;
- }
-
- int c2 = line.indexOf("/*", pos);
- if (c2 > 0 && !Character.isWhitespace(line.charAt(c2 - 1))) {
- // not a comment
- c2 = -1;
- }
-
- int c = line.length();
- int n = line.length();
- if (c1 >= 0 || c2 >= 0) {
- if (c1 >= 0) {
- c = c1;
- }
- if (c2 >= 0 && c2 < c) {
- c = c2;
- }
- int c3 = line.indexOf("*/", c2 + 2);
- if (c == c2 && c3 > c2) {
- n = c3 + 2;
- }
- }
- if (c > 0) {
- if (sb.length() > 0) {
- // add a whitespace if multiple comments on one line
- sb.append(" ");
- }
- sb.append(line.substring(pos, c));
- }
- pos = n;
- }
- return sb.toString();
- }
-
-
- static class Counter {
- int numRequires;
- int numExports;
- int numUses;
- int numProvides;
-
- void validate(Builder builder) {
- assertEquals("requires", numRequires, builder.requires.size(),
- () -> builder.requires.stream()
- .map(Module.Dependence::toString));
- assertEquals("exports", numExports, builder.exports.size(),
- () -> builder.exports.entrySet().stream()
- .map(e -> "exports " + e.getKey() + " to " + e.getValue()));
- assertEquals("uses", numUses, builder.uses.size(),
- () -> builder.uses.stream());
- assertEquals("provides", numProvides,
- (int)builder.provides.values().stream()
- .flatMap(s -> s.stream())
- .count(),
- () -> builder.provides.entrySet().stream()
- .map(e -> "provides " + e.getKey() + " with " + e.getValue()));
- }
-
- private static void assertEquals(String msg, int expected, int got,
- Supplier> supplier) {
- if (expected != got){
- System.err.println("ERROR: mismatched " + msg +
- " expected: " + expected + " got: " + got );
- supplier.get().sorted()
- .forEach(System.err::println);
- throw new AssertionError("mismatched " + msg +
- " expected: " + expected + " got: " + got + " ");
- }
- }
- }
-}
diff --git a/jdk/make/src/classes/build/tools/module/ModulesXmlReader.java b/jdk/make/src/classes/build/tools/module/ModulesXmlReader.java
deleted file mode 100644
index e8b2d546a04..00000000000
--- a/jdk/make/src/classes/build/tools/module/ModulesXmlReader.java
+++ /dev/null
@@ -1,162 +0,0 @@
-/*
- * Copyright (c) 2014, 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 build.tools.module;
-
-import javax.xml.namespace.QName;
-import javax.xml.stream.XMLEventReader;
-import javax.xml.stream.XMLInputFactory;
-import javax.xml.stream.XMLStreamException;
-import javax.xml.stream.events.Attribute;
-import javax.xml.stream.events.XMLEvent;
-import java.io.BufferedInputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.nio.file.Files;
-import java.nio.file.Path;
-import java.util.HashSet;
-import java.util.Set;
-
-public class ModulesXmlReader {
-
- private ModulesXmlReader() {}
-
- public static Set readModules(Path modulesXml)
- throws XMLStreamException, IOException
- {
- Set modules = new HashSet<>();
- try (InputStream in = new BufferedInputStream(Files.newInputStream(modulesXml))) {
- Set mods = ModulesXmlReader.load(in);
- modules.addAll(mods);
- }
- return modules;
- }
-
- private static final String MODULES = "modules";
- private static final String MODULE = "module";
- private static final String NAME = "name";
- private static final String DEPEND = "depend";
- private static final String EXPORT = "export";
- private static final String TO = "to";
- private static final QName REEXPORTS = new QName("re-exports");
- private static Set load(InputStream in)
- throws XMLStreamException, IOException
- {
- Set modules = new HashSet<>();
- XMLInputFactory factory = XMLInputFactory.newInstance();
- XMLEventReader stream = factory.createXMLEventReader(in);
- Module.Builder mb = null;
- String modulename = null;
- String pkg = null;
- Set permits = new HashSet<>();
- while (stream.hasNext()) {
- XMLEvent event = stream.nextEvent();
- if (event.isStartElement()) {
- String startTag = event.asStartElement().getName().getLocalPart();
- switch (startTag) {
- case MODULES:
- break;
- case MODULE:
- if (mb != null) {
- throw new RuntimeException("end tag for module is missing");
- }
- modulename = getNextTag(stream, NAME);
- mb = new Module.Builder();
- mb.name(modulename);
- break;
- case NAME:
- throw new RuntimeException(event.toString());
- case DEPEND:
- boolean reexports = false;
- Attribute attr = event.asStartElement().getAttributeByName(REEXPORTS);
- if (attr != null) {
- String value = attr.getValue();
- if (value.equals("true") || value.equals("false")) {
- reexports = Boolean.parseBoolean(value);
- } else {
- throw new RuntimeException("unexpected attribute " + attr.toString());
- }
- }
- mb.require(getData(stream), reexports);
- break;
- case EXPORT:
- pkg = getNextTag(stream, NAME);
- break;
- case TO:
- permits.add(getData(stream));
- break;
- default:
- }
- } else if (event.isEndElement()) {
- String endTag = event.asEndElement().getName().getLocalPart();
- switch (endTag) {
- case MODULE:
- modules.add(mb.build());
- mb = null;
- break;
- case EXPORT:
- if (pkg == null) {
- throw new RuntimeException("export-to is malformed");
- }
- mb.exportTo(pkg, permits);
- pkg = null;
- permits.clear();
- break;
- default:
- }
- } else if (event.isCharacters()) {
- String s = event.asCharacters().getData();
- if (!s.trim().isEmpty()) {
- throw new RuntimeException("export-to is malformed");
- }
- }
- }
- return modules;
- }
-
- private static String getData(XMLEventReader reader)
- throws XMLStreamException
- {
- XMLEvent e = reader.nextEvent();
- if (e.isCharacters())
- return e.asCharacters().getData();
-
- throw new RuntimeException(e.toString());
- }
-
- private static String getNextTag(XMLEventReader reader, String tag)
- throws XMLStreamException
- {
- XMLEvent e = reader.nextTag();
- if (e.isStartElement()) {
- String t = e.asStartElement().getName().getLocalPart();
- if (!tag.equals(t)) {
- throw new RuntimeException(e + " expected: " + tag);
- }
- return getData(reader);
- }
- throw new RuntimeException("export-to name is missing:" + e);
- }
-}
diff --git a/jdk/make/src/classes/build/tools/module/ModulesXmlWriter.java b/jdk/make/src/classes/build/tools/module/ModulesXmlWriter.java
deleted file mode 100644
index 00fa866424e..00000000000
--- a/jdk/make/src/classes/build/tools/module/ModulesXmlWriter.java
+++ /dev/null
@@ -1,176 +0,0 @@
-/*
- * Copyright (c) 2014, 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 build.tools.module;
-
-import javax.xml.namespace.QName;
-import javax.xml.stream.XMLOutputFactory;
-import javax.xml.stream.XMLStreamException;
-import javax.xml.stream.XMLStreamWriter;
-import java.io.IOException;
-import java.io.OutputStream;
-import java.nio.file.Files;
-import java.nio.file.Path;
-import java.util.Collections;
-import java.util.Comparator;
-import java.util.Map;
-import java.util.Set;
-
-public final class ModulesXmlWriter {
-
- private ModulesXmlWriter() {}
-
- public static void writeModules(Set modules, Path path)
- throws IOException, XMLStreamException
- {
- writeXML(modules, path);
- }
-
- private static final String MODULES = "modules";
- private static final String MODULE = "module";
- private static final String NAME = "name";
- private static final String DEPEND = "depend";
- private static final String EXPORT = "export";
- private static final String TO = "to";
- private static final QName REEXPORTS = new QName("re-exports");
-
- private static void writeXML(Set modules, Path path)
- throws IOException, XMLStreamException
- {
- XMLOutputFactory xof = XMLOutputFactory.newInstance();
- try (OutputStream out = Files.newOutputStream(path)) {
- int depth = 0;
- XMLStreamWriter xtw = xof.createXMLStreamWriter(out, "UTF-8");
- xtw.writeStartDocument("utf-8","1.0");
- writeStartElement(xtw, MODULES, depth);
- modules.stream()
- .sorted(Comparator.comparing(Module::name))
- .forEach(m -> writeModuleElement(xtw, m, depth+1));
- writeEndElement(xtw, depth);
- xtw.writeCharacters("\n");
- xtw.writeEndDocument();
- xtw.flush();
- xtw.close();
- }
- }
-
- private static void writeElement(XMLStreamWriter xtw,
- String element,
- String value,
- int depth) {
- try {
- writeStartElement(xtw, element, depth);
- xtw.writeCharacters(value);
- xtw.writeEndElement();
- } catch (XMLStreamException e) {
- throw new RuntimeException(e);
- }
- }
-
- private static void writeDependElement(XMLStreamWriter xtw,
- Module.Dependence d,
- int depth) {
- try {
- writeStartElement(xtw, DEPEND, depth);
- if (d.reexport) {
- xtw.writeAttribute("re-exports", "true");
- }
- xtw.writeCharacters(d.name);
- xtw.writeEndElement();
- } catch (XMLStreamException e) {
- throw new RuntimeException(e);
- }
- }
-
- private static void writeExportElement(XMLStreamWriter xtw,
- String pkg,
- int depth) {
- writeExportElement(xtw, pkg, Collections.emptySet(), depth);
- }
-
- private static void writeExportElement(XMLStreamWriter xtw,
- String pkg,
- Set permits,
- int depth) {
- try {
- writeStartElement(xtw, EXPORT, depth);
- writeElement(xtw, NAME, pkg, depth+1);
- if (!permits.isEmpty()) {
- permits.stream().sorted()
- .forEach(m -> writeElement(xtw, TO, m, depth + 1));
- }
- writeEndElement(xtw, depth);
- } catch (XMLStreamException e) {
- throw new RuntimeException(e);
- }
- }
- private static void writeModuleElement(XMLStreamWriter xtw,
- Module m,
- int depth) {
- try {
- writeStartElement(xtw, MODULE, depth);
- writeElement(xtw, NAME, m.name(), depth+1);
- m.requires().stream().sorted(Comparator.comparing(d -> d.name))
- .forEach(d -> writeDependElement(xtw, d, depth+1));
- m.exports().keySet().stream()
- .filter(pn -> m.exports().get(pn).isEmpty())
- .sorted()
- .forEach(pn -> writeExportElement(xtw, pn, depth+1));
- m.exports().entrySet().stream()
- .filter(e -> !e.getValue().isEmpty())
- .sorted(Map.Entry.comparingByKey())
- .forEach(e -> writeExportElement(xtw, e.getKey(), e.getValue(), depth+1));
- writeEndElement(xtw, depth);
- } catch (XMLStreamException e) {
- throw new RuntimeException(e);
-
- }
- }
-
- /** Two spaces; the default indentation. */
- public static final String DEFAULT_INDENT = " ";
-
- /** stack[depth] indicates what's been written into the current scope. */
- private static String[] stack = new String[] { "\n",
- "\n" + DEFAULT_INDENT,
- "\n" + DEFAULT_INDENT + DEFAULT_INDENT,
- "\n" + DEFAULT_INDENT + DEFAULT_INDENT + DEFAULT_INDENT};
-
- private static void writeStartElement(XMLStreamWriter xtw,
- String name,
- int depth)
- throws XMLStreamException
- {
- xtw.writeCharacters(stack[depth]);
- xtw.writeStartElement(name);
- }
-
- private static void writeEndElement(XMLStreamWriter xtw, int depth)
- throws XMLStreamException
- {
- xtw.writeCharacters(stack[depth]);
- xtw.writeEndElement();
- }
-}
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 3d9d59fc89e..915dc89f4c8 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
@@ -25,6 +25,7 @@
package java.lang.invoke;
+import jdk.internal.loader.BootLoader;
import jdk.internal.vm.annotation.Stable;
import jdk.internal.org.objectweb.asm.ClassWriter;
import jdk.internal.org.objectweb.asm.FieldVisitor;
@@ -36,6 +37,7 @@ import java.lang.invoke.LambdaForm.NamedFunction;
import java.lang.invoke.MethodHandles.Lookup;
import java.lang.reflect.Field;
import java.util.Arrays;
+import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
import java.util.function.Function;
@@ -463,6 +465,7 @@ import static jdk.internal.org.objectweb.asm.Opcodes.*;
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('/', '.');
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;
@@ -489,7 +492,15 @@ import static jdk.internal.org.objectweb.asm.Opcodes.*;
types, new Function>() {
@Override
public Class extends BoundMethodHandle> apply(String types) {
- return generateConcreteBMHClass(types);
+ String shortTypes = LambdaForm.shortenSignature(types);
+ String className = SPECIES_CLASS_PREFIX + shortTypes;
+ Class> c = BootLoader.loadClassOrNull(className);
+ if (c != null) {
+ return c.asSubclass(BoundMethodHandle.class);
+ } else {
+ // Not pregenerated, generate the class
+ return generateConcreteBMHClass(shortTypes, types);
+ }
}
});
}
@@ -558,12 +569,49 @@ import static jdk.internal.org.objectweb.asm.Opcodes.*;
* @param types the type signature, wherein reference types are erased to 'L'
* @return the generated concrete BMH class
*/
- static Class extends BoundMethodHandle> generateConcreteBMHClass(String types) {
- final ClassWriter cw = new ClassWriter(ClassWriter.COMPUTE_MAXS + ClassWriter.COMPUTE_FRAMES);
+ static Class extends BoundMethodHandle> generateConcreteBMHClass(String shortTypes,
+ String types) {
+ final String className = speciesInternalClassName(shortTypes);
+ byte[] classFile = generateConcreteBMHClassBytes(shortTypes, types, className);
+ // load class
+ InvokerBytecodeGenerator.maybeDump(className, classFile);
+ Class extends BoundMethodHandle> bmhClass =
+ UNSAFE.defineClass(className, classFile, 0, classFile.length,
+ BoundMethodHandle.class.getClassLoader(), null)
+ .asSubclass(BoundMethodHandle.class);
+
+ return bmhClass;
+ }
+
+ /**
+ * @implNote this method is used by GenerateBMHClassesPlugin to enable
+ * ahead-of-time generation of BMH classes at link time. It does
+ * added validation since this string may be user provided.
+ */
+ static Map.Entry generateConcreteBMHClassBytes(
+ final String types) {
+ for (char c : types.toCharArray()) {
+ if ("LIJFD".indexOf(c) < 0) {
+ throw new IllegalArgumentException("All characters must "
+ + "correspond to a basic field type: LIJFD");
+ }
+ }
String shortTypes = LambdaForm.shortenSignature(types);
- final String className = SPECIES_PREFIX_PATH + shortTypes;
+ final String className = speciesInternalClassName(shortTypes);
+ return Map.entry(className,
+ generateConcreteBMHClassBytes(shortTypes, types, className));
+ }
+
+ private static String speciesInternalClassName(String shortTypes) {
+ return SPECIES_PREFIX_PATH + shortTypes;
+ }
+
+ static byte[] generateConcreteBMHClassBytes(final String shortTypes,
+ final String types, final String className) {
final String sourceFile = SPECIES_PREFIX_NAME + shortTypes;
+
+ final ClassWriter cw = new ClassWriter(ClassWriter.COMPUTE_MAXS + ClassWriter.COMPUTE_FRAMES);
final int NOT_ACC_PUBLIC = 0; // not ACC_PUBLIC
cw.visit(V1_6, NOT_ACC_PUBLIC + ACC_FINAL + ACC_SUPER, className, null, BMH, null);
cw.visitSource(sourceFile, null);
@@ -699,16 +747,7 @@ import static jdk.internal.org.objectweb.asm.Opcodes.*;
cw.visitEnd();
- // load class
- final byte[] classFile = cw.toByteArray();
- InvokerBytecodeGenerator.maybeDump(className, classFile);
- Class extends BoundMethodHandle> bmhClass =
- //UNSAFE.defineAnonymousClass(BoundMethodHandle.class, classFile, null).asSubclass(BoundMethodHandle.class);
- UNSAFE.defineClass(className, classFile, 0, classFile.length,
- BoundMethodHandle.class.getClassLoader(), null)
- .asSubclass(BoundMethodHandle.class);
-
- return bmhClass;
+ return cw.toByteArray();
}
private static int typeLoadOp(char t) {
diff --git a/jdk/src/java.base/share/classes/java/lang/invoke/StringConcatFactory.java b/jdk/src/java.base/share/classes/java/lang/invoke/StringConcatFactory.java
index 75776cde90c..f94746a71fa 100644
--- a/jdk/src/java.base/share/classes/java/lang/invoke/StringConcatFactory.java
+++ b/jdk/src/java.base/share/classes/java/lang/invoke/StringConcatFactory.java
@@ -255,7 +255,6 @@ public final class StringConcatFactory {
*/
private static final class Recipe {
private final List elements;
- private final List elementsRev;
public Recipe(String src, Object[] constants) {
List el = new ArrayList<>();
@@ -294,19 +293,13 @@ public final class StringConcatFactory {
el.add(new RecipeElement(acc.toString()));
}
- elements = new ArrayList<>(el);
- Collections.reverse(el);
- elementsRev = el;
+ elements = el;
}
- public Collection getElements() {
+ public List getElements() {
return elements;
}
- public Collection getElementsReversed() {
- return elementsRev;
- }
-
@Override
public boolean equals(Object o) {
if (this == o) return true;
@@ -1310,7 +1303,9 @@ public final class StringConcatFactory {
// Compose append calls. This is done in reverse because the application order is
// reverse as well.
- for (RecipeElement el : recipe.getElementsReversed()) {
+ List elements = recipe.getElements();
+ for (int i = elements.size() - 1; i >= 0; i--) {
+ RecipeElement el = elements.get(i);
MethodHandle appender;
switch (el.getTag()) {
case CONST: {
diff --git a/jdk/src/java.base/share/classes/java/util/AbstractList.java b/jdk/src/java.base/share/classes/java/util/AbstractList.java
index 9e53ab475b3..3168a738acc 100644
--- a/jdk/src/java.base/share/classes/java/util/AbstractList.java
+++ b/jdk/src/java.base/share/classes/java/util/AbstractList.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -462,10 +462,9 @@ public abstract class AbstractList extends AbstractCollection implements L
* @implSpec
* This implementation returns a list that subclasses
* {@code AbstractList}. The subclass stores, in private fields, the
- * offset of the subList within the backing list, the size of the subList
- * (which can change over its lifetime), and the expected
- * {@code modCount} value of the backing list. There are two variants
- * of the subclass, one of which implements {@code RandomAccess}.
+ * size of the subList (which can change over its lifetime), and the
+ * expected {@code modCount} value of the backing list. There are two
+ * variants of the subclass, one of which implements {@code RandomAccess}.
* If this list implements {@code RandomAccess} the returned list will
* be an instance of the subclass that implements {@code RandomAccess}.
*
@@ -493,11 +492,22 @@ public abstract class AbstractList extends AbstractCollection implements L
* {@code (fromIndex > toIndex)}
*/
public List subList(int fromIndex, int toIndex) {
+ subListRangeCheck(fromIndex, toIndex, size());
return (this instanceof RandomAccess ?
new RandomAccessSubList<>(this, fromIndex, toIndex) :
new SubList<>(this, fromIndex, toIndex));
}
+ static void subListRangeCheck(int fromIndex, int toIndex, int size) {
+ if (fromIndex < 0)
+ throw new IndexOutOfBoundsException("fromIndex = " + fromIndex);
+ if (toIndex > size)
+ throw new IndexOutOfBoundsException("toIndex = " + toIndex);
+ if (fromIndex > toIndex)
+ throw new IllegalArgumentException("fromIndex(" + fromIndex +
+ ") > toIndex(" + toIndex + ")");
+ }
+
// Comparison and hashing
/**
@@ -623,174 +633,199 @@ public abstract class AbstractList extends AbstractCollection implements L
private String outOfBoundsMsg(int index) {
return "Index: "+index+", Size: "+size();
}
-}
-class SubList extends AbstractList {
- private final AbstractList l;
- private final int offset;
- private int size;
+ private static class SubList extends AbstractList {
+ private final AbstractList root;
+ private final SubList parent;
+ private final int offset;
+ protected int size;
- SubList(AbstractList list, int fromIndex, int toIndex) {
- if (fromIndex < 0)
- throw new IndexOutOfBoundsException("fromIndex = " + fromIndex);
- if (toIndex > list.size())
- throw new IndexOutOfBoundsException("toIndex = " + toIndex);
- if (fromIndex > toIndex)
- throw new IllegalArgumentException("fromIndex(" + fromIndex +
- ") > toIndex(" + toIndex + ")");
- l = list;
- offset = fromIndex;
- size = toIndex - fromIndex;
- this.modCount = l.modCount;
+ /**
+ * Constructs a sublist of an arbitrary AbstractList, which is
+ * not a SubList itself.
+ */
+ public SubList(AbstractList root, int fromIndex, int toIndex) {
+ this.root = root;
+ this.parent = null;
+ this.offset = fromIndex;
+ this.size = toIndex - fromIndex;
+ this.modCount = root.modCount;
+ }
+
+ /**
+ * Constructs a sublist of another SubList.
+ */
+ protected SubList(SubList parent, int fromIndex, int toIndex) {
+ this.root = parent.root;
+ this.parent = parent;
+ this.offset = parent.offset + fromIndex;
+ this.size = toIndex - fromIndex;
+ this.modCount = root.modCount;
+ }
+
+ public E set(int index, E element) {
+ Objects.checkIndex(index, size);
+ checkForComodification();
+ return root.set(offset + index, element);
+ }
+
+ public E get(int index) {
+ Objects.checkIndex(index, size);
+ checkForComodification();
+ return root.get(offset + index);
+ }
+
+ public int size() {
+ checkForComodification();
+ return size;
+ }
+
+ public void add(int index, E element) {
+ rangeCheckForAdd(index);
+ checkForComodification();
+ root.add(offset + index, element);
+ updateSizeAndModCount(1);
+ }
+
+ public E remove(int index) {
+ Objects.checkIndex(index, size);
+ checkForComodification();
+ E result = root.remove(offset + index);
+ updateSizeAndModCount(-1);
+ return result;
+ }
+
+ protected void removeRange(int fromIndex, int toIndex) {
+ checkForComodification();
+ root.removeRange(offset + fromIndex, offset + toIndex);
+ updateSizeAndModCount(fromIndex - toIndex);
+ }
+
+ public boolean addAll(Collection extends E> c) {
+ return addAll(size, c);
+ }
+
+ public boolean addAll(int index, Collection extends E> c) {
+ rangeCheckForAdd(index);
+ int cSize = c.size();
+ if (cSize==0)
+ return false;
+ checkForComodification();
+ root.addAll(offset + index, c);
+ updateSizeAndModCount(cSize);
+ return true;
+ }
+
+ public Iterator iterator() {
+ return listIterator();
+ }
+
+ public ListIterator listIterator(int index) {
+ checkForComodification();
+ rangeCheckForAdd(index);
+
+ return new ListIterator() {
+ private final ListIterator i =
+ root.listIterator(offset + index);
+
+ public boolean hasNext() {
+ return nextIndex() < size;
+ }
+
+ public E next() {
+ if (hasNext())
+ return i.next();
+ else
+ throw new NoSuchElementException();
+ }
+
+ public boolean hasPrevious() {
+ return previousIndex() >= 0;
+ }
+
+ public E previous() {
+ if (hasPrevious())
+ return i.previous();
+ else
+ throw new NoSuchElementException();
+ }
+
+ public int nextIndex() {
+ return i.nextIndex() - offset;
+ }
+
+ public int previousIndex() {
+ return i.previousIndex() - offset;
+ }
+
+ public void remove() {
+ i.remove();
+ updateSizeAndModCount(-1);
+ }
+
+ public void set(E e) {
+ i.set(e);
+ }
+
+ public void add(E e) {
+ i.add(e);
+ updateSizeAndModCount(1);
+ }
+ };
+ }
+
+ public List subList(int fromIndex, int toIndex) {
+ subListRangeCheck(fromIndex, toIndex, size);
+ return new SubList<>(this, fromIndex, toIndex);
+ }
+
+ private void rangeCheckForAdd(int index) {
+ if (index < 0 || index > size)
+ throw new IndexOutOfBoundsException(outOfBoundsMsg(index));
+ }
+
+ private String outOfBoundsMsg(int index) {
+ return "Index: "+index+", Size: "+size;
+ }
+
+ private void checkForComodification() {
+ if (root.modCount != this.modCount)
+ throw new ConcurrentModificationException();
+ }
+
+ private void updateSizeAndModCount(int sizeChange) {
+ SubList slist = this;
+ do {
+ slist.size += sizeChange;
+ slist.modCount = root.modCount;
+ slist = slist.parent;
+ } while (slist != null);
+ }
}
- public E set(int index, E element) {
- rangeCheck(index);
- checkForComodification();
- return l.set(index+offset, element);
- }
+ private static class RandomAccessSubList
+ extends SubList implements RandomAccess {
- public E get(int index) {
- rangeCheck(index);
- checkForComodification();
- return l.get(index+offset);
- }
+ /**
+ * Constructs a sublist of an arbitrary AbstractList, which is
+ * not a RandomAccessSubList itself.
+ */
+ RandomAccessSubList(AbstractList root,
+ int fromIndex, int toIndex) {
+ super(root, fromIndex, toIndex);
+ }
- public int size() {
- checkForComodification();
- return size;
- }
+ /**
+ * Constructs a sublist of another RandomAccessSubList.
+ */
+ RandomAccessSubList(RandomAccessSubList parent,
+ int fromIndex, int toIndex) {
+ super(parent, fromIndex, toIndex);
+ }
- public void add(int index, E element) {
- rangeCheckForAdd(index);
- checkForComodification();
- l.add(index+offset, element);
- this.modCount = l.modCount;
- size++;
- }
-
- public E remove(int index) {
- rangeCheck(index);
- checkForComodification();
- E result = l.remove(index+offset);
- this.modCount = l.modCount;
- size--;
- return result;
- }
-
- protected void removeRange(int fromIndex, int toIndex) {
- checkForComodification();
- l.removeRange(fromIndex+offset, toIndex+offset);
- this.modCount = l.modCount;
- size -= (toIndex-fromIndex);
- }
-
- public boolean addAll(Collection extends E> c) {
- return addAll(size, c);
- }
-
- public boolean addAll(int index, Collection extends E> c) {
- rangeCheckForAdd(index);
- int cSize = c.size();
- if (cSize==0)
- return false;
-
- checkForComodification();
- l.addAll(offset+index, c);
- this.modCount = l.modCount;
- size += cSize;
- return true;
- }
-
- public Iterator iterator() {
- return listIterator();
- }
-
- public ListIterator listIterator(final int index) {
- checkForComodification();
- rangeCheckForAdd(index);
-
- return new ListIterator() {
- private final ListIterator i = l.listIterator(index+offset);
-
- public boolean hasNext() {
- return nextIndex() < size;
- }
-
- public E next() {
- if (hasNext())
- return i.next();
- else
- throw new NoSuchElementException();
- }
-
- public boolean hasPrevious() {
- return previousIndex() >= 0;
- }
-
- public E previous() {
- if (hasPrevious())
- return i.previous();
- else
- throw new NoSuchElementException();
- }
-
- public int nextIndex() {
- return i.nextIndex() - offset;
- }
-
- public int previousIndex() {
- return i.previousIndex() - offset;
- }
-
- public void remove() {
- i.remove();
- SubList.this.modCount = l.modCount;
- size--;
- }
-
- public void set(E e) {
- i.set(e);
- }
-
- public void add(E e) {
- i.add(e);
- SubList.this.modCount = l.modCount;
- size++;
- }
- };
- }
-
- public List subList(int fromIndex, int toIndex) {
- return new SubList<>(this, fromIndex, toIndex);
- }
-
- private void rangeCheck(int index) {
- if (index < 0 || index >= size)
- throw new IndexOutOfBoundsException(outOfBoundsMsg(index));
- }
-
- private void rangeCheckForAdd(int index) {
- if (index < 0 || index > size)
- throw new IndexOutOfBoundsException(outOfBoundsMsg(index));
- }
-
- private String outOfBoundsMsg(int index) {
- return "Index: "+index+", Size: "+size;
- }
-
- private void checkForComodification() {
- if (this.modCount != l.modCount)
- throw new ConcurrentModificationException();
- }
-}
-
-class RandomAccessSubList extends SubList implements RandomAccess {
- RandomAccessSubList(AbstractList list, int fromIndex, int toIndex) {
- super(list, fromIndex, toIndex);
- }
-
- public List subList(int fromIndex, int toIndex) {
- return new RandomAccessSubList<>(this, fromIndex, toIndex);
+ public List subList(int fromIndex, int toIndex) {
+ subListRangeCheck(fromIndex, toIndex, size);
+ return new RandomAccessSubList<>(this, fromIndex, toIndex);
+ }
}
}
diff --git a/jdk/src/java.base/share/classes/java/util/ArrayList.java b/jdk/src/java.base/share/classes/java/util/ArrayList.java
index 8569de8129f..f5b672aaac1 100644
--- a/jdk/src/java.base/share/classes/java/util/ArrayList.java
+++ b/jdk/src/java.base/share/classes/java/util/ArrayList.java
@@ -432,8 +432,7 @@ public class ArrayList extends AbstractList
* @throws IndexOutOfBoundsException {@inheritDoc}
*/
public E get(int index) {
- rangeCheck(index);
-
+ Objects.checkIndex(index, size);
return elementData(index);
}
@@ -447,8 +446,7 @@ public class ArrayList extends AbstractList
* @throws IndexOutOfBoundsException {@inheritDoc}
*/
public E set(int index, E element) {
- rangeCheck(index);
-
+ Objects.checkIndex(index, size);
E oldValue = elementData(index);
elementData[index] = element;
return oldValue;
@@ -511,7 +509,7 @@ public class ArrayList extends AbstractList
* @throws IndexOutOfBoundsException {@inheritDoc}
*/
public E remove(int index) {
- rangeCheck(index);
+ Objects.checkIndex(index, size);
modCount++;
E oldValue = elementData(index);
@@ -679,17 +677,6 @@ public class ArrayList extends AbstractList
size = newSize;
}
- /**
- * Checks if the given index is in range. If not, throws an appropriate
- * runtime exception. This method does *not* check if the index is
- * negative: It is always used immediately prior to an array access,
- * which throws an ArrayIndexOutOfBoundsException if index is negative.
- */
- private void rangeCheck(int index) {
- if (index >= size)
- throw new IndexOutOfBoundsException(outOfBoundsMsg(index));
- }
-
/**
* A version of rangeCheck used by add and addAll.
*/
@@ -854,8 +841,7 @@ public class ArrayList extends AbstractList
* @throws IndexOutOfBoundsException {@inheritDoc}
*/
public ListIterator listIterator(int index) {
- if (index < 0 || index > size)
- throw new IndexOutOfBoundsException("Index: "+index);
+ rangeCheckForAdd(index);
return new ListItr(index);
}
@@ -1042,76 +1028,75 @@ public class ArrayList extends AbstractList
*/
public List subList(int fromIndex, int toIndex) {
subListRangeCheck(fromIndex, toIndex, size);
- return new SubList(this, 0, fromIndex, toIndex);
+ return new SubList<>(this, fromIndex, toIndex);
}
- static void subListRangeCheck(int fromIndex, int toIndex, int size) {
- if (fromIndex < 0)
- throw new IndexOutOfBoundsException("fromIndex = " + fromIndex);
- if (toIndex > size)
- throw new IndexOutOfBoundsException("toIndex = " + toIndex);
- if (fromIndex > toIndex)
- throw new IllegalArgumentException("fromIndex(" + fromIndex +
- ") > toIndex(" + toIndex + ")");
- }
-
- private class SubList extends AbstractList implements RandomAccess {
- private final AbstractList parent;
- private final int parentOffset;
+ private static class SubList extends AbstractList implements RandomAccess {
+ private final ArrayList root;
+ private final SubList parent;
private final int offset;
- int size;
+ private int size;
- SubList(AbstractList parent,
- int offset, int fromIndex, int toIndex) {
- this.parent = parent;
- this.parentOffset = fromIndex;
- this.offset = offset + fromIndex;
+ /**
+ * Constructs a sublist of an arbitrary ArrayList.
+ */
+ public SubList(ArrayList root, int fromIndex, int toIndex) {
+ this.root = root;
+ this.parent = null;
+ this.offset = fromIndex;
this.size = toIndex - fromIndex;
- this.modCount = ArrayList.this.modCount;
+ this.modCount = root.modCount;
}
- public E set(int index, E e) {
- rangeCheck(index);
+ /**
+ * Constructs a sublist of another SubList.
+ */
+ private SubList(SubList parent, int fromIndex, int toIndex) {
+ this.root = parent.root;
+ this.parent = parent;
+ this.offset = parent.offset + fromIndex;
+ this.size = toIndex - fromIndex;
+ this.modCount = root.modCount;
+ }
+
+ public E set(int index, E element) {
+ Objects.checkIndex(index, size);
checkForComodification();
- E oldValue = ArrayList.this.elementData(offset + index);
- ArrayList.this.elementData[offset + index] = e;
+ E oldValue = root.elementData(offset + index);
+ root.elementData[offset + index] = element;
return oldValue;
}
public E get(int index) {
- rangeCheck(index);
+ Objects.checkIndex(index, size);
checkForComodification();
- return ArrayList.this.elementData(offset + index);
+ return root.elementData(offset + index);
}
public int size() {
checkForComodification();
- return this.size;
+ return size;
}
- public void add(int index, E e) {
+ public void add(int index, E element) {
rangeCheckForAdd(index);
checkForComodification();
- parent.add(parentOffset + index, e);
- this.modCount = parent.modCount;
- this.size++;
+ root.add(offset + index, element);
+ updateSizeAndModCount(1);
}
public E remove(int index) {
- rangeCheck(index);
+ Objects.checkIndex(index, size);
checkForComodification();
- E result = parent.remove(parentOffset + index);
- this.modCount = parent.modCount;
- this.size--;
+ E result = root.remove(offset + index);
+ updateSizeAndModCount(-1);
return result;
}
protected void removeRange(int fromIndex, int toIndex) {
checkForComodification();
- parent.removeRange(parentOffset + fromIndex,
- parentOffset + toIndex);
- this.modCount = parent.modCount;
- this.size -= toIndex - fromIndex;
+ root.removeRange(offset + fromIndex, offset + toIndex);
+ updateSizeAndModCount(fromIndex - toIndex);
}
public boolean addAll(Collection extends E> c) {
@@ -1123,11 +1108,9 @@ public class ArrayList extends AbstractList
int cSize = c.size();
if (cSize==0)
return false;
-
checkForComodification();
- parent.addAll(parentOffset + index, c);
- this.modCount = parent.modCount;
- this.size += cSize;
+ root.addAll(offset + index, c);
+ updateSizeAndModCount(cSize);
return true;
}
@@ -1135,15 +1118,14 @@ public class ArrayList extends AbstractList
return listIterator();
}
- public ListIterator listIterator(final int index) {
+ public ListIterator listIterator(int index) {
checkForComodification();
rangeCheckForAdd(index);
- final int offset = this.offset;
return new ListIterator() {
int cursor = index;
int lastRet = -1;
- int expectedModCount = ArrayList.this.modCount;
+ int expectedModCount = root.modCount;
public boolean hasNext() {
return cursor != SubList.this.size;
@@ -1155,7 +1137,7 @@ public class ArrayList extends AbstractList
int i = cursor;
if (i >= SubList.this.size)
throw new NoSuchElementException();
- Object[] elementData = ArrayList.this.elementData;
+ Object[] elementData = root.elementData;
if (offset + i >= elementData.length)
throw new ConcurrentModificationException();
cursor = i + 1;
@@ -1172,7 +1154,7 @@ public class ArrayList extends AbstractList
int i = cursor - 1;
if (i < 0)
throw new NoSuchElementException();
- Object[] elementData = ArrayList.this.elementData;
+ Object[] elementData = root.elementData;
if (offset + i >= elementData.length)
throw new ConcurrentModificationException();
cursor = i;
@@ -1187,7 +1169,7 @@ public class ArrayList extends AbstractList
if (i >= size) {
return;
}
- final Object[] elementData = ArrayList.this.elementData;
+ final Object[] elementData = root.elementData;
if (offset + i >= elementData.length) {
throw new ConcurrentModificationException();
}
@@ -1216,7 +1198,7 @@ public class ArrayList extends AbstractList
SubList.this.remove(lastRet);
cursor = lastRet;
lastRet = -1;
- expectedModCount = ArrayList.this.modCount;
+ expectedModCount = root.modCount;
} catch (IndexOutOfBoundsException ex) {
throw new ConcurrentModificationException();
}
@@ -1228,7 +1210,7 @@ public class ArrayList extends AbstractList
checkForComodification();
try {
- ArrayList.this.set(offset + lastRet, e);
+ root.set(offset + lastRet, e);
} catch (IndexOutOfBoundsException ex) {
throw new ConcurrentModificationException();
}
@@ -1242,14 +1224,14 @@ public class ArrayList extends AbstractList
SubList.this.add(i, e);
cursor = i + 1;
lastRet = -1;
- expectedModCount = ArrayList.this.modCount;
+ expectedModCount = root.modCount;
} catch (IndexOutOfBoundsException ex) {
throw new ConcurrentModificationException();
}
}
final void checkForComodification() {
- if (expectedModCount != ArrayList.this.modCount)
+ if (root.modCount != expectedModCount)
throw new ConcurrentModificationException();
}
};
@@ -1257,12 +1239,7 @@ public class ArrayList extends AbstractList
public List subList(int fromIndex, int toIndex) {
subListRangeCheck(fromIndex, toIndex, size);
- return new SubList(this, offset, fromIndex, toIndex);
- }
-
- private void rangeCheck(int index) {
- if (index < 0 || index >= this.size)
- throw new IndexOutOfBoundsException(outOfBoundsMsg(index));
+ return new SubList<>(this, fromIndex, toIndex);
}
private void rangeCheckForAdd(int index) {
@@ -1275,13 +1252,24 @@ public class ArrayList extends AbstractList
}
private void checkForComodification() {
- if (ArrayList.this.modCount != this.modCount)
+ if (root.modCount != modCount)
throw new ConcurrentModificationException();
}
+ private void updateSizeAndModCount(int sizeChange) {
+ SubList slist = this;
+ do {
+ slist.size += sizeChange;
+ slist.modCount = root.modCount;
+ slist = slist.parent;
+ } while (slist != null);
+ }
+
public Spliterator spliterator() {
checkForComodification();
+ // ArrayListSpliterator is not used because late-binding logic
+ // is different here
return new Spliterator<>() {
private int index = offset; // current index, modified on advance/split
private int fence = -1; // -1 until used; then one past last index
@@ -1298,8 +1286,9 @@ public class ArrayList extends AbstractList
public ArrayListSpliterator trySplit() {
int hi = getFence(), lo = index, mid = (lo + hi) >>> 1;
+ // ArrayListSpliterator could be used here as the source is already bound
return (lo >= mid) ? null : // divide range in half unless too small
- new ArrayListSpliterator<>(ArrayList.this, lo, index = mid,
+ new ArrayListSpliterator<>(root, lo, index = mid,
expectedModCount);
}
@@ -1308,9 +1297,9 @@ public class ArrayList extends AbstractList
int hi = getFence(), i = index;
if (i < hi) {
index = i + 1;
- @SuppressWarnings("unchecked") E e = (E)elementData[i];
+ @SuppressWarnings("unchecked") E e = (E)root.elementData[i];
action.accept(e);
- if (ArrayList.this.modCount != expectedModCount)
+ if (root.modCount != expectedModCount)
throw new ConcurrentModificationException();
return true;
}
@@ -1320,7 +1309,7 @@ public class ArrayList extends AbstractList
public void forEachRemaining(Consumer super E> action) {
Objects.requireNonNull(action);
int i, hi, mc; // hoist accesses and checks from loop
- ArrayList lst = ArrayList.this;
+ ArrayList lst = root;
Object[] a;
if ((a = lst.elementData) != null) {
if ((hi = fence) < 0) {
diff --git a/jdk/src/java.base/share/classes/java/util/GregorianCalendar.java b/jdk/src/java.base/share/classes/java/util/GregorianCalendar.java
index b731b142843..d244e7d37b2 100644
--- a/jdk/src/java.base/share/classes/java/util/GregorianCalendar.java
+++ b/jdk/src/java.base/share/classes/java/util/GregorianCalendar.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1996, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1996, 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
@@ -1189,37 +1189,33 @@ public class GregorianCalendar extends Calendar {
case HOUR:
case HOUR_OF_DAY:
{
- int unit = max + 1; // 12 or 24 hours
- int h = internalGet(field);
- int nh = (h + amount) % unit;
- if (nh < 0) {
- nh += unit;
+ int rolledValue = getRolledValue(internalGet(field), amount, min, max);
+ int hourOfDay = rolledValue;
+ if (field == HOUR && internalGet(AM_PM) == PM) {
+ hourOfDay += 12;
}
- time += ONE_HOUR * (nh - h);
- // The day might have changed, which could happen if
- // the daylight saving time transition brings it to
- // the next day, although it's very unlikely. But we
- // have to make sure not to change the larger fields.
+ // Create the current date/time value to perform wall-clock-based
+ // roll.
CalendarDate d = calsys.getCalendarDate(time, getZone());
- if (internalGet(DAY_OF_MONTH) != d.getDayOfMonth()) {
- d.setDate(internalGet(YEAR),
- internalGet(MONTH) + 1,
- internalGet(DAY_OF_MONTH));
- if (field == HOUR) {
- assert (internalGet(AM_PM) == PM);
- d.addHours(+12); // restore PM
+ d.setHours(hourOfDay);
+ time = calsys.getTime(d);
+
+ // If we stay on the same wall-clock time, try the next or previous hour.
+ if (internalGet(HOUR_OF_DAY) == d.getHours()) {
+ hourOfDay = getRolledValue(rolledValue, amount > 0 ? +1 : -1, min, max);
+ if (field == HOUR && internalGet(AM_PM) == PM) {
+ hourOfDay += 12;
}
+ d.setHours(hourOfDay);
time = calsys.getTime(d);
}
- int hourOfDay = d.getHours();
- internalSet(field, hourOfDay % unit);
- if (field == HOUR) {
- internalSet(HOUR_OF_DAY, hourOfDay);
- } else {
- internalSet(AM_PM, hourOfDay / 12);
- internalSet(HOUR, hourOfDay % 12);
- }
+ // Get the new hourOfDay value which might have changed due to a DST transition.
+ hourOfDay = d.getHours();
+ // Update the hour related fields
+ internalSet(HOUR_OF_DAY, hourOfDay);
+ internalSet(AM_PM, hourOfDay / 12);
+ internalSet(HOUR, hourOfDay % 12);
// Time zone offset and/or daylight saving might have changed.
int zoneOffset = d.getZoneOffset();
diff --git a/jdk/src/java.base/share/classes/java/util/concurrent/TimeUnit.java b/jdk/src/java.base/share/classes/java/util/concurrent/TimeUnit.java
index 1395886faa5..2f481b04236 100644
--- a/jdk/src/java.base/share/classes/java/util/concurrent/TimeUnit.java
+++ b/jdk/src/java.base/share/classes/java/util/concurrent/TimeUnit.java
@@ -75,136 +75,93 @@ public enum TimeUnit {
/**
* Time unit representing one thousandth of a microsecond.
*/
- NANOSECONDS {
- public long toNanos(long d) { return d; }
- public long toMicros(long d) { return d/(C1/C0); }
- public long toMillis(long d) { return d/(C2/C0); }
- public long toSeconds(long d) { return d/(C3/C0); }
- public long toMinutes(long d) { return d/(C4/C0); }
- public long toHours(long d) { return d/(C5/C0); }
- public long toDays(long d) { return d/(C6/C0); }
- public long convert(long d, TimeUnit u) { return u.toNanos(d); }
- int excessNanos(long d, long m) { return (int)(d - (m*C2)); }
- },
-
+ NANOSECONDS(TimeUnit.NANO_SCALE),
/**
* Time unit representing one thousandth of a millisecond.
*/
- MICROSECONDS {
- public long toNanos(long d) { return x(d, C1/C0, MAX/(C1/C0)); }
- public long toMicros(long d) { return d; }
- public long toMillis(long d) { return d/(C2/C1); }
- public long toSeconds(long d) { return d/(C3/C1); }
- public long toMinutes(long d) { return d/(C4/C1); }
- public long toHours(long d) { return d/(C5/C1); }
- public long toDays(long d) { return d/(C6/C1); }
- public long convert(long d, TimeUnit u) { return u.toMicros(d); }
- int excessNanos(long d, long m) { return (int)((d*C1) - (m*C2)); }
- },
-
+ MICROSECONDS(TimeUnit.MICRO_SCALE),
/**
* Time unit representing one thousandth of a second.
*/
- MILLISECONDS {
- public long toNanos(long d) { return x(d, C2/C0, MAX/(C2/C0)); }
- public long toMicros(long d) { return x(d, C2/C1, MAX/(C2/C1)); }
- public long toMillis(long d) { return d; }
- public long toSeconds(long d) { return d/(C3/C2); }
- public long toMinutes(long d) { return d/(C4/C2); }
- public long toHours(long d) { return d/(C5/C2); }
- public long toDays(long d) { return d/(C6/C2); }
- public long convert(long d, TimeUnit u) { return u.toMillis(d); }
- int excessNanos(long d, long m) { return 0; }
- },
-
+ MILLISECONDS(TimeUnit.MILLI_SCALE),
/**
* Time unit representing one second.
*/
- SECONDS {
- public long toNanos(long d) { return x(d, C3/C0, MAX/(C3/C0)); }
- public long toMicros(long d) { return x(d, C3/C1, MAX/(C3/C1)); }
- public long toMillis(long d) { return x(d, C3/C2, MAX/(C3/C2)); }
- public long toSeconds(long d) { return d; }
- public long toMinutes(long d) { return d/(C4/C3); }
- public long toHours(long d) { return d/(C5/C3); }
- public long toDays(long d) { return d/(C6/C3); }
- public long convert(long d, TimeUnit u) { return u.toSeconds(d); }
- int excessNanos(long d, long m) { return 0; }
- },
-
+ SECONDS(TimeUnit.SECOND_SCALE),
/**
* Time unit representing sixty seconds.
* @since 1.6
*/
- MINUTES {
- public long toNanos(long d) { return x(d, C4/C0, MAX/(C4/C0)); }
- public long toMicros(long d) { return x(d, C4/C1, MAX/(C4/C1)); }
- public long toMillis(long d) { return x(d, C4/C2, MAX/(C4/C2)); }
- public long toSeconds(long d) { return x(d, C4/C3, MAX/(C4/C3)); }
- public long toMinutes(long d) { return d; }
- public long toHours(long d) { return d/(C5/C4); }
- public long toDays(long d) { return d/(C6/C4); }
- public long convert(long d, TimeUnit u) { return u.toMinutes(d); }
- int excessNanos(long d, long m) { return 0; }
- },
-
+ MINUTES(TimeUnit.MINUTE_SCALE),
/**
* Time unit representing sixty minutes.
* @since 1.6
*/
- HOURS {
- public long toNanos(long d) { return x(d, C5/C0, MAX/(C5/C0)); }
- public long toMicros(long d) { return x(d, C5/C1, MAX/(C5/C1)); }
- public long toMillis(long d) { return x(d, C5/C2, MAX/(C5/C2)); }
- public long toSeconds(long d) { return x(d, C5/C3, MAX/(C5/C3)); }
- public long toMinutes(long d) { return x(d, C5/C4, MAX/(C5/C4)); }
- public long toHours(long d) { return d; }
- public long toDays(long d) { return d/(C6/C5); }
- public long convert(long d, TimeUnit u) { return u.toHours(d); }
- int excessNanos(long d, long m) { return 0; }
- },
-
+ HOURS(TimeUnit.HOUR_SCALE),
/**
* Time unit representing twenty four hours.
* @since 1.6
*/
- DAYS {
- public long toNanos(long d) { return x(d, C6/C0, MAX/(C6/C0)); }
- public long toMicros(long d) { return x(d, C6/C1, MAX/(C6/C1)); }
- public long toMillis(long d) { return x(d, C6/C2, MAX/(C6/C2)); }
- public long toSeconds(long d) { return x(d, C6/C3, MAX/(C6/C3)); }
- public long toMinutes(long d) { return x(d, C6/C4, MAX/(C6/C4)); }
- public long toHours(long d) { return x(d, C6/C5, MAX/(C6/C5)); }
- public long toDays(long d) { return d; }
- public long convert(long d, TimeUnit u) { return u.toDays(d); }
- int excessNanos(long d, long m) { return 0; }
- };
+ DAYS(TimeUnit.DAY_SCALE);
- // Handy constants for conversion methods
- static final long C0 = 1L;
- static final long C1 = C0 * 1000L;
- static final long C2 = C1 * 1000L;
- static final long C3 = C2 * 1000L;
- static final long C4 = C3 * 60L;
- static final long C5 = C4 * 60L;
- static final long C6 = C5 * 24L;
+ // Scales as constants
+ private static final long NANO_SCALE = 1L;
+ private static final long MICRO_SCALE = 1000L * NANO_SCALE;
+ private static final long MILLI_SCALE = 1000L * MICRO_SCALE;
+ private static final long SECOND_SCALE = 1000L * MILLI_SCALE;
+ private static final long MINUTE_SCALE = 60L * SECOND_SCALE;
+ private static final long HOUR_SCALE = 60L * MINUTE_SCALE;
+ private static final long DAY_SCALE = 24L * HOUR_SCALE;
- static final long MAX = Long.MAX_VALUE;
-
- /**
- * Scale d by m, checking for overflow.
- * This has a short name to make above code more readable.
+ /*
+ * Instances cache conversion ratios and saturation cutoffs for
+ * the units up through SECONDS. Other cases compute them, in
+ * method cvt.
*/
- static long x(long d, long m, long over) {
- if (d > +over) return Long.MAX_VALUE;
- if (d < -over) return Long.MIN_VALUE;
- return d * m;
+
+ private final long scale;
+ private final long maxNanos;
+ private final long maxMicros;
+ private final long maxMillis;
+ private final long maxSecs;
+ private final long microRatio;
+ private final int milliRatio; // fits in 32 bits
+ private final int secRatio; // fits in 32 bits
+
+ private TimeUnit(long s) {
+ this.scale = s;
+ this.maxNanos = Long.MAX_VALUE / s;
+ long ur = (s >= MICRO_SCALE) ? (s / MICRO_SCALE) : (MICRO_SCALE / s);
+ this.microRatio = ur;
+ this.maxMicros = Long.MAX_VALUE / ur;
+ long mr = (s >= MILLI_SCALE) ? (s / MILLI_SCALE) : (MILLI_SCALE / s);
+ this.milliRatio = (int)mr;
+ this.maxMillis = Long.MAX_VALUE / mr;
+ long sr = (s >= SECOND_SCALE) ? (s / SECOND_SCALE) : (SECOND_SCALE / s);
+ this.secRatio = (int)sr;
+ this.maxSecs = Long.MAX_VALUE / sr;
}
- // To maintain full signature compatibility with 1.5, and to improve the
- // clarity of the generated javadoc (see 6287639: Abstract methods in
- // enum classes should not be listed as abstract), method convert
- // etc. are not declared abstract but otherwise act as abstract methods.
+ /**
+ * General conversion utility.
+ *
+ * @param d duration
+ * @param dst result unit scale
+ * @param src source unit scale
+ */
+ private static long cvt(long d, long dst, long src) {
+ long r, m;
+ if (src == dst)
+ return d;
+ else if (src < dst)
+ return d / (dst / src);
+ else if (d > (m = Long.MAX_VALUE / (r = src / dst)))
+ return Long.MAX_VALUE;
+ else if (d < -m)
+ return Long.MIN_VALUE;
+ else
+ return d * r;
+ }
/**
* Converts the given time duration in the given unit to this unit.
@@ -221,11 +178,17 @@ public enum TimeUnit {
* @param sourceDuration the time duration in the given {@code sourceUnit}
* @param sourceUnit the unit of the {@code sourceDuration} argument
* @return the converted duration in this unit,
- * or {@code Long.MIN_VALUE} if conversion would negatively
- * overflow, or {@code Long.MAX_VALUE} if it would positively overflow.
+ * or {@code Long.MIN_VALUE} if conversion would negatively overflow,
+ * or {@code Long.MAX_VALUE} if it would positively overflow.
*/
public long convert(long sourceDuration, TimeUnit sourceUnit) {
- throw new AbstractMethodError();
+ switch (this) {
+ case NANOSECONDS: return sourceUnit.toNanos(sourceDuration);
+ case MICROSECONDS: return sourceUnit.toMicros(sourceDuration);
+ case MILLISECONDS: return sourceUnit.toMillis(sourceDuration);
+ case SECONDS: return sourceUnit.toSeconds(sourceDuration);
+ default: return cvt(sourceDuration, scale, sourceUnit.scale);
+ }
}
/**
@@ -233,11 +196,19 @@ public enum TimeUnit {
* {@link #convert(long, TimeUnit) NANOSECONDS.convert(duration, this)}.
* @param duration the duration
* @return the converted duration,
- * or {@code Long.MIN_VALUE} if conversion would negatively
- * overflow, or {@code Long.MAX_VALUE} if it would positively overflow.
+ * or {@code Long.MIN_VALUE} if conversion would negatively overflow,
+ * or {@code Long.MAX_VALUE} if it would positively overflow.
*/
public long toNanos(long duration) {
- throw new AbstractMethodError();
+ long s, m;
+ if ((s = scale) == NANO_SCALE)
+ return duration;
+ else if (duration > (m = maxNanos))
+ return Long.MAX_VALUE;
+ else if (duration < -m)
+ return Long.MIN_VALUE;
+ else
+ return duration * s;
}
/**
@@ -245,11 +216,21 @@ public enum TimeUnit {
* {@link #convert(long, TimeUnit) MICROSECONDS.convert(duration, this)}.
* @param duration the duration
* @return the converted duration,
- * or {@code Long.MIN_VALUE} if conversion would negatively
- * overflow, or {@code Long.MAX_VALUE} if it would positively overflow.
+ * or {@code Long.MIN_VALUE} if conversion would negatively overflow,
+ * or {@code Long.MAX_VALUE} if it would positively overflow.
*/
public long toMicros(long duration) {
- throw new AbstractMethodError();
+ long s, m;
+ if ((s = scale) == MICRO_SCALE)
+ return duration;
+ else if (s < MICRO_SCALE)
+ return duration / microRatio;
+ else if (duration > (m = maxMicros))
+ return Long.MAX_VALUE;
+ else if (duration < -m)
+ return Long.MIN_VALUE;
+ else
+ return duration * microRatio;
}
/**
@@ -257,11 +238,21 @@ public enum TimeUnit {
* {@link #convert(long, TimeUnit) MILLISECONDS.convert(duration, this)}.
* @param duration the duration
* @return the converted duration,
- * or {@code Long.MIN_VALUE} if conversion would negatively
- * overflow, or {@code Long.MAX_VALUE} if it would positively overflow.
+ * or {@code Long.MIN_VALUE} if conversion would negatively overflow,
+ * or {@code Long.MAX_VALUE} if it would positively overflow.
*/
public long toMillis(long duration) {
- throw new AbstractMethodError();
+ long s, m;
+ if ((s = scale) == MILLI_SCALE)
+ return duration;
+ else if (s < MILLI_SCALE)
+ return duration / milliRatio;
+ else if (duration > (m = maxMillis))
+ return Long.MAX_VALUE;
+ else if (duration < -m)
+ return Long.MIN_VALUE;
+ else
+ return duration * milliRatio;
}
/**
@@ -269,11 +260,21 @@ public enum TimeUnit {
* {@link #convert(long, TimeUnit) SECONDS.convert(duration, this)}.
* @param duration the duration
* @return the converted duration,
- * or {@code Long.MIN_VALUE} if conversion would negatively
- * overflow, or {@code Long.MAX_VALUE} if it would positively overflow.
+ * or {@code Long.MIN_VALUE} if conversion would negatively overflow,
+ * or {@code Long.MAX_VALUE} if it would positively overflow.
*/
public long toSeconds(long duration) {
- throw new AbstractMethodError();
+ long s, m;
+ if ((s = scale) == SECOND_SCALE)
+ return duration;
+ else if (s < SECOND_SCALE)
+ return duration / secRatio;
+ else if (duration > (m = maxSecs))
+ return Long.MAX_VALUE;
+ else if (duration < -m)
+ return Long.MIN_VALUE;
+ else
+ return duration * secRatio;
}
/**
@@ -281,12 +282,12 @@ public enum TimeUnit {
* {@link #convert(long, TimeUnit) MINUTES.convert(duration, this)}.
* @param duration the duration
* @return the converted duration,
- * or {@code Long.MIN_VALUE} if conversion would negatively
- * overflow, or {@code Long.MAX_VALUE} if it would positively overflow.
+ * or {@code Long.MIN_VALUE} if conversion would negatively overflow,
+ * or {@code Long.MAX_VALUE} if it would positively overflow.
* @since 1.6
*/
public long toMinutes(long duration) {
- throw new AbstractMethodError();
+ return cvt(duration, MINUTE_SCALE, scale);
}
/**
@@ -294,12 +295,12 @@ public enum TimeUnit {
* {@link #convert(long, TimeUnit) HOURS.convert(duration, this)}.
* @param duration the duration
* @return the converted duration,
- * or {@code Long.MIN_VALUE} if conversion would negatively
- * overflow, or {@code Long.MAX_VALUE} if it would positively overflow.
+ * or {@code Long.MIN_VALUE} if conversion would negatively overflow,
+ * or {@code Long.MAX_VALUE} if it would positively overflow.
* @since 1.6
*/
public long toHours(long duration) {
- throw new AbstractMethodError();
+ return cvt(duration, HOUR_SCALE, scale);
}
/**
@@ -310,7 +311,7 @@ public enum TimeUnit {
* @since 1.6
*/
public long toDays(long duration) {
- throw new AbstractMethodError();
+ return cvt(duration, DAY_SCALE, scale);
}
/**
@@ -320,7 +321,15 @@ public enum TimeUnit {
* @param m the number of milliseconds
* @return the number of nanoseconds
*/
- abstract int excessNanos(long d, long m);
+ private int excessNanos(long d, long m) {
+ long s;
+ if ((s = scale) == NANO_SCALE)
+ return (int)(d - (m * MILLI_SCALE));
+ else if (s == MICRO_SCALE)
+ return (int)((d * 1000L) - (m * MILLI_SCALE));
+ else
+ return 0;
+ }
/**
* Performs a timed {@link Object#wait(long, int) Object.wait}
diff --git a/jdk/src/java.base/share/classes/java/util/jar/JarFile.java b/jdk/src/java.base/share/classes/java/util/jar/JarFile.java
index b3bbced134c..7f5726e3656 100644
--- a/jdk/src/java.base/share/classes/java/util/jar/JarFile.java
+++ b/jdk/src/java.base/share/classes/java/util/jar/JarFile.java
@@ -28,7 +28,6 @@ package java.util.jar;
import java.io.*;
import java.lang.ref.SoftReference;
import java.net.URL;
-import java.security.PrivilegedAction;
import java.util.*;
import java.util.stream.Stream;
import java.util.stream.StreamSupport;
@@ -38,11 +37,10 @@ import java.security.cert.Certificate;
import java.security.AccessController;
import java.security.CodeSource;
import jdk.internal.misc.SharedSecrets;
+import sun.security.action.GetPropertyAction;
import sun.security.util.ManifestEntryVerifier;
import sun.security.util.SignatureFileVerifier;
-import static java.util.jar.Attributes.Name.MULTI_RELEASE;
-
/**
* The {@code JarFile} class is used to read the contents of a jar file
* from any file that can be opened with {@code java.io.RandomAccessFile}.
@@ -144,8 +142,9 @@ class JarFile extends ZipFile {
private final int version;
private boolean notVersioned;
private final boolean runtimeVersioned;
+ private boolean isMultiRelease; // is jar multi-release?
- // indicates if Class-Path attribute present (only valid if hasCheckedSpecialAttributes true)
+ // indicates if Class-Path attribute present
private boolean hasClassPathAttribute;
// true if manifest checked for special attributes
private volatile boolean hasCheckedSpecialAttributes;
@@ -155,24 +154,18 @@ class JarFile extends ZipFile {
SharedSecrets.setJavaUtilJarAccess(new JavaUtilJarAccessImpl());
BASE_VERSION = 8; // one less than lowest version for versioned entries
- RUNTIME_VERSION = AccessController.doPrivileged(
- new PrivilegedAction() {
- public Integer run() {
- Integer v = jdk.Version.current().major();
- Integer i = Integer.getInteger("jdk.util.jar.version", v);
- i = i < 0 ? 0 : i;
- return i > v ? v : i;
- }
- }
- );
- String multi_release = AccessController.doPrivileged(
- new PrivilegedAction() {
- public String run() {
- return System.getProperty("jdk.util.jar.enableMultiRelease", "true");
- }
- }
- );
- switch (multi_release) {
+ int runtimeVersion = jdk.Version.current().major();
+ String jarVersion = AccessController.doPrivileged(
+ new GetPropertyAction("jdk.util.jar.version"));
+ if (jarVersion != null) {
+ int jarVer = Integer.parseInt(jarVersion);
+ runtimeVersion = (jarVer > runtimeVersion)
+ ? runtimeVersion : Math.max(jarVer, 0);
+ }
+ RUNTIME_VERSION = runtimeVersion;
+ String enableMultiRelease = AccessController.doPrivileged(
+ new GetPropertyAction("jdk.util.jar.enableMultiRelease", "true"));
+ switch (enableMultiRelease) {
case "true":
default:
MULTI_RELEASE_ENABLED = true;
@@ -353,8 +346,14 @@ class JarFile extends ZipFile {
Objects.requireNonNull(version);
this.verify = verify;
// version applies to multi-release jar files, ignored for regular jar files
- this.version = MULTI_RELEASE_FORCED ? RUNTIME_VERSION : version.value();
+ if (MULTI_RELEASE_FORCED) {
+ this.version = RUNTIME_VERSION;
+ version = Release.RUNTIME;
+ } else {
+ this.version = version.value();
+ }
this.runtimeVersioned = version == Release.RUNTIME;
+
assert runtimeVersionExists();
}
@@ -392,35 +391,18 @@ class JarFile extends ZipFile {
* @since 9
*/
public final boolean isMultiRelease() {
- // do not call this code in a constructor because some subclasses use
- // lazy loading of manifest so it won't be available at construction time
- if (MULTI_RELEASE_ENABLED) {
- // Doubled-checked locking pattern
- Boolean result = isMultiRelease;
- if (result == null) {
- synchronized (this) {
- result = isMultiRelease;
- if (result == null) {
- Manifest man = null;
- try {
- man = getManifest();
- } catch (IOException e) {
- //Ignored, manifest cannot be read
- }
- isMultiRelease = result = (man != null)
- && man.getMainAttributes().containsKey(MULTI_RELEASE)
- ? Boolean.TRUE : Boolean.FALSE;
- }
- }
- }
- return result == Boolean.TRUE;
- } else {
- return false;
+ if (isMultiRelease) {
+ return true;
}
+ if (MULTI_RELEASE_ENABLED && version != BASE_VERSION) {
+ try {
+ checkForSpecialAttributes();
+ } catch (IOException io) {
+ isMultiRelease = false;
+ }
+ }
+ return isMultiRelease;
}
- // the following field, isMultiRelease, should only be used in the method
- // isMultiRelease(), like a static local
- private volatile Boolean isMultiRelease; // is jar multi-release?
/**
* Returns the jar file manifest, or {@code null} if none.
@@ -905,26 +887,44 @@ class JarFile extends ZipFile {
}
// Statics for hand-coded Boyer-Moore search
- private static final char[] CLASSPATH_CHARS = {'c','l','a','s','s','-','p','a','t','h'};
- // The bad character shift for "class-path"
- private static final int[] CLASSPATH_LASTOCC;
- // The good suffix shift for "class-path"
- private static final int[] CLASSPATH_OPTOSFT;
+ private static final byte[] CLASSPATH_CHARS =
+ {'C','L','A','S','S','-','P','A','T','H', ':', ' '};
+
+ // The bad character shift for "class-path:"
+ private static final byte[] CLASSPATH_LASTOCC;
+
+ private static final byte[] MULTIRELEASE_CHARS =
+ {'M','U','L','T','I','-','R','E','L','E', 'A', 'S', 'E', ':', ' '};
+
+ // The bad character shift for "multi-release: "
+ private static final byte[] MULTIRELEASE_LASTOCC;
static {
- CLASSPATH_LASTOCC = new int[128];
- CLASSPATH_OPTOSFT = new int[10];
- CLASSPATH_LASTOCC[(int)'c'] = 1;
- CLASSPATH_LASTOCC[(int)'l'] = 2;
- CLASSPATH_LASTOCC[(int)'s'] = 5;
- CLASSPATH_LASTOCC[(int)'-'] = 6;
- CLASSPATH_LASTOCC[(int)'p'] = 7;
- CLASSPATH_LASTOCC[(int)'a'] = 8;
- CLASSPATH_LASTOCC[(int)'t'] = 9;
- CLASSPATH_LASTOCC[(int)'h'] = 10;
- for (int i=0; i<9; i++)
- CLASSPATH_OPTOSFT[i] = 10;
- CLASSPATH_OPTOSFT[9]=1;
+ CLASSPATH_LASTOCC = new byte[64];
+ CLASSPATH_LASTOCC[(int)'C' - 32] = 1;
+ CLASSPATH_LASTOCC[(int)'L' - 32] = 2;
+ CLASSPATH_LASTOCC[(int)'S' - 32] = 5;
+ CLASSPATH_LASTOCC[(int)'-' - 32] = 6;
+ CLASSPATH_LASTOCC[(int)'P' - 32] = 7;
+ CLASSPATH_LASTOCC[(int)'A' - 32] = 8;
+ CLASSPATH_LASTOCC[(int)'T' - 32] = 9;
+ CLASSPATH_LASTOCC[(int)'H' - 32] = 10;
+ CLASSPATH_LASTOCC[(int)':' - 32] = 11;
+ CLASSPATH_LASTOCC[(int)' ' - 32] = 12;
+
+ MULTIRELEASE_LASTOCC = new byte[64];
+ MULTIRELEASE_LASTOCC[(int)'M' - 32] = 1;
+ MULTIRELEASE_LASTOCC[(int)'U' - 32] = 2;
+ MULTIRELEASE_LASTOCC[(int)'T' - 32] = 4;
+ MULTIRELEASE_LASTOCC[(int)'I' - 32] = 5;
+ MULTIRELEASE_LASTOCC[(int)'-' - 32] = 6;
+ MULTIRELEASE_LASTOCC[(int)'R' - 32] = 7;
+ MULTIRELEASE_LASTOCC[(int)'L' - 32] = 9;
+ MULTIRELEASE_LASTOCC[(int)'A' - 32] = 11;
+ MULTIRELEASE_LASTOCC[(int)'S' - 32] = 12;
+ MULTIRELEASE_LASTOCC[(int)'E' - 32] = 13;
+ MULTIRELEASE_LASTOCC[(int)':' - 32] = 14;
+ MULTIRELEASE_LASTOCC[(int)' ' - 32] = 15;
}
private JarEntry getManEntry() {
@@ -962,22 +962,33 @@ class JarFile extends ZipFile {
/**
* Returns true if the pattern {@code src} is found in {@code b}.
- * The {@code lastOcc} and {@code optoSft} arrays are the precomputed
- * bad character and good suffix shifts.
+ * The {@code lastOcc} array is the precomputed bad character shifts.
+ * Since there are no repeated substring in our search strings,
+ * the good suffix shifts can be replaced with a comparison.
*/
- private boolean match(char[] src, byte[] b, int[] lastOcc, int[] optoSft) {
+ private boolean match(byte[] src, byte[] b, byte[] lastOcc) {
int len = src.length;
int last = b.length - len;
int i = 0;
next:
- while (i<=last) {
- for (int j=(len-1); j>=0; j--) {
- char c = (char) b[i+j];
- c = (((c-'A')|('Z'-c)) >= 0) ? (char)(c + 32) : c;
- if (c != src[j]) {
- i += Math.max(j + 1 - lastOcc[c&0x7F], optoSft[j]);
+ while (i <= last) {
+ for (int j = (len - 1); j >= 0; j--) {
+ byte c = b[i + j];
+ if (c >= ' ' && c <= 'z') {
+ if (c >= 'a') c -= 32; // Canonicalize
+
+ if (c != src[j]) {
+ // no match
+ int goodShift = (j < len - 1) ? len : 1;
+ int badShift = lastOcc[c - 32];
+ i += Math.max(j + 1 - badShift, goodShift);
+ continue next;
+ }
+ } else {
+ // no match, character not valid for name
+ i += len;
continue next;
- }
+ }
}
return true;
}
@@ -986,17 +997,29 @@ class JarFile extends ZipFile {
/**
* On first invocation, check if the JAR file has the Class-Path
- * attribute. A no-op on subsequent calls.
+ * and the Multi-Release attribute. A no-op on subsequent calls.
*/
private void checkForSpecialAttributes() throws IOException {
- if (hasCheckedSpecialAttributes) return;
- JarEntry manEntry = getManEntry();
- if (manEntry != null) {
- byte[] b = getBytes(manEntry);
- if (match(CLASSPATH_CHARS, b, CLASSPATH_LASTOCC, CLASSPATH_OPTOSFT))
- hasClassPathAttribute = true;
+ if (hasCheckedSpecialAttributes) {
+ return;
+ }
+ synchronized (this) {
+ if (hasCheckedSpecialAttributes) {
+ return;
+ }
+ JarEntry manEntry = getManEntry();
+ if (manEntry != null) {
+ byte[] b = getBytes(manEntry);
+ hasClassPathAttribute = match(CLASSPATH_CHARS, b,
+ CLASSPATH_LASTOCC);
+ // is this a multi-release jar file
+ if (MULTI_RELEASE_ENABLED && version != BASE_VERSION) {
+ isMultiRelease = match(MULTIRELEASE_CHARS, b,
+ MULTIRELEASE_LASTOCC);
+ }
+ }
+ hasCheckedSpecialAttributes = true;
}
- hasCheckedSpecialAttributes = true;
}
private synchronized void ensureInitialization() {
diff --git a/jdk/src/java.base/share/classes/java/util/jar/JarInputStream.java b/jdk/src/java.base/share/classes/java/util/jar/JarInputStream.java
index 67f27be2975..15d3c8e1a18 100644
--- a/jdk/src/java.base/share/classes/java/util/jar/JarInputStream.java
+++ b/jdk/src/java.base/share/classes/java/util/jar/JarInputStream.java
@@ -28,7 +28,7 @@ package java.util.jar;
import java.util.zip.*;
import java.io.*;
import sun.security.util.ManifestEntryVerifier;
-import sun.misc.JarIndex;
+import jdk.internal.util.jar.JarIndex;
/**
* The JarInputStream
class is used to read the contents of
diff --git a/jdk/src/java.base/share/classes/java/util/jar/JarVerifier.java b/jdk/src/java.base/share/classes/java/util/jar/JarVerifier.java
index 6e978e41278..2d0f5eb18eb 100644
--- a/jdk/src/java.base/share/classes/java/util/jar/JarVerifier.java
+++ b/jdk/src/java.base/share/classes/java/util/jar/JarVerifier.java
@@ -32,7 +32,7 @@ import java.security.*;
import java.security.cert.CertificateException;
import java.util.zip.ZipEntry;
-import sun.misc.JarIndex;
+import jdk.internal.util.jar.JarIndex;
import sun.security.util.ManifestDigester;
import sun.security.util.ManifestEntryVerifier;
import sun.security.util.SignatureFileVerifier;
diff --git a/jdk/src/java.base/share/classes/jdk/internal/loader/URLClassPath.java b/jdk/src/java.base/share/classes/jdk/internal/loader/URLClassPath.java
index f319716d941..15688e1a573 100644
--- a/jdk/src/java.base/share/classes/jdk/internal/loader/URLClassPath.java
+++ b/jdk/src/java.base/share/classes/jdk/internal/loader/URLClassPath.java
@@ -65,8 +65,8 @@ import java.util.zip.ZipFile;
import jdk.internal.misc.JavaUtilZipFileAccess;
import jdk.internal.misc.SharedSecrets;
-import sun.misc.InvalidJarIndexException;
-import sun.misc.JarIndex;
+import jdk.internal.util.jar.InvalidJarIndexError;
+import jdk.internal.util.jar.JarIndex;
import sun.net.util.URLUtil;
import sun.net.www.ParseUtil;
@@ -902,7 +902,7 @@ public class URLClassPath {
*/
if (!newLoader.validIndex(name)) {
/* the mapping is wrong */
- throw new InvalidJarIndexException("Invalid index");
+ throw new InvalidJarIndexError("Invalid index");
}
}
diff --git a/jdk/src/java.base/share/classes/sun/misc/InvalidJarIndexException.java b/jdk/src/java.base/share/classes/jdk/internal/util/jar/InvalidJarIndexError.java
similarity index 74%
rename from jdk/src/java.base/share/classes/sun/misc/InvalidJarIndexException.java
rename to jdk/src/java.base/share/classes/jdk/internal/util/jar/InvalidJarIndexError.java
index 44ca4ff7103..1d28b80cc42 100644
--- a/jdk/src/java.base/share/classes/sun/misc/InvalidJarIndexException.java
+++ b/jdk/src/java.base/share/classes/jdk/internal/util/jar/InvalidJarIndexError.java
@@ -23,38 +23,32 @@
* questions.
*/
-package sun.misc;
-
-import java.lang.LinkageError;
+package jdk.internal.util.jar;
/**
* Thrown if the URLClassLoader finds the INDEX.LIST file of
* a jar file contains incorrect information.
*
- * @author Zhenghua Li
- * @since 1.3
+ * @since 9
*/
-public
-class InvalidJarIndexException extends RuntimeException {
+public class InvalidJarIndexError extends Error {
- static final long serialVersionUID = -6159797516569680148L;
+ static final long serialVersionUID = 0L;
/**
- * Constructs an InvalidJarIndexException
with no
- * detail message.
+ * Constructs an {@code InvalidJarIndexError} with no detail message.
*/
- public InvalidJarIndexException() {
+ public InvalidJarIndexError() {
super();
}
/**
- * Constructs an InvalidJarIndexException
with the
- * specified detail message.
+ * Constructs an {@code InvalidJarIndexError} with the specified detail message.
*
* @param s the detail message.
*/
- public InvalidJarIndexException(String s) {
+ public InvalidJarIndexError(String s) {
super(s);
}
}
diff --git a/jdk/src/java.base/share/classes/sun/misc/JarIndex.java b/jdk/src/java.base/share/classes/jdk/internal/util/jar/JarIndex.java
similarity index 99%
rename from jdk/src/java.base/share/classes/sun/misc/JarIndex.java
rename to jdk/src/java.base/share/classes/jdk/internal/util/jar/JarIndex.java
index db5e15e4db7..fd92b13bdb9 100644
--- a/jdk/src/java.base/share/classes/sun/misc/JarIndex.java
+++ b/jdk/src/java.base/share/classes/jdk/internal/util/jar/JarIndex.java
@@ -23,7 +23,7 @@
* questions.
*/
-package sun.misc;
+package jdk.internal.util.jar;
import java.io.*;
import java.util.*;
diff --git a/jdk/src/java.base/share/classes/module-info.java b/jdk/src/java.base/share/classes/module-info.java
index 011bef47346..e13a95739f3 100644
--- a/jdk/src/java.base/share/classes/module-info.java
+++ b/jdk/src/java.base/share/classes/module-info.java
@@ -180,6 +180,8 @@ module java.base {
jdk.jvmstat;
exports jdk.internal.ref to
java.desktop;
+ exports jdk.internal.util.jar to
+ jdk.jartool;
exports sun.net to
java.httpclient;
exports sun.net.dns to
diff --git a/jdk/src/java.base/share/classes/sun/misc/resources/Messages_de.java b/jdk/src/java.base/share/classes/sun/misc/resources/Messages_de.java
deleted file mode 100644
index d22b1e592ec..00000000000
--- a/jdk/src/java.base/share/classes/sun/misc/resources/Messages_de.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * Copyright (c) 2002, 2013, 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 sun.misc.resources;
-
-/**
- * This class represents the {@code ResourceBundle}
- * for sun.misc.
- *
- * @author Michael Colburn
- */
-
-public class Messages_de extends java.util.ListResourceBundle {
-
- /**
- * Returns the contents of this {@code ResourceBundle}.
- *
- * @return the contents of this {@code ResourceBundle}.
- */
- public Object[][] getContents() {
- return contents;
- }
-
- private static final Object[][] contents = {
- { "optpkg.versionerror", "ERROR: In JAR-Datei {0} wurde ein ung\u00FCltiges Versionsformat verwendet. Pr\u00FCfen Sie in der Dokumentation, welches Versionsformat unterst\u00FCtzt wird." },
- { "optpkg.attributeerror", "ERROR: In JAR-Datei {1} ist das erforderliche JAR-Manifestattribut {0} nicht festgelegt." },
- { "optpkg.attributeserror", "ERROR: In JAR-Datei {0} sind einige erforderliche JAR-Manifestattribute nicht festgelegt." }
- };
-
-}
diff --git a/jdk/src/java.base/share/classes/sun/misc/resources/Messages_es.java b/jdk/src/java.base/share/classes/sun/misc/resources/Messages_es.java
deleted file mode 100644
index 1d4bc2de250..00000000000
--- a/jdk/src/java.base/share/classes/sun/misc/resources/Messages_es.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * Copyright (c) 2002, 2013, 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 sun.misc.resources;
-
-/**
- * This class represents the {@code ResourceBundle}
- * for sun.misc.
- *
- * @author Michael Colburn
- */
-
-public class Messages_es extends java.util.ListResourceBundle {
-
- /**
- * Returns the contents of this {@code ResourceBundle}.
- *
- * @return the contents of this {@code ResourceBundle}.
- */
- public Object[][] getContents() {
- return contents;
- }
-
- private static final Object[][] contents = {
- { "optpkg.versionerror", "ERROR: el formato del archivo JAR {0} pertenece a una versi\u00F3n no v\u00E1lida. Busque en la documentaci\u00F3n el formato de una versi\u00F3n soportada." },
- { "optpkg.attributeerror", "ERROR: el atributo obligatorio JAR manifest {0} no est\u00E1 definido en el archivo JAR {1}." },
- { "optpkg.attributeserror", "ERROR: algunos atributos obligatorios JAR manifest no est\u00E1n definidos en el archivo JAR {0}." }
- };
-
-}
diff --git a/jdk/src/java.base/share/classes/sun/misc/resources/Messages_fr.java b/jdk/src/java.base/share/classes/sun/misc/resources/Messages_fr.java
deleted file mode 100644
index 8f74b9b063e..00000000000
--- a/jdk/src/java.base/share/classes/sun/misc/resources/Messages_fr.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * Copyright (c) 2002, 2013, 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 sun.misc.resources;
-
-/**
- * This class represents the {@code ResourceBundle}
- * for sun.misc.
- *
- * @author Michael Colburn
- */
-
-public class Messages_fr extends java.util.ListResourceBundle {
-
- /**
- * Returns the contents of this {@code ResourceBundle}.
- *
- * @return the contents of this {@code ResourceBundle}.
- */
- public Object[][] getContents() {
- return contents;
- }
-
- private static final Object[][] contents = {
- { "optpkg.versionerror", "ERREUR\u00A0: le format de version utilis\u00E9 pour le fichier JAR {0} n''est pas valide. Pour conna\u00EEtre le format de version pris en charge, consultez la documentation." },
- { "optpkg.attributeerror", "ERREUR\u00A0: l''attribut manifest JAR {0} obligatoire n''est pas d\u00E9fini dans le fichier JAR {1}." },
- { "optpkg.attributeserror", "ERREUR\u00A0: certains attributs manifest JAR obligatoires ne sont pas d\u00E9finis dans le fichier JAR {0}." }
- };
-
-}
diff --git a/jdk/src/java.base/share/classes/sun/misc/resources/Messages_it.java b/jdk/src/java.base/share/classes/sun/misc/resources/Messages_it.java
deleted file mode 100644
index 2b23c638b31..00000000000
--- a/jdk/src/java.base/share/classes/sun/misc/resources/Messages_it.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * Copyright (c) 2002, 2013, 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 sun.misc.resources;
-
-/**
- * This class represents the {@code ResourceBundle}
- * for sun.misc.
- *
- * @author Michael Colburn
- */
-
-public class Messages_it extends java.util.ListResourceBundle {
-
- /**
- * Returns the contents of this {@code ResourceBundle}.
- *
- * @return the contents of this {@code ResourceBundle}.
- */
- public Object[][] getContents() {
- return contents;
- }
-
- private static final Object[][] contents = {
- { "optpkg.versionerror", "ERRORE: Formato versione non valido nel file JAR {0}. Verificare nella documentazione il formato della versione supportato." },
- { "optpkg.attributeerror", "ERRORE: L''attributo manifest JAR {0} richiesto non \u00E8 impostato nel file JAR {1}." },
- { "optpkg.attributeserror", "ERRORE: Alcuni attributi manifesti JAR obbligatori non sono impostati nel file JAR {0}." }
- };
-
-}
diff --git a/jdk/src/java.base/share/classes/sun/misc/resources/Messages_ja.java b/jdk/src/java.base/share/classes/sun/misc/resources/Messages_ja.java
deleted file mode 100644
index c5242bf108c..00000000000
--- a/jdk/src/java.base/share/classes/sun/misc/resources/Messages_ja.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * Copyright (c) 2002, 2013, 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 sun.misc.resources;
-
-/**
- * This class represents the {@code ResourceBundle}
- * for sun.misc.
- *
- * @author Michael Colburn
- */
-
-public class Messages_ja extends java.util.ListResourceBundle {
-
- /**
- * Returns the contents of this {@code ResourceBundle}.
- *
- * @return the contents of this {@code ResourceBundle}.
- */
- public Object[][] getContents() {
- return contents;
- }
-
- private static final Object[][] contents = {
- { "optpkg.versionerror", "\u30A8\u30E9\u30FC: JAR\u30D5\u30A1\u30A4\u30EB{0}\u3067\u7121\u52B9\u306A\u30D0\u30FC\u30B8\u30E7\u30F3\u5F62\u5F0F\u304C\u4F7F\u7528\u3055\u308C\u3066\u3044\u307E\u3059\u3002\u30B5\u30DD\u30FC\u30C8\u3055\u308C\u308B\u30D0\u30FC\u30B8\u30E7\u30F3\u5F62\u5F0F\u306B\u3064\u3044\u3066\u306E\u30C9\u30AD\u30E5\u30E1\u30F3\u30C8\u3092\u53C2\u7167\u3057\u3066\u304F\u3060\u3055\u3044\u3002" },
- { "optpkg.attributeerror", "\u30A8\u30E9\u30FC: \u5FC5\u8981\u306AJAR\u30DE\u30CB\u30D5\u30A7\u30B9\u30C8\u5C5E\u6027{0}\u304CJAR\u30D5\u30A1\u30A4\u30EB{1}\u306B\u8A2D\u5B9A\u3055\u308C\u3066\u3044\u307E\u305B\u3093\u3002" },
- { "optpkg.attributeserror", "\u30A8\u30E9\u30FC: \u8907\u6570\u306E\u5FC5\u8981\u306AJAR\u30DE\u30CB\u30D5\u30A7\u30B9\u30C8\u5C5E\u6027\u304CJAR\u30D5\u30A1\u30A4\u30EB{0}\u306B\u8A2D\u5B9A\u3055\u308C\u3066\u3044\u307E\u305B\u3093\u3002" }
- };
-
-}
diff --git a/jdk/src/java.base/share/classes/sun/misc/resources/Messages_ko.java b/jdk/src/java.base/share/classes/sun/misc/resources/Messages_ko.java
deleted file mode 100644
index 63119101d46..00000000000
--- a/jdk/src/java.base/share/classes/sun/misc/resources/Messages_ko.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * Copyright (c) 2002, 2013, 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 sun.misc.resources;
-
-/**
- * This class represents the {@code ResourceBundle}
- * for sun.misc.
- *
- * @author Michael Colburn
- */
-
-public class Messages_ko extends java.util.ListResourceBundle {
-
- /**
- * Returns the contents of this {@code ResourceBundle}.
- *
- * @return the contents of this {@code ResourceBundle}.
- */
- public Object[][] getContents() {
- return contents;
- }
-
- private static final Object[][] contents = {
- { "optpkg.versionerror", "\uC624\uB958: {0} JAR \uD30C\uC77C\uC5D0 \uBD80\uC801\uD569\uD55C \uBC84\uC804 \uD615\uC2DD\uC774 \uC0AC\uC6A9\uB418\uC5C8\uC2B5\uB2C8\uB2E4. \uC124\uBA85\uC11C\uC5D0\uC11C \uC9C0\uC6D0\uB418\uB294 \uBC84\uC804 \uD615\uC2DD\uC744 \uD655\uC778\uD558\uC2ED\uC2DC\uC624." },
- { "optpkg.attributeerror", "\uC624\uB958: \uD544\uC694\uD55C {0} JAR manifest \uC18D\uC131\uC774 {1} JAR \uD30C\uC77C\uC5D0 \uC124\uC815\uB418\uC5B4 \uC788\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4." },
- { "optpkg.attributeserror", "\uC624\uB958: \uD544\uC694\uD55C \uC77C\uBD80 JAR manifest \uC18D\uC131\uC774 {0} JAR \uD30C\uC77C\uC5D0 \uC124\uC815\uB418\uC5B4 \uC788\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4." }
- };
-
-}
diff --git a/jdk/src/java.base/share/classes/sun/misc/resources/Messages_pt_BR.java b/jdk/src/java.base/share/classes/sun/misc/resources/Messages_pt_BR.java
deleted file mode 100644
index ec756d2c4b0..00000000000
--- a/jdk/src/java.base/share/classes/sun/misc/resources/Messages_pt_BR.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * Copyright (c) 2002, 2013, 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 sun.misc.resources;
-
-/**
- * This class represents the {@code ResourceBundle}
- * for sun.misc.
- *
- * @author Michael Colburn
- */
-
-public class Messages_pt_BR extends java.util.ListResourceBundle {
-
- /**
- * Returns the contents of this {@code ResourceBundle}.
- *
- * @return the contents of this {@code ResourceBundle}.
- */
- public Object[][] getContents() {
- return contents;
- }
-
- private static final Object[][] contents = {
- { "optpkg.versionerror", "ERRO: formato de vers\u00E3o inv\u00E1lido usado no arquivo JAR {0}. Verifique a documenta\u00E7\u00E3o para obter o formato de vers\u00E3o suportado." },
- { "optpkg.attributeerror", "ERRO: o atributo de manifesto JAR {0} necess\u00E1rio n\u00E3o est\u00E1 definido no arquivo JAR {1}." },
- { "optpkg.attributeserror", "ERRO: alguns atributos de manifesto JAR necess\u00E1rios n\u00E3o est\u00E3o definidos no arquivo JAR {0}." }
- };
-
-}
diff --git a/jdk/src/java.base/share/classes/sun/misc/resources/Messages_sv.java b/jdk/src/java.base/share/classes/sun/misc/resources/Messages_sv.java
deleted file mode 100644
index 3c7402854ab..00000000000
--- a/jdk/src/java.base/share/classes/sun/misc/resources/Messages_sv.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * Copyright (c) 2002, 2013, 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 sun.misc.resources;
-
-/**
- * This class represents the {@code ResourceBundle}
- * for sun.misc.
- *
- * @author Michael Colburn
- */
-
-public class Messages_sv extends java.util.ListResourceBundle {
-
- /**
- * Returns the contents of this {@code ResourceBundle}.
- *
- * @return the contents of this {@code ResourceBundle}.
- */
- public Object[][] getContents() {
- return contents;
- }
-
- private static final Object[][] contents = {
- { "optpkg.versionerror", "FEL: Ogiltigt versionsformat i {0} JAR-fil. Kontrollera i dokumentationen vilket versionsformat som st\u00F6ds." },
- { "optpkg.attributeerror", "FEL: Obligatoriskt JAR manifest-attribut {0} \u00E4r inte inst\u00E4llt i {1} JAR-filen." },
- { "optpkg.attributeserror", "FEL: Vissa obligatoriska JAR manifest-attribut \u00E4r inte inst\u00E4llda i {0} JAR-filen." }
- };
-
-}
diff --git a/jdk/src/java.base/share/classes/sun/misc/resources/Messages_zh_CN.java b/jdk/src/java.base/share/classes/sun/misc/resources/Messages_zh_CN.java
deleted file mode 100644
index efd2ff0ba8d..00000000000
--- a/jdk/src/java.base/share/classes/sun/misc/resources/Messages_zh_CN.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * Copyright (c) 2002, 2013, 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 sun.misc.resources;
-
-/**
- * This class represents the {@code ResourceBundle}
- * for sun.misc.
- *
- * @author Michael Colburn
- */
-
-public class Messages_zh_CN extends java.util.ListResourceBundle {
-
- /**
- * Returns the contents of this {@code ResourceBundle}.
- *
- * @return the contents of this {@code ResourceBundle}.
- */
- public Object[][] getContents() {
- return contents;
- }
-
- private static final Object[][] contents = {
- { "optpkg.versionerror", "\u9519\u8BEF: {0} JAR \u6587\u4EF6\u4E2D\u4F7F\u7528\u7684\u7248\u672C\u683C\u5F0F\u65E0\u6548\u3002\u8BF7\u68C0\u67E5\u6587\u6863\u4EE5\u4E86\u89E3\u652F\u6301\u7684\u7248\u672C\u683C\u5F0F\u3002" },
- { "optpkg.attributeerror", "\u9519\u8BEF: \u5FC5\u8981\u7684{0} JAR \u6E05\u5355\u5C5E\u6027\u672A\u5728{1} JAR \u6587\u4EF6\u4E2D\u8BBE\u7F6E\u3002" },
- { "optpkg.attributeserror", "\u9519\u8BEF: \u67D0\u4E9B\u5FC5\u8981\u7684 JAR \u6E05\u5355\u5C5E\u6027\u672A\u5728{0} JAR \u6587\u4EF6\u4E2D\u8BBE\u7F6E\u3002" }
- };
-
-}
diff --git a/jdk/src/java.base/share/classes/sun/misc/resources/Messages_zh_TW.java b/jdk/src/java.base/share/classes/sun/misc/resources/Messages_zh_TW.java
deleted file mode 100644
index da6938f84a9..00000000000
--- a/jdk/src/java.base/share/classes/sun/misc/resources/Messages_zh_TW.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * Copyright (c) 2002, 2013, 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 sun.misc.resources;
-
-/**
- * This class represents the {@code ResourceBundle}
- * for sun.misc.
- *
- * @author Michael Colburn
- */
-
-public class Messages_zh_TW extends java.util.ListResourceBundle {
-
- /**
- * Returns the contents of this {@code ResourceBundle}.
- *
- * @return the contents of this {@code ResourceBundle}.
- */
- public Object[][] getContents() {
- return contents;
- }
-
- private static final Object[][] contents = {
- { "optpkg.versionerror", "\u932F\u8AA4: {0} JAR \u6A94\u4F7F\u7528\u4E86\u7121\u6548\u7684\u7248\u672C\u683C\u5F0F\u3002\u8ACB\u6AA2\u67E5\u6587\u4EF6\uFF0C\u4EE5\u7372\u5F97\u652F\u63F4\u7684\u7248\u672C\u683C\u5F0F\u3002" },
- { "optpkg.attributeerror", "\u932F\u8AA4: {1} JAR \u6A94\u4E2D\u672A\u8A2D\u5B9A\u5FC5\u8981\u7684 {0} JAR \u8CC7\u8A0A\u6E05\u55AE\u5C6C\u6027\u3002" },
- { "optpkg.attributeserror", "\u932F\u8AA4: {0} JAR \u6A94\u4E2D\u672A\u8A2D\u5B9A\u67D0\u4E9B\u5FC5\u8981\u7684 JAR \u8CC7\u8A0A\u6E05\u55AE\u5C6C\u6027\u3002" }
- };
-
-}
diff --git a/jdk/src/java.base/share/classes/sun/util/resources/LocaleData.java b/jdk/src/java.base/share/classes/sun/util/resources/LocaleData.java
index ddc24395ee7..b98973ad918 100644
--- a/jdk/src/java.base/share/classes/sun/util/resources/LocaleData.java
+++ b/jdk/src/java.base/share/classes/sun/util/resources/LocaleData.java
@@ -197,8 +197,6 @@ public class LocaleData {
private static abstract class LocaleDataResourceBundleProvider
implements ResourceBundleProvider {
- abstract protected boolean isSupportedInModule(String baseName, Locale locale);
-
/**
* Changes baseName to its module dependent package name and
* calls the super class implementation. For example,
@@ -217,10 +215,6 @@ public class LocaleData {
* resource bundles except for the java.time supplementary data.
*/
public static abstract class CommonResourceBundleProvider extends LocaleDataResourceBundleProvider {
- @Override
- protected boolean isSupportedInModule(String baseName, Locale locale) {
- return LocaleDataStrategy.INSTANCE.inJavaBaseModule(baseName, locale);
- }
}
/**
@@ -228,10 +222,6 @@ public class LocaleData {
* resource bundles for java.time.
*/
public static abstract class SupplementaryResourceBundleProvider extends LocaleDataResourceBundleProvider {
- @Override
- protected boolean isSupportedInModule(String baseName, Locale locale) {
- return SupplementaryStrategy.INSTANCE.inJavaBaseModule(baseName, locale);
- }
}
// Bundles.Strategy implementations
diff --git a/jdk/src/jdk.crypto.mscapi/windows/classes/sun/security/mscapi/KeyStore.java b/jdk/src/jdk.crypto.mscapi/windows/classes/sun/security/mscapi/KeyStore.java
index 4e5b5875b34..84828c156bf 100644
--- a/jdk/src/jdk.crypto.mscapi/windows/classes/sun/security/mscapi/KeyStore.java
+++ b/jdk/src/jdk.crypto.mscapi/windows/classes/sun/security/mscapi/KeyStore.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2005, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -188,8 +188,10 @@ abstract class KeyStore extends KeyStoreSpi {
/*
* The keystore entries.
+ * Keys in the map are unique aliases (thus can differ from
+ * KeyEntry.getAlias())
*/
- private Collection entries = new ArrayList();
+ private Map entries = new HashMap<>();
/*
* The keystore name.
@@ -248,13 +250,10 @@ abstract class KeyStore extends KeyStoreSpi {
if (engineIsKeyEntry(alias) == false)
return null;
- for (KeyEntry entry : entries) {
- if (alias.equals(entry.getAlias())) {
- return entry.getPrivateKey();
- }
- }
-
- return null;
+ KeyEntry entry = entries.get(alias);
+ return (entry == null)
+ ? null
+ : entry.getPrivateKey();
}
/**
@@ -274,15 +273,13 @@ abstract class KeyStore extends KeyStoreSpi {
return null;
}
- for (KeyEntry entry : entries) {
- if (alias.equals(entry.getAlias())) {
- X509Certificate[] certChain = entry.getCertificateChain();
-
- return certChain.clone();
- }
- }
-
- return null;
+ KeyEntry entry = entries.get(alias);
+ X509Certificate[] certChain = (entry == null)
+ ? null
+ : entry.getCertificateChain();
+ return (certChain == null)
+ ? null
+ : certChain.clone();
}
/**
@@ -306,15 +303,13 @@ abstract class KeyStore extends KeyStoreSpi {
return null;
}
- for (KeyEntry entry : entries) {
- if (alias.equals(entry.getAlias()))
- {
- X509Certificate[] certChain = entry.getCertificateChain();
- return certChain.length == 0 ? null : certChain[0];
- }
- }
-
- return null;
+ KeyEntry entry = entries.get(alias);
+ X509Certificate[] certChain = (entry == null)
+ ? null
+ : entry.getCertificateChain();
+ return (certChain == null || certChain.length == 0)
+ ? null
+ : certChain[0];
}
/**
@@ -378,16 +373,7 @@ abstract class KeyStore extends KeyStoreSpi {
if (key instanceof RSAPrivateCrtKey) {
- KeyEntry entry = null;
- boolean found = false;
-
- for (KeyEntry e : entries) {
- if (alias.equals(e.getAlias())) {
- found = true;
- entry = e;
- break;
- }
- }
+ KeyEntry entry = entries.get(alias);
X509Certificate[] xchain;
if (chain != null) {
@@ -401,11 +387,11 @@ abstract class KeyStore extends KeyStoreSpi {
xchain = null;
}
- if (! found) {
+ if (entry == null) {
entry =
//TODO new KeyEntry(alias, key, (X509Certificate[]) chain);
new KeyEntry(alias, null, xchain);
- entries.add(entry);
+ storeWithUniqueAlias(alias, entry);
}
entry.setAlias(alias);
@@ -484,23 +470,14 @@ abstract class KeyStore extends KeyStoreSpi {
// TODO - build CryptoAPI chain?
X509Certificate[] chain =
new X509Certificate[]{ (X509Certificate) cert };
- KeyEntry entry = null;
- boolean found = false;
+ KeyEntry entry = entries.get(alias);
- for (KeyEntry e : entries) {
- if (alias.equals(e.getAlias())) {
- found = true;
- entry = e;
- break;
- }
- }
-
- if (! found) {
+ if (entry == null) {
entry =
new KeyEntry(alias, null, chain);
- entries.add(entry);
-
+ storeWithUniqueAlias(alias, entry);
}
+
if (entry.getPrivateKey() == null) { // trusted-cert entry
entry.setAlias(alias);
@@ -532,32 +509,26 @@ abstract class KeyStore extends KeyStoreSpi {
throw new KeyStoreException("alias must not be null");
}
- for (KeyEntry entry : entries) {
- if (alias.equals(entry.getAlias())) {
+ KeyEntry entry = entries.remove(alias);
+ if (entry != null) {
+ // Get end-entity certificate and remove from system cert store
+ X509Certificate[] certChain = entry.getCertificateChain();
+ if (certChain != null) {
- // Get end-entity certificate and remove from system cert store
- X509Certificate[] certChain = entry.getCertificateChain();
- if (certChain != null) {
+ try {
- try {
-
- byte[] encoding = certChain[0].getEncoded();
- removeCertificate(getName(), alias, encoding,
+ byte[] encoding = certChain[0].getEncoded();
+ removeCertificate(getName(), entry.getAlias(), encoding,
encoding.length);
- } catch (CertificateException e) {
- throw new KeyStoreException("Cannot remove entry: " +
- e);
- }
+ } catch (CertificateException e) {
+ throw new KeyStoreException("Cannot remove entry: ", e);
}
- Key privateKey = entry.getPrivateKey();
- if (privateKey != null) {
- destroyKeyContainer(
- Key.getContainerName(privateKey.getHCryptProvider()));
- }
-
- entries.remove(entry);
- break;
+ }
+ Key privateKey = entry.getPrivateKey();
+ if (privateKey != null) {
+ destroyKeyContainer(
+ Key.getContainerName(privateKey.getHCryptProvider()));
}
}
}
@@ -568,8 +539,7 @@ abstract class KeyStore extends KeyStoreSpi {
* @return enumeration of the alias names
*/
public Enumeration engineAliases() {
-
- final Iterator iter = entries.iterator();
+ final Iterator iter = entries.keySet().iterator();
return new Enumeration()
{
@@ -580,8 +550,7 @@ abstract class KeyStore extends KeyStoreSpi {
public String nextElement()
{
- KeyEntry entry = iter.next();
- return entry.getAlias();
+ return iter.next();
}
};
}
@@ -594,15 +563,7 @@ abstract class KeyStore extends KeyStoreSpi {
* @return true if the alias exists, false otherwise
*/
public boolean engineContainsAlias(String alias) {
- for (Enumeration enumerator = engineAliases();
- enumerator.hasMoreElements();)
- {
- String a = enumerator.nextElement();
-
- if (a.equals(alias))
- return true;
- }
- return false;
+ return entries.containsKey(alias);
}
/**
@@ -627,13 +588,8 @@ abstract class KeyStore extends KeyStoreSpi {
return false;
}
- for (KeyEntry entry : entries) {
- if (alias.equals(entry.getAlias())) {
- return entry.getPrivateKey() != null;
- }
- }
-
- return false;
+ KeyEntry entry = entries.get(alias);
+ return entry != null && entry.getPrivateKey() != null;
}
/**
@@ -643,15 +599,14 @@ abstract class KeyStore extends KeyStoreSpi {
* @return true if the entry identified by the given alias is a
* trusted certificate entry, false otherwise.
*/
- public boolean engineIsCertificateEntry(String alias)
- {
- for (KeyEntry entry : entries) {
- if (alias.equals(entry.getAlias())) {
- return entry.getPrivateKey() == null;
- }
+ public boolean engineIsCertificateEntry(String alias) {
+
+ if (alias == null) {
+ return false;
}
- return false;
+ KeyEntry entry = entries.get(alias);
+ return entry != null && entry.getPrivateKey() == null;
}
/**
@@ -670,9 +625,10 @@ abstract class KeyStore extends KeyStoreSpi {
* @return the (alias) name of the first entry with matching certificate,
* or null if no such entry exists in this keystore.
*/
- public String engineGetCertificateAlias(Certificate cert)
- {
- for (KeyEntry entry : entries) {
+ public String engineGetCertificateAlias(Certificate cert) {
+
+ for (Map.Entry mapEntry : entries.entrySet()) {
+ KeyEntry entry = mapEntry.getValue();
if (entry.certChain != null && entry.certChain[0].equals(cert)) {
return entry.getAlias();
}
@@ -765,20 +721,39 @@ abstract class KeyStore extends KeyStoreSpi {
try {
// Load keys and/or certificate chains
- loadKeysOrCertificateChains(getName(), entries);
+ loadKeysOrCertificateChains(getName());
} catch (KeyStoreException e) {
throw new IOException(e);
}
}
+ /**
+ * Stores the given entry into the map, making sure
+ * the alias, used as the key is unique.
+ * If the same alias already exists, it tries to append
+ * a suffix (1), (2), etc to it until it finds a unique
+ * value.
+ */
+ private void storeWithUniqueAlias(String alias, KeyEntry entry) {
+ String uniqAlias = alias;
+ int uniqNum = 1;
+
+ while (true) {
+ if (entries.putIfAbsent(uniqAlias, entry) == null) {
+ break;
+ }
+ uniqAlias = alias + " (" + (uniqNum++) + ")";
+ }
+ }
+
+
/**
* Generates a certificate chain from the collection of
* certificates and stores the result into a key entry.
*/
private void generateCertificateChain(String alias,
- Collection extends Certificate> certCollection,
- Collection entries)
+ Collection extends Certificate> certCollection)
{
try
{
@@ -792,10 +767,8 @@ abstract class KeyStore extends KeyStoreSpi {
certChain[i] = (X509Certificate) iter.next();
}
- KeyEntry entry = new KeyEntry(alias, null, certChain);
-
- // Add cert chain
- entries.add(entry);
+ storeWithUniqueAlias(alias,
+ new KeyEntry(alias, null, certChain));
}
catch (Throwable e)
{
@@ -810,8 +783,7 @@ abstract class KeyStore extends KeyStoreSpi {
*/
private void generateRSAKeyAndCertificateChain(String alias,
long hCryptProv, long hCryptKey, int keyLength,
- Collection extends Certificate> certCollection,
- Collection entries)
+ Collection extends Certificate> certCollection)
{
try
{
@@ -825,11 +797,9 @@ abstract class KeyStore extends KeyStoreSpi {
certChain[i] = (X509Certificate) iter.next();
}
- KeyEntry entry = new KeyEntry(alias, new RSAPrivateKey(hCryptProv,
- hCryptKey, keyLength), certChain);
-
- // Add cert chain
- entries.add(entry);
+ storeWithUniqueAlias(alias, new KeyEntry(alias,
+ new RSAPrivateKey(hCryptProv, hCryptKey, keyLength),
+ certChain));
}
catch (Throwable e)
{
@@ -886,8 +856,8 @@ abstract class KeyStore extends KeyStoreSpi {
* @param name Name of keystore.
* @param entries Collection of key/certificate.
*/
- private native void loadKeysOrCertificateChains(String name,
- Collection entries) throws KeyStoreException;
+ private native void loadKeysOrCertificateChains(String name)
+ throws KeyStoreException;
/**
* Stores a DER-encoded certificate into the certificate store
diff --git a/jdk/src/jdk.crypto.mscapi/windows/native/libsunmscapi/security.cpp b/jdk/src/jdk.crypto.mscapi/windows/native/libsunmscapi/security.cpp
index 41f3367bc4e..19f40b74d28 100644
--- a/jdk/src/jdk.crypto.mscapi/windows/native/libsunmscapi/security.cpp
+++ b/jdk/src/jdk.crypto.mscapi/windows/native/libsunmscapi/security.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2005, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -272,7 +272,7 @@ JNIEXPORT jbyteArray JNICALL Java_sun_security_mscapi_PRNG_generateSeed
* Signature: (Ljava/lang/String;Ljava/util/Collection;)V
*/
JNIEXPORT void JNICALL Java_sun_security_mscapi_KeyStore_loadKeysOrCertificateChains
- (JNIEnv *env, jobject obj, jstring jCertStoreName, jobject jCollections)
+ (JNIEnv *env, jobject obj, jstring jCertStoreName)
{
/**
* Certificate in cert store has enhanced key usage extension
@@ -331,7 +331,7 @@ JNIEXPORT void JNICALL Java_sun_security_mscapi_KeyStore_loadKeysOrCertificateCh
// Determine method ID to generate certificate chain
jmethodID mGenCertChain = env->GetMethodID(clazzOfThis,
"generateCertificateChain",
- "(Ljava/lang/String;Ljava/util/Collection;Ljava/util/Collection;)V");
+ "(Ljava/lang/String;Ljava/util/Collection;)V");
if (mGenCertChain == NULL) {
__leave;
}
@@ -339,7 +339,7 @@ JNIEXPORT void JNICALL Java_sun_security_mscapi_KeyStore_loadKeysOrCertificateCh
// Determine method ID to generate RSA certificate chain
jmethodID mGenRSAKeyAndCertChain = env->GetMethodID(clazzOfThis,
"generateRSAKeyAndCertificateChain",
- "(Ljava/lang/String;JJILjava/util/Collection;Ljava/util/Collection;)V");
+ "(Ljava/lang/String;JJILjava/util/Collection;)V");
if (mGenRSAKeyAndCertChain == NULL) {
__leave;
}
@@ -366,38 +366,37 @@ JNIEXPORT void JNICALL Java_sun_security_mscapi_KeyStore_loadKeysOrCertificateCh
} else {
// Private key is available
- BOOL bGetUserKey = ::CryptGetUserKey(hCryptProv, dwKeySpec, &hUserKey);
+ BOOL bGetUserKey = ::CryptGetUserKey(hCryptProv, dwKeySpec, &hUserKey);
- // Skip certificate if cannot find private key
- if (bGetUserKey == FALSE)
- {
- if (bCallerFreeProv)
- ::CryptReleaseContext(hCryptProv, NULL);
+ // Skip certificate if cannot find private key
+ if (bGetUserKey == FALSE)
+ {
+ if (bCallerFreeProv)
+ ::CryptReleaseContext(hCryptProv, NULL);
+
+ continue;
+ }
+
+ // Set cipher mode to ECB
+ DWORD dwCipherMode = CRYPT_MODE_ECB;
+ ::CryptSetKeyParam(hUserKey, KP_MODE, (BYTE*)&dwCipherMode, NULL);
+
+
+ // If the private key is present in smart card, we may not be able to
+ // determine the key length by using the private key handle. However,
+ // since public/private key pairs must have the same length, we could
+ // determine the key length of the private key by using the public key
+ // in the certificate.
+ dwPublicKeyLength = ::CertGetPublicKeyLength(X509_ASN_ENCODING | PKCS_7_ASN_ENCODING,
+ &(pCertContext->pCertInfo->SubjectPublicKeyInfo));
- continue;
}
-
- // Set cipher mode to ECB
- DWORD dwCipherMode = CRYPT_MODE_ECB;
- ::CryptSetKeyParam(hUserKey, KP_MODE, (BYTE*)&dwCipherMode, NULL);
-
-
- // If the private key is present in smart card, we may not be able to
- // determine the key length by using the private key handle. However,
- // since public/private key pairs must have the same length, we could
- // determine the key length of the private key by using the public key
- // in the certificate.
- dwPublicKeyLength = ::CertGetPublicKeyLength(X509_ASN_ENCODING | PKCS_7_ASN_ENCODING,
- &(pCertContext->pCertInfo->SubjectPublicKeyInfo));
-
-}
PCCERT_CHAIN_CONTEXT pCertChainContext = NULL;
// Build certificate chain by using system certificate store.
// Add cert chain into collection for any key usage.
//
- if (GetCertificateChain(OID_EKU_ANY, pCertContext,
- &pCertChainContext))
+ if (GetCertificateChain(OID_EKU_ANY, pCertContext, &pCertChainContext))
{
for (unsigned int i=0; i < pCertChainContext->cChain; i++)
@@ -456,26 +455,26 @@ JNIEXPORT void JNICALL Java_sun_security_mscapi_KeyStore_loadKeysOrCertificateCh
// collection
env->CallVoidMethod(obj, mGenCertChain,
env->NewStringUTF(pszNameString),
- jArrayList, jCollections);
+ jArrayList);
}
else
{
- // Determine key type: RSA or DSA
- DWORD dwData = CALG_RSA_KEYX;
- DWORD dwSize = sizeof(DWORD);
- ::CryptGetKeyParam(hUserKey, KP_ALGID, (BYTE*)&dwData,
- &dwSize, NULL);
+ // Determine key type: RSA or DSA
+ DWORD dwData = CALG_RSA_KEYX;
+ DWORD dwSize = sizeof(DWORD);
+ ::CryptGetKeyParam(hUserKey, KP_ALGID, (BYTE*)&dwData,
+ &dwSize, NULL);
- if ((dwData & ALG_TYPE_RSA) == ALG_TYPE_RSA)
- {
- // Generate RSA certificate chain and store into cert
- // chain collection
- env->CallVoidMethod(obj, mGenRSAKeyAndCertChain,
- env->NewStringUTF(pszNameString),
- (jlong) hCryptProv, (jlong) hUserKey,
- dwPublicKeyLength, jArrayList, jCollections);
+ if ((dwData & ALG_TYPE_RSA) == ALG_TYPE_RSA)
+ {
+ // Generate RSA certificate chain and store into cert
+ // chain collection
+ env->CallVoidMethod(obj, mGenRSAKeyAndCertChain,
+ env->NewStringUTF(pszNameString),
+ (jlong) hCryptProv, (jlong) hUserKey,
+ dwPublicKeyLength, jArrayList);
+ }
}
-}
}
// Free cert chain
diff --git a/jdk/src/jdk.jartool/share/classes/sun/tools/jar/Main.java b/jdk/src/jdk.jartool/share/classes/sun/tools/jar/Main.java
index be2882d037b..ffe38159603 100644
--- a/jdk/src/jdk.jartool/share/classes/sun/tools/jar/Main.java
+++ b/jdk/src/jdk.jartool/share/classes/sun/tools/jar/Main.java
@@ -51,8 +51,8 @@ import java.text.MessageFormat;
import jdk.internal.module.Hasher;
import jdk.internal.module.ModuleInfoExtender;
-import sun.misc.JarIndex;
-import static sun.misc.JarIndex.INDEX_NAME;
+import jdk.internal.util.jar.JarIndex;
+import static jdk.internal.util.jar.JarIndex.INDEX_NAME;
import static java.util.jar.JarFile.MANIFEST_NAME;
import static java.util.stream.Collectors.joining;
import static java.nio.file.StandardCopyOption.REPLACE_EXISTING;
diff --git a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/ImageFileCreator.java b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/ImageFileCreator.java
index 5e8d85b1eff..6246e29afc2 100644
--- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/ImageFileCreator.java
+++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/ImageFileCreator.java
@@ -46,6 +46,7 @@ import jdk.tools.jlink.internal.Archive.Entry;
import jdk.tools.jlink.internal.Archive.Entry.EntryType;
import jdk.tools.jlink.internal.PoolImpl.CompressedModuleData;
import jdk.tools.jlink.plugin.ExecutableImage;
+import jdk.tools.jlink.plugin.PluginException;
import jdk.tools.jlink.plugin.Pool;
import jdk.tools.jlink.plugin.Pool.ModuleData;
import jdk.tools.jlink.plugin.Pool.ModuleDataType;
@@ -183,6 +184,8 @@ public final class ImageFileCreator {
PoolImpl resultResources;
try {
resultResources = pluginSupport.visitResources(allContent);
+ } catch (PluginException pe) {
+ throw pe;
} catch (Exception ex) {
throw new IOException(ex);
}
diff --git a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/GenerateJLIClassesPlugin.java b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/GenerateJLIClassesPlugin.java
new file mode 100644
index 00000000000..d2b2995bdda
--- /dev/null
+++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/GenerateJLIClassesPlugin.java
@@ -0,0 +1,226 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package jdk.tools.jlink.internal.plugins;
+
+import java.io.ByteArrayInputStream;
+import java.lang.reflect.Method;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.EnumSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.stream.Collectors;
+import jdk.tools.jlink.plugin.PluginException;
+import jdk.tools.jlink.plugin.Pool;
+import jdk.tools.jlink.plugin.TransformerPlugin;
+
+/**
+ * Plugin to generate java.lang.invoke classes.
+ */
+public final class GenerateJLIClassesPlugin implements TransformerPlugin {
+
+ private static final String NAME = "generate-jli-classes";
+
+ private static final String BMH_PARAM = "bmh";
+
+ private static final String BMH_SPECIES_PARAM = "bmh-species";
+
+ private static final String DESCRIPTION = PluginsResourceBundle.getDescription(NAME);
+
+ private static final String BMH = "java/lang/invoke/BoundMethodHandle";
+
+ private static final Method FACTORY_METHOD;
+
+ List speciesTypes;
+
+ public GenerateJLIClassesPlugin() {
+ }
+
+ @Override
+ public Set getType() {
+ return Collections.singleton(CATEGORY.TRANSFORMER);
+ }
+
+ @Override
+ public String getName() {
+ return NAME;
+ }
+
+ @Override
+ public String getDescription() {
+ return DESCRIPTION;
+ }
+
+ @Override
+ public Set getState() {
+ return EnumSet.of(STATE.AUTO_ENABLED, STATE.FUNCTIONAL);
+ }
+
+ @Override
+ public boolean hasArguments() {
+ return true;
+ }
+
+ @Override
+ public String getArgumentsDescription() {
+ return PluginsResourceBundle.getArgument(NAME);
+ }
+
+ /**
+ * @return the default Species forms to generate.
+ *
+ * This list was derived from running a Java concatenating strings
+ * with -Djava.lang.invoke.stringConcat=MH_INLINE_SIZED_EXACT set
+ * plus a subset of octane. A better long-term solution is to define
+ * and run a set of quick generators and extracting this list as a
+ * step in the build process.
+ */
+ public static List defaultSpecies() {
+ return List.of("LL", "L3", "L4", "L5", "L6", "L7", "L7I",
+ "L7II", "L7IIL", "L8", "L9", "L10", "L11", "L11I", "L11II",
+ "L12", "L13", "LI", "D", "L3I", "LIL", "LLI", "LLIL",
+ "LILL", "I", "LLILL");
+ }
+
+ @Override
+ public void configure(Map config) {
+ String mainArgument = config.get(NAME);
+
+ // Enable by default
+ boolean bmhEnabled = true;
+ if (mainArgument != null) {
+ Set args = Arrays.stream(mainArgument.split(","))
+ .collect(Collectors.toSet());
+ if (!args.contains(BMH_PARAM)) {
+ bmhEnabled = false;
+ }
+ }
+
+ if (!bmhEnabled) {
+ speciesTypes = List.of();
+ } else {
+ String args = config.get(BMH_SPECIES_PARAM);
+ List bmhSpecies;
+ if (args != null && !args.isEmpty()) {
+ bmhSpecies = Arrays.stream(args.split(","))
+ .map(String::trim)
+ .filter(s -> !s.isEmpty())
+ .collect(Collectors.toList());
+ } else {
+ bmhSpecies = defaultSpecies();
+ }
+
+ // Expand BMH species signatures
+ speciesTypes = bmhSpecies.stream()
+ .map(type -> expandSignature(type))
+ .collect(Collectors.toList());
+
+ // Validation check
+ for (String type : speciesTypes) {
+ for (char c : type.toCharArray()) {
+ if ("LIJFD".indexOf(c) < 0) {
+ throw new PluginException("All characters must "
+ + "correspond to a basic field type: LIJFD");
+ }
+ }
+ }
+ }
+ }
+
+ @Override
+ public void visit(Pool in, Pool out) {
+ for (Pool.ModuleData data : in.getContent()) {
+ if (("/java.base/" + BMH + ".class").equals(data.getPath())) {
+ // Add BoundMethodHandle unchanged
+ out.add(data);
+ speciesTypes.forEach(types -> generateConcreteClass(types, data, out));
+ } else {
+ if (!out.contains(data)) {
+ out.add(data);
+ }
+ }
+ }
+ }
+
+ @SuppressWarnings("unchecked")
+ private void generateConcreteClass(String types, Pool.ModuleData data, Pool out) {
+ try {
+ // Generate class
+ Map.Entry result = (Map.Entry)
+ FACTORY_METHOD.invoke(null, types);
+ String className = result.getKey();
+ byte[] bytes = result.getValue();
+
+ // Add class to pool
+ Pool.ModuleData ndata = new Pool.ModuleData(data.getModule(),
+ "/java.base/" + className + ".class",
+ Pool.ModuleDataType.CLASS_OR_RESOURCE,
+ new ByteArrayInputStream(bytes), bytes.length);
+ if (!out.contains(ndata)) {
+ out.add(ndata);
+ }
+ } catch (Exception ex) {
+ throw new PluginException(ex);
+ }
+ }
+
+ static {
+ try {
+ Class> BMHFactory = Class.forName("java.lang.invoke.BoundMethodHandle$Factory");
+ Method genClassMethod = BMHFactory.getDeclaredMethod("generateConcreteBMHClassBytes",
+ String.class);
+ genClassMethod.setAccessible(true);
+ FACTORY_METHOD = genClassMethod;
+ } catch (Exception e) {
+ throw new PluginException(e);
+ }
+ }
+
+ // Convert LL -> LL, L3 -> LLL
+ private static String expandSignature(String signature) {
+ StringBuilder sb = new StringBuilder();
+ char last = 'X';
+ int count = 0;
+ for (int i = 0; i < signature.length(); i++) {
+ char c = signature.charAt(i);
+ if (c >= '0' && c <= '9') {
+ count *= 10;
+ count += (c - '0');
+ } else {
+ for (int j = 1; j < count; j++) {
+ sb.append(last);
+ }
+ sb.append(c);
+ last = c;
+ count = 0;
+ }
+ }
+ for (int j = 1; j < count; j++) {
+ sb.append(last);
+ }
+ return sb.toString();
+ }
+}
diff --git a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/IncludeLocalesPlugin.java b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/IncludeLocalesPlugin.java
index 8a37d8c518e..b373f85b935 100644
--- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/IncludeLocalesPlugin.java
+++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/IncludeLocalesPlugin.java
@@ -92,6 +92,7 @@ public final class IncludeLocalesPlugin implements TransformerPlugin, ResourcePr
"*sun/text/resources/cldr/ext/[^\\/]+_%%.class," +
"*sun/util/resources/cldr/ext/[^\\/]+_%%.class,";
private Predicate predicate;
+ private String userParam;
private List priorityList;
private List available;
private List filtered;
@@ -155,13 +156,17 @@ public final class IncludeLocalesPlugin implements TransformerPlugin, ResourcePr
@Override
public void configure(Map config) {
- try {
- priorityList = Arrays.stream(config.get(NAME).split(","))
- .map(Locale.LanguageRange::new)
- .collect(Collectors.toList());
- } catch (IllegalArgumentException iae) {
- throw new PluginException(iae.getLocalizedMessage());
- }
+ userParam = config.get(NAME);
+ priorityList = Arrays.stream(userParam.split(","))
+ .map(s -> {
+ try {
+ return new Locale.LanguageRange(s);
+ } catch (IllegalArgumentException iae) {
+ throw new PluginException(String.format(
+ PluginsResourceBundle.getMessage(NAME + ".invalidtag"), s));
+ }
+ })
+ .collect(Collectors.toList());
}
@Override
@@ -191,7 +196,8 @@ public final class IncludeLocalesPlugin implements TransformerPlugin, ResourcePr
filtered = filterLocales(available);
if (filtered.isEmpty()) {
- throw new PluginException(PluginsResourceBundle.getMessage(NAME + ".nomatchinglocales"));
+ throw new PluginException(
+ String.format(PluginsResourceBundle.getMessage(NAME + ".nomatchinglocales"), userParam));
}
try {
diff --git a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/resources/plugins.properties b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/resources/plugins.properties
index 0fd33da26b0..73143b8ef79 100644
--- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/resources/plugins.properties
+++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/resources/plugins.properties
@@ -20,7 +20,7 @@ Level 0: constant string sharing\n\
Level 1: ZIP\n\
Level 2: both.\n\
An optional filter can be specified to list the pattern of files to be filtered.\n\
-Use ^ for negation. eg: *Exception.class,*Error.class,^/java.base/java/lang/*
+Use ^ for negation. e.g.: *Exception.class,*Error.class,^/java.base/java/lang/*
compact-cp.argument=
@@ -32,17 +32,22 @@ copy-files.argument== to copy to the image>.
copy-files.description=\
If files to copy are not absolute path, JDK home dir is used.\n\
-eg: jrt-fs.jar,LICENSE,/home/me/myfile.txt=somewehere/conf.txt
+e.g.: jrt-fs.jar,LICENSE,/home/me/myfile.txt=somewehere/conf.txt
exclude-files.argument=
exclude-files.description=\
-Specify files to exclude. eg: *.diz, /java.base/native/client/*
+Specify files to exclude. e.g.: *.diz, /java.base/native/client/*
exclude-resources.argument=
exclude-resources.description=\
-Specify resources to exclude. eg: *.jcov, */META-INF/*
+Specify resources to exclude. e.g.: *.jcov, */META-INF/*
+
+generate-jli-classes.argument=
+
+generate-jli-classes.description=\
+Concrete java.lang.invoke classes to generate
installed-modules.description=Fast loading of module descriptors (always enabled)
@@ -51,7 +56,7 @@ onoff.argument=
sort-resources.argument=
sort-resources.description=\
-Sort resources. eg: */modules-info.class,/java-base/java/lang/*
+Sort resources. e.g.: */modules-info.class,/java-base/java/lang/*
strip-debug.description=\
Strip debug information from the output image
@@ -73,13 +78,16 @@ include-locales.argument=\
include-locales.description=\
BCP 47 language tags separated by a comma, allowing locale matching\n\
-defined in RFC 4647. eg: en,ja,*-IN
+defined in RFC 4647. e.g.: en,ja,*-IN
include-locales.missingpackages=\
Missing locale data packages in jdk.localedata:\n\t
include-locales.nomatchinglocales=\
-No matching locales found. Check the specified pattern.
+No matching locales found for \"%s\". Check the specified pattern.
+
+include-locales.invalidtag=\
+Invalid language tag: %s
main.status.ok=Functional.
diff --git a/jdk/src/jdk.jlink/share/classes/module-info.java b/jdk/src/jdk.jlink/share/classes/module-info.java
index 06688eec181..2edf6460b29 100644
--- a/jdk/src/jdk.jlink/share/classes/module-info.java
+++ b/jdk/src/jdk.jlink/share/classes/module-info.java
@@ -45,5 +45,6 @@ module jdk.jlink {
provides jdk.tools.jlink.plugin.TransformerPlugin with jdk.tools.jlink.internal.plugins.OptimizationPlugin;
provides jdk.tools.jlink.plugin.TransformerPlugin with jdk.tools.jlink.internal.plugins.ExcludeVMPlugin;
provides jdk.tools.jlink.plugin.TransformerPlugin with jdk.tools.jlink.internal.plugins.IncludeLocalesPlugin;
+ provides jdk.tools.jlink.plugin.TransformerPlugin with jdk.tools.jlink.internal.plugins.GenerateJLIClassesPlugin;
provides jdk.tools.jlink.plugin.PostProcessorPlugin with jdk.tools.jlink.internal.plugins.ReleaseInfoPlugin;
}
diff --git a/jdk/src/jdk.localedata/share/classes/sun/util/resources/provider/LocaleDataProvider.java b/jdk/src/jdk.localedata/share/classes/sun/util/resources/provider/LocaleDataProvider.java
index b2b312eb639..2513237f7bf 100644
--- a/jdk/src/jdk.localedata/share/classes/sun/util/resources/provider/LocaleDataProvider.java
+++ b/jdk/src/jdk.localedata/share/classes/sun/util/resources/provider/LocaleDataProvider.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -25,34 +25,33 @@
package sun.util.resources.provider;
-import java.lang.reflect.Module;
import java.util.Locale;
import java.util.ResourceBundle;
-import sun.util.locale.provider.ResourceBundleProviderSupport;
import sun.util.resources.LocaleData;
/**
- * {@code LocaleDataProvider} in module jdk.localedata implements
- * {@code LocaleDataBundleProvider} in module java.base. This class works as a
- * service agent between {@code ResourceBundle.getBundle} callers in java.base
- * and resource bundles in jdk.localedata.
+ * Service Provider for loading locale data resource bundles in jdk.localedata
+ * except for JavaTimeSupplementary resource bundles.
*/
public class LocaleDataProvider extends LocaleData.CommonResourceBundleProvider {
@Override
- protected boolean isSupportedInModule(String baseName, Locale locale) {
- // The assumption here is that there are two modules containing
- // resource bundles for locale support. If resource bundles are split
- // into more modules, this method will need to be changed to determine
- // what locales are exactly supported.
- return !super.isSupportedInModule(baseName, locale);
+ public ResourceBundle getBundle(String baseName, Locale locale) {
+ return loadResourceBundle(toBundleName(baseName, locale));
}
- @Override
- public ResourceBundle getBundle(String baseName, Locale locale) {
- if (isSupportedInModule(baseName, locale)) {
- Module module = LocaleDataProvider.class.getModule();
- String bundleName = toBundleName(baseName, locale);
- return ResourceBundleProviderSupport.loadResourceBundle(module, bundleName);
+ /**
+ * Utility method for loading a resource bundle in jdk.localedata.
+ */
+ static ResourceBundle loadResourceBundle(String bundleName) {
+ Class> c = Class.forName(LocaleDataProvider.class.getModule(), bundleName);
+ if (c != null && ResourceBundle.class.isAssignableFrom(c)) {
+ try {
+ @SuppressWarnings("unchecked")
+ ResourceBundle rb = ((Class) c).newInstance();
+ return rb;
+ } catch (InstantiationException | IllegalAccessException e) {
+ throw new InternalError(e);
+ }
}
return null;
}
diff --git a/jdk/src/jdk.localedata/share/classes/sun/util/resources/provider/SupplementaryLocaleDataProvider.java b/jdk/src/jdk.localedata/share/classes/sun/util/resources/provider/SupplementaryLocaleDataProvider.java
index 29884d04b6a..04d3c11b663 100644
--- a/jdk/src/jdk.localedata/share/classes/sun/util/resources/provider/SupplementaryLocaleDataProvider.java
+++ b/jdk/src/jdk.localedata/share/classes/sun/util/resources/provider/SupplementaryLocaleDataProvider.java
@@ -25,33 +25,16 @@
package sun.util.resources.provider;
-import java.lang.reflect.Module;
import java.util.Locale;
import java.util.ResourceBundle;
-
-import sun.util.locale.provider.ResourceBundleProviderSupport;
import sun.util.resources.LocaleData;
/**
- * {@code SupplementaryLocaleDataProvider} in module jdk.localedata implements
- * {@code JavaTimeSupplementaryProvider} in module java.base. This class works as a
- * service agent between {@code ResourceBundle.getBundle} callers in java.base
- * and resource bundles in jdk.localedata.
+ * Service Provider for loading JavaTimeSupplementary resource bundles in jdk.localedata.
*/
public class SupplementaryLocaleDataProvider extends LocaleData.SupplementaryResourceBundleProvider {
- @Override
- protected boolean isSupportedInModule(String baseName, Locale locale) {
- // The assumption here is that there are two modules containing
- // resource bundles for locale support. If resource bundles are split
- // into more modules, this method will need to be changed to determine
- // what locales are exactly supported.
- return !super.isSupportedInModule(baseName, locale);
- }
-
@Override
public ResourceBundle getBundle(String baseName, Locale locale) {
- Module module = LocaleDataProvider.class.getModule();
- String bundleName = toBundleName(baseName, locale);
- return ResourceBundleProviderSupport.loadResourceBundle(module, bundleName);
+ return LocaleDataProvider.loadResourceBundle(toBundleName(baseName, locale));
}
}
diff --git a/jdk/test/Makefile b/jdk/test/Makefile
index 3312cccbc57..caf0d19ca09 100644
--- a/jdk/test/Makefile
+++ b/jdk/test/Makefile
@@ -302,6 +302,8 @@ JTREG_BASIC_OPTIONS += $(JTREG_TIMEOUT_OPTION)
# Set the max memory for jtreg control vm
JTREG_MEMORY_OPTION = -J-Xmx512m
JTREG_BASIC_OPTIONS += $(JTREG_MEMORY_OPTION)
+# Give tests access to JT_JAVA, see JDK-8141609
+JTREG_BASIC_OPTIONS += -e:JDK8_HOME=${JT_JAVA}
# Add any extra options
JTREG_BASIC_OPTIONS += $(EXTRA_JTREG_OPTIONS)
# Set other vm and test options
diff --git a/jdk/test/ProblemList.txt b/jdk/test/ProblemList.txt
index 49eb36ecf4a..971a0b8b0aa 100644
--- a/jdk/test/ProblemList.txt
+++ b/jdk/test/ProblemList.txt
@@ -116,221 +116,184 @@
# jdk_beans
-# 8060027
-java/beans/XMLEncoder/Test4903007.java generic-all
-java/beans/XMLEncoder/java_awt_GridBagLayout.java generic-all
-java/beans/XMLDecoder/8028054/TestConstructorFinder.java generic-all
-java/beans/XMLDecoder/8028054/TestMethodFinder.java generic-all
+java/beans/XMLEncoder/Test4903007.java 8060027 generic-all
+java/beans/XMLEncoder/java_awt_GridBagLayout.java 8060027 generic-all
+java/beans/XMLDecoder/8028054/TestConstructorFinder.java 8060027 generic-all
+java/beans/XMLDecoder/8028054/TestMethodFinder.java 8060027 generic-all
-# 8132565
-java/beans/Introspector/8132566/OverridePropertyInfoTest.java generic-all
-java/beans/Introspector/8132566/OverrideUserDefPropertyInfoTest.java generic-all
+java/beans/Introspector/8132566/OverridePropertyInfoTest.java 8132565 generic-all
+java/beans/Introspector/8132566/OverrideUserDefPropertyInfoTest.java 8132565 generic-all
############################################################################
# jdk_lang
-# 8029891
-java/lang/ClassLoader/deadlock/GetResource.java generic-all
+java/lang/ClassLoader/deadlock/GetResource.java 8029891 generic-all
-# 7008363
-java/lang/StringCoding/CheckEncodings.sh generic-all
+java/lang/StringCoding/CheckEncodings.sh 7008363 generic-all
############################################################################
# jdk_instrument
-# 8061177
-java/lang/instrument/RedefineBigClass.sh generic-all
-java/lang/instrument/RetransformBigClass.sh generic-all
+java/lang/instrument/RedefineBigClass.sh 8061177 generic-all
+java/lang/instrument/RetransformBigClass.sh 8061177 generic-all
-# 8072130
-java/lang/instrument/BootClassPath/BootClassPathTest.sh macosx-all
+java/lang/instrument/BootClassPath/BootClassPathTest.sh 8072130 macosx-all
-# 8130339
-java/lang/management/MemoryMXBean/LowMemoryTest.java generic-all
+java/lang/management/MemoryMXBean/LowMemoryTest.java 8130339 generic-all
############################################################################
# jdk_jmx
-# 8030957
-com/sun/management/OperatingSystemMXBean/GetProcessCpuLoad.java aix-all
-com/sun/management/OperatingSystemMXBean/GetSystemCpuLoad.java aix-all
-javax/management/MBeanServer/OldMBeanServerTest.java aix-all
+com/sun/management/OperatingSystemMXBean/GetProcessCpuLoad.java 8030957 aix-all
+com/sun/management/OperatingSystemMXBean/GetSystemCpuLoad.java 8030957 aix-all
+javax/management/MBeanServer/OldMBeanServerTest.java 8030957 aix-all
-# 8042215
-javax/management/remote/mandatory/notif/NotifReconnectDeadlockTest.java generic-all
+javax/management/remote/mandatory/notif/NotifReconnectDeadlockTest.java 8042215 generic-all
-# 8147985
-sun/management/jmxremote/bootstrap/JMXInterfaceBindingTest.java generic-all
+sun/management/jmxremote/bootstrap/JMXInterfaceBindingTest.java 8147985 generic-all
############################################################################
# jdk_net
-# 7148829
-sun/net/InetAddress/nameservice/simple/CacheTest.java generic-all
-sun/net/InetAddress/nameservice/simple/DefaultCaching.java generic-all
+sun/net/InetAddress/nameservice/simple/CacheTest.java 7148829 generic-all
+sun/net/InetAddress/nameservice/simple/DefaultCaching.java 7148829 generic-all
-# 7122846
-java/net/MulticastSocket/NoLoopbackPackets.java macosx-all
-java/net/MulticastSocket/SetLoopbackMode.java macosx-all
+java/net/MulticastSocket/NoLoopbackPackets.java 7122846 macosx-all
+java/net/MulticastSocket/SetLoopbackMode.java 7122846 macosx-all
-# 7145658
-java/net/MulticastSocket/Test.java macosx-all
+java/net/MulticastSocket/Test.java 7145658 macosx-all
-# 7143960
-java/net/DatagramSocket/SendDatagramToBadAddress.java macosx-all
+java/net/DatagramSocket/SendDatagramToBadAddress.java 7143960 macosx-all
############################################################################
# jdk_nio
-# 6963118
-java/nio/channels/Selector/Wakeup.java windows-all
+java/nio/channels/Selector/Wakeup.java 6963118 windows-all
-# 7141822
-java/nio/channels/DatagramChannel/ChangingAddress.java macosx-all
+java/nio/channels/DatagramChannel/ChangingAddress.java 7141822 macosx-all
-# 7132677
-java/nio/channels/Selector/OutOfBand.java macosx-all
+java/nio/channels/Selector/OutOfBand.java 7132677 macosx-all
-# 7158947, Solaris 11
-java/nio/file/WatchService/Basic.java solaris-all
-java/nio/file/WatchService/MayFlies.java solaris-all
-java/nio/file/WatchService/LotsOfEvents.java solaris-all
+java/nio/file/WatchService/Basic.java 7158947 solaris-all Solaris 11
+java/nio/file/WatchService/MayFlies.java 7158947 solaris-all Solaris 11
+java/nio/file/WatchService/LotsOfEvents.java 7158947 solaris-all Solaris 11
-# 8149712
-java/nio/charset/coders/BashStreams.java generic-all
+java/nio/charset/coders/BashStreams.java 8149712 generic-all
############################################################################
# jdk_rmi
-# 7140992
-java/rmi/server/Unreferenced/finiteGCLatency/FiniteGCLatency.java generic-all
+java/rmi/server/Unreferenced/finiteGCLatency/FiniteGCLatency.java 7140992 generic-all
-# 7146541
-java/rmi/transport/rapidExportUnexport/RapidExportUnexport.java linux-all
+java/rmi/transport/rapidExportUnexport/RapidExportUnexport.java 7146541 linux-all
-# 7191877
-java/rmi/transport/checkLeaseInfoLeak/CheckLeaseLeak.java generic-all
+java/rmi/transport/checkLeaseInfoLeak/CheckLeaseLeak.java 7191877 generic-all
-# 7195095
-sun/rmi/transport/proxy/EagerHttpFallback.java generic-all
+sun/rmi/transport/proxy/EagerHttpFallback.java 7195095 generic-all
-# 8062724
-java/rmi/activation/Activatable/extLoadedImpl/ext.sh generic-all
+java/rmi/activation/Activatable/extLoadedImpl/ext.sh 8062724 generic-all
-# 8145980
-sun/rmi/rmic/newrmic/equivalence/run.sh generic-all
+sun/rmi/rmic/newrmic/equivalence/run.sh 8145980 generic-all
############################################################################
# jdk_security
-# 7157786
-sun/security/pkcs11/ec/TestKeyFactory.java generic-all
+sun/security/pkcs11/ec/TestKeyFactory.java 7157786 generic-all
-# 7164518: no PortUnreachableException on Mac
-sun/security/krb5/auto/Unreachable.java macosx-all
+sun/security/krb5/auto/Unreachable.java 7164518 macosx-all no PortUnreachableException on Mac
-# 7041639: Solaris DSA keypair generation bug
-java/security/KeyPairGenerator/SolarisShortDSA.java solaris-all
-sun/security/tools/keytool/standard.sh solaris-all
+java/security/KeyPairGenerator/SolarisShortDSA.java 7041639 solaris-all
+sun/security/tools/keytool/standard.sh 7041639 solaris-all
-# 8062758
-java/security/Security/ClassLoaderDeadlock/Deadlock2.sh generic-all
+java/security/Security/ClassLoaderDeadlock/Deadlock2.sh 8062758 generic-all
-# 8026393
-sun/security/tools/jarsigner/warnings/BadKeyUsageTest.java generic-all
+sun/security/tools/jarsigner/warnings/BadKeyUsageTest.java 8026393 generic-all
-# 8077138: Some PKCS11 tests fail because NSS library is not initialized
-# 8023434: NSS initialization failed
-sun/security/pkcs11/Cipher/ReinitCipher.java windows-all
-sun/security/pkcs11/Cipher/TestPKCS5PaddingError.java windows-all
-sun/security/pkcs11/Cipher/TestRSACipher.java windows-all
-sun/security/pkcs11/Cipher/TestRSACipherWrap.java windows-all
-sun/security/pkcs11/Cipher/TestRawRSACipher.java windows-all
-sun/security/pkcs11/Cipher/TestSymmCiphers.java windows-all
-sun/security/pkcs11/Cipher/TestSymmCiphersNoPad.java windows-all
-sun/security/pkcs11/KeyAgreement/TestDH.java windows-all
-sun/security/pkcs11/KeyAgreement/TestInterop.java windows-all
-sun/security/pkcs11/KeyAgreement/TestShort.java windows-all
-sun/security/pkcs11/KeyGenerator/DESParity.java windows-all
-sun/security/pkcs11/KeyGenerator/TestKeyGenerator.java windows-all
-sun/security/pkcs11/KeyPairGenerator/TestDH2048.java windows-all
-sun/security/pkcs11/KeyStore/SecretKeysBasic.sh windows-all
-sun/security/pkcs11/Mac/MacKAT.java windows-all
-sun/security/pkcs11/Mac/MacSameTest.java windows-all
-sun/security/pkcs11/Mac/ReinitMac.java windows-all
-sun/security/pkcs11/MessageDigest/ByteBuffers.java windows-all
-sun/security/pkcs11/MessageDigest/DigestKAT.java windows-all
-sun/security/pkcs11/MessageDigest/ReinitDigest.java windows-all
-sun/security/pkcs11/MessageDigest/TestCloning.java windows-all
-sun/security/pkcs11/Provider/ConfigQuotedString.sh windows-all
-sun/security/pkcs11/Provider/Login.sh windows-all
-sun/security/pkcs11/SampleTest.java windows-all
-sun/security/pkcs11/Secmod/AddPrivateKey.java windows-all
-sun/security/pkcs11/Secmod/AddTrustedCert.java windows-all
-sun/security/pkcs11/Secmod/Crypto.java windows-all
-sun/security/pkcs11/Secmod/GetPrivateKey.java windows-all
-sun/security/pkcs11/Secmod/JksSetPrivateKey.java windows-all
-sun/security/pkcs11/Secmod/LoadKeystore.java windows-all
-sun/security/pkcs11/SecureRandom/Basic.java windows-all
-sun/security/pkcs11/SecureRandom/TestDeserialization.java windows-all
-sun/security/pkcs11/Serialize/SerializeProvider.java windows-all
-sun/security/pkcs11/Signature/ByteBuffers.java windows-all
-sun/security/pkcs11/Signature/ReinitSignature.java windows-all
-sun/security/pkcs11/Signature/TestDSA.java windows-all
-sun/security/pkcs11/Signature/TestDSAKeyLength.java windows-all
-sun/security/pkcs11/Signature/TestRSAKeyLength.java windows-all
-sun/security/pkcs11/ec/ReadCertificates.java windows-all
-sun/security/pkcs11/ec/ReadPKCS12.java windows-all
-sun/security/pkcs11/ec/TestCurves.java windows-all
-sun/security/pkcs11/ec/TestECDH.java windows-all
-sun/security/pkcs11/ec/TestECDH2.java windows-all
-sun/security/pkcs11/ec/TestECDSA.java windows-all
-sun/security/pkcs11/ec/TestECDSA2.java windows-all
-sun/security/pkcs11/ec/TestECGenSpec.java windows-all
-sun/security/pkcs11/rsa/KeyWrap.java windows-all
-sun/security/pkcs11/rsa/TestCACerts.java windows-all
-sun/security/pkcs11/rsa/TestKeyFactory.java windows-all
-sun/security/pkcs11/rsa/TestKeyPairGenerator.java windows-all
-sun/security/pkcs11/rsa/TestSignatures.java windows-all
-sun/security/pkcs11/sslecc/ClientJSSEServerJSSE.java windows-all
-sun/security/pkcs11/tls/TestKeyMaterial.java windows-all
-sun/security/pkcs11/tls/TestLeadingZeroesP11.java windows-all
-sun/security/pkcs11/tls/TestMasterSecret.java windows-all
-sun/security/pkcs11/tls/TestPRF.java windows-all
-sun/security/pkcs11/tls/TestPremaster.java windows-all
+sun/security/pkcs11/Cipher/ReinitCipher.java 8077138,8023434 windows-all
+sun/security/pkcs11/Cipher/TestPKCS5PaddingError.java 8077138,8023434 windows-all
+sun/security/pkcs11/Cipher/TestRSACipher.java 8077138,8023434 windows-all
+sun/security/pkcs11/Cipher/TestRSACipherWrap.java 8077138,8023434 windows-all
+sun/security/pkcs11/Cipher/TestRawRSACipher.java 8077138,8023434 windows-all
+sun/security/pkcs11/Cipher/TestSymmCiphers.java 8077138,8023434 windows-all
+sun/security/pkcs11/Cipher/TestSymmCiphersNoPad.java 8077138,8023434 windows-all
+sun/security/pkcs11/KeyAgreement/TestDH.java 8077138,8023434 windows-all
+sun/security/pkcs11/KeyAgreement/TestInterop.java 8077138,8023434 windows-all
+sun/security/pkcs11/KeyAgreement/TestShort.java 8077138,8023434 windows-all
+sun/security/pkcs11/KeyGenerator/DESParity.java 8077138,8023434 windows-all
+sun/security/pkcs11/KeyGenerator/TestKeyGenerator.java 8077138,8023434 windows-all
+sun/security/pkcs11/KeyPairGenerator/TestDH2048.java 8077138,8023434 windows-all
+sun/security/pkcs11/KeyStore/SecretKeysBasic.sh 8077138,8023434 windows-all
+sun/security/pkcs11/Mac/MacKAT.java 8077138,8023434 windows-all
+sun/security/pkcs11/Mac/MacSameTest.java 8077138,8023434 windows-all
+sun/security/pkcs11/Mac/ReinitMac.java 8077138,8023434 windows-all
+sun/security/pkcs11/MessageDigest/ByteBuffers.java 8077138,8023434 windows-all
+sun/security/pkcs11/MessageDigest/DigestKAT.java 8077138,8023434 windows-all
+sun/security/pkcs11/MessageDigest/ReinitDigest.java 8077138,8023434 windows-all
+sun/security/pkcs11/MessageDigest/TestCloning.java 8077138,8023434 windows-all
+sun/security/pkcs11/Provider/ConfigQuotedString.sh 8077138,8023434 windows-all
+sun/security/pkcs11/Provider/Login.sh 8077138,8023434 windows-all
+sun/security/pkcs11/SampleTest.java 8077138,8023434 windows-all
+sun/security/pkcs11/Secmod/AddPrivateKey.java 8077138,8023434 windows-all
+sun/security/pkcs11/Secmod/AddTrustedCert.java 8077138,8023434 windows-all
+sun/security/pkcs11/Secmod/Crypto.java 8077138,8023434 windows-all
+sun/security/pkcs11/Secmod/GetPrivateKey.java 8077138,8023434 windows-all
+sun/security/pkcs11/Secmod/JksSetPrivateKey.java 8077138,8023434 windows-all
+sun/security/pkcs11/Secmod/LoadKeystore.java 8077138,8023434 windows-all
+sun/security/pkcs11/SecureRandom/Basic.java 8077138,8023434 windows-all
+sun/security/pkcs11/SecureRandom/TestDeserialization.java 8077138,8023434 windows-all
+sun/security/pkcs11/Serialize/SerializeProvider.java 8077138,8023434 windows-all
+sun/security/pkcs11/Signature/ByteBuffers.java 8077138,8023434 windows-all
+sun/security/pkcs11/Signature/ReinitSignature.java 8077138,8023434 windows-all
+sun/security/pkcs11/Signature/TestDSA.java 8077138,8023434 windows-all
+sun/security/pkcs11/Signature/TestDSAKeyLength.java 8077138,8023434 windows-all
+sun/security/pkcs11/Signature/TestRSAKeyLength.java 8077138,8023434 windows-all
+sun/security/pkcs11/ec/ReadCertificates.java 8077138,8023434 windows-all
+sun/security/pkcs11/ec/ReadPKCS12.java 8077138,8023434 windows-all
+sun/security/pkcs11/ec/TestCurves.java 8077138,8023434 windows-all
+sun/security/pkcs11/ec/TestECDH.java 8077138,8023434 windows-all
+sun/security/pkcs11/ec/TestECDH2.java 8077138,8023434 windows-all
+sun/security/pkcs11/ec/TestECDSA.java 8077138,8023434 windows-all
+sun/security/pkcs11/ec/TestECDSA2.java 8077138,8023434 windows-all
+sun/security/pkcs11/ec/TestECGenSpec.java 8077138,8023434 windows-all
+sun/security/pkcs11/rsa/KeyWrap.java 8077138,8023434 windows-all
+sun/security/pkcs11/rsa/TestCACerts.java 8077138,8023434 windows-all
+sun/security/pkcs11/rsa/TestKeyFactory.java 8077138,8023434 windows-all
+sun/security/pkcs11/rsa/TestKeyPairGenerator.java 8077138,8023434 windows-all
+sun/security/pkcs11/rsa/TestSignatures.java 8077138,8023434 windows-all
+sun/security/pkcs11/sslecc/ClientJSSEServerJSSE.java 8077138,8023434 windows-all
+sun/security/pkcs11/tls/TestKeyMaterial.java 8077138,8023434 windows-all
+sun/security/pkcs11/tls/TestLeadingZeroesP11.java 8077138,8023434 windows-all
+sun/security/pkcs11/tls/TestMasterSecret.java 8077138,8023434 windows-all
+sun/security/pkcs11/tls/TestPRF.java 8077138,8023434 windows-all
+sun/security/pkcs11/tls/TestPremaster.java 8077138,8023434 windows-all
-# 8051770
-sun/security/provider/SecureRandom/StrongSecureRandom.java macosx-10.10
+sun/security/provider/SecureRandom/StrongSecureRandom.java 8051770 macosx-10.10
-# 8074580
-sun/security/pkcs11/rsa/TestKeyPairGenerator.java generic-all
+sun/security/pkcs11/rsa/TestKeyPairGenerator.java 8074580 generic-all
-# 8038079
-sun/security/krb5/auto/HttpNegotiateServer.java generic-all
+sun/security/krb5/auto/HttpNegotiateServer.java 8038079 generic-all
-# 8130302
-sun/security/tools/keytool/autotest.sh generic-all
+sun/security/tools/keytool/autotest.sh 8130302 generic-all
############################################################################
# jdk_sound
-# 8059743
-javax/sound/midi/Gervill/SoftProvider/GetDevice.java generic-all
+javax/sound/midi/Gervill/SoftProvider/GetDevice.java 8059743 generic-all
############################################################################
# jdk_imageio
-javax/imageio/plugins/shared/CanWriteSequence.java generic-all
-javax/imageio/plugins/tiff/MultiPageTest/MultiPageTest.java generic-all
-javax/imageio/plugins/tiff/WriteToSequenceAfterAbort.java generic-all
+javax/imageio/plugins/shared/CanWriteSequence.java 8148454 generic-all
+javax/imageio/plugins/tiff/MultiPageTest/MultiPageTest.java 8148454 generic-all
+javax/imageio/plugins/tiff/WriteToSequenceAfterAbort.java 8148454 generic-all
############################################################################
@@ -348,56 +311,41 @@ javax/imageio/plugins/tiff/WriteToSequenceAfterAbort.java generic-all
# jdk_tools
-# Tests take too long, on sparcs see 7143279
-# also see 8059906
-tools/pack200/CommandLineTests.java generic-all
+tools/pack200/CommandLineTests.java 7143279,8059906 generic-all
-# 8059906 fails on solaris and macosx, 8151901
-tools/pack200/Pack200Test.java generic-all
+tools/pack200/Pack200Test.java 8059906,8151901 generic-all
-# 8152622
-tools/pack200/Pack200Props.java macosx-all
+tools/pack200/Pack200Props.java 8152622 macosx-all
-# 8068049
-tools/launcher/FXLauncherTest.java linux-all,macosx-all
+tools/launcher/FXLauncherTest.java 8068049 linux-all,macosx-all
############################################################################
# jdk_jdi
-# 8004127
-com/sun/jdi/RedefineImplementor.sh generic-all
+com/sun/jdi/RedefineImplementor.sh 8004127 generic-all
-# 8031555
-com/sun/jdi/JdbMethodExitTest.sh generic-all
+com/sun/jdi/JdbMethodExitTest.sh 8031555 generic-all
-# 8043571
-com/sun/jdi/RepStep.java generic-all
+com/sun/jdi/RepStep.java 8043571 generic-all
-# 8058616
-com/sun/jdi/RedefinePop.sh generic-all
+com/sun/jdi/RedefinePop.sh 8058616 generic-all
-# 8068645
-com/sun/jdi/CatchPatternTest.sh generic-all
+com/sun/jdi/CatchPatternTest.sh 8068645 generic-all
-# 8067354
-com/sun/jdi/GetLocalVariables4Test.sh windows-all
+com/sun/jdi/GetLocalVariables4Test.sh 8067354 windows-all
############################################################################
# jdk_util
-# 8062512
-java/util/spi/ResourceBundleControlProvider/UserDefaultControlTest.java generic-all
+java/util/spi/ResourceBundleControlProvider/UserDefaultControlTest.java 8062512 generic-all
-# 8130337
-java/util/stream/test/org/openjdk/tests/java/util/stream/IntPrimitiveOpsTests.java generic-all
+java/util/stream/test/org/openjdk/tests/java/util/stream/IntPrimitiveOpsTests.java 8130337 generic-all
-# 8080165, 8085982
-java/util/Arrays/ParallelPrefix.java generic-all
+java/util/Arrays/ParallelPrefix.java 8080165,8085982 generic-all
-# 8079538
-java/util/BitSet/BitSetStreamTest.java generic-all
+java/util/BitSet/BitSetStreamTest.java 8079538 generic-all
############################################################################
@@ -407,43 +355,33 @@ java/util/BitSet/BitSetStreamTest.java generic-all
# svc_tools
-# 8031482
-sun/tools/jcmd/TestJcmdSanity.java windows-all
+sun/tools/jcmd/TestJcmdSanity.java 8031482 windows-all
-# 8072131, 8132452
-sun/tools/jmap/heapconfig/JMapHeapConfigTest.java generic-all
+sun/tools/jmap/heapconfig/JMapHeapConfigTest.java 8072131,8132452 generic-all
-# 8046285
-sun/tools/jstatd/TestJstatdExternalRegistry.java generic-all
+sun/tools/jstatd/TestJstatdExternalRegistry.java 8046285 generic-all
-# 6456333
-sun/tools/jps/TestJpsJarRelative.java generic-all
+sun/tools/jps/TestJpsJarRelative.java 6456333 generic-all
-# 6734748
-sun/tools/jinfo/JInfoRunningProcessFlagTest.java generic-all
+sun/tools/jinfo/JInfoRunningProcessFlagTest.java 6734748 generic-all
-# 8057732
-sun/jvmstat/monitor/MonitoredVm/MonitorVmStartTerminate.java generic-all
+sun/jvmstat/monitor/MonitoredVm/MonitorVmStartTerminate.java 8057732 generic-all
-# 8059035
-sun/tools/jinfo/JInfoSanityTest.java generic-all
+sun/tools/jinfo/JInfoSanityTest.java 8059035 generic-all
-# 8151899
-demo/jvmti/compiledMethodLoad/CompiledMethodLoadTest.java generic-all
+demo/jvmti/compiledMethodLoad/CompiledMethodLoadTest.java 8151899 generic-all
############################################################################
# jdk_other
-# 8141370
-com/sun/jndi/ldap/DeadSSLLdapTimeoutTest.java linux-i586,macosx-all
+com/sun/jndi/ldap/DeadSSLLdapTimeoutTest.java 8141370 linux-i586,macosx-all
############################################################################
# core_tools
-# 8150975
-# tools/jimage/JImageTest.java linux-i586,windows-i586
+tools/jimage/JImageTest.java 8150975 linux-i586,windows-i586
############################################################################
diff --git a/jdk/test/TEST.groups b/jdk/test/TEST.groups
index 898ace52108..53deee5c732 100644
--- a/jdk/test/TEST.groups
+++ b/jdk/test/TEST.groups
@@ -60,7 +60,8 @@ tier3 = \
:jdk_rmi \
:jdk_beans \
:jdk_imageio \
- :jdk_sound
+ :jdk_sound \
+ :jdk_client_sanity
###############################################################################
#
@@ -351,6 +352,10 @@ jdk_desktop = \
:jdk_sound \
:jdk_imageio
+# SwingSet3 tests.
+jdk_client_sanity = \
+ sanity/client/SwingSet
+
###############################################################################
#
# Serviceability sanity groups
diff --git a/jdk/test/java/net/BindException/Test.java b/jdk/test/java/net/BindException/Test.java
index 03a7e83bdbb..ab13b083ffe 100644
--- a/jdk/test/java/net/BindException/Test.java
+++ b/jdk/test/java/net/BindException/Test.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2001, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2001, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -24,6 +24,7 @@
/*
* @test
* @bug 4417734
+ * @key intermittent
* @summary Test that we get a BindException in all expected combinations
*/
import java.net.*;
diff --git a/jdk/test/java/util/Calendar/Bug8152077.java b/jdk/test/java/util/Calendar/Bug8152077.java
new file mode 100644
index 00000000000..25afc5632eb
--- /dev/null
+++ b/jdk/test/java/util/Calendar/Bug8152077.java
@@ -0,0 +1,135 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/**
+ * @test
+ * @bug 8152077
+ * @summary Make sure that roll() with HOUR/HOUR_OF_DAY works around standard/daylight
+ * time transitions
+ */
+
+import java.util.Calendar;
+import java.util.GregorianCalendar;
+import java.util.TimeZone;
+import static java.util.Calendar.*;
+
+public class Bug8152077 {
+ private static final TimeZone LA = TimeZone.getTimeZone("America/Los_Angeles");
+ private static final TimeZone BR = TimeZone.getTimeZone("America/Sao_Paulo");
+
+ private static final int[] ALLDAY_HOURS = {
+ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11,
+ 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23
+ };
+ private static final int[] AM_HOURS = {
+ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11
+ };
+ private static final int[] PM_HOURS = { // in 24-hour clock
+ 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23
+ };
+
+ private static int errors;
+
+ public static void main(String[] args) {
+ TimeZone initialTz = TimeZone.getDefault();
+ try {
+ testRoll(LA, new int[] { 2016, MARCH, 13 },
+ new int[] { 0, 1, 3, 4, 5, 6, 7, 8, 9, 10, 11,
+ 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23 });
+ testRoll(LA, new int[] { 2016, MARCH, 13 },
+ new int[] { 0, 1, 3, 4, 5, 6, 7, 8, 9, 10, 11 });
+ testRoll(LA, new int[] { 2016, MARCH, 13 }, PM_HOURS);
+
+ testRoll(LA, new int[] { 2016, NOVEMBER, 6 }, ALLDAY_HOURS);
+ testRoll(LA, new int[] { 2016, NOVEMBER, 6 }, AM_HOURS);
+ testRoll(LA, new int[] { 2016, NOVEMBER, 6 }, PM_HOURS);
+
+ testRoll(BR, new int[] { 2016, FEBRUARY, 21 }, ALLDAY_HOURS);
+ testRoll(BR, new int[] { 2016, FEBRUARY, 21 }, AM_HOURS);
+ testRoll(BR, new int[] { 2016, FEBRUARY, 21 }, PM_HOURS);
+
+ testRoll(BR, new int[] { 2016, OCTOBER, 15 }, ALLDAY_HOURS);
+ testRoll(BR, new int[] { 2016, OCTOBER, 15 }, PM_HOURS);
+ testRoll(BR, new int[] { 2016, OCTOBER, 16 },
+ new int[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11,
+ 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23 });
+ testRoll(BR, new int[] { 2016, OCTOBER, 16 },
+ new int[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11 });
+ testRoll(BR, new int[] { 2016, OCTOBER, 16 }, PM_HOURS);
+ } finally {
+ TimeZone.setDefault(initialTz);
+ }
+ if (errors > 0) {
+ throw new RuntimeException("Test failed");
+ }
+ }
+
+ private static void testRoll(TimeZone tz, int[] params, int[] sequence) {
+ TimeZone.setDefault(tz);
+ for (int i = 0; i < sequence.length; i++) {
+ testRoll(+1, params, sequence, i);
+ testRoll(-1, params, sequence, i);
+ }
+ }
+
+ // amount must be 1 or -1.
+ private static void testRoll(int amount, int[] params, int[] sequence, int startIndex) {
+ int year = params[0];
+ int month = params[1];
+ int dayOfMonth = params[2];
+ int hourOfDay = sequence[startIndex];
+ Calendar cal = new GregorianCalendar(year, month, dayOfMonth,
+ hourOfDay, 0, 0);
+ int ampm = cal.get(AM_PM);
+
+ int length = sequence.length;
+ int count = length * 2;
+ int field = (length > 12) ? HOUR_OF_DAY : HOUR;
+
+ System.out.printf("roll(%s, %2d) starting from %s%n",
+ (field == HOUR) ? "HOUR" : "HOUR_OF_DAY", amount, cal.getTime());
+ for (int i = 0; i < count; i++) {
+ int index = (amount > 0) ? (startIndex + i + 1) % length
+ : Math.floorMod(startIndex - i - 1, length);
+ int expected = sequence[index];
+ if (field == HOUR) {
+ expected %= 12;
+ }
+ cal.roll(field, amount);
+ int value = cal.get(field);
+ if (value != expected) {
+ System.out.println("Unexpected field value: got=" + value
+ + ", expected=" + expected);
+ errors++;
+ }
+ if (cal.get(DAY_OF_MONTH) != dayOfMonth) {
+ System.out.println("DAY_OF_MONTH changed: " + dayOfMonth
+ + " to " + cal.get(DAY_OF_MONTH));
+ }
+ if (field == HOUR && cal.get(AM_PM) != ampm) {
+ System.out.println("AM_PM changed: " + ampm + " to " + cal.get(AM_PM));
+ errors++;
+ }
+ }
+ }
+}
diff --git a/jdk/test/java/util/List/NestedSubList.java b/jdk/test/java/util/List/NestedSubList.java
new file mode 100644
index 00000000000..18eb64cf375
--- /dev/null
+++ b/jdk/test/java/util/List/NestedSubList.java
@@ -0,0 +1,97 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 8079136
+ * @run testng NestedSubList
+ * @summary Accessing a nested sublist leads to StackOverflowError
+ */
+
+import java.util.AbstractList;
+import java.util.Arrays;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Vector;
+
+import org.testng.annotations.Test;
+import org.testng.annotations.DataProvider;
+import static org.testng.Assert.fail;
+
+public class NestedSubList {
+
+ static final int NEST_LIMIT = 65536;
+
+ @Test(dataProvider="lists")
+ public void testAccessToSublists(List list, boolean modifiable) {
+ Class> cls = list.getClass();
+ for (int i = 0; i < NEST_LIMIT; ++i) {
+ list = list.subList(0, 1);
+ }
+
+ try {
+ list.get(0);
+ if (modifiable) {
+ list.remove(0);
+ list.add(0, 42);
+ }
+ } catch (StackOverflowError e) {
+ fail("failed for " + cls);
+ }
+ }
+
+ @DataProvider
+ public static Object[][] lists() {
+ final boolean MODIFIABLE = true;
+ final boolean NON_MODIFIABLE = false;
+ List c = Arrays.asList(42);
+
+ return new Object[][] {
+ {c, NON_MODIFIABLE},
+ {new ArrayList<>(c), MODIFIABLE},
+ {new LinkedList<>(c), MODIFIABLE},
+ {new MyList(), NON_MODIFIABLE},
+ {new Vector<>(c), MODIFIABLE},
+ {Collections.singletonList(42), NON_MODIFIABLE},
+ {Collections.checkedList(c, Integer.class), NON_MODIFIABLE},
+ {Collections.checkedList(new ArrayList<>(c), Integer.class), MODIFIABLE},
+ {Collections.checkedList(new LinkedList<>(c), Integer.class), MODIFIABLE},
+ {Collections.checkedList(new Vector<>(c), Integer.class), MODIFIABLE},
+ {Collections.synchronizedList(c), NON_MODIFIABLE},
+ {Collections.synchronizedList(new ArrayList<>(c)), MODIFIABLE},
+ {Collections.synchronizedList(new LinkedList<>(c)), MODIFIABLE},
+ {Collections.synchronizedList(new Vector<>(c)), MODIFIABLE},
+ {Collections.unmodifiableList(c), NON_MODIFIABLE},
+ {Collections.unmodifiableList(new ArrayList<>(c)), NON_MODIFIABLE},
+ {Collections.unmodifiableList(new LinkedList<>(c)), NON_MODIFIABLE},
+ {Collections.unmodifiableList(new Vector<>(c)), NON_MODIFIABLE},
+ };
+ }
+
+ static class MyList extends AbstractList {
+ public Integer get(int index) { return 42; }
+ public int size() { return 1; }
+ }
+}
diff --git a/jdk/test/java/util/List/SubList.java b/jdk/test/java/util/List/SubList.java
new file mode 100644
index 00000000000..8d82dbfeaaa
--- /dev/null
+++ b/jdk/test/java/util/List/SubList.java
@@ -0,0 +1,676 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 8079136
+ * @library /lib/testlibrary
+ * @build jdk.testlibrary.*
+ * @run testng SubList
+ * @summary Basic functionality of sublists
+ * @key randomness
+ */
+
+import java.util.AbstractList;
+import java.util.Arrays;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.ConcurrentModificationException;
+import java.util.Iterator;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.ListIterator;
+import java.util.Random;
+import java.util.Vector;
+
+import org.testng.annotations.Test;
+import org.testng.annotations.DataProvider;
+
+import jdk.testlibrary.RandomFactory;
+
+
+public class SubList extends org.testng.Assert {
+
+ final Random rnd = RandomFactory.getRandom();
+
+ @Test(dataProvider = "modifiable")
+ public void testAdd(List list, int from, int to) {
+ List subList = list.subList(from, to);
+ Integer e = rnd.nextInt();
+ subList.add(e);
+ assertEquals(list.get(to), e);
+ assertEquals(subList.size(), to - from + 1);
+ }
+
+ @Test(dataProvider = "modifiable",
+ expectedExceptions = ConcurrentModificationException.class)
+ public void testModAdd(List list, int from, int to) {
+ List subList = list.subList(from, to);
+ list.add(42);
+ subList.add(42);
+ }
+
+ @Test(dataProvider = "unresizable",
+ expectedExceptions = UnsupportedOperationException.class)
+ public void testUnmodAdd(List list, int from, int to) {
+ List subList = list.subList(from, to);
+ subList.add(42);
+ }
+
+ @Test(dataProvider = "modifiable")
+ public void testAddAtPos(List list, int from, int to) {
+ List subList = list.subList(from, to);
+ int i = rnd.nextInt(1 + to - from);
+ Integer e = rnd.nextInt();
+ subList.add(i, e);
+ assertEquals(list.get(from + i), e);
+ assertEquals(subList.size(), to - from + 1);
+ }
+
+ @Test(dataProvider = "modifiable",
+ expectedExceptions = ConcurrentModificationException.class)
+ public void testModAddAtPos(List list, int from, int to) {
+ List subList = list.subList(from, to);
+ list.add(42);
+ int i = rnd.nextInt(1 + to - from);
+ subList.add(i, 42);
+ }
+
+ @Test(dataProvider = "unresizable",
+ expectedExceptions = UnsupportedOperationException.class)
+ public void testUnmodAddAtPos(List list, int from, int to) {
+ List subList = list.subList(from, to);
+ int i = rnd.nextInt(1 + to - from);
+ subList.add(i, 42);
+ }
+
+ @Test(dataProvider = "modifiable")
+ public void testClear(List list, int from, int to) {
+ List subList = list.subList(from, to);
+ subList.clear();
+ assertTrue(subList.isEmpty());
+ assertEquals(subList.size(), 0);
+ }
+
+ @Test(dataProvider = "modifiable",
+ expectedExceptions = ConcurrentModificationException.class)
+ public void testModClear(List list, int from, int to) {
+ List subList = list.subList(from, to);
+ list.add(42);
+ subList.clear();
+ }
+
+ @Test(dataProvider = "unresizable",
+ expectedExceptions = UnsupportedOperationException.class)
+ public void testUnmodClear(List list, int from, int to) {
+ List subList = list.subList(from, to);
+ subList.clear();
+ }
+
+ @Test(dataProvider = "all")
+ public void testEquals(List list, int from, int to) {
+ List subList1 = list.subList(from, to);
+ List subList2 = list.subList(from, to);
+ assertTrue(subList1.equals(subList2));
+ assertEquals(subList1.hashCode(), subList2.hashCode());
+ for (int i = 0; i != 16; ++i) {
+ int from3 = rnd.nextInt(1 + list.size());
+ int to3 = from3 + rnd.nextInt(1 + list.size() - from3);
+ boolean equal = (to - from) == (to3 - from3);
+ for (int j = 0; j < to - from && j < to3 - from3; ++j)
+ equal &= list.get(from + j) == list.get(from3 + j);
+ List subList3 = list.subList(from3, to3);
+ assertEquals(subList1.equals(subList3), equal);
+ }
+ }
+
+// @Test(dataProvider = "modifiable",
+// expectedExceptions = ConcurrentModificationException.class)
+// public void testModEquals(List list, int from, int to) {
+// List subList = list.subList(from, to);
+// list.add(42);
+// subList.equals(subList);
+// }
+
+ @Test(dataProvider = "modifiable",
+ expectedExceptions = ConcurrentModificationException.class)
+ public void testModHashCode(List list, int from, int to) {
+ List subList = list.subList(from, to);
+ list.add(42);
+ subList.hashCode();
+ }
+
+ @Test(dataProvider = "all")
+ public void testGet(List list, int from, int to) {
+ List subList = list.subList(from, to);
+ for (int i = 0; i < to - from; ++i)
+ assertEquals(list.get(from + i), subList.get(i));
+ }
+
+ @Test(dataProvider = "modifiable",
+ expectedExceptions = ConcurrentModificationException.class)
+ public void testModGet(List list, int from, int to) {
+ List subList = list.subList(from, to);
+ list.add(42);
+ subList.get(from);
+ }
+
+ @Test(dataProvider = "all")
+ public void testIndexOf(List list, int from, int to) {
+ List subList = list.subList(from, to);
+ if (from < to) {
+ Integer e = list.get(from);
+ int j = subList.indexOf(e);
+ assertTrue(j == 0);
+ }
+ for (int i = 0; i < list.size(); ++i) {
+ Integer e = list.get(i);
+ int j = subList.indexOf(e);
+ if (i < from || i >= to) {
+ assertTrue(j == -1 || subList.get(j) == e);
+ } else {
+ assertTrue(j >= 0);
+ assertTrue(j <= i - from);
+ assertEquals(subList.get(j), e);
+ }
+ }
+ for (int i = 0; i < 16; ++i) {
+ Integer r = rnd.nextInt();
+ if (list.contains(r)) continue;
+ int j = subList.indexOf(r);
+ assertTrue(j == -1);
+ }
+ }
+
+ @Test(dataProvider = "modifiable",
+ expectedExceptions = ConcurrentModificationException.class)
+ public void testModIndexOf(List list, int from, int to) {
+ List subList = list.subList(from, to);
+ list.add(42);
+ subList.indexOf(from);
+ }
+
+ @Test(dataProvider = "all")
+ public void testIterator(List list, int from, int to) {
+ List subList = list.subList(from, to);
+ Iterator it = subList.iterator();
+ for (int i = from; i < to; ++i) {
+ assertTrue(it.hasNext());
+ assertEquals(list.get(i), it.next());
+ }
+ assertFalse(it.hasNext());
+ }
+
+ @Test(dataProvider = "modifiable",
+ expectedExceptions = ConcurrentModificationException.class)
+ public void testModIteratorNext(List list, int from, int to) {
+ List subList = list.subList(from, to);
+ Iterator it = subList.iterator();
+ list.add(42);
+ it.next();
+ }
+
+ @Test(dataProvider = "modifiable")
+ public void testIteratorRemove(List list, int from, int to) {
+ List subList = list.subList(from, to);
+ Iterator it = subList.iterator();
+ for (int i = from; i < to; ++i) {
+ assertTrue(it.hasNext());
+ assertEquals(list.get(from), it.next());
+ it.remove();
+ }
+ assertFalse(it.hasNext());
+ assertTrue(subList.isEmpty());
+ }
+
+ @Test(dataProvider = "modifiable",
+ expectedExceptions = ConcurrentModificationException.class)
+ public void testModIteratorRemove(List list, int from, int to) {
+ List subList = list.subList(from, to);
+ Iterator it = subList.iterator();
+ it.next();
+ list.add(42);
+ it.remove();
+ }
+
+ @Test(dataProvider = "unresizable",
+ expectedExceptions = UnsupportedOperationException.class)
+ public void testUnmodIteratorRemove(List list, int from, int to) {
+ List subList = list.subList(from, to);
+ Iterator it = subList.iterator();
+ it.next();
+ it.remove();
+ }
+
+ @Test(dataProvider = "all")
+ public void testIteratorForEachRemaining(List list, int from, int to) {
+ List subList = list.subList(from, to);
+ for (int k = 0; k < 16; ++k) {
+ int r = from + rnd.nextInt(1 + to - from);
+ Iterator it = subList.iterator();
+ for (int i = from; i < to; ++i) {
+ assertTrue(it.hasNext());
+ if (i == r) {
+ Iterator jt = list.listIterator(r);
+ it.forEachRemaining(x ->
+ assertTrue(jt.hasNext() && x == jt.next()));
+ break;
+ }
+ assertEquals(list.get(i), it.next());
+ }
+ it.forEachRemaining(x -> fail());
+ }
+ }
+
+ @Test(dataProvider = "all")
+ public void testLastIndexOf(List list, int from, int to) {
+ List subList = list.subList(from, to);
+ if (from < to) {
+ Integer e = list.get(to - 1);
+ int j = subList.lastIndexOf(e);
+ assertTrue(j == to - from - 1);
+ }
+ for (int i = 0; i < list.size(); ++i) {
+ Integer e = list.get(i);
+ int j = subList.lastIndexOf(e);
+ if (i < from || i >= to) {
+ assertTrue(j == -1 || subList.get(j) == e);
+ } else {
+ assertTrue(j >= 0 && j >= i - from);
+ assertEquals(subList.get(j), e);
+ }
+ }
+ for (int i = 0; i < 16; ++i) {
+ Integer r = rnd.nextInt();
+ if (list.contains(r)) continue;
+ int j = subList.lastIndexOf(r);
+ assertTrue(j == -1);
+ }
+ }
+
+ @Test(dataProvider = "modifiable",
+ expectedExceptions = ConcurrentModificationException.class)
+ public void testModLastIndexOf(List list, int from, int to) {
+ List subList = list.subList(from, to);
+ list.add(42);
+ subList.lastIndexOf(42);
+ }
+
+ @Test(dataProvider = "unresizable")
+ public void testListIterator(List list, int from, int to) {
+ List subList = list.subList(from, to);
+ ListIterator it = subList.listIterator();
+ for (int i = from; i < to; ++i) {
+ assertTrue(it.hasNext());
+ assertTrue(it.nextIndex() == i - from);
+ assertEquals(list.get(i), it.next());
+ }
+ assertFalse(it.hasNext());
+ }
+
+ @Test(dataProvider = "modifiable",
+ expectedExceptions = ConcurrentModificationException.class)
+ public void testModListIteratorNext(List list, int from, int to) {
+ List subList = list.subList(from, to);
+ ListIterator it = subList.listIterator();
+ list.add(42);
+ it.next();
+ }
+
+ @Test(dataProvider = "modifiable")
+ public void testListIteratorSet(List list, int from, int to) {
+ List subList = list.subList(from, to);
+ ListIterator it = subList.listIterator();
+ for (int i = from; i < to; ++i) {
+ assertTrue(it.hasNext());
+ assertTrue(it.nextIndex() == i - from);
+ assertEquals(list.get(i), it.next());
+ Integer e = rnd.nextInt();
+ it.set(e);
+ assertEquals(list.get(i), e);
+ }
+ assertFalse(it.hasNext());
+ }
+
+ @Test(dataProvider = "modifiable",
+ expectedExceptions = ConcurrentModificationException.class)
+ public void testModListIteratorSet(List list, int from, int to) {
+ List subList = list.subList(from, to);
+ ListIterator it = subList.listIterator();
+ it.next();
+ list.add(42);
+ it.set(42);
+ }
+
+ @Test(dataProvider = "unsettable",
+ expectedExceptions = UnsupportedOperationException.class)
+ public void testUnmodListIteratorSet(List list, int from, int to) {
+ List