Merge
authorjwilhelm
Tue, 18 Apr 2017 22:25:33 +0200
changeset 46388 d7a164ad6b7f
parent 46387 c46632622b17 (current diff)
parent 44622 f113ce12fe24 (diff)
child 46390 cb3afb654b77
Merge
hotspot/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.core.common/src/org/graalvm/compiler/core/common/util/ModuleAPI.java
hotspot/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.hotspot/src/org/graalvm/compiler/hotspot/phases/aot/EliminateRedundantInitializationPhase.java
hotspot/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.test/src/org/graalvm/compiler/test/JLRModule.java
hotspot/src/share/vm/classfile/classFileParser.cpp
hotspot/src/share/vm/classfile/javaClasses.cpp
hotspot/src/share/vm/classfile/javaClasses.hpp
hotspot/src/share/vm/classfile/moduleEntry.cpp
hotspot/src/share/vm/classfile/moduleEntry.hpp
hotspot/src/share/vm/classfile/modules.cpp
hotspot/src/share/vm/classfile/modules.hpp
hotspot/src/share/vm/classfile/systemDictionary.hpp
hotspot/src/share/vm/oops/constantPool.hpp
hotspot/src/share/vm/oops/cpCache.hpp
hotspot/src/share/vm/oops/klass.cpp
hotspot/src/share/vm/oops/method.hpp
hotspot/src/share/vm/prims/jvmtiEnv.cpp
hotspot/src/share/vm/runtime/globals.hpp
hotspot/src/share/vm/runtime/reflection.cpp
hotspot/src/share/vm/runtime/thread.cpp
hotspot/test/runtime/modules/JVMDefineModule.java
hotspot/test/runtime/modules/ModuleHelper.java
hotspot/test/runtime/modules/java.base/java/lang/reflect/ModuleHelper.java
jdk/src/java.base/share/classes/java/lang/reflect/Layer.java
jdk/src/java.base/share/classes/java/lang/reflect/LayerInstantiationException.java
jdk/src/java.base/share/classes/java/lang/reflect/Module.java
jdk/src/java.base/share/classes/java/lang/reflect/WeakPairMap.java
jdk/src/java.base/share/classes/jdk/internal/misc/JavaLangReflectModuleAccess.java
jdk/test/java/lang/reflect/Layer/BasicLayerTest.java
jdk/test/java/lang/reflect/Layer/LayerAndLoadersTest.java
jdk/test/java/lang/reflect/Layer/LayerControllerTest.java
jdk/test/java/lang/reflect/Layer/layertest/Test.java
jdk/test/java/lang/reflect/Layer/src/m1/module-info.java
jdk/test/java/lang/reflect/Layer/src/m1/p/Main.java
jdk/test/java/lang/reflect/Layer/src/m1/p/Service.java
jdk/test/java/lang/reflect/Layer/src/m2/module-info.java
jdk/test/java/lang/reflect/Layer/src/m2/q/Hello.java
jdk/test/java/lang/reflect/Layer/src/m3/module-info.java
jdk/test/java/lang/reflect/Layer/src/m3/w/Hello.java
jdk/test/java/lang/reflect/Layer/src/m4/impl/ServiceImpl.java
jdk/test/java/lang/reflect/Layer/src/m4/module-info.java
jdk/test/java/lang/reflect/Module/AddExportsTest.java
jdk/test/java/lang/reflect/Module/AnnotationsTest.java
jdk/test/java/lang/reflect/Module/BasicModuleTest.java
jdk/test/java/lang/reflect/Module/WithSecurityManager.java
jdk/test/java/lang/reflect/Module/access/AccessTest.java
jdk/test/java/lang/reflect/Module/access/src/target/module-info.java
jdk/test/java/lang/reflect/Module/access/src/target/p1/Helper.java
jdk/test/java/lang/reflect/Module/access/src/target/p1/Public.java
jdk/test/java/lang/reflect/Module/access/src/target/p2/NonPublic.java
jdk/test/java/lang/reflect/Module/access/src/target/q1/Public.java
jdk/test/java/lang/reflect/Module/access/src/target/q2/NonPublic.java
jdk/test/java/lang/reflect/Module/access/src/test/module-info.java
jdk/test/java/lang/reflect/Module/access/src/test/test/Main.java
jdk/test/java/lang/reflect/Module/addXXX/Driver.java
jdk/test/java/lang/reflect/Module/addXXX/m1/module-info.java
jdk/test/java/lang/reflect/Module/addXXX/m1/p1/C.java
jdk/test/java/lang/reflect/Module/addXXX/m2/module-info.java
jdk/test/java/lang/reflect/Module/addXXX/m2/p2/C.java
jdk/test/java/lang/reflect/Module/addXXX/m2/p2/internal/C.java
jdk/test/java/lang/reflect/Module/addXXX/m3/module-info.java
jdk/test/java/lang/reflect/Module/addXXX/m3/p3/C.java
jdk/test/java/lang/reflect/Module/addXXX/m4/module-info.java
jdk/test/java/lang/reflect/Module/addXXX/m4/p4/C.java
jdk/test/java/lang/reflect/Module/addXXX/test/module-info.java
jdk/test/java/lang/reflect/Module/addXXX/test/test/C.java
jdk/test/java/lang/reflect/Module/addXXX/test/test/Main.java
jdk/test/java/lang/reflect/Module/addXXX/test/test/Service.java
jdk/test/java/lang/reflect/Module/allow.policy
jdk/test/java/lang/reflect/Module/annotation/Basic.java
jdk/test/java/lang/reflect/Module/annotation/src/m/module-info.java
jdk/test/java/lang/reflect/Module/annotation/src/m/p/annotation/Bar.java
jdk/test/java/lang/reflect/Module/annotation/src/m/p/annotation/Baz.java
jdk/test/java/lang/reflect/Module/annotation/src/m/p/annotation/Foo.java
jdk/test/java/lang/reflect/WeakPairMap/Driver.java
jdk/test/java/lang/reflect/WeakPairMap/java.base/java/lang/reflect/WeakPairMapTest.java
--- a/.hgtags	Tue Apr 18 13:19:42 2017 -0400
+++ b/.hgtags	Tue Apr 18 22:25:33 2017 +0200
@@ -1,3 +1,4 @@
+3965b747cfe1e6cbd66b8739da5a1ea6ec6985e9 jdk-9+165
 d16aebbb56d37f12e0c0b0a4fb427db65e1fb1a8 jdk-9+162
 18c41483a082e097ac2f5f983c1226ed94aa4215 jdk-9+163
 32db52c675e7d5bc413605d2e89b68b608b19be0 jdk-9+164
@@ -411,3 +412,4 @@
 74116beae88a8f17a80301aa6c83865c82f10ece jdk-10+1
 4a79ad46e578112fce68f1af9dd931025cc235cb jdk-10+2
 d1cab6c7e608479be4ebfad48a25b0ed48600f62 jdk-10+3
+02253db2ace1422f576f58502fc7831ead77424b jdk-10+4
--- a/.hgtags-top-repo	Tue Apr 18 13:19:42 2017 -0400
+++ b/.hgtags-top-repo	Tue Apr 18 22:25:33 2017 +0200
@@ -408,3 +408,4 @@
 21b063d75b3edbffb9bebc8872d990920c4ae1e5 jdk-9+162
 c38c6b270ccc8e2b86d1631bcf42248241b54d2c jdk-9+163
 7810f75d016a52e32295c4233009de5ca90e31af jdk-9+164
+aff4f339acd40942d3dab499846b52acd87b3af1 jdk-9+165
--- a/common/conf/jib-profiles.js	Tue Apr 18 13:19:42 2017 -0400
+++ b/common/conf/jib-profiles.js	Tue Apr 18 22:25:33 2017 +0200
@@ -882,7 +882,7 @@
         jtreg: {
             server: "javare",
             revision: "4.2",
-            build_number: "b05",
+            build_number: "b07",
             checksum_file: "MD5_VALUES",
             file: "jtreg_bin-4.2.zip",
             environment_name: "JT_HOME",
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/common/doc/testing.html	Tue Apr 18 22:25:33 2017 +0200
@@ -0,0 +1,112 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml">
+<head>
+  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+  <meta http-equiv="Content-Style-Type" content="text/css" />
+  <meta name="generator" content="pandoc" />
+  <title>Testing OpenJDK</title>
+  <style type="text/css">code{white-space: pre;}</style>
+  <link rel="stylesheet" href="http://openjdk.java.net/page.css" type="text/css" />
+  <style type="text/css">pre, code, tt { color: #1d6ae5; }</style>
+  <style type="text/css">pre { font-size: 10pt; }</style>
+</head>
+<body>
+<div id="header">
+<h1 class="title">Testing OpenJDK</h1>
+</div>
+<div id="TOC">
+<ul>
+<li><a href="#using-the-run-test-framework">Using the run-test framework</a></li>
+<li><a href="#test-selection">Test selection</a><ul>
+<li><a href="#jtreg">JTreg</a></li>
+<li><a href="#gtest">Gtest</a></li>
+</ul></li>
+<li><a href="#test-results-and-summary">Test results and summary</a></li>
+<li><a href="#test-suite-control">Test suite control</a><ul>
+<li><a href="#jtreg-keywords">JTreg keywords</a></li>
+<li><a href="#gtest-keywords">Gtest keywords</a></li>
+</ul></li>
+</ul>
+</div>
+<h2 id="using-the-run-test-framework">Using the run-test framework</h2>
+<p>This new way of running tests is developer-centric. It assumes that you have built a jdk locally and want to test it. Running common test targets is simple, and more complex ad-hoc combination of tests is possible. The user interface is forgiving, and clearly report errors it cannot resolve.</p>
+<p>Some example command-lines:</p>
+<pre><code>$ make run-test-tier1
+$ make run-test-jdk_lang JTREG=&quot;JOBS=8&quot;
+$ make run-test TEST=jdk_lang
+$ make run-test-only TEST=&quot;gtest:LogTagSet gtest:LogTagSetDescriptions&quot; GTEST=&quot;REPEAT=-1&quot;
+$ make run-test TEST=&quot;hotspot/test:hotspot_gc&quot; JTREG=&quot;JOBS=1;TIMEOUT=8;VM_OTIONS=-XshowSettings -Xlog:gc+ref=debug&quot;
+$ make run-test TEST=&quot;jtreg:hotspot/test:hotspot_gc hotspot/test/native_sanity/JniVersion.java&quot;</code></pre>
+<h2 id="test-selection">Test selection</h2>
+<p>All functionality is available using the run-test make target. In this use case, the test or tests to be executed is controlled using the <code>TEST</code> variable. To speed up subsequent test runs with no source code changes, run-test-only can be used instead, which do not depend on the source and test image build.</p>
+<p>For some common top-level tests, direct make targets have been generated. This includes all JTreg test groups, the hotspot gtest, and custom tests (if present). This means that <code>make run-test-tier1</code> is equivalent to <code>make run-test TEST=&quot;tier1&quot;</code>, but the latter is more tab-completion friendly. For more complex test runs, the <code>run-test TEST=&quot;x&quot;</code> solution needs to be used.</p>
+<p>The test specifications given in <code>TEST</code> is parsed into fully qualified test descriptors, which clearly and unambigously show which tests will be run. As an example, <code>:tier1</code> will expand to <code>jtreg:jdk/test:tier1 jtreg:langtools/test:tier1 jtreg:nashorn/test:tier1 jtreg:jaxp/test:tier1</code>. You can always submit a list of fully qualified test descriptors in the <code>TEST</code> variable if you want to shortcut the parser.</p>
+<h3 id="jtreg">JTreg</h3>
+<p>JTreg test groups can be specified either without a test root, e.g. <code>:tier1</code> (or <code>tier1</code>, the initial colon is optional), or with, e.g. <code>hotspot/test:tier1</code>, <code>jdk/test:jdk_util</code>.</p>
+<p>When specified without a test root, all matching groups from all tests roots will be added. Otherwise, only the group from the specified test root will be added.</p>
+<p>Individual JTreg tests or directories containing JTreg tests can also be specified, like <code>hotspot/test/native_sanity/JniVersion.java</code> or <code>hotspot/test/native_sanity</code>. You can also specify an absolute path, to point to a JTreg test outside the source tree.</p>
+<p>As long as the test groups or test paths can be uniquely resolved, you do not need to enter the <code>jtreg:</code> prefix. If this is not possible, or if you want to use a fully qualified test descriptor, add <code>jtreg:</code>, e.g. <code>jtreg:hotspot/test/native_sanity</code>.</p>
+<h3 id="gtest">Gtest</h3>
+<p>Since the Hotspot Gtest suite is so quick, the default is to run all tests. This is specified by just <code>gtest</code>, or as a fully qualified test descriptor <code>gtest:all</code>.</p>
+<p>If you want, you can single out an individual test or a group of tests, for instance <code>gtest:LogDecorations</code> or <code>gtest:LogDecorations.level_test_vm</code>. This can be particularly useful if you want to run a shaky test repeatedly.</p>
+<h2 id="test-results-and-summary">Test results and summary</h2>
+<p>At the end of the test run, a summary of all tests run will be presented. This will have a consistent look, regardless of what test suites were used. This is a sample summary:</p>
+<pre><code>==============================
+Test summary
+==============================
+   TEST                                          TOTAL  PASS  FAIL ERROR
+&gt;&gt; jtreg:jdk/test:tier1                           1867  1865     2     0 &lt;&lt;
+   jtreg:langtools/test:tier1                     4711  4711     0     0
+   jtreg:nashorn/test:tier1                        133   133     0     0
+==============================
+TEST FAILURE</code></pre>
+<p>Tests where the number of TOTAL tests does not equal the number of PASSed tests will be considered a test failure. These are marked with the <code>&gt;&gt; ... &lt;&lt;</code> marker for easy identification.</p>
+<p>The classification of non-passed tests differs a bit between test suites. In the summary, ERROR is used as a catch-all for tests that neither passed nor are classified as failed by the framework. This might indicate test framework error, timeout or other problems.</p>
+<p>In case of test failures, <code>make run-test</code> will exit with a non-zero exit value.</p>
+<p>All tests have their result stored in <code>build/$BUILD/test-result/$TEST_ID</code>, where TEST_ID is a path-safe conversion from the fully qualified test descriptor, e.g. for <code>jtreg:jdk/test:tier1</code> the TEST_ID is <code>jtreg_jdk_test_tier1</code>. This path is also printed in the log at the end of the test run.</p>
+<p>Additional work data is stored in <code>build/$BUILD/test-support/$TEST_ID</code>. For some frameworks, this directory might contain information that is useful in determining the cause of a failed test.</p>
+<h2 id="test-suite-control">Test suite control</h2>
+<p>It is possible to control various aspects of the test suites using make control variables.</p>
+<p>These variables use a keyword=value approach to allow multiple values to be set. So, for instance, <code>JTREG=&quot;JOBS=1;TIMEOUT=8&quot;</code> will set the JTreg concurrency level to 1 and the timeout factor to 8. This is equivalent to setting <code>JTREG_JOBS=1 JTREG_TIMEOUT=8</code>, but using the keyword format means that the <code>JTREG</code> variable is parsed and verified for correctness, so <code>JTREG=&quot;TMIEOUT=8&quot;</code> would give an error, while <code>JTREG_TMIEOUT=8</code> would just pass unnoticed.</p>
+<p>To separate multiple keyword=value pairs, use <code>;</code> (semicolon). Since the shell normally eats <code>;</code>, the recommended usage is to write the assignment inside qoutes, e.g. <code>JTREG=&quot;...;...&quot;</code>. This will also make sure spaces are preserved, as in <code>JTREG=&quot;VM_OTIONS=-XshowSettings -Xlog:gc+ref=debug&quot;</code>.</p>
+<p>(Other ways are possible, e.g. using backslash: <code>JTREG=JOBS=1\;TIMEOUT=8</code>. Also, as a special technique, the string <code>%20</code> will be replaced with space for certain options, e.g. <code>JTREG=VM_OTIONS=-XshowSettings%20-Xlog:gc+ref=debug</code>. This can be useful if you have layers of scripts and have trouble getting proper quoting of command line arguments through.)</p>
+<p>As far as possible, the names of the keywords have been standardized between test suites.</p>
+<h3 id="jtreg-keywords">JTreg keywords</h3>
+<h4 id="jobs">JOBS</h4>
+<p>The test concurrency (<code>-concurrency</code>).</p>
+<p>Defaults to TEST_JOBS (if set by <code>--with-test-jobs=</code>), otherwise it defaults to JOBS, except for Hotspot, where the default is <em>number of CPU cores/2</em>, but never more than 12.</p>
+<h4 id="timeout">TIMEOUT</h4>
+<p>The timeout factor (<code>-timeoutFactor</code>).</p>
+<p>Defaults to 4.</p>
+<h4 id="test_mode">TEST_MODE</h4>
+<p>The test mode (<code>-agentvm</code>, <code>-samevm</code> or <code>-othervm</code>).</p>
+<p>Defaults to <code>-agentvm</code>.</p>
+<h4 id="assert">ASSERT</h4>
+<p>Enable asserts (<code>-ea -esa</code>, or none).</p>
+<p>Set to <code>true</code> or <code>false</code>. If true, adds <code>-ea -esa</code>. Defaults to true, except for hotspot.</p>
+<h4 id="verbose">VERBOSE</h4>
+<p>The verbosity level (<code>-verbose</code>).</p>
+<p>Defaults to <code>fail,error,summary</code>.</p>
+<h4 id="retain">RETAIN</h4>
+<p>What test data to retain (<code>-retain</code>).</p>
+<p>Defaults to <code>fail,error</code>.</p>
+<h4 id="max_mem">MAX_MEM</h4>
+<p>Limit memory consumption (<code>-Xmx</code> and <code>-vmoption:-Xmx</code>, or none).</p>
+<p>Limit memory consumption for JTreg test framework and VM under test. Set to 0 to disable the limits.</p>
+<p>Defaults to 512m, except for hotspot, where it defaults to 0 (no limit).</p>
+<h4 id="options">OPTIONS</h4>
+<p>Additional options to the JTreg test framework.</p>
+<p>Use <code>JTREG=&quot;OPTIONS=--help all&quot;</code> to see all available JTreg options.</p>
+<h4 id="java_options">JAVA_OPTIONS</h4>
+<p>Additional Java options to JTreg (<code>-javaoption</code>).</p>
+<h4 id="vm_options">VM_OPTIONS</h4>
+<p>Additional VM options to JTreg (<code>-vmoption</code>).</p>
+<h3 id="gtest-keywords">Gtest keywords</h3>
+<h4 id="repeat">REPEAT</h4>
+<p>The number of times to repeat the tests (<code>--gtest_repeat</code>).</p>
+<p>Default is 1. Set to -1 to repeat indefinitely. This can be especially useful combined with <code>OPTIONS=--gtest_break_on_failure</code> to reproduce an intermittent problem.</p>
+<h4 id="options-1">OPTIONS</h4>
+<p>Additional options to the Gtest test framework.</p>
+<p>Use <code>GTEST=&quot;OPTIONS=--help&quot;</code> to see all available Gtest options.</p>
+</body>
+</html>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/common/doc/testing.md	Tue Apr 18 22:25:33 2017 +0200
@@ -0,0 +1,207 @@
+% Testing OpenJDK
+
+## Using the run-test framework
+
+This new way of running tests is developer-centric. It assumes that you have
+built a jdk locally and want to test it. Running common test targets is simple,
+and more complex ad-hoc combination of tests is possible. The user interface is
+forgiving, and clearly report errors it cannot resolve.
+
+Some example command-lines:
+
+    $ make run-test-tier1
+    $ make run-test-jdk_lang JTREG="JOBS=8"
+    $ make run-test TEST=jdk_lang
+    $ make run-test-only TEST="gtest:LogTagSet gtest:LogTagSetDescriptions" GTEST="REPEAT=-1"
+    $ make run-test TEST="hotspot/test:hotspot_gc" JTREG="JOBS=1;TIMEOUT=8;VM_OTIONS=-XshowSettings -Xlog:gc+ref=debug"
+    $ make run-test TEST="jtreg:hotspot/test:hotspot_gc hotspot/test/native_sanity/JniVersion.java"
+
+## Test selection
+
+All functionality is available using the run-test make target. In this use
+case, the test or tests to be executed is controlled using the `TEST` variable.
+To speed up subsequent test runs with no source code changes, run-test-only can
+be used instead, which do not depend on the source and test image build.
+
+For some common top-level tests, direct make targets have been generated. This
+includes all JTreg test groups, the hotspot gtest, and custom tests (if
+present). This means that `make run-test-tier1` is equivalent to `make run-test
+TEST="tier1"`, but the latter is more tab-completion friendly. For more complex
+test runs, the `run-test TEST="x"` solution needs to be used.
+
+The test specifications given in `TEST` is parsed into fully qualified test
+descriptors, which clearly and unambigously show which tests will be run. As an
+example, `:tier1` will expand to `jtreg:jdk/test:tier1
+jtreg:langtools/test:tier1 jtreg:nashorn/test:tier1 jtreg:jaxp/test:tier1`. You
+can always submit a list of fully qualified test descriptors in the `TEST`
+variable if you want to shortcut the parser.
+
+### JTreg
+
+JTreg test groups can be specified either without a test root, e.g. `:tier1`
+(or `tier1`, the initial colon is optional), or with, e.g.
+`hotspot/test:tier1`, `jdk/test:jdk_util`.
+
+When specified without a test root, all matching groups from all tests roots
+will be added. Otherwise, only the group from the specified test root will be
+added.
+
+Individual JTreg tests or directories containing JTreg tests can also be
+specified, like `hotspot/test/native_sanity/JniVersion.java` or
+`hotspot/test/native_sanity`. You can also specify an absolute path, to point
+to a JTreg test outside the source tree.
+
+As long as the test groups or test paths can be uniquely resolved, you do not
+need to enter the `jtreg:` prefix. If this is not possible, or if you want to
+use a fully qualified test descriptor, add `jtreg:`, e.g.
+`jtreg:hotspot/test/native_sanity`.
+
+### Gtest
+
+Since the Hotspot Gtest suite is so quick, the default is to run all tests.
+This is specified by just `gtest`, or as a fully qualified test descriptor
+`gtest:all`.
+
+If you want, you can single out an individual test or a group of tests, for
+instance `gtest:LogDecorations` or `gtest:LogDecorations.level_test_vm`. This
+can be particularly useful if you want to run a shaky test repeatedly.
+
+## Test results and summary
+
+At the end of the test run, a summary of all tests run will be presented. This
+will have a consistent look, regardless of what test suites were used. This is
+a sample summary:
+
+    ==============================
+    Test summary
+    ==============================
+       TEST                                          TOTAL  PASS  FAIL ERROR
+    >> jtreg:jdk/test:tier1                           1867  1865     2     0 <<
+       jtreg:langtools/test:tier1                     4711  4711     0     0
+       jtreg:nashorn/test:tier1                        133   133     0     0
+    ==============================
+    TEST FAILURE
+
+Tests where the number of TOTAL tests does not equal the number of PASSed tests
+will be considered a test failure. These are marked with the `>> ... <<` marker
+for easy identification.
+
+The classification of non-passed tests differs a bit between test suites. In
+the summary, ERROR is used as a catch-all for tests that neither passed nor are
+classified as failed by the framework. This might indicate test framework
+error, timeout or other problems.
+
+In case of test failures, `make run-test` will exit with a non-zero exit value.
+
+All tests have their result stored in `build/$BUILD/test-result/$TEST_ID`,
+where TEST_ID is a path-safe conversion from the fully qualified test
+descriptor, e.g. for `jtreg:jdk/test:tier1` the TEST_ID is
+`jtreg_jdk_test_tier1`. This path is also printed in the log at the end of the
+test run.
+
+Additional work data is stored in `build/$BUILD/test-support/$TEST_ID`. For
+some frameworks, this directory might contain information that is useful in
+determining the cause of a failed test.
+
+## Test suite control
+
+It is possible to control various aspects of the test suites using make control
+variables.
+
+These variables use a keyword=value approach to allow multiple values to be
+set. So, for instance, `JTREG="JOBS=1;TIMEOUT=8"` will set the JTreg
+concurrency level to 1 and the timeout factor to 8. This is equivalent to
+setting `JTREG_JOBS=1 JTREG_TIMEOUT=8`, but using the keyword format means that
+the `JTREG` variable is parsed and verified for correctness, so
+`JTREG="TMIEOUT=8"` would give an error, while `JTREG_TMIEOUT=8` would just
+pass unnoticed.
+
+To separate multiple keyword=value pairs, use `;` (semicolon). Since the shell
+normally eats `;`, the recommended usage is to write the assignment inside
+qoutes, e.g. `JTREG="...;..."`. This will also make sure spaces are preserved,
+as in `JTREG="VM_OTIONS=-XshowSettings -Xlog:gc+ref=debug"`.
+
+(Other ways are possible, e.g. using backslash: `JTREG=JOBS=1\;TIMEOUT=8`.
+Also, as a special technique, the string `%20` will be replaced with space for
+certain options, e.g. `JTREG=VM_OTIONS=-XshowSettings%20-Xlog:gc+ref=debug`.
+This can be useful if you have layers of scripts and have trouble getting
+proper quoting of command line arguments through.)
+
+As far as possible, the names of the keywords have been standardized between
+test suites.
+
+### JTreg keywords
+
+#### JOBS
+The test concurrency (`-concurrency`).
+
+Defaults to TEST_JOBS (if set by `--with-test-jobs=`), otherwise it defaults to
+JOBS, except for Hotspot, where the default is *number of CPU cores/2*, but
+never more than 12.
+
+#### TIMEOUT
+The timeout factor (`-timeoutFactor`).
+
+Defaults to 4.
+
+#### TEST_MODE
+The test mode (`-agentvm`, `-samevm` or `-othervm`).
+
+Defaults to `-agentvm`.
+
+#### ASSERT
+Enable asserts (`-ea -esa`, or none).
+
+Set to `true` or `false`. If true, adds `-ea -esa`. Defaults to true, except
+for hotspot.
+
+#### VERBOSE
+The verbosity level (`-verbose`).
+
+Defaults to `fail,error,summary`.
+
+#### RETAIN
+What test data to retain (`-retain`).
+
+Defaults to `fail,error`.
+
+#### MAX_MEM
+Limit memory consumption (`-Xmx` and `-vmoption:-Xmx`, or none).
+
+Limit memory consumption for JTreg test framework and VM under test. Set to 0
+to disable the limits.
+
+Defaults to 512m, except for hotspot, where it defaults to 0 (no limit).
+
+#### OPTIONS
+Additional options to the JTreg test framework.
+
+Use `JTREG="OPTIONS=--help all"` to see all available JTreg options.
+
+#### JAVA_OPTIONS
+Additional Java options to JTreg (`-javaoption`).
+
+#### VM_OPTIONS
+Additional VM options to JTreg (`-vmoption`).
+
+### Gtest keywords
+
+#### REPEAT
+The number of times to repeat the tests (`--gtest_repeat`).
+
+Default is 1. Set to -1 to repeat indefinitely. This can be especially useful
+combined with `OPTIONS=--gtest_break_on_failure` to reproduce an intermittent
+problem.
+
+#### OPTIONS
+Additional options to the Gtest test framework.
+
+Use `GTEST="OPTIONS=--help"` to see all available Gtest options.
+
+---
+# Override some definitions in http://openjdk.java.net/page.css that are
+# unsuitable for this document.
+header-includes:
+ - '<style type="text/css">pre, code, tt { color: #1d6ae5; }</style>'
+ - '<style type="text/css">pre { font-size: 10pt; }</style>'
+---
--- a/corba/.hgtags	Tue Apr 18 13:19:42 2017 -0400
+++ b/corba/.hgtags	Tue Apr 18 22:25:33 2017 +0200
@@ -408,3 +408,4 @@
 18ffcf99a3b4a10457853d94190e825bdf07e39b jdk-9+162
 493011dee80e51c2a2b064d049183c047df36d80 jdk-9+163
 965bbae3072702f7c0d95c240523b65e6bb19261 jdk-9+164
+a510b2201154abdd12ede42788086b5283bfb9a6 jdk-9+165
--- a/hotspot/.hgtags	Tue Apr 18 13:19:42 2017 -0400
+++ b/hotspot/.hgtags	Tue Apr 18 22:25:33 2017 +0200
@@ -568,3 +568,4 @@
 b01c519b715ef6f785d0631adee0a6537cf6c12e jdk-9+162
 983fe207555724d98f4876991e1cbafbcf2733e8 jdk-9+163
 0af429be8bbaeaaf0cb838e9af28c953dda6a9c8 jdk-9+164
+c92c6416ca03b1464d5ed99cf6201e52b5ba0a70 jdk-9+165
--- a/hotspot/src/cpu/x86/vm/assembler_x86.cpp	Tue Apr 18 13:19:42 2017 -0400
+++ b/hotspot/src/cpu/x86/vm/assembler_x86.cpp	Tue Apr 18 22:25:33 2017 +0200
@@ -917,7 +917,7 @@
     break;
 
   case 0x62: // EVEX_4bytes
-    assert((UseAVX > 0), "shouldn't have EVEX prefix");
+    assert(VM_Version::supports_evex(), "shouldn't have EVEX prefix");
     assert(ip == inst+1, "no prefixes allowed");
     // no EVEX collisions, all instructions that have 0x62 opcodes
     // have EVEX versions and are subopcodes of 0x66
--- a/hotspot/src/cpu/x86/vm/nativeInst_x86.cpp	Tue Apr 18 13:19:42 2017 -0400
+++ b/hotspot/src/cpu/x86/vm/nativeInst_x86.cpp	Tue Apr 18 22:25:33 2017 +0200
@@ -365,6 +365,10 @@
     NOT_LP64(assert((0xC0 & ubyte_at(1)) == 0xC0, "shouldn't have LDS and LES instructions"));
     return 3;
   }
+  if (instr_0 == instruction_EVEX_prefix_4bytes) {
+    assert(VM_Version::supports_evex(), "shouldn't have EVEX prefix");
+    return 4;
+  }
 
   // First check to see if we have a (prefixed or not) xor
   if (instr_0 >= instruction_prefix_wide_lo && // 0x40
--- a/hotspot/src/cpu/x86/vm/nativeInst_x86.hpp	Tue Apr 18 13:19:42 2017 -0400
+++ b/hotspot/src/cpu/x86/vm/nativeInst_x86.hpp	Tue Apr 18 22:25:33 2017 +0200
@@ -356,6 +356,7 @@
 
     instruction_VEX_prefix_2bytes       = Assembler::VEX_2bytes,
     instruction_VEX_prefix_3bytes       = Assembler::VEX_3bytes,
+    instruction_EVEX_prefix_4bytes      = Assembler::EVEX_4bytes,
 
     instruction_size                    = 4,
     instruction_offset                  = 0,
--- a/hotspot/src/jdk.internal.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotConstantReflectionProvider.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/hotspot/src/jdk.internal.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotConstantReflectionProvider.java	Tue Apr 18 22:25:33 2017 +0200
@@ -179,11 +179,14 @@
         if (hotspotField.isStatic()) {
             HotSpotResolvedJavaType holder = (HotSpotResolvedJavaType) hotspotField.getDeclaringClass();
             if (holder.isInitialized()) {
-                return memoryAccess.readUnsafeConstant(hotspotField.getJavaKind(), HotSpotObjectConstantImpl.forObject(holder.mirror()), hotspotField.offset());
+                return memoryAccess.readFieldValue(hotspotField, holder.mirror());
             }
         } else {
-            if (receiver.isNonNull() && hotspotField.isInObject(((HotSpotObjectConstantImpl) receiver).object())) {
-                return memoryAccess.readUnsafeConstant(hotspotField.getJavaKind(), receiver, hotspotField.offset());
+            if (receiver.isNonNull()) {
+                Object object = ((HotSpotObjectConstantImpl) receiver).object();
+                if (hotspotField.isInObject(object)) {
+                    return memoryAccess.readFieldValue(hotspotField, object);
+                }
             }
         }
         return null;
--- a/hotspot/src/jdk.internal.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotMemoryAccessProvider.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/hotspot/src/jdk.internal.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotMemoryAccessProvider.java	Tue Apr 18 22:25:33 2017 +0200
@@ -31,6 +31,10 @@
  */
 public interface HotSpotMemoryAccessProvider extends MemoryAccessProvider {
 
+    /**
+     * @throws IllegalArgumentException if the address computed from {@code base} and
+     *             {@code displacement} does not denote a location holding a narrow oop
+     */
     JavaConstant readNarrowOopConstant(Constant base, long displacement);
 
     Constant readKlassPointerConstant(Constant base, long displacement);
--- a/hotspot/src/jdk.internal.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotMemoryAccessProviderImpl.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/hotspot/src/jdk.internal.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotMemoryAccessProviderImpl.java	Tue Apr 18 22:25:33 2017 +0200
@@ -22,13 +22,21 @@
  */
 package jdk.vm.ci.hotspot;
 
+import static jdk.vm.ci.hotspot.HotSpotJVMCIRuntimeProvider.getArrayBaseOffset;
+import static jdk.vm.ci.hotspot.HotSpotJVMCIRuntimeProvider.getArrayIndexScale;
 import static jdk.vm.ci.hotspot.UnsafeAccess.UNSAFE;
 
+import java.lang.reflect.Array;
+
+import jdk.vm.ci.common.JVMCIError;
 import jdk.vm.ci.meta.Constant;
 import jdk.vm.ci.meta.JavaConstant;
 import jdk.vm.ci.meta.JavaKind;
 import jdk.vm.ci.meta.MemoryAccessProvider;
+import jdk.vm.ci.meta.MetaAccessProvider;
 import jdk.vm.ci.meta.PrimitiveConstant;
+import jdk.vm.ci.meta.ResolvedJavaField;
+import jdk.vm.ci.meta.ResolvedJavaType;
 
 /**
  * HotSpot implementation of {@link MemoryAccessProvider}.
@@ -41,12 +49,93 @@
         this.runtime = runtime;
     }
 
-    private static Object asObject(Constant base) {
+    /**
+     * Gets the object boxed by {@code base} that is about to have a value of kind {@code kind} read
+     * from it at the offset {@code displacement}.
+     *
+     * @param base constant value containing the base address for a pending read
+     * @return {@code null} if {@code base} does not box an object otherwise the object boxed in
+     *         {@code base}
+     */
+    private Object asObject(Constant base, JavaKind kind, long displacement) {
         if (base instanceof HotSpotObjectConstantImpl) {
-            return ((HotSpotObjectConstantImpl) base).object();
+            HotSpotObjectConstantImpl constant = (HotSpotObjectConstantImpl) base;
+            HotSpotResolvedObjectType type = constant.getType();
+            Object object = constant.object();
+            checkRead(kind, displacement, type, object);
+            return object;
+        }
+        return null;
+    }
+
+    /**
+     * Offset of injected {@code java.lang.Class::oop_size} field. No need to make {@code volatile}
+     * as initialization is idempotent.
+     */
+    private long oopSizeOffset;
+
+    private static int computeOopSizeOffset(HotSpotJVMCIRuntimeProvider runtime) {
+        MetaAccessProvider metaAccess = runtime.getHostJVMCIBackend().getMetaAccess();
+        ResolvedJavaType staticType = metaAccess.lookupJavaType(Class.class);
+        for (ResolvedJavaField f : staticType.getInstanceFields(false)) {
+            if (f.getName().equals("oop_size")) {
+                int offset = ((HotSpotResolvedJavaField) f).offset();
+                assert offset != 0 : "not expecting offset of java.lang.Class::oop_size to be 0";
+                return offset;
+            }
+        }
+        throw new JVMCIError("Could not find injected java.lang.Class::oop_size field");
+    }
+
+    private boolean checkRead(JavaKind kind, long displacement, HotSpotResolvedObjectType type, Object object) {
+        if (type.isArray()) {
+            ResolvedJavaType componentType = type.getComponentType();
+            JavaKind componentKind = componentType.getJavaKind();
+            final int headerSize = getArrayBaseOffset(componentKind);
+            int sizeOfElement = getArrayIndexScale(componentKind);
+            int length = Array.getLength(object);
+            long arrayEnd = headerSize + (sizeOfElement * length);
+            boolean aligned = ((displacement - headerSize) % sizeOfElement) == 0;
+            if (displacement < 0 || displacement > (arrayEnd - sizeOfElement) || (kind == JavaKind.Object && !aligned)) {
+                int index = (int) ((displacement - headerSize) / sizeOfElement);
+                throw new AssertionError("Unsafe array access: reading element of kind " + kind +
+                                " at offset " + displacement + " (index ~ " + index + ") in " +
+                                type.toJavaName() + " object of length " + length);
+            }
+        } else if (kind != JavaKind.Object) {
+            long size;
+            if (object instanceof Class) {
+                if (oopSizeOffset == 0) {
+                    oopSizeOffset = computeOopSizeOffset(runtime);
+                }
+                int wordSize = runtime.getHostJVMCIBackend().getCodeCache().getTarget().wordSize;
+                size = UNSAFE.getInt(object, oopSizeOffset) * wordSize;
+            } else {
+                size = Math.abs(type.instanceSize());
+            }
+            int bytesToRead = kind.getByteCount();
+            if (displacement + bytesToRead > size || displacement < 0) {
+                throw new IllegalArgumentException("Unsafe access: reading " + bytesToRead + " bytes at offset " + displacement + " in " +
+                                type.toJavaName() + " object of size " + size);
+            }
         } else {
-            return null;
+            ResolvedJavaField field = type.findInstanceFieldWithOffset(displacement, JavaKind.Object);
+            if (field == null && object instanceof Class) {
+                // Read of a static field
+                MetaAccessProvider metaAccess = runtime.getHostJVMCIBackend().getMetaAccess();
+                HotSpotResolvedObjectTypeImpl staticFieldsHolder = (HotSpotResolvedObjectTypeImpl) metaAccess.lookupJavaType((Class<?>) object);
+                field = staticFieldsHolder.findStaticFieldWithOffset(displacement, JavaKind.Object);
+            }
+            if (field == null) {
+                throw new IllegalArgumentException("Unsafe object access: field not found for read of kind Object" +
+                                " at offset " + displacement + " in " + type.toJavaName() + " object");
+            }
+            if (field.getJavaKind() != JavaKind.Object) {
+                throw new IllegalArgumentException("Unsafe object access: field " + field.format("%H.%n:%T") + " not of expected kind Object" +
+                                " at offset " + displacement + " in " + type.toJavaName() + " object");
+            }
         }
+        return true;
     }
 
     private boolean isValidObjectFieldDisplacement(Constant base, long displacement) {
@@ -77,8 +166,8 @@
         throw new IllegalArgumentException(String.valueOf(base));
     }
 
-    private static long readRawValue(Constant baseConstant, long displacement, int bits) {
-        Object base = asObject(baseConstant);
+    private long readRawValue(Constant baseConstant, long displacement, JavaKind kind, int bits) {
+        Object base = asObject(baseConstant, kind, displacement);
         if (base != null) {
             switch (bits) {
                 case Byte.SIZE:
@@ -123,9 +212,8 @@
 
     private Object readRawObject(Constant baseConstant, long initialDisplacement, boolean compressed) {
         long displacement = initialDisplacement;
-
         Object ret;
-        Object base = asObject(baseConstant);
+        Object base = asObject(baseConstant, JavaKind.Object, displacement);
         if (base == null) {
             assert !compressed;
             displacement += asRawPointer(baseConstant);
@@ -138,34 +226,43 @@
         return ret;
     }
 
-    /**
-     * Reads a value of this kind using a base address and a displacement. No bounds checking or
-     * type checking is performed. Returns {@code null} if the value is not available at this point.
-     *
-     * @param baseConstant the base address from which the value is read.
-     * @param displacement the displacement within the object in bytes
-     * @return the read value encapsulated in a {@link JavaConstant} object, or {@code null} if the
-     *         value cannot be read.
-     * @throws IllegalArgumentException if {@code kind} is {@code null}, {@link JavaKind#Void}, not
-     *             {@link JavaKind#Object} or not {@linkplain JavaKind#isPrimitive() primitive} kind
-     */
-    JavaConstant readUnsafeConstant(JavaKind kind, JavaConstant baseConstant, long displacement) {
-        if (kind == null) {
-            throw new IllegalArgumentException("null JavaKind");
-        }
-        if (kind == JavaKind.Object) {
-            Object o = readRawObject(baseConstant, displacement, runtime.getConfig().useCompressedOops);
+    JavaConstant readFieldValue(HotSpotResolvedJavaField field, Object obj) {
+        assert obj != null;
+        assert !field.isStatic() || obj instanceof Class;
+        long displacement = field.offset();
+        assert checkRead(field.getJavaKind(), displacement, (HotSpotResolvedObjectType) runtime.getHostJVMCIBackend().getMetaAccess().lookupJavaType(obj.getClass()), obj);
+        if (field.getJavaKind() == JavaKind.Object) {
+            Object o = UNSAFE.getObject(obj, displacement);
             return HotSpotObjectConstantImpl.forObject(o);
         } else {
-            int bits = kind.getByteCount() * Byte.SIZE;
-            return readPrimitiveConstant(kind, baseConstant, displacement, bits);
+            JavaKind kind = field.getJavaKind();
+            switch (kind) {
+                case Boolean:
+                    return JavaConstant.forBoolean(UNSAFE.getBoolean(obj, displacement));
+                case Byte:
+                    return JavaConstant.forByte(UNSAFE.getByte(obj, displacement));
+                case Char:
+                    return JavaConstant.forChar(UNSAFE.getChar(obj, displacement));
+                case Short:
+                    return JavaConstant.forShort(UNSAFE.getShort(obj, displacement));
+                case Int:
+                    return JavaConstant.forInt(UNSAFE.getInt(obj, displacement));
+                case Long:
+                    return JavaConstant.forLong(UNSAFE.getLong(obj, displacement));
+                case Float:
+                    return JavaConstant.forFloat(UNSAFE.getFloat(obj, displacement));
+                case Double:
+                    return JavaConstant.forDouble(UNSAFE.getDouble(obj, displacement));
+                default:
+                    throw new IllegalArgumentException("Unsupported kind: " + kind);
+            }
         }
     }
 
     @Override
     public JavaConstant readPrimitiveConstant(JavaKind kind, Constant baseConstant, long initialDisplacement, int bits) {
         try {
-            long rawValue = readRawValue(baseConstant, initialDisplacement, bits);
+            long rawValue = readRawValue(baseConstant, initialDisplacement, kind, bits);
             switch (kind) {
                 case Boolean:
                     return JavaConstant.forBoolean(rawValue != 0);
@@ -193,6 +290,10 @@
 
     @Override
     public JavaConstant readObjectConstant(Constant base, long displacement) {
+        if (base instanceof HotSpotObjectConstantImpl) {
+            Object o = readRawObject(base, displacement, runtime.getConfig().useCompressedOops);
+            return HotSpotObjectConstantImpl.forObject(o);
+        }
         if (!isValidObjectFieldDisplacement(base, displacement)) {
             return null;
         }
--- a/hotspot/src/jdk.internal.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotResolvedObjectTypeImpl.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/hotspot/src/jdk.internal.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotResolvedObjectTypeImpl.java	Tue Apr 18 22:25:33 2017 +0200
@@ -847,6 +847,15 @@
     @Override
     public ResolvedJavaField findInstanceFieldWithOffset(long offset, JavaKind expectedEntryKind) {
         ResolvedJavaField[] declaredFields = getInstanceFields(true);
+        return findFieldWithOffset(offset, expectedEntryKind, declaredFields);
+    }
+
+    public ResolvedJavaField findStaticFieldWithOffset(long offset, JavaKind expectedEntryKind) {
+        ResolvedJavaField[] declaredFields = getStaticFields();
+        return findFieldWithOffset(offset, expectedEntryKind, declaredFields);
+    }
+
+    private static ResolvedJavaField findFieldWithOffset(long offset, JavaKind expectedEntryKind, ResolvedJavaField[] declaredFields) {
         for (ResolvedJavaField field : declaredFields) {
             HotSpotResolvedJavaField resolvedField = (HotSpotResolvedJavaField) field;
             long resolvedFieldOffset = resolvedField.offset();
--- a/hotspot/src/jdk.internal.vm.ci/share/classes/jdk.vm.ci.meta/src/jdk/vm/ci/meta/MemoryAccessProvider.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/hotspot/src/jdk.internal.vm.ci/share/classes/jdk.vm.ci.meta/src/jdk/vm/ci/meta/MemoryAccessProvider.java	Tue Apr 18 22:25:33 2017 +0200
@@ -35,9 +35,9 @@
      * @param displacement the displacement within the object in bytes
      * @param bits the number of bits to read from memory
      * @return the read value encapsulated in a {@link JavaConstant} object of {@link JavaKind} kind
-     * @throws IllegalArgumentException if {@code kind} is {@link JavaKind#Void} or not
-     *             {@linkplain JavaKind#isPrimitive() primitive} kind or {@code bits} is not 8, 16,
-     *             32 or 64
+     * @throws IllegalArgumentException if the read is out of bounds of the object or {@code kind}
+     *             is {@link JavaKind#Void} or not {@linkplain JavaKind#isPrimitive() primitive}
+     *             kind or {@code bits} is not 8, 16, 32 or 64
      */
     JavaConstant readPrimitiveConstant(JavaKind kind, Constant base, long displacement, int bits) throws IllegalArgumentException;
 
@@ -46,9 +46,9 @@
      *
      * @param base the base address from which the value is read
      * @param displacement the displacement within the object in bytes
-     * @return the read value encapsulated in a {@link Constant} object or {@code null} if the
-     *         address computed from {@code base} and {@code displacement} does not denote a
-     *         location holding an {@code Object} value
+     * @return the read value encapsulated in a {@link Constant} object
+     * @throws IllegalArgumentException if the address computed from {@code base} and
+     *             {@code displacement} does not denote a location holding an {@code Object} value
      */
     JavaConstant readObjectConstant(Constant base, long displacement);
 }
--- a/hotspot/src/jdk.internal.vm.ci/share/classes/jdk.vm.ci.services/src/jdk/vm/ci/services/Services.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/hotspot/src/jdk.internal.vm.ci/share/classes/jdk.vm.ci.services/src/jdk/vm/ci/services/Services.java	Tue Apr 18 22:25:33 2017 +0200
@@ -28,6 +28,7 @@
 import java.util.Iterator;
 import java.util.ServiceConfigurationError;
 import java.util.ServiceLoader;
+import java.util.Set;
 
 /**
  * A mechanism for accessing service providers via JVMCI.
@@ -108,7 +109,7 @@
             Object jvmci = invoke(getModule, Services.class);
             Object requestorModule = invoke(getModule, requestor);
             if (jvmci != requestorModule) {
-                String[] packages = invoke(getPackages, jvmci);
+                Set<String> packages = invoke(getPackages, jvmci);
                 for (String pkg : packages) {
                     // Export all JVMCI packages dynamically instead
                     // of requiring a long list of --add-exports
--- a/hotspot/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.core.common/src/org/graalvm/compiler/core/common/util/ModuleAPI.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/hotspot/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.core.common/src/org/graalvm/compiler/core/common/util/ModuleAPI.java	Tue Apr 18 22:25:33 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2016, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -64,27 +64,27 @@
     public static final ModuleAPI addOpens;
 
     /**
-     * {@code java.lang.reflect.Module.getResourceAsStream(String)}.
+     * {@code java.lang.Module.getResourceAsStream(String)}.
      */
     public static final ModuleAPI getResourceAsStream;
 
     /**
-     * {@code java.lang.reflect.Module.getPackages()}.
+     * {@code java.lang.Module.getPackages()}.
      */
     public static final ModuleAPI getPackages;
 
     /**
-     * {@code java.lang.reflect.Module.canRead(Module)}.
+     * {@code java.lang.Module.canRead(Module)}.
      */
     public static final ModuleAPI canRead;
 
     /**
-     * {@code java.lang.reflect.Module.isExported(String)}.
+     * {@code java.lang.Module.isExported(String)}.
      */
     public static final ModuleAPI isExported;
 
     /**
-     * {@code java.lang.reflect.Module.isExported(String, Module)}.
+     * {@code java.lang.Module.isExported(String, Module)}.
      */
     public static final ModuleAPI isExportedTo;
 
--- a/hotspot/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.test/src/org/graalvm/compiler/test/ExportingClassLoader.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/hotspot/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.test/src/org/graalvm/compiler/test/ExportingClassLoader.java	Tue Apr 18 22:25:33 2017 +0200
@@ -29,14 +29,14 @@
 public class ExportingClassLoader extends ClassLoader {
     public ExportingClassLoader() {
         if (!GraalTest.Java8OrEarlier) {
-            JLRModule.fromClass(getClass()).exportAllPackagesTo(JLRModule.getUnnamedModuleFor(this));
+            JLModule.fromClass(getClass()).exportAllPackagesTo(JLModule.getUnnamedModuleFor(this));
         }
     }
 
     public ExportingClassLoader(ClassLoader parent) {
         super(parent);
         if (!GraalTest.Java8OrEarlier) {
-            JLRModule.fromClass(getClass()).exportAllPackagesTo(JLRModule.getUnnamedModuleFor(this));
+            JLModule.fromClass(getClass()).exportAllPackagesTo(JLModule.getUnnamedModuleFor(this));
         }
     }
 }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.test/src/org/graalvm/compiler/test/JLModule.java	Tue Apr 18 22:25:33 2017 +0200
@@ -0,0 +1,130 @@
+/*
+ * 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.
+ */
+package org.graalvm.compiler.test;
+
+import java.lang.reflect.Method;
+import java.util.Set;
+
+/**
+ * Facade for the {@code java.lang.Module} class introduced in JDK9 that allows tests to be
+ * developed against JDK8 but use module logic if deployed on JDK9.
+ */
+public class JLModule {
+
+    static {
+        if (GraalTest.Java8OrEarlier) {
+            throw new AssertionError("Use of " + JLModule.class + " only allowed if " + GraalTest.class.getName() + ".JDK8OrEarlier is false");
+        }
+    }
+
+    private final Object realModule;
+
+    public JLModule(Object module) {
+        this.realModule = module;
+    }
+
+    private static final Class<?> moduleClass;
+    private static final Method getModuleMethod;
+    private static final Method getUnnamedModuleMethod;
+    private static final Method getPackagesMethod;
+    private static final Method isExportedMethod;
+    private static final Method isExported2Method;
+    private static final Method addExportsMethod;
+    static {
+        try {
+            moduleClass = Class.forName("java.lang.Module");
+            getModuleMethod = Class.class.getMethod("getModule");
+            getUnnamedModuleMethod = ClassLoader.class.getMethod("getUnnamedModule");
+            getPackagesMethod = moduleClass.getMethod("getPackages");
+            isExportedMethod = moduleClass.getMethod("isExported", String.class);
+            isExported2Method = moduleClass.getMethod("isExported", String.class, moduleClass);
+            addExportsMethod = moduleClass.getMethod("addExports", String.class, moduleClass);
+        } catch (Exception e) {
+            throw new AssertionError(e);
+        }
+    }
+
+    public static JLModule fromClass(Class<?> cls) {
+        try {
+            return new JLModule(getModuleMethod.invoke(cls));
+        } catch (Exception e) {
+            throw new AssertionError(e);
+        }
+    }
+
+    public static JLModule getUnnamedModuleFor(ClassLoader cl) {
+        try {
+            return new JLModule(getUnnamedModuleMethod.invoke(cl));
+        } catch (Exception e) {
+            throw new AssertionError(e);
+        }
+    }
+
+    /**
+     * Exports all packages in this module to a given module.
+     */
+    public void exportAllPackagesTo(JLModule module) {
+        if (this != module) {
+            for (String pkg : getPackages()) {
+                // Export all JVMCI packages dynamically instead
+                // of requiring a long list of -XaddExports
+                // options on the JVM command line.
+                if (!isExported(pkg, module)) {
+                    addExports(pkg, module);
+                }
+            }
+        }
+    }
+
+    public Set<String> getPackages() {
+        try {
+            return (Set<String>) getPackagesMethod.invoke(realModule);
+        } catch (Exception e) {
+            throw new AssertionError(e);
+        }
+    }
+
+    public boolean isExported(String pn) {
+        try {
+            return (Boolean) isExportedMethod.invoke(realModule, pn);
+        } catch (Exception e) {
+            throw new AssertionError(e);
+        }
+    }
+
+    public boolean isExported(String pn, JLModule other) {
+        try {
+            return (Boolean) isExported2Method.invoke(realModule, pn, other.realModule);
+        } catch (Exception e) {
+            throw new AssertionError(e);
+        }
+    }
+
+    public void addExports(String pn, JLModule other) {
+        try {
+            addExportsMethod.invoke(realModule, pn, other.realModule);
+        } catch (Exception e) {
+            throw new AssertionError(e);
+        }
+    }
+}
--- a/hotspot/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.test/src/org/graalvm/compiler/test/JLRModule.java	Tue Apr 18 13:19:42 2017 -0400
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,129 +0,0 @@
-/*
- * 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.
- */
-package org.graalvm.compiler.test;
-
-import java.lang.reflect.Method;
-
-/**
- * Facade for the {@code java.lang.reflect.Module} class introduced in JDK9 that allows tests to be
- * developed against JDK8 but use module logic if deployed on JDK9.
- */
-public class JLRModule {
-
-    static {
-        if (GraalTest.Java8OrEarlier) {
-            throw new AssertionError("Use of " + JLRModule.class + " only allowed if " + GraalTest.class.getName() + ".JDK8OrEarlier is false");
-        }
-    }
-
-    private final Object realModule;
-
-    public JLRModule(Object module) {
-        this.realModule = module;
-    }
-
-    private static final Class<?> moduleClass;
-    private static final Method getModuleMethod;
-    private static final Method getUnnamedModuleMethod;
-    private static final Method getPackagesMethod;
-    private static final Method isExportedMethod;
-    private static final Method isExported2Method;
-    private static final Method addExportsMethod;
-    static {
-        try {
-            moduleClass = Class.forName("java.lang.reflect.Module");
-            getModuleMethod = Class.class.getMethod("getModule");
-            getUnnamedModuleMethod = ClassLoader.class.getMethod("getUnnamedModule");
-            getPackagesMethod = moduleClass.getMethod("getPackages");
-            isExportedMethod = moduleClass.getMethod("isExported", String.class);
-            isExported2Method = moduleClass.getMethod("isExported", String.class, moduleClass);
-            addExportsMethod = moduleClass.getMethod("addExports", String.class, moduleClass);
-        } catch (Exception e) {
-            throw new AssertionError(e);
-        }
-    }
-
-    public static JLRModule fromClass(Class<?> cls) {
-        try {
-            return new JLRModule(getModuleMethod.invoke(cls));
-        } catch (Exception e) {
-            throw new AssertionError(e);
-        }
-    }
-
-    public static JLRModule getUnnamedModuleFor(ClassLoader cl) {
-        try {
-            return new JLRModule(getUnnamedModuleMethod.invoke(cl));
-        } catch (Exception e) {
-            throw new AssertionError(e);
-        }
-    }
-
-    /**
-     * Exports all packages in this module to a given module.
-     */
-    public void exportAllPackagesTo(JLRModule module) {
-        if (this != module) {
-            for (String pkg : getPackages()) {
-                // Export all JVMCI packages dynamically instead
-                // of requiring a long list of -XaddExports
-                // options on the JVM command line.
-                if (!isExported(pkg, module)) {
-                    addExports(pkg, module);
-                }
-            }
-        }
-    }
-
-    public String[] getPackages() {
-        try {
-            return (String[]) getPackagesMethod.invoke(realModule);
-        } catch (Exception e) {
-            throw new AssertionError(e);
-        }
-    }
-
-    public boolean isExported(String pn) {
-        try {
-            return (Boolean) isExportedMethod.invoke(realModule, pn);
-        } catch (Exception e) {
-            throw new AssertionError(e);
-        }
-    }
-
-    public boolean isExported(String pn, JLRModule other) {
-        try {
-            return (Boolean) isExported2Method.invoke(realModule, pn, other.realModule);
-        } catch (Exception e) {
-            throw new AssertionError(e);
-        }
-    }
-
-    public void addExports(String pn, JLRModule other) {
-        try {
-            addExportsMethod.invoke(realModule, pn, other.realModule);
-        } catch (Exception e) {
-            throw new AssertionError(e);
-        }
-    }
-}
--- a/hotspot/src/share/vm/classfile/classFileParser.cpp	Tue Apr 18 13:19:42 2017 -0400
+++ b/hotspot/src/share/vm/classfile/classFileParser.cpp	Tue Apr 18 22:25:33 2017 +0200
@@ -5416,7 +5416,7 @@
   ModuleEntry* module_entry = ik->module();
   assert(module_entry != NULL, "module_entry should always be set");
 
-  // Obtain java.lang.reflect.Module
+  // Obtain java.lang.Module
   Handle module_handle(THREAD, JNIHandles::resolve(module_entry->module()));
 
   // Allocate mirror and initialize static fields
--- a/hotspot/src/share/vm/classfile/javaClasses.cpp	Tue Apr 18 13:19:42 2017 -0400
+++ b/hotspot/src/share/vm/classfile/javaClasses.cpp	Tue Apr 18 22:25:33 2017 +0200
@@ -772,13 +772,13 @@
   InstanceKlass::cast(k)->do_local_static_fields(&initialize_static_field, mirror, CHECK);
 }
 
-// Set the java.lang.reflect.Module module field in the java_lang_Class mirror
+// Set the java.lang.Module module field in the java_lang_Class mirror
 void java_lang_Class::set_mirror_module_field(Klass* k, Handle mirror, Handle module, TRAPS) {
   if (module.is_null()) {
     // During startup, the module may be NULL only if java.base has not been defined yet.
-    // Put the class on the fixup_module_list to patch later when the java.lang.reflect.Module
+    // Put the class on the fixup_module_list to patch later when the java.lang.Module
     // for java.base is known.
-    assert(!Universe::is_module_initialized(), "Incorrect java.lang.reflect.Module pre module system initialization");
+    assert(!Universe::is_module_initialized(), "Incorrect java.lang.Module pre module system initialization");
 
     bool javabase_was_defined = false;
     {
@@ -809,7 +809,7 @@
     assert(Universe::is_module_initialized() ||
            (ModuleEntryTable::javabase_defined() &&
             (module() == JNIHandles::resolve(ModuleEntryTable::javabase_moduleEntry()->module()))),
-           "Incorrect java.lang.reflect.Module specification while creating mirror");
+           "Incorrect java.lang.Module specification while creating mirror");
     set_module(mirror(), module());
   }
 }
@@ -2802,27 +2802,27 @@
 }
 
 
-int java_lang_reflect_Module::loader_offset;
-int java_lang_reflect_Module::name_offset;
-int java_lang_reflect_Module::_module_entry_offset = -1;
-
-Handle java_lang_reflect_Module::create(Handle loader, Handle module_name, TRAPS) {
+int java_lang_Module::loader_offset;
+int java_lang_Module::name_offset;
+int java_lang_Module::_module_entry_offset = -1;
+
+Handle java_lang_Module::create(Handle loader, Handle module_name, TRAPS) {
   assert(Universe::is_fully_initialized(), "Need to find another solution to the reflection problem");
 
-  Symbol* name = vmSymbols::java_lang_reflect_Module();
+  Symbol* name = vmSymbols::java_lang_Module();
   Klass* k = SystemDictionary::resolve_or_fail(name, true, CHECK_NH);
   InstanceKlass* ik = InstanceKlass::cast(k);
-  Handle jlrmh = ik->allocate_instance_handle(CHECK_NH);
+  Handle jlmh = ik->allocate_instance_handle(CHECK_NH);
   JavaValue result(T_VOID);
-  JavaCalls::call_special(&result, jlrmh, ik,
+  JavaCalls::call_special(&result, jlmh, ik,
                           vmSymbols::object_initializer_name(),
-                          vmSymbols::java_lang_reflect_module_init_signature(),
+                          vmSymbols::java_lang_module_init_signature(),
                           loader, module_name, CHECK_NH);
-  return jlrmh;
-}
-
-void java_lang_reflect_Module::compute_offsets() {
-  Klass* k = SystemDictionary::reflect_Module_klass();
+  return jlmh;
+}
+
+void java_lang_Module::compute_offsets() {
+  Klass* k = SystemDictionary::Module_klass();
   if(NULL != k) {
     compute_offset(loader_offset,  k, vmSymbols::loader_name(),  vmSymbols::classloader_signature());
     compute_offset(name_offset,    k, vmSymbols::name_name(),    vmSymbols::string_signature());
@@ -2831,27 +2831,27 @@
 }
 
 
-oop java_lang_reflect_Module::loader(oop module) {
+oop java_lang_Module::loader(oop module) {
   assert(Universe::is_fully_initialized(), "Need to find another solution to the reflection problem");
   return module->obj_field(loader_offset);
 }
 
-void java_lang_reflect_Module::set_loader(oop module, oop value) {
+void java_lang_Module::set_loader(oop module, oop value) {
   assert(Universe::is_fully_initialized(), "Need to find another solution to the reflection problem");
   module->obj_field_put(loader_offset, value);
 }
 
-oop java_lang_reflect_Module::name(oop module) {
+oop java_lang_Module::name(oop module) {
   assert(Universe::is_fully_initialized(), "Need to find another solution to the reflection problem");
   return module->obj_field(name_offset);
 }
 
-void java_lang_reflect_Module::set_name(oop module, oop value) {
+void java_lang_Module::set_name(oop module, oop value) {
   assert(Universe::is_fully_initialized(), "Need to find another solution to the reflection problem");
   module->obj_field_put(name_offset, value);
 }
 
-ModuleEntry* java_lang_reflect_Module::module_entry(oop module, TRAPS) {
+ModuleEntry* java_lang_Module::module_entry(oop module, TRAPS) {
   assert(_module_entry_offset != -1, "Uninitialized module_entry_offset");
   assert(module != NULL, "module can't be null");
   assert(module->is_oop(), "module must be oop");
@@ -2860,7 +2860,7 @@
   if (module_entry == NULL) {
     // If the inject field containing the ModuleEntry* is null then return the
     // class loader's unnamed module.
-    oop loader = java_lang_reflect_Module::loader(module);
+    oop loader = java_lang_Module::loader(module);
     Handle h_loader = Handle(THREAD, loader);
     ClassLoaderData* loader_cld = SystemDictionary::register_loader(h_loader, CHECK_NULL);
     return loader_cld->unnamed_module();
@@ -2868,7 +2868,7 @@
   return module_entry;
 }
 
-void java_lang_reflect_Module::set_module_entry(oop module, ModuleEntry* module_entry) {
+void java_lang_Module::set_module_entry(oop module, ModuleEntry* module_entry) {
   assert(_module_entry_offset != -1, "Uninitialized module_entry_offset");
   assert(module != NULL, "module can't be null");
   assert(module->is_oop(), "module must be oop");
@@ -3873,7 +3873,7 @@
   reflect_ConstantPool::compute_offsets();
   reflect_UnsafeStaticFieldAccessorImpl::compute_offsets();
   java_lang_reflect_Parameter::compute_offsets();
-  java_lang_reflect_Module::compute_offsets();
+  java_lang_Module::compute_offsets();
   java_lang_StackFrameInfo::compute_offsets();
   java_lang_LiveStackFrameInfo::compute_offsets();
 
--- a/hotspot/src/share/vm/classfile/javaClasses.hpp	Tue Apr 18 13:19:42 2017 -0400
+++ b/hotspot/src/share/vm/classfile/javaClasses.hpp	Tue Apr 18 22:25:33 2017 +0200
@@ -749,9 +749,9 @@
 };
 
 #define MODULE_INJECTED_FIELDS(macro)                            \
-  macro(java_lang_reflect_Module, module_entry, intptr_signature, false)
+  macro(java_lang_Module, module_entry, intptr_signature, false)
 
-class java_lang_reflect_Module {
+class java_lang_Module {
   private:
     static int loader_offset;
     static int name_offset;
--- a/hotspot/src/share/vm/classfile/javaClasses.inline.hpp	Tue Apr 18 13:19:42 2017 -0400
+++ b/hotspot/src/share/vm/classfile/javaClasses.inline.hpp	Tue Apr 18 22:25:33 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -162,8 +162,8 @@
   return obj != NULL && is_subclass(obj->klass());
 }
 
-inline bool java_lang_reflect_Module::is_instance(oop obj) {
-  return obj != NULL && obj->klass() == SystemDictionary::reflect_Module_klass();
+inline bool java_lang_Module::is_instance(oop obj) {
+  return obj != NULL && obj->klass() == SystemDictionary::Module_klass();
 }
 
 inline int Backtrace::merge_bci_and_version(int bci, int version) {
--- a/hotspot/src/share/vm/classfile/moduleEntry.cpp	Tue Apr 18 13:19:42 2017 -0400
+++ b/hotspot/src/share/vm/classfile/moduleEntry.cpp	Tue Apr 18 22:25:33 2017 +0200
@@ -235,7 +235,7 @@
 
   // Store pointer to the ModuleEntry in the unnamed module's java.lang.Module
   // object.
-  java_lang_reflect_Module::set_module_entry(module, unnamed_module);
+  java_lang_Module::set_module_entry(module, unnamed_module);
 
   return unnamed_module;
 }
@@ -424,27 +424,27 @@
     fatal("Unable to finalize module definition for " JAVA_BASE_NAME);
   }
 
-  // Set java.lang.reflect.Module, version and location for java.base
+  // Set java.lang.Module, version and location for java.base
   ModuleEntry* jb_module = javabase_moduleEntry();
   assert(jb_module != NULL, JAVA_BASE_NAME " ModuleEntry not defined");
   jb_module->set_version(version);
   jb_module->set_location(location);
   // Once java.base's ModuleEntry _module field is set with the known
-  // java.lang.reflect.Module, java.base is considered "defined" to the VM.
+  // java.lang.Module, java.base is considered "defined" to the VM.
   jb_module->set_module(boot_loader_data->add_handle(module_handle));
 
-  // Store pointer to the ModuleEntry for java.base in the java.lang.reflect.Module object.
-  java_lang_reflect_Module::set_module_entry(module_handle(), jb_module);
+  // Store pointer to the ModuleEntry for java.base in the java.lang.Module object.
+  java_lang_Module::set_module_entry(module_handle(), jb_module);
 }
 
-// Within java.lang.Class instances there is a java.lang.reflect.Module field
-// that must be set with the defining module.  During startup, prior to java.base's
-// definition, classes needing their module field set are added to the fixup_module_list.
-// Their module field is set once java.base's java.lang.reflect.Module is known to the VM.
+// Within java.lang.Class instances there is a java.lang.Module field that must
+// be set with the defining module.  During startup, prior to java.base's definition,
+// classes needing their module field set are added to the fixup_module_list.
+// Their module field is set once java.base's java.lang.Module is known to the VM.
 void ModuleEntryTable::patch_javabase_entries(Handle module_handle) {
   if (module_handle.is_null()) {
     fatal("Unable to patch the module field of classes loaded prior to "
-          JAVA_BASE_NAME "'s definition, invalid java.lang.reflect.Module");
+          JAVA_BASE_NAME "'s definition, invalid java.lang.Module");
   }
 
   // Do the fixups for the basic primitive types
--- a/hotspot/src/share/vm/classfile/moduleEntry.hpp	Tue Apr 18 13:19:42 2017 -0400
+++ b/hotspot/src/share/vm/classfile/moduleEntry.hpp	Tue Apr 18 22:25:33 2017 +0200
@@ -45,7 +45,7 @@
 // A ModuleEntry describes a module that has been defined by a call to JVM_DefineModule.
 // It contains:
 //   - Symbol* containing the module's name.
-//   - pointer to the java.lang.reflect.Module for this module.
+//   - pointer to the java.lang.Module for this module.
 //   - pointer to the java.security.ProtectionDomain shared by classes defined to this module.
 //   - ClassLoaderData*, class loader of this module.
 //   - a growable array containg other module entries that this module can read.
@@ -55,7 +55,7 @@
 // data structure.
 class ModuleEntry : public HashtableEntry<Symbol*, mtModule> {
 private:
-  jobject _module;                     // java.lang.reflect.Module
+  jobject _module;                     // java.lang.Module
   jobject _pd;                         // java.security.ProtectionDomain, cached
                                        // for shared classes from this module
   ClassLoaderData* _loader_data;
--- a/hotspot/src/share/vm/classfile/modules.cpp	Tue Apr 18 13:19:42 2017 -0400
+++ b/hotspot/src/share/vm/classfile/modules.cpp	Tue Apr 18 22:25:33 2017 +0200
@@ -62,7 +62,7 @@
 }
 
 static char* get_module_name(oop module, TRAPS) {
-  oop name_oop = java_lang_reflect_Module::name(module);
+  oop name_oop = java_lang_Module::name(module);
   if (name_oop == NULL) {
     THROW_MSG_NULL(vmSymbols::java_lang_NullPointerException(), "Null module name");
   }
@@ -98,11 +98,11 @@
 
 static ModuleEntry* get_module_entry(jobject module, TRAPS) {
   Handle module_h(THREAD, JNIHandles::resolve(module));
-  if (!java_lang_reflect_Module::is_instance(module_h())) {
+  if (!java_lang_Module::is_instance(module_h())) {
     THROW_MSG_NULL(vmSymbols::java_lang_IllegalArgumentException(),
-                   "module is not an instance of type java.lang.reflect.Module");
+                   "module is not an instance of type java.lang.Module");
   }
-  return java_lang_reflect_Module::module_entry(module_h(), CHECK_NULL);
+  return java_lang_Module::module_entry(module_h(), CHECK_NULL);
 }
 
 static PackageEntry* get_package_entry(ModuleEntry* module_entry, const char* package_name, TRAPS) {
@@ -175,7 +175,7 @@
   }
 
   // Validate java_base's loader is the boot loader.
-  oop loader = java_lang_reflect_Module::loader(module_handle());
+  oop loader = java_lang_Module::loader(module_handle());
   if (loader != NULL) {
     THROW_MSG(vmSymbols::java_lang_IllegalArgumentException(),
               "Class loader must be the boot class loader");
@@ -228,7 +228,7 @@
   // Only the thread that actually defined the base module will get here,
   // so no locking is needed.
 
-  // Patch any previously loaded class's module field with java.base's java.lang.reflect.Module.
+  // Patch any previously loaded class's module field with java.base's java.lang.Module.
   ModuleEntryTable::patch_javabase_entries(module_handle);
 
   log_debug(modules)("define_javabase_module(): Definition of module: "
@@ -278,9 +278,9 @@
   }
 
   Handle module_handle(THREAD, JNIHandles::resolve(module));
-  if (!java_lang_reflect_Module::is_instance(module_handle())) {
+  if (!java_lang_Module::is_instance(module_handle())) {
     THROW_MSG(vmSymbols::java_lang_IllegalArgumentException(),
-              "module is not an instance of type java.lang.reflect.Module");
+              "module is not an instance of type java.lang.Module");
   }
 
   char* module_name = get_module_name(module_handle(), CHECK);
@@ -297,7 +297,7 @@
 
   const char* module_version = get_module_version(version);
 
-  oop loader = java_lang_reflect_Module::loader(module_handle());
+  oop loader = java_lang_Module::loader(module_handle());
   // Make sure loader is not the jdk.internal.reflect.DelegatingClassLoader.
   if (loader != java_lang_ClassLoader::non_reflection_class_loader(loader)) {
     THROW_MSG(vmSymbols::java_lang_IllegalArgumentException(),
@@ -413,8 +413,8 @@
           pkg_list->at(y)->decrement_refcount();
         }
 
-        // Store pointer to ModuleEntry record in java.lang.reflect.Module object.
-        java_lang_reflect_Module::set_module_entry(module_handle(), module_entry);
+        // Store pointer to ModuleEntry record in java.lang.Module object.
+        java_lang_Module::set_module_entry(module_handle(), module_entry);
       }
     }
   }  // Release the lock
@@ -456,20 +456,20 @@
     THROW_MSG(vmSymbols::java_lang_NullPointerException(), "Null module object");
   }
   Handle module_handle(THREAD, JNIHandles::resolve(module));
-  if (!java_lang_reflect_Module::is_instance(module_handle())) {
+  if (!java_lang_Module::is_instance(module_handle())) {
     THROW_MSG(vmSymbols::java_lang_IllegalArgumentException(),
-              "module is not an instance of type java.lang.reflect.Module");
+              "module is not an instance of type java.lang.Module");
   }
 
   // Ensure that this is an unnamed module
-  oop name = java_lang_reflect_Module::name(module_handle());
+  oop name = java_lang_Module::name(module_handle());
   if (name != NULL) {
     THROW_MSG(vmSymbols::java_lang_IllegalArgumentException(),
-              "boot loader's unnamed module's java.lang.reflect.Module has a name");
+              "boot loader's unnamed module's java.lang.Module has a name");
   }
 
   // Validate java_base's loader is the boot loader.
-  oop loader = java_lang_reflect_Module::loader(module_handle());
+  oop loader = java_lang_Module::loader(module_handle());
   if (loader != NULL) {
     THROW_MSG(vmSymbols::java_lang_IllegalArgumentException(),
               "Class loader must be the boot class loader");
@@ -483,8 +483,8 @@
   ModuleEntry* unnamed_module = boot_loader_data->unnamed_module();
   assert(unnamed_module != NULL, "boot loader's unnamed ModuleEntry not defined");
   unnamed_module->set_module(boot_loader_data->add_handle(module_handle));
-  // Store pointer to the ModuleEntry in the unnamed module's java.lang.reflect.Module object.
-  java_lang_reflect_Module::set_module_entry(module_handle(), unnamed_module);
+  // Store pointer to the ModuleEntry in the unnamed module's java.lang.Module object.
+  java_lang_Module::set_module_entry(module_handle(), unnamed_module);
 }
 
 void Modules::add_module_exports(jobject from_module, const char* package_name, jobject to_module, TRAPS) {
@@ -614,13 +614,13 @@
   oop module = java_lang_Class::module(mirror);
 
   assert(module != NULL, "java.lang.Class module field not set");
-  assert(java_lang_reflect_Module::is_instance(module), "module is not an instance of type java.lang.reflect.Module");
+  assert(java_lang_Module::is_instance(module), "module is not an instance of type java.lang.Module");
 
   if (log_is_enabled(Debug, modules)) {
     ResourceMark rm(THREAD);
     outputStream* logst = Log(modules)::debug_stream();
     Klass* klass = java_lang_Class::as_Klass(mirror);
-    oop module_name = java_lang_reflect_Module::name(module);
+    oop module_name = java_lang_Module::name(module);
     if (module_name != NULL) {
       logst->print("get_module(): module ");
       java_lang_String::print(module_name, tty);
--- a/hotspot/src/share/vm/classfile/modules.hpp	Tue Apr 18 13:19:42 2017 -0400
+++ b/hotspot/src/share/vm/classfile/modules.hpp	Tue Apr 18 22:25:33 2017 +0200
@@ -1,5 +1,5 @@
 /*
-* Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
+* Copyright (c) 2016, 2017, Oracle and/or its affiliates. All rights reserved.
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 *
 * This code is free software; you can redistribute it and/or modify it
@@ -54,12 +54,12 @@
                             jstring location, const char* const* packages,
                             jsize num_packages, TRAPS);
 
-  // Provides the java.lang.reflect.Module for the unnamed module defined
+  // Provides the java.lang.Module for the unnamed module defined
   // to the boot loader.
   //
   //  IllegalArgumentExceptions are thrown for the following :
   //  * Module has a name
-  //  * Module is not a subclass of java.lang.reflect.Module
+  //  * Module is not a subclass of java.lang.Module
   //  * Module's class loader is not the boot loader
   //  NullPointerExceptions are thrown if module is null.
   static void set_bootloader_unnamed_module(jobject module, TRAPS);
@@ -95,10 +95,10 @@
   // module does not exist.
   static void add_reads_module(jobject from_module, jobject to_module, TRAPS);
 
-  // Return the java.lang.reflect.Module object for this class object.
+  // Return the java.lang.Module object for this class object.
   static jobject get_module(jclass clazz, TRAPS);
 
-  // Return the java.lang.reflect.Module object for this class loader and package.
+  // Return the java.lang.Module object for this class loader and package.
   // Returns NULL if the class loader has not loaded any classes in the package.
   // The package should contain /'s, not .'s, as in java/lang, not java.lang.
   // NullPointerException is thrown if package is null.
@@ -107,7 +107,7 @@
   static jobject get_named_module(Handle h_loader, const char* package, TRAPS);
 
   // If package is defined by loader, return the
-  // java.lang.reflect.Module object for the module in which the package is defined.
+  // java.lang.Module object for the module in which the package is defined.
   // Returns NULL if package is invalid or not defined by loader.
   static jobject get_module(Symbol* package_name, Handle h_loader, TRAPS);
 
--- a/hotspot/src/share/vm/classfile/systemDictionary.hpp	Tue Apr 18 13:19:42 2017 -0400
+++ b/hotspot/src/share/vm/classfile/systemDictionary.hpp	Tue Apr 18 22:25:33 2017 +0200
@@ -133,9 +133,9 @@
   do_klass(Thread_klass,                                java_lang_Thread,                          Pre                 ) \
   do_klass(ThreadGroup_klass,                           java_lang_ThreadGroup,                     Pre                 ) \
   do_klass(Properties_klass,                            java_util_Properties,                      Pre                 ) \
+  do_klass(Module_klass,                                java_lang_Module,                          Pre                 ) \
   do_klass(reflect_AccessibleObject_klass,              java_lang_reflect_AccessibleObject,        Pre                 ) \
   do_klass(reflect_Field_klass,                         java_lang_reflect_Field,                   Pre                 ) \
-  do_klass(reflect_Module_klass,                        java_lang_reflect_Module,                  Pre                 ) \
   do_klass(reflect_Parameter_klass,                     java_lang_reflect_Parameter,               Opt                 ) \
   do_klass(reflect_Method_klass,                        java_lang_reflect_Method,                  Pre                 ) \
   do_klass(reflect_Constructor_klass,                   java_lang_reflect_Constructor,             Pre                 ) \
--- a/hotspot/src/share/vm/classfile/vmSymbols.hpp	Tue Apr 18 13:19:42 2017 -0400
+++ b/hotspot/src/share/vm/classfile/vmSymbols.hpp	Tue Apr 18 22:25:33 2017 +0200
@@ -56,6 +56,7 @@
   template(java_lang_Object,                          "java/lang/Object")                         \
   template(java_lang_Class,                           "java/lang/Class")                          \
   template(java_lang_Package,                         "java/lang/Package")                        \
+  template(java_lang_Module,                          "java/lang/Module")                         \
   template(java_lang_String,                          "java/lang/String")                         \
   template(java_lang_StringLatin1,                    "java/lang/StringLatin1")                   \
   template(java_lang_StringUTF16,                     "java/lang/StringUTF16")                    \
@@ -90,7 +91,6 @@
   template(java_lang_reflect_Method,                  "java/lang/reflect/Method")                 \
   template(java_lang_reflect_Constructor,             "java/lang/reflect/Constructor")            \
   template(java_lang_reflect_Field,                   "java/lang/reflect/Field")                  \
-  template(java_lang_reflect_Module,                  "java/lang/reflect/Module")                 \
   template(java_lang_reflect_Parameter,               "java/lang/reflect/Parameter")              \
   template(java_lang_reflect_Array,                   "java/lang/reflect/Array")                  \
   template(java_lang_StringBuffer,                    "java/lang/StringBuffer")                   \
@@ -136,7 +136,7 @@
   template(initPhase1_name,                           "initPhase1")                               \
   template(initPhase2_name,                           "initPhase2")                               \
   template(initPhase3_name,                           "initPhase3")                               \
-  template(java_lang_reflect_module_init_signature,   "(Ljava/lang/ClassLoader;Ljava/lang/String;)V") \
+  template(java_lang_module_init_signature,           "(Ljava/lang/ClassLoader;Ljava/lang/String;)V") \
                                                                                                   \
   /* class file format tags */                                                                    \
   template(tag_source_file,                           "SourceFile")                               \
@@ -450,7 +450,7 @@
   template(getModule_name,                            "getModule")                                \
   template(input_stream_void_signature,               "(Ljava/io/InputStream;)V")                 \
   template(definePackage_name,                        "definePackage")                            \
-  template(definePackage_signature,                   "(Ljava/lang/String;Ljava/lang/reflect/Module;)Ljava/lang/Package;") \
+  template(definePackage_signature,                   "(Ljava/lang/String;Ljava/lang/Module;)Ljava/lang/Package;") \
   template(defineOrCheckPackage_name,                 "defineOrCheckPackage")                     \
   template(defineOrCheckPackage_signature,            "(Ljava/lang/String;Ljava/util/jar/Manifest;Ljava/net/URL;)Ljava/lang/Package;") \
   template(fileToEncodedURL_name,                     "fileToEncodedURL")                         \
@@ -532,7 +532,7 @@
   template(void_class_signature,                      "()Ljava/lang/Class;")                                      \
   template(void_class_array_signature,                "()[Ljava/lang/Class;")                                     \
   template(void_string_signature,                     "()Ljava/lang/String;")                                     \
-  template(void_module_signature,                     "()Ljava/lang/reflect/Module;")                             \
+  template(void_module_signature,                     "()Ljava/lang/Module;")                                     \
   template(object_array_object_signature,             "([Ljava/lang/Object;)Ljava/lang/Object;")                  \
   template(object_object_array_object_signature,      "(Ljava/lang/Object;[Ljava/lang/Object;)Ljava/lang/Object;")\
   template(exception_void_signature,                  "(Ljava/lang/Exception;)V")                                 \
@@ -552,7 +552,7 @@
   template(reference_signature,                       "Ljava/lang/ref/Reference;")                                \
   template(sun_misc_Cleaner_signature,                "Lsun/misc/Cleaner;")                                       \
   template(executable_signature,                      "Ljava/lang/reflect/Executable;")                           \
-  template(module_signature,                          "Ljava/lang/reflect/Module;")                               \
+  template(module_signature,                          "Ljava/lang/Module;")                                       \
   template(concurrenthashmap_signature,               "Ljava/util/concurrent/ConcurrentHashMap;")                 \
   template(String_StringBuilder_signature,            "(Ljava/lang/String;)Ljava/lang/StringBuilder;")            \
   template(int_StringBuilder_signature,               "(I)Ljava/lang/StringBuilder;")                             \
@@ -642,16 +642,16 @@
   template(jdk_internal_module_Modules,                "jdk/internal/module/Modules")                             \
   template(jdk_internal_vm_VMSupport,                  "jdk/internal/vm/VMSupport")                               \
   template(addReads_name,                              "addReads")                                                \
-  template(addReads_signature,                         "(Ljava/lang/reflect/Module;Ljava/lang/reflect/Module;)V") \
+  template(addReads_signature,                         "(Ljava/lang/Module;Ljava/lang/Module;)V")                 \
   template(addExports_name,                            "addExports")                                              \
   template(addOpens_name,                              "addOpens")                                                \
-  template(addExports_signature,                       "(Ljava/lang/reflect/Module;Ljava/lang/String;Ljava/lang/reflect/Module;)V") \
+  template(addExports_signature,                       "(Ljava/lang/Module;Ljava/lang/String;Ljava/lang/Module;)V") \
   template(addUses_name,                               "addUses")                                                 \
-  template(addUses_signature,                          "(Ljava/lang/reflect/Module;Ljava/lang/Class;)V")          \
+  template(addUses_signature,                          "(Ljava/lang/Module;Ljava/lang/Class;)V")                  \
   template(addProvides_name,                           "addProvides")                                             \
-  template(addProvides_signature,                      "(Ljava/lang/reflect/Module;Ljava/lang/Class;Ljava/lang/Class;)V") \
+  template(addProvides_signature,                      "(Ljava/lang/Module;Ljava/lang/Class;Ljava/lang/Class;)V") \
   template(transformedByAgent_name,                    "transformedByAgent")                                      \
-  template(transformedByAgent_signature,               "(Ljava/lang/reflect/Module;)V")                           \
+  template(transformedByAgent_signature,               "(Ljava/lang/Module;)V")                                   \
   template(appendToClassPathForInstrumentation_name,   "appendToClassPathForInstrumentation")                     \
   do_alias(appendToClassPathForInstrumentation_signature, string_void_signature)                                  \
   template(serializePropertiesToByteArray_name,        "serializePropertiesToByteArray")                          \
--- a/hotspot/src/share/vm/gc/parallel/gcTaskThread.cpp	Tue Apr 18 13:19:42 2017 -0400
+++ b/hotspot/src/share/vm/gc/parallel/gcTaskThread.cpp	Tue Apr 18 22:25:33 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2002, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2002, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -54,8 +54,26 @@
   }
 }
 
+void GCTaskThread::add_task_timestamp(const char* name, jlong t_entry, jlong t_exit) {
+  if (_time_stamp_index < GCTaskTimeStampEntries) {
+    GCTaskTimeStamp* time_stamp = time_stamp_at(_time_stamp_index);
+    time_stamp->set_name(name);
+    time_stamp->set_entry_time(t_entry);
+    time_stamp->set_exit_time(t_exit);
+  } else {
+    if (_time_stamp_index ==  GCTaskTimeStampEntries) {
+      log_warning(gc, task, time)("GC-thread %u: Too many timestamps, ignoring future ones. "
+                                  "Increase GCTaskTimeStampEntries to get more info.",
+                                  id());
+    }
+    // Let _time_stamp_index keep counting to give the user an idea about how many
+    // are needed.
+  }
+  _time_stamp_index++;
+}
+
 GCTaskTimeStamp* GCTaskThread::time_stamp_at(uint index) {
-  guarantee(index < GCTaskTimeStampEntries, "increase GCTaskTimeStampEntries");
+  assert(index < GCTaskTimeStampEntries, "Precondition");
   if (_time_stamps == NULL) {
     // We allocate the _time_stamps array lazily since logging can be enabled dynamically
     GCTaskTimeStamp* time_stamps = NEW_C_HEAP_ARRAY(GCTaskTimeStamp, GCTaskTimeStampEntries, mtGC);
@@ -65,7 +83,6 @@
       FREE_C_HEAP_ARRAY(GCTaskTimeStamp, time_stamps);
     }
   }
-
   return &(_time_stamps[index]);
 }
 
@@ -75,8 +92,11 @@
   // Since _time_stamps is now lazily allocated we need to check that it
   // has in fact been allocated when calling this function.
   if (_time_stamps != NULL) {
-    log_debug(gc, task, time)("GC-Thread %u entries: %d", id(), _time_stamp_index);
-    for(uint i=0; i<_time_stamp_index; i++) {
+    log_debug(gc, task, time)("GC-Thread %u entries: %d%s", id(),
+                              _time_stamp_index,
+                              _time_stamp_index >= GCTaskTimeStampEntries ? " (overflow)" : "");
+    const uint max_index = MIN2(_time_stamp_index, GCTaskTimeStampEntries);
+    for (uint i = 0; i < max_index; i++) {
       GCTaskTimeStamp* time_stamp = time_stamp_at(i);
       log_debug(gc, task, time)("\t[ %s " JLONG_FORMAT " " JLONG_FORMAT " ]",
                                 time_stamp->name(),
@@ -144,16 +164,7 @@
 
         if (log_is_enabled(Debug, gc, task, time)) {
           timer.update();
-
-          GCTaskTimeStamp* time_stamp = time_stamp_at(_time_stamp_index);
-
-          time_stamp->set_name(name);
-          time_stamp->set_entry_time(entry_time);
-          time_stamp->set_exit_time(timer.ticks());
-
-          // Update the index after we have set up the entry correctly since
-          // GCTaskThread::print_task_time_stamps() may read this value concurrently.
-          _time_stamp_index++;
+          add_task_timestamp(name, entry_time, timer.ticks());
         }
       } else {
         // idle tasks complete outside the normal accounting
--- a/hotspot/src/share/vm/gc/parallel/gcTaskThread.hpp	Tue Apr 18 13:19:42 2017 -0400
+++ b/hotspot/src/share/vm/gc/parallel/gcTaskThread.hpp	Tue Apr 18 22:25:33 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2002, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2002, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -45,6 +45,7 @@
   uint _time_stamp_index;
 
   GCTaskTimeStamp* time_stamp_at(uint index);
+  void add_task_timestamp(const char* name, jlong t_entry, jlong t_exit);
 
   bool _is_working;                     // True if participating in GC tasks
 
@@ -92,16 +93,16 @@
  private:
   jlong  _entry_time;
   jlong  _exit_time;
-  char*  _name;
+  const char*  _name;
 
  public:
   jlong entry_time()              { return _entry_time; }
   jlong exit_time()               { return _exit_time; }
-  const char* name() const        { return (const char*)_name; }
+  const char* name() const        { return _name; }
 
   void set_entry_time(jlong time) { _entry_time = time; }
   void set_exit_time(jlong time)  { _exit_time = time; }
-  void set_name(char* name)       { _name = name; }
+  void set_name(const char* name) { _name = name; }
 };
 
 #endif // SHARE_VM_GC_PARALLEL_GCTASKTHREAD_HPP
--- a/hotspot/src/share/vm/oops/constMethod.hpp	Tue Apr 18 13:19:42 2017 -0400
+++ b/hotspot/src/share/vm/oops/constMethod.hpp	Tue Apr 18 22:25:33 2017 +0200
@@ -359,7 +359,9 @@
   }
 
   // Sizing
-  static int header_size() { return sizeof(ConstMethod)/wordSize; }
+  static int header_size() {
+    return align_size_up(sizeof(ConstMethod), wordSize) / wordSize;
+  }
 
   // Size needed
   static int size(int code_size, InlineTableSizes* sizes);
--- a/hotspot/src/share/vm/oops/constantPool.hpp	Tue Apr 18 13:19:42 2017 -0400
+++ b/hotspot/src/share/vm/oops/constantPool.hpp	Tue Apr 18 22:25:33 2017 +0200
@@ -705,7 +705,9 @@
   }
 
   // Sizing (in words)
-  static int header_size()             { return sizeof(ConstantPool)/wordSize; }
+  static int header_size()             {
+    return align_size_up(sizeof(ConstantPool), wordSize) / wordSize;
+  }
   static int size(int length)          { return align_metadata_size(header_size() + length); }
   int size() const                     { return size(length()); }
 #if INCLUDE_SERVICES
--- a/hotspot/src/share/vm/oops/cpCache.hpp	Tue Apr 18 13:19:42 2017 -0400
+++ b/hotspot/src/share/vm/oops/cpCache.hpp	Tue Apr 18 22:25:33 2017 +0200
@@ -359,7 +359,9 @@
                                                    return (TosState)((_flags >> tos_state_shift) & tos_state_mask); }
 
   // Code generation support
-  static WordSize size()                         { return in_WordSize(sizeof(ConstantPoolCacheEntry) / wordSize); }
+  static WordSize size()                         {
+    return in_WordSize(align_size_up(sizeof(ConstantPoolCacheEntry), wordSize) / wordSize);
+  }
   static ByteSize size_in_bytes()                { return in_ByteSize(sizeof(ConstantPoolCacheEntry)); }
   static ByteSize indices_offset()               { return byte_offset_of(ConstantPoolCacheEntry, _indices); }
   static ByteSize f1_offset()                    { return byte_offset_of(ConstantPoolCacheEntry, _f1); }
--- a/hotspot/src/share/vm/oops/klass.cpp	Tue Apr 18 13:19:42 2017 -0400
+++ b/hotspot/src/share/vm/oops/klass.cpp	Tue Apr 18 22:25:33 2017 +0200
@@ -532,7 +532,7 @@
     } else {
       module_entry = ModuleEntryTable::javabase_moduleEntry();
     }
-    // Obtain java.lang.reflect.Module, if available
+    // Obtain java.lang.Module, if available
     Handle module_handle(THREAD, ((module_entry != NULL) ? JNIHandles::resolve(module_entry->module()) : (oop)NULL));
     java_lang_Class::create_mirror(this, loader, module_handle, protection_domain, CHECK);
   }
--- a/hotspot/src/share/vm/oops/method.hpp	Tue Apr 18 13:19:42 2017 -0400
+++ b/hotspot/src/share/vm/oops/method.hpp	Tue Apr 18 22:25:33 2017 +0200
@@ -666,7 +666,9 @@
 #endif
 
   // sizing
-  static int header_size()                       { return sizeof(Method)/wordSize; }
+  static int header_size()                       {
+    return align_size_up(sizeof(Method), wordSize) / wordSize;
+  }
   static int size(bool is_native);
   int size() const                               { return method_size(); }
 #if INCLUDE_SERVICES
--- a/hotspot/src/share/vm/oops/methodCounters.hpp	Tue Apr 18 13:19:42 2017 -0400
+++ b/hotspot/src/share/vm/oops/methodCounters.hpp	Tue Apr 18 22:25:33 2017 +0200
@@ -116,7 +116,9 @@
 
   AOT_ONLY(Method* method() const { return _method; })
 
-  static int size() { return sizeof(MethodCounters) / wordSize; }
+  static int size() {
+    return align_size_up(sizeof(MethodCounters), wordSize) / wordSize;
+  }
 
   bool is_klass() const { return false; }
 
--- a/hotspot/src/share/vm/prims/jvmti.xml	Tue Apr 18 13:19:42 2017 -0400
+++ b/hotspot/src/share/vm/prims/jvmti.xml	Tue Apr 18 22:25:33 2017 +0200
@@ -6516,7 +6516,7 @@
     <function id="GetNamedModule" num="40" since="9">
       <synopsis>Get Named Module</synopsis>
       <description>
-        Return the <code>java.lang.reflect.Module</code> object for a named
+        Return the <code>java.lang.Module</code> object for a named
         module defined to a class loader that contains a given package.
         The module is returned via <code>module_ptr</code>.
         <p/>
@@ -6554,7 +6554,7 @@
         <param id="module_ptr">
           <outptr><jobject/></outptr>
           <description>
-            On return, points to a <code>java.lang.reflect.Module</code> object
+            On return, points to a <code>java.lang.Module</code> object
             or points to <code>NULL</code>.
           </description>
         </param>
@@ -6599,6 +6599,10 @@
         <error id="JVMTI_ERROR_INVALID_MODULE">
           If <paramlink id="to_module"></paramlink> is not a module object.
         </error>
+        <error id="JVMTI_ERROR_UNMODIFIABLE_MODULE">
+          if the module cannot be modified.
+          See <functionlink id="IsModifiableModule"/>.
+        </error>
       </errors>
     </function>
 
@@ -6633,7 +6637,7 @@
           <description>
             The module the package is exported to.
             If the <code>to_module</code> is not a subclass of
-            <code>java.lang.reflect.Module</code> this function returns
+            <code>java.lang.Module</code> this function returns
             <errorlink id="JVMTI_ERROR_INVALID_MODULE"></errorlink>.
           </description>
         </param>
@@ -6649,6 +6653,10 @@
           If the package <paramlink id="pkg_name"></paramlink>
           does not belong to the module.
         </error>
+        <error id="JVMTI_ERROR_UNMODIFIABLE_MODULE">
+          if the module cannot be modified.
+          See <functionlink id="IsModifiableModule"/>.
+        </error>
       </errors>
     </function>
 
@@ -6684,7 +6692,7 @@
           <description>
             The module with the package to open.
             If the <code>to_module</code> is not a subclass of
-            <code>java.lang.reflect.Module</code> this function returns
+            <code>java.lang.Module</code> this function returns
             <errorlink id="JVMTI_ERROR_INVALID_MODULE"></errorlink>.
           </description>
         </param>
@@ -6700,6 +6708,10 @@
           If the package <paramlink id="pkg_name"></paramlink>
           does not belong to the module.
         </error>
+        <error id="JVMTI_ERROR_UNMODIFIABLE_MODULE">
+          if the module cannot be modified.
+          See <functionlink id="IsModifiableModule"/>.
+        </error>
       </errors>
     </function>
 
@@ -6737,6 +6749,10 @@
         <error id="JVMTI_ERROR_INVALID_CLASS">
           If <paramlink id="service"></paramlink> is not a class object.
         </error>
+        <error id="JVMTI_ERROR_UNMODIFIABLE_MODULE">
+          if the module cannot be modified.
+          See <functionlink id="IsModifiableModule"/>.
+        </error>
       </errors>
     </function>
 
@@ -6783,6 +6799,44 @@
         <error id="JVMTI_ERROR_INVALID_CLASS">
           If <paramlink id="impl_class"></paramlink> is not a class object.
         </error>
+        <error id="JVMTI_ERROR_UNMODIFIABLE_MODULE">
+          if the module cannot be modified.
+          See <functionlink id="IsModifiableModule"/>.
+        </error>
+      </errors>
+    </function>
+
+    <function id="IsModifiableModule" num="99" since="9">
+      <synopsis>Is Modifiable Module</synopsis>
+      <description>
+        Determines whether a module is modifiable.
+        If a module is modifiable then this module can be updated with
+        <functionlink id="AddModuleReads"/>, <functionlink id="AddModuleExports"/>,
+        <functionlink id="AddModuleOpens"/>, <functionlink id="AddModuleUses"/>,
+        and <functionlink id="AddModuleProvides"/>. If a module is not modifiable
+        then the module can not be updated with these functions.
+      </description>
+      <origin>new</origin>
+      <capabilities>
+      </capabilities>
+      <parameters>
+        <param id="module">
+          <ptrtype><jobject/></ptrtype>
+          <description>
+            The module to query.
+          </description>
+        </param>
+        <param id="is_modifiable_module_ptr">
+          <outptr><jboolean/></outptr>
+          <description>
+            On return, points to the boolean result of this function.
+          </description>
+        </param>
+      </parameters>
+      <errors>
+        <error id="JVMTI_ERROR_INVALID_MODULE">
+          If <paramlink id="module"></paramlink> is not a module object.
+        </error>
       </errors>
     </function>
 
@@ -7803,6 +7857,10 @@
 	  A method in the new class version has different modifiers
 	  than its counterpart in the old class version.
 	</error>
+        <error id="JVMTI_ERROR_UNMODIFIABLE_MODULE">
+          A module cannot be modified.
+          See <functionlink id="IsModifiableModule"/>.
+        </error>
       </errors>
     </function>
 
@@ -11567,6 +11625,9 @@
     <errorid id="JVMTI_ERROR_UNMODIFIABLE_CLASS" num="79">
       The class cannot be modified.
     </errorid>
+    <errorid id="JVMTI_ERROR_UNMODIFIABLE_MODULE" num="80">
+      The module cannot be modified.
+    </errorid>
     <errorid id="JVMTI_ERROR_NOT_AVAILABLE" num="98">
       The functionality is not available in this virtual machine.
     </errorid>
@@ -14736,6 +14797,7 @@
        - Add new functions:
           - GetAllModules
           - AddModuleReads, AddModuleExports, AddModuleOpens, AddModuleUses, AddModuleProvides
+          - IsModifiableModule
       Clarified can_redefine_any_classes, can_retransform_any_classes and IsModifiableClass API to
       disallow some implementation defined classes.
   </change>
--- a/hotspot/src/share/vm/prims/jvmtiEnv.cpp	Tue Apr 18 13:19:42 2017 -0400
+++ b/hotspot/src/share/vm/prims/jvmtiEnv.cpp	Tue Apr 18 22:25:33 2017 +0200
@@ -235,12 +235,12 @@
 
   // check module
   Handle h_module(THREAD, JNIHandles::resolve(module));
-  if (!java_lang_reflect_Module::is_instance(h_module())) {
+  if (!java_lang_Module::is_instance(h_module())) {
     return JVMTI_ERROR_INVALID_MODULE;
   }
   // check to_module
   Handle h_to_module(THREAD, JNIHandles::resolve(to_module));
-  if (!java_lang_reflect_Module::is_instance(h_to_module())) {
+  if (!java_lang_Module::is_instance(h_to_module())) {
     return JVMTI_ERROR_INVALID_MODULE;
   }
   return JvmtiExport::add_module_reads(h_module, h_to_module, THREAD);
@@ -257,12 +257,12 @@
 
   // check module
   Handle h_module(THREAD, JNIHandles::resolve(module));
-  if (!java_lang_reflect_Module::is_instance(h_module())) {
+  if (!java_lang_Module::is_instance(h_module())) {
     return JVMTI_ERROR_INVALID_MODULE;
   }
   // check to_module
   Handle h_to_module(THREAD, JNIHandles::resolve(to_module));
-  if (!java_lang_reflect_Module::is_instance(h_to_module())) {
+  if (!java_lang_Module::is_instance(h_to_module())) {
     return JVMTI_ERROR_INVALID_MODULE;
   }
   return JvmtiExport::add_module_exports(h_module, h_pkg, h_to_module, THREAD);
@@ -279,12 +279,12 @@
 
   // check module
   Handle h_module(THREAD, JNIHandles::resolve(module));
-  if (!java_lang_reflect_Module::is_instance(h_module())) {
+  if (!java_lang_Module::is_instance(h_module())) {
     return JVMTI_ERROR_INVALID_MODULE;
   }
   // check to_module
   Handle h_to_module(THREAD, JNIHandles::resolve(to_module));
-  if (!java_lang_reflect_Module::is_instance(h_to_module())) {
+  if (!java_lang_Module::is_instance(h_to_module())) {
     return JVMTI_ERROR_INVALID_MODULE;
   }
   return JvmtiExport::add_module_opens(h_module, h_pkg, h_to_module, THREAD);
@@ -299,7 +299,7 @@
 
   // check module
   Handle h_module(THREAD, JNIHandles::resolve(module));
-  if (!java_lang_reflect_Module::is_instance(h_module())) {
+  if (!java_lang_Module::is_instance(h_module())) {
     return JVMTI_ERROR_INVALID_MODULE;
   }
   // check service
@@ -321,7 +321,7 @@
 
   // check module
   Handle h_module(THREAD, JNIHandles::resolve(module));
-  if (!java_lang_reflect_Module::is_instance(h_module())) {
+  if (!java_lang_Module::is_instance(h_module())) {
     return JVMTI_ERROR_INVALID_MODULE;
   }
   // check service
@@ -339,6 +339,22 @@
   return JvmtiExport::add_module_provides(h_module, h_service, h_impl_class, THREAD);
 } /* end AddModuleProvides */
 
+// module - pre-checked for NULL
+// is_modifiable_class_ptr - pre-checked for NULL
+jvmtiError
+JvmtiEnv::IsModifiableModule(jobject module, jboolean* is_modifiable_module_ptr) {
+  JavaThread* THREAD = JavaThread::current();
+
+  // check module
+  Handle h_module(THREAD, JNIHandles::resolve(module));
+  if (!java_lang_Module::is_instance(h_module())) {
+    return JVMTI_ERROR_INVALID_MODULE;
+  }
+
+  *is_modifiable_module_ptr = JNI_TRUE;
+  return JVMTI_ERROR_NONE;
+} /* end IsModifiableModule */
+
 
   //
   // Class functions
--- a/hotspot/src/share/vm/runtime/globals.hpp	Tue Apr 18 13:19:42 2017 -0400
+++ b/hotspot/src/share/vm/runtime/globals.hpp	Tue Apr 18 22:25:33 2017 +0200
@@ -1453,9 +1453,9 @@
           "Number of threads concurrent gc will use")                       \
           constraint(ConcGCThreadsConstraintFunc,AfterErgo)                 \
                                                                             \
-  product(uintx, GCTaskTimeStampEntries, 200,                               \
+  product(uint, GCTaskTimeStampEntries, 200,                                \
           "Number of time stamp entries per gc worker thread")              \
-          range(1, max_uintx)                                               \
+          range(1, max_jint)                                                \
                                                                             \
   product(bool, AlwaysTenure, false,                                        \
           "Always tenure objects in eden (ParallelGC only)")                \
--- a/hotspot/src/share/vm/runtime/reflection.cpp	Tue Apr 18 13:19:42 2017 -0400
+++ b/hotspot/src/share/vm/runtime/reflection.cpp	Tue Apr 18 22:25:33 2017 +0200
@@ -587,9 +587,9 @@
           current_class_name, module_from_name, new_class_name,
           module_to_name, module_from_name, module_to_name);
       } else {
-        jobject jlrm = module_to->module();
-        assert(jlrm != NULL, "Null jlrm in module_to ModuleEntry");
-        intptr_t identity_hash = JNIHandles::resolve(jlrm)->identity_hash();
+        jobject jlm = module_to->module();
+        assert(jlm != NULL, "Null jlm in module_to ModuleEntry");
+        intptr_t identity_hash = JNIHandles::resolve(jlm)->identity_hash();
         size_t len = 160 + strlen(current_class_name) + 2*strlen(module_from_name) +
           strlen(new_class_name) + 2*sizeof(uintx);
         msg = NEW_RESOURCE_ARRAY(char, len);
@@ -614,9 +614,9 @@
           current_class_name, module_from_name, new_class_name,
           module_to_name, module_to_name, package_name, module_from_name);
       } else {
-        jobject jlrm = module_from->module();
-        assert(jlrm != NULL, "Null jlrm in module_from ModuleEntry");
-        intptr_t identity_hash = JNIHandles::resolve(jlrm)->identity_hash();
+        jobject jlm = module_from->module();
+        assert(jlm != NULL, "Null jlm in module_from ModuleEntry");
+        intptr_t identity_hash = JNIHandles::resolve(jlm)->identity_hash();
         size_t len = 170 + strlen(current_class_name) + strlen(new_class_name) +
           2*strlen(module_to_name) + strlen(package_name) + 2*sizeof(uintx);
         msg = NEW_RESOURCE_ARRAY(char, len);
--- a/hotspot/src/share/vm/runtime/thread.cpp	Tue Apr 18 13:19:42 2017 -0400
+++ b/hotspot/src/share/vm/runtime/thread.cpp	Tue Apr 18 22:25:33 2017 +0200
@@ -3462,7 +3462,7 @@
                                       java_lang_Thread::RUNNABLE);
 
   // The VM creates objects of this class.
-  initialize_class(vmSymbols::java_lang_reflect_Module(), CHECK);
+  initialize_class(vmSymbols::java_lang_Module(), CHECK);
 
   // The VM preresolves methods to these classes. Make sure that they get initialized
   initialize_class(vmSymbols::java_lang_reflect_Method(), CHECK);
--- a/hotspot/test/TEST.ROOT	Tue Apr 18 13:19:42 2017 -0400
+++ b/hotspot/test/TEST.ROOT	Tue Apr 18 22:25:33 2017 +0200
@@ -50,8 +50,8 @@
     vm.cpu.features \
     vm.debug
 
-# Tests using jtreg 4.2 b04 features
-requiredVersion=4.2 b04
+# Tests using jtreg 4.2 b07 features
+requiredVersion=4.2 b07
 
 # Path to libraries in the topmost test directory. This is needed so @library
 # does not need ../../ notation to reach them
--- a/hotspot/test/compiler/c2/cr7200264/TestDriver.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/hotspot/test/compiler/c2/cr7200264/TestDriver.java	Tue Apr 18 22:25:33 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2016, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -26,7 +26,6 @@
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
-import java.util.regex.Pattern;
 
 import jdk.test.lib.Asserts;
 import jdk.test.lib.process.OutputAnalyzer;
@@ -45,7 +44,7 @@
     }
 
     private List<String> executeApplication() throws Throwable {
-        OutputAnalyzer outputAnalyzer = ProcessTools.executeTestJvmAllArgs(
+        OutputAnalyzer outputAnalyzer = ProcessTools.executeTestJvm(
             "-Xbatch",
             "-XX:-TieredCompilation",
             "-XX:+PrintCompilation",
--- a/hotspot/test/compiler/compilercontrol/share/scenario/Executor.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/hotspot/test/compiler/compilercontrol/share/scenario/Executor.java	Tue Apr 18 22:25:33 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -25,6 +25,7 @@
 
 import compiler.compilercontrol.share.actions.BaseAction;
 import jdk.test.lib.Asserts;
+import jdk.test.lib.management.InputArguments;
 import jdk.test.lib.process.OutputAnalyzer;
 import jdk.test.lib.process.ProcessTools;
 import jdk.test.lib.dcmd.CommandExecutor;
@@ -38,6 +39,7 @@
 import java.net.ServerSocket;
 import java.net.Socket;
 import java.util.ArrayList;
+import java.util.Arrays;
 import java.util.Collections;
 import java.util.List;
 import java.util.Map;
@@ -97,9 +99,13 @@
                 // Start separate thread to connect with test VM
                 new Thread(() -> connectTestVM(serverSocket)).start();
             }
-            // Start test VM
-            output = ProcessTools.executeTestJvmAllArgs(
-                    vmOptions.toArray(new String[vmOptions.size()]));
+            // Start a test VM using vm flags from @run and from vm options
+            String[] vmInputArgs = InputArguments.getVmInputArgs();
+            String[] cmds = Arrays.copyOf(vmInputArgs,
+                    vmInputArgs.length + vmOptions.size());
+            System.arraycopy(vmOptions.toArray(), 0, cmds, vmInputArgs.length,
+                    vmOptions.size());
+            output = ProcessTools.executeTestJvm(cmds);
         } catch (Throwable thr) {
             throw new Error("Execution failed: " + thr.getMessage(), thr);
         }
--- a/hotspot/test/compiler/jvmci/common/CTVMUtilities.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/hotspot/test/compiler/jvmci/common/CTVMUtilities.java	Tue Apr 18 22:25:33 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -41,7 +41,6 @@
 import java.lang.reflect.Field;
 import java.lang.reflect.Method;
 import java.lang.reflect.Modifier;
-import java.lang.reflect.Module;
 import java.lang.reflect.Parameter;
 import java.util.HashMap;
 import java.util.Map;
--- a/hotspot/test/compiler/jvmci/compilerToVM/DebugOutputTest.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/hotspot/test/compiler/jvmci/compilerToVM/DebugOutputTest.java	Tue Apr 18 22:25:33 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -30,11 +30,9 @@
  * @modules java.base/jdk.internal.misc
  * @modules jdk.internal.vm.ci/jdk.vm.ci.hotspot
  * @build jdk.internal.vm.ci/jdk.vm.ci.hotspot.CompilerToVMHelper
- * @run main/othervm compiler.jvmci.compilerToVM.DebugOutputTest
+ * @run driver compiler.jvmci.compilerToVM.DebugOutputTest
  */
 
- // as soon as CODETOOLS-7901589 fixed, '@run main/othervm' should be replaced w/ '@run driver'
-
 package compiler.jvmci.compilerToVM;
 
 import jdk.test.lib.process.OutputAnalyzer;
@@ -42,8 +40,11 @@
 import jdk.vm.ci.hotspot.CompilerToVMHelper;
 
 import java.util.Arrays;
+import java.nio.file.Path;
+import java.nio.file.Paths;
 
 public class DebugOutputTest {
+    private static final String VM_CI_MODULE = "jdk.internal.vm.ci";
     public static void main(String[] args) {
         new DebugOutputTest().test();
     }
@@ -53,10 +54,18 @@
             System.out.println(testCase);
             OutputAnalyzer oa;
             try {
-                oa = ProcessTools.executeTestJvmAllArgs(
+                Path patch = Paths.get(System.getProperty("test.patch.path"));
+                Path jvmciPath = patch.resolve(VM_CI_MODULE).toAbsolutePath();
+                if (!jvmciPath.toFile().exists()) {
+                    throw new Error("TESTBUG: patch for " + VM_CI_MODULE + " : "
+                            + jvmciPath.toString() + " does not exist");
+                }
+                oa = ProcessTools.executeTestJvm(
                         "-XX:+UnlockExperimentalVMOptions",
                         "-XX:+EnableJVMCI",
-                        "-Xbootclasspath/a:.",
+                        "--add-exports", "java.base/jdk.internal.misc=ALL-UNNAMED",
+                        "--add-exports", "jdk.internal.vm.ci/jdk.vm.ci.hotspot=ALL-UNNAMED",
+                        "--patch-module", VM_CI_MODULE + "=" + jvmciPath.toString(),
                         DebugOutputTest.Worker.class.getName(),
                         testCase.name());
                } catch (Throwable e) {
--- a/hotspot/test/compiler/jvmci/jdk.vm.ci.hotspot.test/src/jdk/vm/ci/hotspot/test/MemoryAccessProviderData.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/hotspot/test/compiler/jvmci/jdk.vm.ci.hotspot.test/src/jdk/vm/ci/hotspot/test/MemoryAccessProviderData.java	Tue Apr 18 22:25:33 2017 +0200
@@ -27,6 +27,7 @@
 
 import org.testng.annotations.DataProvider;
 
+import sun.hotspot.WhiteBox;
 import jdk.internal.misc.Unsafe;
 import jdk.vm.ci.hotspot.HotSpotConstantReflectionProvider;
 import jdk.vm.ci.hotspot.HotSpotJVMCIRuntimeProvider;
@@ -36,6 +37,10 @@
 import jdk.vm.ci.meta.JavaConstant;
 import jdk.vm.ci.meta.JavaKind;
 import jdk.vm.ci.runtime.JVMCI;
+import java.util.List;
+import java.util.ArrayList;
+import java.util.Map;
+import java.util.HashMap;
 
 public class MemoryAccessProviderData {
     private static final Unsafe UNSAFE = Unsafe.getUnsafe();
@@ -43,6 +48,18 @@
     private static final TestClass TEST_OBJECT = new TestClass();
     private static final JavaConstant TEST_CONSTANT = CONSTANT_REFLECTION.forObject(TEST_OBJECT);
     private static final JavaConstant TEST_CLASS_CONSTANT = CONSTANT_REFLECTION.forObject(TestClass.class);
+    private static KindData[] PRIMITIVE_KIND_DATA = {
+        new KindData(JavaKind.Boolean, TEST_OBJECT),
+        new KindData(JavaKind.Byte, TEST_OBJECT),
+        new KindData(JavaKind.Char, TEST_OBJECT),
+        new KindData(JavaKind.Short, TEST_OBJECT),
+        new KindData(JavaKind.Int, TEST_OBJECT),
+        new KindData(JavaKind.Float, TEST_OBJECT),
+        new KindData(JavaKind.Long, TEST_OBJECT),
+        new KindData(JavaKind.Double, TEST_OBJECT)
+    };
+    private static final WhiteBox WHITE_BOX = WhiteBox.getWhiteBox();
+
 
     @DataProvider(name = "positiveObject")
     public static Object[][] getPositiveObjectJavaKind() {
@@ -54,51 +71,40 @@
 
     @DataProvider(name = "positivePrimitive")
     public static Object[][] getPositivePrimitiveJavaKinds() {
-        Field booleanField;
-        Field byteField;
-        Field shortField;
-        Field intField;
-        Field longField;
-        Field floatField;
-        Field doubleField;
-        Field charField;
-        try {
-            booleanField = MemoryAccessProviderData.TestClass.class.getDeclaredField("booleanField");
-            byteField = MemoryAccessProviderData.TestClass.class.getDeclaredField("byteField");
-            shortField = MemoryAccessProviderData.TestClass.class.getDeclaredField("shortField");
-            intField = MemoryAccessProviderData.TestClass.class.getDeclaredField("intField");
-            longField = MemoryAccessProviderData.TestClass.class.getDeclaredField("longField");
-            floatField = MemoryAccessProviderData.TestClass.class.getDeclaredField("floatField");
-            doubleField = MemoryAccessProviderData.TestClass.class.getDeclaredField("doubleField");
-            charField = MemoryAccessProviderData.TestClass.class.getDeclaredField("charField");
-        } catch (NoSuchFieldException e) {
-            throw new Error("TESTBUG: can't find test field " + e, e);
+        List<Object[]> result = new ArrayList<>();
+        for (KindData k : PRIMITIVE_KIND_DATA) {
+            result.add(new Object[] {k.kind, TEST_CONSTANT, k.instanceFieldOffset, k.instanceFieldValue, Math.max(8, k.kind.getBitCount())});
+            result.add(new Object[] {k.kind, TEST_CLASS_CONSTANT, k.staticFieldOffset, k.staticFieldValue, Math.max(8, k.kind.getBitCount())});
         }
-        long booleanFieldOffset = UNSAFE.objectFieldOffset(booleanField);
-        long byteFieldOffset = UNSAFE.objectFieldOffset(byteField);
-        long shortFieldOffset = UNSAFE.objectFieldOffset(shortField);
-        long intFieldOffset = UNSAFE.objectFieldOffset(intField);
-        long longFieldOffset = UNSAFE.objectFieldOffset(longField);
-        long floatFieldOffset = UNSAFE.objectFieldOffset(floatField);
-        long doubleFieldOffset = UNSAFE.objectFieldOffset(doubleField);
-        long charFieldOffset = UNSAFE.objectFieldOffset(charField);
-        return new Object[][]{
-                        new Object[]{JavaKind.Boolean, TEST_CONSTANT, booleanFieldOffset,
-                                        JavaConstant.forBoolean(TEST_OBJECT.booleanField), 8},
-                        new Object[]{JavaKind.Byte, TEST_CONSTANT, byteFieldOffset,
-                                        JavaConstant.forByte(TEST_OBJECT.byteField), 8},
-                        new Object[]{JavaKind.Short, TEST_CONSTANT, shortFieldOffset,
-                                        JavaConstant.forShort(TEST_OBJECT.shortField), 16},
-                        new Object[]{JavaKind.Int, TEST_CONSTANT, intFieldOffset,
-                                        JavaConstant.forInt(TEST_OBJECT.intField), 32},
-                        new Object[]{JavaKind.Long, TEST_CONSTANT, longFieldOffset,
-                                        JavaConstant.forLong(TEST_OBJECT.longField), 64},
-                        new Object[]{JavaKind.Float, TEST_CONSTANT, floatFieldOffset,
-                                        JavaConstant.forFloat(TEST_OBJECT.floatField), 32},
-                        new Object[]{JavaKind.Double, TEST_CONSTANT, doubleFieldOffset,
-                                        JavaConstant.forDouble(TEST_OBJECT.doubleField), 64},
-                        new Object[]{JavaKind.Char, TEST_CONSTANT, charFieldOffset,
-                                        JavaConstant.forChar(TEST_OBJECT.charField), 16}};
+        return result.toArray(new Object[result.size()][]);
+    }
+
+    @DataProvider(name = "outOfBoundsInstanceFields")
+    public static Object[][] getOutOfBoundsStaticFieldReads() {
+        long instanceSize = WHITE_BOX.getObjectSize(TEST_OBJECT);
+        List<Object[]> result = new ArrayList<>();
+        for (KindData k : PRIMITIVE_KIND_DATA) {
+            long lastValidOffset = instanceSize - (k.kind.getByteCount());
+            result.add(new Object[] {k.kind, TEST_CONSTANT, lastValidOffset, false});
+            result.add(new Object[] {k.kind, TEST_CONSTANT, (long) -1, true});
+            result.add(new Object[] {k.kind, TEST_CONSTANT, lastValidOffset + 1, true});
+            result.add(new Object[] {k.kind, TEST_CONSTANT, lastValidOffset + 100, true});
+        }
+        return result.toArray(new Object[result.size()][]);
+    }
+
+    @DataProvider(name = "outOfBoundsStaticFields")
+    public static Object[][] getOutOfBoundsInstanceFieldReads() {
+        long staticsSize = WHITE_BOX.getObjectSize(TEST_OBJECT.getClass());
+        List<Object[]> result = new ArrayList<>();
+        for (KindData k : PRIMITIVE_KIND_DATA) {
+            long lastValidOffset = staticsSize - (k.kind.getByteCount());
+            result.add(new Object[] {k.kind, TEST_CLASS_CONSTANT, lastValidOffset, false});
+            result.add(new Object[] {k.kind, TEST_CLASS_CONSTANT, (long) -1, true});
+            result.add(new Object[] {k.kind, TEST_CLASS_CONSTANT, lastValidOffset + 1, true});
+            result.add(new Object[] {k.kind, TEST_CLASS_CONSTANT, lastValidOffset + 100, true});
+        }
+        return result.toArray(new Object[result.size()][]);
     }
 
     @DataProvider(name = "negative")
@@ -108,6 +114,7 @@
                         new Object[]{JavaKind.Illegal, JavaConstant.INT_1}};
     }
 
+
     private static class TestClass {
         public final boolean booleanField = true;
         public final byte byteField = 2;
@@ -117,6 +124,43 @@
         public final double doubleField = 6.0d;
         public final float floatField = 7.0f;
         public final char charField = 'a';
-        public final String stringField = "abc";
+        public final String objectField = "abc";
+
+        public static final boolean booleanStaticField = true;
+        public static final byte byteStaticField = 2;
+        public static final short shortStaticField = 3;
+        public static final int intStaticField = 4;
+        public static final long longStaticField = 5L;
+        public static final double doubleStaticField = 6.0d;
+        public static final float floatStaticField = 7.0f;
+        public static final char charStaticField = 'a';
+        public static final String objectStaticField = "abc";
+    }
+
+
+    static class KindData {
+        final JavaKind kind;
+        final Field instanceField;
+        final Field staticField;
+        final long instanceFieldOffset;
+        final long staticFieldOffset;
+        final JavaConstant instanceFieldValue;
+        final JavaConstant staticFieldValue;
+        KindData(JavaKind kind, Object testObject) {
+            this.kind = kind;
+            try {
+                Class<?> c = testObject.getClass();
+                instanceField = c.getDeclaredField(kind.getJavaName() + "Field");
+                staticField = c.getDeclaredField(kind.getJavaName() + "StaticField");
+                instanceField.setAccessible(true);
+                staticField.setAccessible(true);
+                instanceFieldOffset = UNSAFE.objectFieldOffset(instanceField);
+                staticFieldOffset = UNSAFE.staticFieldOffset(staticField);
+                instanceFieldValue = JavaConstant.forBoxedPrimitive(instanceField.get(testObject));
+                staticFieldValue = JavaConstant.forBoxedPrimitive(staticField.get(null));
+            } catch (Exception e) {
+                throw new Error("TESTBUG for kind " + kind, e);
+            }
+        }
     }
 }
--- a/hotspot/test/compiler/jvmci/jdk.vm.ci.hotspot.test/src/jdk/vm/ci/hotspot/test/MemoryAccessProviderTest.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/hotspot/test/compiler/jvmci/jdk.vm.ci.hotspot.test/src/jdk/vm/ci/hotspot/test/MemoryAccessProviderTest.java	Tue Apr 18 22:25:33 2017 +0200
@@ -31,12 +31,19 @@
  *          jdk.internal.vm.ci/jdk.vm.ci.runtime
  *          jdk.internal.vm.ci/jdk.vm.ci.hotspot
  *          java.base/jdk.internal.misc
- * @run testng/othervm -XX:+UnlockExperimentalVMOptions -XX:+EnableJVMCI
+ * @build sun.hotspot.WhiteBox
+ * @run driver ClassFileInstaller sun.hotspot.WhiteBox
+ *                                sun.hotspot.WhiteBox$WhiteBoxPermission
+ * @run testng/othervm -Xbootclasspath/a:.
+ *      -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI
+ *      -XX:+UnlockExperimentalVMOptions -XX:+EnableJVMCI
  *      jdk.vm.ci.hotspot.test.MemoryAccessProviderTest
  */
 
 package jdk.vm.ci.hotspot.test;
 
+import sun.hotspot.WhiteBox;
+
 import jdk.vm.ci.meta.Constant;
 import jdk.vm.ci.meta.JavaKind;
 import jdk.vm.ci.meta.MemoryAccessProvider;
@@ -59,7 +66,27 @@
 
     @Test(dataProvider = "negative", dataProviderClass = MemoryAccessProviderData.class, expectedExceptions = {IllegalArgumentException.class})
     public void testNegativeReadPrimitiveConstant(JavaKind kind, Constant base) {
-        PROVIDER.readPrimitiveConstant(kind, base, 0L, kind == null ? 0 : kind.getBitCount());
+        PROVIDER.readPrimitiveConstant(kind, base, 0L, kind == null ? 0 : kind.getByteCount() / 8);
+    }
+
+    @Test(dataProvider = "outOfBoundsInstanceFields", dataProviderClass = MemoryAccessProviderData.class)
+    public void testReadPrimitiveInstanceFieldOutOfBounds(JavaKind kind, Constant base, Long offset, boolean isOutOfBounds) {
+        try {
+            PROVIDER.readPrimitiveConstant(kind, base, offset, kind.getByteCount() * 8);
+            Assert.assertFalse(isOutOfBounds);
+        } catch (IllegalArgumentException iae) {
+            Assert.assertTrue(isOutOfBounds);
+        }
+    }
+
+    @Test(dataProvider = "outOfBoundsStaticFields", dataProviderClass = MemoryAccessProviderData.class)
+    public void testReadPrimitiveStaticFieldOutOFBounds(JavaKind kind, Constant base, Long offset, boolean isOutOfBounds) {
+        try {
+            PROVIDER.readPrimitiveConstant(kind, base, offset, kind.getByteCount() * 8);
+            Assert.assertFalse(isOutOfBounds);
+        } catch (IllegalArgumentException iae) {
+            Assert.assertTrue(isOutOfBounds);
+        }
     }
 
     @Test(dataProvider = "positiveObject", dataProviderClass = MemoryAccessProviderData.class, expectedExceptions = {IllegalArgumentException.class})
@@ -87,7 +114,7 @@
         Assert.assertNull(PROVIDER.readObjectConstant(base, offset + 1), "Expected null");
     }
 
-    @Test(dataProvider = "positivePrimitive", dataProviderClass = MemoryAccessProviderData.class)
+    @Test(dataProvider = "positivePrimitive", dataProviderClass = MemoryAccessProviderData.class, expectedExceptions = {IllegalArgumentException.class})
     public void testNegativeReadObjectConstantPrimitiveBase(JavaKind kind, Constant base, Long offset, Object expected, int bitsCount) {
         Assert.assertNull(PROVIDER.readObjectConstant(base, offset), "Expected null");
     }
--- a/hotspot/test/gc/parallel/TestPrintGCDetailsVerbose.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/hotspot/test/gc/parallel/TestPrintGCDetailsVerbose.java	Tue Apr 18 22:25:33 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -23,12 +23,13 @@
 
 /*
  * @test TestPrintGCDetailsVerbose
- * @bug 8016740
+ * @bug 8016740 8177963
  * @summary Tests that jvm with maximally verbose GC logging does not crash when ParOldGC has no memory
  * @key gc
  * @requires vm.gc.Parallel
  * @modules java.base/jdk.internal.misc
  * @run main/othervm -Xmx50m -XX:+UseParallelGC -Xlog:gc*=trace TestPrintGCDetailsVerbose
+ * @run main/othervm -Xmx50m -XX:+UseParallelGC -XX:GCTaskTimeStampEntries=1 -Xlog:gc*=trace TestPrintGCDetailsVerbose
  */
 public class TestPrintGCDetailsVerbose {
 
--- a/hotspot/test/native/runtime/test_globals.cpp	Tue Apr 18 13:19:42 2017 -0400
+++ b/hotspot/test/native/runtime/test_globals.cpp	Tue Apr 18 22:25:33 2017 +0200
@@ -53,7 +53,7 @@
 }
 
 TEST_VM(FlagGuard, uintx_flag) {
-  TEST_FLAG(GCTaskTimeStampEntries, uintx, 1337);
+  TEST_FLAG(GCTaskTimeStampEntries, uint, 1337);
 }
 
 TEST_VM(FlagGuard, size_t_flag) {
--- a/hotspot/test/runtime/classFileParserBug/fakeMethodAccessor.jasm	Tue Apr 18 13:19:42 2017 -0400
+++ b/hotspot/test/runtime/classFileParserBug/fakeMethodAccessor.jasm	Tue Apr 18 22:25:33 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2016, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -26,7 +26,6 @@
  // to create a sub-type of jdk.internal.reflect.MethodAccessorImpl in order
  // to bypass Reflection.getCallerClass.  That should fail with an IAE.
  //
- import java.lang.reflect.Module;
  class fakeMethodAccessor extends jdk.internal.reflect.MethodAccessorImpl {
      public static void main(String[] a) throws Exception {
         fakeMethodAccessor f = new fakeMethodAccessor();
@@ -60,11 +59,11 @@
         astore_1;
         getstatic    Field java/lang/System.out:"Ljava/io/PrintStream;";
         ldc    class java/lang/String;
-        invokevirtual    Method java/lang/Class.getModule:"()Ljava/lang/reflect/Module;";
+        invokevirtual    Method java/lang/Class.getModule:"()Ljava/lang/Module;";
         ldc    String "jdk.internal.misc";
         ldc    class FakeMethodAccessor;
-        invokevirtual    Method java/lang/Class.getModule:"()Ljava/lang/reflect/Module;";
-        invokevirtual    Method java/lang/reflect/Module.isExported:"(Ljava/lang/String;Ljava/lang/reflect/Module;)Z";
+        invokevirtual    Method java/lang/Class.getModule:"()Ljava/lang/Module;";
+        invokevirtual    Method java/lang/Module.isExported:"(Ljava/lang/String;Ljava/lang/Module;)Z";
         invokevirtual    Method java/io/PrintStream.println:"(Z)V";
         return;
 }
--- a/hotspot/test/runtime/getSysPackage/GetSysPkgTest.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/hotspot/test/runtime/getSysPackage/GetSysPkgTest.java	Tue Apr 18 22:25:33 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -55,7 +55,7 @@
                 return m;
             }
         }
-        throw new RuntimeException("Failed to find method " + name + " in java.lang.reflect.Module");
+        throw new RuntimeException("Failed to find method " + name + " in java.lang.Module");
     }
 
     // Throw RuntimeException if getSystemPackageLocation() does not return
--- a/hotspot/test/runtime/modules/AccModuleTest.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/hotspot/test/runtime/modules/AccModuleTest.java	Tue Apr 18 22:25:33 2017 +0200
@@ -28,8 +28,6 @@
  * @run main AccModuleTest
  */
 
-import java.io.File;
-
 public class AccModuleTest {
 
     public static void main(String args[]) throws Throwable {
--- a/hotspot/test/runtime/modules/AccessCheck/AccessExportTwice.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/hotspot/test/runtime/modules/AccessCheck/AccessExportTwice.java	Tue Apr 18 22:25:33 2017 +0200
@@ -39,8 +39,6 @@
 import java.lang.module.Configuration;
 import java.lang.module.ModuleDescriptor;
 import java.lang.module.ModuleFinder;
-import java.lang.reflect.Layer;
-import java.lang.reflect.Module;
 import java.util.HashMap;
 import java.util.Map;
 import java.util.Set;
@@ -58,7 +56,7 @@
 
 public class AccessExportTwice {
 
-    // Create a Layer over the boot layer.
+    // Create a layer over the boot layer.
     // Define modules within this layer to test access between
     // publicly defined classes within packages of those modules.
     public void createLayerOnBoot() throws Throwable {
@@ -87,7 +85,7 @@
         ModuleFinder finder = ModuleLibrary.of(descriptor_first_mod, descriptor_second_mod);
 
         // Resolves "first_mod"
-        Configuration cf = Layer.boot()
+        Configuration cf = ModuleLayer.boot()
                 .configuration()
                 .resolve(finder, ModuleFinder.of(), Set.of("first_mod"));
 
@@ -96,8 +94,8 @@
         map.put("first_mod", MySameClassLoader.loader1);
         map.put("second_mod", MySameClassLoader.loader1);
 
-        // Create Layer that contains first_mod & second_mod
-        Layer layer = Layer.boot().defineModules(cf, map::get);
+        // Create layer that contains first_mod & second_mod
+        ModuleLayer layer = ModuleLayer.boot().defineModules(cf, map::get);
 
         assertTrue(layer.findLoader("first_mod") == MySameClassLoader.loader1);
         assertTrue(layer.findLoader("second_mod") == MySameClassLoader.loader1);
--- a/hotspot/test/runtime/modules/AccessCheck/AccessReadTwice.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/hotspot/test/runtime/modules/AccessCheck/AccessReadTwice.java	Tue Apr 18 22:25:33 2017 +0200
@@ -39,8 +39,6 @@
 import java.lang.module.Configuration;
 import java.lang.module.ModuleDescriptor;
 import java.lang.module.ModuleFinder;
-import java.lang.reflect.Layer;
-import java.lang.reflect.Module;
 import java.util.HashMap;
 import java.util.Map;
 import java.util.Set;
@@ -56,7 +54,7 @@
 
 public class AccessReadTwice {
 
-    // Create a Layer over the boot layer.
+    // Create a layer over the boot layer.
     // Define modules within this layer to test access between
     // publicly defined classes within packages of those modules.
     public void createLayerOnBoot() throws Throwable {
@@ -85,7 +83,7 @@
         ModuleFinder finder = ModuleLibrary.of(descriptor_first_mod, descriptor_second_mod);
 
         // Resolves "first_mod" and "second_mod"
-        Configuration cf = Layer.boot()
+        Configuration cf = ModuleLayer.boot()
                 .configuration()
                 .resolve(finder, ModuleFinder.of(), Set.of("first_mod", "second_mod"));
 
@@ -95,8 +93,8 @@
         map.put("first_mod", loader);
         map.put("second_mod", loader);
 
-        // Create Layer that contains first_mod & second_mod
-        Layer layer = Layer.boot().defineModules(cf, map::get);
+        // Create layer that contains first_mod & second_mod
+        ModuleLayer layer = ModuleLayer.boot().defineModules(cf, map::get);
 
         assertTrue(layer.findLoader("first_mod") == loader);
         assertTrue(layer.findLoader("second_mod") == loader);
--- a/hotspot/test/runtime/modules/AccessCheck/CheckRead.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/hotspot/test/runtime/modules/AccessCheck/CheckRead.java	Tue Apr 18 22:25:33 2017 +0200
@@ -37,7 +37,6 @@
 
 import static jdk.test.lib.Asserts.*;
 
-import java.lang.reflect.Layer;
 import java.lang.module.Configuration;
 import java.lang.module.ModuleDescriptor;
 import java.lang.module.ModuleFinder;
@@ -59,7 +58,7 @@
 //
 public class CheckRead {
 
-    // Create a Layer over the boot layer.
+    // Create a layer over the boot layer.
     // Define modules within this layer to test access between
     // publicly defined classes within packages of those modules.
     public void createLayerOnBoot() throws Throwable {
@@ -100,7 +99,7 @@
         ModuleFinder finder = ModuleLibrary.of(descriptor_m1x, descriptor_m2x, descriptor_m3x);
 
         // Resolves "m1x"
-        Configuration cf = Layer.boot()
+        Configuration cf = ModuleLayer.boot()
                 .configuration()
                 .resolve(finder, ModuleFinder.of(), Set.of("m1x"));
 
@@ -110,8 +109,8 @@
         map.put("m2x", MySameClassLoader.loader1);
         map.put("m3x", MySameClassLoader.loader1);
 
-        // Create Layer that contains m1x, m2x and m3x
-        Layer layer = Layer.boot().defineModules(cf, map::get);
+        // Create layer that contains m1x, m2x and m3x
+        ModuleLayer layer = ModuleLayer.boot().defineModules(cf, map::get);
 
         assertTrue(layer.findLoader("m1x") == MySameClassLoader.loader1);
         assertTrue(layer.findLoader("m2x") == MySameClassLoader.loader1);
--- a/hotspot/test/runtime/modules/AccessCheck/DiffCL_CheckRead.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/hotspot/test/runtime/modules/AccessCheck/DiffCL_CheckRead.java	Tue Apr 18 22:25:33 2017 +0200
@@ -37,7 +37,6 @@
 
 import static jdk.test.lib.Asserts.*;
 
-import java.lang.reflect.Layer;
 import java.lang.module.Configuration;
 import java.lang.module.ModuleDescriptor;
 import java.lang.module.ModuleFinder;
@@ -59,7 +58,7 @@
 //
 public class DiffCL_CheckRead {
 
-    // Create a Layer over the boot layer.
+    // Create a layer over the boot layer.
     // Define modules within this layer to test access between
     // publicly defined classes within packages of those modules.
     public void createLayerOnBoot() throws Throwable {
@@ -100,7 +99,7 @@
         ModuleFinder finder = ModuleLibrary.of(descriptor_m1x, descriptor_m2x, descriptor_m3x);
 
         // Resolves "m1x"
-        Configuration cf = Layer.boot()
+        Configuration cf = ModuleLayer.boot()
                 .configuration()
                 .resolve(finder, ModuleFinder.of(), Set.of("m1x"));
 
@@ -110,8 +109,8 @@
         map.put("m2x", MyDiffClassLoader.loader2);
         map.put("m3x", MyDiffClassLoader.loader2);
 
-        // Create Layer that contains m1x, m2x and m3x
-        Layer layer = Layer.boot().defineModules(cf, map::get);
+        // Create layer that contains m1x, m2x and m3x
+        ModuleLayer layer = ModuleLayer.boot().defineModules(cf, map::get);
 
         assertTrue(layer.findLoader("m1x") == MyDiffClassLoader.loader1);
         assertTrue(layer.findLoader("m2x") == MyDiffClassLoader.loader2);
--- a/hotspot/test/runtime/modules/AccessCheck/DiffCL_ExpQualOther.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/hotspot/test/runtime/modules/AccessCheck/DiffCL_ExpQualOther.java	Tue Apr 18 22:25:33 2017 +0200
@@ -38,7 +38,6 @@
 
 import static jdk.test.lib.Asserts.*;
 
-import java.lang.reflect.Layer;
 import java.lang.module.Configuration;
 import java.lang.module.ModuleDescriptor;
 import java.lang.module.ModuleFinder;
@@ -60,7 +59,7 @@
 //
 public class DiffCL_ExpQualOther {
 
-    // Create a Layer over the boot layer.
+    // Create a layer over the boot layer.
     // Define modules within this layer to test access between
     // publically defined classes within packages of those modules.
     public void createLayerOnBoot() throws Throwable {
@@ -102,7 +101,7 @@
         ModuleFinder finder = ModuleLibrary.of(descriptor_m1x, descriptor_m2x, descriptor_m3x);
 
         // Resolves "m1x"
-        Configuration cf = Layer.boot()
+        Configuration cf = ModuleLayer.boot()
                 .configuration()
                 .resolve(finder, ModuleFinder.of(), Set.of("m1x"));
 
@@ -112,8 +111,8 @@
         map.put("m2x", MyDiffClassLoader.loader2);
         map.put("m3x", MyDiffClassLoader.loader2);
 
-        // Create Layer that contains m1x & m2x
-        Layer layer = Layer.boot().defineModules(cf, map::get);
+        // Create layer that contains m1x & m2x
+        ModuleLayer layer = ModuleLayer.boot().defineModules(cf, map::get);
 
         assertTrue(layer.findLoader("m1x") == MyDiffClassLoader.loader1);
         assertTrue(layer.findLoader("m2x") == MyDiffClassLoader.loader2);
--- a/hotspot/test/runtime/modules/AccessCheck/DiffCL_ExpQualToM1.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/hotspot/test/runtime/modules/AccessCheck/DiffCL_ExpQualToM1.java	Tue Apr 18 22:25:33 2017 +0200
@@ -37,7 +37,6 @@
 
 import static jdk.test.lib.Asserts.*;
 
-import java.lang.reflect.Layer;
 import java.lang.module.Configuration;
 import java.lang.module.ModuleDescriptor;
 import java.lang.module.ModuleFinder;
@@ -58,7 +57,7 @@
 //
 public class DiffCL_ExpQualToM1 {
 
-    // Create a Layer over the boot layer.
+    // Create a layer over the boot layer.
     // Define modules within this layer to test access between
     // publically defined classes within packages of those modules.
     public void createLayerOnBoot() throws Throwable {
@@ -88,7 +87,7 @@
         ModuleFinder finder = ModuleLibrary.of(descriptor_m1x, descriptor_m2x);
 
         // Resolves "m1x"
-        Configuration cf = Layer.boot()
+        Configuration cf = ModuleLayer.boot()
                 .configuration()
                 .resolve(finder, ModuleFinder.of(), Set.of("m1x"));
 
@@ -97,8 +96,8 @@
         map.put("m1x", MyDiffClassLoader.loader1);
         map.put("m2x", MyDiffClassLoader.loader2);
 
-        // Create Layer that contains m1x & m2x
-        Layer layer = Layer.boot().defineModules(cf, map::get);
+        // Create layer that contains m1x & m2x
+        ModuleLayer layer = ModuleLayer.boot().defineModules(cf, map::get);
 
         assertTrue(layer.findLoader("m1x") == MyDiffClassLoader.loader1);
         assertTrue(layer.findLoader("m2x") == MyDiffClassLoader.loader2);
--- a/hotspot/test/runtime/modules/AccessCheck/DiffCL_ExpUnqual.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/hotspot/test/runtime/modules/AccessCheck/DiffCL_ExpUnqual.java	Tue Apr 18 22:25:33 2017 +0200
@@ -37,7 +37,6 @@
 
 import static jdk.test.lib.Asserts.*;
 
-import java.lang.reflect.Layer;
 import java.lang.module.Configuration;
 import java.lang.module.ModuleDescriptor;
 import java.lang.module.ModuleFinder;
@@ -59,7 +58,7 @@
 //
 public class DiffCL_ExpUnqual {
 
-    // Create a Layer over the boot layer.
+    // Create a layer over the boot layer.
     // Define modules within this layer to test access between
     // publically defined classes within packages of those modules.
     public void createLayerOnBoot() throws Throwable {
@@ -89,7 +88,7 @@
         ModuleFinder finder = ModuleLibrary.of(descriptor_m1x, descriptor_m2x);
 
         // Resolves "m1x"
-        Configuration cf = Layer.boot()
+        Configuration cf = ModuleLayer.boot()
                 .configuration()
                 .resolve(finder, ModuleFinder.of(), Set.of("m1x"));
 
@@ -98,8 +97,8 @@
         map.put("m1x", MyDiffClassLoader.loader1);
         map.put("m2x", MyDiffClassLoader.loader2);
 
-        // Create Layer that contains m1x & m2x
-        Layer layer = Layer.boot().defineModules(cf, map::get);
+        // Create layer that contains m1x & m2x
+        ModuleLayer layer = ModuleLayer.boot().defineModules(cf, map::get);
 
         assertTrue(layer.findLoader("m1x") == MyDiffClassLoader.loader1);
         assertTrue(layer.findLoader("m2x") == MyDiffClassLoader.loader2);
--- a/hotspot/test/runtime/modules/AccessCheck/DiffCL_PkgNotExp.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/hotspot/test/runtime/modules/AccessCheck/DiffCL_PkgNotExp.java	Tue Apr 18 22:25:33 2017 +0200
@@ -37,7 +37,6 @@
 
 import static jdk.test.lib.Asserts.*;
 
-import java.lang.reflect.Layer;
 import java.lang.module.Configuration;
 import java.lang.module.ModuleDescriptor;
 import java.lang.module.ModuleFinder;
@@ -58,7 +57,7 @@
 //
 public class DiffCL_PkgNotExp {
 
-    // Create a Layer over the boot layer.
+    // Create a layer over the boot layer.
     // Define modules within this layer to test access between
     // publically defined classes within packages of those modules.
     public void createLayerOnBoot() throws Throwable {
@@ -88,7 +87,7 @@
         ModuleFinder finder = ModuleLibrary.of(descriptor_m1x, descriptor_m2x);
 
         // Resolves "m1x"
-        Configuration cf = Layer.boot()
+        Configuration cf = ModuleLayer.boot()
                 .configuration()
                 .resolve(finder, ModuleFinder.of(), Set.of("m1x"));
 
@@ -97,8 +96,8 @@
         map.put("m1x", MyDiffClassLoader.loader1);
         map.put("m2x", MyDiffClassLoader.loader2);
 
-        // Create Layer that contains m1x & m2x
-        Layer layer = Layer.boot().defineModules(cf, map::get);
+        // Create layer that contains m1x & m2x
+        ModuleLayer layer = ModuleLayer.boot().defineModules(cf, map::get);
 
         assertTrue(layer.findLoader("m1x") == MyDiffClassLoader.loader1);
         assertTrue(layer.findLoader("m2x") == MyDiffClassLoader.loader2);
--- a/hotspot/test/runtime/modules/AccessCheck/DiffCL_Umod.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/hotspot/test/runtime/modules/AccessCheck/DiffCL_Umod.java	Tue Apr 18 22:25:33 2017 +0200
@@ -42,8 +42,6 @@
 import java.lang.module.Configuration;
 import java.lang.module.ModuleDescriptor;
 import java.lang.module.ModuleFinder;
-import java.lang.reflect.Layer;
-import java.lang.reflect.Module;
 import java.util.HashMap;
 import java.util.Map;
 import java.util.Set;
@@ -68,7 +66,7 @@
 //
 public class DiffCL_Umod {
 
- // Create Layers over the boot layer to test different
+ // Create layers over the boot layer to test different
  // accessing scenarios of a named module to an unnamed module.
 
  // Module m1x is a strict module and has not established
@@ -89,7 +87,7 @@
      ModuleFinder finder = ModuleLibrary.of(descriptor_m1x);
 
      // Resolves "m1x"
-     Configuration cf = Layer.boot()
+     Configuration cf = ModuleLayer.boot()
              .configuration()
              .resolve(finder, ModuleFinder.of(), Set.of("m1x"));
 
@@ -102,8 +100,8 @@
      Map<String, ClassLoader> map = new HashMap<>();
      map.put("m1x", MyDiffClassLoader.loader1);
 
-     // Create Layer that contains m1x
-     Layer layer = Layer.boot().defineModules(cf, map::get);
+     // Create layer that contains m1x
+     ModuleLayer layer = ModuleLayer.boot().defineModules(cf, map::get);
 
      assertTrue(layer.findLoader("m1x") == MyDiffClassLoader.loader1);
      assertTrue(layer.findLoader("java.base") == null);
@@ -138,7 +136,7 @@
      ModuleFinder finder = ModuleLibrary.of(descriptor_m1x);
 
      // Resolves "m1x"
-     Configuration cf = Layer.boot()
+     Configuration cf = ModuleLayer.boot()
              .configuration()
              .resolve(finder, ModuleFinder.of(), Set.of("m1x"));
 
@@ -151,8 +149,8 @@
      Map<String, ClassLoader> map = new HashMap<>();
      map.put("m1x", MyDiffClassLoader.loader1);
 
-     // Create Layer that contains m1x
-     Layer layer = Layer.boot().defineModules(cf, map::get);
+     // Create layer that contains m1x
+     ModuleLayer layer = ModuleLayer.boot().defineModules(cf, map::get);
 
      assertTrue(layer.findLoader("m1x") == MyDiffClassLoader.loader1);
      assertTrue(layer.findLoader("java.base") == null);
@@ -187,7 +185,7 @@
      ModuleFinder finder = ModuleLibrary.of(descriptor_m1x);
 
      // Resolves "m1x"
-     Configuration cf = Layer.boot()
+     Configuration cf = ModuleLayer.boot()
              .configuration()
              .resolve(finder, ModuleFinder.of(), Set.of("m1x"));
 
@@ -200,8 +198,8 @@
      Map<String, ClassLoader> map = new HashMap<>();
      map.put("m1x", MyDiffClassLoader.loader1);
 
-     // Create Layer that contains m1x
-     Layer layer = Layer.boot().defineModules(cf, map::get);
+     // Create layer that contains m1x
+     ModuleLayer layer = ModuleLayer.boot().defineModules(cf, map::get);
 
      assertTrue(layer.findLoader("m1x") == MyDiffClassLoader.loader1);
      assertTrue(layer.findLoader("java.base") == null);
--- a/hotspot/test/runtime/modules/AccessCheck/DiffCL_UmodUpkg.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/hotspot/test/runtime/modules/AccessCheck/DiffCL_UmodUpkg.java	Tue Apr 18 22:25:33 2017 +0200
@@ -38,7 +38,6 @@
 
 import static jdk.test.lib.Asserts.*;
 
-import java.lang.reflect.Layer;
 import java.lang.module.Configuration;
 import java.lang.module.ModuleDescriptor;
 import java.lang.module.ModuleFinder;
@@ -63,7 +62,7 @@
 //
 public class DiffCL_UmodUpkg {
 
- // Create Layers over the boot layer to test different
+ // Create layers over the boot layer to test different
  // accessing scenarios of a named module to an unnamed module.
 
  // Module m1x is a strict module and has not established
@@ -84,7 +83,7 @@
      ModuleFinder finder = ModuleLibrary.of(descriptor_m1x);
 
      // Resolves "m1x"
-     Configuration cf = Layer.boot()
+     Configuration cf = ModuleLayer.boot()
              .configuration()
              .resolve(finder, ModuleFinder.of(), Set.of("m1x"));
 
@@ -97,8 +96,8 @@
      Map<String, ClassLoader> map = new HashMap<>();
      map.put("m1x", MyDiffClassLoader.loader1);
 
-     // Create Layer that contains m1x
-     Layer layer = Layer.boot().defineModules(cf, map::get);
+     // Create layer that contains m1x
+     ModuleLayer layer = ModuleLayer.boot().defineModules(cf, map::get);
 
      assertTrue(layer.findLoader("m1x") == MyDiffClassLoader.loader1);
      assertTrue(layer.findLoader("java.base") == null);
@@ -133,7 +132,7 @@
      ModuleFinder finder = ModuleLibrary.of(descriptor_m1x);
 
      // Resolves "m1x"
-     Configuration cf = Layer.boot()
+     Configuration cf = ModuleLayer.boot()
              .configuration()
              .resolve(finder, ModuleFinder.of(), Set.of("m1x"));
 
@@ -146,8 +145,8 @@
      Map<String, ClassLoader> map = new HashMap<>();
      map.put("m1x", MyDiffClassLoader.loader1);
 
-     // Create Layer that contains m1x
-     Layer layer = Layer.boot().defineModules(cf, map::get);
+     // Create layer that contains m1x
+     ModuleLayer layer = ModuleLayer.boot().defineModules(cf, map::get);
 
      assertTrue(layer.findLoader("m1x") == MyDiffClassLoader.loader1);
      assertTrue(layer.findLoader("java.base") == null);
--- a/hotspot/test/runtime/modules/AccessCheck/ExpQualOther.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/hotspot/test/runtime/modules/AccessCheck/ExpQualOther.java	Tue Apr 18 22:25:33 2017 +0200
@@ -38,7 +38,6 @@
 
 import static jdk.test.lib.Asserts.*;
 
-import java.lang.reflect.Layer;
 import java.lang.module.Configuration;
 import java.lang.module.ModuleDescriptor;
 import java.lang.module.ModuleFinder;
@@ -60,7 +59,7 @@
 //
 public class ExpQualOther {
 
-    // Create a Layer over the boot layer.
+    // Create a layer over the boot layer.
     // Define modules within this layer to test access between
     // publically defined classes within packages of those modules.
     public void createLayerOnBoot() throws Throwable {
@@ -102,7 +101,7 @@
         ModuleFinder finder = ModuleLibrary.of(descriptor_m1x, descriptor_m2x, descriptor_m3x);
 
         // Resolves "m1x"
-        Configuration cf = Layer.boot()
+        Configuration cf = ModuleLayer.boot()
                 .configuration()
                 .resolve(finder, ModuleFinder.of(), Set.of("m1x"));
 
@@ -112,8 +111,8 @@
         map.put("m2x", MySameClassLoader.loader1);
         map.put("m3x", MySameClassLoader.loader1);
 
-        // Create Layer that contains m1x & m2x
-        Layer layer = Layer.boot().defineModules(cf, map::get);
+        // Create layer that contains m1x & m2x
+        ModuleLayer layer = ModuleLayer.boot().defineModules(cf, map::get);
 
         assertTrue(layer.findLoader("m1x") == MySameClassLoader.loader1);
         assertTrue(layer.findLoader("m2x") == MySameClassLoader.loader1);
--- a/hotspot/test/runtime/modules/AccessCheck/ExpQualToM1.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/hotspot/test/runtime/modules/AccessCheck/ExpQualToM1.java	Tue Apr 18 22:25:33 2017 +0200
@@ -37,7 +37,6 @@
 
 import static jdk.test.lib.Asserts.*;
 
-import java.lang.reflect.Layer;
 import java.lang.module.Configuration;
 import java.lang.module.ModuleDescriptor;
 import java.lang.module.ModuleFinder;
@@ -48,7 +47,7 @@
 
 public class ExpQualToM1 {
 
-    // Create a Layer over the boot layer.
+    // Create a layer over the boot layer.
     // Define modules within this layer to test access between
     // publically defined classes within packages of those modules.
     public void createLayerOnBoot() throws Throwable {
@@ -78,7 +77,7 @@
         ModuleFinder finder = ModuleLibrary.of(descriptor_m1x, descriptor_m2x);
 
         // Resolves "m1x"
-        Configuration cf = Layer.boot()
+        Configuration cf = ModuleLayer.boot()
                 .configuration()
                 .resolve(finder, ModuleFinder.of(), Set.of("m1x"));
 
@@ -87,8 +86,8 @@
         map.put("m1x", MySameClassLoader.loader1);
         map.put("m2x", MySameClassLoader.loader1);
 
-        // Create Layer that contains m1x & m2x
-        Layer layer = Layer.boot().defineModules(cf, map::get);
+        // Create layer that contains m1x & m2x
+        ModuleLayer layer = ModuleLayer.boot().defineModules(cf, map::get);
 
         assertTrue(layer.findLoader("m1x") == MySameClassLoader.loader1);
         assertTrue(layer.findLoader("m2x") == MySameClassLoader.loader1);
--- a/hotspot/test/runtime/modules/AccessCheck/ExpUnqual.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/hotspot/test/runtime/modules/AccessCheck/ExpUnqual.java	Tue Apr 18 22:25:33 2017 +0200
@@ -37,7 +37,6 @@
 
 import static jdk.test.lib.Asserts.*;
 
-import java.lang.reflect.Layer;
 import java.lang.module.Configuration;
 import java.lang.module.ModuleDescriptor;
 import java.lang.module.ModuleFinder;
@@ -48,7 +47,7 @@
 
 public class ExpUnqual {
 
-    // Create a Layer over the boot layer.
+    // Create a layer over the boot layer.
     // Define modules within this layer to test access between
     // publically defined classes within packages of those modules.
     public void createLayerOnBoot() throws Throwable {
@@ -78,7 +77,7 @@
         ModuleFinder finder = ModuleLibrary.of(descriptor_m1x, descriptor_m2x);
 
         // Resolves "m1x"
-        Configuration cf = Layer.boot()
+        Configuration cf = ModuleLayer.boot()
                 .configuration()
                 .resolve(finder, ModuleFinder.of(), Set.of("m1x"));
 
@@ -87,8 +86,8 @@
         map.put("m1x", MySameClassLoader.loader1);
         map.put("m2x", MySameClassLoader.loader1);
 
-        // Create Layer that contains m1x & m2x
-        Layer layer = Layer.boot().defineModules(cf, map::get);
+        // Create layer that contains m1x & m2x
+        ModuleLayer layer = ModuleLayer.boot().defineModules(cf, map::get);
 
         assertTrue(layer.findLoader("m1x") == MySameClassLoader.loader1);
         assertTrue(layer.findLoader("m2x") == MySameClassLoader.loader1);
--- a/hotspot/test/runtime/modules/AccessCheck/ExportAllUnnamed.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/hotspot/test/runtime/modules/AccessCheck/ExportAllUnnamed.java	Tue Apr 18 22:25:33 2017 +0200
@@ -41,8 +41,6 @@
 import java.lang.module.Configuration;
 import java.lang.module.ModuleDescriptor;
 import java.lang.module.ModuleFinder;
-import java.lang.reflect.Layer;
-import java.lang.reflect.Module;
 import java.util.HashMap;
 import java.util.Map;
 import java.util.Set;
@@ -61,7 +59,7 @@
 
 public class ExportAllUnnamed {
 
-    // Create a Layer over the boot layer.
+    // Create a layer over the boot layer.
     // Define modules within this layer to test access between
     // publically defined classes within packages of those modules.
     public void createLayerOnBoot() throws Throwable {
@@ -90,7 +88,7 @@
         ModuleFinder finder = ModuleLibrary.of(descriptor_m1x, descriptor_m2x);
 
         // Resolves "m1x"
-        Configuration cf = Layer.boot()
+        Configuration cf = ModuleLayer.boot()
                 .configuration()
                 .resolve(finder, ModuleFinder.of(), Set.of("m1x"));
 
@@ -99,8 +97,8 @@
         map.put("m1x", MySameClassLoader.loader1);
         map.put("m2x", MySameClassLoader.loader1);
 
-        // Create Layer that contains m1x & m2x
-        Layer layer = Layer.boot().defineModules(cf, map::get);
+        // Create layer that contains m1x & m2x
+        ModuleLayer layer = ModuleLayer.boot().defineModules(cf, map::get);
 
         assertTrue(layer.findLoader("m1x") == MySameClassLoader.loader1);
         assertTrue(layer.findLoader("m2x") == MySameClassLoader.loader1);
--- a/hotspot/test/runtime/modules/AccessCheck/PkgNotExp.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/hotspot/test/runtime/modules/AccessCheck/PkgNotExp.java	Tue Apr 18 22:25:33 2017 +0200
@@ -37,7 +37,6 @@
 
 import static jdk.test.lib.Asserts.*;
 
-import java.lang.reflect.Layer;
 import java.lang.module.Configuration;
 import java.lang.module.ModuleDescriptor;
 import java.lang.module.ModuleFinder;
@@ -58,7 +57,7 @@
 //
 public class PkgNotExp {
 
-    // Create a Layer over the boot layer.
+    // Create a layer over the boot layer.
     // Define modules within this layer to test access between
     // publically defined classes within packages of those modules.
     public void createLayerOnBoot() throws Throwable {
@@ -88,7 +87,7 @@
         ModuleFinder finder = ModuleLibrary.of(descriptor_m1x, descriptor_m2x);
 
         // Resolves "m1x"
-        Configuration cf = Layer.boot()
+        Configuration cf = ModuleLayer.boot()
                 .configuration()
                 .resolve(finder, ModuleFinder.of(), Set.of("m1x"));
 
@@ -97,8 +96,8 @@
         map.put("m1x", MySameClassLoader.loader1);
         map.put("m2x", MySameClassLoader.loader1);
 
-        // Create Layer that contains m1x and m2x
-        Layer layer = Layer.boot().defineModules(cf, map::get);
+        // Create layer that contains m1x and m2x
+        ModuleLayer layer = ModuleLayer.boot().defineModules(cf, map::get);
 
         assertTrue(layer.findLoader("m1x") == MySameClassLoader.loader1);
         assertTrue(layer.findLoader("m2x") == MySameClassLoader.loader1);
--- a/hotspot/test/runtime/modules/AccessCheck/Umod.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/hotspot/test/runtime/modules/AccessCheck/Umod.java	Tue Apr 18 22:25:33 2017 +0200
@@ -39,11 +39,9 @@
 
 import static jdk.test.lib.Asserts.*;
 
-import java.lang.reflect.Layer;
 import java.lang.module.Configuration;
 import java.lang.module.ModuleDescriptor;
 import java.lang.module.ModuleFinder;
-import java.lang.reflect.Module;
 import java.util.HashMap;
 import java.util.Map;
 import java.util.Set;
@@ -68,7 +66,7 @@
 //
 public class Umod {
 
- // Create Layers over the boot layer to test different
+ // Create layers over the boot layer to test different
  // accessing scenarios of a named module to an unnamed module.
 
  // Module m1x is a strict module and has not established
@@ -89,7 +87,7 @@
      ModuleFinder finder = ModuleLibrary.of(descriptor_m1x);
 
      // Resolves "m1x"
-     Configuration cf = Layer.boot()
+     Configuration cf = ModuleLayer.boot()
              .configuration()
              .resolve(finder, ModuleFinder.of(), Set.of("m1x"));
 
@@ -99,8 +97,8 @@
      Map<String, ClassLoader> map = new HashMap<>();
      map.put("m1x", loader);
 
-     // Create Layer that contains m1x
-     Layer layer = Layer.boot().defineModules(cf, map::get);
+     // Create layer that contains m1x
+     ModuleLayer layer = ModuleLayer.boot().defineModules(cf, map::get);
 
      assertTrue(layer.findLoader("m1x") == loader);
      assertTrue(layer.findLoader("java.base") == null);
@@ -135,7 +133,7 @@
      ModuleFinder finder = ModuleLibrary.of(descriptor_m1x);
 
      // Resolves "m1x"
-     Configuration cf = Layer.boot()
+     Configuration cf = ModuleLayer.boot()
              .configuration()
              .resolve(finder, ModuleFinder.of(), Set.of("m1x"));
 
@@ -145,8 +143,8 @@
      Map<String, ClassLoader> map = new HashMap<>();
      map.put("m1x", loader);
 
-     // Create Layer that contains m1x
-     Layer layer = Layer.boot().defineModules(cf, map::get);
+     // Create layer that contains m1x
+     ModuleLayer layer = ModuleLayer.boot().defineModules(cf, map::get);
 
      assertTrue(layer.findLoader("m1x") == loader);
      assertTrue(layer.findLoader("java.base") == null);
@@ -181,7 +179,7 @@
      ModuleFinder finder = ModuleLibrary.of(descriptor_m1x);
 
      // Resolves "m1x"
-     Configuration cf = Layer.boot()
+     Configuration cf = ModuleLayer.boot()
              .configuration()
              .resolve(finder, ModuleFinder.of(), Set.of("m1x"));
 
@@ -191,8 +189,8 @@
      Map<String, ClassLoader> map = new HashMap<>();
      map.put("m1x", loader);
 
-     // Create Layer that contains m1x
-     Layer layer = Layer.boot().defineModules(cf, map::get);
+     // Create layer that contains m1x
+     ModuleLayer layer = ModuleLayer.boot().defineModules(cf, map::get);
 
      assertTrue(layer.findLoader("m1x") == loader);
      assertTrue(layer.findLoader("java.base") == null);
--- a/hotspot/test/runtime/modules/AccessCheck/UmodDiffCL_ExpQualOther.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/hotspot/test/runtime/modules/AccessCheck/UmodDiffCL_ExpQualOther.java	Tue Apr 18 22:25:33 2017 +0200
@@ -38,7 +38,6 @@
 
 import static jdk.test.lib.Asserts.*;
 
-import java.lang.reflect.Layer;
 import java.lang.module.Configuration;
 import java.lang.module.ModuleDescriptor;
 import java.lang.module.ModuleFinder;
@@ -60,7 +59,7 @@
 //
 public class UmodDiffCL_ExpQualOther {
 
-    // Create a Layer over the boot layer.
+    // Create a layer over the boot layer.
     // Define modules within this layer to test access between
     // publically defined classes within packages of those modules.
     public void createLayerOnBoot() throws Throwable {
@@ -89,7 +88,7 @@
         ModuleFinder finder = ModuleLibrary.of(descriptor_m1x, descriptor_m2x);
 
         // Resolves "m1x"
-        Configuration cf = Layer.boot()
+        Configuration cf = ModuleLayer.boot()
                 .configuration()
                 .resolve(finder, ModuleFinder.of(), Set.of("m1x"));
 
@@ -98,8 +97,8 @@
         map.put("m1x", MyDiffClassLoader.loader1);
         map.put("m2x", MyDiffClassLoader.loader2);
 
-        // Create Layer that contains m1x & m2x
-        Layer layer = Layer.boot().defineModules(cf, map::get);
+        // Create layer that contains m1x & m2x
+        ModuleLayer layer = ModuleLayer.boot().defineModules(cf, map::get);
 
         assertTrue(layer.findLoader("m1x") == MyDiffClassLoader.loader1);
         assertTrue(layer.findLoader("m2x") == MyDiffClassLoader.loader2);
--- a/hotspot/test/runtime/modules/AccessCheck/UmodDiffCL_ExpUnqual.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/hotspot/test/runtime/modules/AccessCheck/UmodDiffCL_ExpUnqual.java	Tue Apr 18 22:25:33 2017 +0200
@@ -38,7 +38,6 @@
 
 import static jdk.test.lib.Asserts.*;
 
-import java.lang.reflect.Layer;
 import java.lang.module.Configuration;
 import java.lang.module.ModuleDescriptor;
 import java.lang.module.ModuleFinder;
@@ -60,7 +59,7 @@
 //
 public class UmodDiffCL_ExpUnqual {
 
-    // Create a Layer over the boot layer.
+    // Create a layer over the boot layer.
     // Define modules within this layer to test access between
     // publically defined classes within packages of those modules.
     public void createLayerOnBoot() throws Throwable {
@@ -89,7 +88,7 @@
         ModuleFinder finder = ModuleLibrary.of(descriptor_m1x, descriptor_m2x);
 
         // Resolves "m1x"
-        Configuration cf = Layer.boot()
+        Configuration cf = ModuleLayer.boot()
                 .configuration()
                 .resolve(finder, ModuleFinder.of(), Set.of("m1x"));
 
@@ -98,8 +97,8 @@
         map.put("m1x", MyDiffClassLoader.loader1);
         map.put("m2x", MyDiffClassLoader.loader2);
 
-        // Create Layer that contains m1x & m2x
-        Layer layer = Layer.boot().defineModules(cf, map::get);
+        // Create layer that contains m1x & m2x
+        ModuleLayer layer = ModuleLayer.boot().defineModules(cf, map::get);
 
         assertTrue(layer.findLoader("m1x") == MyDiffClassLoader.loader1);
         assertTrue(layer.findLoader("m2x") == MyDiffClassLoader.loader2);
--- a/hotspot/test/runtime/modules/AccessCheck/UmodDiffCL_PkgNotExp.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/hotspot/test/runtime/modules/AccessCheck/UmodDiffCL_PkgNotExp.java	Tue Apr 18 22:25:33 2017 +0200
@@ -37,7 +37,6 @@
 
 import static jdk.test.lib.Asserts.*;
 
-import java.lang.reflect.Layer;
 import java.lang.module.Configuration;
 import java.lang.module.ModuleDescriptor;
 import java.lang.module.ModuleFinder;
@@ -59,7 +58,7 @@
 //
 public class UmodDiffCL_PkgNotExp {
 
-    // Create a Layer over the boot layer.
+    // Create a layer over the boot layer.
     // Define modules within this layer to test access between
     // publically defined classes within packages of those modules.
     public void createLayerOnBoot() throws Throwable {
@@ -88,7 +87,7 @@
         ModuleFinder finder = ModuleLibrary.of(descriptor_m1x, descriptor_m2x);
 
         // Resolves "m1x"
-        Configuration cf = Layer.boot()
+        Configuration cf = ModuleLayer.boot()
                 .configuration()
                 .resolve(finder, ModuleFinder.of(), Set.of("m1x"));
 
@@ -97,8 +96,8 @@
         map.put("m1x", MyDiffClassLoader.loader1);
         map.put("m2x", MyDiffClassLoader.loader2);
 
-        // Create Layer that contains m1x & m2x
-        Layer layer = Layer.boot().defineModules(cf, map::get);
+        // Create layer that contains m1x & m2x
+        ModuleLayer layer = ModuleLayer.boot().defineModules(cf, map::get);
 
         assertTrue(layer.findLoader("m1x") == MyDiffClassLoader.loader1);
         assertTrue(layer.findLoader("m2x") == MyDiffClassLoader.loader2);
--- a/hotspot/test/runtime/modules/AccessCheck/UmodUPkg.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/hotspot/test/runtime/modules/AccessCheck/UmodUPkg.java	Tue Apr 18 22:25:33 2017 +0200
@@ -40,8 +40,6 @@
 import java.lang.module.Configuration;
 import java.lang.module.ModuleDescriptor;
 import java.lang.module.ModuleFinder;
-import java.lang.reflect.Layer;
-import java.lang.reflect.Module;
 import java.util.HashMap;
 import java.util.Map;
 import java.util.Set;
@@ -63,7 +61,7 @@
 //
 public class UmodUPkg {
 
- // Create Layers over the boot layer to test different
+ // Create layers over the boot layer to test different
  // accessing scenarios of a named module to an unnamed module.
 
  // Module m1x is a strict module and has not established
@@ -84,7 +82,7 @@
      ModuleFinder finder = ModuleLibrary.of(descriptor_m1x);
 
      // Resolves "m1x"
-     Configuration cf = Layer.boot()
+     Configuration cf = ModuleLayer.boot()
              .configuration()
              .resolve(finder, ModuleFinder.of(), Set.of("m1x"));
 
@@ -94,8 +92,8 @@
      Map<String, ClassLoader> map = new HashMap<>();
      map.put("m1x", loader);
 
-     // Create Layer that contains m1x
-     Layer layer = Layer.boot().defineModules(cf, map::get);
+     // Create layer that contains m1x
+     ModuleLayer layer = ModuleLayer.boot().defineModules(cf, map::get);
 
      assertTrue(layer.findLoader("m1x") == loader);
      assertTrue(layer.findLoader("java.base") == null);
@@ -130,7 +128,7 @@
      ModuleFinder finder = ModuleLibrary.of(descriptor_m1x);
 
      // Resolves "m1x"
-     Configuration cf = Layer.boot()
+     Configuration cf = ModuleLayer.boot()
              .configuration()
              .resolve(finder, ModuleFinder.of(), Set.of("m1x"));
 
@@ -140,8 +138,8 @@
      Map<String, ClassLoader> map = new HashMap<>();
      map.put("m1x", loader);
 
-     // Create Layer that contains m1x
-     Layer layer = Layer.boot().defineModules(cf, map::get);
+     // Create layer that contains m1x
+     ModuleLayer layer = ModuleLayer.boot().defineModules(cf, map::get);
 
      assertTrue(layer.findLoader("m1x") == loader);
      assertTrue(layer.findLoader("java.base") == null);
--- a/hotspot/test/runtime/modules/AccessCheck/UmodUpkgDiffCL_ExpQualOther.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/hotspot/test/runtime/modules/AccessCheck/UmodUpkgDiffCL_ExpQualOther.java	Tue Apr 18 22:25:33 2017 +0200
@@ -38,7 +38,6 @@
 
 import static jdk.test.lib.Asserts.*;
 
-import java.lang.reflect.Layer;
 import java.lang.module.Configuration;
 import java.lang.module.ModuleDescriptor;
 import java.lang.module.ModuleFinder;
@@ -60,7 +59,7 @@
 //
 public class UmodUpkgDiffCL_ExpQualOther {
 
-    // Create a Layer over the boot layer.
+    // Create a layer over the boot layer.
     // Define modules within this layer to test access between
     // publically defined classes within packages of those modules.
     public void createLayerOnBoot() throws Throwable {
@@ -89,7 +88,7 @@
         ModuleFinder finder = ModuleLibrary.of(descriptor_m1x, descriptor_m2x);
 
         // Resolves "m1x"
-        Configuration cf = Layer.boot()
+        Configuration cf = ModuleLayer.boot()
                 .configuration()
                 .resolve(finder, ModuleFinder.of(), Set.of("m1x"));
 
@@ -98,8 +97,8 @@
         map.put("m1x", MyDiffClassLoader.loader1);
         map.put("m2x", MyDiffClassLoader.loader2);
 
-        // Create Layer that contains m1x & m2x
-        Layer layer = Layer.boot().defineModules(cf, map::get);
+        // Create layer that contains m1x & m2x
+        ModuleLayer layer = ModuleLayer.boot().defineModules(cf, map::get);
 
         assertTrue(layer.findLoader("m1x") == MyDiffClassLoader.loader1);
         assertTrue(layer.findLoader("m2x") == MyDiffClassLoader.loader2);
--- a/hotspot/test/runtime/modules/AccessCheck/UmodUpkgDiffCL_NotExp.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/hotspot/test/runtime/modules/AccessCheck/UmodUpkgDiffCL_NotExp.java	Tue Apr 18 22:25:33 2017 +0200
@@ -37,7 +37,6 @@
 
 import static jdk.test.lib.Asserts.*;
 
-import java.lang.reflect.Layer;
 import java.lang.module.Configuration;
 import java.lang.module.ModuleDescriptor;
 import java.lang.module.ModuleFinder;
@@ -59,7 +58,7 @@
 //
 public class UmodUpkgDiffCL_NotExp {
 
-    // Create a Layer over the boot layer.
+    // Create a layer over the boot layer.
     // Define modules within this layer to test access between
     // publically defined classes within packages of those modules.
     public void createLayerOnBoot() throws Throwable {
@@ -88,7 +87,7 @@
         ModuleFinder finder = ModuleLibrary.of(descriptor_m1x, descriptor_m2x);
 
         // Resolves "m1x"
-        Configuration cf = Layer.boot()
+        Configuration cf = ModuleLayer.boot()
                 .configuration()
                 .resolve(finder, ModuleFinder.of(), Set.of("m1x"));
 
@@ -97,8 +96,8 @@
         map.put("m1x", MyDiffClassLoader.loader1);
         map.put("m2x", MyDiffClassLoader.loader2);
 
-        // Create Layer that contains m1x & m2x
-        Layer layer = Layer.boot().defineModules(cf, map::get);
+        // Create layer that contains m1x & m2x
+        ModuleLayer layer = ModuleLayer.boot().defineModules(cf, map::get);
 
         assertTrue(layer.findLoader("m1x") == MyDiffClassLoader.loader1);
         assertTrue(layer.findLoader("m2x") == MyDiffClassLoader.loader2);
--- a/hotspot/test/runtime/modules/AccessCheck/UmodUpkg_ExpQualOther.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/hotspot/test/runtime/modules/AccessCheck/UmodUpkg_ExpQualOther.java	Tue Apr 18 22:25:33 2017 +0200
@@ -37,7 +37,6 @@
 
 import static jdk.test.lib.Asserts.*;
 
-import java.lang.reflect.Layer;
 import java.lang.module.Configuration;
 import java.lang.module.ModuleDescriptor;
 import java.lang.module.ModuleFinder;
@@ -59,12 +58,12 @@
 //
 public class UmodUpkg_ExpQualOther {
 
-    // Create a Layer over the boot layer.
+    // Create a layer over the boot layer.
     // Define modules within this layer to test access between
     // publically defined classes within packages of those modules.
     public void createLayerOnBoot() throws Throwable {
 
-        // Define module:     m1x (need to define m1x to establish the Layer successfully)
+        // Define module:     m1x (need to define m1x to establish the layer successfully)
         // Can read:          java.base, m2x, m3x
         // Packages:          none
         // Packages exported: none
@@ -98,7 +97,7 @@
         ModuleFinder finder = ModuleLibrary.of(descriptor_m1x, descriptor_m2x, descriptor_m3x);
 
         // Resolves "m1x"
-        Configuration cf = Layer.boot()
+        Configuration cf = ModuleLayer.boot()
                 .configuration()
                 .resolve(finder, ModuleFinder.of(), Set.of("m1x"));
 
@@ -108,8 +107,8 @@
         map.put("m2x", MySameClassLoader.loader1);
         map.put("m3x", MySameClassLoader.loader1);
 
-        // Create Layer that contains m1x, m2x and m3x
-        Layer layer = Layer.boot().defineModules(cf, map::get);
+        // Create layer that contains m1x, m2x and m3x
+        ModuleLayer layer = ModuleLayer.boot().defineModules(cf, map::get);
 
         assertTrue(layer.findLoader("m1x") == MySameClassLoader.loader1);
         assertTrue(layer.findLoader("m2x") == MySameClassLoader.loader1);
--- a/hotspot/test/runtime/modules/AccessCheck/UmodUpkg_NotExp.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/hotspot/test/runtime/modules/AccessCheck/UmodUpkg_NotExp.java	Tue Apr 18 22:25:33 2017 +0200
@@ -37,7 +37,6 @@
 
 import static jdk.test.lib.Asserts.*;
 
-import java.lang.reflect.Layer;
 import java.lang.module.Configuration;
 import java.lang.module.ModuleDescriptor;
 import java.lang.module.ModuleFinder;
@@ -57,7 +56,7 @@
 //
 public class UmodUpkg_NotExp {
 
-    // Create a Layer over the boot layer.
+    // Create a layer over the boot layer.
     // Define modules within this layer to test access between
     // publically defined classes within packages of those modules.
     public void createLayerOnBoot() throws Throwable {
@@ -86,7 +85,7 @@
         ModuleFinder finder = ModuleLibrary.of(descriptor_m1x, descriptor_m2x);
 
         // Resolves "m1x"
-        Configuration cf = Layer.boot()
+        Configuration cf = ModuleLayer.boot()
                 .configuration()
                 .resolve(finder, ModuleFinder.of(), Set.of("m1x"));
 
@@ -95,8 +94,8 @@
         map.put("m1x", MySameClassLoader.loader1);
         map.put("m2x", MySameClassLoader.loader1);
 
-        // Create Layer that contains m1x and m2x
-        Layer layer = Layer.boot().defineModules(cf, map::get);
+        // Create layer that contains m1x and m2x
+        ModuleLayer layer = ModuleLayer.boot().defineModules(cf, map::get);
 
         assertTrue(layer.findLoader("m1x") == MySameClassLoader.loader1);
         assertTrue(layer.findLoader("m2x") == MySameClassLoader.loader1);
--- a/hotspot/test/runtime/modules/AccessCheck/Umod_ExpQualOther.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/hotspot/test/runtime/modules/AccessCheck/Umod_ExpQualOther.java	Tue Apr 18 22:25:33 2017 +0200
@@ -37,7 +37,6 @@
 
 import static jdk.test.lib.Asserts.*;
 
-import java.lang.reflect.Layer;
 import java.lang.module.Configuration;
 import java.lang.module.ModuleDescriptor;
 import java.lang.module.ModuleFinder;
@@ -59,12 +58,12 @@
 //
 public class Umod_ExpQualOther {
 
-    // Create a Layer over the boot layer.
+    // Create a layer over the boot layer.
     // Define modules within this layer to test access between
     // publically defined classes within packages of those modules.
     public void createLayerOnBoot() throws Throwable {
 
-        // Define module:     m1x (need to define m1x to establish the Layer successfully)
+        // Define module:     m1x (need to define m1x to establish the layer successfully)
         // Can read:          java.base, m2x, m3x
         // Packages:          none
         // Packages exported: none
@@ -98,7 +97,7 @@
         ModuleFinder finder = ModuleLibrary.of(descriptor_m1x, descriptor_m2x, descriptor_m3x);
 
         // Resolves "m1x"
-        Configuration cf = Layer.boot()
+        Configuration cf = ModuleLayer.boot()
                 .configuration()
                 .resolve(finder, ModuleFinder.of(), Set.of("m1x"));
 
@@ -108,8 +107,8 @@
         map.put("m2x", MySameClassLoader.loader1);
         map.put("m3x", MySameClassLoader.loader1);
 
-        // Create Layer that contains m1x, m2x and m3x
-        Layer layer = Layer.boot().defineModules(cf, map::get);
+        // Create layer that contains m1x, m2x and m3x
+        ModuleLayer layer = ModuleLayer.boot().defineModules(cf, map::get);
 
         assertTrue(layer.findLoader("m1x") == MySameClassLoader.loader1);
         assertTrue(layer.findLoader("m2x") == MySameClassLoader.loader1);
--- a/hotspot/test/runtime/modules/AccessCheck/Umod_ExpUnqual.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/hotspot/test/runtime/modules/AccessCheck/Umod_ExpUnqual.java	Tue Apr 18 22:25:33 2017 +0200
@@ -37,7 +37,6 @@
 
 import static jdk.test.lib.Asserts.*;
 
-import java.lang.reflect.Layer;
 import java.lang.module.Configuration;
 import java.lang.module.ModuleDescriptor;
 import java.lang.module.ModuleFinder;
@@ -59,7 +58,7 @@
 
 public class Umod_ExpUnqual {
 
-    // Create a Layer over the boot layer.
+    // Create a layer over the boot layer.
     // Define modules within this layer to test access between
     // publically defined classes within packages of those modules.
     public void createLayerOnBoot() throws Throwable {
@@ -88,7 +87,7 @@
         ModuleFinder finder = ModuleLibrary.of(descriptor_m1x, descriptor_m2x);
 
         // Resolves "m1x"
-        Configuration cf = Layer.boot()
+        Configuration cf = ModuleLayer.boot()
                 .configuration()
                 .resolve(finder, ModuleFinder.of(), Set.of("m1x"));
 
@@ -97,8 +96,8 @@
         map.put("m1x", MySameClassLoader.loader1);
         map.put("m2x", MySameClassLoader.loader1);
 
-        // Create Layer that contains m1x & m2x
-        Layer layer = Layer.boot().defineModules(cf, map::get);
+        // Create layer that contains m1x & m2x
+        ModuleLayer layer = ModuleLayer.boot().defineModules(cf, map::get);
 
         assertTrue(layer.findLoader("m1x") == MySameClassLoader.loader1);
         assertTrue(layer.findLoader("m2x") == MySameClassLoader.loader1);
--- a/hotspot/test/runtime/modules/AccessCheck/Umod_PkgNotExp.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/hotspot/test/runtime/modules/AccessCheck/Umod_PkgNotExp.java	Tue Apr 18 22:25:33 2017 +0200
@@ -37,7 +37,6 @@
 
 import static jdk.test.lib.Asserts.*;
 
-import java.lang.reflect.Layer;
 import java.lang.module.Configuration;
 import java.lang.module.ModuleDescriptor;
 import java.lang.module.ModuleFinder;
@@ -57,7 +56,7 @@
 //
 public class Umod_PkgNotExp {
 
-    // Create a Layer over the boot layer.
+    // Create a layer over the boot layer.
     // Define modules within this layer to test access between
     // publically defined classes within packages of those modules.
     public void createLayerOnBoot() throws Throwable {
@@ -86,7 +85,7 @@
         ModuleFinder finder = ModuleLibrary.of(descriptor_m1x, descriptor_m2x);
 
         // Resolves "m1x"
-        Configuration cf = Layer.boot()
+        Configuration cf = ModuleLayer.boot()
                 .configuration()
                 .resolve(finder, ModuleFinder.of(), Set.of("m1x"));
 
@@ -95,8 +94,8 @@
         map.put("m1x", MySameClassLoader.loader1);
         map.put("m2x", MySameClassLoader.loader1);
 
-        // Create Layer that contains m1x and m2x
-        Layer layer = Layer.boot().defineModules(cf, map::get);
+        // Create layer that contains m1x and m2x
+        ModuleLayer layer = ModuleLayer.boot().defineModules(cf, map::get);
 
         assertTrue(layer.findLoader("m1x") == MySameClassLoader.loader1);
         assertTrue(layer.findLoader("m2x") == MySameClassLoader.loader1);
--- a/hotspot/test/runtime/modules/AccessCheck/p1/c1ReadEdge.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/hotspot/test/runtime/modules/AccessCheck/p1/c1ReadEdge.java	Tue Apr 18 22:25:33 2017 +0200
@@ -22,7 +22,6 @@
  */
 package p1;
 
-import java.lang.reflect.*;
 import p2.c2;
 
 public class c1ReadEdge {
--- a/hotspot/test/runtime/modules/AccessCheck/p1/c1ReadEdgeDiffLoader.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/hotspot/test/runtime/modules/AccessCheck/p1/c1ReadEdgeDiffLoader.java	Tue Apr 18 22:25:33 2017 +0200
@@ -22,7 +22,6 @@
  */
 package p1;
 
-import java.lang.reflect.*;
 import myloaders.MyDiffClassLoader;
 import p2.c2;
 
--- a/hotspot/test/runtime/modules/AccessCheck/p3/c3ReadEdge.jcod	Tue Apr 18 13:19:42 2017 -0400
+++ b/hotspot/test/runtime/modules/AccessCheck/p3/c3ReadEdge.jcod	Tue Apr 18 22:25:33 2017 +0200
@@ -23,7 +23,6 @@
 
 /*
  * package p3;
- * import java.lang.reflect.*;
  * public class c3ReadEdge {
  *    public c3ReadEdge() {
  *       // Establish read edge from module m1x, where c3ReadEdge is defined,
@@ -75,14 +74,14 @@
     Utf8 "java/lang/Object"; // #28     at 0xBC
     Utf8 "java/lang/Class"; // #29     at 0xCF
     Utf8 "getModule"; // #30     at 0xE1
-    Utf8 "()Ljava/lang/reflect/Module;"; // #31     at 0xED
+    Utf8 "()Ljava/lang/Module;"; // #31     at 0xED
     Utf8 "getClassLoader"; // #32     at 0x010C
     Utf8 "()Ljava/lang/ClassLoader;"; // #33     at 0x011D
     Utf8 "java/lang/ClassLoader"; // #34     at 0x0139
     Utf8 "getUnnamedModule"; // #35     at 0x0151
-    Utf8 "java/lang/reflect/Module"; // #36     at 0x0164
+    Utf8 "java/lang/Module"; // #36     at 0x0164
     Utf8 "addReads"; // #37     at 0x017F
-    Utf8 "(Ljava/lang/reflect/Module;)Ljava/lang/reflect/Module;"; // #38     at 0x018A
+    Utf8 "(Ljava/lang/Module;)Ljava/lang/Module;"; // #38     at 0x018A
     Utf8 "method4"; // #39     at 0x01C3
   } // Constant Pool
 
--- a/hotspot/test/runtime/modules/AccessCheck/p3/c3ReadEdgeDiffLoader.jcod	Tue Apr 18 13:19:42 2017 -0400
+++ b/hotspot/test/runtime/modules/AccessCheck/p3/c3ReadEdgeDiffLoader.jcod	Tue Apr 18 22:25:33 2017 +0200
@@ -23,7 +23,6 @@
 
 /* 
  * package p3;
- * import java.lang.reflect.*;
  * import myloaders.MyDiffClassLoader;
  *
  * public class c3ReadEdgeDiffLoader {
@@ -100,14 +99,14 @@
     Utf8 "java/lang/Object"; // #31     at 0xDD
     Utf8 "java/lang/Class"; // #32     at 0xF0
     Utf8 "getModule"; // #33     at 0x0102
-    Utf8 "()Ljava/lang/reflect/Module;"; // #34     at 0x010E
+    Utf8 "()Ljava/lang/Module;"; // #34     at 0x010E
     Utf8 "java/lang/ClassLoader"; // #35     at 0x012D
     Utf8 "getSystemClassLoader"; // #36     at 0x0145
     Utf8 "()Ljava/lang/ClassLoader;"; // #37     at 0x015C
     Utf8 "getUnnamedModule"; // #38     at 0x0178
-    Utf8 "java/lang/reflect/Module"; // #39     at 0x018B
+    Utf8 "java/lang/Module"; // #39     at 0x018B
     Utf8 "addReads"; // #40     at 0x01A6
-    Utf8 "(Ljava/lang/reflect/Module;)Ljava/lang/reflect/Module;"; // #41     at 0x01B1
+    Utf8 "(Ljava/lang/Module;)Ljava/lang/Module;"; // #41     at 0x01B1
     Utf8 "myloaders/MyDiffClassLoader"; // #42     at 0x01EA
     Utf8 "loader2"; // #43     at 0x0208
     Utf8 "Lmyloaders/MyDiffClassLoader;"; // #44     at 0x0212
--- a/hotspot/test/runtime/modules/AccessCheck/p4/c4.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/hotspot/test/runtime/modules/AccessCheck/p4/c4.java	Tue Apr 18 22:25:33 2017 +0200
@@ -25,8 +25,6 @@
 
 package p4;
 
-import java.lang.reflect.Module;
-
 public class c4 {
     // Add a read edge from c4's module to given module m
     public void addReads(Module m) {
--- a/hotspot/test/runtime/modules/AccessCheckAllUnnamed.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/hotspot/test/runtime/modules/AccessCheckAllUnnamed.java	Tue Apr 18 22:25:33 2017 +0200
@@ -21,7 +21,6 @@
  * questions.
  */
 
-import java.lang.reflect.Module;
 import static jdk.test.lib.Asserts.*;
 
 /*
@@ -31,7 +30,7 @@
  * @compile p2/c2.java
  * @compile p1/c1.java
  * @build sun.hotspot.WhiteBox
- * @compile/module=java.base java/lang/reflect/ModuleHelper.java
+ * @compile/module=java.base java/lang/ModuleHelper.java
  * @run main ClassFileInstaller sun.hotspot.WhiteBox
  *                              sun.hotspot.WhiteBox$WhiteBoxPermission
  * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI AccessCheckAllUnnamed
@@ -45,10 +44,10 @@
     public static void main(String args[]) throws Throwable {
         Object m1x, m2x;
 
-        // Get the java.lang.reflect.Module object for module java.base.
+        // Get the java.lang.Module object for module java.base.
         Class jlObject = Class.forName("java.lang.Object");
-        Object jlObject_jlrM = jlObject.getModule();
-        assertNotNull(jlObject_jlrM, "jlrModule object of java.lang.Object should not be null");
+        Object jlM = jlObject.getModule();
+        assertNotNull(jlM, "jlModule object of java.lang.Object should not be null");
 
         // Get the class loader for AccessCheckWorks and assume it's also used to
         // load class p2.c2.
@@ -58,13 +57,13 @@
         m1x = ModuleHelper.ModuleObject("module_one", this_cldr, new String[] { "p3" });
         assertNotNull(m1x, "Module should not be null");
         ModuleHelper.DefineModule(m1x, "9.0", "m1x/there", new String[] { "p3" });
-        ModuleHelper.AddReadsModule(m1x, jlObject_jlrM);
+        ModuleHelper.AddReadsModule(m1x, jlM);
 
         // Define a module for p2.
         m2x = ModuleHelper.ModuleObject("module_two", this_cldr, new String[] { "p2" });
         assertNotNull(m2x, "Module should not be null");
         ModuleHelper.DefineModule(m2x, "9.0", "m2x/there", new String[] { "p2" });
-        ModuleHelper.AddReadsModule(m2x, jlObject_jlrM);
+        ModuleHelper.AddReadsModule(m2x, jlM);
 
         try {
             ModuleHelper.AddModuleExportsToAllUnnamed((Module)null, "p2");
--- a/hotspot/test/runtime/modules/AccessCheckExp.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/hotspot/test/runtime/modules/AccessCheckExp.java	Tue Apr 18 22:25:33 2017 +0200
@@ -28,13 +28,12 @@
  * @compile p2/c2.java
  * @compile p1/c1.java
  * @build sun.hotspot.WhiteBox
- * @compile/module=java.base java/lang/reflect/ModuleHelper.java
+ * @compile/module=java.base java/lang/ModuleHelper.java
  * @run main ClassFileInstaller sun.hotspot.WhiteBox
  *                              sun.hotspot.WhiteBox$WhiteBoxPermission
  * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI AccessCheckExp
  */
 
-import java.lang.reflect.Module;
 import static jdk.test.lib.Asserts.*;
 
 public class AccessCheckExp {
@@ -44,10 +43,10 @@
     public static void main(String args[]) throws Throwable {
         Object m1x, m2x;
 
-        // Get the java.lang.reflect.Module object for module java.base.
+        // Get the java.lang.Module object for module java.base.
         Class jlObject = Class.forName("java.lang.Object");
-        Object jlObject_jlrM = jlObject.getModule();
-        assertNotNull(jlObject_jlrM, "jlrModule object of java.lang.Object should not be null");
+        Object jlObject_jlM = jlObject.getModule();
+        assertNotNull(jlObject_jlM, "jlModule object of java.lang.Object should not be null");
 
         // Get the class loader for AccessCheckExp and assume it's also used to
         // load classes p1.c1 and p2.c2.
@@ -57,13 +56,13 @@
         m1x = ModuleHelper.ModuleObject("module_one", this_cldr, new String[] { "p1" });
         assertNotNull(m1x, "Module should not be null");
         ModuleHelper.DefineModule(m1x, "9.0", "m1x/here", new String[] { "p1" });
-        ModuleHelper.AddReadsModule(m1x, jlObject_jlrM);
+        ModuleHelper.AddReadsModule(m1x, jlObject_jlM);
 
         // Define a module for p2.
         m2x = ModuleHelper.ModuleObject("module_two", this_cldr, new String[] { "p2" });
         assertNotNull(m2x, "Module should not be null");
         ModuleHelper.DefineModule(m2x, "9.0", "m2x/there", new String[] { "p2" });
-        ModuleHelper.AddReadsModule(m2x, jlObject_jlrM);
+        ModuleHelper.AddReadsModule(m2x, jlObject_jlM);
 
         // Make package p1 in m1x visible to everyone.
         ModuleHelper.AddModuleExportsToAll(m1x, "p1");
--- a/hotspot/test/runtime/modules/AccessCheckJavaBase.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/hotspot/test/runtime/modules/AccessCheckJavaBase.java	Tue Apr 18 22:25:33 2017 +0200
@@ -27,13 +27,12 @@
  * @library /test/lib ..
  * @compile p2/c2.java
  * @build sun.hotspot.WhiteBox
- * @compile/module=java.base java/lang/reflect/ModuleHelper.java
+ * @compile/module=java.base java/lang/ModuleHelper.java
  * @run main ClassFileInstaller sun.hotspot.WhiteBox
  *                              sun.hotspot.WhiteBox$WhiteBoxPermission
  * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI AccessCheckJavaBase
  */
 
-import java.lang.reflect.Module;
 import static jdk.test.lib.Asserts.*;
 
 public class AccessCheckJavaBase {
--- a/hotspot/test/runtime/modules/AccessCheckRead.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/hotspot/test/runtime/modules/AccessCheckRead.java	Tue Apr 18 22:25:33 2017 +0200
@@ -28,13 +28,12 @@
  * @compile p2/c2.java
  * @compile p1/c1.java
  * @build sun.hotspot.WhiteBox
- * @compile/module=java.base java/lang/reflect/ModuleHelper.java
+ * @compile/module=java.base java/lang/ModuleHelper.java
  * @run main ClassFileInstaller sun.hotspot.WhiteBox
  *                              sun.hotspot.WhiteBox$WhiteBoxPermission
  * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI AccessCheckRead
  */
 
-import java.lang.reflect.Module;
 import static jdk.test.lib.Asserts.*;
 
 public class AccessCheckRead {
@@ -44,10 +43,10 @@
     public static void main(String args[]) throws Throwable {
         Object m1x, m2x;
 
-        // Get the java.lang.reflect.Module object for module java.base.
+        // Get the java.lang.Module object for module java.base.
         Class jlObject = Class.forName("java.lang.Object");
-        Object jlObject_jlrM = jlObject.getModule();
-        assertNotNull(jlObject_jlrM, "jlrModule object of java.lang.Object should not be null");
+        Object jlObject_jlM = jlObject.getModule();
+        assertNotNull(jlObject_jlM, "jlModule object of java.lang.Object should not be null");
 
         // Get the class loader for AccessCheckRead and assume it's also used to
         // load classes p1.c1 and p2.c2.
@@ -57,13 +56,13 @@
         m1x = ModuleHelper.ModuleObject("module_one", this_cldr, new String[] { "p1" });
         assertNotNull(m1x, "Module should not be null");
         ModuleHelper.DefineModule(m1x, "9.0", "m1x/here", new String[] { "p1" });
-        ModuleHelper.AddReadsModule(m1x, jlObject_jlrM);
+        ModuleHelper.AddReadsModule(m1x, jlObject_jlM);
 
         // Define a module for p2.
         m2x = ModuleHelper.ModuleObject("module_two", this_cldr, new String[] { "p2" });
         assertNotNull(m2x, "Module should not be null");
         ModuleHelper.DefineModule(m2x, "9.0", "m2x/there", new String[] { "p2" });
-        ModuleHelper.AddReadsModule(m2x, jlObject_jlrM);
+        ModuleHelper.AddReadsModule(m2x, jlObject_jlM);
 
         // Make package p1 in m1x visible to everyone.
         ModuleHelper.AddModuleExportsToAll(m1x, "p1");
--- a/hotspot/test/runtime/modules/AccessCheckSuper.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/hotspot/test/runtime/modules/AccessCheckSuper.java	Tue Apr 18 22:25:33 2017 +0200
@@ -28,13 +28,12 @@
  * @compile p2/c2.java
  * @compile p3/c3.java
  * @build sun.hotspot.WhiteBox
- * @compile/module=java.base java/lang/reflect/ModuleHelper.java
+ * @compile/module=java.base java/lang/ModuleHelper.java
  * @run main ClassFileInstaller sun.hotspot.WhiteBox
  *                              sun.hotspot.WhiteBox$WhiteBoxPermission
  * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI AccessCheckSuper
  */
 
-import java.lang.reflect.Module;
 import static jdk.test.lib.Asserts.*;
 
 public class AccessCheckSuper {
--- a/hotspot/test/runtime/modules/AccessCheckUnnamed.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/hotspot/test/runtime/modules/AccessCheckUnnamed.java	Tue Apr 18 22:25:33 2017 +0200
@@ -21,7 +21,6 @@
  * questions.
  */
 
-import java.lang.reflect.Module;
 import static jdk.test.lib.Asserts.*;
 
 /*
@@ -31,7 +30,7 @@
  * @compile p2/c2.java
  * @compile p1/c1.java
  * @build sun.hotspot.WhiteBox
- * @compile/module=java.base java/lang/reflect/ModuleHelper.java
+ * @compile/module=java.base java/lang/ModuleHelper.java
  * @run main ClassFileInstaller sun.hotspot.WhiteBox
  *                              sun.hotspot.WhiteBox$WhiteBoxPermission
  * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI AccessCheckUnnamed
@@ -44,10 +43,10 @@
     public static void main(String args[]) throws Throwable {
         Object m1x, m2x;
 
-        // Get the java.lang.reflect.Module object for module java.base.
+        // Get the java.lang.Module object for module java.base.
         Class jlObject = Class.forName("java.lang.Object");
-        Object jlObject_jlrM = jlObject.getModule();
-        assertNotNull(jlObject_jlrM, "jlrModule object of java.lang.Object should not be null");
+        Object jlObject_jlM = jlObject.getModule();
+        assertNotNull(jlObject_jlM, "jlModule object of java.lang.Object should not be null");
 
         // Get the class loader for AccessCheckWorks and assume it's also used to
         // load class p2.c2.
@@ -57,7 +56,7 @@
         m2x = ModuleHelper.ModuleObject("module_two", this_cldr, new String[] { "p2" });
         assertNotNull(m2x, "Module should not be null");
         ModuleHelper.DefineModule(m2x, "9.0", "m2x/there", new String[] { "p2" });
-        ModuleHelper.AddReadsModule(m2x, jlObject_jlrM);
+        ModuleHelper.AddReadsModule(m2x, jlObject_jlM);
 
         // p1.c1's ctor tries to call a method in p2.c2.  This should fail because
         // p1 is in the unnamed module and p2.c2 is not unqualifiedly exported.
--- a/hotspot/test/runtime/modules/AccessCheckWorks.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/hotspot/test/runtime/modules/AccessCheckWorks.java	Tue Apr 18 22:25:33 2017 +0200
@@ -28,13 +28,12 @@
  * @compile p2/c2.java
  * @compile p1/c1.java
  * @build sun.hotspot.WhiteBox
- * @compile/module=java.base java/lang/reflect/ModuleHelper.java
+ * @compile/module=java.base java/lang/ModuleHelper.java
  * @run main ClassFileInstaller sun.hotspot.WhiteBox
  *                              sun.hotspot.WhiteBox$WhiteBoxPermission
  * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI AccessCheckWorks
  */
 
-import java.lang.reflect.Module;
 import static jdk.test.lib.Asserts.*;
 
 public class AccessCheckWorks {
@@ -45,10 +44,10 @@
     public static void main(String args[]) throws Throwable {
         Object m1x, m2x;
 
-        // Get the java.lang.reflect.Module object for module java.base.
+        // Get the java.lang.Module object for module java.base.
         Class jlObject = Class.forName("java.lang.Object");
-        Object jlObject_jlrM = jlObject.getModule();
-        assertNotNull(jlObject_jlrM, "jlrModule object of java.lang.Object should not be null");
+        Object jlObject_jlM = jlObject.getModule();
+        assertNotNull(jlObject_jlM, "jlModule object of java.lang.Object should not be null");
 
         // Get the class loader for AccessCheckWorks and assume it's also used to
         // load classes p1.c1 and p2.c2.
@@ -58,13 +57,13 @@
         m1x = ModuleHelper.ModuleObject("module_one", this_cldr, new String[] { "p1" });
         assertNotNull(m1x, "Module should not be null");
         ModuleHelper.DefineModule(m1x, "9.0", "m1x/here", new String[] { "p1" });
-        ModuleHelper.AddReadsModule(m1x, jlObject_jlrM);
+        ModuleHelper.AddReadsModule(m1x, jlObject_jlM);
 
         // Define a module for p2.
         m2x = ModuleHelper.ModuleObject("module_two", this_cldr, new String[] { "p2" });
         assertNotNull(m2x, "Module should not be null");
         ModuleHelper.DefineModule(m2x, "9.0", "m2x/there", new String[] { "p2" });
-        ModuleHelper.AddReadsModule(m2x, jlObject_jlrM);
+        ModuleHelper.AddReadsModule(m2x, jlObject_jlM);
 
         // Make package p1 in m1x visible to everyone.
         ModuleHelper.AddModuleExportsToAll(m1x, "p1");
--- a/hotspot/test/runtime/modules/CCE_module_msg.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/hotspot/test/runtime/modules/CCE_module_msg.java	Tue Apr 18 22:25:33 2017 +0200
@@ -28,14 +28,13 @@
  * @compile p2/c2.java
  * @compile p4/c4.java
  * @build sun.hotspot.WhiteBox
- * @compile/module=java.base java/lang/reflect/ModuleHelper.java
+ * @compile/module=java.base java/lang/ModuleHelper.java
  * @run main ClassFileInstaller sun.hotspot.WhiteBox
  *                              sun.hotspot.WhiteBox$WhiteBoxPermission
  * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI CCE_module_msg
  */
 
 import java.io.*;
-import java.lang.reflect.Module;
 import java.net.URL;
 import java.net.URLClassLoader;
 import java.nio.file.Path;
@@ -73,10 +72,10 @@
     }
 
     public static void invalidClassToString() throws Throwable {
-        // Get the java.lang.reflect.Module object for module java.base.
+        // Get the java.lang.Module object for module java.base.
         Class jlObject = Class.forName("java.lang.Object");
-        Object jlObject_jlrM = jlObject.getModule();
-        assertNotNull(jlObject_jlrM, "jlrModule object of java.lang.Object should not be null");
+        Object jlObject_jlM = jlObject.getModule();
+        assertNotNull(jlObject_jlM, "jlModule object of java.lang.Object should not be null");
 
         // Get the class loader for CCE_module_msg and assume it's also used to
         // load classes p1.c1 and p2.c2.
@@ -86,7 +85,7 @@
         Object m2x = ModuleHelper.ModuleObject("module_two", this_cldr, new String[] { "p2" });
         assertNotNull(m2x, "Module should not be null");
         ModuleHelper.DefineModule(m2x, "9.0", "m2x/there", new String[] { "p2" });
-        ModuleHelper.AddReadsModule(m2x, jlObject_jlrM);
+        ModuleHelper.AddReadsModule(m2x, jlObject_jlM);
 
         try {
             ModuleHelper.AddModuleExportsToAll(m2x, "p2");
@@ -105,10 +104,10 @@
     }
 
     public static void invalidClassToStringCustomLoader() throws Throwable {
-        // Get the java.lang.reflect.Module object for module java.base.
+        // Get the java.lang.Module object for module java.base.
         Class jlObject = Class.forName("java.lang.Object");
-        Object jlObject_jlrM = jlObject.getModule();
-        assertNotNull(jlObject_jlrM, "jlrModule object of java.lang.Object should not be null");
+        Object jlObject_jlM = jlObject.getModule();
+        assertNotNull(jlObject_jlM, "jlModule object of java.lang.Object should not be null");
 
         // Create a customer class loader to load class p4/c4.
         URL[] urls = new URL[] { CLASSES_DIR.toUri().toURL() };
--- a/hotspot/test/runtime/modules/ExportTwice.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/hotspot/test/runtime/modules/ExportTwice.java	Tue Apr 18 22:25:33 2017 +0200
@@ -28,13 +28,12 @@
  * @compile p2/c2.java
  * @compile p1/c1.java
  * @build sun.hotspot.WhiteBox
- * @compile/module=java.base java/lang/reflect/ModuleHelper.java
+ * @compile/module=java.base java/lang/ModuleHelper.java
  * @run main ClassFileInstaller sun.hotspot.WhiteBox
  *                              sun.hotspot.WhiteBox$WhiteBoxPermission
  * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI ExportTwice
  */
 
-import java.lang.reflect.Module;
 import static jdk.test.lib.Asserts.*;
 
 public class ExportTwice {
@@ -46,10 +45,10 @@
     public static void main(String args[]) throws Throwable {
         Object m1x, m2x, m3x;
 
-        // Get the java.lang.reflect.Module object for module java.base.
+        // Get the java.lang.Module object for module java.base.
         Class jlObject = Class.forName("java.lang.Object");
-        Object jlObject_jlrM = jlObject.getModule();
-        assertNotNull(jlObject_jlrM, "jlrModule object of java.lang.Object should not be null");
+        Object jlObject_jlM = jlObject.getModule();
+        assertNotNull(jlObject_jlM, "jlModule object of java.lang.Object should not be null");
 
         // Get the class loader for ExportTwice and assume it's also used to
         // load classes p1.c1 and p2.c2.
@@ -59,19 +58,19 @@
         m1x = ModuleHelper.ModuleObject("module_one", this_cldr, new String[] { "p1" });
         assertNotNull(m1x, "Module should not be null");
         ModuleHelper.DefineModule(m1x, "9.0", "m1x/here", new String[] { "p1" });
-        ModuleHelper.AddReadsModule(m1x, jlObject_jlrM);
+        ModuleHelper.AddReadsModule(m1x, jlObject_jlM);
 
         // Define a module for p2.
         m2x = ModuleHelper.ModuleObject("module_two", this_cldr, new String[] { "p2" });
         assertNotNull(m2x, "Module should not be null");
         ModuleHelper.DefineModule(m2x, "9.0", "m2x/there", new String[] { "p2" });
-        ModuleHelper.AddReadsModule(m2x, jlObject_jlrM);
+        ModuleHelper.AddReadsModule(m2x, jlObject_jlM);
 
         // Define a module for p3.
         m3x = ModuleHelper.ModuleObject("module_three", this_cldr, new String[] { "p3" });
         assertNotNull(m3x, "Module should not be null");
         ModuleHelper.DefineModule(m3x, "9.0", "m3x/there", new String[] { "p3" });
-        ModuleHelper.AddReadsModule(m3x, jlObject_jlrM);
+        ModuleHelper.AddReadsModule(m3x, jlObject_jlM);
 
         // Make package p1 in m1x visible to everyone.
         ModuleHelper.AddModuleExportsToAll(m1x, "p1");
--- a/hotspot/test/runtime/modules/JVMAddModuleExportToAllUnnamed.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/hotspot/test/runtime/modules/JVMAddModuleExportToAllUnnamed.java	Tue Apr 18 22:25:33 2017 +0200
@@ -30,11 +30,10 @@
  * @build sun.hotspot.WhiteBox
  * @run main ClassFileInstaller sun.hotspot.WhiteBox
  *                              sun.hotspot.WhiteBox$WhiteBoxPermission
- * @compile/module=java.base java/lang/reflect/ModuleHelper.java
+ * @compile/module=java.base java/lang/ModuleHelper.java
  * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI JVMAddModuleExportToAllUnnamed
  */
 
-import java.lang.reflect.Module;
 import static jdk.test.lib.Asserts.*;
 
 public class JVMAddModuleExportToAllUnnamed {
@@ -44,10 +43,10 @@
     public static void main(String args[]) throws Throwable {
         Object m1x;
 
-        // Get the java.lang.reflect.Module object for module java.base.
+        // Get the java.lang.Module object for module java.base.
         Class jlObject = Class.forName("java.lang.Object");
-        Object jlObject_jlrM = jlObject.getModule();
-        assertNotNull(jlObject_jlrM, "jlrModule object of java.lang.Object should not be null");
+        Object jlObject_jlM = jlObject.getModule();
+        assertNotNull(jlObject_jlM, "jlModule object of java.lang.Object should not be null");
 
         // Get the class loader for JVMAddModuleExportToAllUnnamed and assume it's also used to
         // load class p1.c1.
@@ -57,7 +56,7 @@
         m1x = ModuleHelper.ModuleObject("module_one", this_cldr, new String[] { "p1" });
         assertNotNull(m1x, "Module should not be null");
         ModuleHelper.DefineModule(m1x, "9.0", "m1x/here", new String[] { "p1" });
-        ModuleHelper.AddReadsModule(m1x, jlObject_jlrM);
+        ModuleHelper.AddReadsModule(m1x, jlObject_jlM);
 
         // Make package p1 in m1x visible to everyone.
         ModuleHelper.AddModuleExportsToAll(m1x, "p1");
--- a/hotspot/test/runtime/modules/JVMAddModuleExports.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/hotspot/test/runtime/modules/JVMAddModuleExports.java	Tue Apr 18 22:25:33 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2016, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -26,13 +26,12 @@
  * @modules java.base/jdk.internal.misc
  * @library /test/lib ..
  * @build sun.hotspot.WhiteBox
- * @compile/module=java.base java/lang/reflect/ModuleHelper.java
+ * @compile/module=java.base java/lang/ModuleHelper.java
  * @run main ClassFileInstaller sun.hotspot.WhiteBox
  *                              sun.hotspot.WhiteBox$WhiteBoxPermission
  * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI JVMAddModuleExports
  */
 
-import java.lang.reflect.Module;
 import static jdk.test.lib.Asserts.*;
 
 public class JVMAddModuleExports {
--- a/hotspot/test/runtime/modules/JVMAddModuleExportsToAll.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/hotspot/test/runtime/modules/JVMAddModuleExportsToAll.java	Tue Apr 18 22:25:33 2017 +0200
@@ -21,7 +21,6 @@
  * questions.
  */
 
-import java.lang.reflect.Module;
 import static jdk.test.lib.Asserts.*;
 
 /*
@@ -31,7 +30,7 @@
  * @compile p2/c2.java
  * @compile p1/c1.java
  * @build sun.hotspot.WhiteBox
- * @compile/module=java.base java/lang/reflect/ModuleHelper.java
+ * @compile/module=java.base java/lang/ModuleHelper.java
  * @run main ClassFileInstaller sun.hotspot.WhiteBox
  *                              sun.hotspot.WhiteBox$WhiteBoxPermission
  * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI JVMAddModuleExportsToAll
@@ -45,10 +44,10 @@
     public static void main(String args[]) throws Throwable {
         Object m1x, m2x, m3x;
 
-        // Get the java.lang.reflect.Module object for module java.base.
+        // Get the java.lang.Module object for module java.base.
         Class jlObject = Class.forName("java.lang.Object");
-        Object jlObject_jlrM = jlObject.getModule();
-        assertNotNull(jlObject_jlrM, "jlrModule object of java.lang.Object should not be null");
+        Object jlObject_jlM = jlObject.getModule();
+        assertNotNull(jlObject_jlM, "jlModule object of java.lang.Object should not be null");
 
         // Get the class loader for JVMAddModuleExportsToAll and assume it's also used to
         // load class p2.c2.
@@ -58,13 +57,13 @@
         m1x = ModuleHelper.ModuleObject("module_one", this_cldr, new String[] { "p3" });
         assertNotNull(m1x, "Module should not be null");
         ModuleHelper.DefineModule(m1x, "9.0", "m1x/there", new String[] { "p3" });
-        ModuleHelper.AddReadsModule(m1x, jlObject_jlrM);
+        ModuleHelper.AddReadsModule(m1x, jlObject_jlM);
 
         // Define a module for p2.
         m2x = ModuleHelper.ModuleObject("module_two", this_cldr, new String[] { "p2" });
         assertNotNull(m2x, "Module should not be null");
         ModuleHelper.DefineModule(m2x, "9.0", "m2x/there", new String[] { "p2" });
-        ModuleHelper.AddReadsModule(m2x, jlObject_jlrM);
+        ModuleHelper.AddReadsModule(m2x, jlObject_jlM);
 
         try {
             ModuleHelper.AddModuleExportsToAll((Module)null, "p2");
@@ -80,7 +79,7 @@
             // Expected
         }
 
-        try { // Expect IAE when passing a ClassLoader object instead of a java.lang.reflect.Module object.
+        try { // Expect IAE when passing a ClassLoader object instead of a java.lang.Module object.
             ModuleHelper.AddModuleExportsToAll(this_cldr, "p2");
             throw new RuntimeException("Failed to get the expected IAE for bad module");
         } catch(IllegalArgumentException e) {
--- a/hotspot/test/runtime/modules/JVMAddModulePackage.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/hotspot/test/runtime/modules/JVMAddModulePackage.java	Tue Apr 18 22:25:33 2017 +0200
@@ -26,7 +26,7 @@
  * @modules java.base/jdk.internal.misc
  * @library /test/lib ..
  * @build sun.hotspot.WhiteBox
- * @compile/module=java.base java/lang/reflect/ModuleHelper.java
+ * @compile/module=java.base java/lang/ModuleHelper.java
  * @run main ClassFileInstaller sun.hotspot.WhiteBox
  *                              sun.hotspot.WhiteBox$WhiteBoxPermission
  * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI JVMAddModulePackage
--- a/hotspot/test/runtime/modules/JVMAddReadsModule.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/hotspot/test/runtime/modules/JVMAddReadsModule.java	Tue Apr 18 22:25:33 2017 +0200
@@ -26,7 +26,7 @@
  * @modules java.base/jdk.internal.misc
  * @library /test/lib ..
  * @build sun.hotspot.WhiteBox
- * @compile/module=java.base java/lang/reflect/ModuleHelper.java
+ * @compile/module=java.base java/lang/ModuleHelper.java
  * @run main ClassFileInstaller sun.hotspot.WhiteBox
  *                              sun.hotspot.WhiteBox$WhiteBoxPermission
  * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI JVMAddReadsModule
--- a/hotspot/test/runtime/modules/JVMDefineModule.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/hotspot/test/runtime/modules/JVMDefineModule.java	Tue Apr 18 22:25:33 2017 +0200
@@ -26,7 +26,7 @@
  * @modules java.base/jdk.internal.misc
  * @library /test/lib ..
  * @build sun.hotspot.WhiteBox
- * @compile/module=java.base java/lang/reflect/ModuleHelper.java
+ * @compile/module=java.base java/lang/ModuleHelper.java
  * @run main ClassFileInstaller sun.hotspot.WhiteBox
  *                              sun.hotspot.WhiteBox$WhiteBoxPermission
  * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI JVMDefineModule
@@ -78,7 +78,7 @@
             ModuleHelper.DefineModule(new Object(),  "9.0", "mymodule/here", new String[] { "mypackage1" });
             throw new RuntimeException("Failed to get expected IAE or NPE for bad module");
         } catch(IllegalArgumentException e) {
-            if (!e.getMessage().contains("module is not an instance of type java.lang.reflect.Module")) {
+            if (!e.getMessage().contains("module is not an instance of type java.lang.Module")) {
               throw new RuntimeException("Failed to get expected IAE message for bad module: " + e.getMessage());
             }
         }
--- a/hotspot/test/runtime/modules/LoadUnloadModuleStress.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/hotspot/test/runtime/modules/LoadUnloadModuleStress.java	Tue Apr 18 22:25:33 2017 +0200
@@ -27,7 +27,7 @@
  * @modules java.base/jdk.internal.misc
  * @library /test/lib ..
  * @build sun.hotspot.WhiteBox
- * @compile/module=java.base java/lang/reflect/ModuleHelper.java
+ * @compile/module=java.base java/lang/ModuleHelper.java
  * @run main ClassFileInstaller sun.hotspot.WhiteBox
  *                              sun.hotspot.WhiteBox$WhiteBoxPermission
  * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xmx64m -Xmx64m LoadUnloadModuleStress 15000
--- a/hotspot/test/runtime/modules/ModuleHelper.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/hotspot/test/runtime/modules/ModuleHelper.java	Tue Apr 18 22:25:33 2017 +0200
@@ -23,7 +23,6 @@
 
 import java.net.URI;
 import java.lang.module.ModuleDescriptor;
-import java.lang.reflect.Module;
 import java.util.Collections;
 import java.util.HashSet;
 import java.util.Set;
@@ -41,31 +40,31 @@
     public static void AddModuleExports(Object from, String pkg, Object to) throws Throwable {
         WhiteBox wb = WhiteBox.getWhiteBox();
         wb.AddModuleExports(from, pkg, to);
-        java.lang.reflect.ModuleHelper.addExportsNoSync((Module)from, pkg, (Module)to);
+        java.lang.ModuleHelper.addExportsNoSync((Module)from, pkg, (Module)to);
     }
 
     public static void AddReadsModule(Object from, Object to) throws Throwable {
         WhiteBox wb = WhiteBox.getWhiteBox();
         wb.AddReadsModule(from, to);
-        java.lang.reflect.ModuleHelper.addReadsNoSync((Module)from, (Module)to);
+        java.lang.ModuleHelper.addReadsNoSync((Module)from, (Module)to);
     }
 
     public static void AddModulePackage(Object m, String pkg) throws Throwable {
         WhiteBox wb = WhiteBox.getWhiteBox();
         wb.AddModulePackage(m, pkg);
-        java.lang.reflect.ModuleHelper.addPackageNoSync((Module)m, pkg);
+        java.lang.ModuleHelper.addPackageNoSync((Module)m, pkg);
     }
 
     public static void AddModuleExportsToAllUnnamed(Object m, String pkg) throws Throwable {
         WhiteBox wb = WhiteBox.getWhiteBox();
         wb.AddModuleExportsToAllUnnamed(m, pkg);
-        //java.lang.reflect.ModuleHelper.addExportsToAllUnnamedNoSync((Module)m, pkg);
+        //java.lang.ModuleHelper.addExportsToAllUnnamedNoSync((Module)m, pkg);
     }
 
     public static void AddModuleExportsToAll(Object m, String pkg) throws Throwable {
         WhiteBox wb = WhiteBox.getWhiteBox();
         wb.AddModuleExportsToAll(m, pkg);
-        java.lang.reflect.ModuleHelper.addExportsNoSync((Module)m, pkg, (Module)null);
+        java.lang.ModuleHelper.addExportsNoSync((Module)m, pkg, (Module)null);
     }
 
     public static Module ModuleObject(String name, ClassLoader loader, String[] pkgs) throws Throwable {
@@ -82,7 +81,7 @@
             ModuleDescriptor.newModule(name).packages(pkg_set).build();
         URI uri = URI.create("module:/" + name);
 
-        return java.lang.reflect.ModuleHelper.newModule(loader, descriptor);
+        return java.lang.ModuleHelper.newModule(loader, descriptor);
     }
 
 }
--- a/hotspot/test/runtime/modules/ModuleStress/ModuleNonBuiltinCLMain.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/hotspot/test/runtime/modules/ModuleStress/ModuleNonBuiltinCLMain.java	Tue Apr 18 22:25:33 2017 +0200
@@ -25,7 +25,6 @@
 
 import static jdk.test.lib.Asserts.*;
 
-import java.lang.reflect.Layer;
 import java.lang.module.Configuration;
 import java.lang.module.ModuleDescriptor;
 import java.lang.module.ModuleFinder;
@@ -47,7 +46,7 @@
 //
 public class ModuleNonBuiltinCLMain {
 
-    // Create a Layer over the boot layer.
+    // Create a layer over the boot layer.
     // Define modules within this layer to test access between
     // publically defined classes within packages of those modules.
     public void createLayerOnBoot() throws Throwable {
@@ -90,7 +89,7 @@
         ModuleFinder finder = ModuleLibrary.of(descriptor_m1x, descriptor_m2x, descriptor_m3x);
 
         // Resolves "m1x"
-        Configuration cf = Layer.boot()
+        Configuration cf = ModuleLayer.boot()
                 .configuration()
                 .resolve(finder, ModuleFinder.of(), Set.of("m1x"));
 
@@ -103,8 +102,8 @@
         map.put("m2x", cl2);
         map.put("m3x", cl3);
 
-        // Create Layer that contains m1x & m2x
-        Layer layer = Layer.boot().defineModules(cf, map::get);
+        // Create layer that contains m1x & m2x
+        ModuleLayer layer = ModuleLayer.boot().defineModules(cf, map::get);
         assertTrue(layer.findLoader("m1x") == cl1);
         assertTrue(layer.findLoader("m2x") == cl2);
         assertTrue(layer.findLoader("m3x") == cl3);
--- a/hotspot/test/runtime/modules/ModuleStress/ModuleSameCLMain.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/hotspot/test/runtime/modules/ModuleStress/ModuleSameCLMain.java	Tue Apr 18 22:25:33 2017 +0200
@@ -25,7 +25,6 @@
 
 import static jdk.test.lib.Asserts.*;
 
-import java.lang.reflect.Layer;
 import java.lang.module.Configuration;
 import java.lang.module.ModuleDescriptor;
 import java.lang.module.ModuleFinder;
@@ -45,7 +44,7 @@
 //
 public class ModuleSameCLMain {
 
-    // Create a Layer over the boot layer.
+    // Create a layer over the boot layer.
     // Define modules within this layer to test access between
     // publically defined classes within packages of those modules.
     public void createLayerOnBoot() throws Throwable {
@@ -75,7 +74,7 @@
         ModuleFinder finder = ModuleLibrary.of(descriptor_m1x, descriptor_m2x);
 
         // Resolves "m1x"
-        Configuration cf = Layer.boot()
+        Configuration cf = ModuleLayer.boot()
                 .configuration()
                 .resolve(finder, ModuleFinder.of(), Set.of("m1x"));
 
@@ -85,8 +84,8 @@
         map.put("m1x", cl1);
         map.put("m2x", cl1);
 
-        // Create Layer that contains m1x & m2x
-        Layer layer = Layer.boot().defineModules(cf, map::get);
+        // Create layer that contains m1x & m2x
+        ModuleLayer layer = ModuleLayer.boot().defineModules(cf, map::get);
         assertTrue(layer.findLoader("m1x") == cl1);
         assertTrue(layer.findLoader("m2x") == cl1);
         assertTrue(layer.findLoader("java.base") == null);
--- a/hotspot/test/runtime/modules/ModuleStress/src/jdk.test/test/Main.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/hotspot/test/runtime/modules/ModuleStress/src/jdk.test/test/Main.java	Tue Apr 18 22:25:33 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2016, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -25,9 +25,7 @@
 
 import java.lang.module.Configuration;
 import java.lang.module.ModuleFinder;
-import java.lang.reflect.Layer;
 import java.lang.reflect.Method;
-import java.lang.reflect.Module;
 import java.nio.file.Path;
 import java.nio.file.Paths;
 import java.util.*;
@@ -44,7 +42,7 @@
     public static void main(String[] args) throws Exception {
 
         ModuleFinder finder = ModuleFinder.of(MODS_DIR);
-        Layer layerBoot = Layer.boot();
+        ModuleLayer layerBoot = ModuleLayer.boot();
 
         Configuration cf = layerBoot
                 .configuration()
@@ -58,7 +56,7 @@
         Callable<Void> task = new Callable<Void>() {
             @Override
             public Void call() throws Exception {
-                Layer layer = Layer.boot().defineModulesWithOneLoader(cf, scl);
+                ModuleLayer layer = ModuleLayer.boot().defineModulesWithOneLoader(cf, scl);
                 Module transletModule = layer.findModule(MODULE_NAME).get();
                 testModule.addExports("test", transletModule);
                 Class<?> c = layer.findLoader(MODULE_NAME).loadClass("translet.Main");
--- a/hotspot/test/runtime/modules/ModuleStress/src/jdk.test/test/MainGC.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/hotspot/test/runtime/modules/ModuleStress/src/jdk.test/test/MainGC.java	Tue Apr 18 22:25:33 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2016, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -25,9 +25,7 @@
 
 import java.lang.module.Configuration;
 import java.lang.module.ModuleFinder;
-import java.lang.reflect.Layer;
 import java.lang.reflect.Method;
-import java.lang.reflect.Module;
 import java.nio.file.Path;
 import java.nio.file.Paths;
 import java.util.*;
@@ -44,7 +42,7 @@
     public static void main(String[] args) throws Exception {
 
         ModuleFinder finder = ModuleFinder.of(MODS_DIR);
-        Layer layerBoot = Layer.boot();
+        ModuleLayer layerBoot = ModuleLayer.boot();
 
         Configuration cf = layerBoot
                 .configuration()
@@ -59,7 +57,7 @@
         Callable<Void> task = new Callable<Void>() {
             @Override
             public Void call() throws Exception {
-                Layer layer = Layer.boot().defineModulesWithOneLoader(cf, scl);
+                ModuleLayer layer = ModuleLayer.boot().defineModulesWithOneLoader(cf, scl);
                 Module transletModule = layer.findModule(MODULE_NAME).get();
                 testModule.addExports("test", transletModule);
                 testModule.addReads(transletModule);
--- a/hotspot/test/runtime/modules/getModuleJNI/GetModule.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/hotspot/test/runtime/modules/getModuleJNI/GetModule.java	Tue Apr 18 22:25:33 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2016, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -26,7 +26,6 @@
  * @run main/native GetModule
  */
 
-import java.lang.reflect.Module;
 import java.lang.management.LockInfo;
 public class GetModule {
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/test/runtime/modules/java.base/java/lang/ModuleHelper.java	Tue Apr 18 22:25:33 2017 +0200
@@ -0,0 +1,73 @@
+/*
+ * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package java.lang;
+
+import java.lang.module.ModuleDescriptor;
+
+/**
+ * A helper class intended to be injected into java.lang using the
+ * java --patch-module option. The helper class provides access to package private
+ * methods in java.lang.Module.
+ */
+
+public final class ModuleHelper {
+
+    private ModuleHelper() { }
+
+    /**
+     * Creates a named module but without defining the module to the VM.
+     */
+    public static Module newModule(ClassLoader loader, ModuleDescriptor descriptor) {
+        return new Module(loader, descriptor);
+    }
+
+    /**
+     * Updates module {@code from} to that it reads module {@code to} without
+     * notifying the VM.
+     */
+    public static void addReadsNoSync(Module from, Module to) {
+        from.implAddReadsNoSync(to);
+    }
+
+    /**
+     * Updates module {@code from} so that it exports package {@code pkg}
+     * to module {@code to} but without notifying the VM. If {@code to} is
+     * {@code null} then the package is exported unconditionally.
+     */
+    public static void addExportsNoSync(Module from, String pkg, Module to) {
+        if (to == null) {
+            from.implAddExportsNoSync(pkg);
+        } else {
+            from.implAddExportsNoSync(pkg, to);
+        }
+    }
+
+    /**
+     * Adds a package to a module without notifying the VM.
+     */
+    public static void addPackageNoSync(Module m, String pkg) {
+        m.implAddPackageNoSync(pkg);
+    }
+
+}
--- a/hotspot/test/runtime/modules/java.base/java/lang/reflect/ModuleHelper.java	Tue Apr 18 13:19:42 2017 -0400
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,69 +0,0 @@
-/*
- * 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
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package java.lang.reflect;
-
-import java.lang.module.ModuleDescriptor;
-
-/**
- * A helper class intended to be injected into java.lang.reflect using the
- * java --patch-module option. The helper class provides access to package private
- * methods in java.lang.reflect.Module.
- */
-
-public final class ModuleHelper {
-
-    private ModuleHelper() { }
-
-    /**
-     * Creates a named module but without defining the module to the VM.
-     */
-    public static Module newModule(ClassLoader loader, ModuleDescriptor descriptor) {
-        return new Module(loader, descriptor);
-    }
-
-    /**
-     * Updates module {@code from} to that it reads module {@code to} without
-     * notifying the VM.
-     */
-    public static void addReadsNoSync(Module from, Module to) {
-        from.implAddReadsNoSync(to);
-    }
-
-    /**
-     * Updates module {@code from} so that it exports package {@code pkg}
-     * to module {@code to} but without notifying the VM. If {@code to} is
-     * {@code null} then the package is exported unconditionally.
-     */
-    public static void addExportsNoSync(Module from, String pkg, Module to) {
-        from.implAddExportsNoSync(pkg, to);
-    }
-
-    /**
-     * Adds a package to a module without notifying the VM.
-     */
-    public static void addPackageNoSync(Module m, String pkg) {
-        m.implAddPackageNoSync(pkg);
-    }
-
-}
--- a/hotspot/test/serviceability/jdwp/AllModulesCommandTestDebuggee.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/hotspot/test/serviceability/jdwp/AllModulesCommandTestDebuggee.java	Tue Apr 18 22:25:33 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2016, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -21,8 +21,6 @@
  * questions.
  */
 
-import java.lang.reflect.Module;
-import java.lang.reflect.Layer;
 import java.util.Set;
 import java.util.HashSet;
 
@@ -35,10 +33,10 @@
 
     public static void main(String[] args) throws InterruptedException {
 
-        int modCount = Layer.boot().modules().size();
+        int modCount = ModuleLayer.boot().modules().size();
 
         // Send all modules names via the process output
-        for (Module mod : Layer.boot().modules()) {
+        for (Module mod : ModuleLayer.boot().modules()) {
             String info = String.format("module %s", mod.getName());
             write(info);
         }
--- a/hotspot/test/serviceability/jvmti/AddModuleExportsAndOpens/MyPackage/AddModuleExportsAndOpensTest.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/hotspot/test/serviceability/jvmti/AddModuleExportsAndOpens/MyPackage/AddModuleExportsAndOpensTest.java	Tue Apr 18 22:25:33 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2016, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -31,7 +31,6 @@
  */
 
 import java.io.PrintStream;
-import java.lang.reflect.Module;
 
 public class AddModuleExportsAndOpensTest {
 
--- a/hotspot/test/serviceability/jvmti/AddModuleExportsAndOpens/libAddModuleExportsAndOpensTest.c	Tue Apr 18 13:19:42 2017 -0400
+++ b/hotspot/test/serviceability/jvmti/AddModuleExportsAndOpens/libAddModuleExportsAndOpensTest.c	Tue Apr 18 22:25:33 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2016, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -47,7 +47,7 @@
 #define FAILED 2
 
 static const char *EXC_CNAME = "java/lang/Exception";
-static const char* MOD_CNAME = "Ljava/lang/reflect/Module;";
+static const char* MOD_CNAME = "Ljava/lang/Module;";
 
 static jvmtiEnv *jvmti = NULL;
 static jint result = PASSED;
@@ -97,7 +97,7 @@
 }
 
 static
-jclass jlrM(JNIEnv *env) {
+jclass jlM(JNIEnv *env) {
     jclass cls = NULL;
 
     cls = JNI_ENV_PTR(env)->FindClass(JNI_ENV_ARG(env, MOD_CNAME));
@@ -127,7 +127,7 @@
     if (mIsExported == NULL) {
         const char* sign = "(Ljava/lang/String;)Z";
         const char* name = open ? "isOpen" : "isExported";
-        mIsExported = get_method(env, jlrM(env), name, sign);
+        mIsExported = get_method(env, jlM(env), name, sign);
     }
     jstr = JNI_ENV_PTR(env)->NewStringUTF(JNI_ENV_ARG(env, pkg));
     res = JNI_ENV_PTR(env)->CallBooleanMethod(JNI_ENV_ARG(env, module),
@@ -143,9 +143,9 @@
     jboolean res = JNI_FALSE;
 
     if (mIsExportedTo == NULL) {
-        const char* sign = "(Ljava/lang/String;Ljava/lang/reflect/Module;)Z";
+        const char* sign = "(Ljava/lang/String;Ljava/lang/Module;)Z";
         const char* name = open ? "isOpen" : "isExported";
-        mIsExportedTo = get_method(env, jlrM(env), name, sign);
+        mIsExportedTo = get_method(env, jlM(env), name, sign);
     }
     jstr = JNI_ENV_PTR(env)->NewStringUTF(JNI_ENV_ARG(env, pkg));
     res = JNI_ENV_PTR(env)->CallBooleanMethod(JNI_ENV_ARG(env, module),
--- a/hotspot/test/serviceability/jvmti/AddModuleReads/MyPackage/AddModuleReadsTest.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/hotspot/test/serviceability/jvmti/AddModuleReads/MyPackage/AddModuleReadsTest.java	Tue Apr 18 22:25:33 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2016, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -32,7 +32,6 @@
 
 import java.io.PrintStream;
 import java.lang.instrument.Instrumentation;
-import java.lang.reflect.Module;
 
 public class AddModuleReadsTest {
 
--- a/hotspot/test/serviceability/jvmti/AddModuleReads/libAddModuleReadsTest.c	Tue Apr 18 13:19:42 2017 -0400
+++ b/hotspot/test/serviceability/jvmti/AddModuleReads/libAddModuleReadsTest.c	Tue Apr 18 22:25:33 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2016, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -47,7 +47,7 @@
 #define FAILED 2
 
 static const char *EXC_CNAME = "java/lang/Exception";
-static const char* MOD_CNAME = "Ljava/lang/reflect/Module;";
+static const char* MOD_CNAME = "Ljava/lang/Module;";
 
 static jvmtiEnv *jvmti = NULL;
 static jint result = PASSED;
@@ -96,7 +96,7 @@
 }
 
 static
-jclass jlrM(JNIEnv *env) {
+jclass jlM(JNIEnv *env) {
     jclass cls = NULL;
 
     cls = JNI_ENV_PTR(env)->FindClass(JNI_ENV_ARG(env, MOD_CNAME));
@@ -123,8 +123,8 @@
     jboolean res = JNI_FALSE;
 
     if (mCanRead == NULL) {
-        const char* sign = "(Ljava/lang/reflect/Module;)Z";
-        mCanRead = get_method(env, jlrM(env), "canRead", sign);
+        const char* sign = "(Ljava/lang/Module;)Z";
+        mCanRead = get_method(env, jlM(env), "canRead", sign);
     }
     res = JNI_ENV_PTR(env)->CallBooleanMethod(JNI_ENV_ARG(env, module),
                                               mCanRead, to_module);
--- a/hotspot/test/serviceability/jvmti/AddModuleUsesAndProvides/MyPackage/AddModuleUsesAndProvidesTest.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/hotspot/test/serviceability/jvmti/AddModuleUsesAndProvides/MyPackage/AddModuleUsesAndProvidesTest.java	Tue Apr 18 22:25:33 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2016, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -34,7 +34,6 @@
 
 import java.io.PrintStream;
 import java.lang.TestProvider;
-import java.lang.reflect.Module;
 
 public class AddModuleUsesAndProvidesTest {
 
--- a/hotspot/test/serviceability/jvmti/AddModuleUsesAndProvides/libAddModuleUsesAndProvidesTest.c	Tue Apr 18 13:19:42 2017 -0400
+++ b/hotspot/test/serviceability/jvmti/AddModuleUsesAndProvides/libAddModuleUsesAndProvidesTest.c	Tue Apr 18 22:25:33 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2016, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -47,7 +47,7 @@
 #define FAILED 2
 
 static const char *EXC_CNAME = "java/lang/Exception";
-static const char* MOD_CNAME = "Ljava/lang/reflect/Module;";
+static const char* MOD_CNAME = "Ljava/lang/Module;";
 
 static jvmtiEnv *jvmti = NULL;
 static jint result = PASSED;
@@ -97,7 +97,7 @@
 }
 
 static
-jclass jlrM(JNIEnv *env) {
+jclass jlM(JNIEnv *env) {
     jclass cls = NULL;
 
     cls = JNI_ENV_PTR(env)->FindClass(JNI_ENV_ARG(env, MOD_CNAME));
@@ -125,7 +125,7 @@
 
     if (mCanUse == NULL) {
         const char* sign = "(Ljava/lang/Class;)Z";
-        mCanUse = get_method(env, jlrM(env), "canUse", sign);
+        mCanUse = get_method(env, jlM(env), "canUse", sign);
     }
     res = JNI_ENV_PTR(env)->CallBooleanMethod(JNI_ENV_ARG(env, module),
                                               mCanUse, service);
--- a/hotspot/test/serviceability/jvmti/GetModulesInfo/JvmtiGetAllModulesTest.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/hotspot/test/serviceability/jvmti/GetModulesInfo/JvmtiGetAllModulesTest.java	Tue Apr 18 22:25:33 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2016, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -28,8 +28,6 @@
  * @run main/othervm -agentlib:JvmtiGetAllModulesTest JvmtiGetAllModulesTest
  *
  */
-import java.lang.reflect.Layer;
-import java.lang.reflect.Module;
 import java.lang.module.ModuleReference;
 import java.lang.module.ModuleFinder;
 import java.lang.module.ModuleReader;
@@ -79,15 +77,15 @@
         final String MY_MODULE_NAME = "myModule";
 
         // Verify that JVMTI reports exactly the same info as Java regarding the named modules
-        Asserts.assertEquals(Layer.boot().modules(), getModulesJVMTI());
+        Asserts.assertEquals(ModuleLayer.boot().modules(), getModulesJVMTI());
 
         // Load a new named module
         ModuleDescriptor descriptor = ModuleDescriptor.newModule(MY_MODULE_NAME).build();
         ModuleFinder finder = finderOf(descriptor);
         ClassLoader loader = new ClassLoader() {};
-        Configuration parent = Layer.boot().configuration();
+        Configuration parent = ModuleLayer.boot().configuration();
         Configuration cf = parent.resolve(finder, ModuleFinder.of(), Set.of(MY_MODULE_NAME));
-        Layer my = Layer.boot().defineModules(cf, m -> loader);
+        ModuleLayer my = ModuleLayer.boot().defineModules(cf, m -> loader);
 
         // Verify that the loaded module is indeed reported by JVMTI
         Set<Module> jvmtiModules = getModulesJVMTI();
--- a/hotspot/test/serviceability/jvmti/GetModulesInfo/libJvmtiGetAllModulesTest.c	Tue Apr 18 13:19:42 2017 -0400
+++ b/hotspot/test/serviceability/jvmti/GetModulesInfo/libJvmtiGetAllModulesTest.c	Tue Apr 18 22:25:33 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2016, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -53,7 +53,7 @@
             return NULL;
         }
 
-        array = (*env)->NewObjectArray(env, modules_count, (*env)->FindClass(env, "java/lang/reflect/Module"), NULL);
+        array = (*env)->NewObjectArray(env, modules_count, (*env)->FindClass(env, "java/lang/Module"), NULL);
 
         for (i = 0; i < modules_count; ++i) {
             (*env)->SetObjectArrayElement(env, array, i, modules_ptr[i]);
--- a/hotspot/test/serviceability/jvmti/GetNamedModule/libGetNamedModuleTest.c	Tue Apr 18 13:19:42 2017 -0400
+++ b/hotspot/test/serviceability/jvmti/GetNamedModule/libGetNamedModuleTest.c	Tue Apr 18 22:25:33 2017 +0200
@@ -47,7 +47,7 @@
 #define FAILED 2
 
 static const char *EXC_CNAME = "java/lang/Exception";
-static const char* MOD_CNAME = "Ljava/lang/reflect/Module;";
+static const char* MOD_CNAME = "Ljava/lang/Module;";
 
 static jvmtiEnv *jvmti = NULL;
 static jint result = PASSED;
@@ -115,7 +115,7 @@
 }
 
 static
-jclass jlrM(JNIEnv *env) {
+jclass jlM(JNIEnv *env) {
     jclass cls = NULL;
 
     cls = JNI_ENV_PTR(env)->FindClass(JNI_ENV_ARG(env, MOD_CNAME));
@@ -142,7 +142,7 @@
     jobject loader = NULL;
 
     if (cl_method == NULL) {
-        cl_method = get_method(env, jlrM(env), "getClassLoader", "()Ljava/lang/ClassLoader;");
+        cl_method = get_method(env, jlM(env), "getClassLoader", "()Ljava/lang/ClassLoader;");
     }
     loader = (jobject)JNI_ENV_PTR(env)->CallObjectMethod(JNI_ENV_ARG(env, module), cl_method);
     return loader;
@@ -157,7 +157,7 @@
     const char *nstr = NULL;
 
     if (method == NULL) {
-        method = get_method(env, jlrM(env), "getName", "()Ljava/lang/String;");
+        method = get_method(env, jlM(env), "getName", "()Ljava/lang/String;");
     }
     jstr = (jstring)JNI_ENV_PTR(env)->CallObjectMethod(JNI_ENV_ARG(env, module), method);
     if (jstr != NULL) {
--- a/hotspot/test/testlibrary/ctw/src/sun/hotspot/tools/ctw/PathHandler.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/hotspot/test/testlibrary/ctw/src/sun/hotspot/tools/ctw/PathHandler.java	Tue Apr 18 22:25:33 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2013, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -151,8 +151,9 @@
         if (id >= Utils.COMPILE_THE_WORLD_START_AT) {
             try {
                 Class<?> aClass = loader.loadClass(name);
-                if (name != "sun.reflect.misc.Trampoline"
-                        && name != "sun.tools.jconsole.OutputViewer") { // workaround for JDK-8159155
+                if (!"sun.reflect.misc.Trampoline".equals(name)
+                        // workaround for JDK-8159155
+                        && !"sun.tools.jconsole.OutputViewer".equals(name)) {
                     UNSAFE.ensureClassInitialized(aClass);
                 }
                 CompileTheWorld.OUT.printf("[%d]\t%s%n", id, name);
--- a/jaxp/.hgtags	Tue Apr 18 13:19:42 2017 -0400
+++ b/jaxp/.hgtags	Tue Apr 18 22:25:33 2017 +0200
@@ -408,3 +408,4 @@
 d02b6fbcab06c59a5f5a4a6736bd4ec6d2567855 jdk-9+162
 92a38c75cd277d8b11f4382511a62087044659a1 jdk-9+163
 6dc790a4e8310c86712cfdf7561a9820818546e6 jdk-9+164
+55419603989707ec50c84bb379bbdc1adeec3ab2 jdk-9+165
--- a/jaxp/src/java.xml/share/classes/com/sun/org/apache/xalan/internal/xsltc/compiler/Constants.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/jaxp/src/java.xml/share/classes/com/sun/org/apache/xalan/internal/xsltc/compiler/Constants.java	Tue Apr 18 22:25:33 2017 +0200
@@ -99,7 +99,7 @@
         = com.sun.org.apache.bcel.internal.Constants.ACC_STATIC;
 
     public static final String MODULE_SIG
-        = "Ljava/lang/reflect/Module;";
+        = "Ljava/lang/Module;";
     public static final String CLASS_SIG
         = "Ljava/lang/Class;";
     public static final String STRING_SIG
@@ -255,7 +255,7 @@
     public static final String CLASS_CLASS
         = "java.lang.Class";
     public static final String MODULE_CLASS
-        = "java.lang.reflect.Module";
+        = "java.lang.Module";
     public static final String STRING_CLASS
         = "java.lang.String";
     public static final String OBJECT_CLASS
--- a/jaxp/src/java.xml/share/classes/com/sun/org/apache/xalan/internal/xsltc/trax/TemplatesImpl.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/jaxp/src/java.xml/share/classes/com/sun/org/apache/xalan/internal/xsltc/trax/TemplatesImpl.java	Tue Apr 18 22:25:33 2017 +0200
@@ -43,8 +43,6 @@
 import java.lang.module.ModuleFinder;
 import java.lang.module.ModuleReference;
 import java.lang.module.ModuleReader;
-import java.lang.reflect.Layer;
-import java.lang.reflect.Module;
 import java.security.AccessController;
 import java.security.CodeSigner;
 import java.security.CodeSource;
@@ -435,13 +433,13 @@
             }
         };
 
-        Layer bootLayer = Layer.boot();
+        ModuleLayer bootLayer = ModuleLayer.boot();
 
         Configuration cf = bootLayer.configuration()
                 .resolve(finder, ModuleFinder.of(), Set.of(mn));
 
-        PrivilegedAction<Layer> pa = () -> bootLayer.defineModules(cf, name -> loader);
-        Layer layer = AccessController.doPrivileged(pa);
+        PrivilegedAction<ModuleLayer> pa = () -> bootLayer.defineModules(cf, name -> loader);
+        ModuleLayer layer = AccessController.doPrivileged(pa);
 
         Module m = layer.findModule(mn).get();
         assert m.getLayer() == layer;
--- a/jaxp/test/TEST.ROOT	Tue Apr 18 13:19:42 2017 -0400
+++ b/jaxp/test/TEST.ROOT	Tue Apr 18 22:25:33 2017 +0200
@@ -23,7 +23,7 @@
 groups=TEST.groups
 
 # Minimum jtreg version
-requiredVersion=4.2 b04
+requiredVersion=4.2 b07
 
 # Use new module options
 useNewOptions=true
--- a/jaxp/test/javax/xml/jaxp/libs/jdk/testlibrary/JDKToolLauncher.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/jaxp/test/javax/xml/jaxp/libs/jdk/testlibrary/JDKToolLauncher.java	Tue Apr 18 22:25:33 2017 +0200
@@ -24,7 +24,6 @@
 package jdk.testlibrary;
 
 import java.util.ArrayList;
-import java.util.Arrays;
 import java.util.List;
 
 /**
@@ -60,7 +59,6 @@
         } else {
             executable = JDKToolFinder.getTestJDKTool(tool);
         }
-        vmArgs.addAll(Arrays.asList(ProcessTools.getPlatformSpecificVMArgs()));
     }
 
     /**
--- a/jaxp/test/javax/xml/jaxp/libs/jdk/testlibrary/ProcessTools.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/jaxp/test/javax/xml/jaxp/libs/jdk/testlibrary/ProcessTools.java	Tue Apr 18 22:25:33 2017 +0200
@@ -260,31 +260,13 @@
     }
 
     /**
-     * Get platform specific VM arguments (e.g. -d64 on 64bit Solaris)
-     *
-     * @return String[] with platform specific arguments, empty if there are
-     *         none
-     */
-    public static String[] getPlatformSpecificVMArgs() {
-        String osName = System.getProperty("os.name");
-        String dataModel = System.getProperty("sun.arch.data.model");
-
-        if (osName.equals("SunOS") && dataModel.equals("64")) {
-            return new String[] { "-d64" };
-        }
-
-        return new String[] {};
-    }
-
-    /**
      * Create ProcessBuilder using the java launcher from the jdk to be tested,
      * and with any platform specific arguments prepended.
      *
      * @param command Arguments to pass to the java command.
      * @return The ProcessBuilder instance representing the java command.
      */
-    public static ProcessBuilder createJavaProcessBuilder(String... command)
-            throws Exception {
+    public static ProcessBuilder createJavaProcessBuilder(String... command) {
         return createJavaProcessBuilder(false, command);
     }
 
@@ -297,12 +279,11 @@
      * @param command Arguments to pass to the java command.
      * @return The ProcessBuilder instance representing the java command.
      */
-    public static ProcessBuilder createJavaProcessBuilder(boolean addTestVmAndJavaOptions, String... command) throws Exception {
+    public static ProcessBuilder createJavaProcessBuilder(boolean addTestVmAndJavaOptions, String... command) {
         String javapath = JDKToolFinder.getJDKTool("java");
 
         ArrayList<String> args = new ArrayList<>();
         args.add(javapath);
-        Collections.addAll(args, getPlatformSpecificVMArgs());
 
         if (addTestVmAndJavaOptions) {
             // -cp is needed to make sure the same classpath is used whether the test is
--- a/jaxp/test/javax/xml/jaxp/module/ServiceProviderTest/DefaultFactoryWrapperTest.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/jaxp/test/javax/xml/jaxp/module/ServiceProviderTest/DefaultFactoryWrapperTest.java	Tue Apr 18 22:25:33 2017 +0200
@@ -27,8 +27,6 @@
 
 import java.io.StringReader;
 import java.io.StringWriter;
-import java.lang.reflect.Layer;
-import java.lang.reflect.Module;
 
 import javax.xml.datatype.DatatypeFactory;
 import javax.xml.parsers.DocumentBuilderFactory;
@@ -52,7 +50,7 @@
  * @summary test customized provider wraps the built-in system-default implementation of JAXP factories
  */
 public class DefaultFactoryWrapperTest {
-    private static final Module XML_MODULE = Layer.boot().findModule("java.xml").get();
+    private static final Module XML_MODULE = ModuleLayer.boot().findModule("java.xml").get();
 
     private static final String PROVIDER_PACKAGE = "xwp";
 
--- a/jaxp/test/javax/xml/jaxp/module/ServiceProviderTest/LayerModularXMLParserTest.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/jaxp/test/javax/xml/jaxp/module/ServiceProviderTest/LayerModularXMLParserTest.java	Tue Apr 18 22:25:33 2017 +0200
@@ -29,9 +29,7 @@
 import java.lang.System;
 import java.lang.module.Configuration;
 import java.lang.module.ModuleFinder;
-import java.lang.reflect.Layer;
 import java.lang.reflect.Method;
-import java.lang.reflect.Module;
 import java.nio.file.Paths;
 import java.nio.file.Path;
 import java.util.Collections;
@@ -95,23 +93,23 @@
      */
     public void testOneLayer() throws Exception {
         ModuleFinder finder1 = ModuleFinder.of(MOD_DIR1);
-        Configuration cf1 = Layer.boot().configuration()
+        Configuration cf1 = ModuleLayer.boot().configuration()
                 .resolveAndBind(finder1, ModuleFinder.of(), Set.of("test"));
         ClassLoader scl = ClassLoader.getSystemClassLoader();
-        Layer layer1 = Layer.boot().defineModulesWithManyLoaders(cf1, scl);
+        ModuleLayer layer1 = ModuleLayer.boot().defineModulesWithManyLoaders(cf1, scl);
         ClassLoader cl1 = layer1.findLoader("test");
 
         Method m = cl1.loadClass("test.XMLFactoryHelper").getMethod("instantiateXMLService", String.class);
         for (String service : services1) {
             Object o = m.invoke(null, service);
-            Layer providerLayer = o.getClass().getModule().getLayer();
+            ModuleLayer providerLayer = o.getClass().getModule().getLayer();
             assertSame(providerLayer, layer1);
         }
 
         for (String service : services2) {
             Object o = m.invoke(null, service);
-            Layer providerLayer = o.getClass().getModule().getLayer();
-            assertSame(providerLayer, Layer.boot());
+            ModuleLayer providerLayer = o.getClass().getModule().getLayer();
+            assertSame(providerLayer, ModuleLayer.boot());
         }
 
     }
@@ -125,26 +123,26 @@
      */
     public void testTwoLayer() throws Exception {
         ModuleFinder finder1 = ModuleFinder.of(MOD_DIR1);
-        Configuration cf1 = Layer.boot().configuration()
+        Configuration cf1 = ModuleLayer.boot().configuration()
                 .resolveAndBind(finder1, ModuleFinder.of(), Set.of("test"));
         ClassLoader scl = ClassLoader.getSystemClassLoader();
-        Layer layer1 = Layer.boot().defineModulesWithManyLoaders(cf1, scl);
+        ModuleLayer layer1 = ModuleLayer.boot().defineModulesWithManyLoaders(cf1, scl);
 
         ModuleFinder finder2 = ModuleFinder.of(MOD_DIR2);
         Configuration cf2 = cf1.resolveAndBind(finder2, ModuleFinder.of(), Set.of("test"));
-        Layer layer2 = layer1.defineModulesWithOneLoader(cf2, layer1.findLoader("test"));
+        ModuleLayer layer2 = layer1.defineModulesWithOneLoader(cf2, layer1.findLoader("test"));
         ClassLoader cl2 = layer2.findLoader("test");
 
         Method m = cl2.loadClass("test.XMLFactoryHelper").getMethod("instantiateXMLService", String.class);
         for (String service : services1) {
             Object o = m.invoke(null, service);
-            Layer providerLayer = o.getClass().getModule().getLayer();
+            ModuleLayer providerLayer = o.getClass().getModule().getLayer();
             assertSame(providerLayer, layer1);
         }
 
         for (String service : services2) {
             Object o = m.invoke(null, service);
-            Layer providerLayer = o.getClass().getModule().getLayer();
+            ModuleLayer providerLayer = o.getClass().getModule().getLayer();
             assertSame(providerLayer, layer2);
         }
 
@@ -159,26 +157,26 @@
      */
     public void testTwoLayerWithDuplicate() throws Exception {
         ModuleFinder finder1 = ModuleFinder.of(MOD_DIR1, MOD_DIR2);
-        Configuration cf1 = Layer.boot().configuration()
+        Configuration cf1 = ModuleLayer.boot().configuration()
                 .resolveAndBind(finder1, ModuleFinder.of(), Set.of("test"));
         ClassLoader scl = ClassLoader.getSystemClassLoader();
-        Layer layer1 = Layer.boot().defineModulesWithManyLoaders(cf1, scl);
+        ModuleLayer layer1 = ModuleLayer.boot().defineModulesWithManyLoaders(cf1, scl);
 
         ModuleFinder finder2 = ModuleFinder.of(MOD_DIR2);
         Configuration cf2 = cf1.resolveAndBind(finder2, ModuleFinder.of(), Set.of("test"));
-        Layer layer2 = layer1.defineModulesWithOneLoader(cf2, layer1.findLoader("test"));
+        ModuleLayer layer2 = layer1.defineModulesWithOneLoader(cf2, layer1.findLoader("test"));
         ClassLoader cl2 = layer2.findLoader("test");
 
         Method m = cl2.loadClass("test.XMLFactoryHelper").getMethod("instantiateXMLService", String.class);
         for (String service : services1) {
             Object o = m.invoke(null, service);
-            Layer providerLayer = o.getClass().getModule().getLayer();
+            ModuleLayer providerLayer = o.getClass().getModule().getLayer();
             assertSame(providerLayer, layer1);
         }
 
         for (String service : services2) {
             Object o = m.invoke(null, service);
-            Layer providerLayer = o.getClass().getModule().getLayer();
+            ModuleLayer providerLayer = o.getClass().getModule().getLayer();
             assertSame(providerLayer, layer2);
         }
 
--- a/jaxp/test/javax/xml/jaxp/module/ServiceProviderTest/src/unnamed/Main.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/jaxp/test/javax/xml/jaxp/module/ServiceProviderTest/src/unnamed/Main.java	Tue Apr 18 22:25:33 2017 +0200
@@ -24,8 +24,6 @@
 import static javax.xml.XMLConstants.W3C_XML_SCHEMA_NS_URI;
 
 import java.lang.module.ModuleDescriptor.Provides;
-import java.lang.reflect.Layer;
-import java.lang.reflect.Module;
 import java.util.Arrays;
 import java.util.HashSet;
 import java.util.Set;
@@ -38,7 +36,7 @@
      * @param args, the names of provider modules, which have been loaded
      */
     public static void main(String[] args) throws Exception {
-        Module xml = Layer.boot().findModule("java.xml").get();
+        Module xml = ModuleLayer.boot().findModule("java.xml").get();
 
         Set<String> allServices = new HashSet<>(Arrays.asList(expectedAllServices));
         if (!allServices.equals(xml.getDescriptor().uses()))
@@ -46,7 +44,7 @@
                     + xml.getDescriptor().uses());
 
         long violationCount = Stream.of(args)
-                .map(xmlProviderName -> Layer.boot().findModule(xmlProviderName).get())
+                .map(xmlProviderName -> ModuleLayer.boot().findModule(xmlProviderName).get())
                 .mapToLong(
                         // services provided by the implementation in provider module
                         provider -> provider.getDescriptor().provides().stream()
--- a/jaxws/.hgtags	Tue Apr 18 13:19:42 2017 -0400
+++ b/jaxws/.hgtags	Tue Apr 18 22:25:33 2017 +0200
@@ -411,3 +411,4 @@
 b8aebe5292f23689f97cb8e66a9f327834dd43e6 jdk-9+162
 3890f96e8995be8c84f330d1f65269b03ac36b24 jdk-9+163
 1a52de2da827459e866fd736f9e9c62eb2ecd6bb jdk-9+164
+a987401bac0d528475e57732c9d5d93f4405804c jdk-9+165
--- a/jaxws/src/java.xml.ws/share/classes/com/sun/xml/internal/ws/addressing/EPRSDDocumentFilter.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/jaxws/src/java.xml.ws/share/classes/com/sun/xml/internal/ws/addressing/EPRSDDocumentFilter.java	Tue Apr 18 22:25:33 2017 +0200
@@ -26,6 +26,7 @@
 package com.sun.xml.internal.ws.addressing;
 
 import com.sun.xml.internal.ws.api.server.*;
+import com.sun.xml.internal.ws.api.server.Module;
 import com.sun.xml.internal.ws.api.addressing.WSEndpointReference;
 import com.sun.xml.internal.ws.api.addressing.AddressingVersion;
 import com.sun.xml.internal.ws.api.streaming.XMLStreamReaderFactory;
--- a/jaxws/src/java.xml.ws/share/classes/com/sun/xml/internal/ws/api/server/SDDocumentSource.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/jaxws/src/java.xml.ws/share/classes/com/sun/xml/internal/ws/api/server/SDDocumentSource.java	Tue Apr 18 22:25:33 2017 +0200
@@ -155,12 +155,10 @@
             }
 
             private InputStream inputStream() throws IOException {
-                java.lang.reflect.Module module = resolvingClass.getModule();
-                if (module != null) {
-                    InputStream stream = module.getResourceAsStream(path);
-                    if (stream != null) {
-                        return stream;
-                    }
+                java.lang.Module module = resolvingClass.getModule();
+                InputStream stream = module.getResourceAsStream(path);
+                if (stream != null) {
+                    return stream;
                 }
                 throw new ServerRtException("cannot.load.wsdl", path);
             }
--- a/jaxws/src/java.xml.ws/share/classes/com/sun/xml/internal/ws/util/HandlerAnnotationProcessor.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/jaxws/src/java.xml.ws/share/classes/com/sun/xml/internal/ws/util/HandlerAnnotationProcessor.java	Tue Apr 18 22:25:33 2017 +0200
@@ -234,17 +234,15 @@
     }
 
     private static InputStream moduleResource(Class resolvingClass, String name) {
-        java.lang.reflect.Module module = resolvingClass.getModule();
-        if (module != null) {
-            try {
-                InputStream stream = module.getResourceAsStream(name);
-                if (stream != null) {
-                    return stream;
-                }
-            } catch(IOException e) {
-                throw new UtilException("util.failed.to.find.handlerchain.file",
-                        resolvingClass.getName(), name);
+        Module module = resolvingClass.getModule();
+        try {
+            InputStream stream = module.getResourceAsStream(name);
+            if (stream != null) {
+                return stream;
             }
+        } catch(IOException e) {
+            throw new UtilException("util.failed.to.find.handlerchain.file",
+                    resolvingClass.getName(), name);
         }
         return null;
     }
--- a/jaxws/src/jdk.xml.bind/share/legal/relaxngdatatype.md	Tue Apr 18 13:19:42 2017 -0400
+++ b/jaxws/src/jdk.xml.bind/share/legal/relaxngdatatype.md	Tue Apr 18 22:25:33 2017 +0200
@@ -3,7 +3,7 @@
 ### RelaxNG Datatype License
 <pre>
 
-Copyright (c) 2001, Thai Open Source Software Center Ltd, Sun Microsystems.
+Copyright (c) 2005, 2010 Thai Open Source Software Center Ltd
 All rights reserved.
 
 Redistribution and use in source and binary forms, with or without
--- a/jdk/.hgtags	Tue Apr 18 13:19:42 2017 -0400
+++ b/jdk/.hgtags	Tue Apr 18 22:25:33 2017 +0200
@@ -408,3 +408,4 @@
 f6bf027e88e9a4dd19f721001a7af00157af42c4 jdk-9+162
 50171f8c47961710cbf87aead6f03fa431d8d240 jdk-9+163
 6dea581453d7c0e767e3169cfec8b423a381e71d jdk-9+164
+a7942c3b1e59495dbf51dc7c41aab355fcd253d7 jdk-9+165
--- a/jdk/make/data/tzdata/VERSION	Tue Apr 18 13:19:42 2017 -0400
+++ b/jdk/make/data/tzdata/VERSION	Tue Apr 18 22:25:33 2017 +0200
@@ -21,4 +21,4 @@
 # or visit www.oracle.com if you need additional information or have any
 # questions.
 #
-tzdata2017a
+tzdata2017b
--- a/jdk/make/data/tzdata/africa	Tue Apr 18 13:19:42 2017 -0400
+++ b/jdk/make/data/tzdata/africa	Tue Apr 18 22:25:33 2017 +0200
@@ -443,18 +443,25 @@
 # See Africa/Johannesburg.
 
 # Liberia
-# From Paul Eggert (2006-03-22):
-# In 1972 Liberia was the last country to switch
-# from a UTC offset that was not a multiple of 15 or 20 minutes.
-# Howse reports that it was in honor of their president's birthday.
-# Shank & Pottenger report the date as May 1, whereas Howse reports Jan;
-# go with Shanks & Pottenger.
-# For Liberia before 1972, Shanks & Pottenger report -0:44, whereas Howse and
-# Whitman each report -0:44:30; go with the more precise figure.
+#
+# From Paul Eggert (2017-03-02):
+#
+# The Nautical Almanac for the Year 1970, p 264, is the source for -0:44:30.
+#
+# In 1972 Liberia was the last country to switch from a UTC offset
+# that was not a multiple of 15 or 20 minutes.  The 1972 change was on
+# 1972-01-07, according to an entry dated 1972-01-04 on p 330 of:
+# Presidential Papers: First year of the administration of
+# President William R. Tolbert, Jr., July 23, 1971-July 31, 1972.
+# Monrovia: Executive Mansion.
+#
+# Use the abbreviation "MMT" before 1972, as the more-accurate numeric
+# abbreviation "-004430" would be one byte over the POSIX limit.
+#
 # Zone	NAME		GMTOFF	RULES	FORMAT	[UNTIL]
 Zone	Africa/Monrovia	-0:43:08 -	LMT	1882
 			-0:43:08 -	MMT	1919 Mar # Monrovia Mean Time
-			-0:44:30 -	-004430	1972 May
+			-0:44:30 -	MMT	1972 Jan 7 # approximately MMT
 			 0:00	-	GMT
 
 ###############################################################################
--- a/jdk/make/data/tzdata/iso3166.tab	Tue Apr 18 13:19:42 2017 -0400
+++ b/jdk/make/data/tzdata/iso3166.tab	Tue Apr 18 22:25:33 2017 +0200
@@ -32,8 +32,8 @@
 # All text uses UTF-8 encoding.  The columns of the table are as follows:
 #
 # 1.  ISO 3166-1 alpha-2 country code, current as of
-#     ISO 3166-1 Newsletter VI-16 (2013-07-11).  See: Updates on ISO 3166
-#   http://www.iso.org/iso/home/standards/country_codes/updates_on_iso_3166.htm
+#     ISO 3166-1 N905 (2016-11-15).  See: Updates on ISO 3166-1
+#     http://isotc.iso.org/livelink/livelink/Open/16944257
 # 2.  The usual English name for the coded region,
 #     chosen so that alphabetic sorting of subsets produces helpful lists.
 #     This is not the same as the English name in the ISO 3166 tables.
--- a/jdk/make/data/tzdata/northamerica	Tue Apr 18 13:19:42 2017 -0400
+++ b/jdk/make/data/tzdata/northamerica	Tue Apr 18 22:25:33 2017 +0200
@@ -3162,6 +3162,12 @@
 # http://www.vantbefinfo.com/changement-dheure-pas-pour-haiti/
 # http://news.anmwe.com/haiti-lheure-nationale-ne-sera-ni-avancee-ni-reculee-cette-annee/
 
+# From Steffen Thorsen (2017-03-12):
+# We have received 4 mails from different people telling that Haiti
+# has started DST again today, and this source seems to confirm that,
+# I have not been able to find a more authoritative source:
+# https://www.haitilibre.com/en/news-20319-haiti-notices-time-change-in-haiti.html
+
 # Rule	NAME	FROM	TO	TYPE	IN	ON	AT	SAVE	LETTER/S
 Rule	Haiti	1983	only	-	May	8	0:00	1:00	D
 Rule	Haiti	1984	1987	-	Apr	lastSun	0:00	1:00	D
@@ -3174,6 +3180,8 @@
 Rule	Haiti	2005	2006	-	Oct	lastSun	0:00	0	S
 Rule	Haiti	2012	2015	-	Mar	Sun>=8	2:00	1:00	D
 Rule	Haiti	2012	2015	-	Nov	Sun>=1	2:00	0	S
+Rule	Haiti	2017	max	-	Mar	Sun>=8	2:00	1:00	D
+Rule	Haiti	2017	max	-	Nov	Sun>=1	2:00	0	S
 # Zone	NAME		GMTOFF	RULES	FORMAT	[UNTIL]
 Zone America/Port-au-Prince -4:49:20 -	LMT	1890
 			-4:49	-	PPMT	1917 Jan 24 12:00 # P-a-P MT
--- a/jdk/make/mapfiles/libjava/mapfile-vers	Tue Apr 18 13:19:42 2017 -0400
+++ b/jdk/make/mapfiles/libjava/mapfile-vers	Tue Apr 18 22:25:33 2017 +0200
@@ -273,12 +273,12 @@
                 Java_jdk_internal_misc_VM_getRuntimeArguments;
                 Java_jdk_internal_misc_VM_initialize;
 
-                Java_java_lang_reflect_Module_defineModule0;
-                Java_java_lang_reflect_Module_addReads0;
-                Java_java_lang_reflect_Module_addExports0;
-                Java_java_lang_reflect_Module_addExportsToAll0;
-                Java_java_lang_reflect_Module_addExportsToAllUnnamed0;
-                Java_java_lang_reflect_Module_addPackage0;
+                Java_java_lang_Module_defineModule0;
+                Java_java_lang_Module_addReads0;
+                Java_java_lang_Module_addExports0;
+                Java_java_lang_Module_addExportsToAll0;
+                Java_java_lang_Module_addExportsToAllUnnamed0;
+                Java_java_lang_Module_addPackage0;
 
 		Java_jdk_internal_loader_BootLoader_getSystemPackageLocation;
 		Java_jdk_internal_loader_BootLoader_getSystemPackageNames;
--- a/jdk/src/java.base/macosx/classes/java/net/DefaultInterface.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/jdk/src/java.base/macosx/classes/java/net/DefaultInterface.java	Tue Apr 18 22:25:33 2017 +0200
@@ -50,10 +50,11 @@
     }
 
     /**
-     * Choose a default interface. This method returns an interface that is
-     * both "up" and supports multicast. This method choses an interface in
+     * Choose a default interface. This method returns the first interface that
+     * is both "up" and supports multicast. This method chooses an interface in
      * order of preference:
      * 1. neither loopback nor point to point
+     *    ( prefer interfaces with dual IP support )
      * 2. point to point
      * 3. loopback
      *
@@ -66,32 +67,56 @@
         try {
            nifs = NetworkInterface.getNetworkInterfaces();
         } catch (IOException ignore) {
-            // unable to enumate network interfaces
+            // unable to enumerate network interfaces
             return null;
         }
 
+        NetworkInterface preferred = null;
         NetworkInterface ppp = null;
         NetworkInterface loopback = null;
 
         while (nifs.hasMoreElements()) {
             NetworkInterface ni = nifs.nextElement();
             try {
-                if (ni.isUp() && ni.supportsMulticast()) {
-                    boolean isLoopback = ni.isLoopback();
-                    boolean isPPP = ni.isPointToPoint();
-                    if (!isLoopback && !isPPP) {
-                        // found an interface that is not the loopback or a
-                        // point-to-point interface
+                if (!ni.isUp() || !ni.supportsMulticast())
+                    continue;
+
+                boolean ip4 = false, ip6 = false;
+                Enumeration<InetAddress> addrs = ni.getInetAddresses();
+                while (addrs.hasMoreElements()) {
+                    InetAddress addr = addrs.nextElement();
+                    if (!addr.isAnyLocalAddress()) {
+                        if (addr instanceof Inet4Address) {
+                            ip4 = true;
+                        } else if (addr instanceof Inet6Address) {
+                            ip6 = true;
+                        }
+                    }
+                }
+
+                boolean isLoopback = ni.isLoopback();
+                boolean isPPP = ni.isPointToPoint();
+                if (!isLoopback && !isPPP) {
+                    // found an interface that is not the loopback or a
+                    // point-to-point interface
+                    if (preferred == null) {
+                        preferred = ni;
+                    } else if (ip4 && ip6){
                         return ni;
                     }
-                    if (ppp == null && isPPP)
-                        ppp = ni;
-                    if (loopback == null && isLoopback)
-                        loopback = ni;
                 }
+                if (ppp == null && isPPP)
+                    ppp = ni;
+                if (loopback == null && isLoopback)
+                    loopback = ni;
+
             } catch (IOException skip) { }
         }
 
-        return (ppp != null) ? ppp : loopback;
+        if (preferred != null) {
+            return preferred;
+        } else {
+            return (ppp != null) ? ppp : loopback;
+        }
     }
 }
--- a/jdk/src/java.base/share/classes/com/sun/crypto/provider/DESKey.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/jdk/src/java.base/share/classes/com/sun/crypto/provider/DESKey.java	Tue Apr 18 22:25:33 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -149,6 +149,7 @@
      * Ensures that the bytes of this key are
      * set to zero when there are no more references to it.
      */
+    @SuppressWarnings("deprecation")
     protected void finalize() throws Throwable {
         try {
             if (this.key != null) {
--- a/jdk/src/java.base/share/classes/com/sun/crypto/provider/DESedeKey.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/jdk/src/java.base/share/classes/com/sun/crypto/provider/DESedeKey.java	Tue Apr 18 22:25:33 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -150,6 +150,7 @@
      * Ensures that the bytes of this key are
      * set to zero when there are no more references to it.
      */
+    @SuppressWarnings("deprecation")
     protected void finalize() throws Throwable {
         try {
             if (this.key != null) {
--- a/jdk/src/java.base/share/classes/com/sun/crypto/provider/PBEKey.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/jdk/src/java.base/share/classes/com/sun/crypto/provider/PBEKey.java	Tue Apr 18 22:25:33 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -145,6 +145,7 @@
      * Ensures that the password bytes of this key are
      * set to zero when there are no more references to it.
      */
+    @SuppressWarnings("deprecation")
     protected void finalize() throws Throwable {
         try {
             if (this.key != null) {
--- a/jdk/src/java.base/share/classes/com/sun/crypto/provider/PBKDF2KeyImpl.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/jdk/src/java.base/share/classes/com/sun/crypto/provider/PBKDF2KeyImpl.java	Tue Apr 18 22:25:33 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -267,6 +267,7 @@
      * Ensures that the password bytes of this key are
      * erased when there are no more references to it.
      */
+    @SuppressWarnings("deprecation")
     protected void finalize() throws Throwable {
         try {
             if (this.passwd != null) {
--- a/jdk/src/java.base/share/classes/java/io/BufferedReader.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/jdk/src/java.base/share/classes/java/io/BufferedReader.java	Tue Apr 18 22:25:33 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1996, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1996, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -297,14 +297,15 @@
 
     /**
      * Reads a line of text.  A line is considered to be terminated by any one
-     * of a line feed ('\n'), a carriage return ('\r'), or a carriage return
-     * followed immediately by a linefeed.
+     * of a line feed ('\n'), a carriage return ('\r'), a carriage return
+     * followed immediately by a line feed, or by reaching the end-of-file
+     * (EOF).
      *
      * @param      ignoreLF  If true, the next '\n' will be skipped
      *
      * @return     A String containing the contents of the line, not including
      *             any line-termination characters, or null if the end of the
-     *             stream has been reached
+     *             stream has been reached without reading any characters
      *
      * @see        java.io.LineNumberReader#readLine()
      *
@@ -375,12 +376,13 @@
 
     /**
      * Reads a line of text.  A line is considered to be terminated by any one
-     * of a line feed ('\n'), a carriage return ('\r'), or a carriage return
-     * followed immediately by a linefeed.
+     * of a line feed ('\n'), a carriage return ('\r'), a carriage return
+     * followed immediately by a line feed, or by reaching the end-of-file
+     * (EOF).
      *
      * @return     A String containing the contents of the line, not including
      *             any line-termination characters, or null if the end of the
-     *             stream has been reached
+     *             stream has been reached without reading any characters
      *
      * @exception  IOException  If an I/O error occurs
      *
--- a/jdk/src/java.base/share/classes/java/io/FileInputStream.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/jdk/src/java.base/share/classes/java/io/FileInputStream.java	Tue Apr 18 22:25:33 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1994, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1994, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -413,9 +413,19 @@
      * Ensures that the <code>close</code> method of this file input stream is
      * called when there are no more references to it.
      *
+     * @deprecated The {@code finalize} method has been deprecated.
+     *     Subclasses that override {@code finalize} in order to perform cleanup
+     *     should be modified to use alternative cleanup mechanisms and
+     *     to remove the overriding {@code finalize} method.
+     *     When overriding the {@code finalize} method, its implementation must explicitly
+     *     ensure that {@code super.finalize()} is invoked as described in {@link Object#finalize}.
+     *     See the specification for {@link Object#finalize()} for further
+     *     information about migration options.
+     *
      * @exception  IOException  if an I/O error occurs.
      * @see        java.io.FileInputStream#close()
      */
+    @Deprecated(since="9")
     protected void finalize() throws IOException {
         if ((fd != null) &&  (fd != FileDescriptor.in)) {
             /* if fd is shared, the references in FileDescriptor
--- a/jdk/src/java.base/share/classes/java/io/FileOutputStream.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/jdk/src/java.base/share/classes/java/io/FileOutputStream.java	Tue Apr 18 22:25:33 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1994, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1994, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -427,9 +427,18 @@
      * <code>close</code> method of this file output stream is
      * called when there are no more references to this stream.
      *
+     * @deprecated The {@code finalize} method has been deprecated.
+     * Subclasses that override {@code finalize} in order to perform cleanup
+     * should be modified to use alternative cleanup mechanisms and
+     * to remove the overriding {@code finalize} method.
+     * When overriding the {@code finalize} method, its implementation must explicitly
+     * ensure that {@code super.finalize()} is invoked as described in {@link Object#finalize}.
+     * See the specification for {@link Object#finalize()} for further
+     * information about migration options.
      * @exception  IOException  if an I/O error occurs.
      * @see        java.io.FileInputStream#close()
      */
+    @Deprecated(since="9")
     protected void finalize() throws IOException {
         if (fd != null) {
             if (fd == FileDescriptor.out || fd == FileDescriptor.err) {
--- a/jdk/src/java.base/share/classes/java/io/ObjectInputFilter.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/jdk/src/java.base/share/classes/java/io/ObjectInputFilter.java	Tue Apr 18 22:25:33 2017 +0200
@@ -322,7 +322,7 @@
          * Other patterns match or reject class or package name
          * as returned from {@link Class#getName() Class.getName()} and
          * if an optional module name is present
-         * {@link java.lang.reflect.Module#getName() class.getModule().getName()}.
+         * {@link Module#getName() class.getModule().getName()}.
          * Note that for arrays the element type is used in the pattern,
          * not the array type.
          * <ul>
--- a/jdk/src/java.base/share/classes/java/lang/Class.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/jdk/src/java.base/share/classes/java/lang/Class.java	Tue Apr 18 22:25:33 2017 +0200
@@ -43,7 +43,6 @@
 import java.lang.reflect.Member;
 import java.lang.reflect.Method;
 import java.lang.reflect.Modifier;
-import java.lang.reflect.Module;
 import java.lang.reflect.Proxy;
 import java.lang.reflect.Type;
 import java.lang.reflect.TypeVariable;
@@ -2561,21 +2560,16 @@
     public InputStream getResourceAsStream(String name) {
         name = resolveName(name);
 
-        Module module = getModule();
-        if (module.isNamed()) {
-            if (Resources.canEncapsulate(name)) {
-                Module caller = Reflection.getCallerClass().getModule();
-                if (caller != module) {
-                    Set<String> packages = module.getDescriptor().packages();
-                    String pn = Resources.toPackageName(name);
-                    if (packages.contains(pn) && !module.isOpen(pn, caller)) {
-                        // resource is in package not open to caller
-                        return null;
-                    }
-                }
+        Module thisModule = getModule();
+        if (thisModule.isNamed()) {
+            // check if resource can be located by caller
+            if (Resources.canEncapsulate(name)
+                && !isOpenToCaller(name, Reflection.getCallerClass())) {
+                return null;
             }
 
-            String mn = module.getName();
+            // resource not encapsulated or in package open to caller
+            String mn = thisModule.getName();
             ClassLoader cl = getClassLoader0();
             try {
 
@@ -2663,20 +2657,16 @@
     public URL getResource(String name) {
         name = resolveName(name);
 
-        Module module = getModule();
-        if (module.isNamed()) {
-            if (Resources.canEncapsulate(name)) {
-                Module caller = Reflection.getCallerClass().getModule();
-                if (caller != module) {
-                    Set<String> packages = module.getDescriptor().packages();
-                    String pn = Resources.toPackageName(name);
-                    if (packages.contains(pn) && !module.isOpen(pn, caller)) {
-                        // resource is in package not open to caller
-                        return null;
-                    }
-                }
+        Module thisModule = getModule();
+        if (thisModule.isNamed()) {
+            // check if resource can be located by caller
+            if (Resources.canEncapsulate(name)
+                && !isOpenToCaller(name, Reflection.getCallerClass())) {
+                return null;
             }
-            String mn = getModule().getName();
+
+            // resource not encapsulated or in package open to caller
+            String mn = thisModule.getName();
             ClassLoader cl = getClassLoader0();
             try {
                 if (cl == null) {
@@ -2698,10 +2688,36 @@
         }
     }
 
+    /**
+     * Returns true if a resource with the given name can be located by the
+     * given caller. All resources in a module can be located by code in
+     * the module. For other callers, then the package needs to be open to
+     * the caller.
+     */
+    private boolean isOpenToCaller(String name, Class<?> caller) {
+        // assert getModule().isNamed();
+        Module thisModule = getModule();
+        Module callerModule = (caller != null) ? caller.getModule() : null;
+        if (callerModule != thisModule) {
+            String pn = Resources.toPackageName(name);
+            if (thisModule.getDescriptor().packages().contains(pn)) {
+                if (callerModule == null && !thisModule.isOpen(pn)) {
+                    // no caller, package not open
+                    return false;
+                }
+                if (!thisModule.isOpen(pn, callerModule)) {
+                    // package not open to caller
+                    return false;
+                }
+            }
+        }
+        return true;
+    }
+
+
     /** protection domain returned when the internal domain is null */
     private static java.security.ProtectionDomain allPermDomain;
 
-
     /**
      * Returns the {@code ProtectionDomain} of this class.  If there is a
      * security manager installed, this method first calls the security
--- a/jdk/src/java.base/share/classes/java/lang/ClassLoader.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/jdk/src/java.base/share/classes/java/lang/ClassLoader.java	Tue Apr 18 22:25:33 2017 +0200
@@ -31,7 +31,6 @@
 import java.io.File;
 import java.lang.reflect.Constructor;
 import java.lang.reflect.Field;
-import java.lang.reflect.Module;
 import java.net.URL;
 import java.security.AccessController;
 import java.security.AccessControlContext;
@@ -352,9 +351,7 @@
     private ClassLoader(Void unused, String name, ClassLoader parent) {
         this.name = name;
         this.parent = parent;
-        this.unnamedModule
-            = SharedSecrets.getJavaLangReflectModuleAccess()
-                           .defineUnnamedModule(this);
+        this.unnamedModule = new Module(this);
         if (ParallelLoaders.isRegistered(this.getClass())) {
             parallelLockMap = new ConcurrentHashMap<>();
             package2certs = new ConcurrentHashMap<>();
@@ -2348,6 +2345,7 @@
             this.isBuiltin = isBuiltin;
         }
 
+        @SuppressWarnings("deprecation")
         protected void finalize() {
             synchronized (loadedLibraryNames) {
                 if (fromClass.getClassLoader() != null && loaded) {
--- a/jdk/src/java.base/share/classes/java/lang/Comparable.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/jdk/src/java.base/share/classes/java/lang/Comparable.java	Tue Apr 18 22:25:33 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -124,7 +124,7 @@
      * {@code sgn(}<i>expression</i>{@code )} designates the mathematical
      * <i>signum</i> function, which is defined to return one of {@code -1},
      * {@code 0}, or {@code 1} according to whether the value of
-     * <i>expression</i> is negative, zero or positive.
+     * <i>expression</i> is negative, zero, or positive, respectively.
      *
      * @param   o the object to be compared.
      * @return  a negative integer, zero, or a positive integer as this object
--- a/jdk/src/java.base/share/classes/java/lang/Enum.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/jdk/src/java.base/share/classes/java/lang/Enum.java	Tue Apr 18 22:25:33 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -243,6 +243,7 @@
     /**
      * enum classes cannot have finalize methods.
      */
+    @SuppressWarnings("deprecation")
     protected final void finalize() { }
 
     /**
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/java.base/share/classes/java/lang/LayerInstantiationException.java	Tue Apr 18 22:25:33 2017 +0200
@@ -0,0 +1,79 @@
+/*
+ * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package java.lang;
+
+/**
+ * Thrown when creating a {@linkplain ModuleLayer module layer} fails.
+ *
+ * @see ModuleLayer
+ * @since 9
+ * @spec JPMS
+ */
+public class LayerInstantiationException extends RuntimeException {
+    private static final long serialVersionUID = -906239691613568347L;
+
+    /**
+     * Constructs a {@code LayerInstantiationException} with no detail message.
+     */
+    public LayerInstantiationException() {
+    }
+
+    /**
+     * Constructs a {@code LayerInstantiationException} with the given detail
+     * message.
+     *
+     * @param msg
+     *        The detail message; can be {@code null}
+     */
+    public LayerInstantiationException(String msg) {
+        super(msg);
+    }
+
+    /**
+     * Constructs a {@code LayerInstantiationException} with the given cause.
+     *
+     * @param cause
+     *        The cause; can be {@code null}
+     */
+    public LayerInstantiationException(Throwable cause) {
+        super(cause);
+    }
+
+    /**
+     * Constructs a {@code FindException} with the given detail message
+     * and cause.
+     *
+     * @param msg
+     *        The detail message; can be {@code null}
+     * @param cause
+     *        The cause; can be {@code null}
+     */
+    public LayerInstantiationException(String msg, Throwable cause) {
+        super(msg, cause);
+    }
+
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/java.base/share/classes/java/lang/Module.java	Tue Apr 18 22:25:33 2017 +0200
@@ -0,0 +1,1586 @@
+/*
+ * Copyright (c) 2014, 2017, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package java.lang;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.lang.annotation.Annotation;
+import java.lang.module.Configuration;
+import java.lang.module.ModuleReference;
+import java.lang.module.ModuleDescriptor;
+import java.lang.module.ModuleDescriptor.Exports;
+import java.lang.module.ModuleDescriptor.Opens;
+import java.lang.module.ModuleDescriptor.Version;
+import java.lang.module.ResolvedModule;
+import java.lang.reflect.AnnotatedElement;
+import java.net.URI;
+import java.net.URL;
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Objects;
+import java.util.Optional;
+import java.util.Set;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.function.Function;
+import java.util.stream.Collectors;
+import java.util.stream.Stream;
+
+import jdk.internal.loader.BuiltinClassLoader;
+import jdk.internal.loader.BootLoader;
+import jdk.internal.misc.JavaLangAccess;
+import jdk.internal.misc.SharedSecrets;
+import jdk.internal.module.ServicesCatalog;
+import jdk.internal.module.Resources;
+import jdk.internal.org.objectweb.asm.AnnotationVisitor;
+import jdk.internal.org.objectweb.asm.Attribute;
+import jdk.internal.org.objectweb.asm.ClassReader;
+import jdk.internal.org.objectweb.asm.ClassVisitor;
+import jdk.internal.org.objectweb.asm.ClassWriter;
+import jdk.internal.org.objectweb.asm.Opcodes;
+import jdk.internal.reflect.CallerSensitive;
+import jdk.internal.reflect.Reflection;
+import sun.security.util.SecurityConstants;
+
+/**
+ * Represents a run-time module, either {@link #isNamed() named} or unnamed.
+ *
+ * <p> Named modules have a {@link #getName() name} and are constructed by the
+ * Java Virtual Machine when a graph of modules is defined to the Java virtual
+ * machine to create a {@linkplain ModuleLayer module layer}. </p>
+ *
+ * <p> An unnamed module does not have a name. There is an unnamed module for
+ * each {@link ClassLoader ClassLoader}, obtained by invoking its {@link
+ * ClassLoader#getUnnamedModule() getUnnamedModule} method. All types that are
+ * not in a named module are members of their defining class loader's unnamed
+ * module. </p>
+ *
+ * <p> The package names that are parameters or returned by methods defined in
+ * this class are the fully-qualified names of the packages as defined in
+ * section 6.5.3 of <cite>The Java&trade; Language Specification</cite>, for
+ * example, {@code "java.lang"}. </p>
+ *
+ * <p> Unless otherwise specified, passing a {@code null} argument to a method
+ * in this class causes a {@link NullPointerException NullPointerException} to
+ * be thrown. </p>
+ *
+ * @since 9
+ * @spec JPMS
+ * @see Class#getModule()
+ */
+
+public final class Module implements AnnotatedElement {
+
+    // the layer that contains this module, can be null
+    private final ModuleLayer layer;
+
+    // module name and loader, these fields are read by VM
+    private final String name;
+    private final ClassLoader loader;
+
+    // the module descriptor
+    private final ModuleDescriptor descriptor;
+
+
+    /**
+     * Creates a new named Module. The resulting Module will be defined to the
+     * VM but will not read any other modules, will not have any exports setup
+     * and will not be registered in the service catalog.
+     */
+    Module(ModuleLayer layer,
+           ClassLoader loader,
+           ModuleDescriptor descriptor,
+           URI uri)
+    {
+        this.layer = layer;
+        this.name = descriptor.name();
+        this.loader = loader;
+        this.descriptor = descriptor;
+
+        // define module to VM
+
+        boolean isOpen = descriptor.isOpen();
+        Version version = descriptor.version().orElse(null);
+        String vs = Objects.toString(version, null);
+        String loc = Objects.toString(uri, null);
+        String[] packages = descriptor.packages().toArray(new String[0]);
+        defineModule0(this, isOpen, vs, loc, packages);
+    }
+
+
+    /**
+     * Create the unnamed Module for the given ClassLoader.
+     *
+     * @see ClassLoader#getUnnamedModule
+     */
+    Module(ClassLoader loader) {
+        this.layer = null;
+        this.name = null;
+        this.loader = loader;
+        this.descriptor = null;
+    }
+
+
+    /**
+     * Creates a named module but without defining the module to the VM.
+     *
+     * @apiNote This constructor is for VM white-box testing.
+     */
+    Module(ClassLoader loader, ModuleDescriptor descriptor) {
+        this.layer = null;
+        this.name = descriptor.name();
+        this.loader = loader;
+        this.descriptor = descriptor;
+    }
+
+
+
+    /**
+     * Returns {@code true} if this module is a named module.
+     *
+     * @return {@code true} if this is a named module
+     *
+     * @see ClassLoader#getUnnamedModule()
+     */
+    public boolean isNamed() {
+        return name != null;
+    }
+
+    /**
+     * Returns the module name or {@code null} if this module is an unnamed
+     * module.
+     *
+     * @return The module name
+     */
+    public String getName() {
+        return name;
+    }
+
+    /**
+     * Returns the {@code ClassLoader} for this module.
+     *
+     * <p> If there is a security manager then its {@code checkPermission}
+     * method if first called with a {@code RuntimePermission("getClassLoader")}
+     * permission to check that the caller is allowed to get access to the
+     * class loader. </p>
+     *
+     * @return The class loader for this module
+     *
+     * @throws SecurityException
+     *         If denied by the security manager
+     */
+    public ClassLoader getClassLoader() {
+        SecurityManager sm = System.getSecurityManager();
+        if (sm != null) {
+            sm.checkPermission(SecurityConstants.GET_CLASSLOADER_PERMISSION);
+        }
+        return loader;
+    }
+
+    /**
+     * Returns the module descriptor for this module or {@code null} if this
+     * module is an unnamed module.
+     *
+     * @return The module descriptor for this module
+     */
+    public ModuleDescriptor getDescriptor() {
+        return descriptor;
+    }
+
+    /**
+     * Returns the layer that contains this module or {@code null} if this
+     * module is not in a layer.
+     *
+     * A module layer contains named modules and therefore this method always
+     * returns {@code null} when invoked on an unnamed module.
+     *
+     * <p> <a href="reflect/Proxy.html#dynamicmodule">Dynamic modules</a> are
+     * named modules that are generated at runtime. A dynamic module may or may
+     * not be in a module layer. </p>
+     *
+     * @return The module layer that contains this module
+     *
+     * @see java.lang.reflect.Proxy
+     */
+    public ModuleLayer getLayer() {
+        if (isNamed()) {
+            ModuleLayer layer = this.layer;
+            if (layer != null)
+                return layer;
+
+            // special-case java.base as it is created before the boot layer
+            if (loader == null && name.equals("java.base")) {
+                return ModuleLayer.boot();
+            }
+        }
+        return null;
+    }
+
+
+    // --
+
+    // special Module to mean "all unnamed modules"
+    private static final Module ALL_UNNAMED_MODULE = new Module(null);
+
+    // special Module to mean "everyone"
+    private static final Module EVERYONE_MODULE = new Module(null);
+
+    // set contains EVERYONE_MODULE, used when a package is opened or
+    // exported unconditionally
+    private static final Set<Module> EVERYONE_SET = Set.of(EVERYONE_MODULE);
+
+
+    // -- readability --
+
+    // the modules that this module reads
+    private volatile Set<Module> reads;
+
+    // additional module (2nd key) that some module (1st key) reflectively reads
+    private static final WeakPairMap<Module, Module, Boolean> reflectivelyReads
+        = new WeakPairMap<>();
+
+
+    /**
+     * Indicates if this module reads the given module. This method returns
+     * {@code true} if invoked to test if this module reads itself. It also
+     * returns {@code true} if invoked on an unnamed module (as unnamed
+     * modules read all modules).
+     *
+     * @param  other
+     *         The other module
+     *
+     * @return {@code true} if this module reads {@code other}
+     *
+     * @see #addReads(Module)
+     */
+    public boolean canRead(Module other) {
+        Objects.requireNonNull(other);
+
+        // an unnamed module reads all modules
+        if (!this.isNamed())
+            return true;
+
+        // all modules read themselves
+        if (other == this)
+            return true;
+
+        // check if this module reads other
+        if (other.isNamed()) {
+            Set<Module> reads = this.reads; // volatile read
+            if (reads != null && reads.contains(other))
+                return true;
+        }
+
+        // check if this module reads the other module reflectively
+        if (reflectivelyReads.containsKeyPair(this, other))
+            return true;
+
+        // if other is an unnamed module then check if this module reads
+        // all unnamed modules
+        if (!other.isNamed()
+            && reflectivelyReads.containsKeyPair(this, ALL_UNNAMED_MODULE))
+            return true;
+
+        return false;
+    }
+
+    /**
+     * If the caller's module is this module then update this module to read
+     * the given module.
+     *
+     * This method is a no-op if {@code other} is this module (all modules read
+     * themselves), this module is an unnamed module (as unnamed modules read
+     * all modules), or this module already reads {@code other}.
+     *
+     * @implNote <em>Read edges</em> added by this method are <em>weak</em> and
+     * do not prevent {@code other} from being GC'ed when this module is
+     * strongly reachable.
+     *
+     * @param  other
+     *         The other module
+     *
+     * @return this module
+     *
+     * @throws IllegalCallerException
+     *         If this is a named module and the caller's module is not this
+     *         module
+     *
+     * @see #canRead
+     */
+    @CallerSensitive
+    public Module addReads(Module other) {
+        Objects.requireNonNull(other);
+        if (this.isNamed()) {
+            Module caller = getCallerModule(Reflection.getCallerClass());
+            if (caller != this) {
+                throw new IllegalCallerException(caller + " != " + this);
+            }
+            implAddReads(other, true);
+        }
+        return this;
+    }
+
+    /**
+     * Updates this module to read another module.
+     *
+     * @apiNote Used by the --add-reads command line option.
+     */
+    void implAddReads(Module other) {
+        implAddReads(other, true);
+    }
+
+    /**
+     * Updates this module to read all unnamed modules.
+     *
+     * @apiNote Used by the --add-reads command line option.
+     */
+    void implAddReadsAllUnnamed() {
+        implAddReads(Module.ALL_UNNAMED_MODULE, true);
+    }
+
+    /**
+     * Updates this module to read another module without notifying the VM.
+     *
+     * @apiNote This method is for VM white-box testing.
+     */
+    void implAddReadsNoSync(Module other) {
+        implAddReads(other, false);
+    }
+
+    /**
+     * Makes the given {@code Module} readable to this module.
+     *
+     * If {@code syncVM} is {@code true} then the VM is notified.
+     */
+    private void implAddReads(Module other, boolean syncVM) {
+        Objects.requireNonNull(other);
+        if (!canRead(other)) {
+            // update VM first, just in case it fails
+            if (syncVM) {
+                if (other == ALL_UNNAMED_MODULE) {
+                    addReads0(this, null);
+                } else {
+                    addReads0(this, other);
+                }
+            }
+
+            // add reflective read
+            reflectivelyReads.putIfAbsent(this, other, Boolean.TRUE);
+        }
+    }
+
+
+    // -- exported and open packages --
+
+    // the packages are open to other modules, can be null
+    // if the value contains EVERYONE_MODULE then the package is open to all
+    private volatile Map<String, Set<Module>> openPackages;
+
+    // the packages that are exported, can be null
+    // if the value contains EVERYONE_MODULE then the package is exported to all
+    private volatile Map<String, Set<Module>> exportedPackages;
+
+    // additional exports or opens added at run-time
+    // this module (1st key), other module (2nd key)
+    // (package name, open?) (value)
+    private static final WeakPairMap<Module, Module, Map<String, Boolean>>
+        reflectivelyExports = new WeakPairMap<>();
+
+
+    /**
+     * Returns {@code true} if this module exports the given package to at
+     * least the given module.
+     *
+     * <p> This method returns {@code true} if invoked to test if a package in
+     * this module is exported to itself. It always returns {@code true} when
+     * invoked on an unnamed module. A package that is {@link #isOpen open} to
+     * the given module is considered exported to that module at run-time and
+     * so this method returns {@code true} if the package is open to the given
+     * module. </p>
+     *
+     * <p> This method does not check if the given module reads this module. </p>
+     *
+     * @param  pn
+     *         The package name
+     * @param  other
+     *         The other module
+     *
+     * @return {@code true} if this module exports the package to at least the
+     *         given module
+     *
+     * @see ModuleDescriptor#exports()
+     * @see #addExports(String,Module)
+     */
+    public boolean isExported(String pn, Module other) {
+        Objects.requireNonNull(pn);
+        Objects.requireNonNull(other);
+        return implIsExportedOrOpen(pn, other, /*open*/false);
+    }
+
+    /**
+     * Returns {@code true} if this module has <em>opened</em> a package to at
+     * least the given module.
+     *
+     * <p> This method returns {@code true} if invoked to test if a package in
+     * this module is open to itself. It returns {@code true} when invoked on an
+     * {@link ModuleDescriptor#isOpen open} module with a package in the module.
+     * It always returns {@code true} when invoked on an unnamed module. </p>
+     *
+     * <p> This method does not check if the given module reads this module. </p>
+     *
+     * @param  pn
+     *         The package name
+     * @param  other
+     *         The other module
+     *
+     * @return {@code true} if this module has <em>opened</em> the package
+     *         to at least the given module
+     *
+     * @see ModuleDescriptor#opens()
+     * @see #addOpens(String,Module)
+     * @see AccessibleObject#setAccessible(boolean)
+     * @see java.lang.invoke.MethodHandles#privateLookupIn
+     */
+    public boolean isOpen(String pn, Module other) {
+        Objects.requireNonNull(pn);
+        Objects.requireNonNull(other);
+        return implIsExportedOrOpen(pn, other, /*open*/true);
+    }
+
+    /**
+     * Returns {@code true} if this module exports the given package
+     * unconditionally.
+     *
+     * <p> This method always returns {@code true} when invoked on an unnamed
+     * module. A package that is {@link #isOpen(String) opened} unconditionally
+     * is considered exported unconditionally at run-time and so this method
+     * returns {@code true} if the package is opened unconditionally. </p>
+     *
+     * <p> This method does not check if the given module reads this module. </p>
+     *
+     * @param  pn
+     *         The package name
+     *
+     * @return {@code true} if this module exports the package unconditionally
+     *
+     * @see ModuleDescriptor#exports()
+     */
+    public boolean isExported(String pn) {
+        Objects.requireNonNull(pn);
+        return implIsExportedOrOpen(pn, EVERYONE_MODULE, /*open*/false);
+    }
+
+    /**
+     * Returns {@code true} if this module has <em>opened</em> a package
+     * unconditionally.
+     *
+     * <p> This method always returns {@code true} when invoked on an unnamed
+     * module. Additionally, it always returns {@code true} when invoked on an
+     * {@link ModuleDescriptor#isOpen open} module with a package in the
+     * module. </p>
+     *
+     * <p> This method does not check if the given module reads this module. </p>
+     *
+     * @param  pn
+     *         The package name
+     *
+     * @return {@code true} if this module has <em>opened</em> the package
+     *         unconditionally
+     *
+     * @see ModuleDescriptor#opens()
+     */
+    public boolean isOpen(String pn) {
+        Objects.requireNonNull(pn);
+        return implIsExportedOrOpen(pn, EVERYONE_MODULE, /*open*/true);
+    }
+
+
+    /**
+     * Returns {@code true} if this module exports or opens the given package
+     * to the given module. If the other module is {@code EVERYONE_MODULE} then
+     * this method tests if the package is exported or opened unconditionally.
+     */
+    private boolean implIsExportedOrOpen(String pn, Module other, boolean open) {
+        // all packages in unnamed modules are open
+        if (!isNamed())
+            return true;
+
+        // all packages are exported/open to self
+        if (other == this && containsPackage(pn))
+            return true;
+
+        // all packages in open and automatic modules are open
+        if (descriptor.isOpen() || descriptor.isAutomatic())
+            return containsPackage(pn);
+
+        // exported/opened via module declaration/descriptor
+        if (isStaticallyExportedOrOpen(pn, other, open))
+            return true;
+
+        // exported via addExports/addOpens
+        if (isReflectivelyExportedOrOpen(pn, other, open))
+            return true;
+
+        // not exported or open to other
+        return false;
+    }
+
+    /**
+     * Returns {@code true} if this module exports or opens a package to
+     * the given module via its module declaration.
+     */
+    private boolean isStaticallyExportedOrOpen(String pn, Module other, boolean open) {
+        // package is open to everyone or <other>
+        Map<String, Set<Module>> openPackages = this.openPackages;
+        if (openPackages != null) {
+            Set<Module> targets = openPackages.get(pn);
+            if (targets != null) {
+                if (targets.contains(EVERYONE_MODULE))
+                    return true;
+                if (other != EVERYONE_MODULE && targets.contains(other))
+                    return true;
+            }
+        }
+
+        if (!open) {
+            // package is exported to everyone or <other>
+            Map<String, Set<Module>> exportedPackages = this.exportedPackages;
+            if (exportedPackages != null) {
+                Set<Module> targets = exportedPackages.get(pn);
+                if (targets != null) {
+                    if (targets.contains(EVERYONE_MODULE))
+                        return true;
+                    if (other != EVERYONE_MODULE && targets.contains(other))
+                        return true;
+                }
+            }
+        }
+
+        return false;
+    }
+
+
+    /**
+     * Returns {@code true} if this module reflectively exports or opens given
+     * package package to the given module.
+     */
+    private boolean isReflectivelyExportedOrOpen(String pn, Module other, boolean open) {
+        // exported or open to all modules
+        Map<String, Boolean> exports = reflectivelyExports.get(this, EVERYONE_MODULE);
+        if (exports != null) {
+            Boolean b = exports.get(pn);
+            if (b != null) {
+                boolean isOpen = b.booleanValue();
+                if (!open || isOpen) return true;
+            }
+        }
+
+        if (other != EVERYONE_MODULE) {
+
+            // exported or open to other
+            exports = reflectivelyExports.get(this, other);
+            if (exports != null) {
+                Boolean b = exports.get(pn);
+                if (b != null) {
+                    boolean isOpen = b.booleanValue();
+                    if (!open || isOpen) return true;
+                }
+            }
+
+            // other is an unnamed module && exported or open to all unnamed
+            if (!other.isNamed()) {
+                exports = reflectivelyExports.get(this, ALL_UNNAMED_MODULE);
+                if (exports != null) {
+                    Boolean b = exports.get(pn);
+                    if (b != null) {
+                        boolean isOpen = b.booleanValue();
+                        if (!open || isOpen) return true;
+                    }
+                }
+            }
+
+        }
+
+        return false;
+    }
+
+
+    /**
+     * If the caller's module is this module then update this module to export
+     * the given package to the given module.
+     *
+     * <p> This method has no effect if the package is already exported (or
+     * <em>open</em>) to the given module. </p>
+     *
+     * @apiNote As specified in section 5.4.3 of the <cite>The Java&trade;
+     * Virtual Machine Specification </cite>, if an attempt to resolve a
+     * symbolic reference fails because of a linkage error, then subsequent
+     * attempts to resolve the reference always fail with the same error that
+     * was thrown as a result of the initial resolution attempt.
+     *
+     * @param  pn
+     *         The package name
+     * @param  other
+     *         The module
+     *
+     * @return this module
+     *
+     * @throws IllegalArgumentException
+     *         If {@code pn} is {@code null}, or this is a named module and the
+     *         package {@code pn} is not a package in this module
+     * @throws IllegalCallerException
+     *         If this is a named module and the caller's module is not this
+     *         module
+     *
+     * @jvms 5.4.3 Resolution
+     * @see #isExported(String,Module)
+     */
+    @CallerSensitive
+    public Module addExports(String pn, Module other) {
+        if (pn == null)
+            throw new IllegalArgumentException("package is null");
+        Objects.requireNonNull(other);
+
+        if (isNamed()) {
+            Module caller = getCallerModule(Reflection.getCallerClass());
+            if (caller != this) {
+                throw new IllegalCallerException(caller + " != " + this);
+            }
+            implAddExportsOrOpens(pn, other, /*open*/false, /*syncVM*/true);
+        }
+
+        return this;
+    }
+
+    /**
+     * If this module has <em>opened</em> a package to at least the caller
+     * module then update this module to open the package to the given module.
+     * Opening a package with this method allows all types in the package,
+     * and all their members, not just public types and their public members,
+     * to be reflected on by the given module when using APIs that support
+     * private access or a way to bypass or suppress default Java language
+     * access control checks.
+     *
+     * <p> This method has no effect if the package is already <em>open</em>
+     * to the given module. </p>
+     *
+     * @param  pn
+     *         The package name
+     * @param  other
+     *         The module
+     *
+     * @return this module
+     *
+     * @throws IllegalArgumentException
+     *         If {@code pn} is {@code null}, or this is a named module and the
+     *         package {@code pn} is not a package in this module
+     * @throws IllegalCallerException
+     *         If this is a named module and this module has not opened the
+     *         package to at least the caller's module
+     *
+     * @see #isOpen(String,Module)
+     * @see AccessibleObject#setAccessible(boolean)
+     * @see java.lang.invoke.MethodHandles#privateLookupIn
+     */
+    @CallerSensitive
+    public Module addOpens(String pn, Module other) {
+        if (pn == null)
+            throw new IllegalArgumentException("package is null");
+        Objects.requireNonNull(other);
+
+        if (isNamed()) {
+            Module caller = getCallerModule(Reflection.getCallerClass());
+            if (caller != this && (caller == null || !isOpen(pn, caller)))
+                throw new IllegalCallerException(pn + " is not open to " + caller);
+            implAddExportsOrOpens(pn, other, /*open*/true, /*syncVM*/true);
+        }
+
+        return this;
+    }
+
+
+    /**
+     * Updates this module to export a package unconditionally.
+     *
+     * @apiNote This method is for JDK tests only.
+     */
+    void implAddExports(String pn) {
+        implAddExportsOrOpens(pn, Module.EVERYONE_MODULE, false, true);
+    }
+
+    /**
+     * Updates this module to export a package to another module.
+     *
+     * @apiNote Used by Instrumentation::redefineModule and --add-exports
+     */
+    void implAddExports(String pn, Module other) {
+        implAddExportsOrOpens(pn, other, false, true);
+    }
+
+    /**
+     * Updates this module to export a package to all unnamed modules.
+     *
+     * @apiNote Used by the --add-exports command line option.
+     */
+    void implAddExportsToAllUnnamed(String pn) {
+        implAddExportsOrOpens(pn, Module.ALL_UNNAMED_MODULE, false, true);
+    }
+
+    /**
+     * Updates this export to export a package unconditionally without
+     * notifying the VM.
+     *
+     * @apiNote This method is for VM white-box testing.
+     */
+    void implAddExportsNoSync(String pn) {
+        implAddExportsOrOpens(pn.replace('/', '.'), Module.EVERYONE_MODULE, false, false);
+    }
+
+    /**
+     * Updates a module to export a package to another module without
+     * notifying the VM.
+     *
+     * @apiNote This method is for VM white-box testing.
+     */
+    void implAddExportsNoSync(String pn, Module other) {
+        implAddExportsOrOpens(pn.replace('/', '.'), other, false, false);
+    }
+
+    /**
+     * Updates this module to open a package unconditionally.
+     *
+     * @apiNote This method is for JDK tests only.
+     */
+    void implAddOpens(String pn) {
+        implAddExportsOrOpens(pn, Module.EVERYONE_MODULE, true, true);
+    }
+
+    /**
+     * Updates this module to open a package to another module.
+     *
+     * @apiNote Used by Instrumentation::redefineModule and --add-opens
+     */
+    void implAddOpens(String pn, Module other) {
+        implAddExportsOrOpens(pn, other, true, true);
+    }
+
+    /**
+     * Updates this module to export a package to all unnamed modules.
+     *
+     * @apiNote Used by the --add-opens command line option.
+     */
+    void implAddOpensToAllUnnamed(String pn) {
+        implAddExportsOrOpens(pn, Module.ALL_UNNAMED_MODULE, true, true);
+    }
+
+
+    /**
+     * Updates a module to export or open a module to another module.
+     *
+     * If {@code syncVM} is {@code true} then the VM is notified.
+     */
+    private void implAddExportsOrOpens(String pn,
+                                       Module other,
+                                       boolean open,
+                                       boolean syncVM) {
+        Objects.requireNonNull(other);
+        Objects.requireNonNull(pn);
+
+        // all packages are open in unnamed, open, and automatic modules
+        if (!isNamed() || descriptor.isOpen() || descriptor.isAutomatic())
+            return;
+
+        // nothing to do if already exported/open to other
+        if (implIsExportedOrOpen(pn, other, open))
+            return;
+
+        // can only export a package in the module
+        if (!containsPackage(pn)) {
+            throw new IllegalArgumentException("package " + pn
+                                               + " not in contents");
+        }
+
+        // update VM first, just in case it fails
+        if (syncVM) {
+            if (other == EVERYONE_MODULE) {
+                addExportsToAll0(this, pn);
+            } else if (other == ALL_UNNAMED_MODULE) {
+                addExportsToAllUnnamed0(this, pn);
+            } else {
+                addExports0(this, pn, other);
+            }
+        }
+
+        // add package name to reflectivelyExports if absent
+        Map<String, Boolean> map = reflectivelyExports
+            .computeIfAbsent(this, other,
+                             (m1, m2) -> new ConcurrentHashMap<>());
+
+        if (open) {
+            map.put(pn, Boolean.TRUE);  // may need to promote from FALSE to TRUE
+        } else {
+            map.putIfAbsent(pn, Boolean.FALSE);
+        }
+    }
+
+
+    // -- services --
+
+    // additional service type (2nd key) that some module (1st key) uses
+    private static final WeakPairMap<Module, Class<?>, Boolean> reflectivelyUses
+        = new WeakPairMap<>();
+
+    /**
+     * If the caller's module is this module then update this module to add a
+     * service dependence on the given service type. This method is intended
+     * for use by frameworks that invoke {@link java.util.ServiceLoader
+     * ServiceLoader} on behalf of other modules or where the framework is
+     * passed a reference to the service type by other code. This method is
+     * a no-op when invoked on an unnamed module or an automatic module.
+     *
+     * <p> This method does not cause {@link Configuration#resolveAndBind
+     * resolveAndBind} to be re-run. </p>
+     *
+     * @param  service
+     *         The service type
+     *
+     * @return this module
+     *
+     * @throws IllegalCallerException
+     *         If this is a named module and the caller's module is not this
+     *         module
+     *
+     * @see #canUse(Class)
+     * @see ModuleDescriptor#uses()
+     */
+    @CallerSensitive
+    public Module addUses(Class<?> service) {
+        Objects.requireNonNull(service);
+
+        if (isNamed() && !descriptor.isAutomatic()) {
+            Module caller = getCallerModule(Reflection.getCallerClass());
+            if (caller != this) {
+                throw new IllegalCallerException(caller + " != " + this);
+            }
+            implAddUses(service);
+        }
+
+        return this;
+    }
+
+    /**
+     * Update this module to add a service dependence on the given service
+     * type.
+     */
+    void implAddUses(Class<?> service) {
+        if (!canUse(service)) {
+            reflectivelyUses.putIfAbsent(this, service, Boolean.TRUE);
+        }
+    }
+
+
+    /**
+     * Indicates if this module has a service dependence on the given service
+     * type. This method always returns {@code true} when invoked on an unnamed
+     * module or an automatic module.
+     *
+     * @param  service
+     *         The service type
+     *
+     * @return {@code true} if this module uses service type {@code st}
+     *
+     * @see #addUses(Class)
+     */
+    public boolean canUse(Class<?> service) {
+        Objects.requireNonNull(service);
+
+        if (!isNamed())
+            return true;
+
+        if (descriptor.isAutomatic())
+            return true;
+
+        // uses was declared
+        if (descriptor.uses().contains(service.getName()))
+            return true;
+
+        // uses added via addUses
+        return reflectivelyUses.containsKeyPair(this, service);
+    }
+
+
+
+    // -- packages --
+
+    // Additional packages that are added to the module at run-time.
+    private volatile Map<String, Boolean> extraPackages;
+
+    private boolean containsPackage(String pn) {
+        if (descriptor.packages().contains(pn))
+            return true;
+        Map<String, Boolean> extraPackages = this.extraPackages;
+        if (extraPackages != null && extraPackages.containsKey(pn))
+            return true;
+        return false;
+    }
+
+
+    /**
+     * Returns the set of package names for the packages in this module.
+     *
+     * <p> For named modules, the returned set contains an element for each
+     * package in the module. </p>
+     *
+     * <p> For unnamed modules, this method is the equivalent to invoking the
+     * {@link ClassLoader#getDefinedPackages() getDefinedPackages} method of
+     * this module's class loader and returning the set of package names. </p>
+     *
+     * @return the set of the package names of the packages in this module
+     */
+    public Set<String> getPackages() {
+        if (isNamed()) {
+
+            Set<String> packages = descriptor.packages();
+            Map<String, Boolean> extraPackages = this.extraPackages;
+            if (extraPackages == null) {
+                return packages;
+            } else {
+                return Stream.concat(packages.stream(),
+                                     extraPackages.keySet().stream())
+                        .collect(Collectors.toSet());
+            }
+
+        } else {
+            // unnamed module
+            Stream<Package> packages;
+            if (loader == null) {
+                packages = BootLoader.packages();
+            } else {
+                packages = SharedSecrets.getJavaLangAccess().packages(loader);
+            }
+            return packages.map(Package::getName).collect(Collectors.toSet());
+        }
+    }
+
+    /**
+     * Add a package to this module without notifying the VM.
+     *
+     * @apiNote This method is VM white-box testing.
+     */
+    void implAddPackageNoSync(String pn) {
+        implAddPackage(pn.replace('/', '.'), false);
+    }
+
+    /**
+     * Add a package to this module.
+     *
+     * If {@code syncVM} is {@code true} then the VM is notified. This method is
+     * a no-op if this is an unnamed module or the module already contains the
+     * package.
+     *
+     * @throws IllegalArgumentException if the package name is not legal
+     * @throws IllegalStateException if the package is defined to another module
+     */
+    private void implAddPackage(String pn, boolean syncVM) {
+        // no-op if unnamed module
+        if (!isNamed())
+            return;
+
+        // no-op if module contains the package
+        if (containsPackage(pn))
+            return;
+
+        // check package name is legal for named modules
+        if (pn.isEmpty())
+            throw new IllegalArgumentException("Cannot add <unnamed> package");
+        for (int i=0; i<pn.length(); i++) {
+            char c = pn.charAt(i);
+            if (c == '/' || c == ';' || c == '[') {
+                throw new IllegalArgumentException("Illegal character: " + c);
+            }
+        }
+
+        // create extraPackages if needed
+        Map<String, Boolean> extraPackages = this.extraPackages;
+        if (extraPackages == null) {
+            synchronized (this) {
+                extraPackages = this.extraPackages;
+                if (extraPackages == null)
+                    this.extraPackages = extraPackages = new ConcurrentHashMap<>();
+            }
+        }
+
+        // update VM first in case it fails. This is a no-op if another thread
+        // beats us to add the package first
+        if (syncVM) {
+            // throws IllegalStateException if defined to another module
+            addPackage0(this, pn);
+            if (descriptor.isOpen() || descriptor.isAutomatic()) {
+                addExportsToAll0(this, pn);
+            }
+        }
+        extraPackages.putIfAbsent(pn, Boolean.TRUE);
+    }
+
+
+    // -- creating Module objects --
+
+    /**
+     * Defines all module in a configuration to the runtime.
+     *
+     * @return a map of module name to runtime {@code Module}
+     *
+     * @throws IllegalArgumentException
+     *         If defining any of the modules to the VM fails
+     */
+    static Map<String, Module> defineModules(Configuration cf,
+                                             Function<String, ClassLoader> clf,
+                                             ModuleLayer layer)
+    {
+        Map<String, Module> nameToModule = new HashMap<>();
+        Map<String, ClassLoader> moduleToLoader = new HashMap<>();
+
+        boolean isBootLayer = (ModuleLayer.boot() == null);
+        Set<ClassLoader> loaders = new HashSet<>();
+
+        // map each module to a class loader
+        for (ResolvedModule resolvedModule : cf.modules()) {
+            String name = resolvedModule.name();
+            ClassLoader loader = clf.apply(name);
+            if (loader != null) {
+                moduleToLoader.put(name, loader);
+                loaders.add(loader);
+            } else if (!isBootLayer) {
+                throw new IllegalArgumentException("loader can't be 'null'");
+            }
+        }
+
+        // define each module in the configuration to the VM
+        for (ResolvedModule resolvedModule : cf.modules()) {
+            ModuleReference mref = resolvedModule.reference();
+            ModuleDescriptor descriptor = mref.descriptor();
+            String name = descriptor.name();
+            URI uri = mref.location().orElse(null);
+            ClassLoader loader = moduleToLoader.get(resolvedModule.name());
+            Module m;
+            if (loader == null && isBootLayer && name.equals("java.base")) {
+                // java.base is already defined to the VM
+                m = Object.class.getModule();
+            } else {
+                m = new Module(layer, loader, descriptor, uri);
+            }
+            nameToModule.put(name, m);
+            moduleToLoader.put(name, loader);
+        }
+
+        // setup readability and exports
+        for (ResolvedModule resolvedModule : cf.modules()) {
+            ModuleReference mref = resolvedModule.reference();
+            ModuleDescriptor descriptor = mref.descriptor();
+
+            String mn = descriptor.name();
+            Module m = nameToModule.get(mn);
+            assert m != null;
+
+            // reads
+            Set<Module> reads = new HashSet<>();
+
+            // name -> source Module when in parent layer
+            Map<String, Module> nameToSource = Collections.emptyMap();
+
+            for (ResolvedModule other : resolvedModule.reads()) {
+                Module m2 = null;
+                if (other.configuration() == cf) {
+                    // this configuration
+                    m2 = nameToModule.get(other.name());
+                    assert m2 != null;
+                } else {
+                    // parent layer
+                    for (ModuleLayer parent: layer.parents()) {
+                        m2 = findModule(parent, other);
+                        if (m2 != null)
+                            break;
+                    }
+                    assert m2 != null;
+                    if (nameToSource.isEmpty())
+                        nameToSource = new HashMap<>();
+                    nameToSource.put(other.name(), m2);
+                }
+                reads.add(m2);
+
+                // update VM view
+                addReads0(m, m2);
+            }
+            m.reads = reads;
+
+            // automatic modules read all unnamed modules
+            if (descriptor.isAutomatic()) {
+                m.implAddReads(ALL_UNNAMED_MODULE, true);
+            }
+
+            // exports and opens
+            initExportsAndOpens(m, nameToSource, nameToModule, layer.parents());
+        }
+
+        // register the modules in the boot layer
+        if (isBootLayer) {
+            for (ResolvedModule resolvedModule : cf.modules()) {
+                ModuleReference mref = resolvedModule.reference();
+                ModuleDescriptor descriptor = mref.descriptor();
+                if (!descriptor.provides().isEmpty()) {
+                    String name = descriptor.name();
+                    Module m = nameToModule.get(name);
+                    ClassLoader loader = moduleToLoader.get(name);
+                    ServicesCatalog catalog;
+                    if (loader == null) {
+                        catalog = BootLoader.getServicesCatalog();
+                    } else {
+                        catalog = ServicesCatalog.getServicesCatalog(loader);
+                    }
+                    catalog.register(m);
+                }
+            }
+        }
+
+        // record that there is a layer with modules defined to the class loader
+        for (ClassLoader loader : loaders) {
+            layer.bindToLoader(loader);
+        }
+
+        return nameToModule;
+    }
+
+
+    /**
+     * Find the runtime Module corresponding to the given ResolvedModule
+     * in the given parent layer (or its parents).
+     */
+    private static Module findModule(ModuleLayer parent,
+                                     ResolvedModule resolvedModule) {
+        Configuration cf = resolvedModule.configuration();
+        String dn = resolvedModule.name();
+        return parent.layers()
+                .filter(l -> l.configuration() == cf)
+                .findAny()
+                .map(layer -> {
+                    Optional<Module> om = layer.findModule(dn);
+                    assert om.isPresent() : dn + " not found in layer";
+                    Module m = om.get();
+                    assert m.getLayer() == layer : m + " not in expected layer";
+                    return m;
+                })
+                .orElse(null);
+    }
+
+
+    /**
+     * Initialize the maps of exported and open packages for module m.
+     */
+    private static void initExportsAndOpens(Module m,
+                                            Map<String, Module> nameToSource,
+                                            Map<String, Module> nameToModule,
+                                            List<ModuleLayer> parents) {
+        // The VM doesn't special case open or automatic modules so need to
+        // export all packages
+        ModuleDescriptor descriptor = m.getDescriptor();
+        if (descriptor.isOpen() || descriptor.isAutomatic()) {
+            assert descriptor.opens().isEmpty();
+            for (String source : descriptor.packages()) {
+                addExportsToAll0(m, source);
+            }
+            return;
+        }
+
+        Map<String, Set<Module>> openPackages = new HashMap<>();
+        Map<String, Set<Module>> exportedPackages = new HashMap<>();
+
+        // process the open packages first
+        for (Opens opens : descriptor.opens()) {
+            String source = opens.source();
+
+            if (opens.isQualified()) {
+                // qualified opens
+                Set<Module> targets = new HashSet<>();
+                for (String target : opens.targets()) {
+                    Module m2 = findModule(target, nameToSource, nameToModule, parents);
+                    if (m2 != null) {
+                        addExports0(m, source, m2);
+                        targets.add(m2);
+                    }
+                }
+                if (!targets.isEmpty()) {
+                    openPackages.put(source, targets);
+                }
+            } else {
+                // unqualified opens
+                addExportsToAll0(m, source);
+                openPackages.put(source, EVERYONE_SET);
+            }
+        }
+
+        // next the exports, skipping exports when the package is open
+        for (Exports exports : descriptor.exports()) {
+            String source = exports.source();
+
+            // skip export if package is already open to everyone
+            Set<Module> openToTargets = openPackages.get(source);
+            if (openToTargets != null && openToTargets.contains(EVERYONE_MODULE))
+                continue;
+
+            if (exports.isQualified()) {
+                // qualified exports
+                Set<Module> targets = new HashSet<>();
+                for (String target : exports.targets()) {
+                    Module m2 = findModule(target, nameToSource, nameToModule, parents);
+                    if (m2 != null) {
+                        // skip qualified export if already open to m2
+                        if (openToTargets == null || !openToTargets.contains(m2)) {
+                            addExports0(m, source, m2);
+                            targets.add(m2);
+                        }
+                    }
+                }
+                if (!targets.isEmpty()) {
+                    exportedPackages.put(source, targets);
+                }
+
+            } else {
+                // unqualified exports
+                addExportsToAll0(m, source);
+                exportedPackages.put(source, EVERYONE_SET);
+            }
+        }
+
+        if (!openPackages.isEmpty())
+            m.openPackages = openPackages;
+        if (!exportedPackages.isEmpty())
+            m.exportedPackages = exportedPackages;
+    }
+
+    /**
+     * Find the runtime Module with the given name. The module name is the
+     * name of a target module in a qualified exports or opens directive.
+     *
+     * @param target The target module to find
+     * @param nameToSource The modules in parent layers that are read
+     * @param nameToModule The modules in the layer under construction
+     * @param parents The parent layers
+     */
+    private static Module findModule(String target,
+                                     Map<String, Module> nameToSource,
+                                     Map<String, Module> nameToModule,
+                                     List<ModuleLayer> parents) {
+        Module m = nameToSource.get(target);
+        if (m == null) {
+            m = nameToModule.get(target);
+            if (m == null) {
+                for (ModuleLayer parent : parents) {
+                    m = parent.findModule(target).orElse(null);
+                    if (m != null) break;
+                }
+            }
+        }
+        return m;
+    }
+
+
+    // -- annotations --
+
+    /**
+     * {@inheritDoc}
+     * This method returns {@code null} when invoked on an unnamed module.
+     */
+    @Override
+    public <T extends Annotation> T getAnnotation(Class<T> annotationClass) {
+        return moduleInfoClass().getDeclaredAnnotation(annotationClass);
+    }
+
+    /**
+     * {@inheritDoc}
+     * This method returns an empty array when invoked on an unnamed module.
+     */
+    @Override
+    public Annotation[] getAnnotations() {
+        return moduleInfoClass().getAnnotations();
+    }
+
+    /**
+     * {@inheritDoc}
+     * This method returns an empty array when invoked on an unnamed module.
+     */
+    @Override
+    public Annotation[] getDeclaredAnnotations() {
+        return moduleInfoClass().getDeclaredAnnotations();
+    }
+
+    // cached class file with annotations
+    private volatile Class<?> moduleInfoClass;
+
+    private Class<?> moduleInfoClass() {
+        Class<?> clazz = this.moduleInfoClass;
+        if (clazz != null)
+            return clazz;
+
+        synchronized (this) {
+            clazz = this.moduleInfoClass;
+            if (clazz == null) {
+                if (isNamed()) {
+                    PrivilegedAction<Class<?>> pa = this::loadModuleInfoClass;
+                    clazz = AccessController.doPrivileged(pa);
+                }
+                if (clazz == null) {
+                    class DummyModuleInfo { }
+                    clazz = DummyModuleInfo.class;
+                }
+                this.moduleInfoClass = clazz;
+            }
+            return clazz;
+        }
+    }
+
+    private Class<?> loadModuleInfoClass() {
+        Class<?> clazz = null;
+        try (InputStream in = getResourceAsStream("module-info.class")) {
+            if (in != null)
+                clazz = loadModuleInfoClass(in);
+        } catch (Exception ignore) { }
+        return clazz;
+    }
+
+    /**
+     * Loads module-info.class as a package-private interface in a class loader
+     * that is a child of this module's class loader.
+     */
+    private Class<?> loadModuleInfoClass(InputStream in) throws IOException {
+        final String MODULE_INFO = "module-info";
+
+        ClassWriter cw = new ClassWriter(ClassWriter.COMPUTE_MAXS
+                                         + ClassWriter.COMPUTE_FRAMES);
+
+        ClassVisitor cv = new ClassVisitor(Opcodes.ASM5, cw) {
+            @Override
+            public void visit(int version,
+                              int access,
+                              String name,
+                              String signature,
+                              String superName,
+                              String[] interfaces) {
+                cw.visit(version,
+                        Opcodes.ACC_INTERFACE
+                            + Opcodes.ACC_ABSTRACT
+                            + Opcodes.ACC_SYNTHETIC,
+                        MODULE_INFO,
+                        null,
+                        "java/lang/Object",
+                        null);
+            }
+            @Override
+            public AnnotationVisitor visitAnnotation(String desc, boolean visible) {
+                // keep annotations
+                return super.visitAnnotation(desc, visible);
+            }
+            @Override
+            public void visitAttribute(Attribute attr) {
+                // drop non-annotation attributes
+            }
+        };
+
+        ClassReader cr = new ClassReader(in);
+        cr.accept(cv, 0);
+        byte[] bytes = cw.toByteArray();
+
+        ClassLoader cl = new ClassLoader(loader) {
+            @Override
+            protected Class<?> findClass(String cn)throws ClassNotFoundException {
+                if (cn.equals(MODULE_INFO)) {
+                    return super.defineClass(cn, bytes, 0, bytes.length);
+                } else {
+                    throw new ClassNotFoundException(cn);
+                }
+            }
+        };
+
+        try {
+            return cl.loadClass(MODULE_INFO);
+        } catch (ClassNotFoundException e) {
+            throw new InternalError(e);
+        }
+    }
+
+
+    // -- misc --
+
+
+    /**
+     * Returns an input stream for reading a resource in this module.
+     * The {@code name} parameter is a {@code '/'}-separated path name that
+     * identifies the resource. As with {@link Class#getResourceAsStream
+     * Class.getResourceAsStream}, this method delegates to the module's class
+     * loader {@link ClassLoader#findResource(String,String)
+     * findResource(String,String)} method, invoking it with the module name
+     * (or {@code null} when the module is unnamed) and the name of the
+     * resource. If the resource name has a leading slash then it is dropped
+     * before delegation.
+     *
+     * <p> A resource in a named module may be <em>encapsulated</em> so that
+     * it cannot be located by code in other modules. Whether a resource can be
+     * located or not is determined as follows: </p>
+     *
+     * <ul>
+     *     <li> If the resource name ends with  "{@code .class}" then it is not
+     *     encapsulated. </li>
+     *
+     *     <li> A <em>package name</em> is derived from the resource name. If
+     *     the package name is a {@link #getPackages() package} in the module
+     *     then the resource can only be located by the caller of this method
+     *     when the package is {@link #isOpen(String,Module) open} to at least
+     *     the caller's module. If the resource is not in a package in the module
+     *     then the resource is not encapsulated. </li>
+     * </ul>
+     *
+     * <p> In the above, the <em>package name</em> for a resource is derived
+     * from the subsequence of characters that precedes the last {@code '/'} in
+     * the name and then replacing each {@code '/'} character in the subsequence
+     * with {@code '.'}. A leading slash is ignored when deriving the package
+     * name. As an example, the package name derived for a resource named
+     * "{@code a/b/c/foo.properties}" is "{@code a.b.c}". A resource name
+     * with the name "{@code META-INF/MANIFEST.MF}" is never encapsulated
+     * because "{@code META-INF}" is not a legal package name. </p>
+     *
+     * <p> This method returns {@code null} if the resource is not in this
+     * module, the resource is encapsulated and cannot be located by the caller,
+     * or access to the resource is denied by the security manager. </p>
+     *
+     * @param  name
+     *         The resource name
+     *
+     * @return An input stream for reading the resource or {@code null}
+     *
+     * @throws IOException
+     *         If an I/O error occurs
+     *
+     * @see Class#getResourceAsStream(String)
+     */
+    @CallerSensitive
+    public InputStream getResourceAsStream(String name) throws IOException {
+        if (name.startsWith("/")) {
+            name = name.substring(1);
+        }
+
+        if (isNamed() && Resources.canEncapsulate(name)) {
+            Module caller = getCallerModule(Reflection.getCallerClass());
+            if (caller != this && caller != Object.class.getModule()) {
+                String pn = Resources.toPackageName(name);
+                if (getPackages().contains(pn)) {
+                    if (caller == null && !isOpen(pn)) {
+                        // no caller, package not open
+                        return null;
+                    }
+                    if (!isOpen(pn, caller)) {
+                        // package not open to caller
+                        return null;
+                    }
+                }
+            }
+        }
+
+        String mn = this.name;
+
+        // special-case built-in class loaders to avoid URL connection
+        if (loader == null) {
+            return BootLoader.findResourceAsStream(mn, name);
+        } else if (loader instanceof BuiltinClassLoader) {
+            return ((BuiltinClassLoader) loader).findResourceAsStream(mn, name);
+        }
+
+        // locate resource in module
+        JavaLangAccess jla = SharedSecrets.getJavaLangAccess();
+        URL url = jla.findResource(loader, mn, name);
+        if (url != null) {
+            try {
+                return url.openStream();
+            } catch (SecurityException e) { }
+        }
+
+        return null;
+    }
+
+    /**
+     * Returns the string representation of this module. For a named module,
+     * the representation is the string {@code "module"}, followed by a space,
+     * and then the module name. For an unnamed module, the representation is
+     * the string {@code "unnamed module"}, followed by a space, and then an
+     * implementation specific string that identifies the unnamed module.
+     *
+     * @return The string representation of this module
+     */
+    @Override
+    public String toString() {
+        if (isNamed()) {
+            return "module " + name;
+        } else {
+            String id = Integer.toHexString(System.identityHashCode(this));
+            return "unnamed module @" + id;
+        }
+    }
+
+    /**
+     * Returns the module that a given caller class is a member of. Returns
+     * {@code null} if the caller is {@code null}.
+     */
+    private Module getCallerModule(Class<?> caller) {
+        return (caller != null) ? caller.getModule() : null;
+    }
+
+
+    // -- native methods --
+
+    // JVM_DefineModule
+    private static native void defineModule0(Module module,
+                                             boolean isOpen,
+                                             String version,
+                                             String location,
+                                             String[] pns);
+
+    // JVM_AddReadsModule
+    private static native void addReads0(Module from, Module to);
+
+    // JVM_AddModuleExports
+    private static native void addExports0(Module from, String pn, Module to);
+
+    // JVM_AddModuleExportsToAll
+    private static native void addExportsToAll0(Module from, String pn);
+
+    // JVM_AddModuleExportsToAllUnnamed
+    private static native void addExportsToAllUnnamed0(Module from, String pn);
+
+    // JVM_AddModulePackage
+    private static native void addPackage0(Module m, String pn);
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/java.base/share/classes/java/lang/ModuleLayer.java	Tue Apr 18 22:25:33 2017 +0200
@@ -0,0 +1,944 @@
+/*
+ * Copyright (c) 2014, 2017, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package java.lang;
+
+import java.lang.module.Configuration;
+import java.lang.module.ModuleDescriptor;
+import java.lang.module.ResolvedModule;
+import java.util.ArrayDeque;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Deque;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Objects;
+import java.util.Optional;
+import java.util.Set;
+import java.util.concurrent.CopyOnWriteArrayList;
+import java.util.function.Function;
+import java.util.stream.Collectors;
+import java.util.stream.Stream;
+
+import jdk.internal.loader.ClassLoaderValue;
+import jdk.internal.loader.Loader;
+import jdk.internal.loader.LoaderPool;
+import jdk.internal.module.ServicesCatalog;
+import sun.security.util.SecurityConstants;
+
+
+/**
+ * A layer of modules in the Java virtual machine.
+ *
+ * <p> A layer is created from a graph of modules in a {@link Configuration}
+ * and a function that maps each module to a {@link ClassLoader}.
+ * Creating a layer informs the Java virtual machine about the classes that
+ * may be loaded from the modules so that the Java virtual machine knows which
+ * module that each class is a member of. </p>
+ *
+ * <p> Creating a layer creates a {@link Module} object for each {@link
+ * ResolvedModule} in the configuration. For each resolved module that is
+ * {@link ResolvedModule#reads() read}, the {@code Module} {@link
+ * Module#canRead reads} the corresponding run-time {@code Module}, which may
+ * be in the same layer or a {@link #parents() parent} layer. </p>
+ *
+ * <p> The {@link #defineModulesWithOneLoader defineModulesWithOneLoader} and
+ * {@link #defineModulesWithManyLoaders defineModulesWithManyLoaders} methods
+ * provide convenient ways to create a module layer where all modules are
+ * mapped to a single class loader or where each module is mapped to its own
+ * class loader. The {@link #defineModules defineModules} method is for more
+ * advanced cases where modules are mapped to custom class loaders by means of
+ * a function specified to the method. Each of these methods has an instance
+ * and static variant. The instance methods create a layer with the receiver
+ * as the parent layer. The static methods are for more advanced cases where
+ * there can be more than one parent layer or where a {@link
+ * ModuleLayer.Controller Controller} is needed to control modules in the layer
+ * </p>
+ *
+ * <p> A Java virtual machine has at least one non-empty layer, the {@link
+ * #boot() boot} layer, that is created when the Java virtual machine is
+ * started. The boot layer contains module {@code java.base} and is the only
+ * layer in the Java virtual machine with a module named "{@code java.base}".
+ * The modules in the boot layer are mapped to the bootstrap class loader and
+ * other class loaders that are <a href="../ClassLoader.html#builtinLoaders">
+ * built-in</a> into the Java virtual machine. The boot layer will often be
+ * the {@link #parents() parent} when creating additional layers. </p>
+ *
+ * <p> Each {@code Module} in a layer is created so that it {@link
+ * Module#isExported(String) exports} and {@link Module#isOpen(String) opens}
+ * the packages described by its {@link ModuleDescriptor}. Qualified exports
+ * (where a package is exported to a set of target modules rather than all
+ * modules) are reified when creating the layer as follows: </p>
+ * <ul>
+ *     <li> If module {@code X} exports a package to {@code Y}, and if the
+ *     runtime {@code Module} {@code X} reads {@code Module} {@code Y}, then
+ *     the package is exported to {@code Module} {@code Y} (which may be in
+ *     the same layer as {@code X} or a parent layer). </li>
+ *
+ *     <li> If module {@code X} exports a package to {@code Y}, and if the
+ *     runtime {@code Module} {@code X} does not read {@code Y} then target
+ *     {@code Y} is located as if by invoking {@link #findModule(String)
+ *     findModule} to find the module in the layer or its parent layers. If
+ *     {@code Y} is found then the package is exported to the instance of
+ *     {@code Y} that was found. If {@code Y} is not found then the qualified
+ *     export is ignored. </li>
+ * </ul>
+ *
+ * <p> Qualified opens are handled in same way as qualified exports. </p>
+ *
+ * <p> As when creating a {@code Configuration},
+ * {@link ModuleDescriptor#isAutomatic() automatic} modules receive special
+ * treatment when creating a layer. An automatic module is created in the
+ * Java virtual machine as a {@code Module} that reads every unnamed {@code
+ * Module} in the Java virtual machine. </p>
+ *
+ * <p> Unless otherwise specified, passing a {@code null} argument to a method
+ * in this class causes a {@link NullPointerException NullPointerException} to
+ * be thrown. </p>
+ *
+ * <h3> Example usage: </h3>
+ *
+ * <p> This example creates a configuration by resolving a module named
+ * "{@code myapp}" with the configuration for the boot layer as the parent. It
+ * then creates a new layer with the modules in this configuration. All modules
+ * are defined to the same class loader. </p>
+ *
+ * <pre>{@code
+ *     ModuleFinder finder = ModuleFinder.of(dir1, dir2, dir3);
+ *
+ *     ModuleLayer parent = ModuleLayer.boot();
+ *
+ *     Configuration cf = parent.configuration().resolve(finder, ModuleFinder.of(), Set.of("myapp"));
+ *
+ *     ClassLoader scl = ClassLoader.getSystemClassLoader();
+ *
+ *     ModuleLayer layer = parent.defineModulesWithOneLoader(cf, scl);
+ *
+ *     Class<?> c = layer.findLoader("myapp").loadClass("app.Main");
+ * }</pre>
+ *
+ * @since 9
+ * @spec JPMS
+ * @see Module#getLayer()
+ */
+
+public final class ModuleLayer {
+
+    // the empty layer
+    private static final ModuleLayer EMPTY_LAYER
+        = new ModuleLayer(Configuration.empty(), List.of(), null);
+
+    // the configuration from which this ;ayer was created
+    private final Configuration cf;
+
+    // parent layers, empty in the case of the empty layer
+    private final List<ModuleLayer> parents;
+
+    // maps module name to jlr.Module
+    private final Map<String, Module> nameToModule;
+
+    /**
+     * Creates a new module layer from the modules in the given configuration.
+     */
+    private ModuleLayer(Configuration cf,
+                        List<ModuleLayer> parents,
+                        Function<String, ClassLoader> clf)
+    {
+        this.cf = cf;
+        this.parents = parents; // no need to do defensive copy
+
+        Map<String, Module> map;
+        if (parents.isEmpty()) {
+            map = Collections.emptyMap();
+        } else {
+            map = Module.defineModules(cf, clf, this);
+        }
+        this.nameToModule = map; // no need to do defensive copy
+    }
+
+    /**
+     * Controls a module layer. The static methods defined by {@link ModuleLayer}
+     * to create module layers return a {@code Controller} that can be used to
+     * control modules in the layer.
+     *
+     * <p> Unless otherwise specified, passing a {@code null} argument to a
+     * method in this class causes a {@link NullPointerException
+     * NullPointerException} to be thrown. </p>
+     *
+     * @apiNote Care should be taken with {@code Controller} objects, they
+     * should never be shared with untrusted code.
+     *
+     * @since 9
+     * @spec JPMS
+     */
+    public static final class Controller {
+        private final ModuleLayer layer;
+
+        Controller(ModuleLayer layer) {
+            this.layer = layer;
+        }
+
+        /**
+         * Returns the layer that this object controls.
+         *
+         * @return the module layer
+         */
+        public ModuleLayer layer() {
+            return layer;
+        }
+
+        private void ensureInLayer(Module source) {
+            if (source.getLayer() != layer)
+                throw new IllegalArgumentException(source + " not in layer");
+        }
+
+
+        /**
+         * Updates module {@code source} in the layer to read module
+         * {@code target}. This method is a no-op if {@code source} already
+         * reads {@code target}.
+         *
+         * @implNote <em>Read edges</em> added by this method are <em>weak</em>
+         * and do not prevent {@code target} from being GC'ed when {@code source}
+         * is strongly reachable.
+         *
+         * @param  source
+         *         The source module
+         * @param  target
+         *         The target module to read
+         *
+         * @return This controller
+         *
+         * @throws IllegalArgumentException
+         *         If {@code source} is not in the module layer
+         *
+         * @see Module#addReads
+         */
+        public Controller addReads(Module source, Module target) {
+            ensureInLayer(source);
+            source.implAddReads(target);
+            return this;
+        }
+
+        /**
+         * Updates module {@code source} in the layer to open a package to
+         * module {@code target}. This method is a no-op if {@code source}
+         * already opens the package to at least {@code target}.
+         *
+         * @param  source
+         *         The source module
+         * @param  pn
+         *         The package name
+         * @param  target
+         *         The target module to read
+         *
+         * @return This controller
+         *
+         * @throws IllegalArgumentException
+         *         If {@code source} is not in the module layer or the package
+         *         is not in the source module
+         *
+         * @see Module#addOpens
+         */
+        public Controller addOpens(Module source, String pn, Module target) {
+            ensureInLayer(source);
+            source.implAddOpens(pn, target);
+            return this;
+        }
+    }
+
+
+    /**
+     * Creates a new module layer, with this layer as its parent, by defining the
+     * modules in the given {@code Configuration} to the Java virtual machine.
+     * This method creates one class loader and defines all modules to that
+     * class loader. The {@link ClassLoader#getParent() parent} of each class
+     * loader is the given parent class loader. This method works exactly as
+     * specified by the static {@link
+     * #defineModulesWithOneLoader(Configuration,List,ClassLoader)
+     * defineModulesWithOneLoader} method when invoked with this layer as the
+     * parent. In other words, if this layer is {@code thisLayer} then this
+     * method is equivalent to invoking:
+     * <pre> {@code
+     *     ModuleLayer.defineModulesWithOneLoader(cf, List.of(thisLayer), parentLoader).layer();
+     * }</pre>
+     *
+     * @param  cf
+     *         The configuration for the layer
+     * @param  parentLoader
+     *         The parent class loader for the class loader created by this
+     *         method; may be {@code null} for the bootstrap class loader
+     *
+     * @return The newly created layer
+     *
+     * @throws IllegalArgumentException
+     *         If the parent of the given configuration is not the configuration
+     *         for this layer
+     * @throws LayerInstantiationException
+     *         If the layer cannot be created for any of the reasons specified
+     *         by the static {@code defineModulesWithOneLoader} method
+     * @throws SecurityException
+     *         If {@code RuntimePermission("createClassLoader")} or
+     *         {@code RuntimePermission("getClassLoader")} is denied by
+     *         the security manager
+     *
+     * @see #findLoader
+     */
+    public ModuleLayer defineModulesWithOneLoader(Configuration cf,
+                                                  ClassLoader parentLoader) {
+        return defineModulesWithOneLoader(cf, List.of(this), parentLoader).layer();
+    }
+
+
+    /**
+     * Creates a new module layer, with this layer as its parent, by defining the
+     * modules in the given {@code Configuration} to the Java virtual machine.
+     * Each module is defined to its own {@link ClassLoader} created by this
+     * method. The {@link ClassLoader#getParent() parent} of each class loader
+     * is the given parent class loader. This method works exactly as specified
+     * by the static {@link
+     * #defineModulesWithManyLoaders(Configuration,List,ClassLoader)
+     * defineModulesWithManyLoaders} method when invoked with this layer as the
+     * parent. In other words, if this layer is {@code thisLayer} then this
+     * method is equivalent to invoking:
+     * <pre> {@code
+     *     ModuleLayer.defineModulesWithManyLoaders(cf, List.of(thisLayer), parentLoader).layer();
+     * }</pre>
+     *
+     * @param  cf
+     *         The configuration for the layer
+     * @param  parentLoader
+     *         The parent class loader for each of the class loaders created by
+     *         this method; may be {@code null} for the bootstrap class loader
+     *
+     * @return The newly created layer
+     *
+     * @throws IllegalArgumentException
+     *         If the parent of the given configuration is not the configuration
+     *         for this layer
+     * @throws LayerInstantiationException
+     *         If the layer cannot be created for any of the reasons specified
+     *         by the static {@code defineModulesWithManyLoaders} method
+     * @throws SecurityException
+     *         If {@code RuntimePermission("createClassLoader")} or
+     *         {@code RuntimePermission("getClassLoader")} is denied by
+     *         the security manager
+     *
+     * @see #findLoader
+     */
+    public ModuleLayer defineModulesWithManyLoaders(Configuration cf,
+                                                    ClassLoader parentLoader) {
+        return defineModulesWithManyLoaders(cf, List.of(this), parentLoader).layer();
+    }
+
+
+    /**
+     * Creates a new module layer, with this layer as its parent, by defining the
+     * modules in the given {@code Configuration} to the Java virtual machine.
+     * Each module is mapped, by name, to its class loader by means of the
+     * given function. This method works exactly as specified by the static
+     * {@link #defineModules(Configuration,List,Function) defineModules}
+     * method when invoked with this layer as the parent. In other words, if
+     * this layer is {@code thisLayer} then this method is equivalent to
+     * invoking:
+     * <pre> {@code
+     *     ModuleLayer.defineModules(cf, List.of(thisLayer), clf).layer();
+     * }</pre>
+     *
+     * @param  cf
+     *         The configuration for the layer
+     * @param  clf
+     *         The function to map a module name to a class loader
+     *
+     * @return The newly created layer
+     *
+     * @throws IllegalArgumentException
+     *         If the parent of the given configuration is not the configuration
+     *         for this layer
+     * @throws LayerInstantiationException
+     *         If the layer cannot be created for any of the reasons specified
+     *         by the static {@code defineModules} method
+     * @throws SecurityException
+     *         If {@code RuntimePermission("getClassLoader")} is denied by
+     *         the security manager
+     */
+    public ModuleLayer defineModules(Configuration cf,
+                                     Function<String, ClassLoader> clf) {
+        return defineModules(cf, List.of(this), clf).layer();
+    }
+
+    /**
+     * Creates a new module layer by defining the modules in the given {@code
+     * Configuration} to the Java virtual machine. This method creates one
+     * class loader and defines all modules to that class loader.
+     *
+     * <p> The class loader created by this method implements <em>direct
+     * delegation</em> when loading types from modules. When its {@link
+     * ClassLoader#loadClass(String, boolean) loadClass} method is invoked to
+     * load a class then it uses the package name of the class to map it to a
+     * module. This may be a module in this layer and hence defined to the same
+     * class loader. It may be a package in a module in a parent layer that is
+     * exported to one or more of the modules in this layer. The class
+     * loader delegates to the class loader of the module, throwing {@code
+     * ClassNotFoundException} if not found by that class loader.
+     * When {@code loadClass} is invoked to load classes that do not map to a
+     * module then it delegates to the parent class loader. </p>
+     *
+     * <p> Attempting to create a layer with all modules defined to the same
+     * class loader can fail for the following reasons:
+     *
+     * <ul>
+     *
+     *     <li><p> <em>Overlapping packages</em>: Two or more modules in the
+     *     configuration have the same package. </p></li>
+     *
+     *     <li><p> <em>Split delegation</em>: The resulting class loader would
+     *     need to delegate to more than one class loader in order to load types
+     *     in a specific package. </p></li>
+     *
+     * </ul>
+     *
+     * <p> In addition, a layer cannot be created if the configuration contains
+     * a module named "{@code java.base}", or a module contains a package named
+     * "{@code java}" or a package with a name starting with "{@code java.}". </p>
+     *
+     * <p> If there is a security manager then the class loader created by
+     * this method will load classes and resources with privileges that are
+     * restricted by the calling context of this method. </p>
+     *
+     * @param  cf
+     *         The configuration for the layer
+     * @param  parentLayers
+     *         The list of parent layers in search order
+     * @param  parentLoader
+     *         The parent class loader for the class loader created by this
+     *         method; may be {@code null} for the bootstrap class loader
+     *
+     * @return A controller that controls the newly created layer
+     *
+     * @throws IllegalArgumentException
+     *         If the parent configurations do not match the configuration of
+     *         the parent layers, including order
+     * @throws LayerInstantiationException
+     *         If all modules cannot be defined to the same class loader for any
+     *         of the reasons listed above
+     * @throws SecurityException
+     *         If {@code RuntimePermission("createClassLoader")} or
+     *         {@code RuntimePermission("getClassLoader")} is denied by
+     *         the security manager
+     *
+     * @see #findLoader
+     */
+    public static Controller defineModulesWithOneLoader(Configuration cf,
+                                                        List<ModuleLayer> parentLayers,
+                                                        ClassLoader parentLoader)
+    {
+        List<ModuleLayer> parents = new ArrayList<>(parentLayers);
+        checkConfiguration(cf, parents);
+
+        checkCreateClassLoaderPermission();
+        checkGetClassLoaderPermission();
+
+        try {
+            Loader loader = new Loader(cf.modules(), parentLoader);
+            loader.initRemotePackageMap(cf, parents);
+            ModuleLayer layer =  new ModuleLayer(cf, parents, mn -> loader);
+            return new Controller(layer);
+        } catch (IllegalArgumentException | IllegalStateException e) {
+            throw new LayerInstantiationException(e.getMessage());
+        }
+    }
+
+    /**
+     * Creates a new module layer by defining the modules in the given {@code
+     * Configuration} to the Java virtual machine. Each module is defined to
+     * its own {@link ClassLoader} created by this method. The {@link
+     * ClassLoader#getParent() parent} of each class loader is the given parent
+     * class loader.
+     *
+     * <p> The class loaders created by this method implement <em>direct
+     * delegation</em> when loading types from modules. When {@link
+     * ClassLoader#loadClass(String, boolean) loadClass} method is invoked to
+     * load a class then it uses the package name of the class to map it to a
+     * module. The package may be in the module defined to the class loader.
+     * The package may be exported by another module in this layer to the
+     * module defined to the class loader. It may be in a package exported by a
+     * module in a parent layer. The class loader delegates to the class loader
+     * of the module, throwing {@code ClassNotFoundException} if not found by
+     * that class loader.
+     * When {@code loadClass} is invoked to load classes that do not map to a
+     * module then it delegates to the parent class loader. </p>
+     *
+     * <p> If there is a security manager then the class loaders created by
+     * this method will load classes and resources with privileges that are
+     * restricted by the calling context of this method. </p>
+     *
+     * @param  cf
+     *         The configuration for the layer
+     * @param  parentLayers
+     *         The list of parent layers in search order
+     * @param  parentLoader
+     *         The parent class loader for each of the class loaders created by
+     *         this method; may be {@code null} for the bootstrap class loader
+     *
+     * @return A controller that controls the newly created layer
+     *
+     * @throws IllegalArgumentException
+     *         If the parent configurations do not match the configuration of
+     *         the parent layers, including order
+     * @throws LayerInstantiationException
+     *         If the layer cannot be created because the configuration contains
+     *         a module named "{@code java.base}" or a module contains a package
+     *         named "{@code java}" or a package with a name starting with
+     *         "{@code java.}"
+     *
+     * @throws SecurityException
+     *         If {@code RuntimePermission("createClassLoader")} or
+     *         {@code RuntimePermission("getClassLoader")} is denied by
+     *         the security manager
+     *
+     * @see #findLoader
+     */
+    public static Controller defineModulesWithManyLoaders(Configuration cf,
+                                                          List<ModuleLayer> parentLayers,
+                                                          ClassLoader parentLoader)
+    {
+        List<ModuleLayer> parents = new ArrayList<>(parentLayers);
+        checkConfiguration(cf, parents);
+
+        checkCreateClassLoaderPermission();
+        checkGetClassLoaderPermission();
+
+        LoaderPool pool = new LoaderPool(cf, parents, parentLoader);
+        try {
+            ModuleLayer layer = new ModuleLayer(cf, parents, pool::loaderFor);
+            return new Controller(layer);
+        } catch (IllegalArgumentException | IllegalStateException e) {
+            throw new LayerInstantiationException(e.getMessage());
+        }
+    }
+
+    /**
+     * Creates a new module layer by defining the modules in the given {@code
+     * Configuration} to the Java virtual machine. The given function maps each
+     * module in the configuration, by name, to a class loader. Creating the
+     * layer informs the Java virtual machine about the classes that may be
+     * loaded so that the Java virtual machine knows which module that each
+     * class is a member of.
+     *
+     * <p> The class loader delegation implemented by the class loaders must
+     * respect module readability. The class loaders should be
+     * {@link ClassLoader#registerAsParallelCapable parallel-capable} so as to
+     * avoid deadlocks during class loading. In addition, the entity creating
+     * a new layer with this method should arrange that the class loaders be
+     * ready to load from these modules before there are any attempts to load
+     * classes or resources. </p>
+     *
+     * <p> Creating a layer can fail for the following reasons: </p>
+     *
+     * <ul>
+     *
+     *     <li><p> Two or more modules with the same package are mapped to the
+     *     same class loader. </p></li>
+     *
+     *     <li><p> A module is mapped to a class loader that already has a
+     *     module of the same name defined to it. </p></li>
+     *
+     *     <li><p> A module is mapped to a class loader that has already
+     *     defined types in any of the packages in the module. </p></li>
+     *
+     * </ul>
+     *
+     * <p> In addition, a layer cannot be created if the configuration contains
+     * a module named "{@code java.base}", a configuration contains a module
+     * with a package named "{@code java}" or a package name starting with
+     * "{@code java.}" and the module is mapped to a class loader other than
+     * the {@link ClassLoader#getPlatformClassLoader() platform class loader},
+     * or the function to map a module name to a class loader returns
+     * {@code null}. </p>
+     *
+     * <p> If the function to map a module name to class loader throws an error
+     * or runtime exception then it is propagated to the caller of this method.
+     * </p>
+     *
+     * @apiNote It is implementation specific as to whether creating a layer
+     * with this method is an atomic operation or not. Consequentially it is
+     * possible for this method to fail with some modules, but not all, defined
+     * to the Java virtual machine.
+     *
+     * @param  cf
+     *         The configuration for the layer
+     * @param  parentLayers
+     *         The list of parent layers in search order
+     * @param  clf
+     *         The function to map a module name to a class loader
+     *
+     * @return A controller that controls the newly created layer
+     *
+     * @throws IllegalArgumentException
+     *         If the parent configurations do not match the configuration of
+     *         the parent layers, including order
+     * @throws LayerInstantiationException
+     *         If creating the layer fails for any of the reasons listed above
+     * @throws SecurityException
+     *         If {@code RuntimePermission("getClassLoader")} is denied by
+     *         the security manager
+     */
+    public static Controller defineModules(Configuration cf,
+                                           List<ModuleLayer> parentLayers,
+                                           Function<String, ClassLoader> clf)
+    {
+        List<ModuleLayer> parents = new ArrayList<>(parentLayers);
+        checkConfiguration(cf, parents);
+        Objects.requireNonNull(clf);
+
+        checkGetClassLoaderPermission();
+
+        // The boot layer is checked during module system initialization
+        if (boot() != null) {
+            checkForDuplicatePkgs(cf, clf);
+        }
+
+        try {
+            ModuleLayer layer = new ModuleLayer(cf, parents, clf);
+            return new Controller(layer);
+        } catch (IllegalArgumentException | IllegalStateException e) {
+            throw new LayerInstantiationException(e.getMessage());
+        }
+    }
+
+
+    /**
+     * Checks that the parent configurations match the configuration of
+     * the parent layers.
+     */
+    private static void checkConfiguration(Configuration cf,
+                                           List<ModuleLayer> parentLayers)
+    {
+        Objects.requireNonNull(cf);
+
+        List<Configuration> parentConfigurations = cf.parents();
+        if (parentLayers.size() != parentConfigurations.size())
+            throw new IllegalArgumentException("wrong number of parents");
+
+        int index = 0;
+        for (ModuleLayer parent : parentLayers) {
+            if (parent.configuration() != parentConfigurations.get(index)) {
+                throw new IllegalArgumentException(
+                        "Parent of configuration != configuration of this Layer");
+            }
+            index++;
+        }
+    }
+
+    private static void checkCreateClassLoaderPermission() {
+        SecurityManager sm = System.getSecurityManager();
+        if (sm != null)
+            sm.checkPermission(SecurityConstants.CREATE_CLASSLOADER_PERMISSION);
+    }
+
+    private static void checkGetClassLoaderPermission() {
+        SecurityManager sm = System.getSecurityManager();
+        if (sm != null)
+            sm.checkPermission(SecurityConstants.GET_CLASSLOADER_PERMISSION);
+    }
+
+    /**
+     * Checks a configuration and the module-to-loader mapping to ensure that
+     * no two modules mapped to the same class loader have the same package.
+     * It also checks that no two automatic modules have the same package.
+     *
+     * @throws LayerInstantiationException
+     */
+    private static void checkForDuplicatePkgs(Configuration cf,
+                                              Function<String, ClassLoader> clf)
+    {
+        // HashMap allows null keys
+        Map<ClassLoader, Set<String>> loaderToPackages = new HashMap<>();
+        for (ResolvedModule resolvedModule : cf.modules()) {
+            ModuleDescriptor descriptor = resolvedModule.reference().descriptor();
+            ClassLoader loader = clf.apply(descriptor.name());
+
+            Set<String> loaderPackages
+                = loaderToPackages.computeIfAbsent(loader, k -> new HashSet<>());
+
+            for (String pkg : descriptor.packages()) {
+                boolean added = loaderPackages.add(pkg);
+                if (!added) {
+                    throw fail("More than one module with package %s mapped" +
+                               " to the same class loader", pkg);
+                }
+            }
+        }
+    }
+
+    /**
+     * Creates a LayerInstantiationException with the a message formatted from
+     * the given format string and arguments.
+     */
+    private static LayerInstantiationException fail(String fmt, Object ... args) {
+        String msg = String.format(fmt, args);
+        return new LayerInstantiationException(msg);
+    }
+
+
+    /**
+     * Returns the configuration for this layer.
+     *
+     * @return The configuration for this layer
+     */
+    public Configuration configuration() {
+        return cf;
+    }
+
+
+    /**
+     * Returns the list of this layer's parents unless this is the
+     * {@linkplain #empty empty layer}, which has no parents and so an
+     * empty list is returned.
+     *
+     * @return The list of this layer's parents
+     */
+    public List<ModuleLayer> parents() {
+        return parents;
+    }
+
+
+    /**
+     * Returns an ordered stream of layers. The first element is is this layer,
+     * the remaining elements are the parent layers in DFS order.
+     *
+     * @implNote For now, the assumption is that the number of elements will
+     * be very low and so this method does not use a specialized spliterator.
+     */
+    Stream<ModuleLayer> layers() {
+        List<ModuleLayer> allLayers = this.allLayers;
+        if (allLayers != null)
+            return allLayers.stream();
+
+        allLayers = new ArrayList<>();
+        Set<ModuleLayer> visited = new HashSet<>();
+        Deque<ModuleLayer> stack = new ArrayDeque<>();
+        visited.add(this);
+        stack.push(this);
+
+        while (!stack.isEmpty()) {
+            ModuleLayer layer = stack.pop();
+            allLayers.add(layer);
+
+            // push in reverse order
+            for (int i = layer.parents.size() - 1; i >= 0; i--) {
+                ModuleLayer parent = layer.parents.get(i);
+                if (!visited.contains(parent)) {
+                    visited.add(parent);
+                    stack.push(parent);
+                }
+            }
+        }
+
+        this.allLayers = allLayers = Collections.unmodifiableList(allLayers);
+        return allLayers.stream();
+    }
+
+    private volatile List<ModuleLayer> allLayers;
+
+    /**
+     * Returns the set of the modules in this layer.
+     *
+     * @return A possibly-empty unmodifiable set of the modules in this layer
+     */
+    public Set<Module> modules() {
+        Set<Module> modules = this.modules;
+        if (modules == null) {
+            this.modules = modules =
+                Collections.unmodifiableSet(new HashSet<>(nameToModule.values()));
+        }
+        return modules;
+    }
+
+    private volatile Set<Module> modules;
+
+
+    /**
+     * Returns the module with the given name in this layer, or if not in this
+     * layer, the {@linkplain #parents parent} layers. Finding a module in
+     * parent layers is equivalent to invoking {@code findModule} on each
+     * parent, in search order, until the module is found or all parents have
+     * been searched. In a <em>tree of layers</em>  then this is equivalent to
+     * a depth-first search.
+     *
+     * @param  name
+     *         The name of the module to find
+     *
+     * @return The module with the given name or an empty {@code Optional}
+     *         if there isn't a module with this name in this layer or any
+     *         parent layer
+     */
+    public Optional<Module> findModule(String name) {
+        Objects.requireNonNull(name);
+        if (this == EMPTY_LAYER)
+            return Optional.empty();
+        Module m = nameToModule.get(name);
+        if (m != null)
+            return Optional.of(m);
+
+        return layers()
+                .skip(1)  // skip this layer
+                .map(l -> l.nameToModule)
+                .filter(map -> map.containsKey(name))
+                .map(map -> map.get(name))
+                .findAny();
+    }
+
+
+    /**
+     * Returns the {@code ClassLoader} for the module with the given name. If
+     * a module of the given name is not in this layer then the {@link #parents
+     * parent} layers are searched in the manner specified by {@link
+     * #findModule(String) findModule}.
+     *
+     * <p> If there is a security manager then its {@code checkPermission}
+     * method is called with a {@code RuntimePermission("getClassLoader")}
+     * permission to check that the caller is allowed to get access to the
+     * class loader. </p>
+     *
+     * @apiNote This method does not return an {@code Optional<ClassLoader>}
+     * because `null` must be used to represent the bootstrap class loader.
+     *
+     * @param  name
+     *         The name of the module to find
+     *
+     * @return The ClassLoader that the module is defined to
+     *
+     * @throws IllegalArgumentException if a module of the given name is not
+     *         defined in this layer or any parent of this layer
+     *
+     * @throws SecurityException if denied by the security manager
+     */
+    public ClassLoader findLoader(String name) {
+        Optional<Module> om = findModule(name);
+
+        // can't use map(Module::getClassLoader) as class loader can be null
+        if (om.isPresent()) {
+            return om.get().getClassLoader();
+        } else {
+            throw new IllegalArgumentException("Module " + name
+                                               + " not known to this layer");
+        }
+    }
+
+    /**
+     * Returns a string describing this module layer.
+     *
+     * @return A possibly empty string describing this module layer
+     */
+    @Override
+    public String toString() {
+        return modules().stream()
+                .map(Module::getName)
+                .collect(Collectors.joining(", "));
+    }
+
+    /**
+     * Returns the <em>empty</em> layer. There are no modules in the empty
+     * layer. It has no parents.
+     *
+     * @return The empty layer
+     */
+    public static ModuleLayer empty() {
+        return EMPTY_LAYER;
+    }
+
+
+    /**
+     * Returns the boot layer. The boot layer contains at least one module,
+     * {@code java.base}. Its parent is the {@link #empty() empty} layer.
+     *
+     * @apiNote This method returns {@code null} during startup and before
+     *          the boot layer is fully initialized.
+     *
+     * @return The boot layer
+     */
+    public static ModuleLayer boot() {
+        return System.bootLayer;
+    }
+
+    /**
+     * Returns the ServicesCatalog for this Layer, creating it if not
+     * already created.
+     */
+    ServicesCatalog getServicesCatalog() {
+        ServicesCatalog servicesCatalog = this.servicesCatalog;
+        if (servicesCatalog != null)
+            return servicesCatalog;
+
+        synchronized (this) {
+            servicesCatalog = this.servicesCatalog;
+            if (servicesCatalog == null) {
+                servicesCatalog = ServicesCatalog.create();
+                nameToModule.values().forEach(servicesCatalog::register);
+                this.servicesCatalog = servicesCatalog;
+            }
+        }
+
+        return servicesCatalog;
+    }
+
+    private volatile ServicesCatalog servicesCatalog;
+
+
+    /**
+     * Record that this layer has at least one module defined to the given
+     * class loader.
+     */
+    void bindToLoader(ClassLoader loader) {
+        // CLV.computeIfAbsent(loader, (cl, clv) -> new CopyOnWriteArrayList<>())
+        List<ModuleLayer> list = CLV.get(loader);
+        if (list == null) {
+            list = new CopyOnWriteArrayList<>();
+            List<ModuleLayer> previous = CLV.putIfAbsent(loader, list);
+            if (previous != null) list = previous;
+        }
+        list.add(this);
+    }
+
+    /**
+     * Returns a stream of the layers that have at least one module defined to
+     * the given class loader.
+     */
+    static Stream<ModuleLayer> layers(ClassLoader loader) {
+        List<ModuleLayer> list = CLV.get(loader);
+        if (list != null) {
+            return list.stream();
+        } else {
+            return Stream.empty();
+        }
+    }
+
+    // the list of layers with modules defined to a class loader
+    private static final ClassLoaderValue<List<ModuleLayer>> CLV = new ClassLoaderValue<>();
+}
--- a/jdk/src/java.base/share/classes/java/lang/NamedPackage.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/jdk/src/java.base/share/classes/java/lang/NamedPackage.java	Tue Apr 18 22:25:33 2017 +0200
@@ -26,7 +26,6 @@
 
 import java.lang.module.Configuration;
 import java.lang.module.ModuleReference;
-import java.lang.reflect.Module;
 import java.net.URI;
 
 /**
--- a/jdk/src/java.base/share/classes/java/lang/Object.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/jdk/src/java.base/share/classes/java/lang/Object.java	Tue Apr 18 22:25:33 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1994, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1994, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -561,10 +561,53 @@
      * the finalization of this object to be halted, but is otherwise
      * ignored.
      *
+     * @apiNote
+     * Classes that embed non-heap resources have many options
+     * for cleanup of those resources. The class must ensure that the
+     * lifetime of each instance is longer than that of any resource it embeds.
+     * {@link java.lang.ref.Reference#reachabilityFence} can be used to ensure that
+     * objects remain reachable while resources embedded in the object are in use.
+     * <p>
+     * A subclass should avoid overriding the {@code finalize} method
+     * unless the subclass embeds non-heap resources that must be cleaned up
+     * before the instance is collected.
+     * Finalizer invocations are not automatically chained, unlike constructors.
+     * If a subclass overrides {@code finalize} it must invoke the superclass
+     * finalizer explicitly.
+     * To guard against exceptions prematurely terminating the finalize chain,
+     * the subclass should use a {@code try-finally} block to ensure
+     * {@code super.finalize()} is always invoked. For example,
+     * <pre>{@code      @Override
+     *     protected void finalize() throws Throwable {
+     *         try {
+     *             ... // cleanup subclass state
+     *         } finally {
+     *             super.finalize();
+     *         }
+     *     }
+     * }</pre>
+     *
+     * @deprecated The finalization mechanism is inherently problematic.
+     * Finalization can lead to performance issues, deadlocks, and hangs.
+     * Errors in finalizers can lead to resource leaks; there is no way to cancel
+     * finalization if it is no longer necessary; and no ordering is specified
+     * among calls to {@code finalize} methods of different objects.
+     * Furthermore, there are no guarantees regarding the timing of finalization.
+     * The {@code finalize} method might be called on a finalizable object
+     * only after an indefinite delay, if at all.
+     *
+     * Classes whose instances hold non-heap resources should provide a method
+     * to enable explicit release of those resources, and they should also
+     * implement {@link AutoCloseable} if appropriate.
+     * The {@link java.lang.ref.Cleaner} and {@link java.lang.ref.PhantomReference}
+     * provide more flexible and efficient ways to release resources when an object
+     * becomes unreachable.
+     *
      * @throws Throwable the {@code Exception} raised by this method
      * @see java.lang.ref.WeakReference
      * @see java.lang.ref.PhantomReference
      * @jls 12.6 Finalization of Class Instances
      */
+    @Deprecated(since="9")
     protected void finalize() throws Throwable { }
 }
--- a/jdk/src/java.base/share/classes/java/lang/Package.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/jdk/src/java.base/share/classes/java/lang/Package.java	Tue Apr 18 22:25:33 2017 +0200
@@ -27,7 +27,6 @@
 
 import java.lang.annotation.Annotation;
 import java.lang.reflect.AnnotatedElement;
-import java.lang.reflect.Module;
 import java.net.MalformedURLException;
 import java.net.URI;
 import java.net.URL;
--- a/jdk/src/java.base/share/classes/java/lang/SecurityManager.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/jdk/src/java.base/share/classes/java/lang/SecurityManager.java	Tue Apr 18 22:25:33 2017 +0200
@@ -29,9 +29,7 @@
 import java.lang.module.ModuleDescriptor;
 import java.lang.module.ModuleDescriptor.Exports;
 import java.lang.module.ModuleDescriptor.Opens;
-import java.lang.reflect.Layer;
 import java.lang.reflect.Member;
-import java.lang.reflect.Module;
 import java.io.FileDescriptor;
 import java.io.File;
 import java.io.FilePermission;
@@ -1441,7 +1439,7 @@
 
     static {
         // Get the modules in the boot layer
-        Stream<Module> bootLayerModules = Layer.boot().modules().stream();
+        Stream<Module> bootLayerModules = ModuleLayer.boot().modules().stream();
 
         // Filter out the modules loaded by the boot or platform loader
         PrivilegedAction<Set<Module>> pa = () ->
--- a/jdk/src/java.base/share/classes/java/lang/StackTraceElement.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/jdk/src/java.base/share/classes/java/lang/StackTraceElement.java	Tue Apr 18 22:25:33 2017 +0200
@@ -33,8 +33,6 @@
 import java.lang.module.ModuleDescriptor.Version;
 import java.lang.module.ModuleReference;
 import java.lang.module.ResolvedModule;
-import java.lang.reflect.Layer;
-import java.lang.reflect.Module;
 import java.util.HashSet;
 import java.util.Objects;
 import java.util.Optional;
@@ -191,7 +189,7 @@
      *         if the module name is not available.
      * @since 9
      * @spec JPMS
-     * @see java.lang.reflect.Module#getName()
+     * @see Module#getName()
      */
     public String getModuleName() {
         return moduleName;
@@ -480,7 +478,7 @@
         if (!VM.isModuleSystemInited())
             return true;
 
-        return Layer.boot() == m.getLayer() && HashedModules.contains(m);
+        return ModuleLayer.boot() == m.getLayer() && HashedModules.contains(m);
     }
 
     /*
@@ -492,7 +490,7 @@
 
         static Set<String> hashedModules() {
 
-            Optional<ResolvedModule> resolvedModule = Layer.boot()
+            Optional<ResolvedModule> resolvedModule = ModuleLayer.boot()
                     .configuration()
                     .findModule("java.base");
             assert resolvedModule.isPresent();
--- a/jdk/src/java.base/share/classes/java/lang/System.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/jdk/src/java.base/share/classes/java/lang/System.java	Tue Apr 18 22:25:33 2017 +0200
@@ -35,33 +35,32 @@
 import java.io.PrintStream;
 import java.io.UnsupportedEncodingException;
 import java.lang.annotation.Annotation;
+import java.lang.module.ModuleDescriptor;
 import java.lang.reflect.Constructor;
 import java.lang.reflect.Executable;
-import java.lang.reflect.Layer;
 import java.lang.reflect.Method;
 import java.lang.reflect.Modifier;
-import java.lang.reflect.Module;
+import java.net.URI;
 import java.net.URL;
 import java.security.AccessControlContext;
 import java.security.ProtectionDomain;
-import java.util.Properties;
-import java.util.PropertyPermission;
-import java.util.Map;
 import java.security.AccessController;
 import java.security.PrivilegedAction;
 import java.nio.channels.Channel;
 import java.nio.channels.spi.SelectorProvider;
+import java.util.Map;
+import java.util.Objects;
+import java.util.Properties;
+import java.util.PropertyPermission;
+import java.util.ResourceBundle;
+import java.util.function.Supplier;
 import java.util.concurrent.ConcurrentHashMap;
 import java.util.stream.Stream;
 
-import java.util.Objects;
-import java.util.ResourceBundle;
-import java.util.function.Supplier;
-import sun.nio.ch.Interruptible;
+import jdk.internal.module.ModuleBootstrap;
+import jdk.internal.module.ServicesCatalog;
 import jdk.internal.reflect.CallerSensitive;
 import jdk.internal.reflect.Reflection;
-import sun.security.util.SecurityConstants;
-import sun.reflect.annotation.AnnotationType;
 import jdk.internal.HotSpotIntrinsicCandidate;
 import jdk.internal.misc.JavaLangAccess;;
 import jdk.internal.misc.SharedSecrets;;
@@ -69,8 +68,9 @@
 import jdk.internal.logger.LoggerFinderLoader;
 import jdk.internal.logger.LazyLoggers;
 import jdk.internal.logger.LocalizedLoggerWrapper;
-
-import jdk.internal.module.ModuleBootstrap;
+import sun.reflect.annotation.AnnotationType;
+import sun.nio.ch.Interruptible;
+import sun.security.util.SecurityConstants;
 
 /**
  * The <code>System</code> class contains several useful class fields
@@ -1162,7 +1162,7 @@
          * @param msg the string message (or a key in the message catalog, if
          * this logger is a {@link
          * LoggerFinder#getLocalizedLogger(java.lang.String,
-         * java.util.ResourceBundle, java.lang.reflect.Module) localized logger});
+         * java.util.ResourceBundle, java.lang.Module) localized logger});
          * can be {@code null}.
          *
          * @throws NullPointerException if {@code level} is {@code null}.
@@ -1230,7 +1230,7 @@
          * @param msg the string message (or a key in the message catalog, if
          * this logger is a {@link
          * LoggerFinder#getLocalizedLogger(java.lang.String,
-         * java.util.ResourceBundle, java.lang.reflect.Module) localized logger});
+         * java.util.ResourceBundle, java.lang.Module) localized logger});
          * can be {@code null}.
          * @param thrown a {@code Throwable} associated with the log message;
          *        can be {@code null}.
@@ -1279,7 +1279,7 @@
          * java.text.MessageFormat} format, (or a key in the message
          * catalog, if this logger is a {@link
          * LoggerFinder#getLocalizedLogger(java.lang.String,
-         * java.util.ResourceBundle, java.lang.reflect.Module) localized logger});
+         * java.util.ResourceBundle, java.lang.Module) localized logger});
          * can be {@code null}.
          * @param params an optional list of parameters to the message (may be
          * none).
@@ -1484,7 +1484,7 @@
          * message localization.
          *
          * @implSpec By default, this method calls {@link
-         * #getLogger(java.lang.String, java.lang.reflect.Module)
+         * #getLogger(java.lang.String, java.lang.Module)
          * this.getLogger(name, module)} to obtain a logger, then wraps that
          * logger in a {@link Logger} instance where all methods that do not
          * take a {@link ResourceBundle} as parameter are redirected to one
@@ -1568,7 +1568,7 @@
      * @implSpec
      * Instances returned by this method route messages to loggers
      * obtained by calling {@link LoggerFinder#getLogger(java.lang.String,
-     * java.lang.reflect.Module) LoggerFinder.getLogger(name, module)}, where
+     * java.lang.Module) LoggerFinder.getLogger(name, module)}, where
      * {@code module} is the caller's module.
      * In cases where {@code System.getLogger} is called from a context where
      * there is no caller frame on the stack (e.g when called directly
@@ -1581,7 +1581,7 @@
      *
      * @apiNote
      * This method may defer calling the {@link
-     * LoggerFinder#getLogger(java.lang.String, java.lang.reflect.Module)
+     * LoggerFinder#getLogger(java.lang.String, java.lang.Module)
      * LoggerFinder.getLogger} method to create an actual logger supplied by
      * the logging backend, for instance, to allow loggers to be obtained during
      * the system initialization time.
@@ -1614,7 +1614,7 @@
      * @implSpec
      * The returned logger will perform message localization as specified
      * by {@link LoggerFinder#getLocalizedLogger(java.lang.String,
-     * java.util.ResourceBundle, java.lang.reflect.Module)
+     * java.util.ResourceBundle, java.lang.Module)
      * LoggerFinder.getLocalizedLogger(name, bundle, module)}, where
      * {@code module} is the caller's module.
      * In cases where {@code System.getLogger} is called from a context where
@@ -1979,7 +1979,7 @@
     }
 
     // @see #initPhase2()
-    private static Layer bootLayer;
+    static ModuleLayer bootLayer;
 
     /*
      * Invoked by VM.  Phase 2 module system initialization.
@@ -2099,12 +2099,10 @@
             public Thread newThreadWithAcc(Runnable target, AccessControlContext acc) {
                 return new Thread(target, acc);
             }
+            @SuppressWarnings("deprecation")
             public void invokeFinalize(Object o) throws Throwable {
                 o.finalize();
             }
-            public Layer getBootLayer() {
-                return bootLayer;
-            }
             public ConcurrentHashMap<?, ?> createOrGetClassLoaderValueMap(ClassLoader cl) {
                 return cl.createOrGetClassLoaderValueMap();
             }
@@ -2129,6 +2127,44 @@
             public void invalidatePackageAccessCache() {
                 SecurityManager.invalidatePackageAccessCache();
             }
+            public Module defineModule(ClassLoader loader,
+                                       ModuleDescriptor descriptor,
+                                       URI uri) {
+                return new Module(null, loader, descriptor, uri);
+            }
+            public Module defineUnnamedModule(ClassLoader loader) {
+                return new Module(loader);
+            }
+            public void addReads(Module m1, Module m2) {
+                m1.implAddReads(m2);
+            }
+            public void addReadsAllUnnamed(Module m) {
+                m.implAddReadsAllUnnamed();
+            }
+            public void addExports(Module m, String pn, Module other) {
+                m.implAddExports(pn, other);
+            }
+            public void addExportsToAllUnnamed(Module m, String pn) {
+                m.implAddExportsToAllUnnamed(pn);
+            }
+            public void addOpens(Module m, String pn, Module other) {
+                m.implAddOpens(pn, other);
+            }
+            public void addOpensToAllUnnamed(Module m, String pn) {
+                m.implAddOpensToAllUnnamed(pn);
+            }
+            public void addUses(Module m, Class<?> service) {
+                m.implAddUses(service);
+            }
+            public ServicesCatalog getServicesCatalog(ModuleLayer layer) {
+                return layer.getServicesCatalog();
+            }
+            public Stream<ModuleLayer> layers(ModuleLayer layer) {
+                return layer.layers();
+            }
+            public Stream<ModuleLayer> layers(ClassLoader loader) {
+                return ModuleLayer.layers(loader);
+            }
         });
     }
 }
--- a/jdk/src/java.base/share/classes/java/lang/Thread.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/jdk/src/java.base/share/classes/java/lang/Thread.java	Tue Apr 18 22:25:33 2017 +0200
@@ -927,7 +927,7 @@
      *       for example), the <code>interrupt</code> method should be used to
      *       interrupt the wait.
      *       For more information, see
-     *       <a href="{@docRoot}/../technotes/guides/concurrency/threadPrimitiveDeprecation.html">Why
+     *       <a href="{@docRoot}/java/lang/doc-files/threadPrimitiveDeprecation.html">Why
      *       are Thread.stop, Thread.suspend and Thread.resume Deprecated?</a>.
      */
     @Deprecated(since="1.2")
@@ -960,7 +960,7 @@
      *        could be used to generate exceptions that the target thread was
      *        not prepared to handle.
      *        For more information, see
-     *        <a href="{@docRoot}/../technotes/guides/concurrency/threadPrimitiveDeprecation.html">Why
+     *        <a href="{@docRoot}/java/lang/doc-files/threadPrimitiveDeprecation.html">Why
      *        are Thread.stop, Thread.suspend and Thread.resume Deprecated?</a>.
      *        This method is subject to removal in a future version of Java SE.
      */
@@ -1082,7 +1082,7 @@
      *     If another thread ever attempted to lock this resource, deadlock
      *     would result. Such deadlocks typically manifest themselves as
      *     "frozen" processes. For more information, see
-     *     <a href="{@docRoot}/../technotes/guides/concurrency/threadPrimitiveDeprecation.html">
+     *     <a href="{@docRoot}/java/lang/doc-files/threadPrimitiveDeprecation.html">
      *     Why are Thread.stop, Thread.suspend and Thread.resume Deprecated?</a>.
      *     This method is subject to removal in a future version of Java SE.
      * @throws NoSuchMethodError always
@@ -1122,7 +1122,7 @@
      *   monitor prior to calling <code>resume</code>, deadlock results.  Such
      *   deadlocks typically manifest themselves as "frozen" processes.
      *   For more information, see
-     *   <a href="{@docRoot}/../technotes/guides/concurrency/threadPrimitiveDeprecation.html">Why
+     *   <a href="{@docRoot}/java/lang/doc-files/threadPrimitiveDeprecation.html">Why
      *   are Thread.stop, Thread.suspend and Thread.resume Deprecated?</a>.
      */
     @Deprecated(since="1.2")
@@ -1148,7 +1148,7 @@
      * @deprecated This method exists solely for use with {@link #suspend},
      *     which has been deprecated because it is deadlock-prone.
      *     For more information, see
-     *     <a href="{@docRoot}/../technotes/guides/concurrency/threadPrimitiveDeprecation.html">Why
+     *     <a href="{@docRoot}/java/lang/doc-files/threadPrimitiveDeprecation.html">Why
      *     are Thread.stop, Thread.suspend and Thread.resume Deprecated?</a>.
      */
     @Deprecated(since="1.2")
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/java.base/share/classes/java/lang/WeakPairMap.java	Tue Apr 18 22:25:33 2017 +0200
@@ -0,0 +1,354 @@
+/*
+ * 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 java.lang;
+
+import java.lang.ref.Reference;
+import java.lang.ref.ReferenceQueue;
+import java.lang.ref.WeakReference;
+import java.util.Collection;
+import java.util.Objects;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.function.BiFunction;
+
+/**
+ * A WeakHashMap-like data structure that uses a pair of weakly-referenced keys
+ * with identity equality semantics to associate a strongly-referenced value.
+ * Unlike WeakHashMap, this data structure is thread-safe.
+ *
+ * @param <K1> the type of 1st key in key pair
+ * @param <K2> the type of 2nd key in key pair
+ * @param <V>  the type of value
+ * @author Peter Levart
+ */
+final class WeakPairMap<K1, K2, V> {
+
+    private final ConcurrentHashMap<Pair<K1, K2>, V> map = new ConcurrentHashMap<>();
+    private final ReferenceQueue<Object> queue = new ReferenceQueue<>();
+
+    /**
+     * Tests if the specified pair of keys are associated with a value
+     * in the WeakPairMap.
+     *
+     * @param k1 the 1st of the pair of keys
+     * @param k2 the 2nd of the pair of keys
+     * @return true if and only if the specified key pair is in this WeakPairMap,
+     * as determined by the identity comparison; false otherwise
+     * @throws NullPointerException if any of the specified keys is null
+     */
+    public boolean containsKeyPair(K1 k1, K2 k2) {
+        expungeStaleAssociations();
+        return map.containsKey(Pair.lookup(k1, k2));
+    }
+
+    /**
+     * Returns the value to which the specified pair of keys is mapped, or null
+     * if this WeakPairMap contains no mapping for the key pair.
+     * <p>More formally, if this WeakPairMap contains a mapping from a key pair
+     * {@code (_k1, _k2)} to a value {@code v} such that
+     * {@code k1 == _k1 && k2 == _k2}, then this method returns {@code v};
+     * otherwise it returns {@code null}.
+     * (There can be at most one such mapping.)
+     *
+     * @param k1 the 1st of the pair of keys for which the mapped value is to
+     *           be returned
+     * @param k2 the 2nd of the pair of keys for which the mapped value is to
+     *           be returned
+     * @return the value to which the specified key pair is mapped, or null if
+     * this map contains no mapping for the key pair
+     * @throws NullPointerException if any of the specified keys is null
+     */
+    public V get(K1 k1, K2 k2) {
+        expungeStaleAssociations();
+        return map.get(Pair.lookup(k1, k2));
+    }
+
+    /**
+     * Maps the specified key pair to the specified value in this WeakPairMap.
+     * Neither the keys nor the value can be null.
+     * <p>The value can be retrieved by calling the {@link #get} method
+     * with the the same keys (compared by identity).
+     *
+     * @param k1 the 1st of the pair of keys with which the specified value is to
+     *           be associated
+     * @param k2 the 2nd of the pair of keys with which the specified value is to
+     *           be associated
+     * @param v  value to be associated with the specified key pair
+     * @return the previous value associated with key pair, or {@code null} if
+     * there was no mapping for key pair
+     * @throws NullPointerException if any of the specified keys or value is null
+     */
+    public V put(K1 k1, K2 k2, V v) {
+        expungeStaleAssociations();
+        return map.put(Pair.weak(k1, k2, queue), v);
+    }
+
+    /**
+     * If the specified key pair is not already associated with a value,
+     * associates it with the given value and returns {@code null}, else does
+     * nothing and returns the currently associated value.
+     *
+     * @param k1 the 1st of the pair of keys with which the specified value is to
+     *           be associated
+     * @param k2 the 2nd of the pair of keys with which the specified value is to
+     *           be associated
+     * @param v  value to be associated with the specified key pair
+     * @return the previous value associated with key pair, or {@code null} if
+     * there was no mapping for key pair
+     * @throws NullPointerException if any of the specified keys or value is null
+     */
+    public V putIfAbsent(K1 k1, K2 k2, V v) {
+        expungeStaleAssociations();
+        return map.putIfAbsent(Pair.weak(k1, k2, queue), v);
+    }
+
+    /**
+     * If the specified key pair is not already associated with a value,
+     * attempts to compute its value using the given mapping function
+     * and enters it into this WeakPairMap unless {@code null}. The entire
+     * method invocation is performed atomically, so the function is
+     * applied at most once per key pair. Some attempted update operations
+     * on this WeakPairMap by other threads may be blocked while computation
+     * is in progress, so the computation should be short and simple,
+     * and must not attempt to update any other mappings of this WeakPairMap.
+     *
+     * @param k1              the 1st of the pair of keys with which the
+     *                        computed value is to be associated
+     * @param k2              the 2nd of the pair of keys with which the
+     *                        computed value is to be associated
+     * @param mappingFunction the function to compute a value
+     * @return the current (existing or computed) value associated with
+     * the specified key pair, or null if the computed value is null
+     * @throws NullPointerException  if any of the specified keys or
+     *                               mappingFunction is null
+     * @throws IllegalStateException if the computation detectably
+     *                               attempts a recursive update to this map
+     *                               that would otherwise never complete
+     * @throws RuntimeException      or Error if the mappingFunction does so, in
+     *                               which case the mapping is left unestablished
+     */
+    public V computeIfAbsent(K1 k1, K2 k2,
+                             BiFunction<? super K1, ? super K2, ? extends V>
+                                 mappingFunction) {
+        expungeStaleAssociations();
+        try {
+            return map.computeIfAbsent(
+                Pair.weak(k1, k2, queue),
+                pair -> mappingFunction.apply(pair.first(), pair.second()));
+        } finally {
+            Reference.reachabilityFence(k1);
+            Reference.reachabilityFence(k2);
+        }
+    }
+
+    /**
+     * Returns a {@link Collection} view of the values contained in this
+     * WeakPairMap. The collection is backed by the WeakPairMap, so changes to
+     * the map are reflected in the collection, and vice-versa.  The collection
+     * supports element removal, which removes the corresponding
+     * mapping from this map, via the {@code Iterator.remove},
+     * {@code Collection.remove}, {@code removeAll},
+     * {@code retainAll}, and {@code clear} operations.  It does not
+     * support the {@code add} or {@code addAll} operations.
+     *
+     * @return the collection view
+     */
+    public Collection<V> values() {
+        expungeStaleAssociations();
+        return map.values();
+    }
+
+    /**
+     * Removes associations from this WeakPairMap for which at least one of the
+     * keys in key pair has been found weakly-reachable and corresponding
+     * WeakRefPeer(s) enqueued. Called as part of each public operation.
+     */
+    private void expungeStaleAssociations() {
+        WeakRefPeer<?> peer;
+        while ((peer = (WeakRefPeer<?>) queue.poll()) != null) {
+            map.remove(peer.weakPair());
+        }
+    }
+
+    /**
+     * Common interface of both {@link Weak} and {@link Lookup} key pairs.
+     */
+    private interface Pair<K1, K2> {
+
+        static <K1, K2> Pair<K1, K2> weak(K1 k1, K2 k2,
+                                          ReferenceQueue<Object> queue) {
+            return new Weak<>(k1, k2, queue);
+        }
+
+        static <K1, K2> Pair<K1, K2> lookup(K1 k1, K2 k2) {
+            return new Lookup<>(k1, k2);
+        }
+
+        /**
+         * @return The 1st of the pair of keys (may be null for {@link Weak}
+         * when it gets cleared)
+         */
+        K1 first();
+
+        /**
+         * @return The 2nd of the pair of keys (may be null for {@link Weak}
+         * when it gets cleared)
+         */
+        K2 second();
+
+        static int hashCode(Object first, Object second) {
+            // assert first != null && second != null;
+            return System.identityHashCode(first) ^
+                   System.identityHashCode(second);
+        }
+
+        static boolean equals(Object first, Object second, Pair<?, ?> p) {
+            return first != null && second != null &&
+                   first == p.first() && second == p.second();
+        }
+
+        /**
+         * A Pair where both keys are weakly-referenced.
+         * It is composed of two instances of {@link WeakRefPeer}s:
+         * <pre>{@code
+         *
+         *     +-referent-> [K1]                +-referent-> [K2]
+         *     |                                |
+         *   +----------------+               +----------------+
+         *   | Pair.Weak <:   |-----peer----->| (anonymous) <: |
+         *   | WeakRefPeer,   |               | WeakRefPeer    |
+         *   | Pair           |<--weakPair()--|                |
+         *   +----------------+               +----------------+
+         *     |            ^
+         *     |            |
+         *     +-weakPair()-+
+         *
+         * }</pre>
+         * <p>
+         * Pair.Weak is used for CHM keys. Both peers are associated with the
+         * same {@link ReferenceQueue} so when either of their referents
+         * becomes weakly-reachable, the corresponding entries can be
+         * {@link #expungeStaleAssociations() expunged} from the map.
+         */
+        final class Weak<K1, K2> extends WeakRefPeer<K1> implements Pair<K1, K2> {
+
+            // saved hash so it can be retrieved after the reference is cleared
+            private final int hash;
+            // link to <K2> peer
+            private final WeakRefPeer<K2> peer;
+
+            Weak(K1 k1, K2 k2, ReferenceQueue<Object> queue) {
+                super(k1, queue);
+                hash = Pair.hashCode(k1, k2);
+                peer = new WeakRefPeer<>(k2, queue) {
+                    // link back to <K1> peer
+                    @Override
+                    Weak<?, ?> weakPair() { return Weak.this; }
+                };
+            }
+
+            @Override
+            Weak<?, ?> weakPair() {
+                return this;
+            }
+
+            @Override
+            public K1 first() {
+                return get();
+            }
+
+            @Override
+            public K2 second() {
+                return peer.get();
+            }
+
+            @Override
+            public int hashCode() {
+                return hash;
+            }
+
+            @Override
+            public boolean equals(Object obj) {
+                return this == obj ||
+                       (obj instanceof Pair &&
+                        Pair.equals(first(), second(), (Pair<?, ?>) obj));
+            }
+        }
+
+        /**
+         * Optimized lookup Pair, used as lookup key in methods like
+         * {@link java.util.Map#get(Object)} or
+         * {@link java.util.Map#containsKey(Object)}) where
+         * there is a great chance its allocation is eliminated
+         * by escape analysis when such lookups are inlined by JIT.
+         * All its methods are purposely designed so that 'this' is never
+         * passed to any other method or used as identity.
+         */
+        final class Lookup<K1, K2> implements Pair<K1, K2> {
+            private final K1 k1;
+            private final K2 k2;
+
+            Lookup(K1 k1, K2 k2) {
+                this.k1 = Objects.requireNonNull(k1);
+                this.k2 = Objects.requireNonNull(k2);
+            }
+
+            @Override
+            public K1 first() {
+                return k1;
+            }
+
+            @Override
+            public K2 second() {
+                return k2;
+            }
+
+            @Override
+            public int hashCode() {
+                return Pair.hashCode(k1, k2);
+            }
+
+            @Override
+            public boolean equals(Object obj) {
+                return obj instanceof Pair &&
+                       Pair.equals(k1, k2, (Pair<?, ?>) obj);
+            }
+        }
+    }
+
+    /**
+     * Common abstract supertype of a pair of WeakReference peers.
+     */
+    private static abstract class WeakRefPeer<K> extends WeakReference<K> {
+
+        WeakRefPeer(K k, ReferenceQueue<Object> queue) {
+            super(Objects.requireNonNull(k), queue);
+        }
+
+        /**
+         * @return the {@link Pair.Weak} side of the pair of peers.
+         */
+        abstract Pair.Weak<?, ?> weakPair();
+    }
+}
--- a/jdk/src/java.base/share/classes/java/lang/annotation/ElementType.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/jdk/src/java.base/share/classes/java/lang/annotation/ElementType.java	Tue Apr 18 22:25:33 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -28,7 +28,7 @@
 /**
  * The constants of this enumerated type provide a simple classification of the
  * syntactic locations where annotations may appear in a Java program. These
- * constants are used in {@link Target java.lang.annotation.Target}
+ * constants are used in {@link java.lang.annotation.Target Target}
  * meta-annotations to specify where it is legal to write annotations of a
  * given type.
  *
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/java.base/share/classes/java/lang/doc-files/threadPrimitiveDeprecation.html	Tue Apr 18 22:25:33 2017 +0200
@@ -0,0 +1,364 @@
+<!--
+ Copyright (c) 2005, 2017, Oracle and/or its affiliates. All rights reserved.
+ DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+
+ This code is free software; you can redistribute it and/or modify it
+ 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.
+-->
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
+<html lang="en">
+<head>
+  <title>Java Thread Primitive Deprecation</title>
+  <link rel="stylesheet" type="text/css" href="../../../stylesheet.css" title="Style">
+</head>
+<body>
+<h2>Java Thread Primitive Deprecation</h2>
+<hr size="3" noshade="noshade" />
+<h3>Why is <code>Thread.stop</code> deprecated?</h3>
+<p>Because it is inherently unsafe. Stopping a thread causes it to
+unlock all the monitors that it has locked. (The monitors are
+unlocked as the <code>ThreadDeath</code> exception propagates up
+the stack.) If any of the objects previously protected by these
+monitors were in an inconsistent state, other threads may now view
+these objects in an inconsistent state. Such objects are said to be
+<i>damaged</i>. When threads operate on damaged objects, arbitrary
+behavior can result. This behavior may be subtle and difficult to
+detect, or it may be pronounced. Unlike other unchecked exceptions,
+<code>ThreadDeath</code> kills threads silently; thus, the user has
+no warning that his program may be corrupted. The corruption can
+manifest itself at any time after the actual damage occurs, even
+hours or days in the future.</p>
+<hr />
+<h3>Couldn't I just catch the <code>ThreadDeath</code> exception
+and fix the damaged object?</h3>
+<p>In theory, perhaps, but it would <em>vastly</em> complicate the
+task of writing correct multithreaded code. The task would be
+nearly insurmountable for two reasons:</p>
+<ol>
+<li>A thread can throw a <code>ThreadDeath</code> exception
+<i>almost anywhere</i>. All synchronized methods and blocks would
+have to be studied in great detail, with this in mind.</li>
+<li>A thread can throw a second <code>ThreadDeath</code> exception
+while cleaning up from the first (in the <code>catch</code> or
+<code>finally</code> clause). Cleanup would have to be repeated till
+it succeeded. The code to ensure this would be quite complex.</li>
+</ol>
+In sum, it just isn't practical.
+<hr />
+<h3>What about <code>Thread.stop(Throwable)</code>?</h3>
+<p>In addition to all of the problems noted above, this method may
+be used to generate exceptions that its target thread is unprepared
+to handle (including checked exceptions that the thread could not
+possibly throw, were it not for this method). For example, the
+following method is behaviorally identical to Java's
+<code>throw</code> operation, but circumvents the compiler's
+attempts to guarantee that the calling method has declared all of
+the checked exceptions that it may throw:</p>
+<pre>
+    static void sneakyThrow(Throwable t) {
+        Thread.currentThread().stop(t);
+    }
+</pre>
+<hr />
+<h3>What should I use instead of <code>Thread.stop</code>?</h3>
+<p>Most uses of <code>stop</code> should be replaced by code that
+simply modifies some variable to indicate that the target thread
+should stop running. The target thread should check this variable
+regularly, and return from its run method in an orderly fashion if
+the variable indicates that it is to stop running. To ensure prompt
+communication of the stop-request, the variable must be
+<tt>volatile</tt> (or access to the variable must be
+synchronized).</p>
+<p>For example, suppose your applet contains the following
+<code>start</code>, <code>stop</code> and <code>run</code>
+methods:</p>
+<pre>
+    private Thread blinker;
+
+    public void start() {
+        blinker = new Thread(this);
+        blinker.start();
+    }
+
+    public void stop() {
+        blinker.stop();  // UNSAFE!
+    }
+
+    public void run() {
+        while (true) {
+            try {
+                Thread.sleep(interval);
+            } catch (InterruptedException e){
+            }
+            repaint();
+        }
+    }
+</pre>
+You can avoid the use of <code>Thread.stop</code> by replacing the
+applet's <code>stop</code> and <code>run</code> methods with:
+<pre>
+    private volatile Thread blinker;
+
+    public void stop() {
+        blinker = null;
+    }
+
+    public void run() {
+        Thread thisThread = Thread.currentThread();
+        while (blinker == thisThread) {
+            try {
+                Thread.sleep(interval);
+            } catch (InterruptedException e){
+            }
+            repaint();
+        }
+    }
+</pre>
+<hr />
+<h3>How do I stop a thread that waits for long periods (e.g., for
+input)?</h3>
+<p>That's what the <code>Thread.interrupt</code> method is for. The
+same "state based" signaling mechanism shown above can be used, but
+the state change (<code>blinker = null</code>, in the previous
+example) can be followed by a call to
+<code>Thread.interrupt</code>, to interrupt the wait:</p>
+<pre>
+    public void stop() {
+        Thread moribund = waiter;
+        waiter = null;
+        moribund.interrupt();
+    }
+</pre>
+For this technique to work, it's critical that any method that
+catches an interrupt exception and is not prepared to deal with it
+immediately reasserts the exception. We say <em>reasserts</em>
+rather than <em>rethrows</em>, because it is not always possible to
+rethrow the exception. If the method that catches the
+<code>InterruptedException</code> is not declared to throw this
+(checked) exception, then it should "reinterrupt itself" with the
+following incantation:
+<pre>
+    Thread.currentThread().interrupt();
+</pre>
+This ensures that the Thread will reraise the
+<code>InterruptedException</code> as soon as it is able.
+<hr />
+<h3>What if a thread doesn't respond to
+<code>Thread.interrupt</code>?</h3>
+<p>In some cases, you can use application specific tricks. For
+example, if a thread is waiting on a known socket, you can close
+the socket to cause the thread to return immediately.
+Unfortunately, there really isn't any technique that works in
+general. <em>It should be noted that in all situations where a
+waiting thread doesn't respond to <code>Thread.interrupt</code>, it
+wouldn't respond to <code>Thread.stop</code> either.</em> Such
+cases include deliberate denial-of-service attacks, and I/O
+operations for which thread.stop and thread.interrupt do not work
+properly.</p>
+<hr />
+<h3>Why are <code>Thread.suspend</code> and
+<code>Thread.resume</code> deprecated?</h3>
+<p><code>Thread.suspend</code> is inherently deadlock-prone. If the
+target thread holds a lock on the monitor protecting a critical
+system resource when it is suspended, no thread can access this
+resource until the target thread is resumed. If the thread that
+would resume the target thread attempts to lock this monitor prior
+to calling <code>resume</code>, deadlock results. Such deadlocks
+typically manifest themselves as "frozen" processes.</p>
+<hr />
+<h3>What should I use instead of <code>Thread.suspend</code> and
+<code>Thread.resume</code>?</h3>
+<p>As with <code>Thread.stop</code>, the prudent approach is to
+have the "target thread" poll a variable indicating the desired
+state of the thread (active or suspended). When the desired state
+is suspended, the thread waits using <code>Object.wait</code>. When
+the thread is resumed, the target thread is notified using
+<code>Object.notify</code>.</p>
+<p>For example, suppose your applet contains the following
+mousePressed event handler, which toggles the state of a thread
+called <code>blinker</code>:</p>
+<pre>
+    private boolean threadSuspended;
+
+    Public void mousePressed(MouseEvent e) {
+        e.consume();
+
+        if (threadSuspended)
+            blinker.resume();
+        else
+            blinker.suspend();  // DEADLOCK-PRONE!
+
+        threadSuspended = !threadSuspended;
+    }
+</pre>
+You can avoid the use of <code>Thread.suspend</code> and
+<code>Thread.resume</code> by replacing the event handler above
+with:
+<pre>
+    public synchronized void mousePressed(MouseEvent e) {
+        e.consume();
+
+        threadSuspended = !threadSuspended;
+
+        if (!threadSuspended)
+            notify();
+    }
+</pre>
+and adding the following code to the "run loop":
+<pre>
+                synchronized(this) {
+                    while (threadSuspended)
+                        wait();
+                }
+</pre>
+The <code>wait</code> method throws the
+<code>InterruptedException</code>, so it must be inside a <code>try
+... catch</code> clause. It's fine to put it in the same clause as
+the <code>sleep</code>. The check should follow (rather than
+precede) the <code>sleep</code> so the window is immediately
+repainted when the thread is "resumed." The resulting
+<code>run</code> method follows:
+<pre>
+    public void run() {
+        while (true) {
+            try {
+                Thread.sleep(interval);
+
+                synchronized(this) {
+                    while (threadSuspended)
+                        wait();
+                }
+            } catch (InterruptedException e){
+            }
+            repaint();
+        }
+    }
+</pre>
+Note that the <code>notify</code> in the <code>mousePressed</code>
+method and the <code>wait</code> in the <code>run</code> method are
+inside <code>synchronized</code> blocks. This is required by the
+language, and ensures that <code>wait</code> and
+<code>notify</code> are properly serialized. In practical terms,
+this eliminates race conditions that could cause the "suspended"
+thread to miss a <code>notify</code> and remain suspended
+indefinitely.
+<p>While the cost of synchronization in Java is decreasing as the
+platform matures, it will never be free. A simple trick can be used
+to remove the synchronization that we've added to each iteration of
+the "run loop." The synchronized block that was added is replaced
+by a slightly more complex piece of code that enters a synchronized
+block only if the thread has actually been suspended:</p>
+<pre>
+                if (threadSuspended) {
+                    synchronized(this) {
+                        while (threadSuspended)
+                            wait();
+                    }
+                }
+</pre>
+<p>In the absence of explicit synchronization,
+<tt>threadSuspended</tt> must be made <tt>volatile</tt> to ensure
+prompt communication of the suspend-request.</p>
+The resulting <code>run</code> method is:
+<pre>
+    private volatile boolean threadSuspended;
+
+    public void run() {
+        while (true) {
+            try {
+                Thread.sleep(interval);
+
+                if (threadSuspended) {
+                    synchronized(this) {
+                        while (threadSuspended)
+                            wait();
+                    }
+                }
+            } catch (InterruptedException e){
+            }
+            repaint();
+        }
+    }
+</pre>
+<hr size="3" noshade="noshade" />
+<h3>Can I combine the two techniques to produce a thread that may
+be safely "stopped" or "suspended"?</h3>
+Yes, it's reasonably straightforward. The one subtlety is that the
+target thread may already be suspended at the time that another
+thread tries to stop it. If the <tt>stop</tt> method merely sets
+the state variable (<tt>blinker</tt>) to null, the target thread
+will remain suspended (waiting on the monitor), rather than exiting
+gracefully as it should. If the applet is restarted, multiple
+threads could end up waiting on the monitor at the same time,
+resulting in erratic behavior.
+<p>To rectify this situation, the <tt>stop</tt> method must ensure
+that the target thread resumes immediately if it is suspended. Once
+the target thread resumes, it must recognize immediately that it
+has been stopped, and exit gracefully. Here's how the resulting
+<tt>run</tt> and <tt>stop</tt> methods look:</p>
+<pre>
+    public void run() {
+        Thread thisThread = Thread.currentThread();
+        while (blinker == thisThread) {
+            try {
+                Thread.sleep(interval);
+
+                synchronized(this) {
+                    while (threadSuspended &amp;&amp; blinker==thisThread)
+                        wait();
+                }
+            } catch (InterruptedException e){
+            }
+            repaint();
+        }
+    }
+
+    public synchronized void stop() {
+        blinker = null;
+        notify();
+    }
+</pre>
+If the <tt>stop</tt> method calls <tt>Thread.interrupt</tt>, as
+described above, it needn't call <tt>notify</tt> as well, but it
+still must be synchronized. This ensures that the target thread
+won't miss an interrupt due to a race condition.
+<hr />
+<h3>What about <code>Thread.destroy</code>?</h3>
+<code>Thread.destroy</code> was never implemented and has been
+deprecated. If it were implemented, it would be deadlock-prone in
+the manner of <code>Thread.suspend</code>. (In fact, it is roughly
+equivalent to <code>Thread.suspend</code> without the possibility
+of a subsequent <code>Thread.resume</code>.)
+<hr />
+<h3>Why is <code>Runtime.runFinalizersOnExit</code>
+deprecated?</h3>
+Because it is inherently unsafe. It may result in finalizers being
+called on live objects while other threads are concurrently
+manipulating those objects, resulting in erratic behavior or
+deadlock. While this problem could be prevented if the class whose
+objects are being finalized were coded to "defend against" this
+call, most programmers do <i>not</i> defend against it. They assume
+that an object is dead at the time that its finalizer is called.
+<p>Further, the call is not "thread-safe" in the sense that it sets
+a VM-global flag. This forces <i>every</i> class with a finalizer
+to defend against the finalization of live objects!</p>
+<p><!-- Body text ends here --></p>
+</body>
+</html>
--- a/jdk/src/java.base/share/classes/java/lang/invoke/BoundMethodHandle.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/jdk/src/java.base/share/classes/java/lang/invoke/BoundMethodHandle.java	Tue Apr 18 22:25:33 2017 +0200
@@ -450,32 +450,29 @@
      */
     static class Factory {
 
-        static final String JLO_SIG  = "Ljava/lang/Object;";
-        static final String JLS_SIG  = "Ljava/lang/String;";
-        static final String JLC_SIG  = "Ljava/lang/Class;";
-        static final String MH       = "java/lang/invoke/MethodHandle";
-        static final String MH_SIG   = "L"+MH+";";
-        static final String BMH      = "java/lang/invoke/BoundMethodHandle";
-        static final String BMH_SIG  = "L"+BMH+";";
-        static final String SPECIES_DATA     = "java/lang/invoke/BoundMethodHandle$SpeciesData";
-        static final String SPECIES_DATA_SIG = "L"+SPECIES_DATA+";";
-        static final String STABLE_SIG       = "Ljdk/internal/vm/annotation/Stable;";
+        private static final String JLO_SIG  = "Ljava/lang/Object;";
+        private static final String MH       = "java/lang/invoke/MethodHandle";
+        private static final String MH_SIG   = "L"+MH+";";
+        private static final String BMH      = "java/lang/invoke/BoundMethodHandle";
+        private static final String BMH_NAME = "java.lang.invoke.BoundMethodHandle";
+        private static final String BMH_SIG  = "L"+BMH+";";
+        private static final String SPECIES_DATA     = "java/lang/invoke/BoundMethodHandle$SpeciesData";
+        private static final String SPECIES_DATA_SIG = "L"+SPECIES_DATA+";";
+        private static final String STABLE_SIG       = "Ljdk/internal/vm/annotation/Stable;";
 
-        static final String SPECIES_PREFIX_NAME = "Species_";
-        static final String SPECIES_PREFIX_PATH = BMH + "$" + SPECIES_PREFIX_NAME;
-        static final String SPECIES_CLASS_PREFIX = SPECIES_PREFIX_PATH.replace('/', '.');
+        private static final String SPECIES_PREFIX_NAME = "Species_";
+        private static final String SPECIES_PREFIX_PATH = BMH + "$" + SPECIES_PREFIX_NAME;
+        private static final String SPECIES_CLASS_PREFIX = BMH_NAME + "$" + SPECIES_PREFIX_NAME;
 
-        static final String BMHSPECIES_DATA_EWI_SIG = "(B)" + SPECIES_DATA_SIG;
-        static final String BMHSPECIES_DATA_GFC_SIG = "(" + JLS_SIG + JLC_SIG + ")" + SPECIES_DATA_SIG;
-        static final String MYSPECIES_DATA_SIG = "()" + SPECIES_DATA_SIG;
-        static final String VOID_SIG   = "()V";
-        static final String INT_SIG    = "()I";
+        private static final String BMHSPECIES_DATA_EWI_SIG = "(B)" + SPECIES_DATA_SIG;
+        private static final String MYSPECIES_DATA_SIG = "()" + SPECIES_DATA_SIG;
+        private static final String INT_SIG    = "()I";
 
-        static final String SIG_INCIPIT = "(Ljava/lang/invoke/MethodType;Ljava/lang/invoke/LambdaForm;";
+        private static final String SIG_INCIPIT = "(Ljava/lang/invoke/MethodType;Ljava/lang/invoke/LambdaForm;";
 
-        static final String[] E_THROWABLE = new String[] { "java/lang/Throwable" };
+        private static final String[] E_THROWABLE = new String[] { "java/lang/Throwable" };
 
-        static final ConcurrentMap<String, Class<? extends BoundMethodHandle>> CLASS_CACHE = new ConcurrentHashMap<>();
+        private static final ConcurrentMap<String, Class<? extends BoundMethodHandle>> CLASS_CACHE = new ConcurrentHashMap<>();
 
         /**
          * Get a concrete subclass of BMH for a given combination of bound types.
@@ -830,15 +827,27 @@
 
         private static String makeSignature(String types, boolean ctor) {
             StringBuilder buf = new StringBuilder(SIG_INCIPIT);
-            for (char c : types.toCharArray()) {
-                buf.append(typeSig(c));
+            int len = types.length();
+            for (int i = 0; i < len; i++) {
+                buf.append(typeSig(types.charAt(i)));
             }
             return buf.append(')').append(ctor ? "V" : BMH_SIG).toString();
         }
 
+        private static MethodType makeConstructorType(String types) {
+            int length = types.length();
+            Class<?> ptypes[] = new Class<?>[length + 2];
+            ptypes[0] = MethodType.class;
+            ptypes[1] = LambdaForm.class;
+            for (int i = 0; i < length; i++) {
+                ptypes[i + 2] = BasicType.basicType(types.charAt(i)).basicTypeClass();
+            }
+            return MethodType.makeImpl(BoundMethodHandle.class, ptypes, true);
+        }
+
         static MethodHandle makeCbmhCtor(Class<? extends BoundMethodHandle> cbmh, String types) {
             try {
-                return LOOKUP.findStatic(cbmh, "make", MethodType.fromDescriptor(makeSignature(types, false), null));
+                return LOOKUP.findStatic(cbmh, "make", makeConstructorType(types));
             } catch (NoSuchMethodException | IllegalAccessException | IllegalArgumentException | TypeNotPresentException e) {
                 throw newInternalError(e);
             }
--- a/jdk/src/java.base/share/classes/java/lang/invoke/DirectMethodHandle.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/jdk/src/java.base/share/classes/java/lang/invoke/DirectMethodHandle.java	Tue Apr 18 22:25:33 2017 +0200
@@ -224,12 +224,12 @@
         assert(names.length == nameCursor);
         if (doesAlloc) {
             // names = { argx,y,z,... new C, init method }
-            names[NEW_OBJ] = new Name(NF_allocateInstance, names[DMH_THIS]);
-            names[GET_MEMBER] = new Name(NF_constructorMethod, names[DMH_THIS]);
+            names[NEW_OBJ] = new Name(getFunction(NF_allocateInstance), names[DMH_THIS]);
+            names[GET_MEMBER] = new Name(getFunction(NF_constructorMethod), names[DMH_THIS]);
         } else if (needsInit) {
-            names[GET_MEMBER] = new Name(NF_internalMemberNameEnsureInit, names[DMH_THIS]);
+            names[GET_MEMBER] = new Name(getFunction(NF_internalMemberNameEnsureInit), names[DMH_THIS]);
         } else {
-            names[GET_MEMBER] = new Name(NF_internalMemberName, names[DMH_THIS]);
+            names[GET_MEMBER] = new Name(getFunction(NF_internalMemberName), names[DMH_THIS]);
         }
         assert(findDirectMethodHandle(names[GET_MEMBER]) == names[DMH_THIS]);
         Object[] outArgs = Arrays.copyOfRange(names, ARG_BASE, GET_MEMBER+1, Object[].class);
@@ -249,10 +249,10 @@
         return lform;
     }
 
-    static Object findDirectMethodHandle(Name name) {
-        if (name.function == NF_internalMemberName ||
-            name.function == NF_internalMemberNameEnsureInit ||
-            name.function == NF_constructorMethod) {
+    /* assert */ static Object findDirectMethodHandle(Name name) {
+        if (name.function.equals(getFunction(NF_internalMemberName)) ||
+            name.function.equals(getFunction(NF_internalMemberNameEnsureInit)) ||
+            name.function.equals(getFunction(NF_constructorMethod))) {
             assert(name.arguments.length == 1);
             return name.arguments[0];
         }
@@ -674,18 +674,18 @@
         final int RESULT    = nameCursor-1;  // either the call or the cast
         Name[] names = arguments(nameCursor - ARG_LIMIT, mtype.invokerType());
         if (needsInit)
-            names[INIT_BAR] = new Name(NF_ensureInitialized, names[DMH_THIS]);
+            names[INIT_BAR] = new Name(getFunction(NF_ensureInitialized), names[DMH_THIS]);
         if (needsCast && !isGetter)
-            names[PRE_CAST] = new Name(NF_checkCast, names[DMH_THIS], names[SET_VALUE]);
+            names[PRE_CAST] = new Name(getFunction(NF_checkCast), names[DMH_THIS], names[SET_VALUE]);
         Object[] outArgs = new Object[1 + linkerType.parameterCount()];
         assert(outArgs.length == (isGetter ? 3 : 4));
-        outArgs[0] = names[U_HOLDER] = new Name(NF_UNSAFE);
+        outArgs[0] = names[U_HOLDER] = new Name(getFunction(NF_UNSAFE));
         if (isStatic) {
-            outArgs[1] = names[F_HOLDER]  = new Name(NF_staticBase, names[DMH_THIS]);
-            outArgs[2] = names[F_OFFSET]  = new Name(NF_staticOffset, names[DMH_THIS]);
+            outArgs[1] = names[F_HOLDER]  = new Name(getFunction(NF_staticBase), names[DMH_THIS]);
+            outArgs[2] = names[F_OFFSET]  = new Name(getFunction(NF_staticOffset), names[DMH_THIS]);
         } else {
-            outArgs[1] = names[OBJ_CHECK] = new Name(NF_checkBase, names[OBJ_BASE]);
-            outArgs[2] = names[F_OFFSET]  = new Name(NF_fieldOffset, names[DMH_THIS]);
+            outArgs[1] = names[OBJ_CHECK] = new Name(getFunction(NF_checkBase), names[OBJ_BASE]);
+            outArgs[2] = names[F_OFFSET]  = new Name(getFunction(NF_fieldOffset), names[DMH_THIS]);
         }
         if (!isGetter) {
             outArgs[3] = (needsCast ? names[PRE_CAST] : names[SET_VALUE]);
@@ -693,7 +693,7 @@
         for (Object a : outArgs)  assert(a != null);
         names[LINKER_CALL] = new Name(linker, outArgs);
         if (needsCast && isGetter)
-            names[POST_CAST] = new Name(NF_checkCast, names[DMH_THIS], names[LINKER_CALL]);
+            names[POST_CAST] = new Name(getFunction(NF_checkCast), names[DMH_THIS], names[LINKER_CALL]);
         for (Name n : names)  assert(n != null);
 
         LambdaForm form;
@@ -726,48 +726,72 @@
 
     /**
      * Pre-initialized NamedFunctions for bootstrapping purposes.
-     * Factored in an inner class to delay initialization until first usage.
      */
-    static final NamedFunction
-            NF_internalMemberName,
-            NF_internalMemberNameEnsureInit,
-            NF_ensureInitialized,
-            NF_fieldOffset,
-            NF_checkBase,
-            NF_staticBase,
-            NF_staticOffset,
-            NF_checkCast,
-            NF_allocateInstance,
-            NF_constructorMethod,
-            NF_UNSAFE;
-    static {
+    static final byte NF_internalMemberName = 0,
+            NF_internalMemberNameEnsureInit = 1,
+            NF_ensureInitialized = 2,
+            NF_fieldOffset = 3,
+            NF_checkBase = 4,
+            NF_staticBase = 5,
+            NF_staticOffset = 6,
+            NF_checkCast = 7,
+            NF_allocateInstance = 8,
+            NF_constructorMethod = 9,
+            NF_UNSAFE = 10,
+            NF_LIMIT = 11;
+
+    private static final @Stable NamedFunction[] NFS = new NamedFunction[NF_LIMIT];
+
+    private static NamedFunction getFunction(byte func) {
+        NamedFunction nf = NFS[func];
+        if (nf != null) {
+            return nf;
+        }
+        // Each nf must be statically invocable or we get tied up in our bootstraps.
+        nf = NFS[func] = createFunction(func);
+        assert(InvokerBytecodeGenerator.isStaticallyInvocable(nf));
+        return nf;
+    }
+
+    private static NamedFunction createFunction(byte func) {
         try {
-            NamedFunction nfs[] = {
-                    NF_internalMemberName = new NamedFunction(DirectMethodHandle.class
-                            .getDeclaredMethod("internalMemberName", Object.class)),
-                    NF_internalMemberNameEnsureInit = new NamedFunction(DirectMethodHandle.class
-                            .getDeclaredMethod("internalMemberNameEnsureInit", Object.class)),
-                    NF_ensureInitialized = new NamedFunction(DirectMethodHandle.class
-                            .getDeclaredMethod("ensureInitialized", Object.class)),
-                    NF_fieldOffset = new NamedFunction(DirectMethodHandle.class
-                            .getDeclaredMethod("fieldOffset", Object.class)),
-                    NF_checkBase = new NamedFunction(DirectMethodHandle.class
-                            .getDeclaredMethod("checkBase", Object.class)),
-                    NF_staticBase = new NamedFunction(DirectMethodHandle.class
-                            .getDeclaredMethod("staticBase", Object.class)),
-                    NF_staticOffset = new NamedFunction(DirectMethodHandle.class
-                            .getDeclaredMethod("staticOffset", Object.class)),
-                    NF_checkCast = new NamedFunction(DirectMethodHandle.class
-                            .getDeclaredMethod("checkCast", Object.class, Object.class)),
-                    NF_allocateInstance = new NamedFunction(DirectMethodHandle.class
-                            .getDeclaredMethod("allocateInstance", Object.class)),
-                    NF_constructorMethod = new NamedFunction(DirectMethodHandle.class
-                            .getDeclaredMethod("constructorMethod", Object.class)),
-                    NF_UNSAFE = new NamedFunction(new MemberName(MethodHandleStatics.class
-                            .getDeclaredField("UNSAFE")))
-            };
-            // Each nf must be statically invocable or we get tied up in our bootstraps.
-            assert(InvokerBytecodeGenerator.isStaticallyInvocable(nfs));
+            switch (func) {
+                case NF_internalMemberName:
+                    return new NamedFunction(DirectMethodHandle.class
+                            .getDeclaredMethod("internalMemberName", Object.class));
+                case NF_internalMemberNameEnsureInit:
+                    return new NamedFunction(DirectMethodHandle.class
+                            .getDeclaredMethod("internalMemberNameEnsureInit", Object.class));
+                case NF_ensureInitialized:
+                    return new NamedFunction(DirectMethodHandle.class
+                            .getDeclaredMethod("ensureInitialized", Object.class));
+                case NF_fieldOffset:
+                    return new NamedFunction(DirectMethodHandle.class
+                            .getDeclaredMethod("fieldOffset", Object.class));
+                case NF_checkBase:
+                    return new NamedFunction(DirectMethodHandle.class
+                            .getDeclaredMethod("checkBase", Object.class));
+                case NF_staticBase:
+                    return new NamedFunction(DirectMethodHandle.class
+                            .getDeclaredMethod("staticBase", Object.class));
+                case NF_staticOffset:
+                    return new NamedFunction(DirectMethodHandle.class
+                            .getDeclaredMethod("staticOffset", Object.class));
+                case NF_checkCast:
+                    return new NamedFunction(DirectMethodHandle.class
+                            .getDeclaredMethod("checkCast", Object.class, Object.class));
+                case NF_allocateInstance:
+                    return new NamedFunction(DirectMethodHandle.class
+                            .getDeclaredMethod("allocateInstance", Object.class));
+                case NF_constructorMethod:
+                    return new NamedFunction(DirectMethodHandle.class
+                            .getDeclaredMethod("constructorMethod", Object.class));
+                case NF_UNSAFE:
+                    return new NamedFunction(new MemberName(MethodHandleStatics.class
+                            .getDeclaredField("UNSAFE")));
+                default:
+                    throw newInternalError("Unknown function: " + func);
+            }
         } catch (ReflectiveOperationException ex) {
             throw newInternalError(ex);
         }
--- a/jdk/src/java.base/share/classes/java/lang/invoke/InvokerBytecodeGenerator.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/jdk/src/java.base/share/classes/java/lang/invoke/InvokerBytecodeGenerator.java	Tue Apr 18 22:25:33 2017 +0200
@@ -73,6 +73,7 @@
     private static final String LL_SIG  = "(L" + OBJ + ";)L" + OBJ + ";";
     private static final String LLV_SIG = "(L" + OBJ + ";L" + OBJ + ";)V";
     private static final String CLASS_PREFIX = LF + "$";
+    private static final String SOURCE_PREFIX = "LambdaForm$";
 
     /** Name of its super class*/
     static final String INVOKER_SUPER_NAME = OBJ;
@@ -80,9 +81,6 @@
     /** Name of new class */
     private final String className;
 
-    /** Name of the source file (for stack trace printing). */
-    private final String sourceFile;
-
     private final LambdaForm lambdaForm;
     private final String     invokerName;
     private final MethodType invokerType;
@@ -109,8 +107,7 @@
         if (DUMP_CLASS_FILES) {
             className = makeDumpableClassName(className);
         }
-        this.className  = CLASS_PREFIX + className;
-        this.sourceFile = "LambdaForm$" + className;
+        this.className  = className;
         this.lambdaForm = lambdaForm;
         this.invokerName = invokerName;
         this.invokerType = invokerType;
@@ -173,6 +170,13 @@
         }
     }
 
+    private void maybeDump(final byte[] classFile) {
+        if (DUMP_CLASS_FILES) {
+            maybeDump(CLASS_PREFIX + className, classFile);
+        }
+    }
+
+    // Also used from BoundMethodHandle
     static void maybeDump(final String className, final byte[] classFile) {
         if (DUMP_CLASS_FILES) {
             java.security.AccessController.doPrivileged(
@@ -306,8 +310,9 @@
     private ClassWriter classFilePrologue() {
         final int NOT_ACC_PUBLIC = 0;  // not ACC_PUBLIC
         cw = new ClassWriter(ClassWriter.COMPUTE_MAXS + ClassWriter.COMPUTE_FRAMES);
-        cw.visit(Opcodes.V1_8, NOT_ACC_PUBLIC + Opcodes.ACC_FINAL + Opcodes.ACC_SUPER, className, null, INVOKER_SUPER_NAME, null);
-        cw.visitSource(sourceFile, null);
+        cw.visit(Opcodes.V1_8, NOT_ACC_PUBLIC + Opcodes.ACC_FINAL + Opcodes.ACC_SUPER,
+                CLASS_PREFIX + className, null, INVOKER_SUPER_NAME, null);
+        cw.visitSource(SOURCE_PREFIX + className, null);
         return cw;
     }
 
@@ -617,12 +622,11 @@
         return resolvedMember;
     }
 
-    private static MemberName lookupPregenerated(LambdaForm form) {
+    private static MemberName lookupPregenerated(LambdaForm form, MethodType invokerType) {
         if (form.customized != null) {
             // No pre-generated version for customized LF
             return null;
         }
-        MethodType invokerType = form.methodType();
         String name = form.kind.methodName;
         switch (form.kind) {
             case BOUND_REINVOKER: {
@@ -670,7 +674,7 @@
      * Generate customized bytecode for a given LambdaForm.
      */
     static MemberName generateCustomizedCode(LambdaForm form, MethodType invokerType) {
-        MemberName pregenerated = lookupPregenerated(form);
+        MemberName pregenerated = lookupPregenerated(form, invokerType);
         if (pregenerated != null)  return pregenerated; // pre-generated bytecode
 
         InvokerBytecodeGenerator g = new InvokerBytecodeGenerator("MH", form, invokerType);
@@ -720,7 +724,7 @@
         bogusMethod(lambdaForm);
 
         final byte[] classFile = toByteArray();
-        maybeDump(className, classFile);
+        maybeDump(classFile);
         return classFile;
     }
 
@@ -908,7 +912,7 @@
         //MethodHandle.class already covered
     };
 
-    static boolean isStaticallyInvocable(NamedFunction[] functions) {
+    static boolean isStaticallyInvocable(NamedFunction ... functions) {
         for (NamedFunction nf : functions) {
             if (!isStaticallyInvocable(nf.member())) {
                 return false;
@@ -1761,7 +1765,7 @@
         bogusMethod(invokerType);
 
         final byte[] classFile = cw.toByteArray();
-        maybeDump(className, classFile);
+        maybeDump(classFile);
         return classFile;
     }
 
@@ -1829,7 +1833,7 @@
         bogusMethod(dstType);
 
         final byte[] classFile = cw.toByteArray();
-        maybeDump(className, classFile);
+        maybeDump(classFile);
         return classFile;
     }
 
--- a/jdk/src/java.base/share/classes/java/lang/invoke/Invokers.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/jdk/src/java.base/share/classes/java/lang/invoke/Invokers.java	Tue Apr 18 22:25:33 2017 +0200
@@ -313,15 +313,15 @@
         Object[] outArgs = Arrays.copyOfRange(names, CALL_MH, OUTARG_LIMIT, Object[].class);
         Object mtypeArg = (customized ? mtype : names[MTYPE_ARG]);
         if (!isGeneric) {
-            names[CHECK_TYPE] = new Name(NF_checkExactType, names[CALL_MH], mtypeArg);
+            names[CHECK_TYPE] = new Name(getFunction(NF_checkExactType), names[CALL_MH], mtypeArg);
             // mh.invokeExact(a*):R => checkExactType(mh, TYPEOF(a*:R)); mh.invokeBasic(a*)
         } else {
-            names[CHECK_TYPE] = new Name(NF_checkGenericType, names[CALL_MH], mtypeArg);
+            names[CHECK_TYPE] = new Name(getFunction(NF_checkGenericType), names[CALL_MH], mtypeArg);
             // mh.invokeGeneric(a*):R => checkGenericType(mh, TYPEOF(a*:R)).invokeBasic(a*)
             outArgs[0] = names[CHECK_TYPE];
         }
         if (CHECK_CUSTOM != -1) {
-            names[CHECK_CUSTOM] = new Name(NF_checkCustomized, outArgs[0]);
+            names[CHECK_CUSTOM] = new Name(getFunction(NF_checkCustomized), outArgs[0]);
         }
         names[LINKER_CALL] = new Name(outCallType, outArgs);
         if (customized) {
@@ -368,7 +368,7 @@
         }
         names[VAD_ARG] = new Name(ARG_LIMIT, BasicType.basicType(Object.class));
 
-        names[CHECK_TYPE] = new Name(NF_checkVarHandleGenericType, names[THIS_VH], names[VAD_ARG]);
+        names[CHECK_TYPE] = new Name(getFunction(NF_checkVarHandleGenericType), names[THIS_VH], names[VAD_ARG]);
 
         Object[] outArgs = new Object[ARG_LIMIT + 1];
         outArgs[0] = names[CHECK_TYPE];
@@ -377,7 +377,7 @@
         }
 
         if (CHECK_CUSTOM != -1) {
-            names[CHECK_CUSTOM] = new Name(NF_checkCustomized, outArgs[0]);
+            names[CHECK_CUSTOM] = new Name(getFunction(NF_checkCustomized), outArgs[0]);
         }
 
         MethodType outCallType = mtype.insertParameterTypes(0, VarHandle.class)
@@ -420,9 +420,9 @@
         names[VAD_ARG] = new Name(getter, names[THIS_MH]);
 
         if (isExact) {
-            names[CHECK_TYPE] = new Name(NF_checkVarHandleExactType, names[CALL_VH], names[VAD_ARG]);
+            names[CHECK_TYPE] = new Name(getFunction(NF_checkVarHandleExactType), names[CALL_VH], names[VAD_ARG]);
         } else {
-            names[CHECK_TYPE] = new Name(NF_checkVarHandleGenericType, names[CALL_VH], names[VAD_ARG]);
+            names[CHECK_TYPE] = new Name(getFunction(NF_checkVarHandleGenericType), names[CALL_VH], names[VAD_ARG]);
         }
         Object[] outArgs = new Object[ARG_LIMIT];
         outArgs[0] = names[CHECK_TYPE];
@@ -543,7 +543,7 @@
         assert(names.length == nameCursor);
         assert(names[APPENDIX_ARG] != null);
         if (!skipCallSite)
-            names[CALL_MH] = new Name(NF_getCallSiteTarget, names[CSITE_ARG]);
+            names[CALL_MH] = new Name(getFunction(NF_getCallSiteTarget), names[CSITE_ARG]);
         // (site.)invokedynamic(a*):R => mh = site.getTarget(); mh.invokeBasic(a*)
         final int PREPEND_MH = 0, PREPEND_COUNT = 1;
         Object[] outArgs = Arrays.copyOfRange(names, ARG_BASE, OUTARG_LIMIT + PREPEND_COUNT, Object[].class);
@@ -586,31 +586,51 @@
     }
 
     // Local constant functions:
-    private static final NamedFunction
-        NF_checkExactType,
-        NF_checkGenericType,
-        NF_getCallSiteTarget,
-        NF_checkCustomized,
-        NF_checkVarHandleGenericType,
-        NF_checkVarHandleExactType;
-    static {
+    private static final byte NF_checkExactType = 0,
+        NF_checkGenericType = 1,
+        NF_getCallSiteTarget = 2,
+        NF_checkCustomized = 3,
+        NF_checkVarHandleGenericType = 4,
+        NF_checkVarHandleExactType = 5,
+        NF_LIMIT = 6;
+
+    private static final @Stable NamedFunction[] NFS = new NamedFunction[NF_LIMIT];
+
+    private static NamedFunction getFunction(byte func) {
+        NamedFunction nf = NFS[func];
+        if (nf != null) {
+            return nf;
+        }
+        NFS[func] = nf = createFunction(func);
+        // Each nf must be statically invocable or we get tied up in our bootstraps.
+        assert(InvokerBytecodeGenerator.isStaticallyInvocable(nf));
+        return nf;
+    }
+
+    private static NamedFunction createFunction(byte func) {
         try {
-            NamedFunction nfs[] = {
-                NF_checkExactType = new NamedFunction(Invokers.class
-                        .getDeclaredMethod("checkExactType", MethodHandle.class,  MethodType.class)),
-                NF_checkGenericType = new NamedFunction(Invokers.class
-                        .getDeclaredMethod("checkGenericType", MethodHandle.class,  MethodType.class)),
-                NF_getCallSiteTarget = new NamedFunction(Invokers.class
-                        .getDeclaredMethod("getCallSiteTarget", CallSite.class)),
-                NF_checkCustomized = new NamedFunction(Invokers.class
-                        .getDeclaredMethod("checkCustomized", MethodHandle.class)),
-                NF_checkVarHandleGenericType = new NamedFunction(Invokers.class
-                        .getDeclaredMethod("checkVarHandleGenericType", VarHandle.class, VarHandle.AccessDescriptor.class)),
-                NF_checkVarHandleExactType = new NamedFunction(Invokers.class
-                        .getDeclaredMethod("checkVarHandleExactType", VarHandle.class, VarHandle.AccessDescriptor.class)),
-            };
-            // Each nf must be statically invocable or we get tied up in our bootstraps.
-            assert(InvokerBytecodeGenerator.isStaticallyInvocable(nfs));
+            switch (func) {
+                case NF_checkExactType:
+                    return new NamedFunction(Invokers.class
+                        .getDeclaredMethod("checkExactType", MethodHandle.class,  MethodType.class));
+                case NF_checkGenericType:
+                    return new NamedFunction(Invokers.class
+                        .getDeclaredMethod("checkGenericType", MethodHandle.class,  MethodType.class));
+                case NF_getCallSiteTarget:
+                    return new NamedFunction(Invokers.class
+                        .getDeclaredMethod("getCallSiteTarget", CallSite.class));
+                case NF_checkCustomized:
+                    return new NamedFunction(Invokers.class
+                        .getDeclaredMethod("checkCustomized", MethodHandle.class));
+                case NF_checkVarHandleGenericType:
+                    return new NamedFunction(Invokers.class
+                        .getDeclaredMethod("checkVarHandleGenericType", VarHandle.class, VarHandle.AccessDescriptor.class));
+                case NF_checkVarHandleExactType:
+                    return new NamedFunction(Invokers.class
+                        .getDeclaredMethod("checkVarHandleExactType", VarHandle.class, VarHandle.AccessDescriptor.class));
+                default:
+                    throw newInternalError("Unknown function: " + func);
+            }
         } catch (ReflectiveOperationException ex) {
             throw newInternalError(ex);
         }
--- a/jdk/src/java.base/share/classes/java/lang/invoke/LambdaForm.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/jdk/src/java.base/share/classes/java/lang/invoke/LambdaForm.java	Tue Apr 18 22:25:33 2017 +0200
@@ -270,21 +270,21 @@
         GENERIC("invoke"),
         ZERO("zero"),
         IDENTITY("identity"),
-        BOUND_REINVOKER("BMH.reinvoke"),
-        REINVOKER("MH.reinvoke"),
-        DELEGATE("MH.delegate"),
-        EXACT_LINKER("MH.invokeExact_MT"),
-        EXACT_INVOKER("MH.exactInvoker"),
-        GENERIC_LINKER("MH.invoke_MT"),
-        GENERIC_INVOKER("MH.invoker"),
+        BOUND_REINVOKER("BMH.reinvoke", "reinvoke"),
+        REINVOKER("MH.reinvoke", "reinvoke"),
+        DELEGATE("MH.delegate", "delegate"),
+        EXACT_LINKER("MH.invokeExact_MT", "invokeExact_MT"),
+        EXACT_INVOKER("MH.exactInvoker", "exactInvoker"),
+        GENERIC_LINKER("MH.invoke_MT", "invoke_MT"),
+        GENERIC_INVOKER("MH.invoker", "invoker"),
         LINK_TO_TARGET_METHOD("linkToTargetMethod"),
         LINK_TO_CALL_SITE("linkToCallSite"),
-        DIRECT_INVOKE_VIRTUAL("DMH.invokeVirtual"),
-        DIRECT_INVOKE_SPECIAL("DMH.invokeSpecial"),
-        DIRECT_INVOKE_STATIC("DMH.invokeStatic"),
-        DIRECT_NEW_INVOKE_SPECIAL("DMH.newInvokeSpecial"),
-        DIRECT_INVOKE_INTERFACE("DMH.invokeInterface"),
-        DIRECT_INVOKE_STATIC_INIT("DMH.invokeStaticInit"),
+        DIRECT_INVOKE_VIRTUAL("DMH.invokeVirtual", "invokeVirtual"),
+        DIRECT_INVOKE_SPECIAL("DMH.invokeSpecial", "invokeSpecial"),
+        DIRECT_INVOKE_STATIC("DMH.invokeStatic", "invokeStatic"),
+        DIRECT_NEW_INVOKE_SPECIAL("DMH.newInvokeSpecial", "newInvokeSpecial"),
+        DIRECT_INVOKE_INTERFACE("DMH.invokeInterface", "invokeInterface"),
+        DIRECT_INVOKE_STATIC_INIT("DMH.invokeStaticInit", "invokeStaticInit"),
         GET_OBJECT("getObject"),
         PUT_OBJECT("putObject"),
         GET_OBJECT_VOLATILE("getObjectVolatile"),
@@ -330,20 +330,19 @@
         GUARD("guard"),
         GUARD_WITH_CATCH("guardWithCatch"),
         VARHANDLE_EXACT_INVOKER("VH.exactInvoker"),
-        VARHANDLE_INVOKER("VH.invoker"),
-        VARHANDLE_LINKER("VH.invoke_MT");
+        VARHANDLE_INVOKER("VH.invoker", "invoker"),
+        VARHANDLE_LINKER("VH.invoke_MT", "invoke_MT");
 
         final String defaultLambdaName;
         final String methodName;
 
         private Kind(String defaultLambdaName) {
+            this(defaultLambdaName, defaultLambdaName);
+        }
+
+        private Kind(String defaultLambdaName, String methodName) {
             this.defaultLambdaName = defaultLambdaName;
-            int p = defaultLambdaName.indexOf('.');
-            if (p > -1) {
-                this.methodName = defaultLambdaName.substring(p + 1);
-            } else {
-                this.methodName = defaultLambdaName;
-            }
+            this.methodName = methodName;
         }
     }
 
@@ -642,7 +641,7 @@
         for (int i = 0; i < arity; ++i) {
             ptypes[i] = parameterType(i).btClass;
         }
-        return MethodType.methodType(returnType().btClass, ptypes);
+        return MethodType.makeImpl(returnType().btClass, ptypes, true);
     }
 
     /** Return ABC_Z, where the ABC are parameter type characters, and Z is the return type character. */
@@ -678,7 +677,7 @@
         for (int i = 0; i < ptypes.length; i++)
             ptypes[i] = basicType(sig.charAt(i)).btClass;
         Class<?> rtype = signatureReturn(sig).btClass;
-        return MethodType.methodType(rtype, ptypes);
+        return MethodType.makeImpl(rtype, ptypes, true);
     }
 
     /**
@@ -848,6 +847,10 @@
         if (vmentry != null && isCompiled) {
             return;  // already compiled somehow
         }
+
+        // Obtain the invoker MethodType outside of the following try block.
+        // This ensures that an IllegalArgumentException is directly thrown if the
+        // type would have 256 or more parameters
         MethodType invokerType = methodType();
         assert(vmentry == null || vmentry.getMethodType().basicType().equals(invokerType));
         try {
@@ -902,10 +905,6 @@
         }
         return true;
     }
-    private static boolean returnTypesMatch(String sig, Object[] av, Object res) {
-        MethodHandle mh = (MethodHandle) av[0];
-        return valueMatches(signatureReturn(sig), mh.type().returnType(), res);
-    }
     private static boolean checkInt(Class<?> type, Object x) {
         assert(x instanceof Integer);
         if (type == int.class)  return true;
@@ -1180,7 +1179,6 @@
             // If we have a cached invoker, call it right away.
             // NOTE: The invoker always returns a reference value.
             if (TRACE_INTERPRETER)  return invokeWithArgumentsTracing(arguments);
-            assert(checkArgumentTypes(arguments, methodType()));
             return invoker().invokeBasic(resolvedHandle(), arguments);
         }
 
@@ -1198,7 +1196,6 @@
                     traceInterpreter("| resolve", this);
                     resolvedHandle();
                 }
-                assert(checkArgumentTypes(arguments, methodType()));
                 rval = invoker().invokeBasic(resolvedHandle(), arguments);
             } catch (Throwable ex) {
                 traceInterpreter("] throw =>", ex);
@@ -1214,23 +1211,6 @@
             return invoker = computeInvoker(methodType().form());
         }
 
-        private static boolean checkArgumentTypes(Object[] arguments, MethodType methodType) {
-            if (true)  return true;  // FIXME
-            MethodType dstType = methodType.form().erasedType();
-            MethodType srcType = dstType.basicType().wrap();
-            Class<?>[] ptypes = new Class<?>[arguments.length];
-            for (int i = 0; i < arguments.length; i++) {
-                Object arg = arguments[i];
-                Class<?> ptype = arg == null ? Object.class : arg.getClass();
-                // If the dest. type is a primitive we keep the
-                // argument type.
-                ptypes[i] = dstType.parameterType(i).isPrimitive() ? ptype : Object.class;
-            }
-            MethodType argType = MethodType.methodType(srcType.returnType(), ptypes).wrap();
-            assert(argType.isConvertibleTo(srcType)) : "wrong argument types: cannot convert " + argType + " to " + srcType;
-            return true;
-        }
-
         MethodType methodType() {
             if (resolvedHandle != null)
                 return resolvedHandle.type();
@@ -1726,7 +1706,7 @@
         boolean isVoid = (type == V_TYPE);
         Class<?> btClass = type.btClass;
         MethodType zeType = MethodType.methodType(btClass);
-        MethodType idType = (isVoid) ? zeType : zeType.appendParameterTypes(btClass);
+        MethodType idType = (isVoid) ? zeType : MethodType.methodType(btClass, btClass);
 
         // Look up symbolic names.  It might not be necessary to have these,
         // but if we need to emit direct references to bytecodes, it helps.
--- a/jdk/src/java.base/share/classes/java/lang/invoke/LambdaFormEditor.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/jdk/src/java.base/share/classes/java/lang/invoke/LambdaFormEditor.java	Tue Apr 18 22:25:33 2017 +0200
@@ -532,7 +532,8 @@
         assert(pos > 0);  // cannot spread the MH arg itself
 
         Name spreadParam = new Name(L_TYPE);
-        Name checkSpread = new Name(MethodHandleImpl.NF_checkSpreadArgument, spreadParam, arrayLength);
+        Name checkSpread = new Name(MethodHandleImpl.getFunction(MethodHandleImpl.NF_checkSpreadArgument),
+                spreadParam, arrayLength);
 
         // insert the new expressions
         int exprPos = lambdaForm.arity();
@@ -932,14 +933,14 @@
 
         // replace the null entry in the MHImpl.loop invocation with localTypes
         Name invokeLoop = lambdaForm.names[pos + 1];
-        assert(invokeLoop.function == NF_loop);
+        assert(invokeLoop.function.equals(MethodHandleImpl.getFunction(NF_loop)));
         Object[] args = Arrays.copyOf(invokeLoop.arguments, invokeLoop.arguments.length);
         assert(args[0] == null);
         args[0] = localTypes;
 
         LambdaFormBuffer buf = buffer();
         buf.startEdit();
-        buf.changeName(pos + 1, new Name(NF_loop, args));
+        buf.changeName(pos + 1, new Name(MethodHandleImpl.getFunction(NF_loop), args));
         form = buf.endEdit();
 
         return putInCache(key, form);
--- a/jdk/src/java.base/share/classes/java/lang/invoke/MemberName.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/jdk/src/java.base/share/classes/java/lang/invoke/MemberName.java	Tue Apr 18 22:25:33 2017 +0200
@@ -33,7 +33,6 @@
 import java.lang.reflect.Member;
 import java.lang.reflect.Method;
 import java.lang.reflect.Modifier;
-import java.lang.reflect.Module;
 import java.util.ArrayList;
 import java.util.Collections;
 import java.util.Iterator;
@@ -149,7 +148,7 @@
                 Object[] typeInfo = (Object[]) type;
                 Class<?>[] ptypes = (Class<?>[]) typeInfo[1];
                 Class<?> rtype = (Class<?>) typeInfo[0];
-                MethodType res = MethodType.methodType(rtype, ptypes);
+                MethodType res = MethodType.makeImpl(rtype, ptypes, true);
                 type = res;
             }
             // Make sure type is a MethodType for racing threads.
--- a/jdk/src/java.base/share/classes/java/lang/invoke/MethodHandleImpl.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/jdk/src/java.base/share/classes/java/lang/invoke/MethodHandleImpl.java	Tue Apr 18 22:25:33 2017 +0200
@@ -589,7 +589,7 @@
                 // Spread the array.
                 MethodHandle aload = MethodHandles.arrayElementGetter(spreadArgType);
                 Name array = names[argIndex];
-                names[nameCursor++] = new Name(NF_checkSpreadArgument, array, spreadArgCount);
+                names[nameCursor++] = new Name(getFunction(NF_checkSpreadArgument), array, spreadArgCount);
                 for (int j = 0; j < spreadArgCount; i++, j++) {
                     indexes[i] = nameCursor;
                     names[nameCursor++] = new Name(aload, array, j);
@@ -934,7 +934,7 @@
 
         // profile branch
         if (PROFILE != -1) {
-            names[PROFILE] = new Name(NF_profileBoolean, names[CALL_TEST], names[GET_COUNTERS]);
+            names[PROFILE] = new Name(getFunction(NF_profileBoolean), names[CALL_TEST], names[GET_COUNTERS]);
         }
         // call selectAlternative
         names[SELECT_ALT] = new Name(getConstantHandle(MH_selectAlternative), names[TEST], names[GET_TARGET], names[GET_FALLBACK]);
@@ -1012,7 +1012,7 @@
 
         // t_{i+1}:L=MethodHandleImpl.guardWithCatch(target:L,exType:L,catcher:L,t_{i}:L);
         Object[] gwcArgs = new Object[] {names[GET_TARGET], names[GET_CLASS], names[GET_CATCHER], names[BOXED_ARGS]};
-        names[TRY_CATCH] = new Name(NF_guardWithCatch, gwcArgs);
+        names[TRY_CATCH] = new Name(getFunction(NF_guardWithCatch), gwcArgs);
 
         // t_{i+2}:I=MethodHandle.invokeBasic(unbox:L,t_{i+1}:L);
         MethodHandle invokeBasicUnbox = MethodHandles.basicInvoker(MethodType.methodType(basicType.rtype(), Object.class));
@@ -1085,7 +1085,7 @@
             mh = MethodHandles.dropArguments(mh, 1, Arrays.copyOfRange(type.parameterArray(), 1, arity));
             return mh;
         }
-        return makePairwiseConvert(NF_throwException.resolvedHandle(), type, false, true);
+        return makePairwiseConvert(getFunction(NF_throwException).resolvedHandle(), type, false, true);
     }
 
     static <T extends Throwable> Empty throwException(T t) throws T { throw t; }
@@ -1673,33 +1673,57 @@
     }
 
     // Local constant functions:
-    /*non-public*/ static final NamedFunction
-        NF_checkSpreadArgument,
-        NF_guardWithCatch,
-        NF_throwException,
-        NF_tryFinally,
-        NF_loop,
-        NF_profileBoolean;
+
+    /* non-public */
+    static final byte NF_checkSpreadArgument = 0,
+            NF_guardWithCatch = 1,
+            NF_throwException = 2,
+            NF_tryFinally = 3,
+            NF_loop = 4,
+            NF_profileBoolean = 5,
+            NF_LIMIT = 6;
 
-    static {
+    private static final @Stable NamedFunction[] NFS = new NamedFunction[NF_LIMIT];
+
+    static NamedFunction getFunction(byte func) {
+        NamedFunction nf = NFS[func];
+        if (nf != null) {
+            return nf;
+        }
+        return NFS[func] = createFunction(func);
+    }
+
+    private static NamedFunction createFunction(byte func) {
         try {
-            NF_checkSpreadArgument = new NamedFunction(MethodHandleImpl.class
-                    .getDeclaredMethod("checkSpreadArgument", Object.class, int.class));
-            NF_guardWithCatch = new NamedFunction(MethodHandleImpl.class
-                    .getDeclaredMethod("guardWithCatch", MethodHandle.class, Class.class,
-                            MethodHandle.class, Object[].class));
-            NF_tryFinally = new NamedFunction(MethodHandleImpl.class
-                    .getDeclaredMethod("tryFinally", MethodHandle.class, MethodHandle.class, Object[].class));
-            NF_loop = new NamedFunction(MethodHandleImpl.class
-                    .getDeclaredMethod("loop", BasicType[].class, LoopClauses.class, Object[].class));
-            NF_throwException = new NamedFunction(MethodHandleImpl.class
-                    .getDeclaredMethod("throwException", Throwable.class));
-            NF_profileBoolean = new NamedFunction(MethodHandleImpl.class
-                    .getDeclaredMethod("profileBoolean", boolean.class, int[].class));
+            switch (func) {
+                case NF_checkSpreadArgument:
+                    return new NamedFunction(MethodHandleImpl.class
+                            .getDeclaredMethod("checkSpreadArgument", Object.class, int.class));
+                case NF_guardWithCatch:
+                    return new NamedFunction(MethodHandleImpl.class
+                            .getDeclaredMethod("guardWithCatch", MethodHandle.class, Class.class,
+                                    MethodHandle.class, Object[].class));
+                case NF_tryFinally:
+                    return new NamedFunction(MethodHandleImpl.class
+                            .getDeclaredMethod("tryFinally", MethodHandle.class, MethodHandle.class, Object[].class));
+                case NF_loop:
+                    return new NamedFunction(MethodHandleImpl.class
+                            .getDeclaredMethod("loop", BasicType[].class, LoopClauses.class, Object[].class));
+                case NF_throwException:
+                    return new NamedFunction(MethodHandleImpl.class
+                            .getDeclaredMethod("throwException", Throwable.class));
+                case NF_profileBoolean:
+                    return new NamedFunction(MethodHandleImpl.class
+                            .getDeclaredMethod("profileBoolean", boolean.class, int[].class));
+                default:
+                    throw new InternalError("Undefined function: " + func);
+            }
         } catch (ReflectiveOperationException ex) {
             throw newInternalError(ex);
         }
+    }
 
+    static {
         SharedSecrets.setJavaLangInvokeAccess(new JavaLangInvokeAccess() {
             @Override
             public Object newMemberName() {
@@ -1878,7 +1902,7 @@
             Object[] lArgs =
                     new Object[]{null, // placeholder for BasicType[] localTypes - will be added by LambdaFormEditor
                             names[GET_CLAUSE_DATA], names[BOXED_ARGS]};
-            names[LOOP] = new Name(NF_loop, lArgs);
+            names[LOOP] = new Name(getFunction(NF_loop), lArgs);
 
             // t_{i+2}:I=MethodHandle.invokeBasic(unbox:L,t_{i+1}:L);
             MethodHandle invokeBasicUnbox = MethodHandles.basicInvoker(MethodType.methodType(basicType.rtype(), Object.class));
@@ -2113,7 +2137,7 @@
 
         // t_{i+1}:L=MethodHandleImpl.tryFinally(target:L,exType:L,catcher:L,t_{i}:L);
         Object[] tfArgs = new Object[] {names[GET_TARGET], names[GET_CLEANUP], names[BOXED_ARGS]};
-        names[TRY_FINALLY] = new Name(NF_tryFinally, tfArgs);
+        names[TRY_FINALLY] = new Name(getFunction(NF_tryFinally), tfArgs);
 
         // t_{i+2}:I=MethodHandle.invokeBasic(unbox:L,t_{i+1}:L);
         MethodHandle invokeBasicUnbox = MethodHandles.basicInvoker(MethodType.methodType(basicType.rtype(), Object.class));
--- a/jdk/src/java.base/share/classes/java/lang/invoke/MethodHandles.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/jdk/src/java.base/share/classes/java/lang/invoke/MethodHandles.java	Tue Apr 18 22:25:33 2017 +0200
@@ -43,7 +43,6 @@
 import java.lang.reflect.Member;
 import java.lang.reflect.Method;
 import java.lang.reflect.Modifier;
-import java.lang.reflect.Module;
 import java.lang.reflect.ReflectPermission;
 import java.nio.ByteOrder;
 import java.security.AccessController;
@@ -668,11 +667,11 @@
          *  The value is {@code 0x20}, which does not correspond meaningfully to
          *  any particular {@linkplain java.lang.reflect.Modifier modifier bit}.
          *  A {@code Lookup} with this lookup mode assumes {@linkplain
-         *  java.lang.reflect.Module#canRead(java.lang.reflect.Module) readability}.
+         *  java.lang.Module#canRead(java.lang.Module) readability}.
          *  In conjunction with the {@code PUBLIC} modifier bit, a {@code Lookup}
          *  with this lookup mode can access all public members of public types
          *  of all modules where the type is in a package that is {@link
-         *  java.lang.reflect.Module#isExported(String) exported unconditionally}.
+         *  java.lang.Module#isExported(String) exported unconditionally}.
          *  @since 9
          *  @spec JPMS
          *  @see #publicLookup()
--- a/jdk/src/java.base/share/classes/java/lang/invoke/MethodType.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/jdk/src/java.base/share/classes/java/lang/invoke/MethodType.java	Tue Apr 18 22:25:33 2017 +0200
@@ -95,7 +95,7 @@
     private static final long serialVersionUID = 292L;  // {rtype, {ptype...}}
 
     // The rtype and ptypes fields define the structural identity of the method type:
-    private final Class<?>   rtype;
+    private final @Stable Class<?>   rtype;
     private final @Stable Class<?>[] ptypes;
 
     // The remaining fields are caches of various sorts:
@@ -117,7 +117,8 @@
 
     /**
      * Construct a temporary unchecked instance of MethodType for use only as a key to the intern table.
-     * Does not check the given parameters for validity, and must be discarded after it is used as a searching key.
+     * Does not check the given parameters for validity, and must discarded (if untrusted) or checked
+     * (if trusted) after it has been used as a searching key.
      * The parameters are reversed for this constructor, so that it is not accidentally used.
      */
     private MethodType(Class<?>[] ptypes, Class<?> rtype) {
@@ -181,6 +182,7 @@
         checkSlotCount(ptypes.length + slots);
         return slots;
     }
+
     static {
         // MAX_JVM_ARITY must be power of 2 minus 1 for following code trick to work:
         assert((MAX_JVM_ARITY & (MAX_JVM_ARITY+1)) == 0);
@@ -303,18 +305,26 @@
      */
     /*trusted*/ static
     MethodType makeImpl(Class<?> rtype, Class<?>[] ptypes, boolean trusted) {
-        MethodType mt = internTable.get(new MethodType(ptypes, rtype));
-        if (mt != null)
-            return mt;
         if (ptypes.length == 0) {
             ptypes = NO_PTYPES; trusted = true;
         }
-        mt = new MethodType(rtype, ptypes, trusted);
+        MethodType primordialMT = new MethodType(ptypes, rtype);
+        MethodType mt = internTable.get(primordialMT);
+        if (mt != null)
+            return mt;
+
         // promote the object to the Real Thing, and reprobe
+        if (trusted) {
+            MethodType.checkRtype(rtype);
+            MethodType.checkPtypes(ptypes);
+            mt = primordialMT;
+        } else {
+            mt = new MethodType(rtype, ptypes, false);
+        }
         mt.form = MethodTypeForm.findForm(mt);
         return internTable.add(mt);
     }
-    private static final MethodType[] objectOnlyTypes = new MethodType[20];
+    private static final @Stable MethodType[] objectOnlyTypes = new MethodType[20];
 
     /**
      * Finds or creates a method type whose components are {@code Object} with an optional trailing {@code Object[]} array.
@@ -398,9 +408,14 @@
         checkSlotCount(parameterSlotCount() + ptypesToInsert.length + ins);
         int ilen = ptypesToInsert.length;
         if (ilen == 0)  return this;
-        Class<?>[] nptypes = Arrays.copyOfRange(ptypes, 0, len+ilen);
-        System.arraycopy(nptypes, num, nptypes, num+ilen, len-num);
+        Class<?>[] nptypes = new Class<?>[len + ilen];
+        if (num > 0) {
+            System.arraycopy(ptypes, 0, nptypes, 0, num);
+        }
         System.arraycopy(ptypesToInsert, 0, nptypes, num, ilen);
+        if (num < len) {
+            System.arraycopy(ptypes, num, nptypes, num+ilen, len-num);
+        }
         return makeImpl(rtype, nptypes, true);
     }
 
@@ -636,11 +651,14 @@
         return form.basicType();
     }
 
+    private static final @Stable Class<?>[] METHOD_HANDLE_ARRAY
+            = new Class<?>[] { MethodHandle.class };
+
     /**
      * @return a version of the original type with MethodHandle prepended as the first argument
      */
     /*non-public*/ MethodType invokerType() {
-        return insertParameterTypes(0, MethodHandle.class);
+        return insertParameterTypes(0, METHOD_HANDLE_ARRAY);
     }
 
     /**
--- a/jdk/src/java.base/share/classes/java/lang/module/Configuration.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/jdk/src/java.base/share/classes/java/lang/module/Configuration.java	Tue Apr 18 22:25:33 2017 +0200
@@ -64,11 +64,11 @@
  * with the receiver as the parent configuration. The static methods are for
  * more advanced cases where there can be more than one parent configuration. </p>
  *
- * <p> Each {@link java.lang.reflect.Layer layer} of modules in the Java virtual
+ * <p> Each {@link java.lang.ModuleLayer layer} of modules in the Java virtual
  * machine is created from a configuration. The configuration for the {@link
- * java.lang.reflect.Layer#boot() boot} layer is obtained by invoking {@code
- * Layer.boot().configuration()}. The configuration for the boot layer will
- * often be the parent when creating new configurations. </p>
+ * java.lang.ModuleLayer#boot() boot} layer is obtained by invoking {@code
+ * ModuleLayer.boot().configuration()}. The configuration for the boot layer
+ * will often be the parent when creating new configurations. </p>
  *
  * <h3> Example </h3>
  *
@@ -81,7 +81,7 @@
  * <pre>{@code
  *    ModuleFinder finder = ModuleFinder.of(dir1, dir2, dir3);
  *
- *    Configuration parent = Layer.boot().configuration();
+ *    Configuration parent = ModuleLayer.boot().configuration();
  *
  *    Configuration cf = parent.resolve(finder, ModuleFinder.of(), Set.of("myapp"));
  *    cf.modules().forEach(m -> {
@@ -95,7 +95,7 @@
  *
  * @since 9
  * @spec JPMS
- * @see java.lang.reflect.Layer
+ * @see java.lang.ModuleLayer
  */
 public final class Configuration {
 
--- a/jdk/src/java.base/share/classes/java/lang/module/ModuleDescriptor.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/jdk/src/java.base/share/classes/java/lang/module/ModuleDescriptor.java	Tue Apr 18 22:25:33 2017 +0200
@@ -60,7 +60,7 @@
  * <p> A module descriptor describes a named module and defines methods to
  * obtain each of its components. The module descriptor for a named module
  * in the Java virtual machine is obtained by invoking the {@link
- * java.lang.reflect.Module Module}'s {@link java.lang.reflect.Module#getDescriptor
+ * java.lang.Module Module}'s {@link java.lang.Module#getDescriptor
  * getDescriptor} method. Module descriptors can also be created using the
  * {@link ModuleDescriptor.Builder} class or by reading the binary form of a
  * module declaration ({@code module-info.class}) using the {@link
@@ -85,7 +85,7 @@
  * <p> {@code ModuleDescriptor} objects are immutable and safe for use by
  * multiple concurrent threads.</p>
  *
- * @see java.lang.reflect.Module
+ * @see java.lang.Module
  * @since 9
  * @spec JPMS
  */
@@ -2110,7 +2110,9 @@
 
         /**
          * Sets the module main class. The package for the main class is added
-         * to the module if not already added.
+         * to the module if not already added. In other words, this method is
+         * equivalent to first invoking this builder's {@link #packages(Set)
+         * packages} method to add the package name of the main class.
          *
          * @param  mc
          *         The module main class
@@ -2134,8 +2136,8 @@
                     throw new IllegalArgumentException(mc + ": unnamed package");
                 }
             }
+            packages.add(pn);
             mainClass = mc;
-            packages.add(pn);
             return this;
         }
 
--- a/jdk/src/java.base/share/classes/java/lang/module/ModuleFinder.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/jdk/src/java.base/share/classes/java/lang/module/ModuleFinder.java	Tue Apr 18 22:25:33 2017 +0200
@@ -228,14 +228,14 @@
      * directory is treated as an exploded module rather than a directory of
      * modules. </p>
      *
-     * <p> The module finder returned by this method supports modules that are
-     * packaged as JAR files. A JAR file with a {@code module-info.class} in
-     * the top-level directory of the JAR file (or overridden by a versioned
-     * entry in a {@link java.util.jar.JarFile#isMultiRelease() multi-release}
-     * JAR file) is a modular JAR and is an <em>explicit module</em>.
-     * A JAR file that does not have a {@code module-info.class} in the
-     * top-level directory is created as an automatic module. The components
-     * for the automatic module are derived as follows:
+     * <p id="automatic-modules"> The module finder returned by this method
+     * supports modules packaged as JAR files. A JAR file with a {@code
+     * module-info.class} in its top-level directory, or in a versioned entry
+     * in a {@linkplain java.util.jar.JarFile#isMultiRelease() multi-release}
+     * JAR file, is a modular JAR file and thus defines an <em>explicit</em>
+     * module. A JAR file that does not have a {@code module-info.class} in its
+     * top-level directory defines an <em>automatic module</em>, as follows:
+     * </p>
      *
      * <ul>
      *
@@ -254,16 +254,16 @@
      *         ModuleDescriptor.Version} and ignored if it cannot be parsed as
      *         a {@code Version}. </p></li>
      *
-     *         <li><p> For the module name, then any trailing digits and dots
-     *         are removed, all non-alphanumeric characters ({@code [^A-Za-z0-9]})
-     *         are replaced with a dot ({@code "."}), all repeating dots are
-     *         replaced with one dot, and all leading and trailing dots are
-     *         removed. </p></li>
+     *         <li><p> All non-alphanumeric characters ({@code [^A-Za-z0-9]})
+     *         in the module name are replaced with a dot ({@code "."}), all
+     *         repeating dots are replaced with one dot, and all leading and
+     *         trailing dots are removed. </p></li>
      *
      *         <li><p> As an example, a JAR file named {@code foo-bar.jar} will
      *         derive a module name {@code foo.bar} and no version. A JAR file
-     *         named {@code foo-1.2.3-SNAPSHOT.jar} will derive a module name
-     *         {@code foo} and {@code 1.2.3-SNAPSHOT} as the version. </p></li>
+     *         named {@code foo-bar-1.2.3-SNAPSHOT.jar} will derive a module
+     *         name {@code foo.bar} and {@code 1.2.3-SNAPSHOT} as the version.
+     *         </p></li>
      *
      *     </ul></li>
      *
@@ -312,7 +312,9 @@
      *
      * <p> As with automatic modules, the contents of a packaged or exploded
      * module may need to be <em>scanned</em> in order to determine the packages
-     * in the module. If a {@code .class} file (other than {@code
+     * in the module. Whether {@linkplain java.nio.file.Files#isHidden(Path)
+     * hidden files} are ignored or not is implementation specific and therefore
+     * not specified. If a {@code .class} file (other than {@code
      * module-info.class}) is found in the top-level directory then it is
      * assumed to be a class in the unnamed package and so {@code FindException}
      * is thrown. </p>
--- a/jdk/src/java.base/share/classes/java/lang/module/Resolver.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/jdk/src/java.base/share/classes/java/lang/module/Resolver.java	Tue Apr 18 22:25:33 2017 +0200
@@ -28,7 +28,6 @@
 import java.io.PrintStream;
 import java.lang.module.ModuleDescriptor.Provides;
 import java.lang.module.ModuleDescriptor.Requires.Modifier;
-import java.lang.reflect.Layer;
 import java.util.ArrayDeque;
 import java.util.ArrayList;
 import java.util.Arrays;
@@ -67,6 +66,9 @@
     // maps module name to module reference
     private final Map<String, ModuleReference> nameToReference = new HashMap<>();
 
+    // true if all automatic modules have been found
+    private boolean haveAllAutomaticModules;
+
     // module constraints on target platform
     private String osName;
     private String osArch;
@@ -171,6 +173,21 @@
             ModuleDescriptor descriptor = q.poll();
             assert nameToReference.containsKey(descriptor.name());
 
+            // if the module is an automatic module then all automatic
+            // modules need to be resolved
+            if (descriptor.isAutomatic() && !haveAllAutomaticModules) {
+                addFoundAutomaticModules().forEach(mref -> {
+                    ModuleDescriptor other = mref.descriptor();
+                    q.offer(other);
+                    if (isTracing()) {
+                        trace("Automatic module %s located, required by %s",
+                              other.name(), descriptor.name());
+                        mref.location().ifPresent(uri -> trace("  (%s)", uri));
+                    }
+                });
+                haveAllAutomaticModules = true;
+            }
+
             // process dependences
             for (ModuleDescriptor.Requires requires : descriptor.requires()) {
 
@@ -199,10 +216,15 @@
                 if (!nameToReference.containsKey(dn)) {
                     addFoundModule(mref);
                     q.offer(mref.descriptor());
-                    resolved.add(mref.descriptor());
 
                     if (isTracing()) {
-                        trace("Module %s located, required by %s",
+                        String prefix;
+                        if (mref.descriptor().isAutomatic()) {
+                            prefix = "Automatic module";
+                        } else {
+                            prefix = "Module";
+                        }
+                        trace(prefix + " %s located, required by %s",
                               dn, descriptor.name());
                         mref.location().ifPresent(uri -> trace("  (%s)", uri));
                     }
@@ -250,7 +272,7 @@
 
         // the initial set of modules that may use services
         Set<ModuleDescriptor> initialConsumers;
-        if (Layer.boot() == null) {
+        if (ModuleLayer.boot() == null) {
             initialConsumers = new HashSet<>();
         } else {
             initialConsumers = parents.stream()
@@ -301,6 +323,21 @@
         return this;
     }
 
+    /**
+     * Add all automatic modules that have not already been found to the
+     * nameToReference map.
+     */
+    private Set<ModuleReference> addFoundAutomaticModules() {
+        Set<ModuleReference> result = new HashSet<>();
+        findAll().forEach(mref -> {
+            String mn = mref.descriptor().name();
+            if (mref.descriptor().isAutomatic() && !nameToReference.containsKey(mn)) {
+                addFoundModule(mref);
+                result.add(mref);
+            }
+        });
+        return result;
+    }
 
     /**
      * Add the module to the nameToReference map. Also check any constraints on
@@ -534,7 +571,7 @@
         // need "requires transitive" from the modules in parent configurations
         // as there may be selected modules that have a dependency on modules in
         // the parent configuration.
-        if (Layer.boot() == null) {
+        if (ModuleLayer.boot() == null) {
             g2 = new HashMap<>(capacity);
         } else {
             g2 = parents.stream()
--- a/jdk/src/java.base/share/classes/java/lang/module/package-info.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/jdk/src/java.base/share/classes/java/lang/module/package-info.java	Tue Apr 18 22:25:33 2017 +0200
@@ -70,7 +70,7 @@
  * } </pre>
  *
  * <p> If module {@code m1} is resolved with the configuration for the {@link
- * java.lang.reflect.Layer#boot() boot} layer as the parent then the resulting
+ * java.lang.ModuleLayer#boot() boot} layer as the parent then the resulting
  * configuration contains two modules ({@code m1}, {@code m2}). The edges in
  * its readability graph are:
  * <pre> {@code
@@ -92,10 +92,10 @@
  *
  * <p> {@link java.lang.module.ModuleDescriptor#isAutomatic() Automatic} modules
  * receive special treatment during resolution. Each automatic module is resolved
- * so that it reads all other modules in the configuration and all parent
- * configurations. Each automatic module is also resolved as if it
- * "{@code requires transitive}" all other automatic modules in the configuration
- * (and all automatic modules in parent configurations). </p>
+ * as if it "{@code requires transitive}" all observable automatic modules and
+ * all automatic modules in the parent configurations. Each automatic module is
+ * resolved so that it reads all other modules in the resulting configuration and
+ * all modules in parent configurations. </p>
  *
  * <h2><a name="servicebinding">Service binding</a></h2>
  *
--- a/jdk/src/java.base/share/classes/java/lang/reflect/Layer.java	Tue Apr 18 13:19:42 2017 -0400
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,949 +0,0 @@
-/*
- * Copyright (c) 2014, 2017, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.  Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package java.lang.reflect;
-
-import java.lang.module.Configuration;
-import java.lang.module.ModuleDescriptor;
-import java.lang.module.ResolvedModule;
-import java.util.ArrayDeque;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.Deque;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Objects;
-import java.util.Optional;
-import java.util.Set;
-import java.util.concurrent.CopyOnWriteArrayList;
-import java.util.function.Function;
-import java.util.stream.Collectors;
-import java.util.stream.Stream;
-
-import jdk.internal.loader.ClassLoaderValue;
-import jdk.internal.loader.Loader;
-import jdk.internal.loader.LoaderPool;
-import jdk.internal.misc.SharedSecrets;
-import jdk.internal.module.Modules;
-import jdk.internal.module.ServicesCatalog;
-import sun.security.util.SecurityConstants;
-
-
-/**
- * A layer of modules in the Java virtual machine.
- *
- * <p> A layer is created from a graph of modules in a {@link Configuration}
- * and a function that maps each module to a {@link ClassLoader}.
- * Creating a layer informs the Java virtual machine about the classes that
- * may be loaded from the modules so that the Java virtual machine knows which
- * module that each class is a member of. </p>
- *
- * <p> Creating a layer creates a {@link Module} object for each {@link
- * ResolvedModule} in the configuration. For each resolved module that is
- * {@link ResolvedModule#reads() read}, the {@code Module} {@link
- * Module#canRead reads} the corresponding run-time {@code Module}, which may
- * be in the same layer or a {@link #parents() parent} layer. </p>
- *
- * <p> The {@link #defineModulesWithOneLoader defineModulesWithOneLoader} and
- * {@link #defineModulesWithManyLoaders defineModulesWithManyLoaders} methods
- * provide convenient ways to create a {@code Layer} where all modules are
- * mapped to a single class loader or where each module is mapped to its own
- * class loader. The {@link #defineModules defineModules} method is for more
- * advanced cases where modules are mapped to custom class loaders by means of
- * a function specified to the method. Each of these methods has an instance
- * and static variant. The instance methods create a layer with the receiver
- * as the parent layer. The static methods are for more advanced cases where
- * there can be more than one parent layer or where a {@link Layer.Controller
- * Controller} is needed to control modules in the layer. </p>
- *
- * <p> A Java virtual machine has at least one non-empty layer, the {@link
- * #boot() boot} layer, that is created when the Java virtual machine is
- * started. The boot layer contains module {@code java.base} and is the only
- * layer in the Java virtual machine with a module named "{@code java.base}".
- * The modules in the boot layer are mapped to the bootstrap class loader and
- * other class loaders that are <a href="../ClassLoader.html#builtinLoaders">
- * built-in</a> into the Java virtual machine. The boot layer will often be
- * the {@link #parents() parent} when creating additional layers. </p>
- *
- * <p> Each {@code Module} in a layer is created so that it {@link
- * Module#isExported(String) exports} and {@link Module#isOpen(String) opens}
- * the packages described by its {@link ModuleDescriptor}. Qualified exports
- * (where a package is exported to a set of target modules rather than all
- * modules) are reified when creating the layer as follows: </p>
- * <ul>
- *     <li> If module {@code X} exports a package to {@code Y}, and if the
- *     runtime {@code Module} {@code X} reads {@code Module} {@code Y}, then
- *     the package is exported to {@code Module} {@code Y} (which may be in
- *     the same layer as {@code X} or a parent layer). </li>
- *
- *     <li> If module {@code X} exports a package to {@code Y}, and if the
- *     runtime {@code Module} {@code X} does not read {@code Y} then target
- *     {@code Y} is located as if by invoking {@link #findModule(String)
- *     findModule} to find the module in the layer or its parent layers. If
- *     {@code Y} is found then the package is exported to the instance of
- *     {@code Y} that was found. If {@code Y} is not found then the qualified
- *     export is ignored. </li>
- * </ul>
- *
- * <p> Qualified opens are handled in same way as qualified exports. </p>
- *
- * <p> As when creating a {@code Configuration},
- * {@link ModuleDescriptor#isAutomatic() automatic} modules receive special
- * treatment when creating a layer. An automatic module is created in the
- * Java virtual machine as a {@code Module} that reads every unnamed {@code
- * Module} in the Java virtual machine. </p>
- *
- * <p> Unless otherwise specified, passing a {@code null} argument to a method
- * in this class causes a {@link NullPointerException NullPointerException} to
- * be thrown. </p>
- *
- * <h3> Example usage: </h3>
- *
- * <p> This example creates a configuration by resolving a module named
- * "{@code myapp}" with the configuration for the boot layer as the parent. It
- * then creates a new layer with the modules in this configuration. All modules
- * are defined to the same class loader. </p>
- *
- * <pre>{@code
- *     ModuleFinder finder = ModuleFinder.of(dir1, dir2, dir3);
- *
- *     Layer parent = Layer.boot();
- *
- *     Configuration cf = parent.configuration().resolve(finder, ModuleFinder.of(), Set.of("myapp"));
- *
- *     ClassLoader scl = ClassLoader.getSystemClassLoader();
- *
- *     Layer layer = parent.defineModulesWithOneLoader(cf, scl);
- *
- *     Class<?> c = layer.findLoader("myapp").loadClass("app.Main");
- * }</pre>
- *
- * @since 9
- * @spec JPMS
- * @see Module#getLayer()
- */
-
-public final class Layer {
-
-    // the empty Layer
-    private static final Layer EMPTY_LAYER
-        = new Layer(Configuration.empty(), List.of(), null);
-
-    // the configuration from which this Layer was created
-    private final Configuration cf;
-
-    // parent layers, empty in the case of the empty layer
-    private final List<Layer> parents;
-
-    // maps module name to jlr.Module
-    private final Map<String, Module> nameToModule;
-
-    /**
-     * Creates a new Layer from the modules in the given configuration.
-     */
-    private Layer(Configuration cf,
-                  List<Layer> parents,
-                  Function<String, ClassLoader> clf)
-    {
-        this.cf = cf;
-        this.parents = parents; // no need to do defensive copy
-
-        Map<String, Module> map;
-        if (parents.isEmpty()) {
-            map = Collections.emptyMap();
-        } else {
-            map = Module.defineModules(cf, clf, this);
-        }
-        this.nameToModule = map; // no need to do defensive copy
-    }
-
-    /**
-     * Controls a layer. The static methods defined by {@link Layer} to create
-     * module layers return a {@code Controller} that can be used to control
-     * modules in the layer.
-     *
-     * <p> Unless otherwise specified, passing a {@code null} argument to a
-     * method in this class causes a {@link NullPointerException
-     * NullPointerException} to be thrown. </p>
-     *
-     * @apiNote Care should be taken with {@code Controller} objects, they
-     * should never be shared with untrusted code.
-     *
-     * @since 9
-     * @spec JPMS
-     */
-    public static final class Controller {
-        private final Layer layer;
-
-        Controller(Layer layer) {
-            this.layer = layer;
-        }
-
-        /**
-         * Returns the layer that this object controls.
-         *
-         * @return the layer
-         */
-        public Layer layer() {
-            return layer;
-        }
-
-        private void ensureInLayer(Module source) {
-            if (source.getLayer() != layer)
-                throw new IllegalArgumentException(source + " not in layer");
-        }
-
-
-        /**
-         * Updates module {@code source} in the layer to read module
-         * {@code target}. This method is a no-op if {@code source} already
-         * reads {@code target}.
-         *
-         * @implNote <em>Read edges</em> added by this method are <em>weak</em>
-         * and do not prevent {@code target} from being GC'ed when {@code source}
-         * is strongly reachable.
-         *
-         * @param  source
-         *         The source module
-         * @param  target
-         *         The target module to read
-         *
-         * @return This controller
-         *
-         * @throws IllegalArgumentException
-         *         If {@code source} is not in the layer
-         *
-         * @see Module#addReads
-         */
-        public Controller addReads(Module source, Module target) {
-            ensureInLayer(source);
-            Objects.requireNonNull(target);
-            Modules.addReads(source, target);
-            return this;
-        }
-
-        /**
-         * Updates module {@code source} in the layer to open a package to
-         * module {@code target}. This method is a no-op if {@code source}
-         * already opens the package to at least {@code target}.
-         *
-         * @param  source
-         *         The source module
-         * @param  pn
-         *         The package name
-         * @param  target
-         *         The target module to read
-         *
-         * @return This controller
-         *
-         * @throws IllegalArgumentException
-         *         If {@code source} is not in the layer or the package is not
-         *         in the source module
-         *
-         * @see Module#addOpens
-         */
-        public Controller addOpens(Module source, String pn, Module target) {
-            ensureInLayer(source);
-            Objects.requireNonNull(pn);
-            Objects.requireNonNull(target);
-            Modules.addOpens(source, pn, target);
-            return this;
-        }
-    }
-
-
-    /**
-     * Creates a new layer, with this layer as its parent, by defining the
-     * modules in the given {@code Configuration} to the Java virtual machine.
-     * This method creates one class loader and defines all modules to that
-     * class loader. The {@link ClassLoader#getParent() parent} of each class
-     * loader is the given parent class loader. This method works exactly as
-     * specified by the static {@link
-     * #defineModulesWithOneLoader(Configuration,List,ClassLoader)
-     * defineModulesWithOneLoader} method when invoked with this layer as the
-     * parent. In other words, if this layer is {@code thisLayer} then this
-     * method is equivalent to invoking:
-     * <pre> {@code
-     *     Layer.defineModulesWithOneLoader(cf, List.of(thisLayer), parentLoader).layer();
-     * }</pre>
-     *
-     * @param  cf
-     *         The configuration for the layer
-     * @param  parentLoader
-     *         The parent class loader for the class loader created by this
-     *         method; may be {@code null} for the bootstrap class loader
-     *
-     * @return The newly created layer
-     *
-     * @throws IllegalArgumentException
-     *         If the parent of the given configuration is not the configuration
-     *         for this layer
-     * @throws LayerInstantiationException
-     *         If the layer cannot be created for any of the reasons specified
-     *         by the static {@code defineModulesWithOneLoader} method
-     * @throws SecurityException
-     *         If {@code RuntimePermission("createClassLoader")} or
-     *         {@code RuntimePermission("getClassLoader")} is denied by
-     *         the security manager
-     *
-     * @see #findLoader
-     */
-    public Layer defineModulesWithOneLoader(Configuration cf,
-                                            ClassLoader parentLoader) {
-        return defineModulesWithOneLoader(cf, List.of(this), parentLoader).layer();
-    }
-
-
-    /**
-     * Creates a new layer, with this layer as its parent, by defining the
-     * modules in the given {@code Configuration} to the Java virtual machine.
-     * Each module is defined to its own {@link ClassLoader} created by this
-     * method. The {@link ClassLoader#getParent() parent} of each class loader
-     * is the given parent class loader. This method works exactly as specified
-     * by the static {@link
-     * #defineModulesWithManyLoaders(Configuration,List,ClassLoader)
-     * defineModulesWithManyLoaders} method when invoked with this layer as the
-     * parent. In other words, if this layer is {@code thisLayer} then this
-     * method is equivalent to invoking:
-     * <pre> {@code
-     *     Layer.defineModulesWithManyLoaders(cf, List.of(thisLayer), parentLoader).layer();
-     * }</pre>
-     *
-     * @param  cf
-     *         The configuration for the layer
-     * @param  parentLoader
-     *         The parent class loader for each of the class loaders created by
-     *         this method; may be {@code null} for the bootstrap class loader
-     *
-     * @return The newly created layer
-     *
-     * @throws IllegalArgumentException
-     *         If the parent of the given configuration is not the configuration
-     *         for this layer
-     * @throws LayerInstantiationException
-     *         If the layer cannot be created for any of the reasons specified
-     *         by the static {@code defineModulesWithManyLoaders} method
-     * @throws SecurityException
-     *         If {@code RuntimePermission("createClassLoader")} or
-     *         {@code RuntimePermission("getClassLoader")} is denied by
-     *         the security manager
-     *
-     * @see #findLoader
-     */
-    public Layer defineModulesWithManyLoaders(Configuration cf,
-                                              ClassLoader parentLoader) {
-        return defineModulesWithManyLoaders(cf, List.of(this), parentLoader).layer();
-    }
-
-
-    /**
-     * Creates a new layer, with this layer as its parent, by defining the
-     * modules in the given {@code Configuration} to the Java virtual machine.
-     * Each module is mapped, by name, to its class loader by means of the
-     * given function. This method works exactly as specified by the static
-     * {@link #defineModules(Configuration,List,Function) defineModules}
-     * method when invoked with this layer as the parent. In other words, if
-     * this layer is {@code thisLayer} then this method is equivalent to
-     * invoking:
-     * <pre> {@code
-     *     Layer.defineModules(cf, List.of(thisLayer), clf).layer();
-     * }</pre>
-     *
-     * @param  cf
-     *         The configuration for the layer
-     * @param  clf
-     *         The function to map a module name to a class loader
-     *
-     * @return The newly created layer
-     *
-     * @throws IllegalArgumentException
-     *         If the parent of the given configuration is not the configuration
-     *         for this layer
-     * @throws LayerInstantiationException
-     *         If the layer cannot be created for any of the reasons specified
-     *         by the static {@code defineModules} method
-     * @throws SecurityException
-     *         If {@code RuntimePermission("getClassLoader")} is denied by
-     *         the security manager
-     */
-    public Layer defineModules(Configuration cf,
-                               Function<String, ClassLoader> clf) {
-        return defineModules(cf, List.of(this), clf).layer();
-    }
-
-    /**
-     * Creates a new layer by defining the modules in the given {@code
-     * Configuration} to the Java virtual machine. This method creates one
-     * class loader and defines all modules to that class loader.
-     *
-     * <p> The class loader created by this method implements <em>direct
-     * delegation</em> when loading types from modules. When its {@link
-     * ClassLoader#loadClass(String, boolean) loadClass} method is invoked to
-     * load a class then it uses the package name of the class to map it to a
-     * module. This may be a module in this layer and hence defined to the same
-     * class loader. It may be a package in a module in a parent layer that is
-     * exported to one or more of the modules in this layer. The class
-     * loader delegates to the class loader of the module, throwing {@code
-     * ClassNotFoundException} if not found by that class loader.
-     * When {@code loadClass} is invoked to load classes that do not map to a
-     * module then it delegates to the parent class loader. </p>
-     *
-     * <p> Attempting to create a layer with all modules defined to the same
-     * class loader can fail for the following reasons:
-     *
-     * <ul>
-     *
-     *     <li><p> <em>Overlapping packages</em>: Two or more modules in the
-     *     configuration have the same package. </p></li>
-     *
-     *     <li><p> <em>Split delegation</em>: The resulting class loader would
-     *     need to delegate to more than one class loader in order to load types
-     *     in a specific package. </p></li>
-     *
-     * </ul>
-     *
-     * <p> In addition, a layer cannot be created if the configuration contains
-     * a module named "{@code java.base}", or a module contains a package named
-     * "{@code java}" or a package with a name starting with "{@code java.}". </p>
-     *
-     * <p> If there is a security manager then the class loader created by
-     * this method will load classes and resources with privileges that are
-     * restricted by the calling context of this method. </p>
-     *
-     * @param  cf
-     *         The configuration for the layer
-     * @param  parentLayers
-     *         The list of parent layers in search order
-     * @param  parentLoader
-     *         The parent class loader for the class loader created by this
-     *         method; may be {@code null} for the bootstrap class loader
-     *
-     * @return A controller that controls the newly created layer
-     *
-     * @throws IllegalArgumentException
-     *         If the parent configurations do not match the configuration of
-     *         the parent layers, including order
-     * @throws LayerInstantiationException
-     *         If all modules cannot be defined to the same class loader for any
-     *         of the reasons listed above
-     * @throws SecurityException
-     *         If {@code RuntimePermission("createClassLoader")} or
-     *         {@code RuntimePermission("getClassLoader")} is denied by
-     *         the security manager
-     *
-     * @see #findLoader
-     */
-    public static Controller defineModulesWithOneLoader(Configuration cf,
-                                                        List<Layer> parentLayers,
-                                                        ClassLoader parentLoader)
-    {
-        List<Layer> parents = new ArrayList<>(parentLayers);
-        checkConfiguration(cf, parents);
-
-        checkCreateClassLoaderPermission();
-        checkGetClassLoaderPermission();
-
-        try {
-            Loader loader = new Loader(cf.modules(), parentLoader);
-            loader.initRemotePackageMap(cf, parents);
-            Layer layer =  new Layer(cf, parents, mn -> loader);
-            return new Controller(layer);
-        } catch (IllegalArgumentException | IllegalStateException e) {
-            throw new LayerInstantiationException(e.getMessage());
-        }
-    }
-
-    /**
-     * Creates a new layer by defining the modules in the given {@code
-     * Configuration} to the Java virtual machine. Each module is defined to
-     * its own {@link ClassLoader} created by this method. The {@link
-     * ClassLoader#getParent() parent} of each class loader is the given parent
-     * class loader.
-     *
-     * <p> The class loaders created by this method implement <em>direct
-     * delegation</em> when loading types from modules. When {@link
-     * ClassLoader#loadClass(String, boolean) loadClass} method is invoked to
-     * load a class then it uses the package name of the class to map it to a
-     * module. The package may be in the module defined to the class loader.
-     * The package may be exported by another module in this layer to the
-     * module defined to the class loader. It may be in a package exported by a
-     * module in a parent layer. The class loader delegates to the class loader
-     * of the module, throwing {@code ClassNotFoundException} if not found by
-     * that class loader.
-     * When {@code loadClass} is invoked to load classes that do not map to a
-     * module then it delegates to the parent class loader. </p>
-     *
-     * <p> If there is a security manager then the class loaders created by
-     * this method will load classes and resources with privileges that are
-     * restricted by the calling context of this method. </p>
-     *
-     * @param  cf
-     *         The configuration for the layer
-     * @param  parentLayers
-     *         The list of parent layers in search order
-     * @param  parentLoader
-     *         The parent class loader for each of the class loaders created by
-     *         this method; may be {@code null} for the bootstrap class loader
-     *
-     * @return A controller that controls the newly created layer
-     *
-     * @throws IllegalArgumentException
-     *         If the parent configurations do not match the configuration of
-     *         the parent layers, including order
-     * @throws LayerInstantiationException
-     *         If the layer cannot be created because the configuration contains
-     *         a module named "{@code java.base}" or a module contains a package
-     *         named "{@code java}" or a package with a name starting with
-     *         "{@code java.}"
-     *
-     * @throws SecurityException
-     *         If {@code RuntimePermission("createClassLoader")} or
-     *         {@code RuntimePermission("getClassLoader")} is denied by
-     *         the security manager
-     *
-     * @see #findLoader
-     */
-    public static Controller defineModulesWithManyLoaders(Configuration cf,
-                                                          List<Layer> parentLayers,
-                                                          ClassLoader parentLoader)
-    {
-        List<Layer> parents = new ArrayList<>(parentLayers);
-        checkConfiguration(cf, parents);
-
-        checkCreateClassLoaderPermission();
-        checkGetClassLoaderPermission();
-
-        LoaderPool pool = new LoaderPool(cf, parents, parentLoader);
-        try {
-            Layer layer = new Layer(cf, parents, pool::loaderFor);
-            return new Controller(layer);
-        } catch (IllegalArgumentException | IllegalStateException e) {
-            throw new LayerInstantiationException(e.getMessage());
-        }
-    }
-
-    /**
-     * Creates a new layer by defining the modules in the given {@code
-     * Configuration} to the Java virtual machine. The given function maps each
-     * module in the configuration, by name, to a class loader. Creating the
-     * layer informs the Java virtual machine about the classes that may be
-     * loaded so that the Java virtual machine knows which module that each
-     * class is a member of.
-     *
-     * <p> The class loader delegation implemented by the class loaders must
-     * respect module readability. The class loaders should be
-     * {@link ClassLoader#registerAsParallelCapable parallel-capable} so as to
-     * avoid deadlocks during class loading. In addition, the entity creating
-     * a new layer with this method should arrange that the class loaders be
-     * ready to load from these modules before there are any attempts to load
-     * classes or resources. </p>
-     *
-     * <p> Creating a {@code Layer} can fail for the following reasons: </p>
-     *
-     * <ul>
-     *
-     *     <li><p> Two or more modules with the same package are mapped to the
-     *     same class loader. </p></li>
-     *
-     *     <li><p> A module is mapped to a class loader that already has a
-     *     module of the same name defined to it. </p></li>
-     *
-     *     <li><p> A module is mapped to a class loader that has already
-     *     defined types in any of the packages in the module. </p></li>
-     *
-     * </ul>
-     *
-     * <p> In addition, a layer cannot be created if the configuration contains
-     * a module named "{@code java.base}", a configuration contains a module
-     * with a package named "{@code java}" or a package name starting with
-     * "{@code java.}" and the module is mapped to a class loader other than
-     * the {@link ClassLoader#getPlatformClassLoader() platform class loader},
-     * or the function to map a module name to a class loader returns
-     * {@code null}. </p>
-     *
-     * <p> If the function to map a module name to class loader throws an error
-     * or runtime exception then it is propagated to the caller of this method.
-     * </p>
-     *
-     * @apiNote It is implementation specific as to whether creating a Layer
-     * with this method is an atomic operation or not. Consequentially it is
-     * possible for this method to fail with some modules, but not all, defined
-     * to the Java virtual machine.
-     *
-     * @param  cf
-     *         The configuration for the layer
-     * @param  parentLayers
-     *         The list of parent layers in search order
-     * @param  clf
-     *         The function to map a module name to a class loader
-     *
-     * @return A controller that controls the newly created layer
-     *
-     * @throws IllegalArgumentException
-     *         If the parent configurations do not match the configuration of
-     *         the parent layers, including order
-     * @throws LayerInstantiationException
-     *         If creating the layer fails for any of the reasons listed above
-     * @throws SecurityException
-     *         If {@code RuntimePermission("getClassLoader")} is denied by
-     *         the security manager
-     */
-    public static Controller defineModules(Configuration cf,
-                                           List<Layer> parentLayers,
-                                           Function<String, ClassLoader> clf)
-    {
-        List<Layer> parents = new ArrayList<>(parentLayers);
-        checkConfiguration(cf, parents);
-        Objects.requireNonNull(clf);
-
-        checkGetClassLoaderPermission();
-
-        // The boot layer is checked during module system initialization
-        if (boot() != null) {
-            checkForDuplicatePkgs(cf, clf);
-        }
-
-        try {
-            Layer layer = new Layer(cf, parents, clf);
-            return new Controller(layer);
-        } catch (IllegalArgumentException | IllegalStateException e) {
-            throw new LayerInstantiationException(e.getMessage());
-        }
-    }
-
-
-    /**
-     * Checks that the parent configurations match the configuration of
-     * the parent layers.
-     */
-    private static void checkConfiguration(Configuration cf,
-                                           List<Layer> parentLayers)
-    {
-        Objects.requireNonNull(cf);
-
-        List<Configuration> parentConfigurations = cf.parents();
-        if (parentLayers.size() != parentConfigurations.size())
-            throw new IllegalArgumentException("wrong number of parents");
-
-        int index = 0;
-        for (Layer parent : parentLayers) {
-            if (parent.configuration() != parentConfigurations.get(index)) {
-                throw new IllegalArgumentException(
-                        "Parent of configuration != configuration of this Layer");
-            }
-            index++;
-        }
-    }
-
-    private static void checkCreateClassLoaderPermission() {
-        SecurityManager sm = System.getSecurityManager();
-        if (sm != null)
-            sm.checkPermission(SecurityConstants.CREATE_CLASSLOADER_PERMISSION);
-    }
-
-    private static void checkGetClassLoaderPermission() {
-        SecurityManager sm = System.getSecurityManager();
-        if (sm != null)
-            sm.checkPermission(SecurityConstants.GET_CLASSLOADER_PERMISSION);
-    }
-
-    /**
-     * Checks a configuration and the module-to-loader mapping to ensure that
-     * no two modules mapped to the same class loader have the same package.
-     * It also checks that no two automatic modules have the same package.
-     *
-     * @throws LayerInstantiationException
-     */
-    private static void checkForDuplicatePkgs(Configuration cf,
-                                              Function<String, ClassLoader> clf)
-    {
-        // HashMap allows null keys
-        Map<ClassLoader, Set<String>> loaderToPackages = new HashMap<>();
-        for (ResolvedModule resolvedModule : cf.modules()) {
-            ModuleDescriptor descriptor = resolvedModule.reference().descriptor();
-            ClassLoader loader = clf.apply(descriptor.name());
-
-            Set<String> loaderPackages
-                = loaderToPackages.computeIfAbsent(loader, k -> new HashSet<>());
-
-            for (String pkg : descriptor.packages()) {
-                boolean added = loaderPackages.add(pkg);
-                if (!added) {
-                    throw fail("More than one module with package %s mapped" +
-                               " to the same class loader", pkg);
-                }
-            }
-        }
-    }
-
-    /**
-     * Creates a LayerInstantiationException with the a message formatted from
-     * the given format string and arguments.
-     */
-    private static LayerInstantiationException fail(String fmt, Object ... args) {
-        String msg = String.format(fmt, args);
-        return new LayerInstantiationException(msg);
-    }
-
-
-    /**
-     * Returns the configuration for this layer.
-     *
-     * @return The configuration for this layer
-     */
-    public Configuration configuration() {
-        return cf;
-    }
-
-
-    /**
-     * Returns the list of this layer's parents unless this is the
-     * {@linkplain #empty empty layer}, which has no parents and so an
-     * empty list is returned.
-     *
-     * @return The list of this layer's parents
-     */
-    public List<Layer> parents() {
-        return parents;
-    }
-
-
-    /**
-     * Returns an ordered stream of layers. The first element is is this layer,
-     * the remaining elements are the parent layers in DFS order.
-     *
-     * @implNote For now, the assumption is that the number of elements will
-     * be very low and so this method does not use a specialized spliterator.
-     */
-    Stream<Layer> layers() {
-        List<Layer> allLayers = this.allLayers;
-        if (allLayers != null)
-            return allLayers.stream();
-
-        allLayers = new ArrayList<>();
-        Set<Layer> visited = new HashSet<>();
-        Deque<Layer> stack = new ArrayDeque<>();
-        visited.add(this);
-        stack.push(this);
-
-        while (!stack.isEmpty()) {
-            Layer layer = stack.pop();
-            allLayers.add(layer);
-
-            // push in reverse order
-            for (int i = layer.parents.size() - 1; i >= 0; i--) {
-                Layer parent = layer.parents.get(i);
-                if (!visited.contains(parent)) {
-                    visited.add(parent);
-                    stack.push(parent);
-                }
-            }
-        }
-
-        this.allLayers = allLayers = Collections.unmodifiableList(allLayers);
-        return allLayers.stream();
-    }
-
-    private volatile List<Layer> allLayers;
-
-    /**
-     * Returns the set of the modules in this layer.
-     *
-     * @return A possibly-empty unmodifiable set of the modules in this layer
-     */
-    public Set<Module> modules() {
-        Set<Module> modules = this.modules;
-        if (modules == null) {
-            this.modules = modules =
-                Collections.unmodifiableSet(new HashSet<>(nameToModule.values()));
-        }
-        return modules;
-    }
-
-    private volatile Set<Module> modules;
-
-
-    /**
-     * Returns the module with the given name in this layer, or if not in this
-     * layer, the {@linkplain #parents parent} layers. Finding a module in
-     * parent layers is equivalent to invoking {@code findModule} on each
-     * parent, in search order, until the module is found or all parents have
-     * been searched. In a <em>tree of layers</em>  then this is equivalent to
-     * a depth-first search.
-     *
-     * @param  name
-     *         The name of the module to find
-     *
-     * @return The module with the given name or an empty {@code Optional}
-     *         if there isn't a module with this name in this layer or any
-     *         parent layer
-     */
-    public Optional<Module> findModule(String name) {
-        Objects.requireNonNull(name);
-        if (this == EMPTY_LAYER)
-            return Optional.empty();
-        Module m = nameToModule.get(name);
-        if (m != null)
-            return Optional.of(m);
-
-        return layers()
-                .skip(1)  // skip this layer
-                .map(l -> l.nameToModule)
-                .filter(map -> map.containsKey(name))
-                .map(map -> map.get(name))
-                .findAny();
-    }
-
-
-    /**
-     * Returns the {@code ClassLoader} for the module with the given name. If
-     * a module of the given name is not in this layer then the {@link #parents
-     * parent} layers are searched in the manner specified by {@link
-     * #findModule(String) findModule}.
-     *
-     * <p> If there is a security manager then its {@code checkPermission}
-     * method is called with a {@code RuntimePermission("getClassLoader")}
-     * permission to check that the caller is allowed to get access to the
-     * class loader. </p>
-     *
-     * @apiNote This method does not return an {@code Optional<ClassLoader>}
-     * because `null` must be used to represent the bootstrap class loader.
-     *
-     * @param  name
-     *         The name of the module to find
-     *
-     * @return The ClassLoader that the module is defined to
-     *
-     * @throws IllegalArgumentException if a module of the given name is not
-     *         defined in this layer or any parent of this layer
-     *
-     * @throws SecurityException if denied by the security manager
-     */
-    public ClassLoader findLoader(String name) {
-        Optional<Module> om = findModule(name);
-
-        // can't use map(Module::getClassLoader) as class loader can be null
-        if (om.isPresent()) {
-            return om.get().getClassLoader();
-        } else {
-            throw new IllegalArgumentException("Module " + name
-                                               + " not known to this layer");
-        }
-    }
-
-    /**
-     * Returns a string describing this layer.
-     *
-     * @return A possibly empty string describing this layer
-     */
-    @Override
-    public String toString() {
-        return modules().stream()
-                .map(Module::getName)
-                .collect(Collectors.joining(", "));
-    }
-
-    /**
-     * Returns the <em>empty</em> layer. There are no modules in the empty
-     * layer. It has no parents.
-     *
-     * @return The empty layer
-     */
-    public static Layer empty() {
-        return EMPTY_LAYER;
-    }
-
-
-    /**
-     * Returns the boot layer. The boot layer contains at least one module,
-     * {@code java.base}. Its parent is the {@link #empty() empty} layer.
-     *
-     * @apiNote This method returns {@code null} during startup and before
-     *          the boot layer is fully initialized.
-     *
-     * @return The boot layer
-     */
-    public static Layer boot() {
-        return SharedSecrets.getJavaLangAccess().getBootLayer();
-    }
-
-
-    /**
-     * Returns the ServicesCatalog for this Layer, creating it if not
-     * already created.
-     */
-    ServicesCatalog getServicesCatalog() {
-        ServicesCatalog servicesCatalog = this.servicesCatalog;
-        if (servicesCatalog != null)
-            return servicesCatalog;
-
-        synchronized (this) {
-            servicesCatalog = this.servicesCatalog;
-            if (servicesCatalog == null) {
-                servicesCatalog = ServicesCatalog.create();
-                nameToModule.values().forEach(servicesCatalog::register);
-                this.servicesCatalog = servicesCatalog;
-            }
-        }
-
-        return servicesCatalog;
-    }
-
-    private volatile ServicesCatalog servicesCatalog;
-
-
-    /**
-     * Record that this layer has at least one module defined to the given
-     * class loader.
-     */
-    void bindToLoader(ClassLoader loader) {
-        // CLV.computeIfAbsent(loader, (cl, clv) -> new CopyOnWriteArrayList<>())
-        List<Layer> list = CLV.get(loader);
-        if (list == null) {
-            list = new CopyOnWriteArrayList<>();
-            List<Layer> previous = CLV.putIfAbsent(loader, list);
-            if (previous != null) list = previous;
-        }
-        list.add(this);
-    }
-
-    /**
-     * Returns a stream of the layers that have at least one module defined to
-     * the given class loader.
-     */
-    static Stream<Layer> layers(ClassLoader loader) {
-        List<Layer> list = CLV.get(loader);
-        if (list != null) {
-            return list.stream();
-        } else {
-            return Stream.empty();
-        }
-    }
-
-    // the list of layers with modules defined to a class loader
-    private static final ClassLoaderValue<List<Layer>> CLV = new ClassLoaderValue<>();
-}
--- a/jdk/src/java.base/share/classes/java/lang/reflect/LayerInstantiationException.java	Tue Apr 18 13:19:42 2017 -0400
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,80 +0,0 @@
-/*
- * 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
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.  Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package java.lang.reflect;
-
-/**
- * Thrown when creating a Layer fails.
- *
- * @see Layer
- *
- * @since 9
- * @spec JPMS
- */
-public class LayerInstantiationException extends RuntimeException {
-    private static final long serialVersionUID = -906239691613568347L;
-
-    /**
-     * Constructs a {@code LayerInstantiationException} with no detail message.
-     */
-    public LayerInstantiationException() {
-    }
-
-    /**
-     * Constructs a {@code LayerInstantiationException} with the given detail
-     * message.
-     *
-     * @param msg
-     *        The detail message; can be {@code null}
-     */
-    public LayerInstantiationException(String msg) {
-        super(msg);
-    }
-
-    /**
-     * Constructs a {@code LayerInstantiationException} with the given cause.
-     *
-     * @param cause
-     *        The cause; can be {@code null}
-     */
-    public LayerInstantiationException(Throwable cause) {
-        super(cause);
-    }
-
-    /**
-     * Constructs a {@code FindException} with the given detail message
-     * and cause.
-     *
-     * @param msg
-     *        The detail message; can be {@code null}
-     * @param cause
-     *        The cause; can be {@code null}
-     */
-    public LayerInstantiationException(String msg, Throwable cause) {
-        super(msg, cause);
-    }
-
-}
-
--- a/jdk/src/java.base/share/classes/java/lang/reflect/Module.java	Tue Apr 18 13:19:42 2017 -0400
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,1591 +0,0 @@
-/*
- * Copyright (c) 2014, 2017, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.  Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package java.lang.reflect;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.lang.annotation.Annotation;
-import java.lang.module.Configuration;
-import java.lang.module.ModuleReference;
-import java.lang.module.ModuleDescriptor;
-import java.lang.module.ModuleDescriptor.Exports;
-import java.lang.module.ModuleDescriptor.Opens;
-import java.lang.module.ModuleDescriptor.Version;
-import java.lang.module.ResolvedModule;
-import java.net.URI;
-import java.net.URL;
-import java.security.AccessController;
-import java.security.PrivilegedAction;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Objects;
-import java.util.Optional;
-import java.util.Set;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.function.Function;
-import java.util.stream.Stream;
-
-import jdk.internal.loader.BuiltinClassLoader;
-import jdk.internal.loader.BootLoader;
-import jdk.internal.misc.JavaLangAccess;
-import jdk.internal.misc.JavaLangReflectModuleAccess;
-import jdk.internal.misc.SharedSecrets;
-import jdk.internal.module.ServicesCatalog;
-import jdk.internal.module.Resources;
-import jdk.internal.org.objectweb.asm.AnnotationVisitor;
-import jdk.internal.org.objectweb.asm.Attribute;
-import jdk.internal.org.objectweb.asm.ClassReader;
-import jdk.internal.org.objectweb.asm.ClassVisitor;
-import jdk.internal.org.objectweb.asm.ClassWriter;
-import jdk.internal.org.objectweb.asm.Opcodes;
-import jdk.internal.reflect.CallerSensitive;
-import jdk.internal.reflect.Reflection;
-import sun.security.util.SecurityConstants;
-
-/**
- * Represents a run-time module, either {@link #isNamed() named} or unnamed.
- *
- * <p> Named modules have a {@link #getName() name} and are constructed by the
- * Java Virtual Machine when a graph of modules is defined to the Java virtual
- * machine to create a module {@link Layer Layer}. </p>
- *
- * <p> An unnamed module does not have a name. There is an unnamed module for
- * each {@link ClassLoader ClassLoader}, obtained by invoking its {@link
- * ClassLoader#getUnnamedModule() getUnnamedModule} method. All types that are
- * not in a named module are members of their defining class loader's unnamed
- * module. </p>
- *
- * <p> The package names that are parameters or returned by methods defined in
- * this class are the fully-qualified names of the packages as defined in
- * section 6.5.3 of <cite>The Java&trade; Language Specification</cite>, for
- * example, {@code "java.lang"}. </p>
- *
- * <p> Unless otherwise specified, passing a {@code null} argument to a method
- * in this class causes a {@link NullPointerException NullPointerException} to
- * be thrown. </p>
- *
- * @since 9
- * @spec JPMS
- * @see java.lang.Class#getModule
- */
-
-public final class Module implements AnnotatedElement {
-
-    // the layer that contains this module, can be null
-    private final Layer layer;
-
-    // module name and loader, these fields are read by VM
-    private final String name;
-    private final ClassLoader loader;
-
-    // the module descriptor
-    private final ModuleDescriptor descriptor;
-
-
-    /**
-     * Creates a new named Module. The resulting Module will be defined to the
-     * VM but will not read any other modules, will not have any exports setup
-     * and will not be registered in the service catalog.
-     */
-    private Module(Layer layer,
-                   ClassLoader loader,
-                   ModuleDescriptor descriptor,
-                   URI uri)
-    {
-        this.layer = layer;
-        this.name = descriptor.name();
-        this.loader = loader;
-        this.descriptor = descriptor;
-
-        // define module to VM
-
-        boolean isOpen = descriptor.isOpen();
-        Version version = descriptor.version().orElse(null);
-        String vs = Objects.toString(version, null);
-        String loc = Objects.toString(uri, null);
-        String[] packages = descriptor.packages().toArray(new String[0]);
-        defineModule0(this, isOpen, vs, loc, packages);
-    }
-
-
-    /**
-     * Create the unnamed Module for the given ClassLoader.
-     *
-     * @see ClassLoader#getUnnamedModule
-     */
-    private Module(ClassLoader loader) {
-        this.layer = null;
-        this.name = null;
-        this.loader = loader;
-        this.descriptor = null;
-    }
-
-
-    /**
-     * Creates a named module but without defining the module to the VM.
-     *
-     * @apiNote This constructor is for VM white-box testing.
-     */
-    Module(ClassLoader loader, ModuleDescriptor descriptor) {
-        this.layer = null;
-        this.name = descriptor.name();
-        this.loader = loader;
-        this.descriptor = descriptor;
-    }
-
-
-
-    /**
-     * Returns {@code true} if this module is a named module.
-     *
-     * @return {@code true} if this is a named module
-     *
-     * @see ClassLoader#getUnnamedModule()
-     */
-    public boolean isNamed() {
-        return name != null;
-    }
-
-    /**
-     * Returns the module name or {@code null} if this module is an unnamed
-     * module.
-     *
-     * @return The module name
-     */
-    public String getName() {
-        return name;
-    }
-
-    /**
-     * Returns the {@code ClassLoader} for this module.
-     *
-     * <p> If there is a security manager then its {@code checkPermission}
-     * method if first called with a {@code RuntimePermission("getClassLoader")}
-     * permission to check that the caller is allowed to get access to the
-     * class loader. </p>
-     *
-     * @return The class loader for this module
-     *
-     * @throws SecurityException
-     *         If denied by the security manager
-     */
-    public ClassLoader getClassLoader() {
-        SecurityManager sm = System.getSecurityManager();
-        if (sm != null) {
-            sm.checkPermission(SecurityConstants.GET_CLASSLOADER_PERMISSION);
-        }
-        return loader;
-    }
-
-    /**
-     * Returns the module descriptor for this module or {@code null} if this
-     * module is an unnamed module.
-     *
-     * @return The module descriptor for this module
-     */
-    public ModuleDescriptor getDescriptor() {
-        return descriptor;
-    }
-
-    /**
-     * Returns the layer that contains this module or {@code null} if this
-     * module is not in a layer.
-     *
-     * A module {@code Layer} contains named modules and therefore this
-     * method always returns {@code null} when invoked on an unnamed module.
-     *
-     * <p> <a href="Proxy.html#dynamicmodule">Dynamic modules</a> are named
-     * modules that are generated at runtime. A dynamic module may or may
-     * not be in a module Layer. </p>
-     *
-     * @return The layer that contains this module
-     *
-     * @see Proxy
-     */
-    public Layer getLayer() {
-        if (isNamed()) {
-            Layer layer = this.layer;
-            if (layer != null)
-                return layer;
-
-            // special-case java.base as it is created before the boot Layer
-            if (loader == null && name.equals("java.base")) {
-                return SharedSecrets.getJavaLangAccess().getBootLayer();
-            }
-        }
-
-        return null;
-    }
-
-
-    // --
-
-    // special Module to mean "all unnamed modules"
-    private static final Module ALL_UNNAMED_MODULE = new Module(null);
-
-    // special Module to mean "everyone"
-    private static final Module EVERYONE_MODULE = new Module(null);
-
-    // set contains EVERYONE_MODULE, used when a package is opened or
-    // exported unconditionally
-    private static final Set<Module> EVERYONE_SET = Set.of(EVERYONE_MODULE);
-
-
-    // -- readability --
-
-    // the modules that this module reads
-    private volatile Set<Module> reads;
-
-    // additional module (2nd key) that some module (1st key) reflectively reads
-    private static final WeakPairMap<Module, Module, Boolean> reflectivelyReads
-        = new WeakPairMap<>();
-
-
-    /**
-     * Indicates if this module reads the given module. This method returns
-     * {@code true} if invoked to test if this module reads itself. It also
-     * returns {@code true} if invoked on an unnamed module (as unnamed
-     * modules read all modules).
-     *
-     * @param  other
-     *         The other module
-     *
-     * @return {@code true} if this module reads {@code other}
-     *
-     * @see #addReads(Module)
-     */
-    public boolean canRead(Module other) {
-        Objects.requireNonNull(other);
-
-        // an unnamed module reads all modules
-        if (!this.isNamed())
-            return true;
-
-        // all modules read themselves
-        if (other == this)
-            return true;
-
-        // check if this module reads other
-        if (other.isNamed()) {
-            Set<Module> reads = this.reads; // volatile read
-            if (reads != null && reads.contains(other))
-                return true;
-        }
-
-        // check if this module reads the other module reflectively
-        if (reflectivelyReads.containsKeyPair(this, other))
-            return true;
-
-        // if other is an unnamed module then check if this module reads
-        // all unnamed modules
-        if (!other.isNamed()
-            && reflectivelyReads.containsKeyPair(this, ALL_UNNAMED_MODULE))
-            return true;
-
-        return false;
-    }
-
-    /**
-     * If the caller's module is this module then update this module to read
-     * the given module.
-     *
-     * This method is a no-op if {@code other} is this module (all modules read
-     * themselves), this module is an unnamed module (as unnamed modules read
-     * all modules), or this module already reads {@code other}.
-     *
-     * @implNote <em>Read edges</em> added by this method are <em>weak</em> and
-     * do not prevent {@code other} from being GC'ed when this module is
-     * strongly reachable.
-     *
-     * @param  other
-     *         The other module
-     *
-     * @return this module
-     *
-     * @throws IllegalCallerException
-     *         If this is a named module and the caller's module is not this
-     *         module
-     *
-     * @see #canRead
-     */
-    @CallerSensitive
-    public Module addReads(Module other) {
-        Objects.requireNonNull(other);
-        if (this.isNamed()) {
-            Module caller = Reflection.getCallerClass().getModule();
-            if (caller != this) {
-                throw new IllegalCallerException(caller + " != " + this);
-            }
-            implAddReads(other, true);
-        }
-        return this;
-    }
-
-    /**
-     * Updates this module to read another module.
-     *
-     * @apiNote This method is for Proxy use and white-box testing.
-     */
-    void implAddReads(Module other) {
-        implAddReads(other, true);
-    }
-
-    /**
-     * Updates this module to read another module without notifying the VM.
-     *
-     * @apiNote This method is for VM white-box testing.
-     */
-    void implAddReadsNoSync(Module other) {
-        implAddReads(other, false);
-    }
-
-    /**
-     * Makes the given {@code Module} readable to this module.
-     *
-     * If {@code syncVM} is {@code true} then the VM is notified.
-     */
-    private void implAddReads(Module other, boolean syncVM) {
-        if (!canRead(other)) {
-            // update VM first, just in case it fails
-            if (syncVM) {
-                if (other == ALL_UNNAMED_MODULE) {
-                    addReads0(this, null);
-                } else {
-                    addReads0(this, other);
-                }
-            }
-
-            // add reflective read
-            reflectivelyReads.putIfAbsent(this, other, Boolean.TRUE);
-        }
-    }
-
-
-    // -- exported and open packages --
-
-    // the packages are open to other modules, can be null
-    // if the value contains EVERYONE_MODULE then the package is open to all
-    private volatile Map<String, Set<Module>> openPackages;
-
-    // the packages that are exported, can be null
-    // if the value contains EVERYONE_MODULE then the package is exported to all
-    private volatile Map<String, Set<Module>> exportedPackages;
-
-    // additional exports or opens added at run-time
-    // this module (1st key), other module (2nd key)
-    // (package name, open?) (value)
-    private static final WeakPairMap<Module, Module, Map<String, Boolean>>
-        reflectivelyExports = new WeakPairMap<>();
-
-
-    /**
-     * Returns {@code true} if this module exports the given package to at
-     * least the given module.
-     *
-     * <p> This method returns {@code true} if invoked to test if a package in
-     * this module is exported to itself. It always returns {@code true} when
-     * invoked on an unnamed module. A package that is {@link #isOpen open} to
-     * the given module is considered exported to that module at run-time and
-     * so this method returns {@code true} if the package is open to the given
-     * module. </p>
-     *
-     * <p> This method does not check if the given module reads this module. </p>
-     *
-     * @param  pn
-     *         The package name
-     * @param  other
-     *         The other module
-     *
-     * @return {@code true} if this module exports the package to at least the
-     *         given module
-     *
-     * @see ModuleDescriptor#exports()
-     * @see #addExports(String,Module)
-     */
-    public boolean isExported(String pn, Module other) {
-        Objects.requireNonNull(pn);
-        Objects.requireNonNull(other);
-        return implIsExportedOrOpen(pn, other, /*open*/false);
-    }
-
-    /**
-     * Returns {@code true} if this module has <em>opened</em> a package to at
-     * least the given module.
-     *
-     * <p> This method returns {@code true} if invoked to test if a package in
-     * this module is open to itself. It returns {@code true} when invoked on an
-     * {@link ModuleDescriptor#isOpen open} module with a package in the module.
-     * It always returns {@code true} when invoked on an unnamed module. </p>
-     *
-     * <p> This method does not check if the given module reads this module. </p>
-     *
-     * @param  pn
-     *         The package name
-     * @param  other
-     *         The other module
-     *
-     * @return {@code true} if this module has <em>opened</em> the package
-     *         to at least the given module
-     *
-     * @see ModuleDescriptor#opens()
-     * @see #addOpens(String,Module)
-     * @see AccessibleObject#setAccessible(boolean)
-     * @see java.lang.invoke.MethodHandles#privateLookupIn
-     */
-    public boolean isOpen(String pn, Module other) {
-        Objects.requireNonNull(pn);
-        Objects.requireNonNull(other);
-        return implIsExportedOrOpen(pn, other, /*open*/true);
-    }
-
-    /**
-     * Returns {@code true} if this module exports the given package
-     * unconditionally.
-     *
-     * <p> This method always returns {@code true} when invoked on an unnamed
-     * module. A package that is {@link #isOpen(String) opened} unconditionally
-     * is considered exported unconditionally at run-time and so this method
-     * returns {@code true} if the package is opened unconditionally. </p>
-     *
-     * <p> This method does not check if the given module reads this module. </p>
-     *
-     * @param  pn
-     *         The package name
-     *
-     * @return {@code true} if this module exports the package unconditionally
-     *
-     * @see ModuleDescriptor#exports()
-     */
-    public boolean isExported(String pn) {
-        Objects.requireNonNull(pn);
-        return implIsExportedOrOpen(pn, EVERYONE_MODULE, /*open*/false);
-    }
-
-    /**
-     * Returns {@code true} if this module has <em>opened</em> a package
-     * unconditionally.
-     *
-     * <p> This method always returns {@code true} when invoked on an unnamed
-     * module. Additionally, it always returns {@code true} when invoked on an
-     * {@link ModuleDescriptor#isOpen open} module with a package in the
-     * module. </p>
-     *
-     * <p> This method does not check if the given module reads this module. </p>
-     *
-     * @param  pn
-     *         The package name
-     *
-     * @return {@code true} if this module has <em>opened</em> the package
-     *         unconditionally
-     *
-     * @see ModuleDescriptor#opens()
-     */
-    public boolean isOpen(String pn) {
-        Objects.requireNonNull(pn);
-        return implIsExportedOrOpen(pn, EVERYONE_MODULE, /*open*/true);
-    }
-
-
-    /**
-     * Returns {@code true} if this module exports or opens the given package
-     * to the given module. If the other module is {@code EVERYONE_MODULE} then
-     * this method tests if the package is exported or opened unconditionally.
-     */
-    private boolean implIsExportedOrOpen(String pn, Module other, boolean open) {
-        // all packages in unnamed modules are open
-        if (!isNamed())
-            return true;
-
-        // all packages are exported/open to self
-        if (other == this && containsPackage(pn))
-            return true;
-
-        // all packages in open and automatic modules are open
-        if (descriptor.isOpen() || descriptor.isAutomatic())
-            return containsPackage(pn);
-
-        // exported/opened via module declaration/descriptor
-        if (isStaticallyExportedOrOpen(pn, other, open))
-            return true;
-
-        // exported via addExports/addOpens
-        if (isReflectivelyExportedOrOpen(pn, other, open))
-            return true;
-
-        // not exported or open to other
-        return false;
-    }
-
-    /**
-     * Returns {@code true} if this module exports or opens a package to
-     * the given module via its module declaration.
-     */
-    private boolean isStaticallyExportedOrOpen(String pn, Module other, boolean open) {
-        // package is open to everyone or <other>
-        Map<String, Set<Module>> openPackages = this.openPackages;
-        if (openPackages != null) {
-            Set<Module> targets = openPackages.get(pn);
-            if (targets != null) {
-                if (targets.contains(EVERYONE_MODULE))
-                    return true;
-                if (other != EVERYONE_MODULE && targets.contains(other))
-                    return true;
-            }
-        }
-
-        if (!open) {
-            // package is exported to everyone or <other>
-            Map<String, Set<Module>> exportedPackages = this.exportedPackages;
-            if (exportedPackages != null) {
-                Set<Module> targets = exportedPackages.get(pn);
-                if (targets != null) {
-                    if (targets.contains(EVERYONE_MODULE))
-                        return true;
-                    if (other != EVERYONE_MODULE && targets.contains(other))
-                        return true;
-                }
-            }
-        }
-
-        return false;
-    }
-
-
-    /**
-     * Returns {@code true} if this module reflectively exports or opens given
-     * package package to the given module.
-     */
-    private boolean isReflectivelyExportedOrOpen(String pn, Module other, boolean open) {
-        // exported or open to all modules
-        Map<String, Boolean> exports = reflectivelyExports.get(this, EVERYONE_MODULE);
-        if (exports != null) {
-            Boolean b = exports.get(pn);
-            if (b != null) {
-                boolean isOpen = b.booleanValue();
-                if (!open || isOpen) return true;
-            }
-        }
-
-        if (other != EVERYONE_MODULE) {
-
-            // exported or open to other
-            exports = reflectivelyExports.get(this, other);
-            if (exports != null) {
-                Boolean b = exports.get(pn);
-                if (b != null) {
-                    boolean isOpen = b.booleanValue();
-                    if (!open || isOpen) return true;
-                }
-            }
-
-            // other is an unnamed module && exported or open to all unnamed
-            if (!other.isNamed()) {
-                exports = reflectivelyExports.get(this, ALL_UNNAMED_MODULE);
-                if (exports != null) {
-                    Boolean b = exports.get(pn);
-                    if (b != null) {
-                        boolean isOpen = b.booleanValue();
-                        if (!open || isOpen) return true;
-                    }
-                }
-            }
-
-        }
-
-        return false;
-    }
-
-
-    /**
-     * If the caller's module is this module then update this module to export
-     * the given package to the given module.
-     *
-     * <p> This method has no effect if the package is already exported (or
-     * <em>open</em>) to the given module. </p>
-     *
-     * @apiNote As specified in section 5.4.3 of the <cite>The Java&trade;
-     * Virtual Machine Specification </cite>, if an attempt to resolve a
-     * symbolic reference fails because of a linkage error, then subsequent
-     * attempts to resolve the reference always fail with the same error that
-     * was thrown as a result of the initial resolution attempt.
-     *
-     * @param  pn
-     *         The package name
-     * @param  other
-     *         The module
-     *
-     * @return this module
-     *
-     * @throws IllegalArgumentException
-     *         If {@code pn} is {@code null}, or this is a named module and the
-     *         package {@code pn} is not a package in this module
-     * @throws IllegalCallerException
-     *         If this is a named module and the caller's module is not this
-     *         module
-     *
-     * @jvms 5.4.3 Resolution
-     * @see #isExported(String,Module)
-     */
-    @CallerSensitive
-    public Module addExports(String pn, Module other) {
-        if (pn == null)
-            throw new IllegalArgumentException("package is null");
-        Objects.requireNonNull(other);
-
-        if (isNamed()) {
-            Module caller = Reflection.getCallerClass().getModule();
-            if (caller != this) {
-                throw new IllegalCallerException(caller + " != " + this);
-            }
-            implAddExportsOrOpens(pn, other, /*open*/false, /*syncVM*/true);
-        }
-
-        return this;
-    }
-
-    /**
-     * If this module has <em>opened</em> a package to at least the caller
-     * module then update this module to open the package to the given module.
-     * Opening a package with this method allows all types in the package,
-     * and all their members, not just public types and their public members,
-     * to be reflected on by the given module when using APIs that support
-     * private access or a way to bypass or suppress default Java language
-     * access control checks.
-     *
-     * <p> This method has no effect if the package is already <em>open</em>
-     * to the given module. </p>
-     *
-     * @param  pn
-     *         The package name
-     * @param  other
-     *         The module
-     *
-     * @return this module
-     *
-     * @throws IllegalArgumentException
-     *         If {@code pn} is {@code null}, or this is a named module and the
-     *         package {@code pn} is not a package in this module
-     * @throws IllegalCallerException
-     *         If this is a named module and this module has not opened the
-     *         package to at least the caller's module
-     *
-     * @see #isOpen(String,Module)
-     * @see AccessibleObject#setAccessible(boolean)
-     * @see java.lang.invoke.MethodHandles#privateLookupIn
-     */
-    @CallerSensitive
-    public Module addOpens(String pn, Module other) {
-        if (pn == null)
-            throw new IllegalArgumentException("package is null");
-        Objects.requireNonNull(other);
-
-        if (isNamed()) {
-            Module caller = Reflection.getCallerClass().getModule();
-            if (caller != this && !isOpen(pn, caller))
-                throw new IllegalCallerException(pn + " is not open to " + caller);
-            implAddExportsOrOpens(pn, other, /*open*/true, /*syncVM*/true);
-        }
-
-        return this;
-    }
-
-
-    /**
-     * Updates the exports so that package {@code pn} is exported to module
-     * {@code other} but without notifying the VM.
-     *
-     * @apiNote This method is for VM white-box testing.
-     */
-    void implAddExportsNoSync(String pn, Module other) {
-        if (other == null)
-            other = EVERYONE_MODULE;
-        implAddExportsOrOpens(pn.replace('/', '.'), other, false, false);
-    }
-
-    /**
-     * Updates the exports so that package {@code pn} is exported to module
-     * {@code other}.
-     *
-     * @apiNote This method is for white-box testing.
-     */
-    void implAddExports(String pn, Module other) {
-        implAddExportsOrOpens(pn, other, false, true);
-    }
-
-    /**
-     * Updates the module to open package {@code pn} to module {@code other}.
-     *
-     * @apiNote This method is for white-box tests and jtreg
-     */
-    void implAddOpens(String pn, Module other) {
-        implAddExportsOrOpens(pn, other, true, true);
-    }
-
-    /**
-     * Updates a module to export or open a module to another module.
-     *
-     * If {@code syncVM} is {@code true} then the VM is notified.
-     */
-    private void implAddExportsOrOpens(String pn,
-                                       Module other,
-                                       boolean open,
-                                       boolean syncVM) {
-        Objects.requireNonNull(other);
-        Objects.requireNonNull(pn);
-
-        // all packages are open in unnamed, open, and automatic modules
-        if (!isNamed() || descriptor.isOpen() || descriptor.isAutomatic())
-            return;
-
-        // nothing to do if already exported/open to other
-        if (implIsExportedOrOpen(pn, other, open))
-            return;
-
-        // can only export a package in the module
-        if (!containsPackage(pn)) {
-            throw new IllegalArgumentException("package " + pn
-                                               + " not in contents");
-        }
-
-        // update VM first, just in case it fails
-        if (syncVM) {
-            if (other == EVERYONE_MODULE) {
-                addExportsToAll0(this, pn);
-            } else if (other == ALL_UNNAMED_MODULE) {
-                addExportsToAllUnnamed0(this, pn);
-            } else {
-                addExports0(this, pn, other);
-            }
-        }
-
-        // add package name to reflectivelyExports if absent
-        Map<String, Boolean> map = reflectivelyExports
-            .computeIfAbsent(this, other,
-                             (m1, m2) -> new ConcurrentHashMap<>());
-
-        if (open) {
-            map.put(pn, Boolean.TRUE);  // may need to promote from FALSE to TRUE
-        } else {
-            map.putIfAbsent(pn, Boolean.FALSE);
-        }
-    }
-
-
-    // -- services --
-
-    // additional service type (2nd key) that some module (1st key) uses
-    private static final WeakPairMap<Module, Class<?>, Boolean> reflectivelyUses
-        = new WeakPairMap<>();
-
-    /**
-     * If the caller's module is this module then update this module to add a
-     * service dependence on the given service type. This method is intended
-     * for use by frameworks that invoke {@link java.util.ServiceLoader
-     * ServiceLoader} on behalf of other modules or where the framework is
-     * passed a reference to the service type by other code. This method is
-     * a no-op when invoked on an unnamed module or an automatic module.
-     *
-     * <p> This method does not cause {@link Configuration#resolveAndBind
-     * resolveAndBind} to be re-run. </p>
-     *
-     * @param  service
-     *         The service type
-     *
-     * @return this module
-     *
-     * @throws IllegalCallerException
-     *         If this is a named module and the caller's module is not this
-     *         module
-     *
-     * @see #canUse(Class)
-     * @see ModuleDescriptor#uses()
-     */
-    @CallerSensitive
-    public Module addUses(Class<?> service) {
-        Objects.requireNonNull(service);
-
-        if (isNamed() && !descriptor.isAutomatic()) {
-            Module caller = Reflection.getCallerClass().getModule();
-            if (caller != this) {
-                throw new IllegalCallerException(caller + " != " + this);
-            }
-            implAddUses(service);
-        }
-
-        return this;
-    }
-
-    /**
-     * Update this module to add a service dependence on the given service
-     * type.
-     */
-    void implAddUses(Class<?> service) {
-        if (!canUse(service)) {
-            reflectivelyUses.putIfAbsent(this, service, Boolean.TRUE);
-        }
-    }
-
-
-    /**
-     * Indicates if this module has a service dependence on the given service
-     * type. This method always returns {@code true} when invoked on an unnamed
-     * module or an automatic module.
-     *
-     * @param  service
-     *         The service type
-     *
-     * @return {@code true} if this module uses service type {@code st}
-     *
-     * @see #addUses(Class)
-     */
-    public boolean canUse(Class<?> service) {
-        Objects.requireNonNull(service);
-
-        if (!isNamed())
-            return true;
-
-        if (descriptor.isAutomatic())
-            return true;
-
-        // uses was declared
-        if (descriptor.uses().contains(service.getName()))
-            return true;
-
-        // uses added via addUses
-        return reflectivelyUses.containsKeyPair(this, service);
-    }
-
-
-
-    // -- packages --
-
-    // Additional packages that are added to the module at run-time.
-    private volatile Map<String, Boolean> extraPackages;
-
-    private boolean containsPackage(String pn) {
-        if (descriptor.packages().contains(pn))
-            return true;
-        Map<String, Boolean> extraPackages = this.extraPackages;
-        if (extraPackages != null && extraPackages.containsKey(pn))
-            return true;
-        return false;
-    }
-
-
-    /**
-     * Returns an array of the package names of the packages in this module.
-     *
-     * <p> For named modules, the returned array contains an element for each
-     * package in the module. </p>
-     *
-     * <p> For unnamed modules, this method is the equivalent to invoking the
-     * {@link ClassLoader#getDefinedPackages() getDefinedPackages} method of
-     * this module's class loader and returning the array of package names. </p>
-     *
-     * <p> A package name appears at most once in the returned array. </p>
-     *
-     * @apiNote This method returns an array rather than a {@code Set} for
-     * consistency with other {@code java.lang.reflect} types.
-     *
-     * @return an array of the package names of the packages in this module
-     */
-    public String[] getPackages() {
-        if (isNamed()) {
-
-            Set<String> packages = descriptor.packages();
-            Map<String, Boolean> extraPackages = this.extraPackages;
-            if (extraPackages == null) {
-                return packages.toArray(new String[0]);
-            } else {
-                return Stream.concat(packages.stream(),
-                                     extraPackages.keySet().stream())
-                        .toArray(String[]::new);
-            }
-
-        } else {
-            // unnamed module
-            Stream<Package> packages;
-            if (loader == null) {
-                packages = BootLoader.packages();
-            } else {
-                packages = SharedSecrets.getJavaLangAccess().packages(loader);
-            }
-            return packages.map(Package::getName).toArray(String[]::new);
-        }
-    }
-
-    /**
-     * Add a package to this module without notifying the VM.
-     *
-     * @apiNote This method is VM white-box testing.
-     */
-    void implAddPackageNoSync(String pn) {
-        implAddPackage(pn.replace('/', '.'), false);
-    }
-
-    /**
-     * Add a package to this module.
-     *
-     * If {@code syncVM} is {@code true} then the VM is notified. This method is
-     * a no-op if this is an unnamed module or the module already contains the
-     * package.
-     *
-     * @throws IllegalArgumentException if the package name is not legal
-     * @throws IllegalStateException if the package is defined to another module
-     */
-    private void implAddPackage(String pn, boolean syncVM) {
-        // no-op if unnamed module
-        if (!isNamed())
-            return;
-
-        // no-op if module contains the package
-        if (containsPackage(pn))
-            return;
-
-        // check package name is legal for named modules
-        if (pn.isEmpty())
-            throw new IllegalArgumentException("Cannot add <unnamed> package");
-        for (int i=0; i<pn.length(); i++) {
-            char c = pn.charAt(i);
-            if (c == '/' || c == ';' || c == '[') {
-                throw new IllegalArgumentException("Illegal character: " + c);
-            }
-        }
-
-        // create extraPackages if needed
-        Map<String, Boolean> extraPackages = this.extraPackages;
-        if (extraPackages == null) {
-            synchronized (this) {
-                extraPackages = this.extraPackages;
-                if (extraPackages == null)
-                    this.extraPackages = extraPackages = new ConcurrentHashMap<>();
-            }
-        }
-
-        // update VM first in case it fails. This is a no-op if another thread
-        // beats us to add the package first
-        if (syncVM) {
-            // throws IllegalStateException if defined to another module
-            addPackage0(this, pn);
-            if (descriptor.isOpen() || descriptor.isAutomatic()) {
-                addExportsToAll0(this, pn);
-            }
-        }
-        extraPackages.putIfAbsent(pn, Boolean.TRUE);
-    }
-
-
-    // -- creating Module objects --
-
-    /**
-     * Defines all module in a configuration to the runtime.
-     *
-     * @return a map of module name to runtime {@code Module}
-     *
-     * @throws IllegalArgumentException
-     *         If defining any of the modules to the VM fails
-     */
-    static Map<String, Module> defineModules(Configuration cf,
-                                             Function<String, ClassLoader> clf,
-                                             Layer layer)
-    {
-        Map<String, Module> nameToModule = new HashMap<>();
-        Map<String, ClassLoader> moduleToLoader = new HashMap<>();
-
-        boolean isBootLayer = (Layer.boot() == null);
-        Set<ClassLoader> loaders = new HashSet<>();
-
-        // map each module to a class loader
-        for (ResolvedModule resolvedModule : cf.modules()) {
-            String name = resolvedModule.name();
-            ClassLoader loader = clf.apply(name);
-            if (loader != null) {
-                moduleToLoader.put(name, loader);
-                loaders.add(loader);
-            } else if (!isBootLayer) {
-                throw new IllegalArgumentException("loader can't be 'null'");
-            }
-        }
-
-        // define each module in the configuration to the VM
-        for (ResolvedModule resolvedModule : cf.modules()) {
-            ModuleReference mref = resolvedModule.reference();
-            ModuleDescriptor descriptor = mref.descriptor();
-            String name = descriptor.name();
-            URI uri = mref.location().orElse(null);
-            ClassLoader loader = moduleToLoader.get(resolvedModule.name());
-            Module m;
-            if (loader == null && isBootLayer && name.equals("java.base")) {
-                // java.base is already defined to the VM
-                m = Object.class.getModule();
-            } else {
-                m = new Module(layer, loader, descriptor, uri);
-            }
-            nameToModule.put(name, m);
-            moduleToLoader.put(name, loader);
-        }
-
-        // setup readability and exports
-        for (ResolvedModule resolvedModule : cf.modules()) {
-            ModuleReference mref = resolvedModule.reference();
-            ModuleDescriptor descriptor = mref.descriptor();
-
-            String mn = descriptor.name();
-            Module m = nameToModule.get(mn);
-            assert m != null;
-
-            // reads
-            Set<Module> reads = new HashSet<>();
-
-            // name -> source Module when in parent layer
-            Map<String, Module> nameToSource = Collections.emptyMap();
-
-            for (ResolvedModule other : resolvedModule.reads()) {
-                Module m2 = null;
-                if (other.configuration() == cf) {
-                    // this configuration
-                    m2 = nameToModule.get(other.name());
-                    assert m2 != null;
-                } else {
-                    // parent layer
-                    for (Layer parent: layer.parents()) {
-                        m2 = findModule(parent, other);
-                        if (m2 != null)
-                            break;
-                    }
-                    assert m2 != null;
-                    if (nameToSource.isEmpty())
-                        nameToSource = new HashMap<>();
-                    nameToSource.put(other.name(), m2);
-                }
-                reads.add(m2);
-
-                // update VM view
-                addReads0(m, m2);
-            }
-            m.reads = reads;
-
-            // automatic modules read all unnamed modules
-            if (descriptor.isAutomatic()) {
-                m.implAddReads(ALL_UNNAMED_MODULE, true);
-            }
-
-            // exports and opens
-            initExportsAndOpens(m, nameToSource, nameToModule, layer.parents());
-        }
-
-        // register the modules in the boot layer
-        if (isBootLayer) {
-            for (ResolvedModule resolvedModule : cf.modules()) {
-                ModuleReference mref = resolvedModule.reference();
-                ModuleDescriptor descriptor = mref.descriptor();
-                if (!descriptor.provides().isEmpty()) {
-                    String name = descriptor.name();
-                    Module m = nameToModule.get(name);
-                    ClassLoader loader = moduleToLoader.get(name);
-                    ServicesCatalog catalog;
-                    if (loader == null) {
-                        catalog = BootLoader.getServicesCatalog();
-                    } else {
-                        catalog = ServicesCatalog.getServicesCatalog(loader);
-                    }
-                    catalog.register(m);
-                }
-            }
-        }
-
-        // record that there is a layer with modules defined to the class loader
-        for (ClassLoader loader : loaders) {
-            layer.bindToLoader(loader);
-        }
-
-        return nameToModule;
-    }
-
-
-    /**
-     * Find the runtime Module corresponding to the given ResolvedModule
-     * in the given parent layer (or its parents).
-     */
-    private static Module findModule(Layer parent, ResolvedModule resolvedModule) {
-        Configuration cf = resolvedModule.configuration();
-        String dn = resolvedModule.name();
-        return parent.layers()
-                .filter(l -> l.configuration() == cf)
-                .findAny()
-                .map(layer -> {
-                    Optional<Module> om = layer.findModule(dn);
-                    assert om.isPresent() : dn + " not found in layer";
-                    Module m = om.get();
-                    assert m.getLayer() == layer : m + " not in expected layer";
-                    return m;
-                })
-                .orElse(null);
-    }
-
-
-    /**
-     * Initialize the maps of exported and open packages for module m.
-     */
-    private static void initExportsAndOpens(Module m,
-                                            Map<String, Module> nameToSource,
-                                            Map<String, Module> nameToModule,
-                                            List<Layer> parents) {
-        // The VM doesn't special case open or automatic modules so need to
-        // export all packages
-        ModuleDescriptor descriptor = m.getDescriptor();
-        if (descriptor.isOpen() || descriptor.isAutomatic()) {
-            assert descriptor.opens().isEmpty();
-            for (String source : descriptor.packages()) {
-                addExportsToAll0(m, source);
-            }
-            return;
-        }
-
-        Map<String, Set<Module>> openPackages = new HashMap<>();
-        Map<String, Set<Module>> exportedPackages = new HashMap<>();
-
-        // process the open packages first
-        for (Opens opens : descriptor.opens()) {
-            String source = opens.source();
-
-            if (opens.isQualified()) {
-                // qualified opens
-                Set<Module> targets = new HashSet<>();
-                for (String target : opens.targets()) {
-                    Module m2 = findModule(target, nameToSource, nameToModule, parents);
-                    if (m2 != null) {
-                        addExports0(m, source, m2);
-                        targets.add(m2);
-                    }
-                }
-                if (!targets.isEmpty()) {
-                    openPackages.put(source, targets);
-                }
-            } else {
-                // unqualified opens
-                addExportsToAll0(m, source);
-                openPackages.put(source, EVERYONE_SET);
-            }
-        }
-
-        // next the exports, skipping exports when the package is open
-        for (Exports exports : descriptor.exports()) {
-            String source = exports.source();
-
-            // skip export if package is already open to everyone
-            Set<Module> openToTargets = openPackages.get(source);
-            if (openToTargets != null && openToTargets.contains(EVERYONE_MODULE))
-                continue;
-
-            if (exports.isQualified()) {
-                // qualified exports
-                Set<Module> targets = new HashSet<>();
-                for (String target : exports.targets()) {
-                    Module m2 = findModule(target, nameToSource, nameToModule, parents);
-                    if (m2 != null) {
-                        // skip qualified export if already open to m2
-                        if (openToTargets == null || !openToTargets.contains(m2)) {
-                            addExports0(m, source, m2);
-                            targets.add(m2);
-                        }
-                    }
-                }
-                if (!targets.isEmpty()) {
-                    exportedPackages.put(source, targets);
-                }
-
-            } else {
-                // unqualified exports
-                addExportsToAll0(m, source);
-                exportedPackages.put(source, EVERYONE_SET);
-            }
-        }
-
-        if (!openPackages.isEmpty())
-            m.openPackages = openPackages;
-        if (!exportedPackages.isEmpty())
-            m.exportedPackages = exportedPackages;
-    }
-
-    /**
-     * Find the runtime Module with the given name. The module name is the
-     * name of a target module in a qualified exports or opens directive.
-     *
-     * @param target The target module to find
-     * @param nameToSource The modules in parent layers that are read
-     * @param nameToModule The modules in the layer under construction
-     * @param parents The parent layers
-     */
-    private static Module findModule(String target,
-                                     Map<String, Module> nameToSource,
-                                     Map<String, Module> nameToModule,
-                                     List<Layer> parents) {
-        Module m = nameToSource.get(target);
-        if (m == null) {
-            m = nameToModule.get(target);
-            if (m == null) {
-                for (Layer parent : parents) {
-                    m = parent.findModule(target).orElse(null);
-                    if (m != null) break;
-                }
-            }
-        }
-        return m;
-    }
-
-
-    // -- annotations --
-
-    /**
-     * {@inheritDoc}
-     * This method returns {@code null} when invoked on an unnamed module.
-     */
-    @Override
-    public <T extends Annotation> T getAnnotation(Class<T> annotationClass) {
-        return moduleInfoClass().getDeclaredAnnotation(annotationClass);
-    }
-
-    /**
-     * {@inheritDoc}
-     * This method returns an empty array when invoked on an unnamed module.
-     */
-    @Override
-    public Annotation[] getAnnotations() {
-        return moduleInfoClass().getAnnotations();
-    }
-
-    /**
-     * {@inheritDoc}
-     * This method returns an empty array when invoked on an unnamed module.
-     */
-    @Override
-    public Annotation[] getDeclaredAnnotations() {
-        return moduleInfoClass().getDeclaredAnnotations();
-    }
-
-    // cached class file with annotations
-    private volatile Class<?> moduleInfoClass;
-
-    private Class<?> moduleInfoClass() {
-        Class<?> clazz = this.moduleInfoClass;
-        if (clazz != null)
-            return clazz;
-
-        synchronized (this) {
-            clazz = this.moduleInfoClass;
-            if (clazz == null) {
-                if (isNamed()) {
-                    PrivilegedAction<Class<?>> pa = this::loadModuleInfoClass;
-                    clazz = AccessController.doPrivileged(pa);
-                }
-                if (clazz == null) {
-                    class DummyModuleInfo { }
-                    clazz = DummyModuleInfo.class;
-                }
-                this.moduleInfoClass = clazz;
-            }
-            return clazz;
-        }
-    }
-
-    private Class<?> loadModuleInfoClass() {
-        Class<?> clazz = null;
-        try (InputStream in = getResourceAsStream("module-info.class")) {
-            if (in != null)
-                clazz = loadModuleInfoClass(in);
-        } catch (Exception ignore) { }
-        return clazz;
-    }
-
-    /**
-     * Loads module-info.class as a package-private interface in a class loader
-     * that is a child of this module's class loader.
-     */
-    private Class<?> loadModuleInfoClass(InputStream in) throws IOException {
-        final String MODULE_INFO = "module-info";
-
-        ClassWriter cw = new ClassWriter(ClassWriter.COMPUTE_MAXS
-                                         + ClassWriter.COMPUTE_FRAMES);
-
-        ClassVisitor cv = new ClassVisitor(Opcodes.ASM5, cw) {
-            @Override
-            public void visit(int version,
-                              int access,
-                              String name,
-                              String signature,
-                              String superName,
-                              String[] interfaces) {
-                cw.visit(version,
-                        Opcodes.ACC_INTERFACE
-                            + Opcodes.ACC_ABSTRACT
-                            + Opcodes.ACC_SYNTHETIC,
-                        MODULE_INFO,
-                        null,
-                        "java/lang/Object",
-                        null);
-            }
-            @Override
-            public AnnotationVisitor visitAnnotation(String desc, boolean visible) {
-                // keep annotations
-                return super.visitAnnotation(desc, visible);
-            }
-            @Override
-            public void visitAttribute(Attribute attr) {
-                // drop non-annotation attributes
-            }
-        };
-
-        ClassReader cr = new ClassReader(in);
-        cr.accept(cv, 0);
-        byte[] bytes = cw.toByteArray();
-
-        ClassLoader cl = new ClassLoader(loader) {
-            @Override
-            protected Class<?> findClass(String cn)throws ClassNotFoundException {
-                if (cn.equals(MODULE_INFO)) {
-                    return super.defineClass(cn, bytes, 0, bytes.length);
-                } else {
-                    throw new ClassNotFoundException(cn);
-                }
-            }
-        };
-
-        try {
-            return cl.loadClass(MODULE_INFO);
-        } catch (ClassNotFoundException e) {
-            throw new InternalError(e);
-        }
-    }
-
-
-    // -- misc --
-
-
-    /**
-     * Returns an input stream for reading a resource in this module.
-     * The {@code name} parameter is a {@code '/'}-separated path name that
-     * identifies the resource. As with {@link Class#getResourceAsStream
-     * Class.getResourceAsStream}, this method delegates to the module's class
-     * loader {@link ClassLoader#findResource(String,String)
-     * findResource(String,String)} method, invoking it with the module name
-     * (or {@code null} when the module is unnamed) and the name of the
-     * resource. If the resource name has a leading slash then it is dropped
-     * before delegation.
-     *
-     * <p> A resource in a named module may be <em>encapsulated</em> so that
-     * it cannot be located by code in other modules. Whether a resource can be
-     * located or not is determined as follows: </p>
-     *
-     * <ul>
-     *     <li> If the resource name ends with  "{@code .class}" then it is not
-     *     encapsulated. </li>
-     *
-     *     <li> A <em>package name</em> is derived from the resource name. If
-     *     the package name is a {@link #getPackages() package} in the module
-     *     then the resource can only be located by the caller of this method
-     *     when the package is {@link #isOpen(String,Module) open} to at least
-     *     the caller's module. If the resource is not in a package in the module
-     *     then the resource is not encapsulated. </li>
-     * </ul>
-     *
-     * <p> In the above, the <em>package name</em> for a resource is derived
-     * from the subsequence of characters that precedes the last {@code '/'} in
-     * the name and then replacing each {@code '/'} character in the subsequence
-     * with {@code '.'}. A leading slash is ignored when deriving the package
-     * name. As an example, the package name derived for a resource named
-     * "{@code a/b/c/foo.properties}" is "{@code a.b.c}". A resource name
-     * with the name "{@code META-INF/MANIFEST.MF}" is never encapsulated
-     * because "{@code META-INF}" is not a legal package name. </p>
-     *
-     * <p> This method returns {@code null} if the resource is not in this
-     * module, the resource is encapsulated and cannot be located by the caller,
-     * or access to the resource is denied by the security manager. </p>
-     *
-     * @param  name
-     *         The resource name
-     *
-     * @return An input stream for reading the resource or {@code null}
-     *
-     * @throws IOException
-     *         If an I/O error occurs
-     *
-     * @see Class#getResourceAsStream(String)
-     */
-    @CallerSensitive
-    public InputStream getResourceAsStream(String name) throws IOException {
-        if (name.startsWith("/")) {
-            name = name.substring(1);
-        }
-
-        if (isNamed() && Resources.canEncapsulate(name)) {
-            Module caller = Reflection.getCallerClass().getModule();
-            if (caller != this && caller != Object.class.getModule()) {
-                // ignore packages added for proxies via addPackage
-                Set<String> packages = getDescriptor().packages();
-                String pn = Resources.toPackageName(name);
-                if (packages.contains(pn) && !isOpen(pn, caller)) {
-                    // resource is in package not open to caller
-                    return null;
-                }
-            }
-        }
-
-        String mn = this.name;
-
-        // special-case built-in class loaders to avoid URL connection
-        if (loader == null) {
-            return BootLoader.findResourceAsStream(mn, name);
-        } else if (loader instanceof BuiltinClassLoader) {
-            return ((BuiltinClassLoader) loader).findResourceAsStream(mn, name);
-        }
-
-        // locate resource in module
-        JavaLangAccess jla = SharedSecrets.getJavaLangAccess();
-        URL url = jla.findResource(loader, mn, name);
-        if (url != null) {
-            try {
-                return url.openStream();
-            } catch (SecurityException e) { }
-        }
-
-        return null;
-    }
-
-    /**
-     * Returns the string representation of this module. For a named module,
-     * the representation is the string {@code "module"}, followed by a space,
-     * and then the module name. For an unnamed module, the representation is
-     * the string {@code "unnamed module"}, followed by a space, and then an
-     * implementation specific string that identifies the unnamed module.
-     *
-     * @return The string representation of this module
-     */
-    @Override
-    public String toString() {
-        if (isNamed()) {
-            return "module " + name;
-        } else {
-            String id = Integer.toHexString(System.identityHashCode(this));
-            return "unnamed module @" + id;
-        }
-    }
-
-
-    // -- native methods --
-
-    // JVM_DefineModule
-    private static native void defineModule0(Module module,
-                                             boolean isOpen,
-                                             String version,
-                                             String location,
-                                             String[] pns);
-
-    // JVM_AddReadsModule
-    private static native void addReads0(Module from, Module to);
-
-    // JVM_AddModuleExports
-    private static native void addExports0(Module from, String pn, Module to);
-
-    // JVM_AddModuleExportsToAll
-    private static native void addExportsToAll0(Module from, String pn);
-
-    // JVM_AddModuleExportsToAllUnnamed
-    private static native void addExportsToAllUnnamed0(Module from, String pn);
-
-    // JVM_AddModulePackage
-    private static native void addPackage0(Module m, String pn);
-
-    /**
-     * Register shared secret to provide access to package-private methods
-     */
-    static {
-        SharedSecrets.setJavaLangReflectModuleAccess(
-            new JavaLangReflectModuleAccess() {
-                @Override
-                public Module defineUnnamedModule(ClassLoader loader) {
-                    return new Module(loader);
-                }
-                @Override
-                public Module defineModule(ClassLoader loader,
-                                           ModuleDescriptor descriptor,
-                                           URI uri) {
-                   return new Module(null, loader, descriptor, uri);
-                }
-                @Override
-                public void addReads(Module m1, Module m2) {
-                    m1.implAddReads(m2, true);
-                }
-                @Override
-                public void addReadsAllUnnamed(Module m) {
-                    m.implAddReads(Module.ALL_UNNAMED_MODULE);
-                }
-                @Override
-                public void addExports(Module m, String pn) {
-                    m.implAddExportsOrOpens(pn, Module.EVERYONE_MODULE, false, true);
-                }
-                @Override
-                public void addExports(Module m, String pn, Module other) {
-                    m.implAddExportsOrOpens(pn, other, false, true);
-                }
-                @Override
-                public void addExportsToAllUnnamed(Module m, String pn) {
-                    m.implAddExportsOrOpens(pn, Module.ALL_UNNAMED_MODULE, false, true);
-                }
-                @Override
-                public void addOpens(Module m, String pn) {
-                    m.implAddExportsOrOpens(pn, Module.EVERYONE_MODULE, true, true);
-                }
-                @Override
-                public void addOpens(Module m, String pn, Module other) {
-                    m.implAddExportsOrOpens(pn, other, true, true);
-                }
-                @Override
-                public void addOpensToAllUnnamed(Module m, String pn) {
-                    m.implAddExportsOrOpens(pn, Module.ALL_UNNAMED_MODULE, true, true);
-                }
-                @Override
-                public void addUses(Module m, Class<?> service) {
-                    m.implAddUses(service);
-                }
-                @Override
-                public ServicesCatalog getServicesCatalog(Layer layer) {
-                    return layer.getServicesCatalog();
-                }
-                @Override
-                public Stream<Layer> layers(Layer layer) {
-                    return layer.layers();
-                }
-                @Override
-                public Stream<Layer> layers(ClassLoader loader) {
-                    return Layer.layers(loader);
-                }
-            });
-    }
-}
--- a/jdk/src/java.base/share/classes/java/lang/reflect/Proxy.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/jdk/src/java.base/share/classes/java/lang/reflect/Proxy.java	Tue Apr 18 22:25:33 2017 +0200
@@ -227,11 +227,11 @@
  * {@code Proxy.newProxyInstance} method should be used instead.
  *
  * <p>
- * A dynamic module can read the modules of all of the superinterfaces of a proxy class
- * and the modules of the types referenced by all public method signatures
+ * A dynamic module can read the modules of all of the superinterfaces of a proxy
+ * class and the modules of the types referenced by all public method signatures
  * of a proxy class.  If a superinterface or a referenced type, say {@code T},
- * is in a non-exported package, the {@linkplain java.lang.reflect.Module module}
- * of {@code T} is updated to export the package of {@code T} to the dynamic module.
+ * is in a non-exported package, the {@linkplain Module module} of {@code T} is
+ * updated to export the package of {@code T} to the dynamic module.
  *
  * <h3>Methods Duplicated in Multiple Proxy Interfaces</h3>
  *
--- a/jdk/src/java.base/share/classes/java/lang/reflect/WeakPairMap.java	Tue Apr 18 13:19:42 2017 -0400
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,354 +0,0 @@
-/*
- * 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 java.lang.reflect;
-
-import java.lang.ref.Reference;
-import java.lang.ref.ReferenceQueue;
-import java.lang.ref.WeakReference;
-import java.util.Collection;
-import java.util.Objects;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.function.BiFunction;
-
-/**
- * A WeakHashMap-like data structure that uses a pair of weakly-referenced keys
- * with identity equality semantics to associate a strongly-referenced value.
- * Unlike WeakHashMap, this data structure is thread-safe.
- *
- * @param <K1> the type of 1st key in key pair
- * @param <K2> the type of 2nd key in key pair
- * @param <V>  the type of value
- * @author Peter Levart
- */
-final class WeakPairMap<K1, K2, V> {
-
-    private final ConcurrentHashMap<Pair<K1, K2>, V> map = new ConcurrentHashMap<>();
-    private final ReferenceQueue<Object> queue = new ReferenceQueue<>();
-
-    /**
-     * Tests if the specified pair of keys are associated with a value
-     * in the WeakPairMap.
-     *
-     * @param k1 the 1st of the pair of keys
-     * @param k2 the 2nd of the pair of keys
-     * @return true if and only if the specified key pair is in this WeakPairMap,
-     * as determined by the identity comparison; false otherwise
-     * @throws NullPointerException if any of the specified keys is null
-     */
-    public boolean containsKeyPair(K1 k1, K2 k2) {
-        expungeStaleAssociations();
-        return map.containsKey(Pair.lookup(k1, k2));
-    }
-
-    /**
-     * Returns the value to which the specified pair of keys is mapped, or null
-     * if this WeakPairMap contains no mapping for the key pair.
-     * <p>More formally, if this WeakPairMap contains a mapping from a key pair
-     * {@code (_k1, _k2)} to a value {@code v} such that
-     * {@code k1 == _k1 && k2 == _k2}, then this method returns {@code v};
-     * otherwise it returns {@code null}.
-     * (There can be at most one such mapping.)
-     *
-     * @param k1 the 1st of the pair of keys for which the mapped value is to
-     *           be returned
-     * @param k2 the 2nd of the pair of keys for which the mapped value is to
-     *           be returned
-     * @return the value to which the specified key pair is mapped, or null if
-     * this map contains no mapping for the key pair
-     * @throws NullPointerException if any of the specified keys is null
-     */
-    public V get(K1 k1, K2 k2) {
-        expungeStaleAssociations();
-        return map.get(Pair.lookup(k1, k2));
-    }
-
-    /**
-     * Maps the specified key pair to the specified value in this WeakPairMap.
-     * Neither the keys nor the value can be null.
-     * <p>The value can be retrieved by calling the {@link #get} method
-     * with the the same keys (compared by identity).
-     *
-     * @param k1 the 1st of the pair of keys with which the specified value is to
-     *           be associated
-     * @param k2 the 2nd of the pair of keys with which the specified value is to
-     *           be associated
-     * @param v  value to be associated with the specified key pair
-     * @return the previous value associated with key pair, or {@code null} if
-     * there was no mapping for key pair
-     * @throws NullPointerException if any of the specified keys or value is null
-     */
-    public V put(K1 k1, K2 k2, V v) {
-        expungeStaleAssociations();
-        return map.put(Pair.weak(k1, k2, queue), v);
-    }
-
-    /**
-     * If the specified key pair is not already associated with a value,
-     * associates it with the given value and returns {@code null}, else does
-     * nothing and returns the currently associated value.
-     *
-     * @param k1 the 1st of the pair of keys with which the specified value is to
-     *           be associated
-     * @param k2 the 2nd of the pair of keys with which the specified value is to
-     *           be associated
-     * @param v  value to be associated with the specified key pair
-     * @return the previous value associated with key pair, or {@code null} if
-     * there was no mapping for key pair
-     * @throws NullPointerException if any of the specified keys or value is null
-     */
-    public V putIfAbsent(K1 k1, K2 k2, V v) {
-        expungeStaleAssociations();
-        return map.putIfAbsent(Pair.weak(k1, k2, queue), v);
-    }
-
-    /**
-     * If the specified key pair is not already associated with a value,
-     * attempts to compute its value using the given mapping function
-     * and enters it into this WeakPairMap unless {@code null}. The entire
-     * method invocation is performed atomically, so the function is
-     * applied at most once per key pair. Some attempted update operations
-     * on this WeakPairMap by other threads may be blocked while computation
-     * is in progress, so the computation should be short and simple,
-     * and must not attempt to update any other mappings of this WeakPairMap.
-     *
-     * @param k1              the 1st of the pair of keys with which the
-     *                        computed value is to be associated
-     * @param k2              the 2nd of the pair of keys with which the
-     *                        computed value is to be associated
-     * @param mappingFunction the function to compute a value
-     * @return the current (existing or computed) value associated with
-     * the specified key pair, or null if the computed value is null
-     * @throws NullPointerException  if any of the specified keys or
-     *                               mappingFunction is null
-     * @throws IllegalStateException if the computation detectably
-     *                               attempts a recursive update to this map
-     *                               that would otherwise never complete
-     * @throws RuntimeException      or Error if the mappingFunction does so, in
-     *                               which case the mapping is left unestablished
-     */
-    public V computeIfAbsent(K1 k1, K2 k2,
-                             BiFunction<? super K1, ? super K2, ? extends V>
-                                 mappingFunction) {
-        expungeStaleAssociations();
-        try {
-            return map.computeIfAbsent(
-                Pair.weak(k1, k2, queue),
-                pair -> mappingFunction.apply(pair.first(), pair.second()));
-        } finally {
-            Reference.reachabilityFence(k1);
-            Reference.reachabilityFence(k2);
-        }
-    }
-
-    /**
-     * Returns a {@link Collection} view of the values contained in this
-     * WeakPairMap. The collection is backed by the WeakPairMap, so changes to
-     * the map are reflected in the collection, and vice-versa.  The collection
-     * supports element removal, which removes the corresponding
-     * mapping from this map, via the {@code Iterator.remove},
-     * {@code Collection.remove}, {@code removeAll},
-     * {@code retainAll}, and {@code clear} operations.  It does not
-     * support the {@code add} or {@code addAll} operations.
-     *
-     * @return the collection view
-     */
-    public Collection<V> values() {
-        expungeStaleAssociations();
-        return map.values();
-    }
-
-    /**
-     * Removes associations from this WeakPairMap for which at least one of the
-     * keys in key pair has been found weakly-reachable and corresponding
-     * WeakRefPeer(s) enqueued. Called as part of each public operation.
-     */
-    private void expungeStaleAssociations() {
-        WeakRefPeer<?> peer;
-        while ((peer = (WeakRefPeer<?>) queue.poll()) != null) {
-            map.remove(peer.weakPair());
-        }
-    }
-
-    /**
-     * Common interface of both {@link Weak} and {@link Lookup} key pairs.
-     */
-    private interface Pair<K1, K2> {
-
-        static <K1, K2> Pair<K1, K2> weak(K1 k1, K2 k2,
-                                          ReferenceQueue<Object> queue) {
-            return new Weak<>(k1, k2, queue);
-        }
-
-        static <K1, K2> Pair<K1, K2> lookup(K1 k1, K2 k2) {
-            return new Lookup<>(k1, k2);
-        }
-
-        /**
-         * @return The 1st of the pair of keys (may be null for {@link Weak}
-         * when it gets cleared)
-         */
-        K1 first();
-
-        /**
-         * @return The 2nd of the pair of keys (may be null for {@link Weak}
-         * when it gets cleared)
-         */
-        K2 second();
-
-        static int hashCode(Object first, Object second) {
-            // assert first != null && second != null;
-            return System.identityHashCode(first) ^
-                   System.identityHashCode(second);
-        }
-
-        static boolean equals(Object first, Object second, Pair<?, ?> p) {
-            return first != null && second != null &&
-                   first == p.first() && second == p.second();
-        }
-
-        /**
-         * A Pair where both keys are weakly-referenced.
-         * It is composed of two instances of {@link WeakRefPeer}s:
-         * <pre>{@code
-         *
-         *     +-referent-> [K1]                +-referent-> [K2]
-         *     |                                |
-         *   +----------------+               +----------------+
-         *   | Pair.Weak <:   |-----peer----->| (anonymous) <: |
-         *   | WeakRefPeer,   |               | WeakRefPeer    |
-         *   | Pair           |<--weakPair()--|                |
-         *   +----------------+               +----------------+
-         *     |            ^
-         *     |            |
-         *     +-weakPair()-+
-         *
-         * }</pre>
-         * <p>
-         * Pair.Weak is used for CHM keys. Both peers are associated with the
-         * same {@link ReferenceQueue} so when either of their referents
-         * becomes weakly-reachable, the corresponding entries can be
-         * {@link #expungeStaleAssociations() expunged} from the map.
-         */
-        final class Weak<K1, K2> extends WeakRefPeer<K1> implements Pair<K1, K2> {
-
-            // saved hash so it can be retrieved after the reference is cleared
-            private final int hash;
-            // link to <K2> peer
-            private final WeakRefPeer<K2> peer;
-
-            Weak(K1 k1, K2 k2, ReferenceQueue<Object> queue) {
-                super(k1, queue);
-                hash = Pair.hashCode(k1, k2);
-                peer = new WeakRefPeer<>(k2, queue) {
-                    // link back to <K1> peer
-                    @Override
-                    Weak<?, ?> weakPair() { return Weak.this; }
-                };
-            }
-
-            @Override
-            Weak<?, ?> weakPair() {
-                return this;
-            }
-
-            @Override
-            public K1 first() {
-                return get();
-            }
-
-            @Override
-            public K2 second() {
-                return peer.get();
-            }
-
-            @Override
-            public int hashCode() {
-                return hash;
-            }
-
-            @Override
-            public boolean equals(Object obj) {
-                return this == obj ||
-                       (obj instanceof Pair &&
-                        Pair.equals(first(), second(), (Pair<?, ?>) obj));
-            }
-        }
-
-        /**
-         * Optimized lookup Pair, used as lookup key in methods like
-         * {@link java.util.Map#get(Object)} or
-         * {@link java.util.Map#containsKey(Object)}) where
-         * there is a great chance its allocation is eliminated
-         * by escape analysis when such lookups are inlined by JIT.
-         * All its methods are purposely designed so that 'this' is never
-         * passed to any other method or used as identity.
-         */
-        final class Lookup<K1, K2> implements Pair<K1, K2> {
-            private final K1 k1;
-            private final K2 k2;
-
-            Lookup(K1 k1, K2 k2) {
-                this.k1 = Objects.requireNonNull(k1);
-                this.k2 = Objects.requireNonNull(k2);
-            }
-
-            @Override
-            public K1 first() {
-                return k1;
-            }
-
-            @Override
-            public K2 second() {
-                return k2;
-            }
-
-            @Override
-            public int hashCode() {
-                return Pair.hashCode(k1, k2);
-            }
-
-            @Override
-            public boolean equals(Object obj) {
-                return obj instanceof Pair &&
-                       Pair.equals(k1, k2, (Pair<?, ?>) obj);
-            }
-        }
-    }
-
-    /**
-     * Common abstract supertype of a pair of WeakReference peers.
-     */
-    private static abstract class WeakRefPeer<K> extends WeakReference<K> {
-
-        WeakRefPeer(K k, ReferenceQueue<Object> queue) {
-            super(Objects.requireNonNull(k), queue);
-        }
-
-        /**
-         * @return the {@link Pair.Weak} side of the pair of peers.
-         */
-        abstract Pair.Weak<?, ?> weakPair();
-    }
-}
--- a/jdk/src/java.base/share/classes/java/lang/reflect/package-info.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/jdk/src/java.base/share/classes/java/lang/reflect/package-info.java	Tue Apr 18 22:25:33 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1998, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1998, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -25,11 +25,10 @@
 
 /**
  * Provides classes and interfaces for obtaining reflective information about
- * modules, classes and objects.  Reflection allows programmatic access to
- * information about modules and to the fields, methods and constructors of
- * loaded classes, and the use of reflected fields, methods, and constructors
- * to operate on their underlying counterparts, within encapsulation and
- * security restrictions.
+ * classes and objects.  Reflection allows programmatic access to information
+ * about the fields, methods and constructors of loaded classes, and the use
+ * of reflected fields, methods, and constructors to operate on their underlying
+ * counterparts, within encapsulation and security restrictions.
  *
  * <p>{@code AccessibleObject} allows suppression of access checks if
  * the necessary {@code ReflectPermission} is available.
--- a/jdk/src/java.base/share/classes/java/net/AbstractPlainDatagramSocketImpl.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/jdk/src/java.base/share/classes/java/net/AbstractPlainDatagramSocketImpl.java	Tue Apr 18 22:25:33 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1996, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1996, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -275,6 +275,7 @@
         return (fd == null) ? true : false;
     }
 
+    @SuppressWarnings("deprecation")
     protected void finalize() {
         close();
     }
--- a/jdk/src/java.base/share/classes/java/net/AbstractPlainSocketImpl.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/jdk/src/java.base/share/classes/java/net/AbstractPlainSocketImpl.java	Tue Apr 18 22:25:33 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1995, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1995, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -646,6 +646,7 @@
     /**
      * Cleans up if the user forgets to close it.
      */
+    @SuppressWarnings("deprecation")
     protected void finalize() throws IOException {
         close();
     }
--- a/jdk/src/java.base/share/classes/java/net/ContentHandler.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/jdk/src/java.base/share/classes/java/net/ContentHandler.java	Tue Apr 18 22:25:33 2017 +0200
@@ -37,10 +37,10 @@
  * application calls the {@code getContent} method in class
  * {@code URL} or in {@code URLConnection}.
  * The application's content handler factory (an instance of a class that
- * implements the interface {@code ContentHandlerFactory} set
- * up by a call to {@code setContentHandler}) is
- * called with a {@code String} giving the MIME type of the
- * object being received on the socket. The factory returns an
+ * implements the interface {@code ContentHandlerFactory} set up by a call to
+ * {@link URLConnection#setContentHandlerFactory(ContentHandlerFactory)
+ * setContentHandlerFactory} is called with a {@code String} giving the
+ * MIME type of the object being received on the socket. The factory returns an
  * instance of a subclass of {@code ContentHandler}, and its
  * {@code getContent} method is called to create the object.
  * <p>
@@ -99,7 +99,8 @@
      * representation of an object, this method reads that stream and
      * creates an object that matches one of the types specified.
      *
-     * The default implementation of this method should call getContent()
+     * The default implementation of this method should call
+     * {@link #getContent(URLConnection)}
      * and screen the return type for a match of the suggested types.
      *
      * @param      urlc   a URL connection.
--- a/jdk/src/java.base/share/classes/java/net/SocketInputStream.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/jdk/src/java.base/share/classes/java/net/SocketInputStream.java	Tue Apr 18 22:25:33 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1995, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1995, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -283,6 +283,7 @@
     /**
      * Overrides finalize, the fd is closed by the Socket.
      */
+    @SuppressWarnings("deprecation")
     protected void finalize() {}
 
     /**
--- a/jdk/src/java.base/share/classes/java/net/SocketOutputStream.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/jdk/src/java.base/share/classes/java/net/SocketOutputStream.java	Tue Apr 18 22:25:33 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1995, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1995, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -175,6 +175,7 @@
     /**
      * Overrides finalize, the fd is closed by the Socket.
      */
+    @SuppressWarnings("deprecation")
     protected void finalize() {}
 
     /**
--- a/jdk/src/java.base/share/classes/java/net/URLConnection.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/jdk/src/java.base/share/classes/java/net/URLConnection.java	Tue Apr 18 22:25:33 2017 +0200
@@ -876,7 +876,7 @@
      * Sets the value of the {@code doInput} field for this
      * {@code URLConnection} to the specified value.
      * <p>
-     * A URL connection can be used for input and/or output.  Set the DoInput
+     * A URL connection can be used for input and/or output.  Set the doInput
      * flag to true if you intend to use the URL connection for input,
      * false if not.  The default is true.
      *
@@ -906,7 +906,7 @@
      * Sets the value of the {@code doOutput} field for this
      * {@code URLConnection} to the specified value.
      * <p>
-     * A URL connection can be used for input and/or output.  Set the DoOutput
+     * A URL connection can be used for input and/or output.  Set the doOutput
      * flag to true if you intend to use the URL connection for output,
      * false if not.  The default is false.
      *
@@ -972,7 +972,7 @@
      * Returns the default value of the {@code allowUserInteraction}
      * field.
      * <p>
-     * Ths default is "sticky", being a part of the static state of all
+     * This default is "sticky", being a part of the static state of all
      * URLConnections.  This flag applies to the next, and all following
      * URLConnections that are created.
      *
@@ -993,7 +993,7 @@
      * "reload" button in a browser).  If the UseCaches flag on a connection
      * is true, the connection is allowed to use whatever caches it can.
      *  If false, caches are to be ignored.
-     *  The default value comes from DefaultUseCaches, which defaults to
+     *  The default value comes from defaultUseCaches, which defaults to
      * true. A default value can also be set per-protocol using
      * {@link #setDefaultUseCaches(String,boolean)}.
      *
@@ -1252,7 +1252,7 @@
      * application. It can be called at most once by an application.
      * <p>
      * The {@code ContentHandlerFactory} instance is used to
-     * construct a content handler from a content type
+     * construct a content handler from a content type.
      * <p>
      * If there is a security manager, this method first calls
      * the security manager's {@code checkSetFactory} method
--- a/jdk/src/java.base/share/classes/java/time/chrono/AbstractChronology.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/jdk/src/java.base/share/classes/java/time/chrono/AbstractChronology.java	Tue Apr 18 22:25:33 2017 +0200
@@ -127,36 +127,6 @@
 public abstract class AbstractChronology implements Chronology {
 
     /**
-     * ChronoLocalDate order constant.
-     */
-    static final Comparator<ChronoLocalDate> DATE_ORDER =
-        (Comparator<ChronoLocalDate> & Serializable) (date1, date2) -> {
-            return Long.compare(date1.toEpochDay(), date2.toEpochDay());
-        };
-    /**
-     * ChronoLocalDateTime order constant.
-     */
-    static final Comparator<ChronoLocalDateTime<? extends ChronoLocalDate>> DATE_TIME_ORDER =
-        (Comparator<ChronoLocalDateTime<? extends ChronoLocalDate>> & Serializable) (dateTime1, dateTime2) -> {
-            int cmp = Long.compare(dateTime1.toLocalDate().toEpochDay(), dateTime2.toLocalDate().toEpochDay());
-            if (cmp == 0) {
-                cmp = Long.compare(dateTime1.toLocalTime().toNanoOfDay(), dateTime2.toLocalTime().toNanoOfDay());
-            }
-            return cmp;
-        };
-    /**
-     * ChronoZonedDateTime order constant.
-     */
-    static final Comparator<ChronoZonedDateTime<?>> INSTANT_ORDER =
-            (Comparator<ChronoZonedDateTime<?>> & Serializable) (dateTime1, dateTime2) -> {
-                int cmp = Long.compare(dateTime1.toEpochSecond(), dateTime2.toEpochSecond());
-                if (cmp == 0) {
-                    cmp = Long.compare(dateTime1.toLocalTime().getNano(), dateTime2.toLocalTime().getNano());
-                }
-                return cmp;
-            };
-
-    /**
      * Map of available calendars by ID.
      */
     private static final ConcurrentHashMap<String, Chronology> CHRONOS_BY_ID = new ConcurrentHashMap<>();
--- a/jdk/src/java.base/share/classes/java/time/chrono/ChronoLocalDate.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/jdk/src/java.base/share/classes/java/time/chrono/ChronoLocalDate.java	Tue Apr 18 22:25:33 2017 +0200
@@ -66,6 +66,7 @@
 import static java.time.temporal.ChronoField.YEAR;
 import static java.time.temporal.ChronoUnit.DAYS;
 
+import java.io.Serializable;
 import java.time.DateTimeException;
 import java.time.LocalDate;
 import java.time.LocalTime;
@@ -256,7 +257,9 @@
      * @see #isEqual
      */
     static Comparator<ChronoLocalDate> timeLineOrder() {
-        return AbstractChronology.DATE_ORDER;
+        return (Comparator<ChronoLocalDate> & Serializable) (date1, date2) -> {
+            return Long.compare(date1.toEpochDay(), date2.toEpochDay());
+        };
     }
 
     //-----------------------------------------------------------------------
--- a/jdk/src/java.base/share/classes/java/time/chrono/ChronoLocalDateTime.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/jdk/src/java.base/share/classes/java/time/chrono/ChronoLocalDateTime.java	Tue Apr 18 22:25:33 2017 +0200
@@ -66,6 +66,7 @@
 import static java.time.temporal.ChronoUnit.FOREVER;
 import static java.time.temporal.ChronoUnit.NANOS;
 
+import java.io.Serializable;
 import java.time.DateTimeException;
 import java.time.Instant;
 import java.time.LocalDateTime;
@@ -136,7 +137,13 @@
      * @see #isEqual
      */
     static Comparator<ChronoLocalDateTime<?>> timeLineOrder() {
-        return AbstractChronology.DATE_TIME_ORDER;
+        return (Comparator<ChronoLocalDateTime<? extends ChronoLocalDate>> & Serializable) (dateTime1, dateTime2) -> {
+            int cmp = Long.compare(dateTime1.toLocalDate().toEpochDay(), dateTime2.toLocalDate().toEpochDay());
+            if (cmp == 0) {
+                cmp = Long.compare(dateTime1.toLocalTime().toNanoOfDay(), dateTime2.toLocalTime().toNanoOfDay());
+            }
+            return cmp;
+        };
     }
 
     //-----------------------------------------------------------------------
--- a/jdk/src/java.base/share/classes/java/time/chrono/ChronoZonedDateTime.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/jdk/src/java.base/share/classes/java/time/chrono/ChronoZonedDateTime.java	Tue Apr 18 22:25:33 2017 +0200
@@ -66,6 +66,7 @@
 import static java.time.temporal.ChronoUnit.FOREVER;
 import static java.time.temporal.ChronoUnit.NANOS;
 
+import java.io.Serializable;
 import java.time.DateTimeException;
 import java.time.Instant;
 import java.time.LocalTime;
@@ -137,7 +138,13 @@
      * @see #isEqual
      */
     static Comparator<ChronoZonedDateTime<?>> timeLineOrder() {
-        return AbstractChronology.INSTANT_ORDER;
+        return (Comparator<ChronoZonedDateTime<?>> & Serializable) (dateTime1, dateTime2) -> {
+                int cmp = Long.compare(dateTime1.toEpochSecond(), dateTime2.toEpochSecond());
+                if (cmp == 0) {
+                    cmp = Long.compare(dateTime1.toLocalTime().getNano(), dateTime2.toLocalTime().getNano());
+                }
+                return cmp;
+            };
     }
 
     //-----------------------------------------------------------------------
--- a/jdk/src/java.base/share/classes/java/util/Comparator.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/jdk/src/java.base/share/classes/java/util/Comparator.java	Tue Apr 18 22:25:33 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -112,12 +112,6 @@
      * zero, or a positive integer as the first argument is less than, equal
      * to, or greater than the second.<p>
      *
-     * In the foregoing description, the notation
-     * {@code sgn(}<i>expression</i>{@code )} designates the mathematical
-     * <i>signum</i> function, which is defined to return one of {@code -1},
-     * {@code 0}, or {@code 1} according to whether the value of
-     * <i>expression</i> is negative, zero or positive.<p>
-     *
      * The implementor must ensure that {@code sgn(compare(x, y)) ==
      * -sgn(compare(y, x))} for all {@code x} and {@code y}.  (This
      * implies that {@code compare(x, y)} must throw an exception if and only
@@ -135,7 +129,13 @@
      * {@code (compare(x, y)==0) == (x.equals(y))}.  Generally speaking,
      * any comparator that violates this condition should clearly indicate
      * this fact.  The recommended language is "Note: this comparator
-     * imposes orderings that are inconsistent with equals."
+     * imposes orderings that are inconsistent with equals."<p>
+     *
+     * In the foregoing description, the notation
+     * {@code sgn(}<i>expression</i>{@code )} designates the mathematical
+     * <i>signum</i> function, which is defined to return one of {@code -1},
+     * {@code 0}, or {@code 1} according to whether the value of
+     * <i>expression</i> is negative, zero, or positive, respectively.
      *
      * @param o1 the first object to be compared.
      * @param o2 the second object to be compared.
--- a/jdk/src/java.base/share/classes/java/util/ResourceBundle.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/jdk/src/java.base/share/classes/java/util/ResourceBundle.java	Tue Apr 18 22:25:33 2017 +0200
@@ -50,7 +50,6 @@
 import java.lang.reflect.Constructor;
 import java.lang.reflect.InvocationTargetException;
 import java.lang.reflect.Modifier;
-import java.lang.reflect.Module;
 import java.net.JarURLConnection;
 import java.net.URL;
 import java.net.URLConnection;
@@ -1836,7 +1835,7 @@
                         cacheKey.setFormat(format);
                         break;
                     }
-                } catch (Exception e) {
+                } catch (LinkageError|Exception e) {
                     cacheKey.setCause(e);
                 }
             }
--- a/jdk/src/java.base/share/classes/java/util/ServiceLoader.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/jdk/src/java.base/share/classes/java/util/ServiceLoader.java	Tue Apr 18 22:25:33 2017 +0200
@@ -31,10 +31,8 @@
 import java.io.InputStreamReader;
 import java.lang.reflect.Constructor;
 import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Layer;
 import java.lang.reflect.Method;
 import java.lang.reflect.Modifier;
-import java.lang.reflect.Module;
 import java.net.URL;
 import java.net.URLConnection;
 import java.security.AccessControlContext;
@@ -50,7 +48,6 @@
 import jdk.internal.loader.BootLoader;
 import jdk.internal.loader.ClassLoaders;
 import jdk.internal.misc.JavaLangAccess;
-import jdk.internal.misc.JavaLangReflectModuleAccess;
 import jdk.internal.misc.SharedSecrets;
 import jdk.internal.misc.VM;
 import jdk.internal.module.ServicesCatalog;
@@ -160,7 +157,7 @@
  * <h2> Locating providers </h2>
  *
  * <p> The {@code load} methods locate providers using a class loader or module
- * {@link Layer layer}. When locating providers using a class loader then
+ * {@link ModuleLayer layer}. When locating providers using a class loader then
  * providers in both named and unnamed modules may be located. When locating
  * providers using a module layer then only providers in named modules in
  * the layer (or parent layers) are located.
@@ -168,11 +165,11 @@
  * <p> When locating providers using a class loader then any providers in named
  * modules defined to the class loader, or any class loader that is reachable
  * via parent delegation, are located. Additionally, providers in module layers
- * other than the {@link Layer#boot() boot} layer, where the module layer
+ * other than the {@link ModuleLayer#boot() boot} layer, where the module layer
  * contains modules defined to the class loader, or any class loader reachable
  * via parent delegation, are also located. For example, suppose there is a
  * module layer where each module is defined to its own class loader (see {@link
- * Layer#defineModulesWithManyLoaders defineModulesWithManyLoaders}). If the
+ * ModuleLayer#defineModulesWithManyLoaders defineModulesWithManyLoaders}). If the
  * {@code load} method is invoked to locate providers using any of these class
  * loaders for this layer then it will locate all of the providers in that
  * layer, irrespective of their defining class loader.
@@ -198,7 +195,7 @@
  *     will locate providers in modules defined to the class loader, then its
  *     parent class loader, its parent parent, and so on to the bootstrap class
  *     loader. If a {@code ClassLoader}, or any class loader in the parent
- *     delegation chain, defines modules in a custom module {@link Layer} then
+ *     delegation chain, defines modules in a custom module {@link ModuleLayer} then
  *     all providers in that layer are located, irrespective of their class
  *     loader. The ordering of modules defined to the same class loader, or the
  *     ordering of modules in a layer, is not defined. </li>
@@ -216,11 +213,11 @@
  *     method finds the service configuration files. </li>
  * </ul>
  *
- * <p> Service loaders created to locate providers in a module {@link Layer}
- * will first locate providers in the layer, before locating providers in
- * parent layers. Traversal of parent layers is depth-first with each layer
- * visited at most once. For example, suppose L0 is the boot layer, L1 and
- * L2 are custom layers with L0 as their parent. Now suppose that L3 is
+ * <p> Service loaders created to locate providers in a {@linkplain ModuleLayer
+ * module layer} will first locate providers in the layer, before locating
+ * providers in parent layers. Traversal of parent layers is depth-first with
+ * each layer visited at most once. For example, suppose L0 is the boot layer,
+ * L1 and L2 are custom layers with L0 as their parent. Now suppose that L3 is
  * created with L1 and L2 as the parents (in that order). Using a service
  * loader to locate providers with L3 as the content will locate providers
  * in the following order: L3, L1, L0, L2. The ordering of modules in a layer
@@ -352,12 +349,12 @@
     // The class of the service type
     private final String serviceName;
 
-    // The module Layer used to locate providers; null when locating
+    // The module layer used to locate providers; null when locating
     // providers using a class loader
-    private final Layer layer;
+    private final ModuleLayer layer;
 
     // The class loader used to locate, load, and instantiate providers;
-    // null when locating provider using a module Layer
+    // null when locating provider using a module layer
     private final ClassLoader loader;
 
     // The access control context taken when the ServiceLoader is created
@@ -376,10 +373,8 @@
     private int reloadCount;
 
     private static JavaLangAccess LANG_ACCESS;
-    private static JavaLangReflectModuleAccess JLRM_ACCESS;
     static {
         LANG_ACCESS = SharedSecrets.getJavaLangAccess();
-        JLRM_ACCESS = SharedSecrets.getJavaLangReflectModuleAccess();
     }
 
     /**
@@ -425,13 +420,13 @@
 
     /**
      * Initializes a new instance of this class for locating service providers
-     * in a module Layer.
+     * in a module layer.
      *
      * @throws ServiceConfigurationError
      *         If {@code svc} is not accessible to {@code caller} or the caller
      *         module does not use the service type.
      */
-    private ServiceLoader(Class<?> caller, Layer layer, Class<S> svc) {
+    private ServiceLoader(Class<?> caller, ModuleLayer layer, Class<S> svc) {
         Objects.requireNonNull(caller);
         Objects.requireNonNull(layer);
         Objects.requireNonNull(svc);
@@ -512,12 +507,15 @@
 
     /**
      * Checks that the given service type is accessible to types in the given
-     * module, and check that the module declare that it uses the service type. ??
+     * module, and check that the module declares that it uses the service type.
      */
     private static void checkCaller(Class<?> caller, Class<?> svc) {
-        Module callerModule = caller.getModule();
+        if (caller == null) {
+            fail(svc, "no caller to check if it declares `uses`");
+        }
 
         // Check access to the service type
+        Module callerModule = caller.getModule();
         int mods = svc.getModifiers();
         if (!Reflection.verifyMemberAccess(caller, svc, null, mods)) {
             fail(svc, "service type not accessible to " + callerModule);
@@ -826,13 +824,13 @@
 
     /**
      * Implements lazy service provider lookup of service providers that
-     * are provided by modules in a module Layer (or parent layers)
+     * are provided by modules in a module layer (or parent layers)
      */
     private final class LayerLookupIterator<T>
         implements Iterator<Provider<T>>
     {
-        Deque<Layer> stack = new ArrayDeque<>();
-        Set<Layer> visited = new HashSet<>();
+        Deque<ModuleLayer> stack = new ArrayDeque<>();
+        Set<ModuleLayer> visited = new HashSet<>();
         Iterator<ServiceProvider> iterator;
         ServiceProvider next;  // next provider to load
 
@@ -841,8 +839,8 @@
             stack.push(layer);
         }
 
-        private Iterator<ServiceProvider> providers(Layer layer) {
-            ServicesCatalog catalog = JLRM_ACCESS.getServicesCatalog(layer);
+        private Iterator<ServiceProvider> providers(ModuleLayer layer) {
+            ServicesCatalog catalog = LANG_ACCESS.getServicesCatalog(layer);
             return catalog.findServices(serviceName).iterator();
         }
 
@@ -864,10 +862,10 @@
                 if (stack.isEmpty())
                     return false;
 
-                Layer layer = stack.pop();
-                List<Layer> parents = layer.parents();
+                ModuleLayer layer = stack.pop();
+                List<ModuleLayer> parents = layer.parents();
                 for (int i = parents.size() - 1; i >= 0; i--) {
-                    Layer parent = parents.get(i);
+                    ModuleLayer parent = parents.get(i);
                     if (!visited.contains(parent)) {
                         visited.add(parent);
                         stack.push(parent);
@@ -915,8 +913,8 @@
          * Returns iterator to iterate over the implementations of {@code
          * service} in the given layer.
          */
-        private List<ServiceProvider> providers(Layer layer) {
-            ServicesCatalog catalog = JLRM_ACCESS.getServicesCatalog(layer);
+        private List<ServiceProvider> providers(ModuleLayer layer) {
+            ServicesCatalog catalog = LANG_ACCESS.getServicesCatalog(layer);
             return catalog.findServices(serviceName);
         }
 
@@ -946,10 +944,10 @@
                 return providers.iterator();
             } else {
                 List<ServiceProvider> allProviders = new ArrayList<>(providers);
-                Layer bootLayer = Layer.boot();
-                Iterator<Layer> iterator = JLRM_ACCESS.layers(loader).iterator();
+                ModuleLayer bootLayer = ModuleLayer.boot();
+                Iterator<ModuleLayer> iterator = LANG_ACCESS.layers(loader).iterator();
                 while (iterator.hasNext()) {
-                    Layer layer = iterator.next();
+                    ModuleLayer layer = iterator.next();
                     if (layer != bootLayer) {
                         allProviders.addAll(providers(layer));
                     }
@@ -1535,7 +1533,7 @@
 
     /**
      * Creates a new service loader for the given service type that loads
-     * service providers from modules in the given {@code Layer} and its
+     * service providers from modules in the given {@code ModuleLayer} and its
      * ancestors.
      *
      * @apiNote Unlike the other load methods defined here, the service type
@@ -1545,7 +1543,7 @@
      * @param  <S> the class of the service type
      *
      * @param  layer
-     *         The module Layer
+     *         The module layer
      *
      * @param  service
      *         The interface or abstract class representing the service
@@ -1561,7 +1559,7 @@
      * @spec JPMS
      */
     @CallerSensitive
-    public static <S> ServiceLoader<S> load(Layer layer, Class<S> service) {
+    public static <S> ServiceLoader<S> load(ModuleLayer layer, Class<S> service) {
         return new ServiceLoader<>(Reflection.getCallerClass(), layer, service);
     }
 
--- a/jdk/src/java.base/share/classes/java/util/Timer.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/jdk/src/java.base/share/classes/java/util/Timer.java	Tue Apr 18 22:25:33 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1999, 2008, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -108,6 +108,7 @@
      * finalizer forgetting to call it.
      */
     private final Object threadReaper = new Object() {
+        @SuppressWarnings("deprecation")
         protected void finalize() throws Throwable {
             synchronized(queue) {
                 thread.newTasksMayBeScheduled = false;
--- a/jdk/src/java.base/share/classes/java/util/concurrent/ConcurrentHashMap.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/jdk/src/java.base/share/classes/java/util/concurrent/ConcurrentHashMap.java	Tue Apr 18 22:25:33 2017 +0200
@@ -1032,9 +1032,10 @@
             }
             else if ((fh = f.hash) == MOVED)
                 tab = helpTransfer(tab, f);
-            else if (onlyIfAbsent && fh == hash &&  // check first node
-                     ((fk = f.key) == key || fk != null && key.equals(fk)) &&
-                     (fv = f.val) != null)
+            else if (onlyIfAbsent // check first node without acquiring lock
+                     && fh == hash
+                     && ((fk = f.key) == key || (fk != null && key.equals(fk)))
+                     && (fv = f.val) != null)
                 return fv;
             else {
                 V oldVal = null;
@@ -1728,9 +1729,9 @@
             }
             else if ((fh = f.hash) == MOVED)
                 tab = helpTransfer(tab, f);
-            else if (fh == h &&                  // check first node
-                     ((fk = f.key) == key || fk != null && key.equals(fk)) &&
-                     (fv = f.val) != null)
+            else if (fh == h    // check first node without acquiring lock
+                     && ((fk = f.key) == key || (fk != null && key.equals(fk)))
+                     && (fv = f.val) != null)
                 return fv;
             else {
                 boolean added = false;
@@ -3468,9 +3469,9 @@
 
     static final class KeyIterator<K,V> extends BaseIterator<K,V>
         implements Iterator<K>, Enumeration<K> {
-        KeyIterator(Node<K,V>[] tab, int index, int size, int limit,
+        KeyIterator(Node<K,V>[] tab, int size, int index, int limit,
                     ConcurrentHashMap<K,V> map) {
-            super(tab, index, size, limit, map);
+            super(tab, size, index, limit, map);
         }
 
         public final K next() {
@@ -3488,9 +3489,9 @@
 
     static final class ValueIterator<K,V> extends BaseIterator<K,V>
         implements Iterator<V>, Enumeration<V> {
-        ValueIterator(Node<K,V>[] tab, int index, int size, int limit,
+        ValueIterator(Node<K,V>[] tab, int size, int index, int limit,
                       ConcurrentHashMap<K,V> map) {
-            super(tab, index, size, limit, map);
+            super(tab, size, index, limit, map);
         }
 
         public final V next() {
@@ -3508,9 +3509,9 @@
 
     static final class EntryIterator<K,V> extends BaseIterator<K,V>
         implements Iterator<Map.Entry<K,V>> {
-        EntryIterator(Node<K,V>[] tab, int index, int size, int limit,
+        EntryIterator(Node<K,V>[] tab, int size, int index, int limit,
                       ConcurrentHashMap<K,V> map) {
-            super(tab, index, size, limit, map);
+            super(tab, size, index, limit, map);
         }
 
         public final Map.Entry<K,V> next() {
--- a/jdk/src/java.base/share/classes/java/util/concurrent/ConcurrentSkipListMap.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/jdk/src/java.base/share/classes/java/util/concurrent/ConcurrentSkipListMap.java	Tue Apr 18 22:25:33 2017 +0200
@@ -48,7 +48,6 @@
 import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
-import java.util.NavigableMap;
 import java.util.NavigableSet;
 import java.util.NoSuchElementException;
 import java.util.Set;
--- a/jdk/src/java.base/share/classes/java/util/concurrent/ConcurrentSkipListSet.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/jdk/src/java.base/share/classes/java/util/concurrent/ConcurrentSkipListSet.java	Tue Apr 18 22:25:33 2017 +0200
@@ -43,7 +43,6 @@
 import java.util.Comparator;
 import java.util.Iterator;
 import java.util.Map;
-import java.util.NavigableMap;
 import java.util.NavigableSet;
 import java.util.Set;
 import java.util.SortedSet;
--- a/jdk/src/java.base/share/classes/java/util/concurrent/Executors.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/jdk/src/java.base/share/classes/java/util/concurrent/Executors.java	Tue Apr 18 22:25:33 2017 +0200
@@ -713,6 +713,7 @@
         FinalizableDelegatedExecutorService(ExecutorService executor) {
             super(executor);
         }
+        @SuppressWarnings("deprecation")
         protected void finalize() {
             super.shutdown();
         }
--- a/jdk/src/java.base/share/classes/java/util/concurrent/ForkJoinPool.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/jdk/src/java.base/share/classes/java/util/concurrent/ForkJoinPool.java	Tue Apr 18 22:25:33 2017 +0200
@@ -2354,7 +2354,7 @@
         checkPermission();
     }
 
-    private Object newInstanceFromSystemProperty(String property)
+    private static Object newInstanceFromSystemProperty(String property)
         throws ReflectiveOperationException {
         String className = System.getProperty(property);
         return (className == null)
@@ -2524,15 +2524,13 @@
      * @throws RejectedExecutionException if the task cannot be
      *         scheduled for execution
      */
+    @SuppressWarnings("unchecked")
     public ForkJoinTask<?> submit(Runnable task) {
         if (task == null)
             throw new NullPointerException();
-        ForkJoinTask<?> job;
-        if (task instanceof ForkJoinTask<?>) // avoid re-wrap
-            job = (ForkJoinTask<?>) task;
-        else
-            job = new ForkJoinTask.AdaptedRunnableAction(task);
-        return externalSubmit(job);
+        return externalSubmit((task instanceof ForkJoinTask<?>)
+            ? (ForkJoinTask<Void>) task // avoid re-wrap
+            : new ForkJoinTask.AdaptedRunnableAction(task));
     }
 
     /**
--- a/jdk/src/java.base/share/classes/java/util/concurrent/ForkJoinWorkerThread.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/jdk/src/java.base/share/classes/java/util/concurrent/ForkJoinWorkerThread.java	Tue Apr 18 22:25:33 2017 +0200
@@ -203,21 +203,19 @@
     static final class InnocuousForkJoinWorkerThread extends ForkJoinWorkerThread {
         /** The ThreadGroup for all InnocuousForkJoinWorkerThreads */
         private static final ThreadGroup innocuousThreadGroup =
-            java.security.AccessController.doPrivileged(
-                new java.security.PrivilegedAction<>() {
-                    public ThreadGroup run() {
-                        ThreadGroup group = Thread.currentThread().getThreadGroup();
-                        for (ThreadGroup p; (p = group.getParent()) != null; )
-                            group = p;
-                        return new ThreadGroup(group, "InnocuousForkJoinWorkerThreadGroup");
-                    }});
+            AccessController.doPrivileged(new PrivilegedAction<>() {
+                public ThreadGroup run() {
+                    ThreadGroup group = Thread.currentThread().getThreadGroup();
+                    for (ThreadGroup p; (p = group.getParent()) != null; )
+                        group = p;
+                    return new ThreadGroup(
+                        group, "InnocuousForkJoinWorkerThreadGroup");
+                }});
 
         /** An AccessControlContext supporting no privileges */
         private static final AccessControlContext INNOCUOUS_ACC =
             new AccessControlContext(
-                new ProtectionDomain[] {
-                    new ProtectionDomain(null, null)
-                });
+                new ProtectionDomain[] { new ProtectionDomain(null, null) });
 
         InnocuousForkJoinWorkerThread(ForkJoinPool pool) {
             super(pool,
--- a/jdk/src/java.base/share/classes/java/util/concurrent/ThreadPoolExecutor.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/jdk/src/java.base/share/classes/java/util/concurrent/ThreadPoolExecutor.java	Tue Apr 18 22:25:33 2017 +0200
@@ -1490,7 +1490,17 @@
     /**
      * Invokes {@code shutdown} when this executor is no longer
      * referenced and it has no threads.
+     *
+     * @deprecated The {@code finalize} method has been deprecated.
+     *     Subclasses that override {@code finalize} in order to perform cleanup
+     *     should be modified to use alternative cleanup mechanisms and
+     *     to remove the overriding {@code finalize} method.
+     *     When overriding the {@code finalize} method, its implementation must explicitly
+     *     ensure that {@code super.finalize()} is invoked as described in {@link Object#finalize}.
+     *     See the specification for {@link Object#finalize()} for further
+     *     information about migration options.
      */
+    @Deprecated(since="9")
     protected void finalize() {
         shutdown();
     }
--- a/jdk/src/java.base/share/classes/java/util/concurrent/locks/ReentrantReadWriteLock.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/jdk/src/java.base/share/classes/java/util/concurrent/locks/ReentrantReadWriteLock.java	Tue Apr 18 22:25:33 2017 +0200
@@ -444,7 +444,7 @@
             }
         }
 
-        private IllegalMonitorStateException unmatchedUnlockException() {
+        private static IllegalMonitorStateException unmatchedUnlockException() {
             return new IllegalMonitorStateException(
                 "attempt to unlock read lock, not locked by current thread");
         }
--- a/jdk/src/java.base/share/classes/java/util/spi/AbstractResourceBundleProvider.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/jdk/src/java.base/share/classes/java/util/spi/AbstractResourceBundleProvider.java	Tue Apr 18 22:25:33 2017 +0200
@@ -31,7 +31,6 @@
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.UncheckedIOException;
-import java.lang.reflect.Module;
 import java.security.AccessController;
 import java.security.PrivilegedAction;
 import java.util.Locale;
--- a/jdk/src/java.base/share/classes/java/util/zip/Deflater.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/jdk/src/java.base/share/classes/java/util/zip/Deflater.java	Tue Apr 18 22:25:33 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1996, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1996, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -551,7 +551,17 @@
 
     /**
      * Closes the compressor when garbage is collected.
+     *
+     * @deprecated The {@code finalize} method has been deprecated.
+     *     Subclasses that override {@code finalize} in order to perform cleanup
+     *     should be modified to use alternative cleanup mechanisms and
+     *     to remove the overriding {@code finalize} method.
+     *     When overriding the {@code finalize} method, its implementation must explicitly
+     *     ensure that {@code super.finalize()} is invoked as described in {@link Object#finalize}.
+     *     See the specification for {@link Object#finalize()} for further
+     *     information about migration options.
      */
+    @Deprecated(since="9")
     protected void finalize() {
         end();
     }
--- a/jdk/src/java.base/share/classes/java/util/zip/Inflater.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/jdk/src/java.base/share/classes/java/util/zip/Inflater.java	Tue Apr 18 22:25:33 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1996, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1996, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -378,7 +378,17 @@
 
     /**
      * Closes the decompressor when garbage is collected.
+     *
+     * @deprecated The {@code finalize} method has been deprecated.
+     *     Subclasses that override {@code finalize} in order to perform cleanup
+     *     should be modified to use alternative cleanup mechanisms and
+     *     to remove the overriding {@code finalize} method.
+     *     When overriding the {@code finalize} method, its implementation must explicitly
+     *     ensure that {@code super.finalize()} is invoked as described in {@link Object#finalize}.
+     *     See the specification for {@link Object#finalize()} for further
+     *     information about migration options.
      */
+    @Deprecated(since="9")
     protected void finalize() {
         end();
     }
--- a/jdk/src/java.base/share/classes/java/util/zip/ZipFile.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/jdk/src/java.base/share/classes/java/util/zip/ZipFile.java	Tue Apr 18 22:25:33 2017 +0200
@@ -420,6 +420,7 @@
                     Integer.MAX_VALUE : (int) avail);
         }
 
+        @SuppressWarnings("deprecation")
         protected void finalize() throws Throwable {
             close();
         }
@@ -641,9 +642,18 @@
      * This will prevent holding up system resources for an undetermined
      * length of time.
      *
+     * @deprecated The {@code finalize} method has been deprecated.
+     *     Subclasses that override {@code finalize} in order to perform cleanup
+     *     should be modified to use alternative cleanup mechanisms and
+     *     to remove the overriding {@code finalize} method.
+     *     When overriding the {@code finalize} method, its implementation must explicitly
+     *     ensure that {@code super.finalize()} is invoked as described in {@link Object#finalize}.
+     *     See the specification for {@link Object#finalize()} for further
+     *     information about migration options.
      * @throws IOException if an I/O error has occurred
      * @see    java.util.zip.ZipFile#close()
      */
+    @Deprecated(since="9")
     protected void finalize() throws IOException {
         close();
     }
@@ -813,6 +823,7 @@
             }
         }
 
+        @SuppressWarnings("deprecation")
         protected void finalize() {
             close();
         }
--- a/jdk/src/java.base/share/classes/javax/crypto/JceSecurityManager.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/jdk/src/java.base/share/classes/javax/crypto/JceSecurityManager.java	Tue Apr 18 22:25:33 2017 +0200
@@ -25,7 +25,6 @@
 
 package javax.crypto;
 
-import java.lang.reflect.Module;
 import java.security.*;
 import java.net.*;
 import java.util.*;
--- a/jdk/src/java.base/share/classes/jdk/internal/jrtfs/JrtFileSystem.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/jdk/src/java.base/share/classes/jdk/internal/jrtfs/JrtFileSystem.java	Tue Apr 18 22:25:33 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -106,6 +106,7 @@
     }
 
     @Override
+    @SuppressWarnings("deprecation")
     protected void finalize() throws Throwable {
         try {
             cleanup();
--- a/jdk/src/java.base/share/classes/jdk/internal/loader/BootLoader.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/jdk/src/java.base/share/classes/jdk/internal/loader/BootLoader.java	Tue Apr 18 22:25:33 2017 +0200
@@ -27,8 +27,6 @@
 import java.io.IOException;
 import java.io.InputStream;
 import java.lang.module.ModuleReference;
-import java.lang.reflect.Layer;
-import java.lang.reflect.Module;
 import java.net.MalformedURLException;
 import java.net.URI;
 import java.net.URL;
@@ -62,8 +60,7 @@
     private static final String JAVA_HOME = System.getProperty("java.home");
 
     static {
-        UNNAMED_MODULE
-            = SharedSecrets.getJavaLangReflectModuleAccess().defineUnnamedModule(null);
+        UNNAMED_MODULE = SharedSecrets.getJavaLangAccess().defineUnnamedModule(null);
         setBootLoaderUnnamedModule0(UNNAMED_MODULE);
     }
 
@@ -255,7 +252,7 @@
 
             if (mn != null) {
                 // named module from runtime image or exploded module
-                Optional<Module> om = Layer.boot().findModule(mn);
+                Optional<Module> om = ModuleLayer.boot().findModule(mn);
                 if (!om.isPresent())
                     throw new InternalError(mn + " not in boot layer");
                 return om.get();
--- a/jdk/src/java.base/share/classes/jdk/internal/loader/ClassLoaders.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/jdk/src/java.base/share/classes/jdk/internal/loader/ClassLoaders.java	Tue Apr 18 22:25:33 2017 +0200
@@ -27,7 +27,6 @@
 
 import java.io.File;
 import java.io.IOException;
-import java.lang.reflect.Module;
 import java.net.URL;
 import java.nio.file.InvalidPathException;
 import java.nio.file.Paths;
--- a/jdk/src/java.base/share/classes/jdk/internal/loader/Loader.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/jdk/src/java.base/share/classes/jdk/internal/loader/Loader.java	Tue Apr 18 22:25:33 2017 +0200
@@ -33,7 +33,6 @@
 import java.lang.module.ModuleReader;
 import java.lang.module.ModuleReference;
 import java.lang.module.ResolvedModule;
-import java.lang.reflect.Layer;
 import java.net.MalformedURLException;
 import java.net.URI;
 import java.net.URL;
@@ -80,8 +79,8 @@
  * loader. This allows automatic modules (for example) to link to types in the
  * unnamed module of the parent class loader.
  *
- * @see Layer#defineModulesWithOneLoader
- * @see Layer#defineModulesWithManyLoaders
+ * @see ModuleModuleLayer#defineModulesWithOneLoader
+ * @see ModuleModuleLayer#defineModulesWithManyLoaders
  */
 
 public final class Loader extends SecureClassLoader {
@@ -207,10 +206,10 @@
      * @param cf the Configuration containing at least modules to be defined to
      *           this class loader
      *
-     * @param parentLayers the parent Layers
+     * @param parentModuleLayers the parent ModuleLayers
      */
     public Loader initRemotePackageMap(Configuration cf,
-                                       List<Layer> parentLayers)
+                                       List<ModuleLayer> parentModuleLayers)
     {
         for (String name : nameToModule.keySet()) {
             ResolvedModule resolvedModule = cf.findModule(name).get();
@@ -236,8 +235,8 @@
                 } else {
 
                     // find the layer for the target module
-                    Layer layer = parentLayers.stream()
-                        .map(parent -> findLayer(parent, other.configuration()))
+                    ModuleLayer layer = parentModuleLayers.stream()
+                        .map(parent -> findModuleLayer(parent, other.configuration()))
                         .flatMap(Optional::stream)
                         .findAny()
                         .orElseThrow(() ->
@@ -286,8 +285,8 @@
      * Find the layer corresponding to the given configuration in the tree
      * of layers rooted at the given parent.
      */
-    private Optional<Layer> findLayer(Layer parent, Configuration cf) {
-        return SharedSecrets.getJavaLangReflectModuleAccess().layers(parent)
+    private Optional<ModuleLayer> findModuleLayer(ModuleLayer parent, Configuration cf) {
+        return SharedSecrets.getJavaLangAccess().layers(parent)
                 .filter(l -> l.configuration() == cf)
                 .findAny();
     }
--- a/jdk/src/java.base/share/classes/jdk/internal/loader/LoaderPool.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/jdk/src/java.base/share/classes/jdk/internal/loader/LoaderPool.java	Tue Apr 18 22:25:33 2017 +0200
@@ -27,7 +27,6 @@
 
 import java.lang.module.Configuration;
 import java.lang.module.ResolvedModule;
-import java.lang.reflect.Layer;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
@@ -36,7 +35,7 @@
 /**
  * A pool of class loaders.
  *
- * @see Layer#defineModulesWithManyLoaders
+ * @see ModuleLayer#defineModulesWithManyLoaders
  */
 
 public final class LoaderPool {
@@ -51,7 +50,7 @@
      * created with the given parent class loader as its parent.
      */
     public LoaderPool(Configuration cf,
-                      List<Layer> parentLayers,
+                      List<ModuleLayer> parentLayers,
                       ClassLoader parentLoader)
     {
         Map<String, Loader> loaders = new HashMap<>();
--- a/jdk/src/java.base/share/classes/jdk/internal/logger/DefaultLoggerFinder.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/jdk/src/java.base/share/classes/jdk/internal/logger/DefaultLoggerFinder.java	Tue Apr 18 22:25:33 2017 +0200
@@ -34,7 +34,6 @@
 import java.lang.System.LoggerFinder;
 import java.lang.System.Logger;
 import java.lang.ref.ReferenceQueue;
-import java.lang.reflect.Module;
 import java.security.AccessController;
 import java.security.PrivilegedAction;
 import java.util.Collection;
--- a/jdk/src/java.base/share/classes/jdk/internal/logger/LazyLoggers.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/jdk/src/java.base/share/classes/jdk/internal/logger/LazyLoggers.java	Tue Apr 18 22:25:33 2017 +0200
@@ -31,7 +31,6 @@
 import java.lang.System.LoggerFinder;
 import java.lang.System.Logger;
 import java.lang.ref.WeakReference;
-import java.lang.reflect.Module;
 import java.util.Objects;
 import jdk.internal.misc.VM;
 import sun.util.logging.PlatformLogger;
@@ -402,10 +401,10 @@
      * @param module The module on behalf of which the logger is created.
      *               If the module is not loaded from the Boot ClassLoader,
      *               the LoggerFinder is accessed and the logger returned
-     *               by {@link LoggerFinder#getLogger(java.lang.String, java.lang.reflect.Module)}
+     *               by {@link LoggerFinder#getLogger(java.lang.String, java.lang.Module)}
      *               is returned to the caller directly.
      *               Otherwise, the logger returned by
-     *               {@link #getLazyLogger(java.lang.String, java.lang.reflect.Module)}
+     *               {@link #getLazyLogger(java.lang.String, java.lang.Module)}
      *               is returned to the caller.
      *
      * @return  a (possibly lazy) Logger instance.
--- a/jdk/src/java.base/share/classes/jdk/internal/misc/JavaLangAccess.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/jdk/src/java.base/share/classes/jdk/internal/misc/JavaLangAccess.java	Tue Apr 18 22:25:33 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -27,10 +27,10 @@
 
 import java.io.IOException;
 import java.lang.annotation.Annotation;
+import java.lang.module.ModuleDescriptor;
 import java.lang.reflect.Executable;
-import java.lang.reflect.Layer;
 import java.lang.reflect.Method;
-import java.lang.reflect.Module;
+import java.net.URI;
 import java.net.URL;
 import java.security.AccessControlContext;
 import java.security.ProtectionDomain;
@@ -38,6 +38,7 @@
 import java.util.concurrent.ConcurrentHashMap;
 import java.util.stream.Stream;
 
+import jdk.internal.module.ServicesCatalog;
 import jdk.internal.reflect.ConstantPool;
 import sun.reflect.annotation.AnnotationType;
 import sun.nio.ch.Interruptible;
@@ -140,11 +141,6 @@
     void invokeFinalize(Object o) throws Throwable;
 
     /**
-     * Returns the boot Layer
-     */
-    Layer getBootLayer();
-
-    /**
      * Returns the ConcurrentHashMap used as a storage for ClassLoaderValue(s)
      * associated with the given class loader, creating it if it doesn't already exist.
      */
@@ -185,4 +181,74 @@
      * Invalidate package access cache
      */
     void invalidatePackageAccessCache();
+
+    /**
+     * Defines a new module to the Java virtual machine. The module
+     * is defined to the given class loader.
+     *
+     * The URI is for information purposes only, it can be {@code null}.
+     */
+    Module defineModule(ClassLoader loader, ModuleDescriptor descriptor, URI uri);
+
+    /**
+     * Defines the unnamed module for the given class loader.
+     */
+    Module defineUnnamedModule(ClassLoader loader);
+
+    /**
+     * Updates the readability so that module m1 reads m2. The new read edge
+     * does not result in a strong reference to m2 (m2 can be GC'ed).
+     *
+     * This method is the same as m1.addReads(m2) but without a permission check.
+     */
+    void addReads(Module m1, Module m2);
+
+    /**
+     * Updates module m to read all unnamed modules.
+     */
+    void addReadsAllUnnamed(Module m);
+
+    /**
+     * Updates module m1 to export a package to module m2. The export does
+     * not result in a strong reference to m2 (m2 can be GC'ed).
+     */
+    void addExports(Module m1, String pkg, Module m2);
+
+    /**
+     * Updates a module m to export a package to all unnamed modules.
+     */
+    void addExportsToAllUnnamed(Module m, String pkg);
+
+    /**
+     * Updates module m1 to open a package to module m2. Opening the
+     * package does not result in a strong reference to m2 (m2 can be GC'ed).
+     */
+    void addOpens(Module m1, String pkg, Module m2);
+
+    /**
+     * Updates a module m to open a package to all unnamed modules.
+     */
+    void addOpensToAllUnnamed(Module m, String pkg);
+
+    /**
+     * Updates a module m to use a service.
+     */
+    void addUses(Module m, Class<?> service);
+
+    /**
+     * Returns the ServicesCatalog for the given Layer.
+     */
+    ServicesCatalog getServicesCatalog(ModuleLayer layer);
+
+    /**
+     * Returns an ordered stream of layers. The first element is is the
+     * given layer, the remaining elements are its parents, in DFS order.
+     */
+    Stream<ModuleLayer> layers(ModuleLayer layer);
+
+    /**
+     * Returns a stream of the layers that have modules defined to the
+     * given class loader.
+     */
+    Stream<ModuleLayer> layers(ClassLoader loader);
 }
--- a/jdk/src/java.base/share/classes/jdk/internal/misc/JavaLangReflectModuleAccess.java	Tue Apr 18 13:19:42 2017 -0400
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,121 +0,0 @@
-/*
- * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.  Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package jdk.internal.misc;
-
-import java.lang.module.ModuleDescriptor;
-import java.lang.reflect.Layer;
-import java.lang.reflect.Module;
-import java.net.URI;
-import java.util.stream.Stream;
-
-import jdk.internal.module.ServicesCatalog;
-
-/**
- * Provides access to non-public methods in java.lang.reflect.Module
- */
-
-public interface JavaLangReflectModuleAccess {
-
-    /**
-     * Defines the unnamed module for the given class loader.
-     */
-    Module defineUnnamedModule(ClassLoader loader);
-
-    /**
-     * Defines a new module to the Java virtual machine. The module
-     * is defined to the given class loader.
-     *
-     * The URI is for information purposes only, it can be {@code null}.
-     */
-    Module defineModule(ClassLoader loader, ModuleDescriptor descriptor, URI uri);
-
-    /**
-     * Updates the readability so that module m1 reads m2. The new read edge
-     * does not result in a strong reference to m2 (m2 can be GC'ed).
-     *
-     * This method is the same as m1.addReads(m2) but without a permission check.
-     */
-    void addReads(Module m1, Module m2);
-
-    /**
-     * Updates module m to read all unnamed modules.
-     */
-    void addReadsAllUnnamed(Module m);
-
-    /**
-     * Update module m to export a package to all modules.
-     */
-    void addExports(Module m, String pn);
-
-    /**
-     * Updates module m1 to export a package to module m2. The export does
-     * not result in a strong reference to m2 (m2 can be GC'ed).
-     */
-    void addExports(Module m1, String pkg, Module m2);
-
-    /**
-     * Updates a module m to export a package to all unnamed modules.
-     */
-    void addExportsToAllUnnamed(Module m, String pkg);
-
-    /**
-     * Updates a module m to open a package to all modules.
-     */
-    void addOpens(Module m, String pkg);
-
-    /**
-     * Updates module m1 to open a package to module m2. Opening the
-     * package does not result in a strong reference to m2 (m2 can be GC'ed).
-     */
-    void addOpens(Module m1, String pkg, Module m2);
-
-    /**
-     * Updates a module m to open a package to all unnamed modules.
-     */
-    void addOpensToAllUnnamed(Module m, String pkg);
-
-    /**
-     * Updates a module m to use a service.
-     */
-    void addUses(Module m, Class<?> service);
-
-    /**
-     * Returns the ServicesCatalog for the given Layer.
-     */
-    ServicesCatalog getServicesCatalog(Layer layer);
-
-    /**
-     * Returns an ordered stream of layers. The first element is is the
-     * given layer, the remaining elements are its parents, in DFS order.
-     */
-    Stream<Layer> layers(Layer layer);
-
-    /**
-     * Returns a stream of the layers that have modules defined to the
-     * given class loader.
-     */
-    Stream<Layer> layers(ClassLoader loader);
-}
\ No newline at end of file
--- a/jdk/src/java.base/share/classes/jdk/internal/misc/JavaUtilResourceBundleAccess.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/jdk/src/java.base/share/classes/jdk/internal/misc/JavaUtilResourceBundleAccess.java	Tue Apr 18 22:25:33 2017 +0200
@@ -25,7 +25,6 @@
 
 package jdk.internal.misc;
 
-import java.lang.reflect.Module;
 import java.util.Locale;
 import java.util.ResourceBundle;
 
--- a/jdk/src/java.base/share/classes/jdk/internal/misc/SharedSecrets.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/jdk/src/java.base/share/classes/jdk/internal/misc/SharedSecrets.java	Tue Apr 18 22:25:33 2017 +0200
@@ -50,7 +50,6 @@
     private static JavaUtilJarAccess javaUtilJarAccess;
     private static JavaLangAccess javaLangAccess;
     private static JavaLangModuleAccess javaLangModuleAccess;
-    private static JavaLangReflectModuleAccess javaLangReflectModuleAccess;
     private static JavaLangInvokeAccess javaLangInvokeAccess;
     private static JavaLangRefAccess javaLangRefAccess;
     private static JavaIOAccess javaIOAccess;
@@ -119,16 +118,6 @@
         return javaLangModuleAccess;
     }
 
-    public static void setJavaLangReflectModuleAccess(JavaLangReflectModuleAccess jlrma) {
-        javaLangReflectModuleAccess = jlrma;
-    }
-
-    public static JavaLangReflectModuleAccess getJavaLangReflectModuleAccess() {
-        if (javaLangReflectModuleAccess == null)
-            unsafe.ensureClassInitialized(java.lang.reflect.Module.class);
-        return javaLangReflectModuleAccess;
-    }
-
     public static void setJavaLangRefAccess(JavaLangRefAccess jlra) {
         javaLangRefAccess = jlra;
     }
--- a/jdk/src/java.base/share/classes/jdk/internal/module/IllegalAccessLogger.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/jdk/src/java.base/share/classes/jdk/internal/module/IllegalAccessLogger.java	Tue Apr 18 22:25:33 2017 +0200
@@ -27,7 +27,6 @@
 
 import java.io.PrintStream;
 import java.lang.invoke.MethodHandles;
-import java.lang.reflect.Module;
 import java.net.URL;
 import java.security.AccessController;
 import java.security.CodeSource;
--- a/jdk/src/java.base/share/classes/jdk/internal/module/ModuleBootstrap.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/jdk/src/java.base/share/classes/jdk/internal/module/ModuleBootstrap.java	Tue Apr 18 22:25:33 2017 +0200
@@ -32,9 +32,6 @@
 import java.lang.module.ModuleFinder;
 import java.lang.module.ModuleReference;
 import java.lang.module.ResolvedModule;
-import java.lang.reflect.Layer;
-import java.lang.reflect.LayerInstantiationException;
-import java.lang.reflect.Module;
 import java.net.URI;
 import java.nio.file.Path;
 import java.nio.file.Paths;
@@ -61,7 +58,7 @@
  * resolving a set of module names specified via the launcher (or equivalent)
  * -m and --add-modules options. The modules are located on a module path that
  * is constructed from the upgrade module path, system modules, and application
- * module path. The Configuration is instantiated as the boot Layer with each
+ * module path. The Configuration is instantiated as the boot layer with each
  * module in the the configuration defined to one of the built-in class loaders.
  */
 
@@ -106,11 +103,11 @@
     }
 
     /**
-     * Initialize the module system, returning the boot Layer.
+     * Initialize the module system, returning the boot layer.
      *
      * @see java.lang.System#initPhase2()
      */
-    public static Layer boot() {
+    public static ModuleLayer boot() {
 
         long t0 = System.nanoTime();
 
@@ -237,7 +234,6 @@
             ModuleFinder f = finder;  // observable modules
             systemModules.findAll()
                 .stream()
-                .filter(mref -> !ModuleResolution.doNotResolveByDefault(mref))
                 .map(ModuleReference::descriptor)
                 .map(ModuleDescriptor::name)
                 .filter(mn -> f.find(mn).isPresent())  // observable
@@ -321,8 +317,7 @@
         if (SystemModules.hasSplitPackages() || needPostResolutionChecks) {
             Map<String, String> packageToModule = new HashMap<>();
             for (ResolvedModule resolvedModule : cf.modules()) {
-                ModuleDescriptor descriptor =
-                    resolvedModule.reference().descriptor();
+                ModuleDescriptor descriptor = resolvedModule.reference().descriptor();
                 String name = descriptor.name();
                 for (String p : descriptor.packages()) {
                     String other = packageToModule.putIfAbsent(p, name);
@@ -338,7 +333,7 @@
         long t4 = System.nanoTime();
 
         // define modules to VM/runtime
-        Layer bootLayer = Layer.empty().defineModules(cf, clf);
+        ModuleLayer bootLayer = ModuleLayer.empty().defineModules(cf, clf);
 
         PerfCounters.layerCreateTime.addElapsedTimeFrom(t4);
 
@@ -476,7 +471,7 @@
      * Process the --add-reads options to add any additional read edges that
      * are specified on the command-line.
      */
-    private static void addExtraReads(Layer bootLayer) {
+    private static void addExtraReads(ModuleLayer bootLayer) {
 
         // decode the command line options
         Map<String, List<String>> map = decode("jdk.module.addreads.");
@@ -514,7 +509,7 @@
      * Process the --add-exports and --add-opens options to export/open
      * additional packages specified on the command-line.
      */
-    private static void addExtraExportsAndOpens(Layer bootLayer) {
+    private static void addExtraExportsAndOpens(ModuleLayer bootLayer) {
         // --add-exports
         String prefix = "jdk.module.addexports.";
         Map<String, List<String>> extraExports = decode(prefix);
@@ -548,7 +543,7 @@
         }
     }
 
-    private static void addExtraExportsOrOpens(Layer bootLayer,
+    private static void addExtraExportsOrOpens(ModuleLayer bootLayer,
                                                Map<String, List<String>> map,
                                                boolean opens)
     {
--- a/jdk/src/java.base/share/classes/jdk/internal/module/ModulePatcher.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/jdk/src/java.base/share/classes/jdk/internal/module/ModulePatcher.java	Tue Apr 18 22:25:33 2017 +0200
@@ -135,8 +135,9 @@
                     Path top = file;
                     Files.find(top, Integer.MAX_VALUE,
                                ((path, attrs) -> attrs.isRegularFile()))
-                            .filter(path -> !isAutomatic
+                            .filter(path -> (!isAutomatic
                                     || path.toString().endsWith(".class"))
+                                    && !isHidden(path))
                             .map(path -> toPackageName(top, path))
                             .filter(Checks::isPackageName)
                             .forEach(packages::add);
@@ -177,11 +178,13 @@
 
         ModuleTarget target = null;
         ModuleHashes recordedHashes = null;
+        ModuleHashes.HashSupplier hasher = null;
         ModuleResolution mres = null;
         if (mref instanceof ModuleReferenceImpl) {
             ModuleReferenceImpl impl = (ModuleReferenceImpl)mref;
             target = impl.moduleTarget();
             recordedHashes = impl.recordedHashes();
+            hasher = impl.hasher();
             mres = impl.moduleResolution();
         }
 
@@ -191,7 +194,7 @@
                                        this,
                                        target,
                                        recordedHashes,
-                                       null,
+                                       hasher,
                                        mres);
 
     }
@@ -556,7 +559,7 @@
 
 
     /**
-     * Derives a package name from a file path to a .class file.
+     * Derives a package name from the file path of an entry in an exploded patch
      */
     private static String toPackageName(Path top, Path file) {
         Path entry = top.relativize(file);
@@ -569,6 +572,17 @@
     }
 
     /**
+     * Returns true if the given file exists and is a hidden file
+     */
+    private boolean isHidden(Path file) {
+        try {
+            return Files.isHidden(file);
+        } catch (IOException ioe) {
+            return false;
+        }
+    }
+
+    /**
      * Derives a package name from the name of an entry in a JAR file.
      */
     private static String toPackageName(Path file, JarEntry entry) {
--- a/jdk/src/java.base/share/classes/jdk/internal/module/ModulePath.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/jdk/src/java.base/share/classes/jdk/internal/module/ModulePath.java	Tue Apr 18 22:25:33 2017 +0200
@@ -547,7 +547,6 @@
      */
     private static class Patterns {
         static final Pattern DASH_VERSION = Pattern.compile("-(\\d+(\\.|$))");
-        static final Pattern TRAILING_VERSION = Pattern.compile("(\\.|\\d)*$");
         static final Pattern NON_ALPHANUM = Pattern.compile("[^A-Za-z0-9]");
         static final Pattern REPEATING_DOTS = Pattern.compile("(\\.)(\\1)+");
         static final Pattern LEADING_DOTS = Pattern.compile("^\\.");
@@ -558,9 +557,6 @@
      * Clean up candidate module name derived from a JAR file name.
      */
     private static String cleanModuleName(String mn) {
-        // drop trailing version from name
-        mn = Patterns.TRAILING_VERSION.matcher(mn).replaceAll("");
-
         // replace non-alphanumeric
         mn = Patterns.NON_ALPHANUM.matcher(mn).replaceAll(".");
 
@@ -630,7 +626,7 @@
     private Set<String> explodedPackages(Path dir) {
         try {
             return Files.find(dir, Integer.MAX_VALUE,
-                              ((path, attrs) -> attrs.isRegularFile()))
+                    ((path, attrs) -> attrs.isRegularFile() && !isHidden(path)))
                     .map(path -> dir.relativize(path))
                     .map(this::toPackageName)
                     .flatMap(Optional::stream)
@@ -726,6 +722,17 @@
         }
     }
 
+    /**
+     * Returns true if the given file exists and is a hidden file
+     */
+    private boolean isHidden(Path file) {
+        try {
+            return Files.isHidden(file);
+        } catch (IOException ioe) {
+            return false;
+        }
+    }
+
     private static final PerfCounter scanTime
         = PerfCounter.newPerfCounter("jdk.module.finder.modulepath.scanTime");
     private static final PerfCounter moduleCount
--- a/jdk/src/java.base/share/classes/jdk/internal/module/Modules.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/jdk/src/java.base/share/classes/jdk/internal/module/Modules.java	Tue Apr 18 22:25:33 2017 +0200
@@ -26,15 +26,13 @@
 package jdk.internal.module;
 
 import java.lang.module.ModuleDescriptor;
-import java.lang.reflect.Layer;
-import java.lang.reflect.Module;
 import java.net.URI;
 import java.security.AccessController;
 import java.security.PrivilegedAction;
 
 import jdk.internal.loader.BootLoader;
 import jdk.internal.loader.ClassLoaders;
-import jdk.internal.misc.JavaLangReflectModuleAccess;
+import jdk.internal.misc.JavaLangAccess;
 import jdk.internal.misc.SharedSecrets;
 
 /**
@@ -51,8 +49,7 @@
 public class Modules {
     private Modules() { }
 
-    private static final JavaLangReflectModuleAccess JLRMA
-        = SharedSecrets.getJavaLangReflectModuleAccess();
+    private static final JavaLangAccess JLA = SharedSecrets.getJavaLangAccess();
 
     /**
      * Creates a new Module. The module has the given ModuleDescriptor and
@@ -67,7 +64,7 @@
                                       ModuleDescriptor descriptor,
                                       URI uri)
     {
-        return JLRMA.defineModule(loader, descriptor, uri);
+        return JLA.defineModule(loader, descriptor, uri);
     }
 
     /**
@@ -75,23 +72,14 @@
      * Same as m1.addReads(m2) but without a caller check.
      */
     public static void addReads(Module m1, Module m2) {
-        JLRMA.addReads(m1, m2);
+        JLA.addReads(m1, m2);
     }
 
     /**
      * Update module m to read all unnamed modules.
      */
     public static void addReadsAllUnnamed(Module m) {
-        JLRMA.addReadsAllUnnamed(m);
-    }
-
-    /**
-     * Update module m to export a package to all modules.
-     *
-     * This method is for intended for use by tests only.
-     */
-    public static void addExports(Module m, String pn) {
-        JLRMA.addExports(m, pn);
+        JLA.addReadsAllUnnamed(m);
     }
 
     /**
@@ -99,23 +87,14 @@
      * Same as m1.addExports(pn, m2) but without a caller check
      */
     public static void addExports(Module m1, String pn, Module m2) {
-        JLRMA.addExports(m1, pn, m2);
+        JLA.addExports(m1, pn, m2);
     }
 
     /**
      * Updates module m to export a package to all unnamed modules.
      */
     public static void addExportsToAllUnnamed(Module m, String pn) {
-        JLRMA.addExportsToAllUnnamed(m, pn);
-    }
-
-    /**
-     * Update module m to open a package to all modules.
-     *
-     * This method is for intended for use by tests only.
-     */
-    public static void addOpens(Module m, String pn) {
-        JLRMA.addOpens(m, pn);
+        JLA.addExportsToAllUnnamed(m, pn);
     }
 
     /**
@@ -123,14 +102,14 @@
      * Same as m1.addOpens(pn, m2) but without a caller check.
      */
     public static void addOpens(Module m1, String pn, Module m2) {
-        JLRMA.addOpens(m1, pn, m2);
+        JLA.addOpens(m1, pn, m2);
     }
 
     /**
      * Updates module m to open a package to all unnamed modules.
      */
     public static void addOpensToAllUnnamed(Module m, String pn) {
-        JLRMA.addOpensToAllUnnamed(m, pn);
+        JLA.addOpensToAllUnnamed(m, pn);
     }
 
     /**
@@ -138,16 +117,16 @@
      * Same as m2.addUses(service) but without a caller check.
      */
     public static void addUses(Module m, Class<?> service) {
-        JLRMA.addUses(m, service);
+        JLA.addUses(m, service);
     }
 
     /**
      * Updates module m to provide a service
      */
     public static void addProvides(Module m, Class<?> service, Class<?> impl) {
-        Layer layer = m.getLayer();
+        ModuleLayer layer = m.getLayer();
 
-        if (layer == null || layer == Layer.boot()) {
+        if (layer == null || layer == ModuleLayer.boot()) {
             // update ClassLoader catalog
             PrivilegedAction<ClassLoader> pa = m::getClassLoader;
             ClassLoader loader = AccessController.doPrivileged(pa);
@@ -162,9 +141,7 @@
 
         if (layer != null) {
             // update Layer catalog
-            SharedSecrets.getJavaLangReflectModuleAccess()
-                    .getServicesCatalog(layer)
-                    .addProvider(m, service, impl);
+            JLA.getServicesCatalog(layer).addProvider(m, service, impl);
         }
     }
 
--- a/jdk/src/java.base/share/classes/jdk/internal/module/ServicesCatalog.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/jdk/src/java.base/share/classes/jdk/internal/module/ServicesCatalog.java	Tue Apr 18 22:25:33 2017 +0200
@@ -25,7 +25,6 @@
 
 package jdk.internal.module;
 
-import java.lang.reflect.Module;
 import java.lang.module.ModuleDescriptor;
 import java.lang.module.ModuleDescriptor.Provides;
 import java.util.ArrayList;
--- a/jdk/src/java.base/share/classes/sun/invoke/util/VerifyAccess.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/jdk/src/java.base/share/classes/sun/invoke/util/VerifyAccess.java	Tue Apr 18 22:25:33 2017 +0200
@@ -27,7 +27,6 @@
 
 import java.lang.reflect.Modifier;
 import static java.lang.reflect.Modifier.*;
-import java.lang.reflect.Module;
 import java.util.Objects;
 import jdk.internal.reflect.Reflection;
 
@@ -297,10 +296,13 @@
      * @param refc the class attempting to make the reference
      */
     public static boolean isTypeVisible(java.lang.invoke.MethodType type, Class<?> refc) {
-        for (int n = -1, max = type.parameterCount(); n < max; n++) {
-            Class<?> ptype = (n < 0 ? type.returnType() : type.parameterType(n));
-            if (!isTypeVisible(ptype, refc))
+        if (!isTypeVisible(type.returnType(), refc)) {
+            return false;
+        }
+        for (int n = 0, max = type.parameterCount(); n < max; n++) {
+            if (!isTypeVisible(type.parameterType(n), refc)) {
                 return false;
+            }
         }
         return true;
     }
--- a/jdk/src/java.base/share/classes/sun/invoke/util/Wrapper.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/jdk/src/java.base/share/classes/sun/invoke/util/Wrapper.java	Tue Apr 18 22:25:33 2017 +0200
@@ -26,20 +26,20 @@
 package sun.invoke.util;
 
 public enum Wrapper {
-    //        wrapperType    primitiveType  char     emptyArray          format
-    BOOLEAN(  Boolean.class, boolean.class, 'Z', new boolean[0], Format.unsigned( 1)),
+    //        wrapperType      simple     primitiveType  simple     char  emptyArray     format
+    BOOLEAN(  Boolean.class,   "Boolean", boolean.class, "boolean", 'Z', new boolean[0], Format.unsigned( 1)),
     // These must be in the order defined for widening primitive conversions in JLS 5.1.2
     // Avoid boxing integral types here to defer initialization of internal caches
-    BYTE   (     Byte.class,    byte.class, 'B', new    byte[0], Format.signed(   8)),
-    SHORT  (    Short.class,   short.class, 'S', new   short[0], Format.signed(  16)),
-    CHAR   (Character.class,    char.class, 'C', new    char[0], Format.unsigned(16)),
-    INT    (  Integer.class,     int.class, 'I', new     int[0], Format.signed(  32)),
-    LONG   (     Long.class,    long.class, 'J', new    long[0], Format.signed(  64)),
-    FLOAT  (    Float.class,   float.class, 'F', new   float[0], Format.floating(32)),
-    DOUBLE (   Double.class,  double.class, 'D', new  double[0], Format.floating(64)),
-    OBJECT (   Object.class,  Object.class, 'L', new  Object[0], Format.other(    1)),
+    BYTE   (     Byte.class,      "Byte",    byte.class,    "byte", 'B', new    byte[0], Format.signed(   8)),
+    SHORT  (    Short.class,     "Short",   short.class,   "short", 'S', new   short[0], Format.signed(  16)),
+    CHAR   (Character.class, "Character",    char.class,    "char", 'C', new    char[0], Format.unsigned(16)),
+    INT    (  Integer.class,   "Integer",     int.class,     "int", 'I', new     int[0], Format.signed(  32)),
+    LONG   (     Long.class,      "Long",    long.class,    "long", 'J', new    long[0], Format.signed(  64)),
+    FLOAT  (    Float.class,     "Float",   float.class,   "float", 'F', new   float[0], Format.floating(32)),
+    DOUBLE (   Double.class,    "Double",  double.class,  "double", 'D', new  double[0], Format.floating(64)),
+    OBJECT (   Object.class,    "Object",  Object.class,  "Object", 'L', new  Object[0], Format.other(    1)),
     // VOID must be the last type, since it is "assignable" from any other type:
-    VOID   (     Void.class,    void.class, 'V',           null, Format.other(    0)),
+    VOID   (     Void.class,      "Void",    void.class,    "void", 'V',           null, Format.other(    0)),
     ;
 
     public static final int COUNT = 10;
@@ -52,14 +52,14 @@
     private final String   wrapperSimpleName;
     private final String   primitiveSimpleName;
 
-    private Wrapper(Class<?> wtype, Class<?> ptype, char tchar, Object emptyArray, int format) {
+    private Wrapper(Class<?> wtype, String wtypeName, Class<?> ptype, String ptypeName, char tchar, Object emptyArray, int format) {
         this.wrapperType = wtype;
         this.primitiveType = ptype;
         this.basicTypeChar = tchar;
         this.emptyArray = emptyArray;
         this.format = format;
-        this.wrapperSimpleName = wtype.getSimpleName();
-        this.primitiveSimpleName = ptype.getSimpleName();
+        this.wrapperSimpleName = wtypeName;
+        this.primitiveSimpleName = ptypeName;
     }
 
     /** For debugging, give the details of this wrapper. */
@@ -518,12 +518,6 @@
      * If the target type is a primitive, change it to a wrapper.
      */
     static <T> Class<T> forceType(Class<?> type, Class<T> exampleType) {
-        boolean z = (type == exampleType ||
-               type.isPrimitive() && forPrimitiveType(type) == findWrapperType(exampleType) ||
-               exampleType.isPrimitive() && forPrimitiveType(exampleType) == findWrapperType(type) ||
-               type == Object.class && !exampleType.isPrimitive());
-        if (!z)
-            System.out.println(type+" <= "+exampleType);
         assert(type == exampleType ||
                type.isPrimitive() && forPrimitiveType(type) == findWrapperType(exampleType) ||
                exampleType.isPrimitive() && forPrimitiveType(exampleType) == findWrapperType(type) ||
--- a/jdk/src/java.base/share/classes/sun/launcher/LauncherHelper.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/jdk/src/java.base/share/classes/sun/launcher/LauncherHelper.java	Tue Apr 18 22:25:33 2017 +0200
@@ -50,10 +50,8 @@
 import java.lang.module.ModuleDescriptor.Exports;
 import java.lang.module.ModuleDescriptor.Opens;
 import java.lang.module.ModuleDescriptor.Provides;
-import java.lang.reflect.Layer;
 import java.lang.reflect.Method;
 import java.lang.reflect.Modifier;
-import java.lang.reflect.Module;
 import java.math.BigDecimal;
 import java.math.RoundingMode;
 import java.net.URI;
@@ -467,7 +465,7 @@
                 String mn = s[0];
                 String pn = s[1];
 
-                Layer.boot().findModule(mn).ifPresent(m -> {
+                ModuleLayer.boot().findModule(mn).ifPresent(m -> {
                     if (m.getDescriptor().packages().contains(pn)) {
                         if (open) {
                             Modules.addOpensToAllUnnamed(m, pn);
@@ -564,7 +562,7 @@
         }
 
         // main module is in the boot layer
-        Layer layer = Layer.boot();
+        ModuleLayer layer = ModuleLayer.boot();
         Optional<Module> om = layer.findModule(mainModule);
         if (!om.isPresent()) {
             // should not happen
@@ -854,7 +852,7 @@
         private static void setFXLaunchParameters(String what, int mode) {
 
             // find the module with the FX launcher
-            Optional<Module> om = Layer.boot().findModule(JAVAFX_GRAPHICS_MODULE_NAME);
+            Optional<Module> om = ModuleLayer.boot().findModule(JAVAFX_GRAPHICS_MODULE_NAME);
             if (!om.isPresent()) {
                 abort(null, "java.launcher.cls.error5");
             }
@@ -938,8 +936,7 @@
      * Called by the launcher to list the observable modules.
      * If called without any sub-options then the output is a simple list of
      * the modules. If called with sub-options then the sub-options are the
-     * names of the modules to list (-listmods:java.base,java.desktop for
-     * example).
+     * names of the modules to list (e.g. --list-modules java.base,java.desktop)
      */
     static void listModules(boolean printToStderr, String optionFlag)
         throws IOException, ClassNotFoundException
@@ -947,89 +944,97 @@
         initOutput(printToStderr);
 
         ModuleFinder finder = jdk.internal.module.ModuleBootstrap.finder();
-
         int colon = optionFlag.indexOf('=');
         if (colon == -1) {
             finder.findAll().stream()
-                .sorted(Comparator.comparing(ModuleReference::descriptor))
-                .forEach(md -> {
-                    ostream.println(midAndLocation(md.descriptor(),
-                                                   md.location()));
-                });
+                  .sorted(Comparator.comparing(ModuleReference::descriptor))
+                  .forEach(mref -> describeModule(finder, mref, false));
         } else {
             String[] names = optionFlag.substring(colon+1).split(",");
             for (String name: names) {
                 ModuleReference mref = finder.find(name).orElse(null);
                 if (mref == null) {
-                    System.err.format("%s not observable!%n", name);
+                    System.err.format("%s not found%n", name);
                     continue;
                 }
-
-                ModuleDescriptor md = mref.descriptor();
-                if (md.isOpen())
-                    ostream.print("open ");
-                if (md.isAutomatic())
-                    ostream.print("automatic ");
-                if (md.modifiers().contains(ModuleDescriptor.Modifier.SYNTHETIC))
-                    ostream.print("synthetic ");
-                if (md.modifiers().contains(ModuleDescriptor.Modifier.MANDATED))
-                    ostream.print("mandated ");
-                ostream.println("module " + midAndLocation(md, mref.location()));
-
-                // unqualified exports (sorted by package)
-                Set<Exports> exports = new TreeSet<>(Comparator.comparing(Exports::source));
-                md.exports().stream().filter(e -> !e.isQualified()).forEach(exports::add);
-                for (Exports e : exports) {
-                    String modsAndSource = Stream.concat(toStringStream(e.modifiers()),
-                            Stream.of(e.source()))
-                            .collect(Collectors.joining(" "));
-                    ostream.format("  exports %s%n", modsAndSource);
-                }
-
-                for (Requires d : md.requires()) {
-                    ostream.format("  requires %s%n", d);
-                }
-                for (String s : md.uses()) {
-                    ostream.format("  uses %s%n", s);
-                }
-
-                for (Provides ps : md.provides()) {
-                    ostream.format("  provides %s with %s%n", ps.service(),
-                            ps.providers().stream().collect(Collectors.joining(", ")));
-                }
-
-                // qualified exports
-                for (Exports e : md.exports()) {
-                    if (e.isQualified()) {
-                        String modsAndSource = Stream.concat(toStringStream(e.modifiers()),
-                                Stream.of(e.source()))
-                                .collect(Collectors.joining(" "));
-                        ostream.format("  exports %s", modsAndSource);
-                        formatCommaList(ostream, " to", e.targets());
-                    }
-                }
-
-                // open packages
-                for (Opens obj: md.opens()) {
-                    String modsAndSource = Stream.concat(toStringStream(obj.modifiers()),
-                            Stream.of(obj.source()))
-                            .collect(Collectors.joining(" "));
-                    ostream.format("  opens %s", modsAndSource);
-                    if (obj.isQualified())
-                        formatCommaList(ostream, " to", obj.targets());
-                    else
-                        ostream.println();
-                }
-
-                // non-exported/non-open packages
-                Set<String> concealed = new TreeSet<>(md.packages());
-                md.exports().stream().map(Exports::source).forEach(concealed::remove);
-                md.opens().stream().map(Opens::source).forEach(concealed::remove);
-                concealed.forEach(p -> ostream.format("  contains %s%n", p));
+                describeModule(finder, mref, true);
             }
         }
     }
 
+    /**
+     * Describes the given module.
+     */
+    static void describeModule(ModuleFinder finder,
+                               ModuleReference mref,
+                               boolean verbose)
+    {
+        ModuleDescriptor md = mref.descriptor();
+        ostream.print("module " + midAndLocation(md, mref.location()));
+        if (md.isAutomatic())
+            ostream.print(" automatic");
+        ostream.println();
+
+        if (!verbose)
+            return;
+
+        // unqualified exports (sorted by package)
+        Set<Exports> exports = new TreeSet<>(Comparator.comparing(Exports::source));
+        md.exports().stream().filter(e -> !e.isQualified()).forEach(exports::add);
+        for (Exports e : exports) {
+            String modsAndSource = Stream.concat(toStringStream(e.modifiers()),
+                    Stream.of(e.source()))
+                    .collect(Collectors.joining(" "));
+            ostream.format("  exports %s%n", modsAndSource);
+        }
+
+        for (Requires d : md.requires()) {
+            ostream.format("  requires %s", d);
+            String suffix = finder.find(d.name())
+                    .map(ModuleReference::descriptor)
+                    .map(any -> any.isAutomatic() ? " automatic" : "")
+                    .orElse(" not found");
+            ostream.println(suffix);
+        }
+        for (String s : md.uses()) {
+            ostream.format("  uses %s%n", s);
+        }
+
+        for (Provides ps : md.provides()) {
+            ostream.format("  provides %s with %s%n", ps.service(),
+                    ps.providers().stream().collect(Collectors.joining(", ")));
+        }
+
+        // qualified exports
+        for (Exports e : md.exports()) {
+            if (e.isQualified()) {
+                String modsAndSource = Stream.concat(toStringStream(e.modifiers()),
+                        Stream.of(e.source()))
+                        .collect(Collectors.joining(" "));
+                ostream.format("  exports %s", modsAndSource);
+                formatCommaList(ostream, " to", e.targets());
+            }
+        }
+
+        // open packages
+        for (Opens obj: md.opens()) {
+            String modsAndSource = Stream.concat(toStringStream(obj.modifiers()),
+                    Stream.of(obj.source()))
+                    .collect(Collectors.joining(" "));
+            ostream.format("  opens %s", modsAndSource);
+            if (obj.isQualified())
+                formatCommaList(ostream, " to", obj.targets());
+            else
+                ostream.println();
+        }
+
+        // non-exported/non-open packages
+        Set<String> concealed = new TreeSet<>(md.packages());
+        md.exports().stream().map(Exports::source).forEach(concealed::remove);
+        md.opens().stream().map(Opens::source).forEach(concealed::remove);
+        concealed.forEach(p -> ostream.format("  contains %s%n", p));
+    }
+
     static <T> String toString(Set<T> s) {
         return toStringStream(s).collect(Collectors.joining(" "));
     }
--- a/jdk/src/java.base/share/classes/sun/launcher/resources/launcher.properties	Tue Apr 18 13:19:42 2017 -0400
+++ b/jdk/src/java.base/share/classes/sun/launcher/resources/launcher.properties	Tue Apr 18 22:25:33 2017 +0200
@@ -39,7 +39,8 @@
 java.launcher.opt.hotspot    =\    {0}\t  is a synonym for the "{1}" VM  [deprecated]\n
 
 # Translators please note do not translate the options themselves
-java.launcher.opt.footer     =\    -cp <class search path of directories and zip/jar files>\n\
+java.launcher.opt.footer = \
+\    -cp <class search path of directories and zip/jar files>\n\
 \    -classpath <class search path of directories and zip/jar files>\n\
 \    --class-path <class search path of directories and zip/jar files>\n\
 \                  A {0} separated list of directories, JAR archives,\n\
@@ -101,8 +102,11 @@
 \                  should always be passed as the argument to the -splash option.\n\
 \                  The most appropriate scaled image provided will be picked up\n\
 \                  automatically.\n\
-\                  See the SplashScreen API documentation for more information.\n\
-\    @<filepath>   read options from the specified file\n\n\
+\                  See the SplashScreen API documentation for more information\n\
+\    @argument files\n\
+\                  one or more argument files containing options\n\
+\    -disable-@files\n\
+\                  prevent further argument file expansion\n\
 \To specify an argument for a long option, you can use --<name>=<value> or\n\
 \--<name> <value>.\n
 
--- a/jdk/src/java.base/share/classes/sun/net/www/MeteredStream.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/jdk/src/java.base/share/classes/sun/net/www/MeteredStream.java	Tue Apr 18 22:25:33 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1994, 2004, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1994, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -203,6 +203,7 @@
         return super.markSupported();
     }
 
+    @SuppressWarnings("deprecation")
     protected void finalize() throws Throwable {
         try {
             close();
--- a/jdk/src/java.base/share/classes/sun/net/www/protocol/https/DelegateHttpsURLConnection.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/jdk/src/java.base/share/classes/sun/net/www/protocol/https/DelegateHttpsURLConnection.java	Tue Apr 18 22:25:33 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2001, 2005, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2001, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -77,6 +77,7 @@
      * Called by layered delegator's finalize() method to handle closing
      * the underlying object.
      */
+    @SuppressWarnings("deprecation")
     protected void dispose() throws Throwable {
         super.finalize();
     }
--- a/jdk/src/java.base/share/classes/sun/net/www/protocol/https/HttpsURLConnectionImpl.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/jdk/src/java.base/share/classes/sun/net/www/protocol/https/HttpsURLConnectionImpl.java	Tue Apr 18 22:25:33 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2001, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2001, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -478,6 +478,7 @@
      * sun.net.www.protocol.http.HttpURLConnection's finalize()
      * would have to be made public.
      */
+    @SuppressWarnings("deprecation")
     protected void finalize() throws Throwable {
         delegate.dispose();
     }
--- a/jdk/src/java.base/share/classes/sun/nio/ch/DatagramChannelImpl.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/jdk/src/java.base/share/classes/sun/nio/ch/DatagramChannelImpl.java	Tue Apr 18 22:25:33 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2001, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2001, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -1034,6 +1034,7 @@
         }
     }
 
+    @SuppressWarnings("deprecation")
     protected void finalize() throws IOException {
         // fd is null if constructor threw exception
         if (fd != null)
--- a/jdk/src/java.base/share/classes/sun/reflect/misc/MethodUtil.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/jdk/src/java.base/share/classes/sun/reflect/misc/MethodUtil.java	Tue Apr 18 22:25:33 2017 +0200
@@ -25,7 +25,6 @@
 
 package sun.reflect.misc;
 
-import java.lang.reflect.Module;
 import java.io.EOFException;
 import java.security.AllPermission;
 import java.security.AccessController;
--- a/jdk/src/java.base/share/classes/sun/security/provider/KeyProtector.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/jdk/src/java.base/share/classes/sun/security/provider/KeyProtector.java	Tue Apr 18 22:25:33 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2006, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -147,6 +147,7 @@
      * Ensures that the password bytes of this key protector are
      * set to zero when there are no more references to it.
      */
+    @SuppressWarnings("deprecation")
     protected void finalize() {
         if (passwdBytes != null) {
             Arrays.fill(passwdBytes, (byte)0x00);
--- a/jdk/src/java.base/share/classes/sun/security/ssl/BaseSSLSocketImpl.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/jdk/src/java.base/share/classes/sun/security/ssl/BaseSSLSocketImpl.java	Tue Apr 18 22:25:33 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2002, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2002, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -265,6 +265,7 @@
      * the penalty of prematurly killing SSL sessions.
      */
     @Override
+    @SuppressWarnings("deprecation")
     protected final void finalize() throws Throwable {
         try {
             close();
--- a/jdk/src/java.base/share/classes/sun/security/ssl/SunJSSE.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/jdk/src/java.base/share/classes/sun/security/ssl/SunJSSE.java	Tue Apr 18 22:25:33 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1999, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -247,6 +247,7 @@
     }
 
     @Override
+    @SuppressWarnings("deprecation")
     protected final void finalize() throws Throwable {
         // empty
         super.finalize();
--- a/jdk/src/java.base/share/classes/sun/security/tools/keytool/Main.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/jdk/src/java.base/share/classes/sun/security/tools/keytool/Main.java	Tue Apr 18 22:25:33 2017 +0200
@@ -485,7 +485,9 @@
 
             if (c != null) {
                 command = c;
-            } else if (collator.compare(flags, "-help") == 0) {
+            } else if (collator.compare(flags, "-help") == 0 ||
+                    collator.compare(flags, "-h") == 0 ||
+                    collator.compare(flags, "-?") == 0) {
                 help = true;
             } else if (collator.compare(flags, "-conf") == 0) {
                 i++;
--- a/jdk/src/java.base/share/native/libjava/Module.c	Tue Apr 18 13:19:42 2017 -0400
+++ b/jdk/src/java.base/share/native/libjava/Module.c	Tue Apr 18 22:25:33 2017 +0200
@@ -29,12 +29,12 @@
 #include "jni_util.h"
 #include "jvm.h"
 
-#include "java_lang_reflect_Module.h"
+#include "java_lang_Module.h"
 
 /*
  * Gets the UTF-8 chars for the string and translates '.' to '/'.  Does no
  * further validation, assumption being that both calling code in
- * java.lang.reflect.Module and VM will do deeper validation.
+ * java.lang.Module and VM will do deeper validation.
  */
 static char*
 GetInternalPackageName(JNIEnv *env, jstring pkg, char* buf, jsize buf_size)
@@ -68,7 +68,7 @@
 }
 
 JNIEXPORT void JNICALL
-Java_java_lang_reflect_Module_defineModule0(JNIEnv *env, jclass cls, jobject module,
+Java_java_lang_Module_defineModule0(JNIEnv *env, jclass cls, jobject module,
                                             jboolean is_open, jstring version,
                                             jstring location, jobjectArray packages)
 {
@@ -109,14 +109,14 @@
 }
 
 JNIEXPORT void JNICALL
-Java_java_lang_reflect_Module_addReads0(JNIEnv *env, jclass cls, jobject from, jobject to)
+Java_java_lang_Module_addReads0(JNIEnv *env, jclass cls, jobject from, jobject to)
 {
     JVM_AddReadsModule(env, from, to);
 }
 
 JNIEXPORT void JNICALL
-Java_java_lang_reflect_Module_addExports0(JNIEnv *env, jclass cls, jobject from,
-                                          jstring pkg, jobject to)
+Java_java_lang_Module_addExports0(JNIEnv *env, jclass cls, jobject from,
+                                  jstring pkg, jobject to)
 {
     char buf[128];
     char* pkg_name;
@@ -136,8 +136,8 @@
 }
 
 JNIEXPORT void JNICALL
-Java_java_lang_reflect_Module_addExportsToAll0(JNIEnv *env, jclass cls, jobject from,
-                                               jstring pkg)
+Java_java_lang_Module_addExportsToAll0(JNIEnv *env, jclass cls, jobject from,
+                                       jstring pkg)
 {
     char buf[128];
     char* pkg_name;
@@ -157,8 +157,8 @@
 }
 
 JNIEXPORT void JNICALL
-Java_java_lang_reflect_Module_addExportsToAllUnnamed0(JNIEnv *env, jclass cls,
-                                                      jobject from, jstring pkg)
+Java_java_lang_Module_addExportsToAllUnnamed0(JNIEnv *env, jclass cls,
+                                              jobject from, jstring pkg)
 {
     char buf[128];
     char* pkg_name;
@@ -178,7 +178,7 @@
 }
 
 JNIEXPORT void JNICALL
-Java_java_lang_reflect_Module_addPackage0(JNIEnv *env, jclass cls, jobject m, jstring pkg)
+Java_java_lang_Module_addPackage0(JNIEnv *env, jclass cls, jobject m, jstring pkg)
 {
     char buf[128];
     char* pkg_name;
--- a/jdk/src/java.desktop/macosx/classes/apple/laf/JRSUIControl.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/jdk/src/java.desktop/macosx/classes/apple/laf/JRSUIControl.java	Tue Apr 18 22:25:33 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -114,6 +114,7 @@
         changes.putAll(other.changes);
     }
 
+    @SuppressWarnings("deprecation")
     protected synchronized void finalize() throws Throwable {
         if (cfDictionaryPtr == 0) return;
         disposeCFDictionary(cfDictionaryPtr);
--- a/jdk/src/java.desktop/macosx/classes/sun/awt/CGraphicsEnvironment.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/jdk/src/java.desktop/macosx/classes/sun/awt/CGraphicsEnvironment.java	Tue Apr 18 22:25:33 2017 +0200
@@ -124,6 +124,7 @@
     }
 
     @Override
+    @SuppressWarnings("deprecation")
     protected void finalize() throws Throwable {
         try {
             super.finalize();
--- a/jdk/src/java.desktop/macosx/classes/sun/font/CFont.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/jdk/src/java.desktop/macosx/classes/sun/font/CFont.java	Tue Apr 18 22:25:33 2017 +0200
@@ -250,6 +250,7 @@
         return compFont;
     }
 
+    @SuppressWarnings("deprecation")
     protected synchronized void finalize() {
         if (nativeFontPtr != 0) {
             disposeNativeFont(nativeFontPtr);
--- a/jdk/src/java.desktop/macosx/classes/sun/font/CStrike.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/jdk/src/java.desktop/macosx/classes/sun/font/CStrike.java	Tue Apr 18 22:25:33 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -127,6 +127,7 @@
         return nativeStrikePtr;
     }
 
+    @SuppressWarnings("deprecation")
     protected synchronized void finalize() throws Throwable {
         if (nativeStrikePtr != 0) {
             disposeNativeStrikePtr(nativeStrikePtr);
--- a/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CFRetainedResource.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CFRetainedResource.java	Tue Apr 18 22:25:33 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -135,6 +135,7 @@
     }
 
     @Override
+    @SuppressWarnings("deprecation")
     protected final void finalize() throws Throwable {
         dispose();
     }
--- a/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CPrinterJob.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CPrinterJob.java	Tue Apr 18 22:25:33 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2011, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -556,6 +556,7 @@
     // The following methods are CPrinterJob specific.
 
     @Override
+    @SuppressWarnings("deprecation")
     protected void finalize() {
         synchronized (fNSPrintInfoLock) {
             if (fNSPrintInfo != -1) {
--- a/jdk/src/java.desktop/share/classes/com/sun/imageio/plugins/common/SubImageInputStream.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/jdk/src/java.desktop/share/classes/com/sun/imageio/plugins/common/SubImageInputStream.java	Tue Apr 18 22:25:33 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2000, 2005, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -72,6 +72,7 @@
         streamPos = pos;
     }
 
+    @SuppressWarnings("deprecation")
     protected void finalize() throws Throwable {
         // Empty finalizer (for improved performance; no need to call
         // super.finalize() in this case)
--- a/jdk/src/java.desktop/share/classes/com/sun/imageio/plugins/png/PNGImageWriter.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/jdk/src/java.desktop/share/classes/com/sun/imageio/plugins/png/PNGImageWriter.java	Tue Apr 18 22:25:33 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -143,6 +143,7 @@
     }
 
     @Override
+    @SuppressWarnings("deprecation")
     protected void finalize() throws Throwable {
         // Empty finalizer (for improved performance; no need to call
         // super.finalize() in this case)
@@ -279,6 +280,7 @@
     }
 
     @Override
+    @SuppressWarnings("deprecation")
     protected void finalize() throws Throwable {
         // Empty finalizer (for improved performance; no need to call
         // super.finalize() in this case)
--- a/jdk/src/java.desktop/share/classes/com/sun/imageio/plugins/tiff/TIFFBaseJPEGCompressor.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/jdk/src/java.desktop/share/classes/com/sun/imageio/plugins/tiff/TIFFBaseJPEGCompressor.java	Tue Apr 18 22:25:33 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -435,6 +435,7 @@
         return compDataLength;
     }
 
+    @SuppressWarnings("deprecation")
     protected void finalize() throws Throwable {
         super.finalize();
         if(JPEGWriter != null) {
--- a/jdk/src/java.desktop/share/classes/com/sun/imageio/plugins/tiff/TIFFJPEGDecompressor.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/jdk/src/java.desktop/share/classes/com/sun/imageio/plugins/tiff/TIFFJPEGDecompressor.java	Tue Apr 18 22:25:33 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -139,6 +139,7 @@
         JPEGReader.read(0, JPEGParam);
     }
 
+    @SuppressWarnings("deprecation")
     protected void finalize() throws Throwable {
         super.finalize();
         JPEGReader.dispose();
--- a/jdk/src/java.desktop/share/classes/com/sun/imageio/plugins/tiff/TIFFOldJPEGDecompressor.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/jdk/src/java.desktop/share/classes/com/sun/imageio/plugins/tiff/TIFFOldJPEGDecompressor.java	Tue Apr 18 22:25:33 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -610,6 +610,7 @@
         JPEGReader.read(0, JPEGParam);
     }
 
+    @SuppressWarnings("deprecation")
     protected void finalize() throws Throwable {
         super.finalize();
         JPEGReader.dispose();
--- a/jdk/src/java.desktop/share/classes/com/sun/imageio/stream/StreamFinalizer.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/jdk/src/java.desktop/share/classes/com/sun/imageio/stream/StreamFinalizer.java	Tue Apr 18 22:25:33 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -60,6 +60,7 @@
         this.stream = stream;
     }
 
+    @SuppressWarnings("deprecation")
     protected void finalize() throws Throwable {
         try {
             stream.close();
--- a/jdk/src/java.desktop/share/classes/com/sun/media/sound/AbstractMidiDevice.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/jdk/src/java.desktop/share/classes/com/sun/media/sound/AbstractMidiDevice.java	Tue Apr 18 22:25:33 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1999, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -444,6 +444,7 @@
      * close this device if discarded by the garbage collector.
      */
     @Override
+    @SuppressWarnings("deprecation")
     protected final void finalize() {
         close();
     }
--- a/jdk/src/java.desktop/share/classes/java/awt/Graphics.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/jdk/src/java.desktop/share/classes/java/awt/Graphics.java	Tue Apr 18 22:25:33 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1995, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1995, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -1159,8 +1159,18 @@
 
     /**
      * Disposes of this graphics context once it is no longer referenced.
+     *
+     * @deprecated The {@code finalize} method has been deprecated.
+     *     Subclasses that override {@code finalize} in order to perform cleanup
+     *     should be modified to use alternative cleanup mechanisms and
+     *     to remove the overriding {@code finalize} method.
+     *     When overriding the {@code finalize} method, its implementation must explicitly
+     *     ensure that {@code super.finalize()} is invoked as described in {@link Object#finalize}.
+     *     See the specification for {@link Object#finalize()} for further
+     *     information about migration options.
      * @see #dispose
      */
+    @Deprecated(since="9")
     public void finalize() {
         dispose();
     }
--- a/jdk/src/java.desktop/share/classes/java/awt/PrintJob.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/jdk/src/java.desktop/share/classes/java/awt/PrintJob.java	Tue Apr 18 22:25:33 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1996, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1996, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -79,8 +79,18 @@
 
     /**
      * Ends this print job once it is no longer referenced.
+     *
+     * @deprecated The {@code finalize} method has been deprecated.
+     *     Subclasses that override {@code finalize} in order to perform cleanup
+     *     should be modified to use alternative cleanup mechanisms and
+     *     to remove the overriding {@code finalize} method.
+     *     When overriding the {@code finalize} method, its implementation must explicitly
+     *     ensure that {@code super.finalize()} is invoked as described in {@link Object#finalize}.
+     *     See the specification for {@link Object#finalize()} for further
+     *     information about migration options.
      * @see #end
      */
+    @Deprecated(since="9")
     public void finalize() {
         end();
     }
--- a/jdk/src/java.desktop/share/classes/java/awt/color/ICC_Profile.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/jdk/src/java.desktop/share/classes/java/awt/color/ICC_Profile.java	Tue Apr 18 22:25:33 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -751,7 +751,17 @@
 
     /**
      * Frees the resources associated with an ICC_Profile object.
+     *
+     * @deprecated The {@code finalize} method has been deprecated.
+     *     Subclasses that override {@code finalize} in order to perform cleanup
+     *     should be modified to use alternative cleanup mechanisms and
+     *     to remove the overriding {@code finalize} method.
+     *     When overriding the {@code finalize} method, its implementation must explicitly
+     *     ensure that {@code super.finalize()} is invoked as described in {@link Object#finalize}.
+     *     See the specification for {@link Object#finalize()} for further
+     *     information about migration options.
      */
+    @Deprecated(since="9")
     protected void finalize () {
         if (cmmProfile != null) {
             CMSManager.getModule().freeProfile(cmmProfile);
--- a/jdk/src/java.desktop/share/classes/java/awt/image/ColorModel.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/jdk/src/java.desktop/share/classes/java/awt/image/ColorModel.java	Tue Apr 18 22:25:33 2017 +0200
@@ -1620,7 +1620,17 @@
      * Disposes of system resources associated with this
      * {@code ColorModel} once this {@code ColorModel} is no
      * longer referenced.
+     *
+     * @deprecated The {@code finalize} method has been deprecated.
+     *     Subclasses that override {@code finalize} in order to perform cleanup
+     *     should be modified to use alternative cleanup mechanisms and
+     *     to remove the overriding {@code finalize} method.
+     *     When overriding the {@code finalize} method, its implementation must explicitly
+     *     ensure that {@code super.finalize()} is invoked as described in {@link Object#finalize}.
+     *     See the specification for {@link Object#finalize()} for further
+     *     information about migration options.
      */
+    @Deprecated(since="9")
     public void finalize() {
     }
 
@@ -1952,4 +1962,4 @@
         return lg16Toog16LUT;
     }
 
-}
\ No newline at end of file
+}
--- a/jdk/src/java.desktop/share/classes/java/awt/image/IndexColorModel.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/jdk/src/java.desktop/share/classes/java/awt/image/IndexColorModel.java	Tue Apr 18 22:25:33 2017 +0200
@@ -1514,7 +1514,17 @@
      * Disposes of system resources associated with this
      * {@code ColorModel} once this {@code ColorModel} is no
      * longer referenced.
+     *
+     * @deprecated The {@code finalize} method has been deprecated.
+     *     Subclasses that override {@code finalize} in order to perform cleanup
+     *     should be modified to use alternative cleanup mechanisms and
+     *     to remove the overriding {@code finalize} method.
+     *     When overriding the {@code finalize} method, its implementation must explicitly
+     *     ensure that {@code super.finalize()} is invoked as described in {@link Object#finalize}.
+     *     See the specification for {@link Object#finalize()} for further
+     *     information about migration options.
      */
+    @Deprecated(since="9")
     public void finalize() {
     }
 
@@ -1630,4 +1640,4 @@
         }
         return result;
     }
-}
\ No newline at end of file
+}
--- a/jdk/src/java.desktop/share/classes/javax/imageio/metadata/IIOMetadata.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/jdk/src/java.desktop/share/classes/javax/imageio/metadata/IIOMetadata.java	Tue Apr 18 22:25:33 2017 +0200
@@ -28,7 +28,6 @@
 import org.w3c.dom.Node;
 
 import java.lang.reflect.Method;
-import java.lang.reflect.Module;
 import java.security.AccessController;
 import java.security.PrivilegedAction;
 
--- a/jdk/src/java.desktop/share/classes/javax/imageio/spi/ImageReaderWriterSpi.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/jdk/src/java.desktop/share/classes/javax/imageio/spi/ImageReaderWriterSpi.java	Tue Apr 18 22:25:33 2017 +0200
@@ -28,7 +28,6 @@
 import java.io.IOException;
 import java.lang.reflect.Constructor;
 import java.lang.reflect.Method;
-import java.lang.reflect.Module;
 import java.security.AccessController;
 import java.security.PrivilegedAction;
 import java.util.Arrays;
--- a/jdk/src/java.desktop/share/classes/javax/imageio/spi/ServiceRegistry.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/jdk/src/java.desktop/share/classes/javax/imageio/spi/ServiceRegistry.java	Tue Apr 18 22:25:33 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -706,7 +706,17 @@
      *
      * @exception Throwable if an error occurs during superclass
      * finalization.
+     *
+     * @deprecated The {@code finalize} method has been deprecated.
+     *     Subclasses that override {@code finalize} in order to perform cleanup
+     *     should be modified to use alternative cleanup mechanisms and
+     *     to remove the overriding {@code finalize} method.
+     *     When overriding the {@code finalize} method, its implementation must explicitly
+     *     ensure that {@code super.finalize()} is invoked as described in {@link Object#finalize}.
+     *     See the specification for {@link Object#finalize()} for further
+     *     information about migration options.
      */
+    @Deprecated(since="9")
     public void finalize() throws Throwable {
         deregisterAll();
         super.finalize();
@@ -846,6 +856,7 @@
         poset.clear();
     }
 
+    @SuppressWarnings("deprecation")
     public synchronized void finalize() {
         clear();
     }
--- a/jdk/src/java.desktop/share/classes/javax/imageio/stream/FileCacheImageInputStream.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/jdk/src/java.desktop/share/classes/javax/imageio/stream/FileCacheImageInputStream.java	Tue Apr 18 22:25:33 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -260,7 +260,17 @@
 
     /**
      * {@inheritDoc}
+     *
+     * @deprecated The {@code finalize} method has been deprecated.
+     *     Subclasses that override {@code finalize} in order to perform cleanup
+     *     should be modified to use alternative cleanup mechanisms and
+     *     to remove the overriding {@code finalize} method.
+     *     When overriding the {@code finalize} method, its implementation must explicitly
+     *     ensure that {@code super.finalize()} is invoked as described in {@link Object#finalize}.
+     *     See the specification for {@link Object#finalize()} for further
+     *     information about migration options.
      */
+    @Deprecated(since="9")
     protected void finalize() throws Throwable {
         // Empty finalizer: for performance reasons we instead use the
         // Disposer mechanism for ensuring that the underlying
--- a/jdk/src/java.desktop/share/classes/javax/imageio/stream/FileImageInputStream.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/jdk/src/java.desktop/share/classes/javax/imageio/stream/FileImageInputStream.java	Tue Apr 18 22:25:33 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2000, 2007, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -155,7 +155,17 @@
 
     /**
      * {@inheritDoc}
+     *
+     * @deprecated The {@code finalize} method has been deprecated.
+     *     Subclasses that override {@code finalize} in order to perform cleanup
+     *     should be modified to use alternative cleanup mechanisms and
+     *     to remove the overriding {@code finalize} method.
+     *     When overriding the {@code finalize} method, its implementation must explicitly
+     *     ensure that {@code super.finalize()} is invoked as described in {@link Object#finalize}.
+     *     See the specification for {@link Object#finalize()} for further
+     *     information about migration options.
      */
+    @Deprecated(since="9")
     protected void finalize() throws Throwable {
         // Empty finalizer: for performance reasons we instead use the
         // Disposer mechanism for ensuring that the underlying
--- a/jdk/src/java.desktop/share/classes/javax/imageio/stream/FileImageOutputStream.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/jdk/src/java.desktop/share/classes/javax/imageio/stream/FileImageOutputStream.java	Tue Apr 18 22:25:33 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2000, 2007, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -163,7 +163,17 @@
 
     /**
      * {@inheritDoc}
+     *
+     * @deprecated The {@code finalize} method has been deprecated.
+     *     Subclasses that override {@code finalize} in order to perform cleanup
+     *     should be modified to use alternative cleanup mechanisms and
+     *     to remove the overriding {@code finalize} method.
+     *     When overriding the {@code finalize} method, its implementation must explicitly
+     *     ensure that {@code super.finalize()} is invoked as described in {@link Object#finalize}.
+     *     See the specification for {@link Object#finalize()} for further
+     *     information about migration options.
      */
+    @Deprecated(since="9")
     protected void finalize() throws Throwable {
         // Empty finalizer: for performance reasons we instead use the
         // Disposer mechanism for ensuring that the underlying
--- a/jdk/src/java.desktop/share/classes/javax/imageio/stream/ImageInputStreamImpl.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/jdk/src/java.desktop/share/classes/javax/imageio/stream/ImageInputStreamImpl.java	Tue Apr 18 22:25:33 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -867,7 +867,17 @@
      *
      * @exception Throwable if an error occurs during superclass
      * finalization.
+     *
+     * @deprecated The {@code finalize} method has been deprecated.
+     *     Subclasses that override {@code finalize} in order to perform cleanup
+     *     should be modified to use alternative cleanup mechanisms and
+     *     to remove the overriding {@code finalize} method.
+     *     When overriding the {@code finalize} method, its implementation must explicitly
+     *     ensure that {@code super.finalize()} is invoked as described in {@link Object#finalize}.
+     *     See the specification for {@link Object#finalize()} for further
+     *     information about migration options.
      */
+    @Deprecated(since="9")
     protected void finalize() throws Throwable {
         if (!isClosed) {
             try {
--- a/jdk/src/java.desktop/share/classes/javax/imageio/stream/MemoryCacheImageInputStream.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/jdk/src/java.desktop/share/classes/javax/imageio/stream/MemoryCacheImageInputStream.java	Tue Apr 18 22:25:33 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2000, 2007, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -178,7 +178,17 @@
 
     /**
      * {@inheritDoc}
+     *
+     * @deprecated The {@code finalize} method has been deprecated.
+     *     Subclasses that override {@code finalize} in order to perform cleanup
+     *     should be modified to use alternative cleanup mechanisms and
+     *     to remove the overriding {@code finalize} method.
+     *     When overriding the {@code finalize} method, its implementation must explicitly
+     *     ensure that {@code super.finalize()} is invoked as described in {@link Object#finalize}.
+     *     See the specification for {@link Object#finalize()} for further
+     *     information about migration options.
      */
+    @Deprecated(since="9")
     protected void finalize() throws Throwable {
         // Empty finalizer: for performance reasons we instead use the
         // Disposer mechanism for ensuring that the underlying
--- a/jdk/src/java.desktop/share/classes/javax/swing/text/PlainView.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/jdk/src/java.desktop/share/classes/javax/swing/text/PlainView.java	Tue Apr 18 22:25:33 2017 +0200
@@ -31,7 +31,6 @@
 import java.security.PrivilegedAction;
 import java.util.Objects;
 import javax.swing.event.*;
-import java.lang.reflect.Module;
 import java.lang.ref.SoftReference;
 import java.util.HashMap;
 
--- a/jdk/src/java.desktop/share/classes/javax/swing/text/StringContent.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/jdk/src/java.desktop/share/classes/javax/swing/text/StringContent.java	Tue Apr 18 22:25:33 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -351,6 +351,7 @@
             return rec.offset;
         }
 
+        @SuppressWarnings("deprecation")
         protected void finalize() throws Throwable {
             // schedule the record to be removed later
             // on another thread.
--- a/jdk/src/java.desktop/share/classes/sun/awt/image/BufImgSurfaceData.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/jdk/src/java.desktop/share/classes/sun/awt/image/BufImgSurfaceData.java	Tue Apr 18 22:25:33 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -472,6 +472,7 @@
             this.pData = pData;
         }
 
+        @SuppressWarnings("deprecation")
         public void finalize() {
             if (pData != 0L) {
                 BufImgSurfaceData.freeNativeICMData(pData);
--- a/jdk/src/java.desktop/share/classes/sun/java2d/SunGraphics2D.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/jdk/src/java.desktop/share/classes/sun/java2d/SunGraphics2D.java	Tue Apr 18 22:25:33 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1996, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1996, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -3633,6 +3633,7 @@
      * enough to know that if our override is empty then it should not
      * mark us as finalizeable.
      */
+    @SuppressWarnings("deprecation")
     public void finalize() {
         // DO NOT REMOVE THIS METHOD
     }
--- a/jdk/src/java.desktop/share/classes/sun/java2d/pipe/RegionClipSpanIterator.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/jdk/src/java.desktop/share/classes/sun/java2d/pipe/RegionClipSpanIterator.java	Tue Apr 18 22:25:33 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1999, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -383,6 +383,7 @@
      */
     //public native void dispose();
 
+    @SuppressWarnings("deprecation")
     protected void finalize() {
         //dispose();
     }
--- a/jdk/src/java.desktop/share/classes/sun/print/PeekGraphics.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/jdk/src/java.desktop/share/classes/sun/print/PeekGraphics.java	Tue Apr 18 22:25:33 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1998, 2006, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1998, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -1336,6 +1336,7 @@
     /**
      * Empty finalizer as no clean up needed here.
      */
+    @SuppressWarnings("deprecation")
     public void finalize() {
     }
 
--- a/jdk/src/java.desktop/share/classes/sun/print/PrintJob2D.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/jdk/src/java.desktop/share/classes/sun/print/PrintJob2D.java	Tue Apr 18 22:25:33 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -942,6 +942,7 @@
      * Ends this print job once it is no longer referenced.
      * @see #end
      */
+    @SuppressWarnings("deprecation")
     public void finalize() {
         end();
     }
--- a/jdk/src/java.desktop/share/classes/sun/print/ProxyGraphics.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/jdk/src/java.desktop/share/classes/sun/print/ProxyGraphics.java	Tue Apr 18 22:25:33 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2000, 2007, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -1099,6 +1099,7 @@
     /**
      * Empty finalizer as no clean up needed here.
      */
+    @SuppressWarnings("deprecation")
     public void finalize() {
     }
 
--- a/jdk/src/java.desktop/share/classes/sun/print/ProxyGraphics2D.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/jdk/src/java.desktop/share/classes/sun/print/ProxyGraphics2D.java	Tue Apr 18 22:25:33 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1998, 2006, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1998, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -1264,6 +1264,7 @@
     /**
      * Empty finalizer as no clean up needed here.
      */
+    @SuppressWarnings("deprecation")
     public void finalize() {
     }
 
--- a/jdk/src/java.desktop/share/legal/jpeg.md	Tue Apr 18 13:19:42 2017 -0400
+++ b/jdk/src/java.desktop/share/legal/jpeg.md	Tue Apr 18 22:25:33 2017 +0200
@@ -1,4 +1,4 @@
-## JPEG release 6b
+## Independent JPEG Group: JPEG release 6b
 
 ### JPEG License
 <pre>
--- a/jdk/src/java.desktop/unix/classes/sun/awt/X11InputMethod.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/jdk/src/java.desktop/unix/classes/sun/awt/X11InputMethod.java	Tue Apr 18 22:25:33 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -181,6 +181,7 @@
         }
     }
 
+    @SuppressWarnings("deprecation")
     protected void finalize() throws Throwable {
         dispose();
         super.finalize();
--- a/jdk/src/java.desktop/windows/classes/sun/awt/windows/WInputMethod.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/jdk/src/java.desktop/windows/classes/sun/awt/windows/WInputMethod.java	Tue Apr 18 22:25:33 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -132,6 +132,7 @@
     }
 
     @Override
+    @SuppressWarnings("deprecation")
     protected void finalize() throws Throwable
     {
         // Release the resources used by the native input context.
--- a/jdk/src/java.instrument/share/classes/java/lang/instrument/ClassFileTransformer.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/jdk/src/java.instrument/share/classes/java/lang/instrument/ClassFileTransformer.java	Tue Apr 18 22:25:33 2017 +0200
@@ -25,7 +25,6 @@
 
 package java.lang.instrument;
 
-import java.lang.reflect.Module;
 import java.security.AccessController;
 import java.security.PrivilegedAction;
 import java.security.ProtectionDomain;
--- a/jdk/src/java.instrument/share/classes/java/lang/instrument/Instrumentation.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/jdk/src/java.instrument/share/classes/java/lang/instrument/Instrumentation.java	Tue Apr 18 22:25:33 2017 +0200
@@ -25,7 +25,6 @@
 
 package java.lang.instrument;
 
-import java.lang.reflect.Module;
 import java.security.ProtectionDomain;
 import java.util.List;
 import java.util.Map;
@@ -346,7 +345,7 @@
 
 
     /**
-     * Determines whether a class is modifiable by
+     * Tests whether a class is modifiable by
      * {@linkplain #retransformClasses retransformation}
      * or {@linkplain #redefineClasses redefinition}.
      * If a class is modifiable then this method returns <code>true</code>.
@@ -711,8 +710,11 @@
      *         {@code extraProvides} map contains a service provider type that
      *         is not a member of the module or an implementation of the service;
      *         or {@code extraProvides} maps a key to an empty list
+     * @throws UnmodifiableModuleException if the module cannot be modified
      * @throws NullPointerException if any of the arguments are {@code null} or
      *         any of the Sets or Maps contains a {@code null} key or value
+     *
+     * @see #isModifiableModule(Module)
      * @since 9
      * @spec JPMS
      */
@@ -722,4 +724,19 @@
                         Map<String, Set<Module>> extraOpens,
                         Set<Class<?>> extraUses,
                         Map<Class<?>, List<Class<?>>> extraProvides);
+
+    /**
+     * Tests whether a module can be modified with {@link #redefineModule
+     * redefineModule}. If a module is modifiable then this method returns
+     * {@code true}. If a module is not modifiable then this method returns
+     * {@code false}.
+     *
+     * @param module the module to test if it can be modified
+     * @return {@code true} if the module is modifiable, otherwise {@code false}
+     * @throws NullPointerException if the module is {@code null}
+     *
+     * @since 9
+     * @spec JPMS
+     */
+    boolean isModifiableModule(Module module);
 }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/java.instrument/share/classes/java/lang/instrument/UnmodifiableModuleException.java	Tue Apr 18 22:25:33 2017 +0200
@@ -0,0 +1,56 @@
+/*
+ * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package java.lang.instrument;
+
+/**
+ * Thrown to indicate that a module cannot be modified.
+ *
+ * @see Instrumentation#redefineModule
+ * @since 9
+ * @spec JPMS
+ */
+
+public class UnmodifiableModuleException extends RuntimeException {
+    private static final long serialVersionUID = 6912511912351080644L;
+
+    /**
+     * Constructs an {@code UnmodifiableModuleException} with no
+     * detail message.
+     */
+    public UnmodifiableModuleException() {
+        super();
+    }
+
+    /**
+     * Constructs an {@code UnmodifiableModuleException} with the
+     * specified detail message.
+     *
+     * @param  msg the detail message.
+     */
+    public UnmodifiableModuleException(String msg) {
+        super(msg);
+    }
+}
--- a/jdk/src/java.instrument/share/classes/sun/instrument/InstrumentationImpl.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/jdk/src/java.instrument/share/classes/sun/instrument/InstrumentationImpl.java	Tue Apr 18 22:25:33 2017 +0200
@@ -23,11 +23,10 @@
  * questions.
  */
 
-
 package sun.instrument;
 
+import java.lang.instrument.UnmodifiableModuleException;
 import java.lang.reflect.Method;
-import java.lang.reflect.Module;
 import java.lang.reflect.AccessibleObject;
 import java.lang.instrument.ClassFileTransformer;
 import java.lang.instrument.ClassDefinition;
@@ -132,6 +131,13 @@
         return isModifiableClass0(mNativeAgent, theClass);
     }
 
+    public boolean isModifiableModule(Module module) {
+        if (module == null) {
+            throw new NullPointerException("'module' is null");
+        }
+        return true;
+    }
+
     public boolean
     isRetransformClassesSupported() {
         // ask lazily since there is some overhead
@@ -243,6 +249,9 @@
         if (!module.isNamed())
             return;
 
+        if (!isModifiableModule(module))
+            throw new UnmodifiableModuleException(module.getName());
+
         // copy and check reads
         extraReads = new HashSet<>(extraReads);
         if (extraReads.contains(null))
@@ -312,7 +321,7 @@
             return Collections.emptyMap();
 
         Map<String, Set<Module>> result = new HashMap<>();
-        Set<String> packages = Set.of(module.getPackages());
+        Set<String> packages = module.getPackages();
         for (Map.Entry<String, Set<Module>> e : map.entrySet()) {
             String pkg = e.getKey();
             if (pkg == null)
--- a/jdk/src/java.instrument/share/classes/sun/instrument/TransformerManager.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/jdk/src/java.instrument/share/classes/sun/instrument/TransformerManager.java	Tue Apr 18 22:25:33 2017 +0200
@@ -25,10 +25,8 @@
 
 package sun.instrument;
 
-
 import java.lang.instrument.Instrumentation;
 import java.lang.instrument.ClassFileTransformer;
-import java.lang.reflect.Module;
 import java.security.ProtectionDomain;
 
 /*
--- a/jdk/src/java.instrument/share/native/libinstrument/JPLISAgent.h	Tue Apr 18 13:19:42 2017 -0400
+++ b/jdk/src/java.instrument/share/native/libinstrument/JPLISAgent.h	Tue Apr 18 22:25:33 2017 +0200
@@ -66,7 +66,7 @@
 #define JPLIS_INSTRUMENTIMPL_AGENTMAININVOKER_METHODSIGNATURE "(Ljava/lang/String;Ljava/lang/String;)V"
 #define JPLIS_INSTRUMENTIMPL_TRANSFORM_METHODNAME           "transform"
 #define JPLIS_INSTRUMENTIMPL_TRANSFORM_METHODSIGNATURE      \
-    "(Ljava/lang/reflect/Module;Ljava/lang/ClassLoader;Ljava/lang/String;Ljava/lang/Class;Ljava/security/ProtectionDomain;[BZ)[B"
+    "(Ljava/lang/Module;Ljava/lang/ClassLoader;Ljava/lang/String;Ljava/lang/Class;Ljava/security/ProtectionDomain;[BZ)[B"
 
 
 /*
--- a/jdk/src/java.logging/share/classes/java/util/logging/Level.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/jdk/src/java.logging/share/classes/java/util/logging/Level.java	Tue Apr 18 22:25:33 2017 +0200
@@ -24,10 +24,10 @@
  */
 
 package java.util.logging;
+
 import java.lang.ref.Reference;
 import java.lang.ref.ReferenceQueue;
 import java.lang.ref.WeakReference;
-import java.lang.reflect.Module;
 import java.security.AccessController;
 import java.security.PrivilegedAction;
 import java.util.ArrayList;
--- a/jdk/src/java.logging/share/classes/java/util/logging/LogManager.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/jdk/src/java.logging/share/classes/java/util/logging/LogManager.java	Tue Apr 18 22:25:33 2017 +0200
@@ -23,7 +23,6 @@
  * questions.
  */
 
-
 package java.util.logging;
 
 import java.io.*;
@@ -43,7 +42,6 @@
 import jdk.internal.misc.JavaAWTAccess;
 import jdk.internal.misc.SharedSecrets;
 import sun.util.logging.internal.LoggingProviderImpl;
-import java.lang.reflect.Module;
 import static jdk.internal.logger.DefaultLoggerFinder.isSystem;
 
 /**
--- a/jdk/src/java.logging/share/classes/java/util/logging/Logger.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/jdk/src/java.logging/share/classes/java/util/logging/Logger.java	Tue Apr 18 22:25:33 2017 +0200
@@ -23,11 +23,9 @@
  * questions.
  */
 
-
 package java.util.logging;
 
 import java.lang.ref.WeakReference;
-import java.lang.reflect.Module;
 import java.security.AccessController;
 import java.security.PrivilegedAction;
 import java.util.ArrayList;
@@ -664,7 +662,7 @@
      * a new logger is created.
      * <p>
      * If a new logger is created its log level will be configured
-     * based on the LogManager configuration and it will configured
+     * based on the LogManager configuration and it will be configured
      * to also send logging output to its parent's Handlers.  It will
      * be registered in the LogManager global namespace.
      * <p>
@@ -726,7 +724,7 @@
      *
      * <p>
      * If a new logger is created its log level will be configured
-     * based on the LogManager and it will configured to also send logging
+     * based on the LogManager and it will be configured to also send logging
      * output to its parent's Handlers.  It will be registered in
      * the LogManager global namespace.
      * <p>
--- a/jdk/src/java.logging/share/classes/sun/util/logging/internal/LoggingProviderImpl.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/jdk/src/java.logging/share/classes/sun/util/logging/internal/LoggingProviderImpl.java	Tue Apr 18 22:25:33 2017 +0200
@@ -32,7 +32,6 @@
 import java.util.function.Supplier;
 import java.lang.System.LoggerFinder;
 import java.lang.System.Logger;
-import java.lang.reflect.Module;
 import java.util.Objects;
 import java.util.logging.LogManager;
 import jdk.internal.logger.DefaultLoggerFinder;
--- a/jdk/src/java.management.rmi/share/classes/javax/management/remote/rmi/RMIConnector.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/jdk/src/java.management.rmi/share/classes/javax/management/remote/rmi/RMIConnector.java	Tue Apr 18 22:25:33 2017 +0200
@@ -43,7 +43,6 @@
 import java.lang.reflect.Constructor;
 import java.lang.reflect.InvocationHandler;
 import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Module;
 import java.lang.reflect.Proxy;
 import java.net.MalformedURLException;
 import java.rmi.MarshalledObject;
--- a/jdk/src/java.management/share/classes/java/lang/management/LockInfo.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/jdk/src/java.management/share/classes/java/lang/management/LockInfo.java	Tue Apr 18 22:25:33 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -38,8 +38,8 @@
  * a synchronizer that may be exclusively owned by a thread and uses
  * {@link AbstractOwnableSynchronizer AbstractOwnableSynchronizer}
  * (or its subclass) to implement its synchronization property.
- * {@link ReentrantLock ReentrantLock} and
- * {@link ReentrantReadWriteLock ReentrantReadWriteLock} are
+ * {@link ReentrantLock ReentrantLock} and the write-lock (but not
+ * the read-lock) of {@link ReentrantReadWriteLock ReentrantReadWriteLock} are
  * two examples of ownable synchronizers provided by the platform.
  *
  * <h3><a name="MappedType">MXBean Mapping</a></h3>
--- a/jdk/src/java.management/share/classes/javax/management/remote/JMXConnectorFactory.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/jdk/src/java.management/share/classes/javax/management/remote/JMXConnectorFactory.java	Tue Apr 18 22:25:33 2017 +0200
@@ -28,7 +28,6 @@
 import com.sun.jmx.mbeanserver.Util;
 import java.io.IOException;
 import java.io.UncheckedIOException;
-import java.lang.reflect.Module;
 import java.net.MalformedURLException;
 import java.util.Collections;
 import java.util.HashMap;
--- a/jdk/src/java.management/share/classes/sun/management/ManagementFactoryHelper.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/jdk/src/java.management/share/classes/sun/management/ManagementFactoryHelper.java	Tue Apr 18 22:25:33 2017 +0200
@@ -45,7 +45,6 @@
 import java.util.ArrayList;
 import java.util.List;
 
-import java.lang.reflect.Module;
 import java.lang.reflect.UndeclaredThrowableException;
 import java.security.PrivilegedAction;
 import java.util.Collections;
@@ -181,8 +180,7 @@
             return AccessController.doPrivileged(new PrivilegedAction<>() {
                 @Override
                 public Class<?> run() {
-                    Optional<Module> logging = java.lang.reflect.Layer.boot()
-                        .findModule("java.logging");
+                    Optional<Module> logging = ModuleLayer.boot().findModule("java.logging");
                     if (logging.isPresent()) {
                         return Class.forName(logging.get(), className);
                     }
--- a/jdk/src/java.naming/share/classes/com/sun/jndi/ldap/AbstractLdapNamingEnumeration.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/jdk/src/java.naming/share/classes/com/sun/jndi/ldap/AbstractLdapNamingEnumeration.java	Tue Apr 18 22:25:33 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -382,6 +382,7 @@
         listArg = ne.listArg;
     }
 
+    @SuppressWarnings("deprecation")
     protected final void finalize() {
         cleanup();
     }
--- a/jdk/src/java.naming/share/classes/com/sun/jndi/ldap/LdapClient.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/jdk/src/java.naming/share/classes/com/sun/jndi/ldap/LdapClient.java	Tue Apr 18 22:25:33 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1999, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -474,6 +474,7 @@
         }
     }
 
+    @SuppressWarnings("deprecation")
     protected void finalize() {
         if (debug > 0) System.err.println("LdapClient: finalize " + this);
         forceClose(pooled);
--- a/jdk/src/java.naming/share/classes/com/sun/jndi/ldap/LdapCtx.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/jdk/src/java.naming/share/classes/com/sun/jndi/ldap/LdapCtx.java	Tue Apr 18 22:25:33 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1999, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -2609,6 +2609,7 @@
 
    // ----------------- Connection  ---------------------
 
+    @SuppressWarnings("deprecation")
     protected void finalize() {
         try {
             close();
--- a/jdk/src/java.naming/share/classes/com/sun/jndi/ldap/sasl/DefaultCallbackHandler.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/jdk/src/java.naming/share/classes/com/sun/jndi/ldap/sasl/DefaultCallbackHandler.java	Tue Apr 18 22:25:33 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -129,6 +129,7 @@
         }
     }
 
+    @SuppressWarnings("deprecation")
     protected void finalize() throws Throwable {
         clearPassword();
     }
--- a/jdk/src/java.naming/share/classes/com/sun/naming/internal/VersionHelper.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/jdk/src/java.naming/share/classes/com/sun/naming/internal/VersionHelper.java	Tue Apr 18 22:25:33 2017 +0200
@@ -176,7 +176,7 @@
     InputStream getResourceAsStream(Class<?> c, String name) {
         PrivilegedAction<InputStream> act = () -> {
             try {
-                java.lang.reflect.Module m = c.getModule();
+                Module m = c.getModule();
                 return c.getModule().getResourceAsStream(resolveName(c,name));
              } catch (IOException x) {
                  return null;
--- a/jdk/src/java.rmi/share/classes/java/rmi/activation/ActivationInstantiator.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/jdk/src/java.rmi/share/classes/java/rmi/activation/ActivationInstantiator.java	Tue Apr 18 22:25:33 2017 +0200
@@ -67,11 +67,11 @@
     *
     * <ul><li>The class to be activated and the special activation constructor are both public,
     * and the class resides in a package that is
-    * {@linkplain java.lang.reflect.Module#isExported(String,java.lang.reflect.Module) exported}
+    * {@linkplain Module#isExported(String,Module) exported}
     * to at least the {@code java.rmi} module; or
     *
     * <li>The class to be activated resides in a package that is
-    * {@linkplain java.lang.reflect.Module#isOpen(String,java.lang.reflect.Module) open}
+    * {@linkplain Module#isOpen(String,Module) open}
     * to at least the {@code java.rmi} module.
     * </ul>
     *
--- a/jdk/src/java.rmi/share/classes/java/rmi/server/UnicastRemoteObject.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/jdk/src/java.rmi/share/classes/java/rmi/server/UnicastRemoteObject.java	Tue Apr 18 22:25:33 2017 +0200
@@ -135,9 +135,9 @@
  * remote object's class.
  *
  * <li>Each remote interface must either be public and reside in a package that is
- * {@linkplain java.lang.reflect.Module#isExported(String,java.lang.reflect.Module) exported}
+ * {@linkplain Module#isExported(String,Module) exported}
  * to at least the {@code java.rmi} module, or it must reside in a package that is
- * {@linkplain java.lang.reflect.Module#isOpen(String,java.lang.reflect.Module) open}
+ * {@linkplain Module#isOpen(String,Module) open}
  * to at least the {@code java.rmi} module.
  *
  * <li>The proxy's invocation handler is a {@link
--- a/jdk/src/java.rmi/share/classes/sun/rmi/log/LogInputStream.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/jdk/src/java.rmi/share/classes/sun/rmi/log/LogInputStream.java	Tue Apr 18 22:25:33 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 1999, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -128,6 +128,7 @@
     /**
      * Closes the stream when garbage is collected.
      */
+    @SuppressWarnings("deprecation")
     protected void finalize() throws IOException {
         close();
     }
--- a/jdk/src/java.rmi/share/classes/sun/rmi/transport/tcp/ConnectionMultiplexer.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/jdk/src/java.rmi/share/classes/sun/rmi/transport/tcp/ConnectionMultiplexer.java	Tue Apr 18 22:25:33 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1996, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1996, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -440,6 +440,7 @@
     /**
      * Shut down connection upon finalization.
      */
+    @SuppressWarnings("deprecation")
     protected void finalize() throws Throwable
     {
         super.finalize();
--- a/jdk/src/java.security.jgss/share/classes/sun/security/jgss/wrapper/GSSCredElement.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/jdk/src/java.security.jgss/share/classes/sun/security/jgss/wrapper/GSSCredElement.java	Tue Apr 18 22:25:33 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -130,6 +130,7 @@
         return "N/A";
     }
 
+    @SuppressWarnings("deprecation")
     protected void finalize() throws Throwable {
         dispose();
     }
--- a/jdk/src/java.security.jgss/share/classes/sun/security/jgss/wrapper/GSSNameElement.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/jdk/src/java.security.jgss/share/classes/sun/security/jgss/wrapper/GSSNameElement.java	Tue Apr 18 22:25:33 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -289,6 +289,7 @@
         }
     }
 
+    @SuppressWarnings("deprecation")
     protected void finalize() throws Throwable {
         dispose();
     }
--- a/jdk/src/java.security.jgss/share/classes/sun/security/jgss/wrapper/NativeGSSContext.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/jdk/src/java.security.jgss/share/classes/sun/security/jgss/wrapper/NativeGSSContext.java	Tue Apr 18 22:25:33 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 2009, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -618,6 +618,7 @@
         return isInitiator;
     }
 
+    @SuppressWarnings("deprecation")
     protected void finalize() throws Throwable {
         dispose();
     }
--- a/jdk/src/java.security.sasl/share/classes/com/sun/security/sasl/CramMD5Base.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/jdk/src/java.security.sasl/share/classes/com/sun/security/sasl/CramMD5Base.java	Tue Apr 18 22:25:33 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -136,6 +136,7 @@
         }
     }
 
+    @SuppressWarnings("deprecation")
     protected void finalize() {
         clearPassword();
     }
--- a/jdk/src/java.security.sasl/share/classes/com/sun/security/sasl/PlainClient.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/jdk/src/java.security.sasl/share/classes/com/sun/security/sasl/PlainClient.java	Tue Apr 18 22:25:33 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2000, 2006, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -199,6 +199,7 @@
         }
     }
 
+    @SuppressWarnings("deprecation")
     protected void finalize() {
         clearPassword();
     }
--- a/jdk/src/java.smartcardio/share/classes/sun/security/smartcardio/CardImpl.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/jdk/src/java.smartcardio/share/classes/sun/security/smartcardio/CardImpl.java	Tue Apr 18 22:25:33 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -274,6 +274,7 @@
             + ", protocol " + getProtocol() + ", state " + state;
     }
 
+    @SuppressWarnings("deprecation")
     protected void finalize() throws Throwable {
         try {
             if (state == State.OK) {
--- a/jdk/src/java.sql/share/classes/java/sql/Connection.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/jdk/src/java.sql/share/classes/java/sql/Connection.java	Tue Apr 18 22:25:33 2017 +0200
@@ -1535,8 +1535,9 @@
      * <li>The connection pool caches {@code PooledConnection} objects</li>
      * <li>Returns a logical connection handle when {@code getConnection} is
      * called by the application</li>
-     * <li>The pool manager calls {@code Connection.close} on the logical connection handle
-     * prior to returning the {@code PooledConnection} back to the cache</li>
+     * <li>The logical {@code Connection} is closed by calling
+     * {@code Connection.close} prior to returning the {@code PooledConnection}
+     * to the cache.</li>
      * </ul>
      * @throws SQLException if an error occurs
      * @since 9
@@ -1577,8 +1578,9 @@
      * <li>The connection pool caches {@code PooledConnection} objects</li>
      * <li>Returns a logical connection handle when {@code getConnection} is
      * called by the application</li>
-     * <li>The pool manager calls {@code Connection.close} on the logical connection handle
-     * prior to returning the {@code PooledConnection} back to the cache</li>
+     * <li>The logical {@code Connection} is closed by calling
+     * {@code Connection.close} prior to returning the {@code PooledConnection}
+     * to the cache.</li>
      * </ul>
      * @throws SQLException if an error occurs
      * @since 9
@@ -1590,7 +1592,10 @@
     }
 
     /**
-     * Sets and validates the sharding keys for this connection.
+     * Sets and validates the sharding keys for this connection. A {@code null}
+     * value may be specified for the sharding Key. The validity
+     * of a {@code null} sharding key is vendor-specific. Consult your vendor&#39;s
+     * documentation for additional information.
      * @implSpec
      * The default implementation will throw a
      * {@code SQLFeatureNotSupportedException}.
@@ -1600,7 +1605,8 @@
      * {@code Connection}. The timeout value indicates how long the driver
      * should wait for the {@code Connection} to verify that the sharding key
      * is valid before {@code setShardingKeyIfValid} returns false.
-     * @param shardingKey the sharding key to be validated against this connection
+     * @param shardingKey the sharding key to be validated against this connection.
+     * The sharding key may be {@code null}
      * @param superShardingKey the super sharding key to be validated against this
      * connection. The super sharding key may be {@code null}.
      * @param timeout time in seconds before which the validation process is expected to
@@ -1610,10 +1616,10 @@
      * and set on this connection; false if the sharding keys are not valid or
      * the timeout period expires before the operation completes.
      * @throws SQLException if an error occurs while performing this validation;
-     * the {@code shardingkey} is {@code null}; a {@code superSharedingKey} is specified
+     * a {@code superSharedingKey} is specified
      * without a {@code shardingKey};
      * this method is called on a closed {@code connection}; or
-     * the {@code timeout} value is less than 0.
+     * the {@code timeout} value is negative.
      * @throws SQLFeatureNotSupportedException if the driver does not support sharding
      * @since 9
      * @see ShardingKey
@@ -1626,7 +1632,10 @@
     }
 
     /**
-     * Sets and validates the sharding key for this connection.
+     * Sets and validates the sharding key for this connection. A {@code null}
+     * value may be specified for the sharding Key. The validity
+     * of a {@code null} sharding key is vendor-specific. Consult your vendor&#39;s
+     * documentation for additional information.
      * @implSpec
      * The default implementation will throw a
      * {@code SQLFeatureNotSupportedException}.
@@ -1635,7 +1644,8 @@
      * {@code Connection}. The timeout value indicates how long the driver
      * should wait for the {@code Connection} to verify that the sharding key
      * is valid before {@code setShardingKeyIfValid} returns false.
-     * @param shardingKey the sharding key to be validated against this connection
+     * @param shardingKey the sharding key to be validated against this connection.
+     * The sharding key may be {@code null}
      * @param timeout time in seconds before which the validation process is expected to
      * be completed,else the validation process is aborted. A value of 0 indicates
      * the validation process will not time out.
@@ -1643,8 +1653,8 @@
      * set on this connection; false if the sharding key is not valid or
      * the timeout period expires before the operation completes.
      * @throws SQLException if there is an error while performing this validation;
-     * this method is called on a closed {@code connection}; the {@code shardingkey}
-     * is {@code null}; or the {@code timeout} value is less than 0.
+     * this method is called on a closed {@code connection};
+     * or the {@code timeout} value is negative.
      * @throws SQLFeatureNotSupportedException if the driver does not support sharding
      * @since 9
      * @see ShardingKey
@@ -1664,12 +1674,12 @@
      * This method sets the specified sharding keys but does not require a
      * round trip to the database to validate that the sharding keys are valid
      * for the {@code Connection}.
-     * @param shardingKey the sharding key to set on this connection.
+     * @param shardingKey the sharding key to set on this connection. The sharding
+     * key may be {@code null}
      * @param superShardingKey the super sharding key to set on this connection.
      * The super sharding key may be {@code null}
      * @throws SQLException if an error  occurs setting the sharding keys;
-     * this method is called on a closed {@code connection};
-     * the {@code shardingkey} is {@code null}; or
+     * this method is called on a closed {@code connection}; or
      * a {@code superSharedingKey} is specified without a {@code shardingKey}
      * @throws SQLFeatureNotSupportedException if the driver does not support sharding
      * @since 9
@@ -1690,10 +1700,10 @@
      * This method sets the specified sharding key but does not require a
      * round trip to the database to validate that the sharding key is valid
      * for the {@code Connection}.
-     * @param shardingKey the sharding key to set on this connection.
-     * @throws SQLException if an error  occurs setting the sharding key;
-     * this method is called on a closed {@code connection}; or the
-     * {@code shardkingKey} is {@code null}
+     * @param shardingKey the sharding key to set on this connection. The sharding
+     * key may be {@code null}
+     * @throws SQLException if an error occurs setting the sharding key; or
+     * this method is called on a closed {@code connection}
      * @throws SQLFeatureNotSupportedException if the driver does not support sharding
      * @since 9
      * @see ShardingKey
--- a/jdk/src/jdk.accessibility/share/classes/module-info.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/jdk/src/jdk.accessibility/share/classes/module-info.java	Tue Apr 18 22:25:33 2017 +0200
@@ -26,6 +26,7 @@
 /**
  * Defines JDK utility classes used by implementors of Assistive Technologies.
  *
+ * @moduleGraph
  * @since 9
  */
 module jdk.accessibility {
--- a/jdk/src/jdk.crypto.cryptoki/share/classes/sun/security/pkcs11/P11KeyStore.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/jdk/src/jdk.crypto.cryptoki/share/classes/sun/security/pkcs11/P11KeyStore.java	Tue Apr 18 22:25:33 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -241,6 +241,7 @@
             pc.setPassword(password);  // this clones the password if not null
         }
 
+        @SuppressWarnings("deprecation")
         protected void finalize() throws Throwable {
             if (password != null) {
                 Arrays.fill(password, ' ');
@@ -1022,7 +1023,7 @@
                                     ("trusted certificates may only be set by " +
                                     "token initialization application"));
             }
-            Module module = token.provider.nssModule;
+            Secmod.Module module = token.provider.nssModule;
             if ((module.type != ModuleType.KEYSTORE) && (module.type != ModuleType.FIPS)) {
                 // XXX allow TRUSTANCHOR module
                 throw new KeyStoreException("Trusted certificates can only be "
--- a/jdk/src/jdk.crypto.cryptoki/share/classes/sun/security/pkcs11/SunPKCS11.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/jdk/src/jdk.crypto.cryptoki/share/classes/sun/security/pkcs11/SunPKCS11.java	Tue Apr 18 22:25:33 2017 +0200
@@ -77,7 +77,7 @@
 
     final boolean removable;
 
-    final Module nssModule;
+    final Secmod.Module nssModule;
 
     final boolean nssUseSecmodTrust;
 
@@ -148,7 +148,7 @@
 
         boolean useSecmod = config.getNssUseSecmod();
         boolean nssUseSecmodTrust = config.getNssUseSecmodTrust();
-        Module nssModule = null;
+        Secmod.Module nssModule = null;
 
         //
         // Initialization via Secmod. The way this works is as follows:
@@ -217,7 +217,7 @@
                 // XXX which exception to throw
                 throw new ProviderException("Could not initialize NSS", e);
             }
-            List<Module> modules = secmod.getModules();
+            List<Secmod.Module> modules = secmod.getModules();
             if (config.getShowInfo()) {
                 System.out.println("NSS modules: " + modules);
             }
@@ -258,7 +258,7 @@
                             ("Invalid external module: " + moduleName);
                 }
                 int k = 0;
-                for (Module module : modules) {
+                for (Secmod.Module module : modules) {
                     if (module.getType() == ModuleType.EXTERNAL) {
                         if (++k == moduleIndex) {
                             nssModule = module;
--- a/jdk/src/jdk.crypto.cryptoki/share/classes/sun/security/pkcs11/wrapper/PKCS11.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/jdk/src/jdk.crypto.cryptoki/share/classes/sun/security/pkcs11/wrapper/PKCS11.java	Tue Apr 18 22:25:33 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2017, Oracle and/or its affiliates. All rights reserved.
  */
 
 /* Copyright  (c) 2002 Graz University of Technology. All rights reserved.
@@ -1531,6 +1531,7 @@
      *
      * @exception Throwable If finalization fails.
      */
+    @SuppressWarnings("deprecation")
     protected void finalize() throws Throwable {
         disconnect();
     }
--- a/jdk/src/jdk.crypto.ec/share/legal/ecc.md	Tue Apr 18 13:19:42 2017 -0400
+++ b/jdk/src/jdk.crypto.ec/share/legal/ecc.md	Tue Apr 18 22:25:33 2017 +0200
@@ -6,7 +6,8 @@
 This notice is provided with respect to Elliptic Curve Cryptography,
 which is included with JRE, JDK, and OpenJDK.
 
-You are receiving a copy of the Elliptic Curve Cryptography library in source
+You are receiving a [copy](http://hg.openjdk.java.net/jdk9/jdk9/jdk/file/tip/src/jdk.crypto.ec/share/native/libsunec/impl)
+of the Elliptic Curve Cryptography library in source
 form with the JDK and OpenJDK source distributions, and as object code in
 the JRE & JDK runtimes.
 
--- a/jdk/src/jdk.crypto.mscapi/windows/classes/sun/security/mscapi/Key.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/jdk/src/jdk.crypto.mscapi/windows/classes/sun/security/mscapi/Key.java	Tue Apr 18 22:25:33 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -52,6 +52,7 @@
         /**
          * Finalization method
          */
+        @SuppressWarnings("deprecation")
         protected void finalize() throws Throwable
         {
             try {
--- a/jdk/src/jdk.editpad/share/classes/module-info.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/jdk/src/jdk.editpad/share/classes/module-info.java	Tue Apr 18 22:25:33 2017 +0200
@@ -26,6 +26,7 @@
 /**
  * Implementation of the edit pad service.
  *
+ * @moduleGraph
  * @since 9
  */
 module jdk.editpad {
--- a/jdk/src/jdk.incubator.httpclient/share/classes/module-info.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/jdk/src/jdk.incubator.httpclient/share/classes/module-info.java	Tue Apr 18 22:25:33 2017 +0200
@@ -27,6 +27,7 @@
  * Defines the high-level HTTP and WebSocket API.
  * {@Incubating}
  *
+ * @moduleGraph
  * @since 9
  */
 module jdk.incubator.httpclient {
--- a/jdk/src/jdk.internal.le/share/classes/jdk/internal/jline/console/ConsoleReader.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/jdk/src/jdk.internal.le/share/classes/jdk/internal/jline/console/ConsoleReader.java	Tue Apr 18 22:25:33 2017 +0200
@@ -306,6 +306,7 @@
      * Shuts down the ConsoleReader if the JVM attempts to clean it up.
      */
     @Override
+    @SuppressWarnings("deprecation")
     protected void finalize() throws Throwable {
         try {
             shutdown();
--- a/jdk/src/jdk.internal.le/share/classes/jdk/internal/jline/extra/EditingHistory.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/jdk/src/jdk.internal.le/share/classes/jdk/internal/jline/extra/EditingHistory.java	Tue Apr 18 22:25:33 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -74,7 +74,7 @@
                 //in.resetPromptLine(in.getPrompt(), in.getHistory().current().toString(), -1);
                 //but that would mean more re-writing on the screen, (and prints an additional
                 //empty line), so using setBuffer directly:
-                Method setBuffer = in.getClass().getDeclaredMethod("setBuffer", String.class);
+                Method setBuffer = ConsoleReader.class.getDeclaredMethod("setBuffer", String.class);
 
                 setBuffer.setAccessible(true);
                 setBuffer.invoke(in, in.getHistory().current().toString());
--- a/jdk/src/jdk.jartool/share/classes/sun/security/tools/jarsigner/Main.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/jdk/src/jdk.jartool/share/classes/sun/security/tools/jarsigner/Main.java	Tue Apr 18 22:25:33 2017 +0200
@@ -444,6 +444,7 @@
             } else if (collator.compare(flags, "-strict") ==0) {
                 strict = true;
             } else if (collator.compare(flags, "-h") == 0 ||
+                        collator.compare(flags, "-?") == 0 ||
                         collator.compare(flags, "-help") == 0) {
                 fullusage();
             } else {
--- a/jdk/src/jdk.jcmd/share/classes/sun/tools/common/ProcessArgumentMatcher.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/jdk/src/jdk.jcmd/share/classes/sun/tools/common/ProcessArgumentMatcher.java	Tue Apr 18 22:25:33 2017 +0200
@@ -25,7 +25,6 @@
 
 package sun.tools.common;
 
-import java.lang.reflect.Module;
 import java.net.URISyntaxException;
 import java.util.ArrayList;
 import java.util.Collection;
--- a/jdk/src/jdk.jdwp.agent/share/native/libjdwp/ModuleReferenceImpl.c	Tue Apr 18 13:19:42 2017 -0400
+++ b/jdk/src/jdk.jdwp.agent/share/native/libjdwp/ModuleReferenceImpl.c	Tue Apr 18 22:25:33 2017 +0200
@@ -29,8 +29,8 @@
 #include "ModuleReferenceImpl.h"
 
 
-static jclass jlrM(JNIEnv *env) {
-    return findClass(env, "Ljava/lang/reflect/Module;");
+static jclass jlM(JNIEnv *env) {
+    return findClass(env, "Ljava/lang/Module;");
 }
 
 static jboolean
@@ -43,7 +43,7 @@
     jobject module;
 
     if (method == NULL) {
-        method = getMethod(env, jlrM(env), "getName", "()Ljava/lang/String;");
+        method = getMethod(env, jlM(env), "getName", "()Ljava/lang/String;");
     }
     module = inStream_readModuleRef(getEnv(), in);
     if (inStream_error(in)) {
@@ -71,7 +71,7 @@
     jobject module;
 
     if (method == NULL) {
-        method = getMethod(env, jlrM(env), "getClassLoader", "()Ljava/lang/ClassLoader;");
+        method = getMethod(env, jlM(env), "getClassLoader", "()Ljava/lang/ClassLoader;");
     }
     module = inStream_readModuleRef(env, in);
     if (inStream_error(in)) {
--- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/Jlink.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/Jlink.java	Tue Apr 18 22:25:33 2017 +0200
@@ -26,7 +26,6 @@
 
 import java.lang.module.Configuration;
 import java.lang.module.ModuleFinder;
-import java.lang.reflect.Layer;
 import java.nio.ByteOrder;
 import java.nio.file.Path;
 import java.util.ArrayList;
@@ -55,10 +54,10 @@
      * @return A new plugin or null if plugin is unknown.
      */
     public static Plugin newPlugin(String name,
-            Map<String, String> configuration, Layer pluginsLayer) {
+            Map<String, String> configuration, ModuleLayer pluginsLayer) {
         Objects.requireNonNull(name);
         Objects.requireNonNull(configuration);
-        pluginsLayer = pluginsLayer == null ? Layer.boot() : pluginsLayer;
+        pluginsLayer = pluginsLayer == null ? ModuleLayer.boot() : pluginsLayer;
         return PluginRepository.newPlugin(configuration, name, pluginsLayer);
     }
 
@@ -330,7 +329,7 @@
 
     private PluginsConfiguration addAutoEnabledPlugins(PluginsConfiguration pluginsConfig) {
         List<Plugin> plugins = new ArrayList<>(pluginsConfig.getPlugins());
-        List<Plugin> bootPlugins = PluginRepository.getPlugins(Layer.boot());
+        List<Plugin> bootPlugins = PluginRepository.getPlugins(ModuleLayer.boot());
         for (Plugin bp : bootPlugins) {
             if (Utils.isAutoEnabled(bp)) {
                 try {
--- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/PluginRepository.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/PluginRepository.java	Tue Apr 18 22:25:33 2017 +0200
@@ -24,7 +24,6 @@
  */
 package jdk.tools.jlink.internal;
 
-import java.lang.reflect.Layer;
 import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.Iterator;
@@ -56,7 +55,7 @@
      * @return A provider or null if not found.
      */
     public static Plugin getPlugin(String name,
-            Layer pluginsLayer) {
+            ModuleLayer pluginsLayer) {
         return getPlugin(Plugin.class, name, pluginsLayer);
     }
 
@@ -69,7 +68,7 @@
      * @return A plugin or null if no plugin found.
      */
     public static Plugin newPlugin(Map<String, String> config, String name,
-            Layer pluginsLayer) {
+            ModuleLayer pluginsLayer) {
         Objects.requireNonNull(name);
         Objects.requireNonNull(pluginsLayer);
         Plugin plugin = getPlugin(name, pluginsLayer);
@@ -107,12 +106,12 @@
         registeredPlugins.remove(name);
     }
 
-    public static List<Plugin> getPlugins(Layer pluginsLayer) {
+    public static List<Plugin> getPlugins(ModuleLayer pluginsLayer) {
         return getPlugins(Plugin.class, pluginsLayer);
     }
 
     private static <T extends Plugin> T getPlugin(Class<T> clazz, String name,
-            Layer pluginsLayer) {
+            ModuleLayer pluginsLayer) {
         Objects.requireNonNull(name);
         Objects.requireNonNull(pluginsLayer);
         @SuppressWarnings("unchecked")
@@ -136,7 +135,7 @@
      * @param pluginsLayer
      * @return The list of plugins.
      */
-    private static <T extends Plugin> List<T> getPlugins(Class<T> clazz, Layer pluginsLayer) {
+    private static <T extends Plugin> List<T> getPlugins(Class<T> clazz, ModuleLayer pluginsLayer) {
         Objects.requireNonNull(pluginsLayer);
         List<T> factories = new ArrayList<>();
         try {
--- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/TaskHelper.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/TaskHelper.java	Tue Apr 18 22:25:33 2017 +0200
@@ -29,7 +29,6 @@
 import java.io.PrintWriter;
 import java.lang.module.Configuration;
 import java.lang.module.ModuleFinder;
-import java.lang.reflect.Layer;
 import java.nio.file.Files;
 import java.nio.file.Path;
 import java.nio.file.Paths;
@@ -211,7 +210,7 @@
 
     private final class PluginsHelper {
 
-        private Layer pluginsLayer = Layer.boot();
+        private ModuleLayer pluginsLayer = ModuleLayer.boot();
         private final List<Plugin> plugins;
         private String lastSorter;
         private boolean listPlugins;
@@ -655,7 +654,7 @@
             return defaults;
         }
 
-        public Layer getPluginsLayer() {
+        public ModuleLayer getPluginsLayer() {
             return pluginOptions.pluginsLayer;
         }
     }
@@ -725,18 +724,18 @@
         return System.getProperty("java.version");
     }
 
-    static Layer createPluginsLayer(List<Path> paths) {
+    static ModuleLayer createPluginsLayer(List<Path> paths) {
 
         Path[] dirs = paths.toArray(new Path[0]);
         ModuleFinder finder = ModulePath.of(Runtime.version(), true, dirs);
-        Configuration bootConfiguration = Layer.boot().configuration();
+        Configuration bootConfiguration = ModuleLayer.boot().configuration();
         try {
             Configuration cf = bootConfiguration
                 .resolveAndBind(ModuleFinder.of(),
                                 finder,
                                 Collections.emptySet());
             ClassLoader scl = ClassLoader.getSystemClassLoader();
-            return Layer.boot().defineModulesWithOneLoader(cf, scl);
+            return ModuleLayer.boot().defineModulesWithOneLoader(cf, scl);
         } catch (Exception ex) {
             // Malformed plugin modules (e.g.: same package in multiple modules).
             throw new PluginException("Invalid modules in the plugins path: " + ex);
--- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/Utils.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/Utils.java	Tue Apr 18 22:25:33 2017 +0200
@@ -24,7 +24,6 @@
  */
 package jdk.tools.jlink.internal;
 
-import java.lang.reflect.Module;
 import java.net.URI;
 import java.nio.file.FileSystem;
 import java.nio.file.FileSystems;
--- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/ReleaseInfoPlugin.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/ReleaseInfoPlugin.java	Tue Apr 18 22:25:33 2017 +0200
@@ -27,6 +27,7 @@
 import java.io.ByteArrayOutputStream;
 import java.io.FileInputStream;
 import java.io.IOException;
+import java.io.PrintWriter;
 import java.io.UncheckedIOException;
 import java.lang.module.ModuleDescriptor;
 import java.util.EnumSet;
@@ -43,8 +44,6 @@
 import jdk.tools.jlink.plugin.ResourcePoolBuilder;
 import jdk.tools.jlink.plugin.ResourcePoolEntry;
 import jdk.tools.jlink.plugin.ResourcePoolModule;
-import jdk.tools.jlink.plugin.Plugin.Category;
-import jdk.tools.jlink.plugin.Plugin.State;
 import jdk.tools.jlink.plugin.Plugin;
 
 /**
@@ -101,9 +100,9 @@
                 //     --release-info add:build_type=fastdebug,source=openjdk,java_version=9
                 // and put whatever value that was passed in command line.
 
-                config.keySet().stream().
-                    filter(s -> !NAME.equals(s)).
-                    forEach(s -> release.put(s, config.get(s)));
+                config.keySet().stream()
+                      .filter(s -> !NAME.equals(s))
+                      .forEach(s -> release.put(s, config.get(s)));
             }
             break;
 
@@ -148,8 +147,8 @@
 
         // put topological sorted module names separated by space
         release.put("MODULES",  new ModuleSorter(in.moduleView())
-                .sorted().map(ResourcePoolModule::name)
-                .collect(Collectors.joining(" ", "\"", "\"")));
+               .sorted().map(ResourcePoolModule::name)
+               .collect(Collectors.joining(" ", "\"", "\"")));
 
         // create a TOP level ResourcePoolEntry for "release" file.
         out.add(ResourcePoolEntry.create("/java.base/release",
@@ -160,11 +159,11 @@
     // Parse version string and return a string that includes only version part
     // leaving "pre", "build" information. See also: java.lang.Runtime.Version.
     private static String parseVersion(String str) {
-        return Runtime.Version.parse(str).
-            version().
-            stream().
-            map(Object::toString).
-            collect(Collectors.joining("."));
+        return Runtime.Version.parse(str)
+                      .version()
+                      .stream()
+                      .map(Object::toString)
+                      .collect(Collectors.joining("."));
     }
 
     private static String quote(String str) {
@@ -172,14 +171,12 @@
     }
 
     private byte[] releaseFileContent() {
-        Properties props = new Properties();
-        props.putAll(release);
         ByteArrayOutputStream baos = new ByteArrayOutputStream();
-        try {
-            props.store(baos, "");
-            return baos.toByteArray();
-        } catch (IOException ex) {
-            throw new UncheckedIOException(ex);
+        try (PrintWriter pw = new PrintWriter(baos)) {
+            release.entrySet().stream()
+                   .sorted(Map.Entry.comparingByKey())
+                   .forEach(e -> pw.format("%s=%s%n", e.getKey(), e.getValue()));
         }
+        return baos.toByteArray();
     }
 }
--- a/jdk/src/jdk.naming.dns/share/classes/com/sun/jndi/dns/DnsClient.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/jdk/src/jdk.naming.dns/share/classes/com/sun/jndi/dns/DnsClient.java	Tue Apr 18 22:25:33 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -142,6 +142,7 @@
         resps = Collections.synchronizedMap(new HashMap<Integer, byte[]>());
     }
 
+    @SuppressWarnings("deprecation")
     protected void finalize() {
         close();
     }
--- a/jdk/src/jdk.naming.rmi/share/classes/com/sun/jndi/rmi/registry/RegistryContext.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/jdk/src/jdk.naming.rmi/share/classes/com/sun/jndi/rmi/registry/RegistryContext.java	Tue Apr 18 22:25:33 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1999, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -119,6 +119,7 @@
         reference = ctx.reference;
     }
 
+    @SuppressWarnings("deprecation")
     protected void finalize() {
         close();
     }
@@ -593,6 +594,7 @@
         nextName = 0;
     }
 
+    @SuppressWarnings("deprecation")
     protected void finalize() {
         ctx.close();
     }
@@ -633,6 +635,7 @@
         }
     }
 
+    @SuppressWarnings("deprecation")
     public void close () {
         finalize();
     }
--- a/jdk/src/jdk.security.jgss/share/classes/com/sun/security/sasl/gsskerb/GssKrb5Base.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/jdk/src/jdk.security.jgss/share/classes/com/sun/security/sasl/gsskerb/GssKrb5Base.java	Tue Apr 18 22:25:33 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -158,6 +158,7 @@
         }
     }
 
+    @SuppressWarnings("deprecation")
     protected void finalize() throws Throwable {
         dispose();
     }
--- a/jdk/src/jdk.zipfs/share/classes/jdk/nio/zipfs/ZipFileSystem.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/jdk/src/jdk.zipfs/share/classes/jdk/nio/zipfs/ZipFileSystem.java	Tue Apr 18 22:25:33 2017 +0200
@@ -936,6 +936,7 @@
         return zc.toString(name);
     }
 
+    @SuppressWarnings("deprecation")
     protected void finalize() throws IOException {
         close();
     }
--- a/jdk/test/ProblemList.txt	Tue Apr 18 13:19:42 2017 -0400
+++ b/jdk/test/ProblemList.txt	Tue Apr 18 22:25:33 2017 +0200
@@ -289,8 +289,6 @@
 
 java/util/BitSet/BitSetStreamTest.java                          8079538 generic-all
 
-jdk/internal/util/jar/TestVersionedStream.java                  8177640 windows-all
-
 ############################################################################
 
 # jdk_instrument
--- a/jdk/test/TEST.ROOT	Tue Apr 18 13:19:42 2017 -0400
+++ b/jdk/test/TEST.ROOT	Tue Apr 18 22:25:33 2017 +0200
@@ -26,8 +26,8 @@
 # Allow querying of various System properties in @requires clauses
 requires.properties=sun.arch.data.model java.runtime.name
 
-# Tests using jtreg 4.2 b05 features
-requiredVersion=4.2 b05
+# Tests using jtreg 4.2 b07 features
+requiredVersion=4.2 b07
 
 # Path to libraries in the topmost test directory. This is needed so @library
 # does not need ../../ notation to reach them
--- a/jdk/test/com/sun/jdi/ArgumentValuesTest.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/jdk/test/com/sun/jdi/ArgumentValuesTest.java	Tue Apr 18 22:25:33 2017 +0200
@@ -1,13 +1,38 @@
-/** hard coded linenumbers in other tests - DO NOT CHANGE
- *  @test/nodynamiccopyright/
- *  @bug 4490824
- *  @summary JDI: provide arguments when no debug attributes present
+/*
+ * Copyright (c) 2007, 2017, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * 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.
  *
- *  @author jjh
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+//    THIS TEST IS LINE NUMBER SENSITIVE
+
+/**
+ * @test
+ * @bug 4490824
+ * @summary JDI: provide arguments when no debug attributes present
  *
- *  @run build TestScaffold VMConnection TargetListener TargetAdapter
- *  @run compile ArgumentValuesTest.java
- *  @run driver ArgumentValuesTest
+ * @author jjh
+ *
+ * @run build TestScaffold VMConnection TargetListener TargetAdapter
+ * @run compile ArgumentValuesTest.java
+ * @run driver ArgumentValuesTest
  */
 import com.sun.jdi.*;
 import com.sun.jdi.event.*;
@@ -35,26 +60,26 @@
     static List<Integer> intList;
 
     public static void noArgs() {
-        int index = 0;     // line 38
+        int index = 0;     // line NO_ARGS_LINE_1
     }
 
     public static void allArgs(char p_char, byte p_byte, short p_short,
                                int p_int, long p_long, float p_float,
                                double p_double, int p_iarray[], int p_marray[][],
                                String p_sarray1[], String p_string) {
-        int index = 0;      // line 45
+        int index = 0;      // line ALL_ARGS_LINE_1
     }
 
     public static void varArgs(String ... p1) {
-        int index = 0;     // line 49
+        int index = 0;     // line VAR_ARGS_LINE_1
     }
 
     public static void genericArgs(List<Integer> p1) {
-        int index = 0;     // line 53
+        int index = 0;     // line GENERIC_ARGS_LINE_1
     }
 
     public void instanceMethod(char p_char, byte p_byte) {
-        int index = 0;     // line 57
+        int index = 0;     // line INSTANCE_METHOD_LINE_1
     }
 
     public static void main(String[] args) {
@@ -81,6 +106,12 @@
  /********** test program **********/
 
 public class ArgumentValuesTest extends TestScaffold {
+    static final int NO_ARGS_LINE_1 = 63;
+    static final int ALL_ARGS_LINE_1 = 70;
+    static final int VAR_ARGS_LINE_1 = 74;
+    static final int GENERIC_ARGS_LINE_1 = 78;
+    static final int INSTANCE_METHOD_LINE_1 = 82;
+
     // Must be in same order as args to allArgs(....)
     String fieldNames[] = {"s_char1",   "s_byte1",   "s_short1",  "s_int1",
                            "s_long1",   "s_float1",  "s_double1", "s_iarray1",
@@ -118,7 +149,7 @@
 
         {
             System.out.println("----- Testing each type of arg");
-            bpe = resumeTo("ArgumentValuesTarg", 45);
+            bpe = resumeTo("ArgumentValuesTarg", ALL_ARGS_LINE_1);
             StackFrame frame = bpe.thread().frame(0);
 
             Method mmm = frame.location().method();
@@ -147,7 +178,7 @@
         // a method with no params
         {
             System.out.println("----- Testing no args");
-            bpe = resumeTo("ArgumentValuesTarg", 38);
+            bpe = resumeTo("ArgumentValuesTarg", NO_ARGS_LINE_1);
             StackFrame frame = bpe.thread().frame(0);
 
             Method mmm = frame.location().method();
@@ -165,7 +196,7 @@
         // as a String[3] in the method.
         {
             System.out.println("----- Testing var args");
-            bpe = resumeTo("ArgumentValuesTarg", 49);
+            bpe = resumeTo("ArgumentValuesTarg", VAR_ARGS_LINE_1);
             StackFrame frame = bpe.thread().frame(0);
 
             Method mmm = frame.location().method();
@@ -199,7 +230,7 @@
         // a method with with one generic param
         {
             System.out.println("----- Testing generic args");
-            bpe = resumeTo("ArgumentValuesTarg", 53);
+            bpe = resumeTo("ArgumentValuesTarg", GENERIC_ARGS_LINE_1);
             StackFrame frame = bpe.thread().frame(0);
 
             Method mmm = frame.location().method();
@@ -224,7 +255,7 @@
         // test instance method call
         {
             System.out.println("----- Testing instance method call");
-            bpe = resumeTo("ArgumentValuesTarg", 57);
+            bpe = resumeTo("ArgumentValuesTarg", INSTANCE_METHOD_LINE_1);
             StackFrame frame = bpe.thread().frame(0);
 
             Method mmm = frame.location().method();
--- a/jdk/test/com/sun/jdi/BreakpointTest.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/jdk/test/com/sun/jdi/BreakpointTest.java	Tue Apr 18 22:25:33 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2001, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2001, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -21,19 +21,20 @@
  * questions.
  */
 
+//    THIS TEST IS LINE NUMBER SENSITIVE
+
 /**
- *  @test
- *  @bug 6496524
- *  @summary Setting breakpoint in jdb crashes Hotspot JVM
- *
- *  @author jjh
+ * @test
+ * @bug 6496524
+ * @key intermittent
+ * @summary Setting breakpoint in jdb crashes Hotspot JVM
+ * @author jjh
  *
- *  @key intermittent
- *  @modules jdk.jdi
- *  @run build TestScaffold VMConnection TargetListener TargetAdapter
- *  @run compile -g BreakpointTest.java
- *  @run driver BreakpointTest
+ * @run build TestScaffold VMConnection TargetListener TargetAdapter
+ * @run compile -g BreakpointTest.java
+ * @run driver BreakpointTest
  */
+
 import com.sun.jdi.*;
 import com.sun.jdi.event.*;
 import com.sun.jdi.request.*;
@@ -47,7 +48,6 @@
 
 class BreakpointTarg {
     public final static int BKPT_LINE = 56;
-            // LINE NUMBER SENSITIVE
 
     public static long count;
     static void doit() {
--- a/jdk/test/com/sun/jdi/FetchLocals.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/jdk/test/com/sun/jdi/FetchLocals.java	Tue Apr 18 22:25:33 2017 +0200
@@ -1,13 +1,37 @@
-/** hard coded linenumbers in test - DO NOT CHANGE
- *  @test/nodynamiccopyright/
- *  @bug 4386002 4429245
- *  @summary Test fix for: Incorrect values reported for some locals of type long
+/*
+ * Copyright (c) 2013, 2017, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * 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).
  *
- *  @author Tim Bell
+ * 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.
  *
- *  @run build TestScaffold VMConnection TargetListener TargetAdapter
- *  @run compile -g FetchLocals.java
- *  @run driver FetchLocals
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+//    THIS TEST IS LINE NUMBER SENSITIVE
+
+/**
+ * @test
+ * @bug 4386002 4429245
+ * @summary Test fix for: Incorrect values reported for some locals of type long
+ * @author Tim Bell
+ *
+ * @run build TestScaffold VMConnection TargetListener TargetAdapter
+ * @run compile -g FetchLocals.java
+ * @run driver FetchLocals
  */
 import com.sun.jdi.*;
 import com.sun.jdi.event.*;
@@ -59,7 +83,7 @@
         System.out.println(f);
         System.out.print("d is: ");
         System.out.println(d);
-        System.out.println();   // Thie is Line 63...
+        System.out.println();   // This is FetchLocals::LINE
         if (w == 0xde00ad00be00ef00L) {
           System.out.print  ("The debugger was here.  w modified to: 0x");
           System.out.println(Long.toHexString(w));
@@ -87,6 +111,7 @@
 }
 
 public class FetchLocals extends TestScaffold {
+    static final int LINE = 86;
 
     FetchLocals (String args[]) {
         super(args);
@@ -355,7 +380,7 @@
          * Get to the bottom of testMethod():
          */
         try {
-            BreakpointEvent bpe = resumeTo("FetchLocalsDebugee", 63);
+            BreakpointEvent bpe = resumeTo("FetchLocalsDebugee", LINE);
             /*
              * Fetch values from fields; what did we get?
              */
--- a/jdk/test/com/sun/jdi/GetLocalVariables.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/jdk/test/com/sun/jdi/GetLocalVariables.java	Tue Apr 18 22:25:33 2017 +0200
@@ -1,14 +1,39 @@
-/** hard coded linenumbers in this test - DO NOT CHANGE
- *  @test/nodynamiccopyright/
- *  @bug 4359312 4450091
- *  @summary Test PTR 1421 JVM exceptions making a call to LocalVariable.type().name()
+/*
+ * Copyright (c) 2007, 2017, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * 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.
  *
- *  @author Tim Bell (based on the PTR 1421 report submitted by IBM).
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+//    THIS TEST IS LINE NUMBER SENSITIVE
+
+/**
+ * @test
+ * @bug 4359312 4450091
+ * @summary Test PTR 1421 JVM exceptions making a call to LocalVariable.type().name()
+ * @author Tim Bell (based on the PTR 1421 report submitted by IBM).
  *
- *  @run build TestScaffold VMConnection TargetListener TargetAdapter
- *  @run compile -g GetLocalVariables.java
- *  @run driver GetLocalVariables
+ * @run build TestScaffold VMConnection TargetListener TargetAdapter
+ * @run compile -g GetLocalVariables.java
+ * @run driver GetLocalVariables
  */
+
 import com.sun.jdi.*;
 import com.sun.jdi.event.*;
 import com.sun.jdi.request.*;
@@ -194,7 +219,7 @@
                                      l_long, l_float, l_double, l_iarray,
                                      l_marray, l_string);
 
-        e1.test_1();            // <-- this is line 197
+        e1.test_1();            // RESUME_TO_LINE
         e3.test_1();
         e4.test_1();
         e5.test_1();
@@ -231,6 +256,7 @@
  /********** test program **********/
 
 public class GetLocalVariables extends TestScaffold {
+    static final int RESUME_TO_LINE = 222;
     ReferenceType targetClass;
     ThreadReference mainThread;
 
@@ -257,7 +283,7 @@
         mainThread = bpe.thread();
         EventRequestManager erm = vm().eventRequestManager();
 
-        bpe = resumeTo("GetLocalVariablesTarg", 197);
+        bpe = resumeTo("GetLocalVariablesTarg", RESUME_TO_LINE);
         /*
          * We've arrived.  Look around at some variables.
          */
--- a/jdk/test/com/sun/jdi/GetSetLocalTest.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/jdk/test/com/sun/jdi/GetSetLocalTest.java	Tue Apr 18 22:25:33 2017 +0200
@@ -1,13 +1,37 @@
-/** hard coded linenumbers in other tests - DO NOT CHANGE
- *  @test/nodynamiccopyright/
- *  @bug 4300412
- *  @summary Test GetLocal* and SetLocal* functions
+/*
+ * Copyright (c) 2007, 2017, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * 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).
  *
- *  @author Serguei Spitsyn
+ * 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.
  *
- *  @run build TestScaffold VMConnection TargetListener TargetAdapter
- *  @run compile -g GetSetLocalTest.java
- *  @run driver GetSetLocalTest
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+//    THIS TEST IS LINE NUMBER SENSITIVE
+
+/**
+ * @test
+ * @bug 4300412
+ * @summary Test GetLocal* and SetLocal* functions
+ * @author Serguei Spitsyn
+ *
+ * @run build TestScaffold VMConnection TargetListener TargetAdapter
+ * @run compile -g GetSetLocalTest.java
+ * @run driver GetSetLocalTest
  */
 import com.sun.jdi.*;
 import com.sun.jdi.event.*;
@@ -35,7 +59,7 @@
         int result;
         {
              { boolean bool_1 = false;
-               intArg++;
+               intArg++; // START_LINE
              }
 
              boolean bool_2 = true;
@@ -111,7 +135,7 @@
              }
 
              Object obj_2 = new Object();
-             intArg++;  // <-- Last stop is at this point.
+             intArg++;  // STOP_LINE. Last stop is at this point.
                         //     Only obj_2 and intArg are valid
                         // Note: even result is not valid here!
         }
@@ -125,6 +149,8 @@
     /********** test program **********/
 
 public class GetSetLocalTest extends TestScaffold {
+    static final int START_LINE = 62;
+    static final int STOP_LINE = 138;
     ReferenceType targetClass;
     ThreadReference mainThread;
 
@@ -635,7 +661,7 @@
         println("EventRequestManager");
         StackFrame frame = null;
 
-        for (int line = 38; line < 118; line += 4) {
+        for (int line = START_LINE; line <= STOP_LINE; line += 4) {
             println("\n resumeTo(GetSetLocalTarg, " + line + ")");
             bpe = resumeTo("GetSetLocalTarg", line);
             frame = bpe.thread().frame(0);
--- a/jdk/test/com/sun/jdi/LambdaBreakpointTest.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/jdk/test/com/sun/jdi/LambdaBreakpointTest.java	Tue Apr 18 22:25:33 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -21,19 +21,18 @@
  * questions.
  */
 
-/********** LINE NUMBER SENSITIVE! *****************************************************************/
+//    THIS TEST IS LINE NUMBER SENSITIVE
 
 /**
- *  @test
- *  @summary Test setting breakpoints on lambda calls
- *
- *  @author Staffan Larsen
+ * @test
+ * @summary Test setting breakpoints on lambda calls
+ * @author Staffan Larsen
  *
- *  @modules jdk.jdi
- *  @run build TestScaffold VMConnection TargetListener TargetAdapter
- *  @run compile -g LambdaBreakpointTest.java
- *  @run driver LambdaBreakpointTest
+ * @run build TestScaffold VMConnection TargetListener TargetAdapter
+ * @run compile -g LambdaBreakpointTest.java
+ * @run driver LambdaBreakpointTest
  */
+
 import java.util.List;
 
 import com.sun.jdi.LocalVariable;
@@ -50,22 +49,17 @@
  /********** target program **********/
 
 class LambdaBreakpointTestTarg {
-
-    static int[] breakpointLines = {
-            63, 67, 64, 65, 66, 68
-    };
-
     public static void main(String[] args) {
         test();
     }
 
     private static void test() {
-        Runnable r = () -> {                          // B1: L62
-            String from = "lambda";                   // B3: L63
-            System.out.println("Hello from " + from); // B4: L64
-        };                                            // B5: L65
-        r.run();                                      // B2: L66
-        System.out.println("Goodbye.");               // B6: L67
+        Runnable r = () -> {                          // LambdaBreakpointTest::TEST_LINE_1, BKPT_LINES[0]
+            String from = "lambda";                   // LambdaBreakpointTest::TEST_LINE_2, BKPT_LINES[2]
+            System.out.println("Hello from " + from); // LambdaBreakpointTest::TEST_LINE_3, BKPT_LINES[3]
+        };                                            // LambdaBreakpointTest::TEST_LINE_4, BKPT_LINES[4]
+        r.run();                                      // LambdaBreakpointTest::TEST_LINE_5, BKPT_LINES[1]
+        System.out.println("Goodbye.");               // LambdaBreakpointTest::TEST_LINE_6, BKPT_LINES[5]
     }
 }
 
@@ -73,6 +67,21 @@
  /********** test program **********/
 
 public class LambdaBreakpointTest extends TestScaffold {
+    private static final int TEST_LINE_1 = 57;
+    private static final int TEST_LINE_2 = TEST_LINE_1 + 1;
+    private static final int TEST_LINE_3 = TEST_LINE_1 + 2;
+    private static final int TEST_LINE_4 = TEST_LINE_1 + 3;
+    private static final int TEST_LINE_5 = TEST_LINE_1 + 4;
+    private static final int TEST_LINE_6 = TEST_LINE_1 + 5;
+
+    private static final int[] BKPT_LINES = {
+        TEST_LINE_1,
+        TEST_LINE_5,
+        TEST_LINE_2,
+        TEST_LINE_3,
+        TEST_LINE_4,
+        TEST_LINE_6,
+    };
 
     LambdaBreakpointTest (String args[]) {
         super(args);
@@ -92,7 +101,7 @@
         startToMain("LambdaBreakpointTestTarg");
 
         // Put a breakpoint on each location in the order they should happen
-        for (int line : LambdaBreakpointTestTarg.breakpointLines) {
+        for (int line : BKPT_LINES) {
             System.out.println("Running to line: " + line);
             BreakpointEvent be = resumeTo("LambdaBreakpointTestTarg", line);
             int stoppedAt = be.location().lineNumber();
--- a/jdk/test/com/sun/jdi/LineNumberOnBraceTest.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/jdk/test/com/sun/jdi/LineNumberOnBraceTest.java	Tue Apr 18 22:25:33 2017 +0200
@@ -1,13 +1,37 @@
-/**
- *  @test/nodynamiccopyright/
- *  @bug 4952629 4870514
- *  @summary REGRESSION: javac generates a spurious line number entry on } else {
+/*
+ * Copyright (c) 2007, 2017, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
  *
- *  @author jjh
+ * 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.
  *
- *  @run build VMConnection TargetListener TargetAdapter
- *  @run compile -g LineNumberOnBraceTest.java
- *  @run driver LineNumberOnBraceTest
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+//    THIS TEST IS LINE NUMBER SENSITIVE
+
+/**
+ * @test
+ * @bug 4952629 4870514
+ * @summary REGRESSION: javac generates a spurious line number entry on } else {
+ * @author jjh
+ *
+ * @run build VMConnection TargetListener TargetAdapter
+ * @run compile -g LineNumberOnBraceTest.java
+ * @run driver LineNumberOnBraceTest
  */
 import com.sun.jdi.*;
 import com.sun.jdi.event.*;
@@ -15,29 +39,27 @@
 
 import java.util.*;
 
-    /********** LINE NUMBER SENSITIVE! *****************************************************************/
 class LineNumberOnBraceTarg {
 
-    public final static int stopLine = 29;   // THIS MUST BE THE LINE NUMBER OF THE // stopline LINE
-    public final static int stopLine2 = 35;  // THIS MUST BE THE LINE NUMBER OF THE // stopline2 LINE
-
+    public final static int STOP_LINE = 50;    // THIS MUST BE THE LINE NUMBER OF // STOP_LINE LINE
+    public final static int STOP_LINE_2 = 56;  // THIS MUST BE THE LINE NUMBER OF // STOP_LINE_2 LINE
 
     public static void main(String[] args){
         System.out.println("Howdy!");
         if (args.length == 0) {
-            System.out.println("No args to debuggee");             // stopLine
+            System.out.println("No args to debuggee");             // STOP_LINE
         } else {
             System.out.println("Some args to debuggee");
         }
-        if (args.length == 0) {
+        if (args.length == 0) {                                    // STOP_LINE + 4
             boolean b1 = false;
-            if (b1) {                                              // stopLine2
+            if (b1) {                                              // STOP_LINE_2
                 System.out.println("In 2nd else");                 // bug 4870514 is that we stop here.
             }
         } else {
             System.out.println("In 2nd else");
         }
-        System.out.println("Goodbye from LineNumberOnBraceTarg!");  // stopLine2 + 6
+        System.out.println("Goodbye from LineNumberOnBraceTarg!");
     }
 
     // This isn't part of the test; it is just here
@@ -78,7 +100,7 @@
         targetClass = bpe.location().declaringType();
         mainThread = bpe.thread();
 
-        resumeTo("LineNumberOnBraceTarg", LineNumberOnBraceTarg.stopLine);
+        resumeTo("LineNumberOnBraceTarg", LineNumberOnBraceTarg.STOP_LINE);
         StepEvent stepev = stepOverLine(mainThread);       // step to 2nd if (args.length
 
         // Bug 4952629 is that javac outputs a line number
@@ -87,24 +109,23 @@
 
         int ln = stepev.location().lineNumber();
         System.out.println("Debuggee is stopped at line " + ln);
-        if (ln != LineNumberOnBraceTarg.stopLine + 4) {
+        if (ln != LineNumberOnBraceTarg.STOP_LINE + 4) {
             failure("FAIL: Bug 4952629: Should be at line " +
-                    (LineNumberOnBraceTarg.stopLine + 4) +
+                    (LineNumberOnBraceTarg.STOP_LINE + 4) +
                     ", am at " + ln);
         } else {
             System.out.println("Passed test for 4952629");
         }
 
         // Test for bug 4870514
-        System.out.println("Resuming to " + LineNumberOnBraceTarg.stopLine2);
-        resumeTo("LineNumberOnBraceTarg", LineNumberOnBraceTarg.stopLine2);
-        System.out.println("Stopped at " + LineNumberOnBraceTarg.stopLine2);
+        System.out.println("Resuming to " + LineNumberOnBraceTarg.STOP_LINE_2);
+        resumeTo("LineNumberOnBraceTarg", LineNumberOnBraceTarg.STOP_LINE_2);
+        System.out.println("Stopped at " + LineNumberOnBraceTarg.STOP_LINE_2);
         stepev = stepOverLine(mainThread);
         ln = stepev.location().lineNumber();
         System.out.println("Debuggee is stopped at line " + ln);
-        if (ln == LineNumberOnBraceTarg.stopLine2 + 1) {
-            failure("FAIL: bug 4870514: Incorrectly stopped at " +
-                    (LineNumberOnBraceTarg.stopLine2 + 1));
+        if (ln <= LineNumberOnBraceTarg.STOP_LINE_2 + 1) {
+            failure("FAIL: bug 4870514: Incorrectly stopped at " + ln);
         } else {
             System.out.println("Passed test for 4870514");
         }
--- a/jdk/test/com/sun/jdi/PopAndStepTest.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/jdk/test/com/sun/jdi/PopAndStepTest.java	Tue Apr 18 22:25:33 2017 +0200
@@ -1,17 +1,39 @@
-/* /nodynamiccopyright/ */  // DO NOT DELETE ANY LINES!!!!
-//    THIS TEST IS LINE NUMBER SENSITIVE
-/**
- *  @test
- *  @bug 4530424
- *  @summary Hin says that doing a step over after a popframe acts like a resume.
+/*
+ * Copyright (c) 2007, 2017, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  *
- *  @author jjh
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+//    THIS TEST IS LINE NUMBER SENSITIVE
+
+/**
+ * @test
+ * @bug 4530424
+ * @summary Hin says that doing a step over after a popframe acts like a resume.
+ * @author jjh
  *
- *  @library ..
- *  @modules jdk.jdi
- *  @run build TestScaffold VMConnection TargetListener TargetAdapter
- *  @run compile -g PopAndStepTest.java
- *  @run driver PopAndStepTest
+ * @library ..
+ *
+ * @run build TestScaffold VMConnection TargetListener TargetAdapter
+ * @run compile -g PopAndStepTest.java
+ * @run driver PopAndStepTest
  */
 import com.sun.jdi.*;
 import com.sun.jdi.event.*;
@@ -19,25 +41,23 @@
 
 import java.util.*;
 
-    /********** LINE NUMBER SENSITIVE! *****************************************************************/
-
 class PopAndStepTarg {
     public void B() {
-        System.out.println("debuggee: in B");
-        System.out.println("debuggee: in B, back to A");   // add line breakpoint here line 27 !!!
+        System.out.println("debuggee: in B");             // B_LINE_1
+        System.out.println("debuggee: in B, back to A");  // B_LINE_2
     }
 
     public void A() {
-        System.out.println("debuggee: in A, about to call B");  // line 31
-        B();
-        System.out.println("debuggee: in A, back from B");      // line 33
-        throw new RuntimeException("debuggee: Got to line 34");
+        System.out.println("debuggee: in A, about to call B");  // A_LINE_1
+        B();                                                    // A_LINE_2
+        System.out.println("debuggee: in A, back from B");      // A_LINE_3
+        throw new RuntimeException("debuggee: Got to line A_LINE_4:" + PopAndStepTest.A_LINE_4); // A_LINE_4
     }
 
     public static void main(String[] args) {
-        System.out.println("debuggee: Howdy!");      // line 38
-        PopAndStepTarg xxx = new PopAndStepTarg();   // line 40
-        xxx.A();                                     // line 41
+        System.out.println("debuggee: Howdy!");      // MAIN_LINE_1
+        PopAndStepTarg xxx = new PopAndStepTarg();   // MAIN_LINE_2
+        xxx.A();                                     // MAIN_LINE_3
         System.out.println("debugee: Goodbye from PopAndStepTarg!");
     }
 }
@@ -46,6 +66,18 @@
     /********** test program **********/
 
 public class PopAndStepTest extends TestScaffold {
+    static final int B_LINE_1 = 46;
+    static final int B_LINE_2 = B_LINE_1 + 1;
+
+    static final int A_LINE_1 = 51;
+    static final int A_LINE_2 = A_LINE_1 + 1;
+    static final int A_LINE_3 = A_LINE_1 + 2;
+    static final int A_LINE_4 = A_LINE_1 + 3;
+
+    static final int MAIN_LINE_1 = 58;
+    static final int MAIN_LINE_2 = MAIN_LINE_1 + 1;
+    static final int MAIN_LINE_3 = MAIN_LINE_1 + 2;
+
     ReferenceType targetClass;
     ThreadReference mainThread;
 
@@ -116,10 +148,10 @@
         BreakpointEvent bpe = startToMain("PopAndStepTarg");
         targetClass = bpe.location().declaringType();
         mainThread = bpe.thread();
-        getDebuggeeLineNum(38);
+        getDebuggeeLineNum(MAIN_LINE_1);
 
-        println("Resuming to line 27");
-        bpe = resumeTo("PopAndStepTarg", 27); getDebuggeeLineNum(27);
+        println("Resuming to line B_LINE_2 : " + B_LINE_2);
+        bpe = resumeTo("PopAndStepTarg", B_LINE_2); getDebuggeeLineNum(B_LINE_2);
 
         // The failure is this:
         //   create step request
@@ -141,21 +173,21 @@
         srInto.enable(); // This fails
         mainThread.popFrames(frameFor("A"));
         //srInto.enable();   // if the enable is moved here, it passes
-        println("Popped back to line 41 in main, the call to A()");
-        println("Stepping into line 31");
-        waitForRequestedEvent(srInto);   // println
+        println("Popped back to line MAIN_LINE_3(" + MAIN_LINE_3 + ") in main, the call to A()");
+        println("Stepping into line A_LINE_1:" + A_LINE_1);
+        waitForRequestedEvent(srInto);  // println
         srInto.disable();
 
-        getDebuggeeLineNum(31);
+        getDebuggeeLineNum(A_LINE_1);
 
         // The failure occurs here.
-        println("Stepping over to line 32");
-        stepOverLine(mainThread);   // println
-        getDebuggeeLineNum(32);
+        println("Stepping over to line A_LINE_2:" + A_LINE_2);
+        stepOverLine(mainThread);       // println
+        getDebuggeeLineNum(A_LINE_2);
 
-        println("Stepping over to line 33");
-        stepOverLine(mainThread);        // call to B()
-        getDebuggeeLineNum(33);
+        println("Stepping over to line A_LINE_3:" + A_LINE_3);
+        stepOverLine(mainThread);       // call to B()
+        getDebuggeeLineNum(A_LINE_3);
 
         vm().exit(0);
 
--- a/jdk/test/java/awt/TrayIcon/SystemTrayIconHelper.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/jdk/test/java/awt/TrayIcon/SystemTrayIconHelper.java	Tue Apr 18 22:25:33 2017 +0200
@@ -81,7 +81,7 @@
             try {
                 // sun.lwawt.macosx.CTrayIcon
                 Field f_peer = getField( java.awt.TrayIcon.class, "peer");
-                Method m_addExports = Class.forName("java.awt.Helper").getDeclaredMethod("addExports", String.class, java.lang.reflect.Module.class);
+                Method m_addExports = Class.forName("java.awt.Helper").getDeclaredMethod("addExports", String.class, java.lang.Module.class);
                 m_addExports.invoke(null, "sun.lwawt.macosx", robot.getClass().getModule());
 
 
@@ -105,7 +105,7 @@
         } else {
             try {
                 // sun.awt.X11.XTrayIconPeer
-                Method m_addExports = Class.forName("java.awt.Helper").getDeclaredMethod("addExports", String.class, java.lang.reflect.Module.class);
+                Method m_addExports = Class.forName("java.awt.Helper").getDeclaredMethod("addExports", String.class, java.lang.Module.class);
                 m_addExports.invoke(null, "sun.awt.X11", robot.getClass().getModule());
 
                 Field f_peer = getField(java.awt.TrayIcon.class, "peer");
--- a/jdk/test/java/awt/patchlib/java.desktop/java/awt/Helper.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/jdk/test/java/awt/patchlib/java.desktop/java/awt/Helper.java	Tue Apr 18 22:25:33 2017 +0200
@@ -22,7 +22,6 @@
  */
 
 package java.awt;
-import java.lang.reflect.Module;
 public class Helper {
     private Helper() { }
     public static void addExports(String pn, Module target) {
--- a/jdk/test/java/awt/regtesthelpers/Util.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/jdk/test/java/awt/regtesthelpers/Util.java	Tue Apr 18 22:25:33 2017 +0200
@@ -445,7 +445,7 @@
 
         try {
             final Class _clazz = clazz;
-            Method m_addExports = Class.forName("java.awt.Helper").getDeclaredMethod("addExports", String.class, java.lang.reflect.Module.class);
+            Method m_addExports = Class.forName("java.awt.Helper").getDeclaredMethod("addExports", String.class, java.lang.Module.class);
             // No MToolkit anymore: nothing to do about it.
             // We may be called from non-X11 system, and this permission cannot be delegated to a test.
             m_addExports.invoke(null, "sun.awt.X11", Util.class.getModule());
--- a/jdk/test/java/lang/Class/GetModuleTest.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/jdk/test/java/lang/Class/GetModuleTest.java	Tue Apr 18 22:25:33 2017 +0200
@@ -31,7 +31,6 @@
  */
 
 import java.awt.Component;
-import java.lang.reflect.Module;
 
 import jdk.internal.org.objectweb.asm.ClassWriter;
 import static jdk.internal.org.objectweb.asm.Opcodes.*;
--- a/jdk/test/java/lang/Class/forName/modules/TestLayer.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/jdk/test/java/lang/Class/forName/modules/TestLayer.java	Tue Apr 18 22:25:33 2017 +0200
@@ -23,9 +23,7 @@
 
 import java.lang.module.Configuration;
 import java.lang.module.ModuleFinder;
-import java.lang.reflect.Layer;
 import java.lang.reflect.Method;
-import java.lang.reflect.Module;
 import java.net.URL;
 import java.net.URLClassLoader;
 import java.nio.file.Path;
@@ -45,13 +43,13 @@
 
         ModuleFinder finder = ModuleFinder.of(MODS_DIR);
 
-        Configuration parent = Layer.boot().configuration();
+        Configuration parent = ModuleLayer.boot().configuration();
         Configuration cf = parent.resolveAndBind(ModuleFinder.of(),
                                                  finder,
                                                  modules);
 
         ClassLoader scl = ClassLoader.getSystemClassLoader();
-        Layer layer = Layer.boot().defineModulesWithManyLoaders(cf, scl);
+        ModuleLayer layer = ModuleLayer.boot().defineModulesWithManyLoaders(cf, scl);
 
         Module m1 = layer.findModule("m1").get();
         Module m2 = layer.findModule("m2").get();
--- a/jdk/test/java/lang/Class/forName/modules/TestMain.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/jdk/test/java/lang/Class/forName/modules/TestMain.java	Tue Apr 18 22:25:33 2017 +0200
@@ -21,13 +21,11 @@
  * questions.
  */
 
-import java.lang.reflect.Layer;
 import java.lang.reflect.Method;
-import java.lang.reflect.Module;
 
 public class TestMain {
     public static void main(String[] args) throws Exception {
-        Layer boot = Layer.boot();
+        ModuleLayer boot = ModuleLayer.boot();
         Module m1 = boot.findModule("m1").get();
         Module m2 = boot.findModule("m2").get();
 
--- a/jdk/test/java/lang/Class/forName/modules/src/m2/p2/test/Main.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/jdk/test/java/lang/Class/forName/modules/src/m2/p2/test/Main.java	Tue Apr 18 22:25:33 2017 +0200
@@ -23,12 +23,9 @@
 
 package p2.test;
 
-import java.lang.reflect.Layer;
-import java.lang.reflect.Module;
-
 public class Main {
     public static void main(String... args) throws Exception {
-        Layer boot = Layer.boot();
+        ModuleLayer boot = ModuleLayer.boot();
         Module m1 = boot.findModule("m1").get();
         Module m2 = Main.class.getModule();
 
--- a/jdk/test/java/lang/Class/forName/modules/src/m3/p3/NoAccess.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/jdk/test/java/lang/Class/forName/modules/src/m3/p3/NoAccess.java	Tue Apr 18 22:25:33 2017 +0200
@@ -26,8 +26,6 @@
 import java.io.FilePermission;
 import java.lang.module.Configuration;
 import java.lang.module.ModuleFinder;
-import java.lang.reflect.Layer;
-import java.lang.reflect.Module;
 import java.nio.file.Path;
 import java.nio.file.Paths;
 import java.security.AccessControlException;
@@ -47,7 +45,7 @@
 
         ModuleFinder finder = ModuleFinder.of(Paths.get("mods1"), Paths.get("mods2"));
 
-        Layer bootLayer = Layer.boot();
+        ModuleLayer bootLayer = ModuleLayer.boot();
         Configuration parent = bootLayer.configuration();
 
         Configuration cf = parent.resolveAndBind(finder,
@@ -55,7 +53,7 @@
                                                  Set.of("m1", "m2"));
 
         ClassLoader scl = ClassLoader.getSystemClassLoader();
-        Layer layer = bootLayer.defineModulesWithManyLoaders(cf, scl);
+        ModuleLayer layer = bootLayer.defineModulesWithManyLoaders(cf, scl);
 
         if (sm != null) {
             System.setSecurityManager(sm);
--- a/jdk/test/java/lang/Class/forName/modules/src/m3/p3/NoGetClassLoaderAccess.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/jdk/test/java/lang/Class/forName/modules/src/m3/p3/NoGetClassLoaderAccess.java	Tue Apr 18 22:25:33 2017 +0200
@@ -23,8 +23,6 @@
 
 package p3;
 
-import java.lang.reflect.Layer;
-import java.lang.reflect.Module;
 import java.security.AccessControlException;
 import java.security.Permission;
 
@@ -37,7 +35,7 @@
     private static final Permission GET_CLASSLOADER_PERMISSION = new RuntimePermission("getClassLoader");
 
     public static void main(String[] args) throws Exception {
-        Layer boot = Layer.boot();
+        ModuleLayer boot = ModuleLayer.boot();
 
         System.setSecurityManager(new SecurityManager());
         Module m1 = boot.findModule("m1").get();
--- a/jdk/test/java/lang/Class/getDeclaredField/FieldSetAccessibleTest.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/jdk/test/java/lang/Class/getDeclaredField/FieldSetAccessibleTest.java	Tue Apr 18 22:25:33 2017 +0200
@@ -26,10 +26,8 @@
 import java.io.UncheckedIOException;
 import java.lang.reflect.AccessibleObject;
 import java.lang.reflect.Field;
-import java.lang.reflect.Module;
 import java.lang.reflect.Modifier;
 import java.lang.reflect.InaccessibleObjectException;
-import java.lang.reflect.Layer;
 import java.lang.reflect.ReflectPermission;
 import java.net.URI;
 import java.nio.file.FileSystem;
@@ -269,7 +267,7 @@
             try {
                 return Files.walk(root)
                         .filter(p -> p.getNameCount() > 2)
-                        .filter(p -> Layer.boot().findModule(p.getName(1).toString()).isPresent())
+                        .filter(p -> ModuleLayer.boot().findModule(p.getName(1).toString()).isPresent())
                         .map(p -> p.subpath(2, p.getNameCount()))
                         .map(p -> p.toString())
                         .filter(s -> s.endsWith(".class") && !s.endsWith("module-info.class"))
--- a/jdk/test/java/lang/Class/getResource/Main.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/jdk/test/java/lang/Class/getResource/Main.java	Tue Apr 18 22:25:33 2017 +0200
@@ -23,7 +23,6 @@
 
 import java.lang.module.Configuration;
 import java.lang.module.ResolvedModule;
-import java.lang.reflect.Layer;
 import java.io.IOException;
 import java.io.InputStream;
 import java.net.URL;
@@ -256,7 +255,7 @@
      * Returns the directory for the given module (by name).
      */
     static Path directoryFor(String name) {
-        Configuration cf = Layer.boot().configuration();
+        Configuration cf = ModuleLayer.boot().configuration();
         ResolvedModule resolvedModule = cf.findModule(name).orElse(null);
         if (resolvedModule == null)
             throw new RuntimeException("not found: " + name);
--- a/jdk/test/java/lang/ClassLoader/getResource/automaticmodules/Main.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/jdk/test/java/lang/ClassLoader/getResource/automaticmodules/Main.java	Tue Apr 18 22:25:33 2017 +0200
@@ -26,7 +26,6 @@
 import java.lang.module.ModuleReader;
 import java.lang.module.ModuleReference;
 import java.lang.module.ResolvedModule;
-import java.lang.reflect.Layer;
 import java.net.URL;
 import java.util.Enumeration;
 
@@ -74,7 +73,7 @@
     public static void main(String[] args) throws Exception {
         String mn = args[0];
 
-        ModuleReference mref = Layer.boot()
+        ModuleReference mref = ModuleLayer.boot()
                 .configuration()
                 .findModule(mn)
                 .map(ResolvedModule::reference)
--- a/jdk/test/java/lang/ClassLoader/getResource/modules/Main.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/jdk/test/java/lang/ClassLoader/getResource/modules/Main.java	Tue Apr 18 22:25:33 2017 +0200
@@ -24,7 +24,6 @@
 import java.io.InputStream;
 import java.lang.module.Configuration;
 import java.lang.module.ResolvedModule;
-import java.lang.reflect.Layer;
 import java.io.IOException;
 import java.net.URL;
 import java.nio.file.Files;
@@ -309,7 +308,7 @@
      * Returns the directory for the given module (by name).
      */
     static Path directoryFor(String mn) {
-        Configuration cf = Layer.boot().configuration();
+        Configuration cf = ModuleLayer.boot().configuration();
         ResolvedModule resolvedModule = cf.findModule(mn).orElse(null);
         if (resolvedModule == null)
             throw new RuntimeException("not found: " + mn);
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/lang/ModuleLayer/BasicLayerTest.java	Tue Apr 18 22:25:33 2017 +0200
@@ -0,0 +1,1213 @@
+/*
+ * Copyright (c) 2014, 2017, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * 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
+ * @library /lib/testlibrary
+ * @modules java.base/jdk.internal.misc
+ * @build BasicLayerTest ModuleUtils
+ * @compile layertest/Test.java
+ * @run testng BasicLayerTest
+ * @summary Basic tests for java.lang.ModuleLayer
+ */
+
+import java.lang.module.Configuration;
+import java.lang.module.ModuleDescriptor;
+import java.lang.module.ModuleDescriptor.Requires;
+import java.lang.module.ModuleFinder;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Optional;
+import java.util.Set;
+import java.util.stream.Collectors;
+
+import jdk.internal.misc.SharedSecrets;
+
+import org.testng.annotations.DataProvider;
+import org.testng.annotations.Test;
+import static org.testng.Assert.*;
+
+@Test
+public class BasicLayerTest {
+
+    /**
+     * Creates a "non-strict" builder for building a module. This allows the
+     * test the create ModuleDescriptor objects that do not require java.base.
+     */
+    private static ModuleDescriptor.Builder newBuilder(String mn) {
+        return SharedSecrets.getJavaLangModuleAccess()
+                .newModuleBuilder(mn, false, Set.of());
+    }
+
+    /**
+     * Exercise ModuleLayer.empty()
+     */
+    public void testEmpty() {
+        ModuleLayer emptyLayer = ModuleLayer.empty();
+
+        assertTrue(emptyLayer.parents().isEmpty());
+
+        assertTrue(emptyLayer.configuration() == Configuration.empty());
+
+        assertTrue(emptyLayer.modules().isEmpty());
+
+        assertFalse(emptyLayer.findModule("java.base").isPresent());
+
+        try {
+            emptyLayer.findLoader("java.base");
+            assertTrue(false);
+        } catch (IllegalArgumentException expected) { }
+    }
+
+
+    /**
+     * Exercise ModuleLayer.boot()
+     */
+    public void testBoot() {
+        ModuleLayer bootLayer = ModuleLayer.boot();
+
+        // configuration
+        Configuration cf = bootLayer.configuration();
+        assertTrue(cf.findModule("java.base").get()
+                .reference()
+                .descriptor()
+                .exports()
+                .stream().anyMatch(e -> (e.source().equals("java.lang")
+                                         && !e.isQualified())));
+
+        // modules
+        Set<Module> modules = bootLayer.modules();
+        assertTrue(modules.contains(Object.class.getModule()));
+        int count = (int) modules.stream().map(Module::getName).count();
+        assertEquals(count, modules.size()); // module names are unique
+
+        // findModule
+        Module base = Object.class.getModule();
+        assertTrue(bootLayer.findModule("java.base").get() == base);
+        assertTrue(base.getLayer() == bootLayer);
+
+        // findLoader
+        assertTrue(bootLayer.findLoader("java.base") == null);
+
+        // parents
+        assertTrue(bootLayer.parents().size() == 1);
+        assertTrue(bootLayer.parents().get(0) == ModuleLayer.empty());
+    }
+
+
+    /**
+     * Exercise defineModules, created with empty layer as parent
+     */
+    public void testLayerOnEmpty() {
+        ModuleDescriptor descriptor1 = newBuilder("m1")
+                .requires("m2")
+                .exports("p1")
+                .build();
+
+        ModuleDescriptor descriptor2 = newBuilder("m2")
+                .requires("m3")
+                .build();
+
+        ModuleDescriptor descriptor3 = newBuilder("m3")
+                .build();
+
+        ModuleFinder finder
+            = ModuleUtils.finderOf(descriptor1, descriptor2, descriptor3);
+
+        Configuration cf = resolve(finder, "m1");
+
+        // map each module to its own class loader for this test
+        ClassLoader loader1 = new ClassLoader() { };
+        ClassLoader loader2 = new ClassLoader() { };
+        ClassLoader loader3 = new ClassLoader() { };
+        Map<String, ClassLoader> map = new HashMap<>();
+        map.put("m1", loader1);
+        map.put("m2", loader2);
+        map.put("m3", loader3);
+
+        ModuleLayer layer = ModuleLayer.empty().defineModules(cf, map::get);
+
+        // configuration
+        assertTrue(layer.configuration() == cf);
+        assertTrue(layer.configuration().modules().size() == 3);
+
+        // modules
+        Set<Module> modules = layer.modules();
+        assertTrue(modules.size() == 3);
+        Set<String> names = modules.stream()
+            .map(Module::getName)
+            .collect(Collectors.toSet());
+        assertTrue(names.contains("m1"));
+        assertTrue(names.contains("m2"));
+        assertTrue(names.contains("m3"));
+
+        // findModule
+        Module m1 = layer.findModule("m1").get();
+        Module m2 = layer.findModule("m2").get();
+        Module m3 = layer.findModule("m3").get();
+        assertEquals(m1.getName(), "m1");
+        assertEquals(m2.getName(), "m2");
+        assertEquals(m3.getName(), "m3");
+        assertTrue(m1.getDescriptor() == descriptor1);
+        assertTrue(m2.getDescriptor() == descriptor2);
+        assertTrue(m3.getDescriptor() == descriptor3);
+        assertTrue(m1.getLayer() == layer);
+        assertTrue(m2.getLayer() == layer);
+        assertTrue(m3.getLayer() == layer);
+        assertTrue(modules.contains(m1));
+        assertTrue(modules.contains(m2));
+        assertTrue(modules.contains(m3));
+        assertFalse(layer.findModule("godot").isPresent());
+
+        // findLoader
+        assertTrue(layer.findLoader("m1") == loader1);
+        assertTrue(layer.findLoader("m2") == loader2);
+        assertTrue(layer.findLoader("m3") == loader3);
+        try {
+            ClassLoader loader = layer.findLoader("godot");
+            assertTrue(false);
+        } catch (IllegalArgumentException ignore) { }
+
+        // parents
+        assertTrue(layer.parents().size() == 1);
+        assertTrue(layer.parents().get(0) == ModuleLayer.empty());
+    }
+
+
+    /**
+     * Exercise defineModules, created with boot layer as parent
+     */
+    public void testLayerOnBoot() {
+        ModuleDescriptor descriptor1 = newBuilder("m1")
+                .requires("m2")
+                .requires("java.base")
+                .exports("p1")
+                .build();
+
+        ModuleDescriptor descriptor2 = newBuilder("m2")
+                .requires("java.base")
+                .build();
+
+        ModuleFinder finder
+            = ModuleUtils.finderOf(descriptor1, descriptor2);
+
+        Configuration parent = ModuleLayer.boot().configuration();
+        Configuration cf = resolve(parent, finder, "m1");
+
+        ClassLoader loader = new ClassLoader() { };
+
+        ModuleLayer layer = ModuleLayer.boot().defineModules(cf, mn -> loader);
+
+        // configuration
+        assertTrue(layer.configuration() == cf);
+        assertTrue(layer.configuration().modules().size() == 2);
+
+        // modules
+        Set<Module> modules = layer.modules();
+        assertTrue(modules.size() == 2);
+        Set<String> names = modules.stream()
+            .map(Module::getName)
+            .collect(Collectors.toSet());
+        assertTrue(names.contains("m1"));
+        assertTrue(names.contains("m2"));
+
+        // findModule
+        Module m1 = layer.findModule("m1").get();
+        Module m2 = layer.findModule("m2").get();
+        assertEquals(m1.getName(), "m1");
+        assertEquals(m2.getName(), "m2");
+        assertTrue(m1.getDescriptor() == descriptor1);
+        assertTrue(m2.getDescriptor() == descriptor2);
+        assertTrue(m1.getLayer() == layer);
+        assertTrue(m2.getLayer() == layer);
+        assertTrue(modules.contains(m1));
+        assertTrue(modules.contains(m2));
+        assertTrue(layer.findModule("java.base").get() == Object.class.getModule());
+        assertFalse(layer.findModule("godot").isPresent());
+
+        // findLoader
+        assertTrue(layer.findLoader("m1") == loader);
+        assertTrue(layer.findLoader("m2") == loader);
+        assertTrue(layer.findLoader("java.base") == null);
+
+        // parents
+        assertTrue(layer.parents().size() == 1);
+        assertTrue(layer.parents().get(0) == ModuleLayer.boot());
+    }
+
+
+    /**
+     * Exercise defineModules with a configuration of two modules that
+     * have the same module-private package.
+     */
+    public void testPackageContainedInSelfAndOther() {
+        ModuleDescriptor descriptor1 =  newBuilder("m1")
+                .requires("m2")
+                .packages(Set.of("p"))
+                .build();
+
+        ModuleDescriptor descriptor2 = newBuilder("m2")
+                .packages(Set.of("p"))
+                .build();
+
+        ModuleFinder finder
+            = ModuleUtils.finderOf(descriptor1, descriptor2);
+
+        Configuration cf = resolve(finder, "m1");
+        assertTrue(cf.modules().size() == 2);
+
+        // one loader per module, should be okay
+        ModuleLayer.empty().defineModules(cf, mn -> new ClassLoader() { });
+
+        // same class loader
+        try {
+            ClassLoader loader = new ClassLoader() { };
+            ModuleLayer.empty().defineModules(cf, mn -> loader);
+            assertTrue(false);
+        } catch (LayerInstantiationException expected) { }
+    }
+
+
+    /**
+     * Exercise defineModules with a configuration that is a partitioned
+     * graph. The same package is exported in both partitions.
+     */
+    public void testSameExportInPartitionedGraph() {
+
+        // m1 reads m2, m2 exports p to m1
+        ModuleDescriptor descriptor1 =  newBuilder("m1")
+                .requires("m2")
+                .build();
+        ModuleDescriptor descriptor2 =  newBuilder("m2")
+                .exports("p", Set.of("m1"))
+                .build();
+
+        // m3 reads m4, m4 exports p to m3
+        ModuleDescriptor descriptor3 = newBuilder("m3")
+                .requires("m4")
+                .build();
+        ModuleDescriptor descriptor4 = newBuilder("m4")
+                .exports("p", Set.of("m3"))
+                .build();
+
+        ModuleFinder finder
+            = ModuleUtils.finderOf(descriptor1,
+                                   descriptor2,
+                                   descriptor3,
+                                   descriptor4);
+
+        Configuration cf = resolve(finder, "m1", "m3");
+        assertTrue(cf.modules().size() == 4);
+
+        // one loader per module
+        ModuleLayer.empty().defineModules(cf, mn -> new ClassLoader() { });
+
+        // m1 & m2 in one loader, m3 & m4 in another loader
+        ClassLoader loader1 = new ClassLoader() { };
+        ClassLoader loader2 = new ClassLoader() { };
+        Map<String, ClassLoader> map = new HashMap<>();
+        map.put("m1", loader1);
+        map.put("m2", loader1);
+        map.put("m3", loader2);
+        map.put("m4", loader2);
+        ModuleLayer.empty().defineModules(cf, map::get);
+
+        // same loader
+        try {
+            ClassLoader loader = new ClassLoader() { };
+            ModuleLayer.empty().defineModules(cf, mn -> loader);
+            assertTrue(false);
+        } catch (LayerInstantiationException expected) { }
+    }
+
+
+    /**
+     * Exercise defineModules with a configuration with a module that
+     * contains a package that is the same name as a non-exported package in
+     * a parent layer.
+     */
+    public void testContainsSamePackageAsBootLayer() {
+
+        // check assumption that java.base contains sun.launcher
+        ModuleDescriptor base = Object.class.getModule().getDescriptor();
+        assertTrue(base.packages().contains("sun.launcher"));
+
+        ModuleDescriptor descriptor = newBuilder("m1")
+               .requires("java.base")
+               .packages(Set.of("sun.launcher"))
+               .build();
+
+        ModuleFinder finder = ModuleUtils.finderOf(descriptor);
+
+        Configuration parent = ModuleLayer.boot().configuration();
+        Configuration cf = parent.resolve(finder, ModuleFinder.of(), Set.of("m1"));
+        assertTrue(cf.modules().size() == 1);
+
+        ClassLoader loader = new ClassLoader() { };
+        ModuleLayer layer = ModuleLayer.boot().defineModules(cf, mn -> loader);
+        assertTrue(layer.modules().size() == 1);
+   }
+
+
+    /**
+     * Test layers with implied readability.
+     *
+     * The test consists of three configurations:
+     * - Configuration/layer1: m1, m2 requires transitive m1
+     * - Configuration/layer2: m3 requires m1
+     */
+    public void testImpliedReadabilityWithLayers1() {
+
+        // cf1: m1 and m2, m2 requires transitive m1
+
+        ModuleDescriptor descriptor1 = newBuilder("m1")
+                .build();
+
+        ModuleDescriptor descriptor2 = newBuilder("m2")
+                .requires(Set.of(Requires.Modifier.TRANSITIVE), "m1")
+                .build();
+
+        ModuleFinder finder1 = ModuleUtils.finderOf(descriptor1, descriptor2);
+
+        Configuration cf1 = resolve(finder1, "m2");
+
+        ClassLoader cl1 = new ClassLoader() { };
+        ModuleLayer layer1 = ModuleLayer.empty().defineModules(cf1, mn -> cl1);
+
+
+        // cf2: m3, m3 requires m2
+
+        ModuleDescriptor descriptor3 = newBuilder("m3")
+                .requires("m2")
+                .build();
+
+        ModuleFinder finder2 = ModuleUtils.finderOf(descriptor3);
+
+        Configuration cf2 = resolve(cf1, finder2, "m3");
+
+        ClassLoader cl2 = new ClassLoader() { };
+        ModuleLayer layer2 = layer1.defineModules(cf2, mn -> cl2);
+
+        assertTrue(layer1.parents().size() == 1);
+        assertTrue(layer1.parents().get(0) == ModuleLayer.empty());
+
+        assertTrue(layer2.parents().size() == 1);
+        assertTrue(layer2.parents().get(0) == layer1);
+
+        Module m1 = layer2.findModule("m1").get();
+        Module m2 = layer2.findModule("m2").get();
+        Module m3 = layer2.findModule("m3").get();
+
+        assertTrue(m1.getLayer() == layer1);
+        assertTrue(m2.getLayer() == layer1);
+        assertTrue(m3.getLayer() == layer2);
+
+        assertTrue(m1.getClassLoader() == cl1);
+        assertTrue(m2.getClassLoader() == cl1);
+        assertTrue(m3.getClassLoader() == cl2);
+
+        assertTrue(m1.canRead(m1));
+        assertFalse(m1.canRead(m2));
+        assertFalse(m1.canRead(m3));
+
+        assertTrue(m2.canRead(m1));
+        assertTrue(m2.canRead(m2));
+        assertFalse(m2.canRead(m3));
+
+        assertTrue(m3.canRead(m1));
+        assertTrue(m3.canRead(m2));
+        assertTrue(m3.canRead(m3));
+    }
+
+
+    /**
+     * Test layers with implied readability.
+     *
+     * The test consists of three configurations:
+     * - Configuration/layer1: m1
+     * - Configuration/layer2: m2 requires transitive m3, m3 requires m2
+     */
+    public void testImpliedReadabilityWithLayers2() {
+
+        // cf1: m1
+
+        ModuleDescriptor descriptor1 = newBuilder("m1").build();
+
+        ModuleFinder finder1 = ModuleUtils.finderOf(descriptor1);
+
+        Configuration cf1 = resolve(finder1, "m1");
+
+        ClassLoader cl1 = new ClassLoader() { };
+        ModuleLayer layer1 = ModuleLayer.empty().defineModules(cf1, mn -> cl1);
+
+
+        // cf2: m2, m3: m2 requires transitive m1, m3 requires m2
+
+        ModuleDescriptor descriptor2 = newBuilder("m2")
+                .requires(Set.of(Requires.Modifier.TRANSITIVE), "m1")
+                .build();
+
+        ModuleDescriptor descriptor3 = newBuilder("m3")
+                .requires("m2")
+                .build();
+
+        ModuleFinder finder2 = ModuleUtils.finderOf(descriptor2, descriptor3);
+
+        Configuration cf2 = resolve(cf1, finder2, "m3");
+
+        ClassLoader cl2 = new ClassLoader() { };
+        ModuleLayer layer2 = layer1.defineModules(cf2, mn -> cl2);
+
+        assertTrue(layer1.parents().size() == 1);
+        assertTrue(layer1.parents().get(0) == ModuleLayer.empty());
+
+        assertTrue(layer2.parents().size() == 1);
+        assertTrue(layer2.parents().get(0) == layer1);
+
+        Module m1 = layer2.findModule("m1").get();
+        Module m2 = layer2.findModule("m2").get();
+        Module m3 = layer2.findModule("m3").get();
+
+        assertTrue(m1.getLayer() == layer1);
+        assertTrue(m2.getLayer() == layer2);
+        assertTrue(m3.getLayer() == layer2);
+
+        assertTrue(m1.canRead(m1));
+        assertFalse(m1.canRead(m2));
+        assertFalse(m1.canRead(m3));
+
+        assertTrue(m2.canRead(m1));
+        assertTrue(m2.canRead(m2));
+        assertFalse(m2.canRead(m3));
+
+        assertTrue(m3.canRead(m1));
+        assertTrue(m3.canRead(m2));
+        assertTrue(m3.canRead(m3));
+    }
+
+
+    /**
+     * Test layers with implied readability.
+     *
+     * The test consists of three configurations:
+     * - Configuration/layer1: m1
+     * - Configuration/layer2: m2 requires transitive m1
+     * - Configuration/layer3: m3 requires m1
+     */
+    public void testImpliedReadabilityWithLayers3() {
+
+        // cf1: m1
+
+        ModuleDescriptor descriptor1 = newBuilder("m1").build();
+
+        ModuleFinder finder1 = ModuleUtils.finderOf(descriptor1);
+
+        Configuration cf1 = resolve(finder1, "m1");
+
+        ClassLoader cl1 = new ClassLoader() { };
+        ModuleLayer layer1 = ModuleLayer.empty().defineModules(cf1, mn -> cl1);
+
+
+        // cf2: m2 requires transitive m1
+
+        ModuleDescriptor descriptor2 = newBuilder("m2")
+                .requires(Set.of(Requires.Modifier.TRANSITIVE), "m1")
+                .build();
+
+        ModuleFinder finder2 = ModuleUtils.finderOf(descriptor2);
+
+        Configuration cf2 = resolve(cf1, finder2, "m2");
+
+        ClassLoader cl2 = new ClassLoader() { };
+        ModuleLayer layer2 = layer1.defineModules(cf2, mn -> cl2);
+
+
+        // cf3: m3 requires m2
+
+        ModuleDescriptor descriptor3 = newBuilder("m3")
+                .requires("m2")
+                .build();
+
+        ModuleFinder finder3 = ModuleUtils.finderOf(descriptor3);
+
+        Configuration cf3 = resolve(cf2, finder3, "m3");
+
+        ClassLoader cl3 = new ClassLoader() { };
+        ModuleLayer layer3 = layer2.defineModules(cf3, mn -> cl3);
+
+        assertTrue(layer1.parents().size() == 1);
+        assertTrue(layer1.parents().get(0) == ModuleLayer.empty());
+
+        assertTrue(layer2.parents().size() == 1);
+        assertTrue(layer2.parents().get(0) == layer1);
+
+        assertTrue(layer3.parents().size() == 1);
+        assertTrue(layer3.parents().get(0) == layer2);
+
+        Module m1 = layer3.findModule("m1").get();
+        Module m2 = layer3.findModule("m2").get();
+        Module m3 = layer3.findModule("m3").get();
+
+        assertTrue(m1.getLayer() == layer1);
+        assertTrue(m2.getLayer() == layer2);
+        assertTrue(m3.getLayer() == layer3);
+
+        assertTrue(m1.canRead(m1));
+        assertFalse(m1.canRead(m2));
+        assertFalse(m1.canRead(m3));
+
+        assertTrue(m2.canRead(m1));
+        assertTrue(m2.canRead(m2));
+        assertFalse(m2.canRead(m3));
+
+        assertTrue(m3.canRead(m1));
+        assertTrue(m3.canRead(m2));
+        assertTrue(m3.canRead(m3));
+    }
+
+
+    /**
+     * Test layers with implied readability.
+     *
+     * The test consists of two configurations:
+     * - Configuration/layer1: m1, m2 requires transitive m1
+     * - Configuration/layer2: m3 requires transitive m2, m4 requires m3
+     */
+    public void testImpliedReadabilityWithLayers4() {
+
+        // cf1: m1, m2 requires transitive m1
+
+        ModuleDescriptor descriptor1 = newBuilder("m1")
+                .build();
+
+        ModuleDescriptor descriptor2 = newBuilder("m2")
+                .requires(Set.of(Requires.Modifier.TRANSITIVE), "m1")
+                .build();
+
+        ModuleFinder finder1 = ModuleUtils.finderOf(descriptor1, descriptor2);
+
+        Configuration cf1 = resolve(finder1, "m2");
+
+        ClassLoader cl1 = new ClassLoader() { };
+        ModuleLayer layer1 = ModuleLayer.empty().defineModules(cf1, mn -> cl1);
+
+
+        // cf2: m3 requires transitive m2, m4 requires m3
+
+        ModuleDescriptor descriptor3 = newBuilder("m3")
+                .requires(Set.of(Requires.Modifier.TRANSITIVE), "m2")
+                .build();
+
+        ModuleDescriptor descriptor4 = newBuilder("m4")
+                .requires("m3")
+                .build();
+
+
+        ModuleFinder finder2 = ModuleUtils.finderOf(descriptor3, descriptor4);
+
+        Configuration cf2 = resolve(cf1, finder2, "m3", "m4");
+
+        ClassLoader cl2 = new ClassLoader() { };
+        ModuleLayer layer2 = layer1.defineModules(cf2, mn -> cl2);
+
+        assertTrue(layer1.parents().size() == 1);
+        assertTrue(layer1.parents().get(0) == ModuleLayer.empty());
+
+        assertTrue(layer2.parents().size() == 1);
+        assertTrue(layer2.parents().get(0) == layer1);
+
+        Module m1 = layer2.findModule("m1").get();
+        Module m2 = layer2.findModule("m2").get();
+        Module m3 = layer2.findModule("m3").get();
+        Module m4 = layer2.findModule("m4").get();
+
+        assertTrue(m1.getLayer() == layer1);
+        assertTrue(m2.getLayer() == layer1);
+        assertTrue(m3.getLayer() == layer2);
+        assertTrue(m4.getLayer() == layer2);
+
+        assertTrue(m1.canRead(m1));
+        assertFalse(m1.canRead(m2));
+        assertFalse(m1.canRead(m3));
+        assertFalse(m1.canRead(m4));
+
+        assertTrue(m2.canRead(m1));
+        assertTrue(m2.canRead(m2));
+        assertFalse(m1.canRead(m3));
+        assertFalse(m1.canRead(m4));
+
+        assertTrue(m3.canRead(m1));
+        assertTrue(m3.canRead(m2));
+        assertTrue(m3.canRead(m3));
+        assertFalse(m3.canRead(m4));
+
+        assertTrue(m4.canRead(m1));
+        assertTrue(m4.canRead(m2));
+        assertTrue(m4.canRead(m3));
+        assertTrue(m4.canRead(m4));
+    }
+
+
+    /**
+     * Test layers with a qualified export. The module exporting the package
+     * does not read the target module.
+     *
+     * m1 { exports p to m2 }
+     * m2 { }
+     */
+    public void testQualifiedExports1() {
+        ModuleDescriptor descriptor1 = newBuilder("m1").
+                exports("p", Set.of("m2"))
+                .build();
+
+        ModuleDescriptor descriptor2 = newBuilder("m2")
+                .build();
+
+        ModuleFinder finder1 = ModuleUtils.finderOf(descriptor1, descriptor2);
+
+        Configuration cf = resolve(finder1, "m1", "m2");
+
+        ClassLoader cl = new ClassLoader() { };
+        ModuleLayer layer = ModuleLayer.empty().defineModules(cf, mn -> cl);
+        assertTrue(layer.modules().size() == 2);
+
+        Module m1 = layer.findModule("m1").get();
+        Module m2 = layer.findModule("m2").get();
+
+        // check m1 exports p to m2
+        assertFalse(m1.isExported("p"));
+        assertTrue(m1.isExported("p", m2));
+        assertFalse(m1.isOpen("p", m2));
+    }
+
+
+    /**
+     * Test layers with a qualified export. The module exporting the package
+     * reads the target module.
+     *
+     * m1 { exports p to m2; }
+     * m2 { requires m1; }
+     */
+    public void testQualifiedExports2() {
+        ModuleDescriptor descriptor1 = newBuilder("m1")
+                .exports("p", Set.of("m2"))
+                .build();
+
+        ModuleDescriptor descriptor2 = newBuilder("m2")
+                .requires("m1")
+                .build();
+
+        ModuleFinder finder1 = ModuleUtils.finderOf(descriptor1, descriptor2);
+
+        Configuration cf = resolve(finder1, "m2");
+        ClassLoader cl = new ClassLoader() { };
+        ModuleLayer layer = ModuleLayer.empty().defineModules(cf, mn -> cl);
+        assertTrue(layer.modules().size() == 2);
+
+        Module m1 = layer.findModule("m1").get();
+        Module m2 = layer.findModule("m2").get();
+
+        // check m1 exports p to m2
+        assertFalse(m1.isExported("p"));
+        assertTrue(m1.isExported("p", m2));
+        assertFalse(m1.isOpen("p", m2));
+    }
+
+
+    /**
+     * Test layers with a qualified export. The module exporting the package
+     * does not read the target module in the parent layer.
+     *
+     * - Configuration/layer1: m1 { }
+     * - Configuration/layer2: m2 { exports p to m1; }
+     */
+    public void testQualifiedExports3() {
+        // create layer1 with m1
+        ModuleDescriptor descriptor1 = newBuilder("m1").build();
+        ModuleFinder finder1 = ModuleUtils.finderOf(descriptor1);
+        Configuration cf1 = resolve(finder1, "m1");
+        ClassLoader cl1 = new ClassLoader() { };
+        ModuleLayer layer1 = ModuleLayer.empty().defineModules(cf1, mn -> cl1);
+        assertTrue(layer1.modules().size() == 1);
+
+        // create layer2 with m2
+        ModuleDescriptor descriptor2 = newBuilder("m2")
+                .exports("p", Set.of("m1"))
+                .build();
+        ModuleFinder finder2 = ModuleUtils.finderOf(descriptor2);
+        Configuration cf2 = resolve(cf1, finder2, "m2");
+        ClassLoader cl2 = new ClassLoader() { };
+        ModuleLayer layer2 = layer1.defineModules(cf2, mn -> cl2);
+        assertTrue(layer2.modules().size() == 1);
+
+        Module m1 = layer1.findModule("m1").get();
+        Module m2 = layer2.findModule("m2").get();
+
+        // check m2 exports p to layer1/m1
+        assertFalse(m2.isExported("p"));
+        assertTrue(m2.isExported("p", m1));
+        assertFalse(m2.isOpen("p", m1));
+    }
+
+
+    /**
+     * Test layers with a qualified export. The module exporting the package
+     * reads the target module in the parent layer.
+     *
+     * - Configuration/layer1: m1 { }
+     * - Configuration/layer2: m2 { requires m1; exports p to m1; }
+     */
+    public void testQualifiedExports4() {
+        // create layer1 with m1
+        ModuleDescriptor descriptor1 = newBuilder("m1").build();
+        ModuleFinder finder1 = ModuleUtils.finderOf(descriptor1);
+        Configuration cf1 = resolve(finder1, "m1");
+        ClassLoader cl1 = new ClassLoader() { };
+        ModuleLayer layer1 = ModuleLayer.empty().defineModules(cf1, mn -> cl1);
+        assertTrue(layer1.modules().size() == 1);
+
+        // create layer2 with m2
+        ModuleDescriptor descriptor2 = newBuilder("m2")
+                .requires("m1")
+                .exports("p", Set.of("m1"))
+                .build();
+        ModuleFinder finder2 = ModuleUtils.finderOf(descriptor2);
+        Configuration cf2 = resolve(cf1, finder2, "m2");
+        ClassLoader cl2 = new ClassLoader() { };
+        ModuleLayer layer2 = layer1.defineModules(cf2, mn -> cl2);
+        assertTrue(layer2.modules().size() == 1);
+
+        Module m1 = layer1.findModule("m1").get();
+        Module m2 = layer2.findModule("m2").get();
+
+        // check m2 exports p to layer1/m1
+        assertFalse(m2.isExported("p"));
+        assertTrue(m2.isExported("p", m1));
+        assertFalse(m2.isOpen("p", m1));
+    }
+
+    /**
+     * Test layers with a qualified export. The module exporting the package
+     * does not read the target module.
+     *
+     * - Configuration/layer1: m1
+     * - Configuration/layer2: m1, m2 { exports p to m1; }
+     */
+    public void testQualifiedExports5() {
+        // create layer1 with m1
+        ModuleDescriptor descriptor1 = newBuilder("m1").build();
+        ModuleFinder finder1 = ModuleUtils.finderOf(descriptor1);
+        Configuration cf1 = resolve(finder1, "m1");
+        ClassLoader cl1 = new ClassLoader() { };
+        ModuleLayer layer1 = ModuleLayer.empty().defineModules(cf1, mn -> cl1);
+        assertTrue(layer1.modules().size() == 1);
+
+        // create layer2 with m1 and m2
+        ModuleDescriptor descriptor2 = newBuilder("m2").exports("p", Set.of("m1")).build();
+        ModuleFinder finder2 = ModuleUtils.finderOf(descriptor1, descriptor2);
+        Configuration cf2 = resolve(cf1, finder2, "m1", "m2");
+        ClassLoader cl2 = new ClassLoader() { };
+        ModuleLayer layer2 = layer1.defineModules(cf2, mn -> cl2);
+        assertTrue(layer2.modules().size() == 2);
+
+        Module m1_v1 = layer1.findModule("m1").get();
+        Module m1_v2 = layer2.findModule("m1").get();
+        Module m2 = layer2.findModule("m2").get();
+
+        // check m2 exports p to layer2/m2
+        assertFalse(m2.isExported("p"));
+        assertTrue(m2.isExported("p", m1_v2));
+        assertFalse(m2.isExported("p", m1_v1));
+    }
+
+
+    /**
+     * Test layers with a qualified export. The module exporting the package
+     * reads the target module in the parent layer (due to requires transitive).
+     *
+     * - Configuration/layer1: m1, m2 { requires transitive m1; }
+     * - Configuration/layer2: m1, m3 { requires m2; exports p to m1; }
+     */
+    public void testQualifiedExports6() {
+        // create layer1 with m1 and m2
+        ModuleDescriptor descriptor1 = newBuilder("m1").build();
+        ModuleDescriptor descriptor2 = newBuilder("m2")
+                .requires(Set.of(Requires.Modifier.TRANSITIVE), "m1")
+                .build();
+        ModuleFinder finder1 = ModuleUtils.finderOf(descriptor1, descriptor2);
+        Configuration cf1 = resolve(finder1, "m2");
+        ClassLoader loader1 = new ClassLoader() { };
+        ModuleLayer layer1 = ModuleLayer.empty().defineModules(cf1, mn -> loader1);
+        assertTrue(layer1.modules().size() == 2);
+
+        // create layer2 with m1 and m3
+        ModuleDescriptor descriptor3 = newBuilder("m3")
+                .requires("m2")
+                .exports("p", Set.of("m1"))
+                .build();
+        ModuleFinder finder2 = ModuleUtils.finderOf(descriptor1, descriptor3);
+        Configuration cf2 = resolve(cf1, finder2, "m1", "m3");
+        ClassLoader loader2 = new ClassLoader() { };
+        ModuleLayer layer2 = layer1.defineModules(cf2, mn -> loader2);
+        assertTrue(layer2.modules().size() == 2);
+
+        Module m1_v1 = layer1.findModule("m1").get();
+        Module m2 = layer1.findModule("m2").get();
+
+        Module m1_v2 = layer2.findModule("m1").get();
+        Module m3 = layer2.findModule("m3").get();
+
+        assertTrue(m3.canRead(m1_v1));
+        assertFalse(m3.canRead(m1_v2));
+
+        assertFalse(m3.isExported("p"));
+        assertTrue(m3.isExported("p", m1_v1));
+        assertFalse(m3.isExported("p", m1_v2));
+        assertFalse(m3.isExported("p", m2));
+    }
+
+
+    /**
+     * Test layers with a qualified export. The target module is not in any layer.
+     *
+     * - Configuration/layer1: m1 { }
+     * - Configuration/layer2: m2 { exports p to m3; }
+     */
+    public void testQualifiedExports7() {
+        // create layer1 with m1
+        ModuleDescriptor descriptor1 = newBuilder("m1").build();
+        ModuleFinder finder1 = ModuleUtils.finderOf(descriptor1);
+        Configuration cf1 = resolve(finder1, "m1");
+        ClassLoader cl1 = new ClassLoader() { };
+        ModuleLayer layer1 = ModuleLayer.empty().defineModules(cf1, mn -> cl1);
+        assertTrue(layer1.modules().size() == 1);
+
+        // create layer2 with m2
+        ModuleDescriptor descriptor2 = newBuilder("m2")
+                .exports("p", Set.of("m3"))
+                .build();
+        ModuleFinder finder2 = ModuleUtils.finderOf(descriptor2);
+        Configuration cf2 = resolve(cf1, finder2, "m2");
+        ClassLoader cl2 = new ClassLoader() { };
+        ModuleLayer layer2 = layer1.defineModules(cf2, mn -> cl2);
+        assertTrue(layer2.modules().size() == 1);
+
+        Module m1 = layer1.findModule("m1").get();
+        Module m2 = layer2.findModule("m2").get();
+
+        // check m2 does not export p to anyone
+        assertFalse(m2.isExported("p"));
+        assertFalse(m2.isExported("p", m1));
+    }
+
+    /**
+     * Attempt to use defineModules to create a layer with a module defined
+     * to a class loader that already has a module of the same name defined
+     * to the class loader.
+     */
+    @Test(expectedExceptions = { LayerInstantiationException.class })
+    public void testModuleAlreadyDefinedToLoader() {
+
+        ModuleDescriptor md = newBuilder("m")
+                .requires("java.base")
+                .build();
+
+        ModuleFinder finder = ModuleUtils.finderOf(md);
+
+        Configuration parent = ModuleLayer.boot().configuration();
+
+        Configuration cf = parent.resolve(finder, ModuleFinder.of(), Set.of("m"));
+
+        ClassLoader loader = new ClassLoader() { };
+
+        ModuleLayer.boot().defineModules(cf, mn -> loader);
+
+        // should throw LayerInstantiationException as m1 already defined to loader
+        ModuleLayer.boot().defineModules(cf, mn -> loader);
+
+    }
+
+
+    /**
+     * Attempt to use defineModules to create a layer with a module containing
+     * package {@code p} where the class loader already has a module defined
+     * to it containing package {@code p}.
+     */
+    @Test(expectedExceptions = { LayerInstantiationException.class })
+    public void testPackageAlreadyInNamedModule() {
+
+        ModuleDescriptor md1 = newBuilder("m1")
+                .packages(Set.of("p"))
+                .requires("java.base")
+                .build();
+
+        ModuleDescriptor md2 = newBuilder("m2")
+                .packages(Set.of("p"))
+                .requires("java.base")
+                .build();
+
+        ModuleFinder finder = ModuleUtils.finderOf(md1, md2);
+
+        ClassLoader loader = new ClassLoader() { };
+
+        // define m1 containing package p to class loader
+
+        Configuration parent = ModuleLayer.boot().configuration();
+
+        Configuration cf1 = parent.resolve(finder, ModuleFinder.of(), Set.of("m1"));
+
+        ModuleLayer layer1 = ModuleLayer.boot().defineModules(cf1, mn -> loader);
+
+        // attempt to define m2 containing package p to class loader
+
+        Configuration cf2 = parent.resolve(finder, ModuleFinder.of(), Set.of("m2"));
+
+        // should throw exception because p already in m1
+        ModuleLayer layer2 = ModuleLayer.boot().defineModules(cf2, mn -> loader);
+
+    }
+
+
+    /**
+     * Attempt to use defineModules to create a layer with a module
+     * containing a package in which a type is already loaded by the class
+     * loader.
+     */
+    @Test(expectedExceptions = { LayerInstantiationException.class })
+    public void testPackageAlreadyInUnnamedModule() throws Exception {
+
+        Class<?> c = layertest.Test.class;
+        assertFalse(c.getModule().isNamed());  // in unnamed module
+
+        ModuleDescriptor md = newBuilder("m")
+                .packages(Set.of(c.getPackageName()))
+                .requires("java.base")
+                .build();
+
+        ModuleFinder finder = ModuleUtils.finderOf(md);
+
+        Configuration parent = ModuleLayer.boot().configuration();
+        Configuration cf = parent.resolve(finder, ModuleFinder.of(), Set.of("m"));
+
+        ModuleLayer.boot().defineModules(cf, mn -> c.getClassLoader());
+    }
+
+
+    /**
+     * Attempt to create a layer with a module named "java.base".
+     */
+    public void testLayerWithJavaBase() {
+        ModuleDescriptor descriptor = newBuilder("java.base")
+                .exports("java.lang")
+                .build();
+
+        ModuleFinder finder = ModuleUtils.finderOf(descriptor);
+
+        Configuration cf = ModuleLayer.boot()
+            .configuration()
+            .resolve(finder, ModuleFinder.of(), Set.of("java.base"));
+        assertTrue(cf.modules().size() == 1);
+
+        ClassLoader scl = ClassLoader.getSystemClassLoader();
+
+        try {
+            ModuleLayer.boot().defineModules(cf, mn -> new ClassLoader() { });
+            assertTrue(false);
+        } catch (LayerInstantiationException e) { }
+
+        try {
+            ModuleLayer.boot().defineModulesWithOneLoader(cf, scl);
+            assertTrue(false);
+        } catch (LayerInstantiationException e) { }
+
+        try {
+            ModuleLayer.boot().defineModulesWithManyLoaders(cf, scl);
+            assertTrue(false);
+        } catch (LayerInstantiationException e) { }
+    }
+
+
+    @DataProvider(name = "javaPackages")
+    public Object[][] javaPackages() {
+        return new Object[][] { { "m1", "java" }, { "m2", "java.x" } };
+    }
+
+    /**
+     * Attempt to create a layer with a module containing a "java" package.
+     * This should only be allowed when the module is defined to the platform
+     * class loader.
+     */
+    @Test(dataProvider = "javaPackages")
+    public void testLayerWithJavaPackage(String mn, String pn) {
+        ModuleDescriptor descriptor = newBuilder(mn).packages(Set.of(pn)).build();
+        ModuleFinder finder = ModuleUtils.finderOf(descriptor);
+
+        Configuration cf = ModuleLayer.boot()
+                .configuration()
+                .resolve(finder, ModuleFinder.of(), Set.of(mn));
+        assertTrue(cf.modules().size() == 1);
+
+        ClassLoader pcl = ClassLoader.getPlatformClassLoader();
+        ClassLoader scl = ClassLoader.getSystemClassLoader();
+
+        try {
+            ModuleLayer.boot().defineModules(cf, _mn -> new ClassLoader() { });
+            assertTrue(false);
+        } catch (LayerInstantiationException e) { }
+
+        try {
+            ModuleLayer.boot().defineModulesWithOneLoader(cf, scl);
+            assertTrue(false);
+        } catch (LayerInstantiationException e) { }
+
+        try {
+            ModuleLayer.boot().defineModulesWithManyLoaders(cf, scl);
+            assertTrue(false);
+        } catch (LayerInstantiationException e) { }
+
+        // create layer with module defined to platform class loader
+        ModuleLayer layer = ModuleLayer.boot().defineModules(cf, _mn -> pcl);
+        Optional<Module> om = layer.findModule(mn);
+        assertTrue(om.isPresent());
+        Module foo = om.get();
+        assertTrue(foo.getClassLoader() == pcl);
+        assertTrue(foo.getPackages().size() == 1);
+        assertTrue(foo.getPackages().iterator().next().equals(pn));
+    }
+
+
+    /**
+     * Attempt to create a layer with a module defined to the boot loader
+     */
+    @Test(expectedExceptions = { LayerInstantiationException.class })
+    public void testLayerWithBootLoader() {
+        ModuleDescriptor descriptor = newBuilder("m1")
+                .build();
+
+        ModuleFinder finder = ModuleUtils.finderOf(descriptor);
+
+        Configuration cf = ModuleLayer.boot()
+            .configuration()
+            .resolve(finder, ModuleFinder.of(), Set.of("m1"));
+        assertTrue(cf.modules().size() == 1);
+
+        ModuleLayer.boot().defineModules(cf, mn -> null );
+    }
+
+
+    /**
+     * Parent of configuration != configuration of parent layer
+     */
+    @Test(expectedExceptions = { IllegalArgumentException.class })
+    public void testIncorrectParent1() {
+        ModuleDescriptor descriptor1 = newBuilder("m1")
+                .requires("java.base")
+                .build();
+
+        ModuleFinder finder = ModuleUtils.finderOf(descriptor1);
+
+        Configuration parent = ModuleLayer.boot().configuration();
+        Configuration cf = parent.resolve(finder, ModuleFinder.of(), Set.of("m1"));
+
+        ClassLoader loader = new ClassLoader() { };
+        ModuleLayer.empty().defineModules(cf, mn -> loader);
+    }
+
+
+    /**
+     * Parent of configuration != configuration of parent layer
+     */
+    @Test(expectedExceptions = { IllegalArgumentException.class })
+    public void testIncorrectParent2() {
+        ModuleDescriptor descriptor1 = newBuilder("m1").build();
+
+        ModuleFinder finder = ModuleUtils.finderOf(descriptor1);
+
+        Configuration cf = resolve(finder, "m1");
+
+        ClassLoader loader = new ClassLoader() { };
+        ModuleLayer.boot().defineModules(cf, mn -> loader);
+    }
+
+
+    // null handling
+
+    @Test(expectedExceptions = { NullPointerException.class })
+    public void testCreateWithNull1() {
+        ClassLoader loader = new ClassLoader() { };
+        ModuleLayer.empty().defineModules(null, mn -> loader);
+    }
+
+    @Test(expectedExceptions = { NullPointerException.class })
+    public void testCreateWithNull2() {
+        Configuration cf = resolve(ModuleLayer.boot().configuration(), ModuleFinder.of());
+        ModuleLayer.boot().defineModules(cf, null);
+    }
+
+    @Test(expectedExceptions = { NullPointerException.class })
+    public void testCreateWithNull3() {
+        ClassLoader scl = ClassLoader.getSystemClassLoader();
+        ModuleLayer.empty().defineModulesWithOneLoader(null, scl);
+    }
+
+    @Test(expectedExceptions = { NullPointerException.class })
+    public void testCreateWithNull4() {
+        ClassLoader scl = ClassLoader.getSystemClassLoader();
+        ModuleLayer.empty().defineModulesWithManyLoaders(null, scl);
+    }
+
+    @Test(expectedExceptions = { NullPointerException.class })
+    public void testFindModuleWithNull() {
+        ModuleLayer.boot().findModule(null);
+    }
+
+    @Test(expectedExceptions = { NullPointerException.class })
+    public void testFindLoaderWithNull() {
+        ModuleLayer.boot().findLoader(null);
+    }
+
+
+    // immutable sets
+
+    @Test(expectedExceptions = { UnsupportedOperationException.class })
+    public void testImmutableSet() {
+        Module base = Object.class.getModule();
+        ModuleLayer.boot().modules().add(base);
+    }
+
+
+    /**
+     * Resolve the given modules, by name, and returns the resulting
+     * Configuration.
+     */
+    private static Configuration resolve(Configuration cf,
+                                         ModuleFinder finder,
+                                         String... roots) {
+        return cf.resolve(finder, ModuleFinder.of(), Set.of(roots));
+    }
+
+    private static Configuration resolve(ModuleFinder finder,
+                                         String... roots) {
+        return resolve(Configuration.empty(), finder, roots);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/lang/ModuleLayer/LayerAndLoadersTest.java	Tue Apr 18 22:25:33 2017 +0200
@@ -0,0 +1,721 @@
+/*
+ * 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
+ * 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
+ * @library /lib/testlibrary
+ * @modules jdk.compiler
+ * @build LayerAndLoadersTest CompilerUtils ModuleUtils
+ * @run testng LayerAndLoadersTest
+ * @summary Tests for java.lang.ModuleLayer@defineModulesWithXXX methods
+ */
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.lang.module.Configuration;
+import java.lang.module.ModuleDescriptor;
+import java.lang.module.ModuleFinder;
+import java.lang.module.ModuleReference;
+import java.lang.reflect.Method;
+import java.net.URL;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.util.Enumeration;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Optional;
+import java.util.ServiceLoader;
+import java.util.Set;
+import java.util.stream.Collectors;
+
+import org.testng.annotations.BeforeTest;
+import org.testng.annotations.Test;
+import static org.testng.Assert.*;
+
+@Test
+public class LayerAndLoadersTest {
+
+    private static final String TEST_SRC = System.getProperty("test.src");
+
+    private static final Path SRC_DIR = Paths.get(TEST_SRC, "src");
+    private static final Path MODS_DIR = Paths.get("mods");
+
+    @BeforeTest
+    public void setup() throws Exception {
+
+        // javac -d mods --module-source-path src src/**
+        assertTrue(CompilerUtils.compile(SRC_DIR, MODS_DIR,
+                "--module-source-path", SRC_DIR.toString()));
+    }
+
+
+    /**
+     * Basic test of ModuleLayer.defineModulesWithOneLoader
+     *
+     * Test scenario:
+     *   m1 requires m2 and m3
+     */
+    public void testWithOneLoader() throws Exception {
+
+        Configuration cf = resolve("m1");
+
+        ClassLoader scl = ClassLoader.getSystemClassLoader();
+
+        ModuleLayer layer = ModuleLayer.boot().defineModulesWithOneLoader(cf, scl);
+
+        checkLayer(layer, "m1", "m2", "m3");
+
+        ClassLoader cl1 = layer.findLoader("m1");
+        ClassLoader cl2 = layer.findLoader("m2");
+        ClassLoader cl3 = layer.findLoader("m3");
+
+        assertTrue(cl1.getParent() == scl);
+        assertTrue(cl2 == cl1);
+        assertTrue(cl3 == cl1);
+
+        invoke(layer, "m1", "p.Main");
+
+    }
+
+
+    /**
+     * Basic test of ModuleLayer.defineModulesWithManyLoaders
+     *
+     * Test scenario:
+     *   m1 requires m2 and m3
+     */
+    public void testWithManyLoaders() throws Exception {
+
+        Configuration cf = resolve("m1");
+
+        ClassLoader scl = ClassLoader.getSystemClassLoader();
+
+        ModuleLayer layer = ModuleLayer.boot().defineModulesWithManyLoaders(cf, scl);
+
+        checkLayer(layer, "m1", "m2", "m3");
+
+        ClassLoader cl1 = layer.findLoader("m1");
+        ClassLoader cl2 = layer.findLoader("m2");
+        ClassLoader cl3 = layer.findLoader("m3");
+
+        assertTrue(cl1.getParent() == scl);
+        assertTrue(cl2.getParent() == scl);
+        assertTrue(cl3.getParent() == scl);
+        assertTrue(cl2 != cl1);
+        assertTrue(cl3 != cl1);
+        assertTrue(cl3 != cl2);
+
+        invoke(layer, "m1", "p.Main");
+
+    }
+
+
+    /**
+     * Basic test of ModuleLayer.defineModulesWithOneLoader where one of the
+     * modules is a service provider module.
+     *
+     * Test scenario:
+     *    m1 requires m2 and m3
+     *    m1 uses S
+     *    m4 provides S with ...
+     */
+    public void testServicesWithOneLoader() throws Exception {
+
+        Configuration cf = resolveAndBind("m1");
+
+        ClassLoader scl = ClassLoader.getSystemClassLoader();
+
+        ModuleLayer layer = ModuleLayer.boot().defineModulesWithOneLoader(cf, scl);
+
+        checkLayer(layer, "m1", "m2", "m3", "m4");
+
+        ClassLoader cl1 = layer.findLoader("m1");
+        ClassLoader cl2 = layer.findLoader("m2");
+        ClassLoader cl3 = layer.findLoader("m3");
+        ClassLoader cl4 = layer.findLoader("m4");
+
+        assertTrue(cl1.getParent() == scl);
+        assertTrue(cl2 == cl1);
+        assertTrue(cl3 == cl1);
+        assertTrue(cl4 == cl1);
+
+        Class<?> serviceType = cl1.loadClass("p.Service");
+        assertTrue(serviceType.getClassLoader() == cl1);
+
+        Iterator<?> iter = ServiceLoader.load(serviceType, cl1).iterator();
+        Object provider = iter.next();
+        assertTrue(serviceType.isInstance(provider));
+        assertTrue(provider.getClass().getClassLoader() == cl1);
+        assertFalse(iter.hasNext());
+
+    }
+
+
+    /**
+     * Basic test of ModuleLayer.defineModulesWithManyLoaders where one of the
+     * modules is a service provider module.
+     *
+     * Test scenario:
+     *    m1 requires m2 and m3
+     *    m1 uses S
+     *    m4 provides S with ...
+     */
+    public void testServicesWithManyLoaders() throws Exception {
+
+        Configuration cf = resolveAndBind("m1");
+
+        ClassLoader scl = ClassLoader.getSystemClassLoader();
+
+        ModuleLayer layer = ModuleLayer.boot().defineModulesWithManyLoaders(cf, scl);
+
+        checkLayer(layer, "m1", "m2", "m3", "m4");
+
+        ClassLoader cl1 = layer.findLoader("m1");
+        ClassLoader cl2 = layer.findLoader("m2");
+        ClassLoader cl3 = layer.findLoader("m3");
+        ClassLoader cl4 = layer.findLoader("m4");
+
+        assertTrue(cl1.getParent() == scl);
+        assertTrue(cl2.getParent() == scl);
+        assertTrue(cl3.getParent() == scl);
+        assertTrue(cl4.getParent() == scl);
+        assertTrue(cl2 != cl1);
+        assertTrue(cl3 != cl1);
+        assertTrue(cl3 != cl2);
+        assertTrue(cl4 != cl1);
+        assertTrue(cl4 != cl2);
+        assertTrue(cl4 != cl3);
+
+        Class<?> serviceType = cl1.loadClass("p.Service");
+        assertTrue(serviceType.getClassLoader() == cl1);
+
+        // Test that the service provider can be located via any of
+        // the class loaders in the layer
+        for (Module m : layer.modules()) {
+            ClassLoader loader = m.getClassLoader();
+            Iterator<?> iter = ServiceLoader.load(serviceType, loader).iterator();
+            Object provider = iter.next();
+            assertTrue(serviceType.isInstance(provider));
+            assertTrue(provider.getClass().getClassLoader() == cl4);
+            assertFalse(iter.hasNext());
+        }
+
+    }
+
+
+    /**
+     * Tests that the class loaders created by defineModulesWithXXX delegate
+     * to the given parent class loader.
+     */
+    public void testDelegationToParent() throws Exception {
+
+        Configuration cf = resolve("m1");
+
+        ClassLoader parent = this.getClass().getClassLoader();
+        String cn = this.getClass().getName();
+
+        // one loader
+        ModuleLayer layer = ModuleLayer.boot().defineModulesWithOneLoader(cf, parent);
+        testLoad(layer, cn);
+
+         // one loader with boot loader as parent
+        layer = ModuleLayer.boot().defineModulesWithOneLoader(cf, null);
+        testLoadFail(layer, cn);
+
+        // many loaders
+        layer = ModuleLayer.boot().defineModulesWithManyLoaders(cf, parent);
+        testLoad(layer, cn);
+
+        // many loader with boot loader as parent
+        layer = ModuleLayer.boot().defineModulesWithManyLoaders(cf, null);
+        testLoadFail(layer, cn);
+
+    }
+
+
+    /**
+     * Test defineModulesWithXXX when modules that have overlapping packages.
+     *
+     * Test scenario:
+     *   m1 exports p
+     *   m2 exports p
+     */
+    public void testOverlappingPackages() {
+
+        ModuleDescriptor descriptor1
+            = ModuleDescriptor.newModule("m1").exports("p").build();
+
+        ModuleDescriptor descriptor2
+            = ModuleDescriptor.newModule("m2").exports("p").build();
+
+        ModuleFinder finder = ModuleUtils.finderOf(descriptor1, descriptor2);
+
+        Configuration cf = ModuleLayer.boot()
+            .configuration()
+            .resolve(finder, ModuleFinder.of(), Set.of("m1", "m2"));
+
+        // cannot define both module m1 and m2 to the same class loader
+        try {
+            ModuleLayer.boot().defineModulesWithOneLoader(cf, null);
+            assertTrue(false);
+        } catch (LayerInstantiationException expected) { }
+
+        // should be okay to have one module per class loader
+        ModuleLayer layer = ModuleLayer.boot().defineModulesWithManyLoaders(cf, null);
+        checkLayer(layer, "m1", "m2");
+
+    }
+
+
+    /**
+     * Test ModuleLayer.defineModulesWithXXX with split delegation.
+     *
+     * Test scenario:
+     *   layer1: m1 exports p, m2 exports p
+     *   layer2: m3 reads m1, m4 reads m2
+     */
+    public void testSplitDelegation() {
+
+        ModuleDescriptor descriptor1
+            = ModuleDescriptor.newModule("m1").exports("p").build();
+
+        ModuleDescriptor descriptor2
+            = ModuleDescriptor.newModule("m2").exports("p").build();
+
+        ModuleFinder finder1 = ModuleUtils.finderOf(descriptor1, descriptor2);
+
+        Configuration cf1 = ModuleLayer.boot()
+            .configuration()
+            .resolve(finder1, ModuleFinder.of(), Set.of("m1", "m2"));
+
+        ModuleLayer layer1 = ModuleLayer.boot().defineModulesWithManyLoaders(cf1, null);
+        checkLayer(layer1, "m1", "m2");
+
+        ModuleDescriptor descriptor3
+            = ModuleDescriptor.newModule("m3").requires("m1").build();
+
+        ModuleDescriptor descriptor4
+            = ModuleDescriptor.newModule("m4").requires("m2").build();
+
+        ModuleFinder finder2 = ModuleUtils.finderOf(descriptor3, descriptor4);
+
+        Configuration cf2 = cf1.resolve(finder2, ModuleFinder.of(),
+                                                Set.of("m3", "m4"));
+
+        // package p cannot be supplied by two class loaders
+        try {
+            layer1.defineModulesWithOneLoader(cf2, null);
+            assertTrue(false);
+        } catch (LayerInstantiationException expected) { }
+
+        // no split delegation when modules have their own class loader
+        ModuleLayer layer2 = layer1.defineModulesWithManyLoaders(cf2, null);
+        checkLayer(layer2, "m3", "m4");
+
+    }
+
+
+    /**
+     * Test ModuleLayer.defineModulesWithXXX when the modules that override same
+     * named modules in the parent layer.
+     *
+     * Test scenario:
+     *   layer1: m1, m2, m3 => same loader
+     *   layer2: m1, m2, m4 => same loader
+     */
+    public void testOverriding1() throws Exception {
+
+        Configuration cf1 = resolve("m1");
+
+        ModuleLayer layer1 = ModuleLayer.boot().defineModulesWithOneLoader(cf1, null);
+        checkLayer(layer1, "m1", "m2", "m3");
+
+        ModuleFinder finder = ModuleFinder.of(MODS_DIR);
+        Configuration cf2 = cf1.resolve(finder, ModuleFinder.of(),
+                                                Set.of("m1"));
+
+        ModuleLayer layer2 = layer1.defineModulesWithOneLoader(cf2, null);
+        checkLayer(layer2, "m1", "m2", "m3");
+        invoke(layer1, "m1", "p.Main");
+
+        ClassLoader loader1 = layer1.findLoader("m1");
+        ClassLoader loader2 = layer1.findLoader("m2");
+        ClassLoader loader3 = layer1.findLoader("m3");
+
+        ClassLoader loader4 = layer2.findLoader("m1");
+        ClassLoader loader5 = layer2.findLoader("m2");
+        ClassLoader loader6 = layer2.findLoader("m3");
+
+        assertTrue(loader1 == loader2);
+        assertTrue(loader1 == loader3);
+
+        assertTrue(loader4 == loader5);
+        assertTrue(loader4 == loader6);
+        assertTrue(loader4 != loader1);
+
+        assertTrue(loader1.loadClass("p.Main").getClassLoader() == loader1);
+        assertTrue(loader1.loadClass("q.Hello").getClassLoader() == loader1);
+        assertTrue(loader1.loadClass("w.Hello").getClassLoader() == loader1);
+
+        assertTrue(loader4.loadClass("p.Main").getClassLoader() == loader4);
+        assertTrue(loader4.loadClass("q.Hello").getClassLoader() == loader4);
+        assertTrue(loader4.loadClass("w.Hello").getClassLoader() == loader4);
+
+    }
+
+
+    /**
+     * Test Layer defineModulesWithXXX when the modules that override same
+     * named modules in the parent layer.
+     *
+     * Test scenario:
+     *   layer1: m1, m2, m3 => loader pool
+     *   layer2: m1, m2, m3 => loader pool
+     */
+    public void testOverriding2() throws Exception {
+
+        Configuration cf1 = resolve("m1");
+
+        ModuleLayer layer1 = ModuleLayer.boot().defineModulesWithManyLoaders(cf1, null);
+        checkLayer(layer1, "m1", "m2", "m3");
+
+        ModuleFinder finder = ModuleFinder.of(MODS_DIR);
+        Configuration cf2 = cf1.resolve(finder, ModuleFinder.of(),
+                                                Set.of("m1"));
+
+        ModuleLayer layer2 = layer1.defineModulesWithManyLoaders(cf2, null);
+        checkLayer(layer2, "m1", "m2", "m3");
+        invoke(layer1, "m1", "p.Main");
+
+        ClassLoader loader1 = layer1.findLoader("m1");
+        ClassLoader loader2 = layer1.findLoader("m2");
+        ClassLoader loader3 = layer1.findLoader("m3");
+
+        ClassLoader loader4 = layer2.findLoader("m1");
+        ClassLoader loader5 = layer2.findLoader("m2");
+        ClassLoader loader6 = layer2.findLoader("m3");
+
+        assertTrue(loader4 != loader1);
+        assertTrue(loader5 != loader2);
+        assertTrue(loader6 != loader3);
+
+        assertTrue(loader1.loadClass("p.Main").getClassLoader() == loader1);
+        assertTrue(loader1.loadClass("q.Hello").getClassLoader() == loader2);
+        assertTrue(loader1.loadClass("w.Hello").getClassLoader() == loader3);
+
+        // p.Main is not visible via loader2
+        try {
+            loader2.loadClass("p.Main");
+            assertTrue(false);
+        } catch (ClassNotFoundException expected) { }
+
+        // w.Hello is not visible via loader2
+        try {
+            loader2.loadClass("w.Hello");
+            assertTrue(false);
+        } catch (ClassNotFoundException expected) { }
+
+        // p.Main is not visible via loader3
+        try {
+            loader3.loadClass("p.Main");
+            assertTrue(false);
+        } catch (ClassNotFoundException expected) { }
+
+        // q.Hello is not visible via loader3
+        try {
+            loader3.loadClass("q.Hello");
+            assertTrue(false);
+        } catch (ClassNotFoundException expected) { }
+
+
+        assertTrue(loader4.loadClass("p.Main").getClassLoader() == loader4);
+        assertTrue(loader5.loadClass("q.Hello").getClassLoader() == loader5);
+        assertTrue(loader6.loadClass("w.Hello").getClassLoader() == loader6);
+
+        // p.Main is not visible via loader5
+        try {
+            loader5.loadClass("p.Main");
+            assertTrue(false);
+        } catch (ClassNotFoundException expected) { }
+
+        // w.Hello is not visible via loader5
+        try {
+            loader5.loadClass("w.Hello");
+            assertTrue(false);
+        } catch (ClassNotFoundException expected) { }
+
+        // p.Main is not visible via loader6
+        try {
+            loader6.loadClass("p.Main");
+            assertTrue(false);
+        } catch (ClassNotFoundException expected) { }
+
+        // q.Hello is not visible via loader6
+        try {
+            loader6.loadClass("q.Hello");
+            assertTrue(false);
+        } catch (ClassNotFoundException expected) { }
+
+    }
+
+
+    /**
+     * Test ModuleLayer.defineModulesWithXXX when the modules that override same
+     * named modules in the parent layer.
+     *
+     * layer1: m1, m2, m3 => same loader
+     * layer2: m1, m3 => same loader
+     */
+    public void testOverriding3() throws Exception {
+
+        Configuration cf1 = resolve("m1");
+
+        ModuleLayer layer1 = ModuleLayer.boot().defineModulesWithOneLoader(cf1, null);
+        checkLayer(layer1, "m1", "m2", "m3");
+
+        ModuleFinder finder = finderFor("m1", "m3");
+
+        Configuration cf2 = cf1.resolve(finder, ModuleFinder.of(),
+                                                Set.of("m1"));
+
+        ModuleLayer layer2 = layer1.defineModulesWithOneLoader(cf2, null);
+        checkLayer(layer2, "m1", "m3");
+        invoke(layer1, "m1", "p.Main");
+
+        ClassLoader loader1 = layer1.findLoader("m1");
+        ClassLoader loader2 = layer2.findLoader("m1");
+
+        assertTrue(loader1.loadClass("p.Main").getClassLoader() == loader1);
+        assertTrue(loader1.loadClass("q.Hello").getClassLoader() == loader1);
+        assertTrue(loader1.loadClass("w.Hello").getClassLoader() == loader1);
+
+        assertTrue(loader2.loadClass("p.Main").getClassLoader() == loader2);
+        assertTrue(loader2.loadClass("q.Hello").getClassLoader() == loader1);
+        assertTrue(loader2.loadClass("w.Hello").getClassLoader() == loader2);
+
+    }
+
+
+    /**
+     * Test Layer defineModulesWithXXX when the modules that override same
+     * named modules in the parent layer.
+     *
+     * layer1: m1, m2, m3 => loader pool
+     * layer2: m1, m3 => loader pool
+     */
+    public void testOverriding4() throws Exception {
+
+        Configuration cf1 = resolve("m1");
+
+        ModuleLayer layer1 = ModuleLayer.boot().defineModulesWithManyLoaders(cf1, null);
+        checkLayer(layer1, "m1", "m2", "m3");
+
+        ModuleFinder finder = finderFor("m1", "m3");
+
+        Configuration cf2 = cf1.resolve(finder, ModuleFinder.of(),
+                                                Set.of("m1"));
+
+        ModuleLayer layer2 = layer1.defineModulesWithManyLoaders(cf2, null);
+        checkLayer(layer2, "m1", "m3");
+        invoke(layer1, "m1", "p.Main");
+
+        ClassLoader loader1 = layer1.findLoader("m1");
+        ClassLoader loader2 = layer1.findLoader("m2");
+        ClassLoader loader3 = layer1.findLoader("m3");
+
+        ClassLoader loader4 = layer2.findLoader("m1");
+        ClassLoader loader5 = layer2.findLoader("m2");
+        ClassLoader loader6 = layer2.findLoader("m3");
+
+        assertTrue(loader4 != loader1);
+        assertTrue(loader5 == loader2);  // m2 not overridden
+        assertTrue(loader6 != loader3);
+
+        assertTrue(loader1.loadClass("p.Main").getClassLoader() == loader1);
+        assertTrue(loader1.loadClass("q.Hello").getClassLoader() == loader2);
+        assertTrue(loader1.loadClass("w.Hello").getClassLoader() == loader3);
+
+        assertTrue(loader2.loadClass("q.Hello").getClassLoader() == loader2);
+
+        assertTrue(loader3.loadClass("w.Hello").getClassLoader() == loader3);
+
+        assertTrue(loader4.loadClass("p.Main").getClassLoader() == loader4);
+        assertTrue(loader4.loadClass("q.Hello").getClassLoader() == loader2);
+        assertTrue(loader4.loadClass("w.Hello").getClassLoader() == loader6);
+
+        assertTrue(loader6.loadClass("w.Hello").getClassLoader() == loader6);
+
+    }
+
+
+    /**
+     * Basic test of resource loading with a class loader created by
+     * Layer.defineModulesWithOneLoader.
+     */
+    public void testResourcesOneLoader() throws Exception {
+        Configuration cf = resolve("m1");
+        ClassLoader scl = ClassLoader.getSystemClassLoader();
+        ModuleLayer layer = ModuleLayer.boot().defineModulesWithOneLoader(cf, scl);
+        ClassLoader loader = layer.findLoader("m1");
+        testResourceLoading(loader, "p/Main.class");
+    }
+
+    /**
+     * Basic test of resource loading with a class loader created by
+     * Layer.defineModulesWithOneLoader.
+     */
+    public void testResourcesManyLoaders() throws Exception {
+        Configuration cf = resolve("m1");
+        ClassLoader scl = ClassLoader.getSystemClassLoader();
+        ModuleLayer layer = ModuleLayer.boot().defineModulesWithManyLoaders(cf, scl);
+        ClassLoader loader = layer.findLoader("m1");
+        testResourceLoading(loader, "p/Main.class");
+    }
+
+    /**
+     * Test that a resource is located by a class loader.
+     */
+    private void testResourceLoading(ClassLoader loader, String name)
+        throws IOException
+    {
+        URL url = loader.getResource(name);
+        assertNotNull(url);
+
+        try (InputStream in = loader.getResourceAsStream(name)) {
+            assertNotNull(in);
+        }
+
+        Enumeration<URL> urls = loader.getResources(name);
+        assertTrue(urls.hasMoreElements());
+    }
+
+
+    // -- supporting methods --
+
+
+    /**
+     * Resolve the given modules, by name, and returns the resulting
+     * Configuration.
+     */
+    private static Configuration resolve(String... roots) {
+        ModuleFinder finder = ModuleFinder.of(MODS_DIR);
+        return ModuleLayer.boot()
+            .configuration()
+            .resolve(finder, ModuleFinder.of(), Set.of(roots));
+    }
+
+    /**
+     * Resolve the given modules, by name, and returns the resulting
+     * Configuration.
+     */
+    private static Configuration resolveAndBind(String... roots) {
+        ModuleFinder finder = ModuleFinder.of(MODS_DIR);
+        return ModuleLayer.boot()
+            .configuration()
+            .resolveAndBind(finder, ModuleFinder.of(), Set.of(roots));
+    }
+
+
+    /**
+     * Invokes the static void main(String[]) method on the given class
+     * in the given module.
+     */
+    private static void invoke(ModuleLayer layer, String mn, String mc) throws Exception {
+        ClassLoader loader = layer.findLoader(mn);
+        Class<?> c = loader.loadClass(mc);
+        Method mainMethod = c.getMethod("main", String[].class);
+        mainMethod.invoke(null, (Object)new String[0]);
+    }
+
+
+    /**
+     * Checks that the given layer contains exactly the expected modules
+     * (by name).
+     */
+    private void checkLayer(ModuleLayer layer, String ... expected) {
+        Set<String> names = layer.modules().stream()
+                .map(Module::getName)
+                .collect(Collectors.toSet());
+        assertTrue(names.size() == expected.length);
+        for (String name : expected) {
+            assertTrue(names.contains(name));
+        }
+    }
+
+
+    /**
+     * Test that a class can be loaded via the class loader of all modules
+     * in the given layer.
+     */
+    static void testLoad(ModuleLayer layer, String cn) throws Exception {
+        for (Module m : layer.modules()) {
+            ClassLoader l = m.getClassLoader();
+            l.loadClass(cn);
+        }
+    }
+
+
+    /**
+     * Test that a class cannot be loaded via any of the class loaders of
+     * the modules in the given layer.
+     */
+    static void testLoadFail(ModuleLayer layer, String cn) throws Exception {
+        for (Module m : layer.modules()) {
+            ClassLoader l = m.getClassLoader();
+            try {
+                l.loadClass(cn);
+                assertTrue(false);
+            } catch (ClassNotFoundException expected) { }
+        }
+    }
+
+
+    /**
+     * Returns a ModuleFinder that only finds the given test modules
+     */
+    static ModuleFinder finderFor(String... names) {
+
+        ModuleFinder finder = ModuleFinder.of(MODS_DIR);
+
+        Map<String, ModuleReference> mrefs = new HashMap<>();
+        for (String name : names) {
+            Optional<ModuleReference> omref = finder.find(name);
+            assert omref.isPresent();
+            mrefs.put(name, omref.get());
+        }
+
+        return new ModuleFinder() {
+            @Override
+            public Optional<ModuleReference> find(String name) {
+                ModuleReference mref = mrefs.get(name);
+                return Optional.ofNullable(mref);
+            }
+            @Override
+            public Set<ModuleReference> findAll() {
+                return mrefs.values().stream().collect(Collectors.toSet());
+            }
+        };
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/lang/ModuleLayer/LayerControllerTest.java	Tue Apr 18 22:25:33 2017 +0200
@@ -0,0 +1,194 @@
+/*
+ * 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
+ * @library /lib/testlibrary
+ * @build LayerControllerTest ModuleUtils
+ * @run testng LayerControllerTest
+ * @summary Basic tests for java.lang.ModuleLayer.Controller
+ */
+
+import java.lang.module.Configuration;
+import java.lang.module.ModuleDescriptor;
+import java.lang.module.ModuleFinder;
+import java.util.List;
+import java.util.Set;
+
+import org.testng.annotations.Test;
+import static org.testng.Assert.*;
+
+@Test
+public class LayerControllerTest {
+
+    /**
+     * Creates a Controller for a module layer containing modules m1 and m2.
+     * Module m1 contains p1, reads java.base, does not export/open any package
+     * Module m2 contains p2, reads java.base, does not export/open any package
+     */
+    private ModuleLayer.Controller createTestLayer() {
+        ModuleDescriptor descriptor1
+            = ModuleDescriptor.newModule("m1")
+                .packages(Set.of("p1"))
+                .requires("java.base")
+                .build();
+
+        ModuleDescriptor descriptor2
+            = ModuleDescriptor.newModule("m2")
+                .requires("java.base")
+                .packages(Set.of("p2"))
+                .build();
+
+        ModuleFinder finder = ModuleUtils.finderOf(descriptor1, descriptor2);
+        ModuleLayer bootLayer = ModuleLayer.boot();
+
+        Configuration cf = bootLayer.configuration()
+                .resolve(finder, ModuleFinder.of(), Set.of("m1", "m2"));
+
+        ClassLoader scl = ClassLoader.getSystemClassLoader();
+
+        ModuleLayer.Controller controller
+            = ModuleLayer.defineModulesWithOneLoader(cf, List.of(bootLayer), scl);
+
+        ModuleLayer layer = controller.layer();
+
+        assertTrue(layer.modules().size() == 2);
+        assertTrue(layer.findModule("m1").isPresent());
+        assertTrue(layer.findModule("m2").isPresent());
+
+        return controller;
+    }
+
+    /**
+     * Basic test of Controller to update modules m1 and m2 to read and
+     * open packages to each other.
+     */
+    public void testBasic() {
+        ModuleLayer.Controller controller = createTestLayer();
+        ModuleLayer layer = controller.layer();
+        Module m1 = layer.findModule("m1").orElseThrow(RuntimeException::new);
+        Module m2 = layer.findModule("m2").orElseThrow(RuntimeException::new);
+
+        assertFalse(m1.canRead(m2));
+        assertFalse(m1.isExported("p1"));
+        assertFalse(m1.isOpen("p1"));
+        assertFalse(m1.isExported("p1", m2));
+        assertFalse(m1.isOpen("p1", m2));
+
+        assertFalse(m2.canRead(m1));
+        assertFalse(m2.isExported("p2"));
+        assertFalse(m2.isOpen("p2"));
+        assertFalse(m2.isExported("p2", m1));
+        assertFalse(m2.isOpen("p2", m1));
+
+        // update m1 to read m2
+        assertTrue(controller.addReads(m1, m2) == controller);
+        assertTrue(m1.canRead(m2));
+        assertFalse(m2.canRead(m1));
+
+        // update m2 to read m1
+        assertTrue(controller.addReads(m2, m1) == controller);
+        assertTrue(m1.canRead(m2));
+        assertTrue(m1.canRead(m1));
+
+        // update m1 to open p1 to m2
+        assertTrue(controller.addOpens(m1, "p1", m2) == controller);
+        assertTrue(m1.isExported("p1", m2));
+        assertTrue(m1.isOpen("p1", m2));
+        assertFalse(m1.isExported("p1"));
+        assertFalse(m1.isOpen("p1"));
+
+        // update m2 to open p2 to m1
+        assertTrue(controller.addOpens(m2, "p2", m1) == controller);
+        assertTrue(m2.isExported("p2", m1));
+        assertTrue(m2.isOpen("p2", m1));
+        assertFalse(m2.isExported("p2"));
+        assertFalse(m2.isOpen("p2"));
+    }
+
+    /**
+     * Test invalid argument handling
+     */
+    public void testBadArguments() {
+        ModuleLayer.Controller controller = createTestLayer();
+        ModuleLayer layer = controller.layer();
+        Module m1 = layer.findModule("m1").orElseThrow(RuntimeException::new);
+        Module m2 = layer.findModule("m2").orElseThrow(RuntimeException::new);
+        Module base = Object.class.getModule();
+
+        // java.base is not in layer
+        try {
+            controller.addReads(base, m2);
+            assertTrue(false);
+        } catch (IllegalArgumentException expected) { }
+
+        // java.base is not in layer
+        try {
+            controller.addOpens(base, "java.lang", m2);
+            assertTrue(false);
+        } catch (IllegalArgumentException expected) { }
+
+        // m1 does not contain java.lang
+        try {
+            controller.addOpens(m1, "java.lang", m2);
+            assertTrue(false);
+        } catch (IllegalArgumentException expected) { }
+    }
+
+    /**
+     * Test null handling
+     */
+    public void testNulls() {
+        ModuleLayer.Controller controller = createTestLayer();
+        ModuleLayer layer = controller.layer();
+        Module m1 = layer.findModule("m1").orElseThrow(RuntimeException::new);
+        Module m2 = layer.findModule("m2").orElseThrow(RuntimeException::new);
+        assertTrue(m1 != null);
+        assertTrue(m2 != null);
+
+        try {
+            controller.addReads(null, m2);
+            assertTrue(false);
+        } catch (NullPointerException expected) { }
+
+        try {
+            controller.addReads(m1, null);
+            assertTrue(false);
+        } catch (NullPointerException expected) { }
+
+        try {
+            controller.addOpens(null, "p1", m2);
+            assertTrue(false);
+        } catch (NullPointerException expected) { }
+
+        try {
+            controller.addOpens(m1, null, m2);
+            assertTrue(false);
+        } catch (NullPointerException expected) { }
+
+        try {
+            controller.addOpens(m1, "p1", null);
+            assertTrue(false);
+        } catch (NullPointerException expected) { }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/lang/ModuleLayer/layertest/Test.java	Tue Apr 18 22:25:33 2017 +0200
@@ -0,0 +1,31 @@
+/*
+ * 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.
+ *
+ * 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.
+ */
+
+/**
+ * Supporting class for tests of java.lang.ModuleLayer.
+ */
+
+package layertest;
+
+public class Test { }
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/lang/ModuleLayer/src/m1/module-info.java	Tue Apr 18 22:25:33 2017 +0200
@@ -0,0 +1,29 @@
+/*
+ * 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
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+module m1 {
+    requires m2;
+    requires m3;
+    exports p;
+    uses p.Service;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/lang/ModuleLayer/src/m1/p/Main.java	Tue Apr 18 22:25:33 2017 +0200
@@ -0,0 +1,39 @@
+/*
+ * 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.
+ *
+ * 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 p;
+
+import java.net.URL;
+
+public class Main {
+    public static void main(String[] args) {
+
+        URL url1 = Main.class.getResource("Main.class");
+        if (url1 == null) throw new RuntimeException();
+        URL url2 = Main.class.getResource("/p/Main.class");
+        if (url2 == null) throw new RuntimeException();
+
+        q.Hello.hello();
+        w.Hello.hello();
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/lang/ModuleLayer/src/m1/p/Service.java	Tue Apr 18 22:25:33 2017 +0200
@@ -0,0 +1,26 @@
+/*
+ * 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.
+ *
+ * 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 p;
+
+public interface Service { }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/lang/ModuleLayer/src/m2/module-info.java	Tue Apr 18 22:25:33 2017 +0200
@@ -0,0 +1,26 @@
+/*
+ * 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.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+module m2 {
+    exports q;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/lang/ModuleLayer/src/m2/q/Hello.java	Tue Apr 18 22:25:33 2017 +0200
@@ -0,0 +1,40 @@
+/*
+ * 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.
+ *
+ * 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 q;
+
+import java.net.URL;
+
+public class Hello {
+
+    public static void hello() {
+
+        URL url1 = Hello.class.getResource("Hello.class");
+        if (url1 == null) throw new RuntimeException();
+        URL url2 = Hello.class.getResource("/q/Hello.class");
+        if (url2 == null) throw new RuntimeException();
+
+        System.out.println("Hello!");
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/lang/ModuleLayer/src/m3/module-info.java	Tue Apr 18 22:25:33 2017 +0200
@@ -0,0 +1,27 @@
+/*
+ * 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.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+module m3 {
+    // qualified export
+    exports w to m1;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/lang/ModuleLayer/src/m3/w/Hello.java	Tue Apr 18 22:25:33 2017 +0200
@@ -0,0 +1,40 @@
+/*
+ * 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.
+ *
+ * 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 w;
+
+import java.net.URL;
+
+public class Hello {
+
+    public static void hello() {
+
+        URL url1 = Hello.class.getResource("Hello.class");
+        if (url1 == null) throw new RuntimeException();
+        URL url2 = Hello.class.getResource("/w/Hello.class");
+        if (url2 == null) throw new RuntimeException();
+
+        System.out.println("Hello!");
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/lang/ModuleLayer/src/m4/impl/ServiceImpl.java	Tue Apr 18 22:25:33 2017 +0200
@@ -0,0 +1,27 @@
+/*
+ * 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.
+ *
+ * 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 impl;
+
+public class ServiceImpl implements p.Service {
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/lang/ModuleLayer/src/m4/module-info.java	Tue Apr 18 22:25:33 2017 +0200
@@ -0,0 +1,27 @@
+/*
+ * 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.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+module m4 {
+    requires m1;
+    provides p.Service with impl.ServiceImpl;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/lang/ModuleTests/AddExportsTest.java	Tue Apr 18 22:25:33 2017 +0200
@@ -0,0 +1,126 @@
+/*
+ * 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
+ * @modules java.base/jdk.internal.misc
+ *          java.desktop
+ * @run main/othervm --add-exports=java.desktop/sun.awt=java.base AddExportsTest
+ * @run main/othervm --add-exports=java.desktop/sun.awt=ALL-UNNAMED AddExportsTest
+ * @summary Test Module isExported methods with exports changed by -AddExportsTest
+ */
+
+import java.util.Optional;
+import java.util.stream.Stream;
+
+import jdk.internal.misc.VM;
+
+public class AddExportsTest {
+    /*
+     * jtreg sets -Dtest.modules system property to the internal APIs
+     * specified at @modules tag.  The test will exclude --add-exports set
+     * for @modules.
+     */
+    private static final String TEST_MODULES = System.getProperty("test.modules");
+
+    public static void main(String[] args) {
+
+        Optional<String> oaddExports = Stream.of(VM.getRuntimeArguments())
+            .filter(arg -> arg.startsWith("--add-exports="))
+            .filter(arg -> !arg.equals("--add-exports=" + TEST_MODULES + "=ALL-UNNAMED"))
+            .map(arg -> arg.substring("--add-exports=".length(), arg.length()))
+            .findFirst();
+
+        assertTrue(oaddExports.isPresent());
+
+        ModuleLayer bootLayer = ModuleLayer.boot();
+
+        Module unnamedModule = AddExportsTest.class.getModule();
+        assertFalse(unnamedModule.isNamed());
+
+        for (String expr : oaddExports.get().split(",")) {
+
+            String[] s = expr.split("=");
+            assertTrue(s.length == 2);
+
+            // $MODULE/$PACKAGE
+            String[] moduleAndPackage = s[0].split("/");
+            assertTrue(moduleAndPackage.length == 2);
+
+            String mn = moduleAndPackage[0];
+            String pn = moduleAndPackage[1];
+
+            // source module
+            Module source;
+            Optional<Module> om = bootLayer.findModule(mn);
+            assertTrue(om.isPresent(), mn + " not in boot layer");
+            source = om.get();
+
+            // package should not be exported unconditionally
+            assertFalse(source.isExported(pn),
+                        pn + " should not be exported unconditionally");
+
+            // $TARGET
+            String tn = s[1];
+            if ("ALL-UNNAMED".equals(tn)) {
+
+                // package is exported to all unnamed modules
+                assertTrue(source.isExported(pn, unnamedModule),
+                           pn + " should be exported to all unnamed modules");
+
+            } else {
+
+                om = bootLayer.findModule(tn);
+                assertTrue(om.isPresent());
+                Module target = om.get();
+
+                // package should be exported to target module
+                assertTrue(source.isExported(pn, target),
+                           pn + " should be exported to " + target);
+
+                // package should not be exported to unnamed modules
+                assertFalse(source.isExported(pn, unnamedModule),
+                            pn + " should not be exported to unnamed modules");
+
+            }
+
+        }
+    }
+
+    static void assertTrue(boolean cond) {
+        if (!cond) throw new RuntimeException();
+    }
+
+    static void assertTrue(boolean cond, String msg) {
+        if (!cond) throw new RuntimeException(msg);
+    }
+
+    static void assertFalse(boolean cond) {
+        if (cond) throw new RuntimeException();
+    }
+
+    static void assertFalse(boolean cond, String msg) {
+        if (cond) throw new RuntimeException(msg);
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/lang/ModuleTests/AnnotationsTest.java	Tue Apr 18 22:25:33 2017 +0200
@@ -0,0 +1,154 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.lang.annotation.Annotation;
+import java.lang.module.Configuration;
+import java.lang.module.ModuleFinder;
+import java.nio.file.Files;
+import java.nio.file.Path;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Set;
+
+import jdk.internal.module.ClassFileAttributes;
+import jdk.internal.org.objectweb.asm.AnnotationVisitor;
+import jdk.internal.org.objectweb.asm.Attribute;
+import jdk.internal.org.objectweb.asm.ClassReader;
+import jdk.internal.org.objectweb.asm.ClassVisitor;
+import jdk.internal.org.objectweb.asm.ClassWriter;
+import jdk.internal.org.objectweb.asm.Opcodes;
+
+import org.testng.annotations.Test;
+import static org.testng.Assert.*;
+
+/**
+ * @test
+ * @modules java.base/jdk.internal.org.objectweb.asm
+ *          java.base/jdk.internal.module
+ *          java.xml
+ * @run testng AnnotationsTest
+ * @summary Basic test of annotations on modules
+ */
+
+public class AnnotationsTest {
+
+    /**
+     * Test that there are no annotations on an unnamed module.
+     */
+    @Test
+    public void testUnnamedModule() {
+        Module module = this.getClass().getModule();
+        assertTrue(module.getAnnotations().length == 0);
+    }
+
+    /**
+     * Test loading a module with a RuntimeVisibleAnnotation attribute.
+     * The test copies the module-info.class for java.xml, adds the attribute,
+     * and then loads the updated module.
+     */
+    @Test
+    public void testNamedModule() throws IOException {
+
+        // "deprecate" java.xml
+        Path dir = Files.createTempDirectory("mods");
+        deprecateModule("java.xml", true, "9", dir);
+
+        // "load" the cloned java.xml
+        Module module = loadModule(dir, "java.xml");
+
+        // check the annotation is present
+        assertTrue(module.isAnnotationPresent(Deprecated.class));
+        Deprecated d = module.getAnnotation(Deprecated.class);
+        assertNotNull(d, "@Deprecated not found");
+        assertTrue(d.forRemoval());
+        assertEquals(d.since(), "9");
+        Annotation[] a = module.getAnnotations();
+        assertTrue(a.length == 1);
+        assertTrue(a[0] instanceof Deprecated);
+    }
+
+
+    /**
+     * Copy the module-info.class for the given module, add the
+     * Deprecated annotation, and write the updated module-info.class
+     * to a directory.
+     */
+    static void deprecateModule(String name,
+                                boolean forRemoval,
+                                String since,
+                                Path output) throws IOException {
+        Module module = ModuleLayer.boot().findModule(name).orElse(null);
+        assertNotNull(module, name + " not found");
+
+        InputStream in = module.getResourceAsStream("module-info.class");
+        assertNotNull(in, "No module-info.class for " + name);
+
+        try (in) {
+            ClassWriter cw = new ClassWriter(ClassWriter.COMPUTE_MAXS
+                                             + ClassWriter.COMPUTE_FRAMES);
+
+            ClassVisitor cv = new ClassVisitor(Opcodes.ASM5, cw) { };
+
+            ClassReader cr = new ClassReader(in);
+
+            List<Attribute> attrs = new ArrayList<>();
+            attrs.add(new ClassFileAttributes.ModuleAttribute());
+            attrs.add(new ClassFileAttributes.ModulePackagesAttribute());
+            attrs.add(new ClassFileAttributes.ModuleTargetAttribute());
+            cr.accept(cv, attrs.toArray(new Attribute[0]), 0);
+
+            AnnotationVisitor annotationVisitor
+                = cv.visitAnnotation("Ljava/lang/Deprecated;", true);
+            annotationVisitor.visit("forRemoval", forRemoval);
+            annotationVisitor.visit("since", since);
+            annotationVisitor.visitEnd();
+
+            byte[] bytes = cw.toByteArray();
+            Path mi = output.resolve("module-info.class");
+            Files.write(mi, bytes);
+        }
+    }
+
+    /**
+     * Load the module of the given name in the given directory into a
+     * child layer.
+     */
+    static Module loadModule(Path dir, String name) throws IOException {
+        ModuleFinder finder = ModuleFinder.of(dir);
+
+        ModuleLayer bootLayer = ModuleLayer.boot();
+
+        Configuration cf = bootLayer.configuration()
+                .resolve(finder, ModuleFinder.of(), Set.of(name));
+
+        ClassLoader scl = ClassLoader.getSystemClassLoader();
+        ModuleLayer layer = bootLayer.defineModulesWithOneLoader(cf, scl);
+
+        Module module = layer.findModule(name).orElse(null);
+        assertNotNull(module, name + " not loaded");
+        return module;
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/lang/ModuleTests/BasicModuleTest.java	Tue Apr 18 22:25:33 2017 +0200
@@ -0,0 +1,329 @@
+/*
+ * Copyright (c) 2014, 2017, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+import java.lang.module.ModuleDescriptor.Exports;
+import java.lang.module.ResolvedModule;
+import java.nio.file.spi.FileSystemProvider;  // service type in java.base
+import java.util.function.Predicate;
+import java.util.stream.Stream;
+import javax.print.PrintServiceLookup;        // service type in java.desktop
+
+import org.testng.annotations.Test;
+import static org.testng.Assert.*;
+
+/*
+ * @test
+ * @summary Basic test of java.lang.Module
+ * @modules java.desktop java.xml
+ * @run testng BasicModuleTest
+ */
+
+public class BasicModuleTest {
+
+    /**
+     * Tests that the given module reads all modules in the boot layer.
+     */
+    private void testReadsAllBootModules(Module m) {
+        ModuleLayer bootLayer = ModuleLayer.boot();
+        bootLayer.configuration()
+            .modules()
+            .stream()
+            .map(ResolvedModule::name)
+            .map(bootLayer::findModule)
+            .forEach(target -> assertTrue(m.canRead(target.get())));
+    }
+
+    /**
+     * Returns a {@code Predicate} to test if a package is exported.
+     */
+    private Predicate<Exports> doesExport(String pn) {
+        return e -> (e.source().equals(pn) && !e.isQualified());
+    }
+
+
+
+    @Test
+    public void testThisModule() {
+        Module thisModule = BasicModuleTest.class.getModule();
+        Module baseModule = Object.class.getModule();
+
+        assertFalse(thisModule.isNamed());
+        assertTrue(thisModule.getName() == null);
+        assertTrue(thisModule.getDescriptor() == null);
+        assertTrue(thisModule.getLayer() == null);
+        assertTrue(thisModule.toString().startsWith("unnamed module "));
+
+        ClassLoader thisLoader = BasicModuleTest.class.getClassLoader();
+        assertTrue(thisLoader == thisModule.getClassLoader());
+        assertTrue(thisLoader.getUnnamedModule() == thisModule);
+
+        // unnamed modules read all other modules
+        ClassLoader cl;
+        cl = ClassLoader.getPlatformClassLoader();
+        assertTrue(thisModule.canRead(cl.getUnnamedModule()));
+        cl = ClassLoader.getSystemClassLoader();
+        assertTrue(thisModule.canRead(cl.getUnnamedModule()));
+        testReadsAllBootModules(thisModule);
+
+        // unnamed modules export all packages
+        assertTrue(thisModule.isExported(""));
+        assertTrue(thisModule.isExported("", thisModule));
+        assertTrue(thisModule.isExported("", baseModule));
+        assertTrue(thisModule.isExported("p"));
+        assertTrue(thisModule.isExported("p", thisModule));
+        assertTrue(thisModule.isExported("p", baseModule));
+
+        // this test is in the unnamed package
+        assertTrue(thisModule.getPackages().contains(""));
+    }
+
+
+    @Test
+    public void testUnnamedModules() {
+        Module thisModule = BasicModuleTest.class.getModule();
+        Module baseModule = Object.class.getModule();
+
+        ClassLoader loader1 = ClassLoader.getSystemClassLoader();
+        ClassLoader loader2 = loader1.getParent();
+
+        Module m1 = loader1.getUnnamedModule();
+        Module m2 = loader2.getUnnamedModule();
+
+        assertTrue(m1 != m2);
+
+        assertFalse(m1.isNamed());
+        assertFalse(m2.isNamed());
+
+        assertTrue(m1.getLayer() == null);
+        assertTrue(m2.getLayer() == null);
+
+        assertTrue(m1.toString().startsWith("unnamed module "));
+        assertTrue(m2.toString().startsWith("unnamed module "));
+
+        // unnamed module reads all modules
+        assertTrue(m1.canRead(m2));
+        assertTrue(m2.canRead(m1));
+
+        testReadsAllBootModules(m1);
+        testReadsAllBootModules(m2);
+
+        assertTrue(m1.isExported(""));
+        assertTrue(m1.isExported("", thisModule));
+        assertTrue(m1.isExported("", baseModule));
+        assertTrue(m1.isExported("p"));
+        assertTrue(m1.isExported("p", thisModule));
+        assertTrue(m1.isExported("p", baseModule));
+    }
+
+
+
+    @Test
+    public void testBaseModule() {
+        Module base = Object.class.getModule();
+        Module thisModule = BasicModuleTest.class.getModule();
+
+        // getName
+        assertTrue(base.getName().equals("java.base"));
+
+        // getDescriptor
+        assertTrue(base.getDescriptor().exports().stream()
+                .anyMatch(doesExport("java.lang")));
+
+        // getClassLoader
+        assertTrue(base.getClassLoader() == null);
+
+        // getLayer
+        assertTrue(base.getLayer() == ModuleLayer.boot());
+
+        // toString
+        assertEquals(base.toString(), "module java.base");
+
+        // getPackages
+        assertTrue(base.getPackages().contains("java.lang"));
+
+        // canRead
+        assertTrue(base.canRead(base));
+        assertFalse(base.canRead(thisModule));
+
+        // addReads
+        try {
+            base.addReads(thisModule);
+            assertTrue(false);
+        } catch (IllegalCallerException expected) { }
+        assertFalse(base.canRead(thisModule));
+
+        // isExported
+        assertTrue(base.isExported("java.lang"));
+        assertTrue(base.isExported("java.lang", thisModule));
+        assertTrue(base.isExported("java.lang", base));
+        assertFalse(base.isExported("jdk.internal.misc"));
+        assertFalse(base.isExported("jdk.internal.misc", thisModule));
+        assertTrue(base.isExported("jdk.internal.misc", base));
+        assertFalse(base.isExported("java.wombat"));
+        assertFalse(base.isExported("java.wombat", thisModule));
+        assertFalse(base.isExported("java.wombat", base));
+
+        // addExports
+        try {
+            base.addExports("java.lang", thisModule);
+            assertTrue(false);
+        } catch (IllegalCallerException expected) { }
+        try {
+            base.addExports("jdk.internal.misc", thisModule);
+            assertTrue(false);
+        } catch (IllegalCallerException expected) { }
+        assertFalse(base.isExported("jdk.internal.misc"));
+        assertFalse(base.isExported("jdk.internal.misc", thisModule));
+
+        // isOpen
+        assertFalse(base.isOpen("java.lang"));
+        assertFalse(base.isOpen("java.lang", thisModule));
+        assertTrue(base.isOpen("java.lang", base));
+        assertFalse(base.isOpen("jdk.internal.misc"));
+        assertFalse(base.isOpen("jdk.internal.misc", thisModule));
+        assertTrue(base.isOpen("jdk.internal.misc", base));
+        assertFalse(base.isOpen("java.wombat"));
+        assertFalse(base.isOpen("java.wombat", thisModule));
+        assertFalse(base.isOpen("java.wombat", base));
+
+        // addOpens
+        try {
+            base.addOpens("jdk.internal.misc", thisModule);
+            assertTrue(false);
+        } catch (IllegalCallerException expected) { }
+        assertFalse(base.isOpen("jdk.internal.misc"));
+        assertFalse(base.isOpen("jdk.internal.misc", thisModule));
+
+        // canUse
+        assertTrue(base.canUse(FileSystemProvider.class));
+        assertFalse(base.canUse(Thread.class));
+
+        // addUses
+        try {
+            base.addUses(FileSystemProvider.class);
+            assertTrue(false);
+        } catch (IllegalCallerException expected) { }
+        try {
+            base.addUses(Thread.class);
+            assertTrue(false);
+        } catch (IllegalCallerException expected) { }
+        assertFalse(base.canUse(Thread.class));
+    }
+
+
+    @Test
+    public void testDesktopModule() {
+        Module desktop = java.awt.Component.class.getModule();
+        Module base = Object.class.getModule();
+        Module xml = javax.xml.XMLConstants.class.getModule();
+        Module thisModule = BasicModuleTest.class.getModule();
+
+        // name
+        assertTrue(desktop.getName().equals("java.desktop"));
+
+        // descriptor
+        assertTrue(desktop.getDescriptor().exports().stream()
+                   .anyMatch(doesExport("java.awt")));
+
+        // getClassLoader
+        assertTrue(desktop.getClassLoader() == null);
+
+        // getLayer
+        assertTrue(desktop.getLayer() == ModuleLayer.boot());
+
+        // toString
+        assertEquals(desktop.toString(), "module java.desktop");
+
+        // getPackages
+        assertTrue(desktop.getPackages().contains("java.awt"));
+        assertTrue(desktop.getPackages().contains("sun.awt"));
+
+        // canRead
+        assertTrue(desktop.canRead(base));
+        assertTrue(desktop.canRead(xml));
+
+        // addReads
+        try {
+            desktop.addReads(thisModule);
+            assertTrue(false);
+        } catch (IllegalCallerException expected) { }
+        assertFalse(desktop.canRead(thisModule));
+
+        // isExported
+        assertTrue(desktop.isExported("java.awt"));
+        assertTrue(desktop.isExported("java.awt", thisModule));
+        assertFalse(desktop.isExported("sun.awt"));
+        assertFalse(desktop.isExported("sun.awt", thisModule));
+        assertTrue(desktop.isExported("sun.awt", desktop));
+        assertFalse(desktop.isExported("java.wombat"));
+        assertFalse(desktop.isExported("java.wombat", thisModule));
+        assertFalse(desktop.isExported("java.wombat", base));
+
+        // addExports
+        try {
+            desktop.addExports("java.awt", thisModule);
+            assertTrue(false);
+        } catch (IllegalCallerException expected) { }
+        try {
+            desktop.addExports("sun.awt", thisModule);
+            assertTrue(false);
+        } catch (IllegalCallerException expected) { }
+        assertFalse(desktop.isExported("sun.awt"));
+        assertFalse(desktop.isExported("sun.awt", thisModule));
+
+        // isOpen
+        assertFalse(desktop.isOpen("java.awt"));
+        assertFalse(desktop.isOpen("java.awt", thisModule));
+        assertTrue(desktop.isOpen("java.awt", desktop));
+        assertFalse(desktop.isOpen("sun.awt"));
+        assertFalse(desktop.isOpen("sun.awt", thisModule));
+        assertTrue(desktop.isOpen("sun.awt", desktop));
+        assertFalse(desktop.isOpen("java.wombat"));
+        assertFalse(desktop.isOpen("java.wombat", thisModule));
+        assertFalse(desktop.isOpen("java.wombat", desktop));
+
+        // addOpens
+        try {
+            base.addOpens("sun.awt", thisModule);
+            assertTrue(false);
+        } catch (IllegalCallerException expected) { }
+        assertFalse(desktop.isOpen("sun.awt"));
+        assertFalse(desktop.isOpen("sun.awt", thisModule));
+
+        // canUse
+        assertTrue(base.canUse(FileSystemProvider.class));
+        assertFalse(base.canUse(Thread.class));
+
+        // addUses
+        try {
+            desktop.addUses(PrintServiceLookup.class);
+            assertTrue(false);
+        } catch (IllegalCallerException expected) { }
+        try {
+            desktop.addUses(Thread.class);
+            assertTrue(false);
+        } catch (IllegalCallerException expected) { }
+        assertFalse(desktop.canUse(Thread.class));
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/lang/ModuleTests/WithSecurityManager.java	Tue Apr 18 22:25:33 2017 +0200
@@ -0,0 +1,145 @@
+/*
+ * 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
+ * @modules jdk.compiler
+ * @summary Test java.lang.Module methods that specify permission checks
+ * @run main/othervm -Djava.security.policy=${test.src}/allow.policy WithSecurityManager allow
+ * @run main/othervm WithSecurityManager deny
+ */
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.lang.module.Configuration;
+import java.lang.module.ModuleFinder;
+import java.lang.module.ModuleReference;
+import java.util.Collections;
+import java.util.Optional;
+import java.util.Set;
+
+/**
+ * Test java.lang.Module methods that specify permission checks.
+ */
+
+public class WithSecurityManager {
+
+    // a module that will be loaded into a child layer
+    static final String ANOTHER_MODULE          = "jdk.compiler";
+    static final String ANOTHER_MODULE_RESOURCE = "com/sun/tools/javac/Main.class";
+
+    public static void main(String[] args) throws IOException {
+        boolean allow = args[0].equals("allow");
+
+        // base module, in the boot layer
+        Module base = Object.class.getModule();
+
+        // another module, in a child layer
+        Module other = loadModuleInChildLayer(ANOTHER_MODULE);
+        assertTrue(other.getLayer() != ModuleLayer.boot());
+
+        System.setSecurityManager(new SecurityManager());
+
+        test(base, "java/lang/Object.class", allow);
+        test(other, ANOTHER_MODULE_RESOURCE, allow);
+    }
+
+    /**
+     * Test the permission checks by invoking methods on the given module.
+     *
+     * If {@code allow} is {@code true} then the permission checks should succeed.
+     */
+    static void test(Module m, String name, boolean allow) throws IOException {
+
+        // test Module::getClassLoader
+        System.out.format("Test getClassLoader on %s ...%n", m);
+        try {
+            ClassLoader cl = m.getClassLoader();
+            System.out.println(cl);
+            if (!allow)
+                assertTrue("getClassLoader should have failed", false);
+        } catch (SecurityException e) {
+            System.out.println(e + " thrown");
+            if (allow)
+                throw e;
+        }
+
+        // test Module::getResourceAsStream
+        System.out.format("Test getResourceAsStream(\"%s\") on %s ...%n", name, m);
+        try (InputStream in = m.getResourceAsStream(name)) {
+            System.out.println(in);
+            if (allow && (in == null))
+                assertTrue(name + " not found", false);
+            if (!allow && (in != null))
+                assertTrue(name + " should not be found", false);
+        }
+
+    }
+
+    /**
+     * Create a module layer that contains the given system module.
+     */
+    static Module loadModuleInChildLayer(String mn) {
+        Optional<ModuleReference> omref = ModuleFinder.ofSystem().find(mn);
+        assertTrue("module " + mn + " not a system module", omref.isPresent());
+
+        // create a ModuleFinder that only finds this module
+        ModuleReference mref = omref.get();
+        ModuleFinder finder = new ModuleFinder() {
+            @Override
+            public Optional<ModuleReference> find(String name) {
+                if (name.equals(mn))
+                    return Optional.of(mref);
+                else
+                    return Optional.empty();
+            }
+
+            @Override
+            public Set<ModuleReference> findAll() {
+                return Collections.singleton(mref);
+            }
+        };
+
+        // create a child configuration and layer with this module
+        ModuleLayer bootLayer = ModuleLayer.boot();
+        Configuration cf = bootLayer
+            .configuration()
+            .resolve(finder, ModuleFinder.of(), Set.of(ANOTHER_MODULE));
+        ModuleLayer layer = bootLayer.defineModulesWithOneLoader(cf, null);
+
+        Optional<Module> om = layer.findModule(mn);
+        assertTrue("module " + mn + " not in child layer", om.isPresent());
+        return om.get();
+    }
+
+    static void assertTrue(String msg, boolean e) {
+        if (!e)
+            throw new RuntimeException(msg);
+    }
+
+    static void assertTrue(boolean e) {
+        if (!e)
+            throw new RuntimeException();
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/lang/ModuleTests/access/AccessTest.java	Tue Apr 18 22:25:33 2017 +0200
@@ -0,0 +1,86 @@
+/*
+ * 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
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.util.Arrays;
+import java.util.List;
+
+import static jdk.testlibrary.ProcessTools.executeTestJava;
+
+import org.testng.annotations.BeforeTest;
+import org.testng.annotations.Test;
+import static org.testng.Assert.*;
+
+/**
+ * @test
+ * @library /lib/testlibrary
+ * @modules jdk.compiler
+ * @build AccessTest CompilerUtils jdk.testlibrary.*
+ * @run testng AccessTest
+ * @summary Driver for test that checks access to access to types in
+ *          exported and non-exported packages.
+ */
+
+@Test
+public class AccessTest {
+
+    private static final String TEST_SRC = System.getProperty("test.src");
+
+    private static final Path SRC_DIR = Paths.get(TEST_SRC, "src");
+    private static final Path MODS_DIR = Paths.get("mods");
+
+
+    // the names of the modules in this test
+    private static List<String> modules = Arrays.asList("test", "target");
+
+
+    /**
+     * Compiles all modules used by the test
+     */
+    @BeforeTest
+    public void compileAll() throws Exception {
+        for (String mn : modules) {
+            Path src = SRC_DIR.resolve(mn);
+            Path mods = MODS_DIR.resolve(mn);
+            assertTrue(CompilerUtils.compile(src, mods));
+        }
+    }
+
+    /**
+     * Run the test
+     */
+    public void runTest() throws Exception {
+        int exitValue
+            = executeTestJava("--module-path", MODS_DIR.toString(),
+                              "--add-modules", "target",
+                              "-Dsun.reflect.enableStrictMode=true",
+                              "-m", "test/test.Main")
+                .outputTo(System.out)
+                .errorTo(System.out)
+                .getExitValue();
+
+        assertTrue(exitValue == 0);
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/lang/ModuleTests/access/src/target/module-info.java	Tue Apr 18 22:25:33 2017 +0200
@@ -0,0 +1,27 @@
+/*
+ * 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
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+module target {
+    exports p1;
+    exports p2;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/lang/ModuleTests/access/src/target/p1/Helper.java	Tue Apr 18 22:25:33 2017 +0200
@@ -0,0 +1,40 @@
+/*
+ * 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
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package p1;
+
+/**
+ * Helper class in target module to allow test invoke addExports[Private]
+ */
+
+public class Helper {
+    Helper() { }
+
+    public static void addExports(String pn, Module who) {
+        Helper.class.getModule().addExports(pn, who);
+    }
+
+    public static void addOpens(String pn, Module who) {
+        Helper.class.getModule().addOpens(pn, who);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/lang/ModuleTests/access/src/target/p1/Public.java	Tue Apr 18 22:25:33 2017 +0200
@@ -0,0 +1,45 @@
+/*
+ * 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
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package p1;
+
+public class Public {
+
+    // public constructor
+    public Public() { }
+
+    // non-public constructor
+    private Public(Void ignore) { }
+
+    // public field
+    public static Object f1;
+
+    // non-public field
+    private static Object f2;
+
+    // public method
+    public static void foo() { }
+
+    // non-public method
+    private static void bar() { }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/lang/ModuleTests/access/src/target/p2/NonPublic.java	Tue Apr 18 22:25:33 2017 +0200
@@ -0,0 +1,45 @@
+/*
+ * 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
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package p2;
+
+class NonPublic {
+
+    // public constructor
+    public NonPublic() { }
+
+    // non-public constructor
+    private NonPublic(Void ignore) { }
+
+    // public field
+    public static Object f1;
+
+    // non-public field
+    private static Object f2;
+
+    // public method
+    public static void foo() { }
+
+    // non-public method
+    private static void bar() { }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/lang/ModuleTests/access/src/target/q1/Public.java	Tue Apr 18 22:25:33 2017 +0200
@@ -0,0 +1,45 @@
+/*
+ * 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
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package q1;
+
+public class Public {
+
+    // public constructor
+    public Public() { }
+
+    // non-public constructor
+    private Public(Void ignore) { }
+
+    // public field
+    public static Object f1;
+
+    // non-public field
+    private static Object f2;
+
+    // public method
+    public static void foo() { }
+
+    // non-public method
+    private static void bar() { }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/lang/ModuleTests/access/src/target/q2/NonPublic.java	Tue Apr 18 22:25:33 2017 +0200
@@ -0,0 +1,45 @@
+/*
+ * 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
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package q2;
+
+class NonPublic {
+
+    // public constructor
+    public NonPublic() { }
+
+    // non-public constructor
+    private NonPublic(Void ignore) { }
+
+    // public field
+    public static Object f1;
+
+    // non-public field
+    private static Object f2;
+
+    // public method
+    public static void foo() { }
+
+    // non-public method
+    private static void bar() { }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/lang/ModuleTests/access/src/test/module-info.java	Tue Apr 18 22:25:33 2017 +0200
@@ -0,0 +1,24 @@
+/*
+ * 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.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+module test { }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/lang/ModuleTests/access/src/test/test/Main.java	Tue Apr 18 22:25:33 2017 +0200
@@ -0,0 +1,377 @@
+/*
+ * 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
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package test;
+
+import java.lang.reflect.AccessibleObject;
+import java.lang.reflect.Constructor;
+import java.lang.reflect.Field;
+import java.lang.reflect.Method;
+
+/**
+ * Test access to public/non-public members of public/non-public classes in
+ * exported and non-exported packages.
+ */
+
+public class Main {
+
+    public static void main(String[] args) throws Exception {
+        testPublicClassInExportedPackage();
+        testNonPublicClassInExportedPackage();
+        testPublicClassInNonExportedPackage();
+        testNonPublicClassInNonExportedPackage();
+    }
+
+    static void testPublicClassInExportedPackage() throws Exception {
+        Module thisModule = Main.class.getModule();
+        Module targetModule = getTargetModule();
+
+        assertTrue(targetModule.isExported("p1"));
+        assertTrue(targetModule.isExported("p1", thisModule));
+        assertTrue(targetModule.isExported("p1", targetModule));
+
+        assertFalse(targetModule.isOpen("p1"));
+        assertFalse(targetModule.isOpen("p1", thisModule));
+        assertTrue(targetModule.isOpen("p1", targetModule));
+
+        Class<?> clazz = Class.forName("p1.Public");
+        Constructor<?> ctor1 = clazz.getConstructor();   // public
+        Constructor<?> ctor2 = clazz.getDeclaredConstructor(Void.class); // non-public
+
+        Field f1 = clazz.getField("f1");    // public
+        Field f2 = clazz.getDeclaredField("f2");    // non-public
+
+        Method m1 = clazz.getMethod("foo");  // public
+        Method m2 = clazz.getDeclaredMethod("bar");  // non-public
+
+        tryAccessConstructor(ctor1, true);
+        tryAccessConstructor(ctor2, false);
+        tryAccessMethod(m1, true);
+        tryAccessMethod(m2, false);
+        tryAccessObjectField(f1, true);
+        tryAccessObjectField(f2, false);
+
+        trySetAccessible(ctor1, true);
+        trySetAccessible(ctor2, false);
+        trySetAccessible(m1, true);
+        trySetAccessible(m2, false);
+        trySetAccessible(f1, true);
+        trySetAccessible(f2, false);
+
+        targetAddOpens("p1", thisModule);
+
+        tryAccessConstructor(ctor1, true);
+        tryAccessConstructor(ctor2, false);
+        tryAccessMethod(m1, true);
+        tryAccessMethod(m2, false);
+        tryAccessObjectField(f1, true);
+        tryAccessObjectField(f2, false);
+
+        trySetAccessible(ctor1, true);
+        trySetAccessible(ctor2, true);
+        trySetAccessible(m1, true);
+        trySetAccessible(m2, true);
+        trySetAccessible(f1, true);
+        trySetAccessible(f2, true);
+    }
+
+    static void testNonPublicClassInExportedPackage() throws Exception {
+        Module thisModule = Main.class.getModule();
+        Module targetModule = getTargetModule();
+
+        assertTrue(targetModule.isExported("p2"));
+        assertTrue(targetModule.isExported("p2", thisModule));
+        assertTrue(targetModule.isExported("p2", targetModule));
+
+        assertFalse(targetModule.isOpen("p2"));
+        assertFalse(targetModule.isOpen("p2", thisModule));
+        assertTrue(targetModule.isOpen("p1", targetModule));
+
+        Class<?> clazz = Class.forName("p2.NonPublic");
+        Constructor<?> ctor1 = clazz.getConstructor();
+        Constructor<?> ctor2 = clazz.getDeclaredConstructor(Void.class);
+
+        Field f1 = clazz.getField("f1");    // public
+        Field f2 = clazz.getDeclaredField("f2");    // non-public
+
+        Method m1 = clazz.getMethod("foo");  // public
+        Method m2 = clazz.getDeclaredMethod("bar");  // non-public
+
+        tryAccessConstructor(ctor1, false);
+        tryAccessConstructor(ctor2, false);
+        tryAccessMethod(m1, false);
+        tryAccessMethod(m2, false);
+        tryAccessObjectField(f1, false);
+        tryAccessObjectField(f2, false);
+
+        trySetAccessible(ctor1, false);
+        trySetAccessible(ctor2, false);
+        trySetAccessible(m1, false);
+        trySetAccessible(m2, false);
+        trySetAccessible(f1, false);
+        trySetAccessible(f2, false);
+
+        targetAddExports("p2", thisModule);
+
+        tryAccessConstructor(ctor1, false);
+        tryAccessConstructor(ctor2, false);
+        tryAccessMethod(m1, false);
+        tryAccessMethod(m2, false);
+        tryAccessObjectField(f1, false);
+        tryAccessObjectField(f2, false);
+
+        trySetAccessible(ctor1, false);
+        trySetAccessible(ctor2, false);
+        trySetAccessible(m1, false);
+        trySetAccessible(m2, false);
+        trySetAccessible(f1, false);
+        trySetAccessible(f2, false);
+
+        targetAddOpens("p2", thisModule);
+
+        tryAccessConstructor(ctor1, false);
+        tryAccessConstructor(ctor2, false);
+        tryAccessMethod(m1, false);
+        tryAccessMethod(m2, false);
+        tryAccessObjectField(f1, false);
+        tryAccessObjectField(f2, false);
+
+        trySetAccessible(ctor1, true);
+        trySetAccessible(ctor2, true);
+        trySetAccessible(m1, true);
+        trySetAccessible(m2, true);
+        trySetAccessible(f1, true);
+        trySetAccessible(f2, true);
+    }
+
+    static void testPublicClassInNonExportedPackage() throws Exception {
+        Module thisModule = Main.class.getModule();
+        Module targetModule = getTargetModule();
+
+        assertFalse(targetModule.isExported("q1"));
+        assertFalse(targetModule.isExported("q1", thisModule));
+        assertTrue(targetModule.isExported("q1", targetModule));
+
+        assertFalse(targetModule.isOpen("q1"));
+        assertFalse(targetModule.isOpen("q1", thisModule));
+        assertTrue(targetModule.isOpen("q1", targetModule));
+
+        Class<?> clazz = Class.forName("q1.Public");
+        Constructor<?> ctor1 = clazz.getConstructor();  // public
+        Constructor<?> ctor2 = clazz.getDeclaredConstructor(Void.class);  // non-public
+
+        Field f1 = clazz.getField("f1");    // public
+        Field f2 = clazz.getDeclaredField("f2");    // non-public
+
+        Method m1 = clazz.getMethod("foo");  // public
+        Method m2 = clazz.getDeclaredMethod("bar");  // non-public
+
+        tryAccessConstructor(ctor1, false);
+        tryAccessConstructor(ctor2, false);
+        tryAccessMethod(m1, false);
+        tryAccessMethod(m2, false);
+        tryAccessObjectField(f1, false);
+        tryAccessObjectField(f2, false);
+
+        trySetAccessible(ctor1, false);
+        trySetAccessible(ctor2, false);
+        trySetAccessible(m1, false);
+        trySetAccessible(m2, false);
+        trySetAccessible(f1, false);
+        trySetAccessible(f2, false);
+
+        targetAddExports("q1", thisModule);
+
+        tryAccessConstructor(ctor1, true);
+        tryAccessConstructor(ctor2, false);
+        tryAccessMethod(m1, true);
+        tryAccessMethod(m2, false);
+        tryAccessObjectField(f1, true);
+        tryAccessObjectField(f2, false);
+
+        trySetAccessible(ctor1, true);
+        trySetAccessible(ctor2, false);
+        trySetAccessible(m1, true);
+        trySetAccessible(m2, false);
+        trySetAccessible(f1, true);
+        trySetAccessible(f2, false);
+
+        targetAddOpens("q1", thisModule);
+
+        tryAccessConstructor(ctor1, true);
+        tryAccessConstructor(ctor1, false);
+        tryAccessMethod(m1, true);
+        tryAccessMethod(m2, false);
+        tryAccessObjectField(f1, true);
+        tryAccessObjectField(f2, false);
+
+        trySetAccessible(ctor1, true);
+        trySetAccessible(ctor2, true);
+        trySetAccessible(m1, true);
+        trySetAccessible(m2, true);
+        trySetAccessible(f1, true);
+        trySetAccessible(f2, true);
+    }
+
+    static void testNonPublicClassInNonExportedPackage() throws Exception {
+        Module thisModule = Main.class.getModule();
+        Module targetModule = getTargetModule();
+
+        assertFalse(targetModule.isExported("q2"));
+        assertFalse(targetModule.isExported("q2", thisModule));
+        assertTrue(targetModule.isExported("q2", targetModule));
+
+        assertFalse(targetModule.isOpen("q2"));
+        assertFalse(targetModule.isOpen("q2", thisModule));
+        assertTrue(targetModule.isOpen("q2", targetModule));
+
+        Class<?> clazz = Class.forName("q2.NonPublic");
+        Constructor<?> ctor1 = clazz.getConstructor();  // public
+        Constructor<?> ctor2 = clazz.getDeclaredConstructor(Void.class);  // non-public
+
+        Field f1 = clazz.getField("f1");    // public
+        Field f2 = clazz.getDeclaredField("f2");    // non-public
+
+        Method m1 = clazz.getMethod("foo");  // public
+        Method m2 = clazz.getDeclaredMethod("bar");  // non-public
+
+        tryAccessConstructor(ctor1, false);
+        tryAccessConstructor(ctor2, false);
+        tryAccessMethod(m1, false);
+        tryAccessMethod(m2, false);
+        tryAccessObjectField(f1, false);
+        tryAccessObjectField(f2, false);
+
+        trySetAccessible(ctor1, false);
+        trySetAccessible(ctor2, false);
+        trySetAccessible(m1, false);
+        trySetAccessible(m2, false);
+        trySetAccessible(f1, false);
+        trySetAccessible(f2, false);
+
+        targetAddExports("q2", thisModule);
+
+        tryAccessConstructor(ctor1, false);
+        tryAccessConstructor(ctor2, false);
+        tryAccessMethod(m1, false);
+        tryAccessMethod(m2, false);
+        tryAccessObjectField(f1, false);
+        tryAccessObjectField(f2, false);
+
+        trySetAccessible(ctor1, false);
+        trySetAccessible(ctor2, false);
+        trySetAccessible(m1, false);
+        trySetAccessible(m2, false);
+        trySetAccessible(f1, false);
+        trySetAccessible(f2, false);
+
+        targetAddOpens("q2", thisModule);
+
+        tryAccessConstructor(ctor1, false);
+        tryAccessConstructor(ctor2, false);
+        tryAccessMethod(m1, false);
+        tryAccessMethod(m2, false);
+        tryAccessObjectField(f1, false);
+        tryAccessObjectField(f2, false);
+
+        trySetAccessible(ctor1, true);
+        trySetAccessible(m1, true);
+        trySetAccessible(m2, true);
+        trySetAccessible(f1, true);
+        trySetAccessible(f2, true);
+    }
+
+
+    static Module getTargetModule() {
+        return ModuleLayer.boot().findModule("target").get();
+    }
+
+    static void tryAccessConstructor(Constructor<?> ctor, boolean shouldSucceed) {
+        try {
+            ctor.newInstance();
+            assertTrue(shouldSucceed);
+        } catch (Exception e) {
+            assertFalse(shouldSucceed);
+        }
+    }
+
+    static void tryAccessMethod(Method method, boolean shouldSucceed) {
+        try {
+            method.invoke(null);
+            assertTrue(shouldSucceed);
+        } catch (Exception e) {
+            e.printStackTrace();
+            assertFalse(shouldSucceed);
+        }
+    }
+
+    static void tryAccessObjectField(Field f, boolean shouldSucceed) {
+        try {
+            f.get(null);
+            assertTrue(shouldSucceed);
+        } catch (Exception e) {
+            assertFalse(shouldSucceed);
+        }
+        try {
+            f.set(null, new Object());
+            assertTrue(shouldSucceed);
+        } catch (Exception e) {
+            assertFalse(shouldSucceed);
+        }
+    }
+
+    static void trySetAccessible(AccessibleObject ao, boolean shouldSucceed) {
+        try {
+            ao.setAccessible(true);
+            assertTrue(shouldSucceed);
+        } catch (Exception e) {
+            assertFalse(shouldSucceed);
+        }
+    }
+
+    /**
+     * Update target module to export a package to the given module.
+     */
+    static void targetAddExports(String pn, Module who) throws Exception {
+        Class<?> helper = Class.forName("p1.Helper");
+        Method m = helper.getMethod("addExports", String.class, Module.class);
+        m.invoke(null, pn, who);
+    }
+
+    /**
+     * Update target module to open a package to the given module.
+     */
+    static void targetAddOpens(String pn, Module who) throws Exception {
+        Class<?> helper = Class.forName("p1.Helper");
+        Method m = helper.getMethod("addOpens", String.class, Module.class);
+        m.invoke(null, pn, who);
+    }
+
+    static void assertTrue(boolean expr) {
+        if (!expr) throw new RuntimeException();
+    }
+
+    static void assertFalse(boolean expr) {
+        assertTrue(!expr);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/lang/ModuleTests/addXXX/Driver.java	Tue Apr 18 22:25:33 2017 +0200
@@ -0,0 +1,29 @@
+/*
+ * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/**
+ * @test
+ * @build test/* m1/* m2/* m3/* m4/*
+ * @run testng/othervm test/test.Main
+ * @summary Basic test case for Module::addXXX methods
+ */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/lang/ModuleTests/addXXX/m1/module-info.java	Tue Apr 18 22:25:33 2017 +0200
@@ -0,0 +1,25 @@
+/*
+ * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+module m1 {
+    exports p1;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/lang/ModuleTests/addXXX/m1/p1/C.java	Tue Apr 18 22:25:33 2017 +0200
@@ -0,0 +1,27 @@
+/*
+ * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package p1;
+
+public class C {
+    public C() { }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/lang/ModuleTests/addXXX/m2/module-info.java	Tue Apr 18 22:25:33 2017 +0200
@@ -0,0 +1,25 @@
+/*
+ * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+module m2 {
+    exports p2;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/lang/ModuleTests/addXXX/m2/p2/C.java	Tue Apr 18 22:25:33 2017 +0200
@@ -0,0 +1,30 @@
+/*
+ * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package p2;
+
+public class C {
+
+    public static void export(String pn, Module m) {
+        C.class.getModule().addExports(pn, m);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/lang/ModuleTests/addXXX/m2/p2/internal/C.java	Tue Apr 18 22:25:33 2017 +0200
@@ -0,0 +1,26 @@
+/*
+ * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package p2.internal;
+
+public class C {
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/lang/ModuleTests/addXXX/m3/module-info.java	Tue Apr 18 22:25:33 2017 +0200
@@ -0,0 +1,26 @@
+/*
+ * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+module m3 {
+    exports p3 to test;
+    opens p3 to test;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/lang/ModuleTests/addXXX/m3/p3/C.java	Tue Apr 18 22:25:33 2017 +0200
@@ -0,0 +1,26 @@
+/*
+ * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package p3;
+
+public class C {
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/lang/ModuleTests/addXXX/m4/module-info.java	Tue Apr 18 22:25:33 2017 +0200
@@ -0,0 +1,25 @@
+/*
+ * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+module m4 {
+    exports p4;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/lang/ModuleTests/addXXX/m4/p4/C.java	Tue Apr 18 22:25:33 2017 +0200
@@ -0,0 +1,32 @@
+/*
+ * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package p4;
+
+import java.lang.reflect.Constructor;
+
+public class C {
+    public static Object tryNewInstance(Class<?> clazz) throws Exception {
+        Constructor<?> ctor = clazz.getDeclaredConstructor();
+        return ctor.newInstance();
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/lang/ModuleTests/addXXX/test/module-info.java	Tue Apr 18 22:25:33 2017 +0200
@@ -0,0 +1,30 @@
+/*
+ * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+module test {
+    exports test to testng;
+
+    requires m2;
+    requires m3;
+    requires m4;
+    requires testng;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/lang/ModuleTests/addXXX/test/test/C.java	Tue Apr 18 22:25:33 2017 +0200
@@ -0,0 +1,26 @@
+/*
+ * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package test;
+
+public class C { }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/lang/ModuleTests/addXXX/test/test/Main.java	Tue Apr 18 22:25:33 2017 +0200
@@ -0,0 +1,195 @@
+/*
+ * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package test;
+
+import java.lang.invoke.MethodHandle;
+import java.lang.invoke.MethodHandles;
+import java.lang.invoke.MethodType;
+import java.lang.reflect.Constructor;
+import java.util.ServiceConfigurationError;
+import java.util.ServiceLoader;
+
+import org.testng.annotations.Test;
+import static org.testng.Assert.*;
+
+/**
+ * Basic test case for Module::addXXXX methods
+ */
+
+@Test
+public class Main {
+
+    /**
+     * Test Module::addReads
+     *
+     *     module test { }
+     *
+     *     module m1 {
+     *         exports p1;
+     *     }
+     */
+    public void testAddReads() throws Throwable {
+        Module thisModule = Main.class.getModule();
+        Class<?> clazz = Class.forName("p1.C");
+        Module m1 = clazz.getModule();
+
+        // test does not read m1
+        assertFalse(thisModule.canRead(m1));
+        MethodHandles.Lookup lookup = MethodHandles.lookup();
+        MethodType mt = MethodType.methodType(void.class);
+        try {
+            lookup.findConstructor(clazz, mt);
+            assertTrue(false);
+        } catch (IllegalAccessException expected) { }
+
+        // update test to read m1
+        Module result = thisModule.addReads(m1);
+        assertTrue(result== thisModule);
+        assertTrue(thisModule.canRead(m1));
+        MethodHandle mh = lookup.findConstructor(clazz, mt);
+        Object obj = mh.invoke();
+
+        // attempt to update m1 to read test
+        try {
+            m1.addReads(thisModule);
+            assertTrue(false);
+        } catch (IllegalCallerException expected) { }
+    }
+
+
+    /**
+     * Test Module::addExports
+     *
+     *     module test {
+     *         requires m2;
+     *     }
+     *     module m2 {
+     *         exports p2;
+     *         contains package p2.internal;
+     *     }
+     */
+    public void testAddExports() throws Exception {
+        Module thisModule = Main.class.getModule();
+        Module m2 = p2.C.class.getModule();
+        Class<?> targetClass = Class.forName("p2.internal.C");
+        String p2Internal = targetClass.getPackageName();
+        assertTrue(targetClass.getModule() == m2);
+
+        // m2 does not export p2.internal to test
+        assertFalse(m2.isExported(p2Internal, thisModule));
+        Constructor<?> ctor = targetClass.getDeclaredConstructor();
+        try {
+            ctor.newInstance();
+            assertTrue(false);
+        } catch (IllegalAccessException expected) { }
+
+        // update m2 to export p2.internal to test
+        p2.C.export(p2Internal, thisModule);
+        assertTrue(m2.isExported(p2Internal, thisModule));
+        ctor.newInstance(); // should succeed
+
+        // attempt to update m2 to export a package to test
+        try {
+            m2.addExports("p2.other", thisModule);
+            assertTrue(false);
+        } catch (IllegalCallerException expected) { }
+    }
+
+    /**
+     * Test Module::addOpens
+     *
+     *     module test {
+     *         requires m3;
+     *         requires m4;
+     *     }
+     *
+     *     module m3 {
+     *         exports p3 to test;
+     *         opens p3 to test;
+     *     }
+     *
+     *     module m4 {
+     *         exports p4;
+     *     }
+     */
+    public void testAddOpens() throws Exception {
+        Module thisModule = Main.class.getModule();
+        Module m3 = p3.C.class.getModule();
+        Module m4 = p4.C.class.getModule();
+
+        // test does not open package test to m4
+        assertFalse(thisModule.isOpen("test", m4));
+        try {
+            p4.C.tryNewInstance(test.C.class);
+            assertTrue(false);
+        } catch (IllegalAccessException expected) { }
+
+        // open test to m4
+        thisModule.addOpens("test", m4);
+        p4.C.tryNewInstance(test.C.class);  // should succeed
+
+
+        // m3 does not open p3 to m4
+        assertFalse(m3.isOpen("p3", m4));
+        try {
+            p4.C.tryNewInstance(p3.C.class);
+            assertTrue(false);
+        } catch (IllegalAccessException expected) { }
+
+
+        // m3 opens p3 to test => test allowed to open m3/p3 to m4
+        assertTrue(m3.isOpen("p3", thisModule));
+        m3.addOpens("p3", m4);
+        assertTrue(m3.isOpen("p3", m4));
+        p4.C.tryNewInstance(p3.C.class);   // should succeed
+
+
+        // attempt to update m4 to open package to m3
+        try {
+            m4.addOpens("p4", m3);
+            assertTrue(false);
+        } catch (IllegalCallerException expected) { }
+    }
+
+
+    /**
+     * Test Module::addUses
+     */
+    public void testAddUses() {
+        Module thisModule = Main.class.getModule();
+
+        assertFalse(thisModule.canUse(Service.class));
+        try {
+            ServiceLoader.load(Service.class);
+            assertTrue(false);
+        } catch (ServiceConfigurationError expected) { }
+
+        Module result = thisModule.addUses(Service.class);
+        assertTrue(result== thisModule);
+
+        assertTrue(thisModule.canUse(Service.class));
+        ServiceLoader.load(Service.class); // no exception
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/lang/ModuleTests/addXXX/test/test/Service.java	Tue Apr 18 22:25:33 2017 +0200
@@ -0,0 +1,29 @@
+/*
+ * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package test;
+
+/**
+ * Simple service type
+ */
+public interface Service { }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/lang/ModuleTests/allow.policy	Tue Apr 18 22:25:33 2017 +0200
@@ -0,0 +1,28 @@
+/*
+ * Copyright (c) 2016, 2017, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * 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.
+ */
+
+grant {
+    permission java.lang.RuntimePermission "getClassLoader";
+    permission java.lang.RuntimePermission "accessSystemModules";
+    permission java.io.FilePermission "${java.home}/modules/-", "read";    // exploded build
+};
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/lang/ModuleTests/annotation/Basic.java	Tue Apr 18 22:25:33 2017 +0200
@@ -0,0 +1,76 @@
+/*
+ * 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
+ * @library src
+ * @build m/* Basic
+ * @run testng/othervm Basic
+ * @summary Basic test for annotations on modules
+ */
+
+import java.util.Arrays;
+
+import p.annotation.Foo;
+import p.annotation.Bar;
+import p.annotation.Baz;
+
+import org.testng.annotations.Test;
+import static org.testng.Assert.*;
+
+public class Basic {
+
+    final Module module = Foo.class.getModule();
+
+    /**
+     * {@code @Foo} does not have RUNTIME retention policy.
+     */
+    @Test
+    public void testInvisibleAnnotation() {
+        assertFalse(module.isAnnotationPresent(Foo.class));
+        assertNull(module.getAnnotation(Foo.class));
+    }
+
+    /**
+     * {@code @Bar} has RUNTIME retention policy and value "bar"
+     */
+    @Test
+    public void testBarAnnotation() {
+        assertTrue(module.isAnnotationPresent(Bar.class));
+        Bar bar = module.getAnnotation(Bar.class);
+        assertNotNull(bar);
+        assertEquals(bar.value(), "bar");
+    }
+
+    /**
+     * {@code @Baz} has RUNTIME retention policy has a repeating value
+     */
+    @Test
+    public void testBazAnnotation() {
+        assertTrue(module.isAnnotationPresent(Baz.class));
+        Baz baz = module.getAnnotation(Baz.class);
+        assertNotNull(baz);
+        String[] expected = { "one", "two", "three" };
+        assertTrue(Arrays.equals(baz.value(), expected));
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/lang/ModuleTests/annotation/src/m/module-info.java	Tue Apr 18 22:25:33 2017 +0200
@@ -0,0 +1,31 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+import p.annotation.*;
+
+@Foo
+@Bar("bar")
+@Baz({"one", "two", "three"})
+module m {
+    exports p.annotation;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/lang/ModuleTests/annotation/src/m/p/annotation/Bar.java	Tue Apr 18 22:25:33 2017 +0200
@@ -0,0 +1,35 @@
+/*
+ * 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.
+ */
+
+package p.annotation;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+import static java.lang.annotation.ElementType.MODULE;
+
+@Retention(RetentionPolicy.RUNTIME)
+@Target(value={MODULE})
+public @interface Bar {
+   String value();
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/lang/ModuleTests/annotation/src/m/p/annotation/Baz.java	Tue Apr 18 22:25:33 2017 +0200
@@ -0,0 +1,35 @@
+/*
+ * 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.
+ */
+
+package p.annotation;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+import static java.lang.annotation.ElementType.MODULE;
+
+@Target(value={MODULE})
+@Retention(RetentionPolicy.RUNTIME)
+public @interface Baz {
+   String[] value();
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/lang/ModuleTests/annotation/src/m/p/annotation/Foo.java	Tue Apr 18 22:25:33 2017 +0200
@@ -0,0 +1,30 @@
+/*
+ * 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.
+ */
+
+package p.annotation;
+
+import java.lang.annotation.Target;
+import static java.lang.annotation.ElementType.MODULE;
+
+@Target(value={MODULE})
+public @interface Foo {}
--- a/jdk/test/java/lang/SecurityManager/CheckPackageAccess.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/jdk/test/java/lang/SecurityManager/CheckPackageAccess.java	Tue Apr 18 22:25:33 2017 +0200
@@ -33,7 +33,6 @@
 
 import java.lang.module.ModuleFinder;
 import java.lang.module.ModuleReference;
-import java.lang.reflect.Layer;
 import java.util.Arrays;
 import java.util.List;
 import java.util.Optional;
@@ -82,7 +81,7 @@
 
         void test() {
             final boolean isModulePresent =
-                        Layer.boot().findModule(moduleName).isPresent();
+                        ModuleLayer.boot().findModule(moduleName).isPresent();
             System.out.format("Testing module: %1$s. Module is%2$s present.\n",
                         moduleName, isModulePresent ? "" : " NOT");
 
--- a/jdk/test/java/lang/SecurityManager/CheckSecurityProvider.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/jdk/test/java/lang/SecurityManager/CheckSecurityProvider.java	Tue Apr 18 22:25:33 2017 +0200
@@ -28,7 +28,6 @@
  * @run main/othervm CheckSecurityProvider
  */
 
-import java.lang.reflect.Layer;
 import java.security.Provider;
 import java.security.Security;
 import java.util.ArrayList;
@@ -45,7 +44,7 @@
  */
 public class CheckSecurityProvider {
     public static void main(String[] args) throws Exception {
-        Layer layer = Layer.boot();
+        ModuleLayer layer = ModuleLayer.boot();
 
         System.setSecurityManager(new SecurityManager());
 
--- a/jdk/test/java/lang/SecurityManager/modules/Test.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/jdk/test/java/lang/SecurityManager/modules/Test.java	Tue Apr 18 22:25:33 2017 +0200
@@ -21,8 +21,6 @@
  * questions.
  */
 
-import java.lang.reflect.Module;
-
 public class Test {
     public static void main(String... args) {
         SecurityManager sm = System.getSecurityManager();
--- a/jdk/test/java/lang/StackTraceElement/PublicConstructor.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/jdk/test/java/lang/StackTraceElement/PublicConstructor.java	Tue Apr 18 22:25:33 2017 +0200
@@ -29,7 +29,6 @@
  */
 
 import java.lang.module.ModuleDescriptor;
-import java.lang.reflect.Module;
 
 public class PublicConstructor {
     public static void main(String... args) {
--- a/jdk/test/java/lang/StackTraceElement/lib/m1/com/app/Utils.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/jdk/test/java/lang/StackTraceElement/lib/m1/com/app/Utils.java	Tue Apr 18 22:25:33 2017 +0200
@@ -25,7 +25,6 @@
 
 import java.lang.StackWalker.StackFrame;
 import java.lang.module.ModuleDescriptor;
-import java.lang.reflect.Module;
 import java.util.Objects;
 
 public class Utils {
--- a/jdk/test/java/lang/System/Logger/custom/CustomLoggerTest.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/jdk/test/java/lang/System/Logger/custom/CustomLoggerTest.java	Tue Apr 18 22:25:33 2017 +0200
@@ -46,7 +46,6 @@
 import java.lang.System.Logger;
 import java.lang.System.Logger.Level;
 import java.util.stream.Stream;
-import java.lang.reflect.Module;
 import java.security.AllPermission;
 
 /**
--- a/jdk/test/java/lang/System/LoggerFinder/BaseLoggerFinderTest/BaseLoggerFinder.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/jdk/test/java/lang/System/LoggerFinder/BaseLoggerFinderTest/BaseLoggerFinder.java	Tue Apr 18 22:25:33 2017 +0200
@@ -25,7 +25,6 @@
 import java.security.PrivilegedAction;
 import java.lang.System.LoggerFinder;
 import java.lang.System.Logger;
-import java.lang.reflect.Module;
 
 public  class BaseLoggerFinder extends LoggerFinder implements TestLoggerFinder {
 
--- a/jdk/test/java/lang/System/LoggerFinder/BaseLoggerFinderTest/TestLoggerFinder.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/jdk/test/java/lang/System/LoggerFinder/BaseLoggerFinderTest/TestLoggerFinder.java	Tue Apr 18 22:25:33 2017 +0200
@@ -30,7 +30,6 @@
 import java.util.concurrent.atomic.AtomicLong;
 import java.util.function.Supplier;
 import java.lang.System.Logger;
-import java.lang.reflect.Module;
 
 /**
  * What our test provider needs to implement.
--- a/jdk/test/java/lang/System/LoggerFinder/LoggerFinderAPI/LoggerFinderAPI.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/jdk/test/java/lang/System/LoggerFinder/LoggerFinderAPI/LoggerFinderAPI.java	Tue Apr 18 22:25:33 2017 +0200
@@ -28,7 +28,6 @@
 import java.lang.System.Logger;
 import java.lang.System.Logger.Level;
 import java.lang.System.LoggerFinder;
-import java.lang.reflect.Module;
 import java.util.Enumeration;
 import java.util.Locale;
 import java.util.Objects;
--- a/jdk/test/java/lang/System/LoggerFinder/internal/BaseDefaultLoggerFinderTest/BaseDefaultLoggerFinderTest.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/jdk/test/java/lang/System/LoggerFinder/internal/BaseDefaultLoggerFinderTest/BaseDefaultLoggerFinderTest.java	Tue Apr 18 22:25:33 2017 +0200
@@ -55,7 +55,6 @@
 import jdk.internal.logger.DefaultLoggerFinder;
 import jdk.internal.logger.SimpleConsoleLogger;
 import sun.util.logging.PlatformLogger;
-import java.lang.reflect.Module;
 
 /**
  * @test
--- a/jdk/test/java/lang/System/LoggerFinder/internal/BaseLoggerBridgeTest/BaseLoggerBridgeTest.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/jdk/test/java/lang/System/LoggerFinder/internal/BaseLoggerBridgeTest/BaseLoggerBridgeTest.java	Tue Apr 18 22:25:33 2017 +0200
@@ -47,7 +47,6 @@
 import java.lang.System.Logger;
 import java.lang.System.Logger.Level;
 import java.util.stream.Stream;
-import java.lang.reflect.Module;
 
 /**
  * @test
--- a/jdk/test/java/lang/System/LoggerFinder/internal/BasePlatformLoggerTest/BasePlatformLoggerTest.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/jdk/test/java/lang/System/LoggerFinder/internal/BasePlatformLoggerTest/BasePlatformLoggerTest.java	Tue Apr 18 22:25:33 2017 +0200
@@ -47,7 +47,6 @@
 import java.security.AccessControlException;
 import java.util.stream.Stream;
 import sun.util.logging.PlatformLogger;
-import java.lang.reflect.Module;
 
 /**
  * @test
--- a/jdk/test/java/lang/System/LoggerFinder/internal/BootstrapLogger/BootstrapLoggerAPIsTest.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/jdk/test/java/lang/System/LoggerFinder/internal/BootstrapLogger/BootstrapLoggerAPIsTest.java	Tue Apr 18 22:25:33 2017 +0200
@@ -30,7 +30,6 @@
 import java.util.List;
 import java.util.ResourceBundle;
 import java.util.Set;
-import java.lang.reflect.Module;
 import jdk.internal.logger.BootstrapLogger;
 import jdk.internal.logger.LazyLoggers;
 
--- a/jdk/test/java/lang/System/LoggerFinder/internal/BootstrapLogger/BootstrapLoggerTest.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/jdk/test/java/lang/System/LoggerFinder/internal/BootstrapLogger/BootstrapLoggerTest.java	Tue Apr 18 22:25:33 2017 +0200
@@ -43,7 +43,6 @@
 import java.util.stream.Stream;
 import jdk.internal.logger.BootstrapLogger;
 import jdk.internal.logger.LazyLoggers;
-import java.lang.reflect.Module;
 
 /*
  * @test
--- a/jdk/test/java/lang/System/LoggerFinder/internal/LoggerBridgeTest/LoggerBridgeTest.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/jdk/test/java/lang/System/LoggerFinder/internal/LoggerBridgeTest/LoggerBridgeTest.java	Tue Apr 18 22:25:33 2017 +0200
@@ -51,7 +51,6 @@
 import java.lang.System.Logger.Level;
 import java.util.stream.Stream;
 import sun.util.logging.PlatformLogger;
-import java.lang.reflect.Module;
 
 /**
  * @test
--- a/jdk/test/java/lang/System/LoggerFinder/internal/LoggerFinderLoaderTest/LoggerFinderLoaderTest.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/jdk/test/java/lang/System/LoggerFinder/internal/LoggerFinderLoaderTest/LoggerFinderLoaderTest.java	Tue Apr 18 22:25:33 2017 +0200
@@ -53,7 +53,6 @@
 import java.util.ServiceLoader;
 import java.util.concurrent.atomic.AtomicReference;
 import jdk.internal.logger.SimpleConsoleLogger;
-import java.lang.reflect.Module;
 
 /**
  * @test
--- a/jdk/test/java/lang/System/LoggerFinder/internal/PlatformLoggerBridgeTest/PlatformLoggerBridgeTest.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/jdk/test/java/lang/System/LoggerFinder/internal/PlatformLoggerBridgeTest/PlatformLoggerBridgeTest.java	Tue Apr 18 22:25:33 2017 +0200
@@ -49,7 +49,6 @@
 import java.lang.System.Logger.Level;
 import java.util.stream.Stream;
 import sun.util.logging.PlatformLogger;
-import java.lang.reflect.Module;
 
 /**
  * @test
--- a/jdk/test/java/lang/System/LoggerFinder/internal/SystemLoggerInPlatformLoader/SystemLoggerInPlatformLoader.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/jdk/test/java/lang/System/LoggerFinder/internal/SystemLoggerInPlatformLoader/SystemLoggerInPlatformLoader.java	Tue Apr 18 22:25:33 2017 +0200
@@ -28,7 +28,6 @@
 import java.io.IOException;
 import java.io.InputStream;
 import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Layer;
 import java.lang.reflect.Method;
 
 /*
@@ -106,7 +105,7 @@
         }
         Class<?> platformLoggerType = platformLogger.getClass();
         System.out.println("platformLogger: " + platformLoggerType);
-        boolean simpleConsoleOnly = !Layer.boot().findModule("java.logging").isPresent();
+        boolean simpleConsoleOnly = !ModuleLayer.boot().findModule("java.logging").isPresent();
         if (simpleConsoleOnly) {
             /* Happens if the test is called with custom JDK without java.logging module
                or in case usage commandline option --limit-modules java.base */
--- a/jdk/test/java/lang/System/LoggerFinder/internal/backend/LoggerFinderBackendTest.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/jdk/test/java/lang/System/LoggerFinder/internal/backend/LoggerFinderBackendTest.java	Tue Apr 18 22:25:33 2017 +0200
@@ -78,7 +78,6 @@
 import java.util.logging.LogRecord;
 import java.util.logging.Logger;
 import sun.util.logging.internal.LoggingProviderImpl;
-import java.lang.reflect.Module;
 
 /**
  * @author danielfuchs
--- a/jdk/test/java/lang/System/LoggerFinder/jdk/DefaultLoggerBridgeTest/DefaultLoggerBridgeTest.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/jdk/test/java/lang/System/LoggerFinder/jdk/DefaultLoggerBridgeTest/DefaultLoggerBridgeTest.java	Tue Apr 18 22:25:33 2017 +0200
@@ -48,7 +48,6 @@
 import java.lang.System.Logger;
 import java.util.stream.Stream;
 import sun.util.logging.internal.LoggingProviderImpl;
-import java.lang.reflect.Module;
 
 /**
  * @test
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/lang/WeakPairMap/Driver.java	Tue Apr 18 22:25:33 2017 +0200
@@ -0,0 +1,35 @@
+/*
+ * 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 8888888
+ * @summary Functional test for WeakPairMap
+ * @build java.base/java.lang.WeakPairMapTest
+ * @run main Driver
+ */
+public class Driver {
+    public static void main(String[] args) {
+        java.lang.WeakPairMapTest.main(args);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/lang/WeakPairMap/java.base/java/lang/WeakPairMapTest.java	Tue Apr 18 22:25:33 2017 +0200
@@ -0,0 +1,175 @@
+/*
+ * 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.
+ */
+
+package java.lang;
+
+import java.lang.ref.Reference;
+import java.util.Objects;
+
+/**
+ * Functional test for WeakPairMap
+ *
+ * @author Peter Levart
+ */
+public class WeakPairMapTest {
+    public static void main(String[] args) {
+        WeakPairMap<Object, Object, String> pm = new WeakPairMap<>();
+        Object key1 = new Object();
+        Object key2 = new Object();
+
+        // check for emptiness
+        assertEquals(pm.containsKeyPair(key1, key2), false);
+        assertEquals(pm.get(key1, key2), null);
+
+        // check for NPE(s)
+        for (Object k1 : new Object[]{null, key1}) {
+            for (Object k2 : new Object[]{null, key2}) {
+                for (String v : new String[]{null, "abc"}) {
+
+                    if (k1 != null && k2 != null && v != null) {
+                        // skip non-null args
+                        continue;
+                    }
+
+                    try {
+                        pm.put(k1, k2, v);
+                        throw new AssertionError("Unexpected code path, k1=" +
+                                                 k1 + ", k2=" + k2 + ", v=" + v);
+                    } catch (NullPointerException e) {
+                        // expected
+                    }
+
+                    try {
+                        pm.putIfAbsent(k1, k2, v);
+                        throw new AssertionError("Unexpected code path, k1=" +
+                                                 k1 + ", k2=" + k2 + ", v=" + v);
+                    } catch (NullPointerException e) {
+                        // expected
+                    }
+
+                    if (k1 != null && k2 != null) {
+                        // skip non-null args
+                        continue;
+                    }
+
+                    try {
+                        pm.computeIfAbsent(k1, k2, (_k1, _k2) -> v);
+                        throw new AssertionError("Unexpected code path, k1=" +
+                                                 k1 + ", k2=" + k2 + ", v=" + v);
+                    } catch (NullPointerException e) {
+                        // expected
+                    }
+
+                    try {
+                        pm.containsKeyPair(k1, k2);
+                        throw new AssertionError("Unexpected code path, k1=" +
+                                                 k1 + ", k2=" + k2);
+                    } catch (NullPointerException e) {
+                        // expected
+                    }
+
+                    try {
+                        pm.get(k1, k2);
+                        throw new AssertionError("Unexpected code path, k1=" +
+                                                 k1 + ", k2=" + k2);
+                    } catch (NullPointerException e) {
+                        // expected
+                    }
+                }
+            }
+        }
+
+        // how much to wait when it is expected for entry to be retained
+        final long retentionTimeout = 500L;
+        // how much to wait when it is expected for entry to be removed
+        final long cleanupTimeout = 30_000L;
+
+        // check insertion
+        assertEquals(pm.putIfAbsent(key1, key2, "abc"), null);
+        assertEquals(pm.get(key1, key2), "abc");
+
+        // check retention while both keys are still reachable
+        assertEquals(gcAndWaitRemoved(pm, "abc", retentionTimeout), false);
+        assertEquals(pm.get(key1, key2), "abc");
+
+        // check cleanup when both keys are unreachable
+        key1 = null;
+        key2 = null;
+        assertEquals(gcAndWaitRemoved(pm, "abc", cleanupTimeout), true);
+
+        // new insertion
+        key1 = new Object();
+        key2 = new Object();
+        assertEquals(pm.putIfAbsent(key1, key2, "abc"), null);
+        assertEquals(pm.get(key1, key2), "abc");
+
+        // check retention while both keys are still reachable
+        assertEquals(gcAndWaitRemoved(pm, "abc", retentionTimeout), false);
+        assertEquals(pm.get(key1, key2), "abc");
+
+        // check cleanup when 1st key is unreachable
+        key1 = null;
+        assertEquals(gcAndWaitRemoved(pm, "abc", cleanupTimeout), true);
+        Reference.reachabilityFence(key2);
+
+        // new insertion
+        key1 = new Object();
+        key2 = new Object();
+        assertEquals(pm.putIfAbsent(key1, key2, "abc"), null);
+        assertEquals(pm.get(key1, key2), "abc");
+
+        // check retention while both keys are still reachable
+        assertEquals(gcAndWaitRemoved(pm, "abc", retentionTimeout), false);
+        assertEquals(pm.get(key1, key2), "abc");
+
+        // check cleanup when 2nd key is unreachable
+        key2 = null;
+        assertEquals(gcAndWaitRemoved(pm, "abc", cleanupTimeout), true);
+        Reference.reachabilityFence(key1);
+    }
+
+    /**
+     * Trigger GC and wait for at most {@code millis} ms for given value to
+     * be removed from given WeakPairMap.
+     *
+     * @return true if element has been removed or false if not
+     */
+    static <V> boolean gcAndWaitRemoved(WeakPairMap<?, ?, V> pm, V value,
+                                        long millis) {
+        System.gc();
+        for (int i = 0; i < (millis + 99) / 100 && pm.values().contains(value); i++) {
+            try {
+                Thread.sleep(100L);
+            } catch (InterruptedException e) {
+                throw new AssertionError("Interrupted");
+            }
+        }
+        return !pm.values().contains(value);
+    }
+
+    static void assertEquals(Object actual, Object expected) {
+        if (!Objects.equals(actual, expected)) {
+            throw new AssertionError("Expected: " + expected + ", actual: " + actual);
+        }
+    }
+}
--- a/jdk/test/java/lang/instrument/ATransformerManagementTestCase.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/jdk/test/java/lang/instrument/ATransformerManagementTestCase.java	Tue Apr 18 22:25:33 2017 +0200
@@ -24,8 +24,6 @@
 
 import java.io.*;
 import java.lang.instrument.*;
-
-import java.lang.reflect.Module;
 import java.security.ProtectionDomain;
 import java.util.*;
 
--- a/jdk/test/java/lang/instrument/BootstrapClassPathAgent.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/jdk/test/java/lang/instrument/BootstrapClassPathAgent.java	Tue Apr 18 22:25:33 2017 +0200
@@ -26,7 +26,6 @@
 import java.io.*;
 import java.lang.instrument.ClassFileTransformer;
 import java.lang.instrument.Instrumentation;
-import java.lang.reflect.Module;
 import java.security.ProtectionDomain;
 
 public class BootstrapClassPathAgent {
--- a/jdk/test/java/lang/instrument/BootstrapClassPathTest.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/jdk/test/java/lang/instrument/BootstrapClassPathTest.java	Tue Apr 18 22:25:33 2017 +0200
@@ -33,7 +33,6 @@
 
 import java.io.*;
 import java.lang.instrument.*;
-import java.lang.reflect.Module;
 import java.security.ProtectionDomain;
 
 public class BootstrapClassPathTest {
--- a/jdk/test/java/lang/instrument/RedefineClassWithNativeMethodAgent.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/jdk/test/java/lang/instrument/RedefineClassWithNativeMethodAgent.java	Tue Apr 18 22:25:33 2017 +0200
@@ -24,7 +24,6 @@
 import java.io.InputStream;
 import java.lang.instrument.ClassDefinition;
 import java.lang.instrument.Instrumentation;
-import java.lang.reflect.Module;
 import java.util.Timer;
 import java.util.TimerTask;
 
--- a/jdk/test/java/lang/instrument/RedefineModuleAgent.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/jdk/test/java/lang/instrument/RedefineModuleAgent.java	Tue Apr 18 22:25:33 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2016, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -22,7 +22,6 @@
  */
 
 import java.lang.instrument.Instrumentation;
-import java.lang.reflect.Module;
 import java.util.List;
 import java.util.Map;
 import java.util.Set;
@@ -47,4 +46,8 @@
                                Map<Class<?>, List<Class<?>>> extraProvides) {
         inst.redefineModule(module, extraReads, extraExports, extraOpens, extraUses, extraProvides);
     }
+
+    static boolean isModifiableModule(Module module) {
+        return inst.isModifiableModule(module);
+    }
 }
--- a/jdk/test/java/lang/instrument/RedefineModuleTest.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/jdk/test/java/lang/instrument/RedefineModuleTest.java	Tue Apr 18 22:25:33 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2016, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -34,8 +34,6 @@
 
 import java.lang.TestProvider;
 import java.lang.instrument.Instrumentation;
-import java.lang.reflect.Layer;
-import java.lang.reflect.Module;
 import java.net.URLStreamHandler;
 import java.net.spi.URLStreamHandlerProvider;
 import java.nio.file.FileSystems;
@@ -68,6 +66,10 @@
                                            extraProvides);
     }
 
+    static boolean isModifiableModule(Module module) {
+        return RedefineModuleAgent.isModifiableModule(module);
+    }
+
 
     /**
      * Use redefineModule to update java.base to read java.instrument
@@ -138,13 +140,13 @@
         // pre-conditions
         assertFalse(baseModule.canUse(service));
         assertTrue(collect(ServiceLoader.load(service)).isEmpty());
-        assertTrue(collect(ServiceLoader.load(Layer.boot(), service)).isEmpty());
+        assertTrue(collect(ServiceLoader.load(ModuleLayer.boot(), service)).isEmpty());
 
         // update java.base to use TestProvider
         redefineModule(baseModule, Set.of(), Map.of(), Map.of(), Set.of(service), Map.of());
         assertTrue(baseModule.canUse(service));
         assertTrue(collect(ServiceLoader.load(service)).isEmpty());
-        assertTrue(collect(ServiceLoader.load(Layer.boot(), service)).isEmpty());
+        assertTrue(collect(ServiceLoader.load(ModuleLayer.boot(), service)).isEmpty());
 
         // update java.base to provide an implementation of TestProvider
         Class<?> type1 = Class.forName("jdk.internal.test.TestProviderImpl1");
@@ -162,7 +164,7 @@
         assertTrue(containsInstanceOf(collect(providers), type1));
 
         // use ServiceLoader to load implementations in the boot layer
-        providers = collect(ServiceLoader.load(Layer.boot(), service));
+        providers = collect(ServiceLoader.load(ModuleLayer.boot(), service));
         assertTrue(collect(providers).size() == 1);
         assertTrue(containsInstanceOf(collect(providers), type1));
 
@@ -184,7 +186,7 @@
         assertTrue(containsInstanceOf(providers, type2));
 
         // use ServiceLoader to load implementations in the boot layer
-        providers = collect(ServiceLoader.load(Layer.boot(), service));
+        providers = collect(ServiceLoader.load(ModuleLayer.boot(), service));
         assertTrue(collect(providers).size() == 2);
         assertTrue(containsInstanceOf(providers, type1));
         assertTrue(containsInstanceOf(providers, type2));
@@ -279,6 +281,19 @@
     }
 
     /**
+     * Exercise IsModifiableModule
+     */
+    @Test
+    public void testIsModifiableModule() {
+        ClassLoader pcl = ClassLoader.getPlatformClassLoader();
+        ClassLoader scl = ClassLoader.getSystemClassLoader();
+        assertTrue(isModifiableModule(pcl.getUnnamedModule()));
+        assertTrue(isModifiableModule(scl.getUnnamedModule()));
+        assertTrue(isModifiableModule(RedefineModuleTest.class.getModule()));
+        assertTrue(isModifiableModule(Object.class.getModule()));
+    }
+
+    /**
      * Test redefineClass with null
      */
     public void testNulls() {
--- a/jdk/test/java/lang/instrument/RetransformAgent.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/jdk/test/java/lang/instrument/RetransformAgent.java	Tue Apr 18 22:25:33 2017 +0200
@@ -34,7 +34,6 @@
  */
 
 import java.lang.instrument.*;
-import java.lang.reflect.Module;
 import java.security.ProtectionDomain;
 import java.io.*;
 import asmlib.*;
--- a/jdk/test/java/lang/instrument/SimpleIdentityTransformer.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/jdk/test/java/lang/instrument/SimpleIdentityTransformer.java	Tue Apr 18 22:25:33 2017 +0200
@@ -24,7 +24,6 @@
 import java.lang.instrument.Instrumentation;
 import java.lang.instrument.ClassFileTransformer;
 
-import java.lang.reflect.Module;
 import java.security.*;
 
 /*
--- a/jdk/test/java/lang/invoke/MethodHandles/privateLookupIn/test/p/PrivateLookupInTests.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/jdk/test/java/lang/invoke/MethodHandles/privateLookupIn/test/p/PrivateLookupInTests.java	Tue Apr 18 22:25:33 2017 +0200
@@ -26,7 +26,6 @@
 import java.lang.invoke.MethodHandles;
 import java.lang.invoke.MethodHandles.Lookup;
 import java.lang.reflect.Modifier;
-import java.lang.reflect.Module;
 
 import static java.lang.invoke.MethodHandles.Lookup.*;
 
--- a/jdk/test/java/lang/invoke/modules/m1/p1/Main.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/jdk/test/java/lang/invoke/modules/m1/p1/Main.java	Tue Apr 18 22:25:33 2017 +0200
@@ -27,8 +27,6 @@
 import java.lang.invoke.MethodHandles;
 import java.lang.invoke.MethodHandles.Lookup;
 import java.lang.invoke.MethodType;
-import java.lang.reflect.Layer;
-import java.lang.reflect.Module;
 
 import static java.lang.invoke.MethodHandles.Lookup.*;
 
@@ -64,14 +62,14 @@
         }
 
         // check setup
-        Module m1 = Layer.boot().findModule("m1").orElse(null);
+        Module m1 = ModuleLayer.boot().findModule("m1").orElse(null);
         assertNotNull(m1);
         assertTrue(p1_Type1.getModule() == m1);
         assertTrue(p2_Type2.getModule() == m1);
         assertTrue(m1.isExported("p1"));
         assertFalse(m1.isExported("p2"));
 
-        Module m2 = Layer.boot().findModule("m2").orElse(null);
+        Module m2 = ModuleLayer.boot().findModule("m2").orElse(null);
         assertNotNull(m2);
         assertTrue(q1_Type1.getModule() == m2);
         assertTrue(q2_Type2.getModule() == m2);
--- a/jdk/test/java/lang/module/AutomaticModulesTest.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/jdk/test/java/lang/module/AutomaticModulesTest.java	Tue Apr 18 22:25:33 2017 +0200
@@ -38,8 +38,6 @@
 import java.lang.module.ModuleReference;
 import java.lang.module.ResolutionException;
 import java.lang.module.ResolvedModule;
-import java.lang.reflect.Layer;
-import java.lang.reflect.Module;
 import java.nio.file.Files;
 import java.nio.file.Path;
 import java.nio.file.Paths;
@@ -69,13 +67,8 @@
             { "foo.jar",                    "foo" },
             { "foo4j.jar",                  "foo4j", },
 
-            { "foo1.jar",                   "foo" },
-            { "foo1.2.jar",                 "foo" },
-            { "foo1.2.3.jar",               "foo" },
-
-            { "foo10.jar",                  "foo" },
-            { "foo10.20.jar",               "foo" },
-            { "foo10.20.30.jar",            "foo" },
+            { "foo1.jar",                   "foo1" },
+            { "foo10.jar",                  "foo10" },
 
             { "foo-1.jar",                  "foo/1" },
             { "foo-1.2.jar",                "foo/1.2" },
@@ -93,6 +86,9 @@
             { "foo-bar-10.jar",             "foo.bar/10" },
             { "foo-bar-10.20.jar",          "foo.bar/10.20" },
 
+            { "foo.bar1.jar",               "foo.bar1" },
+            { "foo.bar10.jar",              "foo.bar10" },
+
             { "foo-1.2-SNAPSHOT.jar",       "foo/1.2-SNAPSHOT" },
             { "foo-bar-1.2-SNAPSHOT.jar",   "foo.bar/1.2-SNAPSHOT" },
 
@@ -108,8 +104,12 @@
     public Object[][] createBadNames() {
         return new Object[][]{
 
-            { ".jar",     null },
-            { "_.jar",    null }
+            { ".jar",          null },
+            { "_.jar",         null },
+
+            { "foo.1.jar",     null },
+            { "1foo.jar",      null },
+            { "foo.1bar.jar",  null },
 
         };
     }
@@ -389,7 +389,7 @@
 
         ModuleFinder finder = ModuleFinder.of(dir);
 
-        Configuration parent = Layer.boot().configuration();
+        Configuration parent = ModuleLayer.boot().configuration();
         Configuration cf = resolve(parent, finder, "m");
 
         ModuleDescriptor descriptor = findDescriptor(cf, "m");
@@ -469,11 +469,11 @@
         createDummyJarFile(dir.resolve("c.jar"), "q/T.class");
 
         // module finder locates a and the modules in the directory
-        ModuleFinder finder
-            = ModuleFinder.compose(ModuleUtils.finderOf(descriptor1),
-                ModuleFinder.of(dir));
+        ModuleFinder finder1 = ModuleUtils.finderOf(descriptor1);
+        ModuleFinder finder2 = ModuleFinder.of(dir);
+        ModuleFinder finder = ModuleFinder.compose(finder1, finder2);
 
-        Configuration parent = Layer.boot().configuration();
+        Configuration parent = ModuleLayer.boot().configuration();
         Configuration cf = resolve(parent, finder, "a");
 
         assertTrue(cf.modules().size() == 3);
@@ -482,7 +482,7 @@
         assertTrue(cf.findModule("c").isPresent());
 
         ResolvedModule base = cf.findModule("java.base").get();
-        assertTrue(base.configuration() == Layer.boot().configuration());
+        assertTrue(base.configuration() == ModuleLayer.boot().configuration());
         ResolvedModule a = cf.findModule("a").get();
         ResolvedModule b = cf.findModule("b").get();
         ResolvedModule c = cf.findModule("c").get();
@@ -534,11 +534,11 @@
         createDummyJarFile(dir.resolve("d.jar"), "q/T.class");
 
         // module finder locates a and the modules in the directory
-        ModuleFinder finder
-            = ModuleFinder.compose(ModuleUtils.finderOf(descriptor1, descriptor2),
-                                   ModuleFinder.of(dir));
+        ModuleFinder finder1 = ModuleUtils.finderOf(descriptor1, descriptor2);
+        ModuleFinder finder2 = ModuleFinder.of(dir);
+        ModuleFinder finder = ModuleFinder.compose(finder1, finder2);
 
-        Configuration parent = Layer.boot().configuration();
+        Configuration parent = ModuleLayer.boot().configuration();
         Configuration cf = resolve(parent, finder, "a", "d");
 
         assertTrue(cf.modules().size() == 4);
@@ -554,7 +554,7 @@
         // readability
 
         ResolvedModule base = cf.findModule("java.base").get();
-        assertTrue(base.configuration() == Layer.boot().configuration());
+        assertTrue(base.configuration() == ModuleLayer.boot().configuration());
         ResolvedModule a = cf.findModule("a").get();
         ResolvedModule b = cf.findModule("b").get();
         ResolvedModule c = cf.findModule("c").get();
@@ -607,11 +607,11 @@
         createDummyJarFile(dir.resolve("d.jar"), "q/T.class");
 
         // module finder locates a and the modules in the directory
-        ModuleFinder finder
-            = ModuleFinder.compose(ModuleUtils.finderOf(descriptor1, descriptor2),
-                ModuleFinder.of(dir));
+        ModuleFinder finder1 = ModuleUtils.finderOf(descriptor1, descriptor2);
+        ModuleFinder finder2 = ModuleFinder.of(dir);
+        ModuleFinder finder = ModuleFinder.compose(finder1, finder2);
 
-        Configuration parent = Layer.boot().configuration();
+        Configuration parent = ModuleLayer.boot().configuration();
         Configuration cf = resolve(parent, finder, "a", "d");
 
         assertTrue(cf.modules().size() == 4);
@@ -621,7 +621,7 @@
         assertTrue(cf.findModule("d").isPresent());
 
         ResolvedModule base = cf.findModule("java.base").get();
-        assertTrue(base.configuration() == Layer.boot().configuration());
+        assertTrue(base.configuration() == ModuleLayer.boot().configuration());
         ResolvedModule a = cf.findModule("a").get();
         ResolvedModule b = cf.findModule("b").get();
         ResolvedModule c = cf.findModule("c").get();
@@ -661,6 +661,189 @@
 
 
     /**
+     * Basic test to ensure that no automatic modules are resolved when
+     * an automatic module is not a root or required by other modules.
+     */
+    public void testInConfiguration4() throws IOException {
+        ModuleDescriptor descriptor1
+            = ModuleDescriptor.newModule("m1")
+                .requires("java.base")
+                .build();
+
+        // automatic modules
+        Path dir = Files.createTempDirectory(USER_DIR, "mods");
+        createDummyJarFile(dir.resolve("auto1.jar"), "p1/C.class");
+        createDummyJarFile(dir.resolve("auto2.jar"), "p2/C.class");
+        createDummyJarFile(dir.resolve("auto3.jar"), "p3/C.class");
+
+        // module finder locates m1 and the modules in the directory
+        ModuleFinder finder1 = ModuleUtils.finderOf(descriptor1);
+        ModuleFinder finder2 =  ModuleFinder.of(dir);
+        ModuleFinder finder = ModuleFinder.compose(finder1, finder2);
+
+        Configuration parent = ModuleLayer.boot().configuration();
+        Configuration cf = resolve(parent, finder, "m1");
+
+        // ensure that no automatic module is resolved
+        assertTrue(cf.modules().size() == 1);
+        assertTrue(cf.findModule("m1").isPresent());
+    }
+
+
+    /**
+     * Basic test to ensure that if an automatic module is resolved then
+     * all observable automatic modules are resolved.
+     */
+    public void testInConfiguration5() throws IOException {
+        // m1 requires m2
+        ModuleDescriptor descriptor1
+            = ModuleDescriptor.newModule("m1")
+                .requires("m2").build();
+
+        // m2 requires automatic module
+        ModuleDescriptor descriptor2
+            = ModuleDescriptor.newModule("m2")
+                .requires("auto1")
+                .build();
+
+        // automatic modules
+        Path dir = Files.createTempDirectory(USER_DIR, "mods");
+        createDummyJarFile(dir.resolve("auto1.jar"), "p1/C.class");
+        createDummyJarFile(dir.resolve("auto2.jar"), "p2/C.class");
+        createDummyJarFile(dir.resolve("auto3.jar"), "p3/C.class");
+
+        // module finder locates m1, m2, and the modules in the directory
+        ModuleFinder finder1 = ModuleUtils.finderOf(descriptor1, descriptor2);
+        ModuleFinder finder2 =  ModuleFinder.of(dir);
+        ModuleFinder finder = ModuleFinder.compose(finder1, finder2);
+
+        Configuration parent = ModuleLayer.boot().configuration();
+        Configuration cf = resolve(parent, finder, "m1");
+
+        // all automatic modules should be resolved
+        assertTrue(cf.modules().size() == 5);
+        assertTrue(cf.findModule("m1").isPresent());
+        assertTrue(cf.findModule("m2").isPresent());
+        assertTrue(cf.findModule("auto1").isPresent());
+        assertTrue(cf.findModule("auto2").isPresent());
+        assertTrue(cf.findModule("auto3").isPresent());
+
+        ResolvedModule base = parent.findModule("java.base")
+                                    .orElseThrow(() -> new RuntimeException());
+        ResolvedModule m1 = cf.findModule("m1").get();
+        ResolvedModule m2 = cf.findModule("m2").get();
+        ResolvedModule auto1 = cf.findModule("auto1").get();
+        ResolvedModule auto2 = cf.findModule("auto2").get();
+        ResolvedModule auto3 = cf.findModule("auto3").get();
+
+        // m1 does not read the automatic modules
+        assertTrue(m1.reads().size() == 2);
+        assertTrue(m1.reads().contains(m2));
+        assertTrue(m1.reads().contains(base));
+
+        // m2 should read all the automatic modules
+        assertTrue(m2.reads().size() == 4);
+        assertTrue(m2.reads().contains(auto1));
+        assertTrue(m2.reads().contains(auto2));
+        assertTrue(m2.reads().contains(auto3));
+        assertTrue(m2.reads().contains(base));
+
+        assertTrue(auto1.reads().contains(m1));
+        assertTrue(auto1.reads().contains(m2));
+        assertTrue(auto1.reads().contains(auto2));
+        assertTrue(auto1.reads().contains(auto3));
+        assertTrue(auto1.reads().contains(base));
+
+        assertTrue(auto2.reads().contains(m1));
+        assertTrue(auto2.reads().contains(m2));
+        assertTrue(auto2.reads().contains(auto1));
+        assertTrue(auto2.reads().contains(auto3));
+        assertTrue(auto2.reads().contains(base));
+
+        assertTrue(auto3.reads().contains(m1));
+        assertTrue(auto3.reads().contains(m2));
+        assertTrue(auto3.reads().contains(auto1));
+        assertTrue(auto3.reads().contains(auto2));
+        assertTrue(auto3.reads().contains(base));
+    }
+
+
+    /**
+     * Basic test of automatic modules in a child configuration. All automatic
+     * modules that are found with the before finder should be resolved. The
+     * automatic modules that are found by the after finder and not shadowed
+     * by the before finder, or parent configurations, should also be resolved.
+     */
+    public void testInConfiguration6() throws IOException {
+        // m1 requires auto1
+        ModuleDescriptor descriptor1
+            = ModuleDescriptor.newModule("m1")
+                .requires("auto1")
+                .build();
+
+        Path dir = Files.createTempDirectory(USER_DIR, "mods");
+        createDummyJarFile(dir.resolve("auto1.jar"), "p1/C.class");
+
+        // module finder locates m1 and auto1
+        ModuleFinder finder1 = ModuleUtils.finderOf(descriptor1);
+        ModuleFinder finder2 =  ModuleFinder.of(dir);
+        ModuleFinder finder = ModuleFinder.compose(finder1, finder2);
+
+        Configuration parent = ModuleLayer.boot().configuration();
+        Configuration cf1 = resolve(parent, finder, "m1");
+
+        assertTrue(cf1.modules().size() == 2);
+        assertTrue(cf1.findModule("m1").isPresent());
+        assertTrue(cf1.findModule("auto1").isPresent());
+
+        ResolvedModule base = parent.findModule("java.base")
+                                    .orElseThrow(() -> new RuntimeException());
+        ResolvedModule m1 = cf1.findModule("m1").get();
+        ResolvedModule auto1 = cf1.findModule("auto1").get();
+
+        assertTrue(m1.reads().size() == 2);
+        assertTrue(m1.reads().contains(auto1));
+        assertTrue(m1.reads().contains(base));
+
+        assertTrue(auto1.reads().contains(m1));
+        assertTrue(auto1.reads().contains(base));
+
+
+        // create child configuration - the after finder locates auto1
+
+        dir = Files.createTempDirectory(USER_DIR, "mods");
+        createDummyJarFile(dir.resolve("auto2.jar"), "p2/C.class");
+        ModuleFinder beforeFinder =  ModuleFinder.of(dir);
+
+        dir = Files.createTempDirectory(USER_DIR, "mods");
+        createDummyJarFile(dir.resolve("auto1.jar"), "p1/C.class");
+        createDummyJarFile(dir.resolve("auto2.jar"), "p2/C.class");
+        createDummyJarFile(dir.resolve("auto3.jar"), "p3/C.class");
+        ModuleFinder afterFinder =  ModuleFinder.of(dir);
+
+        Configuration cf2 = cf1.resolve(beforeFinder, afterFinder, Set.of("auto2"));
+
+        // auto1 should be found in parent and should not be in cf2
+        assertTrue(cf2.modules().size() == 2);
+        assertTrue(cf2.findModule("auto2").isPresent());
+        assertTrue(cf2.findModule("auto3").isPresent());
+
+        ResolvedModule auto2 = cf2.findModule("auto2").get();
+        ResolvedModule auto3 = cf2.findModule("auto3").get();
+
+        assertTrue(auto2.reads().contains(m1));
+        assertTrue(auto2.reads().contains(auto1));
+        assertTrue(auto2.reads().contains(auto3));
+        assertTrue(auto2.reads().contains(base));
+
+        assertTrue(auto3.reads().contains(m1));
+        assertTrue(auto3.reads().contains(auto1));
+        assertTrue(auto3.reads().contains(auto2));
+        assertTrue(auto3.reads().contains(base));
+    }
+
+
+    /**
      * Basic test of a configuration created with automatic modules
      *   a requires b* and c*
      *   b* contains p
@@ -684,7 +867,7 @@
             = ModuleFinder.compose(ModuleUtils.finderOf(descriptor),
                                    ModuleFinder.of(dir));
 
-        Configuration parent = Layer.boot().configuration();
+        Configuration parent = ModuleLayer.boot().configuration();
         resolve(parent, finder, "a");
     }
 
@@ -711,13 +894,13 @@
             = ModuleFinder.compose(ModuleUtils.finderOf(descriptor),
                                    ModuleFinder.of(dir));
 
-        Configuration parent = Layer.boot().configuration();
+        Configuration parent = ModuleLayer.boot().configuration();
         resolve(parent, finder, "a");
     }
 
 
     /**
-     * Basic test of Layer containing automatic modules
+     * Basic test of layer containing automatic modules
      */
     public void testInLayer() throws IOException {
         ModuleDescriptor descriptor
@@ -736,12 +919,12 @@
             = ModuleFinder.compose(ModuleUtils.finderOf(descriptor),
                 ModuleFinder.of(dir));
 
-        Configuration parent = Layer.boot().configuration();
+        Configuration parent = ModuleLayer.boot().configuration();
         Configuration cf = resolve(parent, finder, "a");
         assertTrue(cf.modules().size() == 3);
 
         // each module gets its own loader
-        Layer layer = Layer.boot().defineModules(cf, mn -> new ClassLoader() { });
+        ModuleLayer layer = ModuleLayer.boot().defineModules(cf, mn -> new ClassLoader() { });
 
         // an unnamed module
         Module unnamed = (new ClassLoader() { }).getUnnamedModule();
@@ -804,7 +987,7 @@
      */
     static void testReadAllBootModules(Configuration cf, String mn) {
 
-        Set<String> bootModules = Layer.boot().modules().stream()
+        Set<String> bootModules = ModuleLayer.boot().modules().stream()
                 .map(Module::getName)
                 .collect(Collectors.toSet());
 
@@ -813,10 +996,10 @@
     }
 
     /**
-     * Test that the given Module reads all module in the given Layer
-     * and its parent Layers.
+     * Test that the given Module reads all module in the given layer
+     * and its parent layers.
      */
-    static void testsReadsAll(Module m, Layer layer) {
+    static void testsReadsAll(Module m, ModuleLayer layer) {
         // check that m reads all modules in the layer
         layer.configuration().modules().stream()
             .map(ResolvedModule::name)
--- a/jdk/test/java/lang/module/ConfigurationTest.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/jdk/test/java/lang/module/ConfigurationTest.java	Tue Apr 18 22:25:33 2017 +0200
@@ -40,7 +40,6 @@
 import java.lang.module.ModuleFinder;
 import java.lang.module.ResolutionException;
 import java.lang.module.ResolvedModule;
-import java.lang.reflect.Layer;
 import java.nio.file.Files;
 import java.nio.file.Path;
 import java.util.List;
@@ -1708,7 +1707,7 @@
 
         ModuleFinder finder = ModuleUtils.finderOf(descriptor);
 
-        Configuration bootConfiguration = Layer.boot().configuration();
+        Configuration bootConfiguration = ModuleLayer.boot().configuration();
 
         // m1 contains package java.lang, java.base exports package java.lang to m1
         resolve(bootConfiguration, finder, "m1");
@@ -1989,14 +1988,14 @@
 
     @Test(expectedExceptions = { NullPointerException.class })
     public void testResolveRequiresWithNull5() {
-        Configuration cf = Layer.boot().configuration();
+        Configuration cf = ModuleLayer.boot().configuration();
         Configuration.resolve(ModuleFinder.of(), List.of(cf), null, Set.of());
     }
 
     @Test(expectedExceptions = { NullPointerException.class })
     public void testResolveRequiresWithNull6() {
         ModuleFinder empty = ModuleFinder.of();
-        Configuration cf = Layer.boot().configuration();
+        Configuration cf = ModuleLayer.boot().configuration();
         Configuration.resolve(empty, List.of(cf), empty, null);
     }
 
@@ -2024,14 +2023,14 @@
 
     @Test(expectedExceptions = { NullPointerException.class })
     public void testResolveRequiresAndUsesWithNull5() {
-        Configuration cf = Layer.boot().configuration();
+        Configuration cf = ModuleLayer.boot().configuration();
         Configuration.resolveAndBind(ModuleFinder.of(), List.of(cf), null, Set.of());
     }
 
     @Test(expectedExceptions = { NullPointerException.class })
     public void testResolveRequiresAndUsesWithNull6() {
         ModuleFinder empty = ModuleFinder.of();
-        Configuration cf = Layer.boot().configuration();
+        Configuration cf = ModuleLayer.boot().configuration();
         Configuration.resolveAndBind(empty, List.of(cf), empty, null);
     }
 
@@ -2044,14 +2043,14 @@
 
     @Test(expectedExceptions = { UnsupportedOperationException.class })
     public void testImmutableSet1() {
-        Configuration cf = Layer.boot().configuration();
+        Configuration cf = ModuleLayer.boot().configuration();
         ResolvedModule base = cf.findModule("java.base").get();
         cf.modules().add(base);
     }
 
     @Test(expectedExceptions = { UnsupportedOperationException.class })
     public void testImmutableSet2() {
-        Configuration cf = Layer.boot().configuration();
+        Configuration cf = ModuleLayer.boot().configuration();
         ResolvedModule base = cf.findModule("java.base").get();
         base.reads().add(base);
     }
--- a/jdk/test/java/lang/module/ModuleDescriptorTest.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/jdk/test/java/lang/module/ModuleDescriptorTest.java	Tue Apr 18 22:25:33 2017 +0200
@@ -41,7 +41,6 @@
 import java.lang.module.ModuleDescriptor.Provides;
 import java.lang.module.ModuleDescriptor.Requires.Modifier;
 import java.lang.module.ModuleDescriptor.Version;
-import java.lang.reflect.Module;
 import java.nio.ByteBuffer;
 import java.util.ArrayList;
 import java.util.Collections;
--- a/jdk/test/java/lang/module/ModuleFinderTest.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/jdk/test/java/lang/module/ModuleFinderTest.java	Tue Apr 18 22:25:33 2017 +0200
@@ -529,6 +529,30 @@
 
 
     /**
+     * Test ModuleFinder.of with a directory containing hidden files
+     */
+    public void testOfWithHiddenFiles() throws Exception {
+        Path dir = Files.createTempDirectory(USER_DIR, "mods");
+        createExplodedModule(dir.resolve("m"), "m",
+                "com/.ignore",
+                "com/foo/.ignore",
+                "com/foo/foo.properties");
+
+        ModuleFinder finder = ModuleFinder.of(dir);
+        ModuleReference mref = finder.find("m").orElse(null);
+        assertNotNull(mref);
+
+        Set<String> expectedPackages;
+        if (System.getProperty("os.name").startsWith("Windows")) {
+            expectedPackages = Set.of("com", "com.foo");
+        } else {
+            expectedPackages = Set.of("com.foo");
+        }
+        assertEquals(mref.descriptor().packages(), expectedPackages);
+    }
+
+
+    /**
      * Test ModuleFinder.of with a truncated module-info.class
      */
     public void testOfWithTruncatedModuleInfo() throws Exception {
--- a/jdk/test/java/lang/module/ModuleReader/ModuleReaderTest.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/jdk/test/java/lang/module/ModuleReader/ModuleReaderTest.java	Tue Apr 18 22:25:33 2017 +0200
@@ -37,7 +37,6 @@
 import java.lang.module.ModuleFinder;
 import java.lang.module.ModuleReader;
 import java.lang.module.ModuleReference;
-import java.lang.reflect.Module;
 import java.net.URI;
 import java.net.URL;
 import java.net.URLConnection;
--- a/jdk/test/java/lang/reflect/AccessibleObject/ModuleSetAccessibleTest.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/jdk/test/java/lang/reflect/AccessibleObject/ModuleSetAccessibleTest.java	Tue Apr 18 22:25:33 2017 +0200
@@ -36,7 +36,6 @@
 import java.lang.reflect.InaccessibleObjectException;
 import java.lang.reflect.InvocationTargetException;
 import java.lang.reflect.Method;
-import java.lang.reflect.Module;
 
 import jdk.internal.misc.Unsafe;
 
--- a/jdk/test/java/lang/reflect/Layer/BasicLayerTest.java	Tue Apr 18 13:19:42 2017 -0400
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,1219 +0,0 @@
-/*
- * Copyright (c) 2014, 2017, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * 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
- * @library /lib/testlibrary
- * @modules java.base/jdk.internal.misc
- * @build BasicLayerTest ModuleUtils
- * @compile layertest/Test.java
- * @run testng BasicLayerTest
- * @summary Basic tests for java.lang.reflect.Layer
- */
-
-import java.lang.module.Configuration;
-import java.lang.module.ModuleDescriptor;
-import java.lang.module.ModuleDescriptor.Requires;
-import java.lang.module.ModuleFinder;
-import java.lang.reflect.Layer;
-import java.lang.reflect.LayerInstantiationException;
-import java.lang.reflect.Module;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Optional;
-import java.util.Set;
-import java.util.stream.Collectors;
-
-import jdk.internal.misc.SharedSecrets;
-
-import org.testng.annotations.DataProvider;
-import org.testng.annotations.Test;
-import static org.testng.Assert.*;
-
-@Test
-public class BasicLayerTest {
-
-    /**
-     * Creates a "non-strict" builder for building a module. This allows the
-     * test the create ModuleDescriptor objects that do not require java.base.
-     */
-    private static ModuleDescriptor.Builder newBuilder(String mn) {
-        return SharedSecrets.getJavaLangModuleAccess()
-                .newModuleBuilder(mn, false, Set.of());
-    }
-
-    /**
-     * Exercise Layer.empty()
-     */
-    public void testEmpty() {
-        Layer emptyLayer = Layer.empty();
-
-        assertTrue(emptyLayer.parents().isEmpty());
-
-        assertTrue(emptyLayer.configuration() == Configuration.empty());
-
-        assertTrue(emptyLayer.modules().isEmpty());
-
-        assertFalse(emptyLayer.findModule("java.base").isPresent());
-
-        try {
-            emptyLayer.findLoader("java.base");
-            assertTrue(false);
-        } catch (IllegalArgumentException expected) { }
-    }
-
-
-    /**
-     * Exercise Layer.boot()
-     */
-    public void testBoot() {
-        Layer bootLayer = Layer.boot();
-
-        // configuration
-        Configuration cf = bootLayer.configuration();
-        assertTrue(cf.findModule("java.base").get()
-                .reference()
-                .descriptor()
-                .exports()
-                .stream().anyMatch(e -> (e.source().equals("java.lang")
-                                         && !e.isQualified())));
-
-        // modules
-        Set<Module> modules = bootLayer.modules();
-        assertTrue(modules.contains(Object.class.getModule()));
-        int count = (int) modules.stream().map(Module::getName).count();
-        assertEquals(count, modules.size()); // module names are unique
-
-        // findModule
-        Module base = Object.class.getModule();
-        assertTrue(bootLayer.findModule("java.base").get() == base);
-        assertTrue(base.getLayer() == bootLayer);
-
-        // findLoader
-        assertTrue(bootLayer.findLoader("java.base") == null);
-
-        // parents
-        assertTrue(bootLayer.parents().size() == 1);
-        assertTrue(bootLayer.parents().get(0) == Layer.empty());
-    }
-
-
-    /**
-     * Exercise Layer defineModules, created with empty layer as parent
-     */
-    public void testLayerOnEmpty() {
-        ModuleDescriptor descriptor1 = newBuilder("m1")
-                .requires("m2")
-                .exports("p1")
-                .build();
-
-        ModuleDescriptor descriptor2 = newBuilder("m2")
-                .requires("m3")
-                .build();
-
-        ModuleDescriptor descriptor3 = newBuilder("m3")
-                .build();
-
-        ModuleFinder finder
-            = ModuleUtils.finderOf(descriptor1, descriptor2, descriptor3);
-
-        Configuration cf = resolve(finder, "m1");
-
-        // map each module to its own class loader for this test
-        ClassLoader loader1 = new ClassLoader() { };
-        ClassLoader loader2 = new ClassLoader() { };
-        ClassLoader loader3 = new ClassLoader() { };
-        Map<String, ClassLoader> map = new HashMap<>();
-        map.put("m1", loader1);
-        map.put("m2", loader2);
-        map.put("m3", loader3);
-
-        Layer layer = Layer.empty().defineModules(cf, map::get);
-
-        // configuration
-        assertTrue(layer.configuration() == cf);
-        assertTrue(layer.configuration().modules().size() == 3);
-
-        // modules
-        Set<Module> modules = layer.modules();
-        assertTrue(modules.size() == 3);
-        Set<String> names = modules.stream()
-            .map(Module::getName)
-            .collect(Collectors.toSet());
-        assertTrue(names.contains("m1"));
-        assertTrue(names.contains("m2"));
-        assertTrue(names.contains("m3"));
-
-        // findModule
-        Module m1 = layer.findModule("m1").get();
-        Module m2 = layer.findModule("m2").get();
-        Module m3 = layer.findModule("m3").get();
-        assertEquals(m1.getName(), "m1");
-        assertEquals(m2.getName(), "m2");
-        assertEquals(m3.getName(), "m3");
-        assertTrue(m1.getDescriptor() == descriptor1);
-        assertTrue(m2.getDescriptor() == descriptor2);
-        assertTrue(m3.getDescriptor() == descriptor3);
-        assertTrue(m1.getLayer() == layer);
-        assertTrue(m2.getLayer() == layer);
-        assertTrue(m3.getLayer() == layer);
-        assertTrue(modules.contains(m1));
-        assertTrue(modules.contains(m2));
-        assertTrue(modules.contains(m3));
-        assertFalse(layer.findModule("godot").isPresent());
-
-        // findLoader
-        assertTrue(layer.findLoader("m1") == loader1);
-        assertTrue(layer.findLoader("m2") == loader2);
-        assertTrue(layer.findLoader("m3") == loader3);
-        try {
-            ClassLoader loader = layer.findLoader("godot");
-            assertTrue(false);
-        } catch (IllegalArgumentException ignore) { }
-
-        // parents
-        assertTrue(layer.parents().size() == 1);
-        assertTrue(layer.parents().get(0) == Layer.empty());
-    }
-
-
-    /**
-     * Exercise Layer defineModules, created with boot layer as parent
-     */
-    public void testLayerOnBoot() {
-        ModuleDescriptor descriptor1 = newBuilder("m1")
-                .requires("m2")
-                .requires("java.base")
-                .exports("p1")
-                .build();
-
-        ModuleDescriptor descriptor2 = newBuilder("m2")
-                .requires("java.base")
-                .build();
-
-        ModuleFinder finder
-            = ModuleUtils.finderOf(descriptor1, descriptor2);
-
-        Configuration parent = Layer.boot().configuration();
-        Configuration cf = resolve(parent, finder, "m1");
-
-        ClassLoader loader = new ClassLoader() { };
-
-        Layer layer = Layer.boot().defineModules(cf, mn -> loader);
-
-        // configuration
-        assertTrue(layer.configuration() == cf);
-        assertTrue(layer.configuration().modules().size() == 2);
-
-        // modules
-        Set<Module> modules = layer.modules();
-        assertTrue(modules.size() == 2);
-        Set<String> names = modules.stream()
-            .map(Module::getName)
-            .collect(Collectors.toSet());
-        assertTrue(names.contains("m1"));
-        assertTrue(names.contains("m2"));
-
-        // findModule
-        Module m1 = layer.findModule("m1").get();
-        Module m2 = layer.findModule("m2").get();
-        assertEquals(m1.getName(), "m1");
-        assertEquals(m2.getName(), "m2");
-        assertTrue(m1.getDescriptor() == descriptor1);
-        assertTrue(m2.getDescriptor() == descriptor2);
-        assertTrue(m1.getLayer() == layer);
-        assertTrue(m2.getLayer() == layer);
-        assertTrue(modules.contains(m1));
-        assertTrue(modules.contains(m2));
-        assertTrue(layer.findModule("java.base").get() == Object.class.getModule());
-        assertFalse(layer.findModule("godot").isPresent());
-
-        // findLoader
-        assertTrue(layer.findLoader("m1") == loader);
-        assertTrue(layer.findLoader("m2") == loader);
-        assertTrue(layer.findLoader("java.base") == null);
-
-        // parents
-        assertTrue(layer.parents().size() == 1);
-        assertTrue(layer.parents().get(0) == Layer.boot());
-    }
-
-
-    /**
-     * Exercise Layer defineModules with a configuration of two modules that
-     * have the same module-private package.
-     */
-    public void testPackageContainedInSelfAndOther() {
-        ModuleDescriptor descriptor1 =  newBuilder("m1")
-                .requires("m2")
-                .packages(Set.of("p"))
-                .build();
-
-        ModuleDescriptor descriptor2 = newBuilder("m2")
-                .packages(Set.of("p"))
-                .build();
-
-        ModuleFinder finder
-            = ModuleUtils.finderOf(descriptor1, descriptor2);
-
-        Configuration cf = resolve(finder, "m1");
-        assertTrue(cf.modules().size() == 2);
-
-        // one loader per module, should be okay
-        Layer.empty().defineModules(cf, mn -> new ClassLoader() { });
-
-        // same class loader
-        try {
-            ClassLoader loader = new ClassLoader() { };
-            Layer.empty().defineModules(cf, mn -> loader);
-            assertTrue(false);
-        } catch (LayerInstantiationException expected) { }
-    }
-
-
-    /**
-     * Exercise Layer defineModules with a configuration that is a partitioned
-     * graph. The same package is exported in both partitions.
-     */
-    public void testSameExportInPartitionedGraph() {
-
-        // m1 reads m2, m2 exports p to m1
-        ModuleDescriptor descriptor1 =  newBuilder("m1")
-                .requires("m2")
-                .build();
-        ModuleDescriptor descriptor2 =  newBuilder("m2")
-                .exports("p", Set.of("m1"))
-                .build();
-
-        // m3 reads m4, m4 exports p to m3
-        ModuleDescriptor descriptor3 = newBuilder("m3")
-                .requires("m4")
-                .build();
-        ModuleDescriptor descriptor4 = newBuilder("m4")
-                .exports("p", Set.of("m3"))
-                .build();
-
-        ModuleFinder finder
-            = ModuleUtils.finderOf(descriptor1,
-                                   descriptor2,
-                                   descriptor3,
-                                   descriptor4);
-
-        Configuration cf = resolve(finder, "m1", "m3");
-        assertTrue(cf.modules().size() == 4);
-
-        // one loader per module
-        Layer.empty().defineModules(cf, mn -> new ClassLoader() { });
-
-        // m1 & m2 in one loader, m3 & m4 in another loader
-        ClassLoader loader1 = new ClassLoader() { };
-        ClassLoader loader2 = new ClassLoader() { };
-        Map<String, ClassLoader> map = new HashMap<>();
-        map.put("m1", loader1);
-        map.put("m2", loader1);
-        map.put("m3", loader2);
-        map.put("m4", loader2);
-        Layer.empty().defineModules(cf, map::get);
-
-        // same loader
-        try {
-            ClassLoader loader = new ClassLoader() { };
-            Layer.empty().defineModules(cf, mn -> loader);
-            assertTrue(false);
-        } catch (LayerInstantiationException expected) { }
-    }
-
-
-    /**
-     * Exercise Layer defineModules with a configuration with a module that
-     * contains a package that is the same name as a non-exported package in
-     * a parent layer.
-     */
-    public void testContainsSamePackageAsBootLayer() {
-
-        // check assumption that java.base contains sun.launcher
-        ModuleDescriptor base = Object.class.getModule().getDescriptor();
-        assertTrue(base.packages().contains("sun.launcher"));
-
-        ModuleDescriptor descriptor = newBuilder("m1")
-               .requires("java.base")
-               .packages(Set.of("sun.launcher"))
-               .build();
-
-        ModuleFinder finder = ModuleUtils.finderOf(descriptor);
-
-        Configuration parent = Layer.boot().configuration();
-        Configuration cf = parent.resolve(finder, ModuleFinder.of(), Set.of("m1"));
-        assertTrue(cf.modules().size() == 1);
-
-        ClassLoader loader = new ClassLoader() { };
-        Layer layer = Layer.boot().defineModules(cf, mn -> loader);
-        assertTrue(layer.modules().size() == 1);
-   }
-
-
-    /**
-     * Test layers with implied readability.
-     *
-     * The test consists of three configurations:
-     * - Configuration/layer1: m1, m2 requires transitive m1
-     * - Configuration/layer2: m3 requires m1
-     */
-    public void testImpliedReadabilityWithLayers1() {
-
-        // cf1: m1 and m2, m2 requires transitive m1
-
-        ModuleDescriptor descriptor1 = newBuilder("m1")
-                .build();
-
-        ModuleDescriptor descriptor2 = newBuilder("m2")
-                .requires(Set.of(Requires.Modifier.TRANSITIVE), "m1")
-                .build();
-
-        ModuleFinder finder1 = ModuleUtils.finderOf(descriptor1, descriptor2);
-
-        Configuration cf1 = resolve(finder1, "m2");
-
-        ClassLoader cl1 = new ClassLoader() { };
-        Layer layer1 = Layer.empty().defineModules(cf1, mn -> cl1);
-
-
-        // cf2: m3, m3 requires m2
-
-        ModuleDescriptor descriptor3 = newBuilder("m3")
-                .requires("m2")
-                .build();
-
-        ModuleFinder finder2 = ModuleUtils.finderOf(descriptor3);
-
-        Configuration cf2 = resolve(cf1, finder2, "m3");
-
-        ClassLoader cl2 = new ClassLoader() { };
-        Layer layer2 = layer1.defineModules(cf2, mn -> cl2);
-
-        assertTrue(layer1.parents().size() == 1);
-        assertTrue(layer1.parents().get(0) == Layer.empty());
-
-        assertTrue(layer2.parents().size() == 1);
-        assertTrue(layer2.parents().get(0) == layer1);
-
-        Module m1 = layer2.findModule("m1").get();
-        Module m2 = layer2.findModule("m2").get();
-        Module m3 = layer2.findModule("m3").get();
-
-        assertTrue(m1.getLayer() == layer1);
-        assertTrue(m2.getLayer() == layer1);
-        assertTrue(m3.getLayer() == layer2);
-
-        assertTrue(m1.getClassLoader() == cl1);
-        assertTrue(m2.getClassLoader() == cl1);
-        assertTrue(m3.getClassLoader() == cl2);
-
-        assertTrue(m1.canRead(m1));
-        assertFalse(m1.canRead(m2));
-        assertFalse(m1.canRead(m3));
-
-        assertTrue(m2.canRead(m1));
-        assertTrue(m2.canRead(m2));
-        assertFalse(m2.canRead(m3));
-
-        assertTrue(m3.canRead(m1));
-        assertTrue(m3.canRead(m2));
-        assertTrue(m3.canRead(m3));
-    }
-
-
-    /**
-     * Test layers with implied readability.
-     *
-     * The test consists of three configurations:
-     * - Configuration/layer1: m1
-     * - Configuration/layer2: m2 requires transitive m3, m3 requires m2
-     */
-    public void testImpliedReadabilityWithLayers2() {
-
-        // cf1: m1
-
-        ModuleDescriptor descriptor1 = newBuilder("m1").build();
-
-        ModuleFinder finder1 = ModuleUtils.finderOf(descriptor1);
-
-        Configuration cf1 = resolve(finder1, "m1");
-
-        ClassLoader cl1 = new ClassLoader() { };
-        Layer layer1 = Layer.empty().defineModules(cf1, mn -> cl1);
-
-
-        // cf2: m2, m3: m2 requires transitive m1, m3 requires m2
-
-        ModuleDescriptor descriptor2 = newBuilder("m2")
-                .requires(Set.of(Requires.Modifier.TRANSITIVE), "m1")
-                .build();
-
-        ModuleDescriptor descriptor3 = newBuilder("m3")
-                .requires("m2")
-                .build();
-
-        ModuleFinder finder2 = ModuleUtils.finderOf(descriptor2, descriptor3);
-
-        Configuration cf2 = resolve(cf1, finder2, "m3");
-
-        ClassLoader cl2 = new ClassLoader() { };
-        Layer layer2 = layer1.defineModules(cf2, mn -> cl2);
-
-        assertTrue(layer1.parents().size() == 1);
-        assertTrue(layer1.parents().get(0) == Layer.empty());
-
-        assertTrue(layer2.parents().size() == 1);
-        assertTrue(layer2.parents().get(0) == layer1);
-
-        Module m1 = layer2.findModule("m1").get();
-        Module m2 = layer2.findModule("m2").get();
-        Module m3 = layer2.findModule("m3").get();
-
-        assertTrue(m1.getLayer() == layer1);
-        assertTrue(m2.getLayer() == layer2);
-        assertTrue(m3.getLayer() == layer2);
-
-        assertTrue(m1.canRead(m1));
-        assertFalse(m1.canRead(m2));
-        assertFalse(m1.canRead(m3));
-
-        assertTrue(m2.canRead(m1));
-        assertTrue(m2.canRead(m2));
-        assertFalse(m2.canRead(m3));
-
-        assertTrue(m3.canRead(m1));
-        assertTrue(m3.canRead(m2));
-        assertTrue(m3.canRead(m3));
-    }
-
-
-    /**
-     * Test layers with implied readability.
-     *
-     * The test consists of three configurations:
-     * - Configuration/layer1: m1
-     * - Configuration/layer2: m2 requires transitive m1
-     * - Configuration/layer3: m3 requires m1
-     */
-    public void testImpliedReadabilityWithLayers3() {
-
-        // cf1: m1
-
-        ModuleDescriptor descriptor1 = newBuilder("m1").build();
-
-        ModuleFinder finder1 = ModuleUtils.finderOf(descriptor1);
-
-        Configuration cf1 = resolve(finder1, "m1");
-
-        ClassLoader cl1 = new ClassLoader() { };
-        Layer layer1 = Layer.empty().defineModules(cf1, mn -> cl1);
-
-
-        // cf2: m2 requires transitive m1
-
-        ModuleDescriptor descriptor2 = newBuilder("m2")
-                .requires(Set.of(Requires.Modifier.TRANSITIVE), "m1")
-                .build();
-
-        ModuleFinder finder2 = ModuleUtils.finderOf(descriptor2);
-
-        Configuration cf2 = resolve(cf1, finder2, "m2");
-
-        ClassLoader cl2 = new ClassLoader() { };
-        Layer layer2 = layer1.defineModules(cf2, mn -> cl2);
-
-
-        // cf3: m3 requires m2
-
-        ModuleDescriptor descriptor3 = newBuilder("m3")
-                .requires("m2")
-                .build();
-
-        ModuleFinder finder3 = ModuleUtils.finderOf(descriptor3);
-
-        Configuration cf3 = resolve(cf2, finder3, "m3");
-
-        ClassLoader cl3 = new ClassLoader() { };
-        Layer layer3 = layer2.defineModules(cf3, mn -> cl3);
-
-        assertTrue(layer1.parents().size() == 1);
-        assertTrue(layer1.parents().get(0) == Layer.empty());
-
-        assertTrue(layer2.parents().size() == 1);
-        assertTrue(layer2.parents().get(0) == layer1);
-
-        assertTrue(layer3.parents().size() == 1);
-        assertTrue(layer3.parents().get(0) == layer2);
-
-        Module m1 = layer3.findModule("m1").get();
-        Module m2 = layer3.findModule("m2").get();
-        Module m3 = layer3.findModule("m3").get();
-
-        assertTrue(m1.getLayer() == layer1);
-        assertTrue(m2.getLayer() == layer2);
-        assertTrue(m3.getLayer() == layer3);
-
-        assertTrue(m1.canRead(m1));
-        assertFalse(m1.canRead(m2));
-        assertFalse(m1.canRead(m3));
-
-        assertTrue(m2.canRead(m1));
-        assertTrue(m2.canRead(m2));
-        assertFalse(m2.canRead(m3));
-
-        assertTrue(m3.canRead(m1));
-        assertTrue(m3.canRead(m2));
-        assertTrue(m3.canRead(m3));
-    }
-
-
-    /**
-     * Test layers with implied readability.
-     *
-     * The test consists of two configurations:
-     * - Configuration/layer1: m1, m2 requires transitive m1
-     * - Configuration/layer2: m3 requires transitive m2, m4 requires m3
-     */
-    public void testImpliedReadabilityWithLayers4() {
-
-        // cf1: m1, m2 requires transitive m1
-
-        ModuleDescriptor descriptor1 = newBuilder("m1")
-                .build();
-
-        ModuleDescriptor descriptor2 = newBuilder("m2")
-                .requires(Set.of(Requires.Modifier.TRANSITIVE), "m1")
-                .build();
-
-        ModuleFinder finder1 = ModuleUtils.finderOf(descriptor1, descriptor2);
-
-        Configuration cf1 = resolve(finder1, "m2");
-
-        ClassLoader cl1 = new ClassLoader() { };
-        Layer layer1 = Layer.empty().defineModules(cf1, mn -> cl1);
-
-
-        // cf2: m3 requires transitive m2, m4 requires m3
-
-        ModuleDescriptor descriptor3 = newBuilder("m3")
-                .requires(Set.of(Requires.Modifier.TRANSITIVE), "m2")
-                .build();
-
-        ModuleDescriptor descriptor4 = newBuilder("m4")
-                .requires("m3")
-                .build();
-
-
-        ModuleFinder finder2 = ModuleUtils.finderOf(descriptor3, descriptor4);
-
-        Configuration cf2 = resolve(cf1, finder2, "m3", "m4");
-
-        ClassLoader cl2 = new ClassLoader() { };
-        Layer layer2 = layer1.defineModules(cf2, mn -> cl2);
-
-        assertTrue(layer1.parents().size() == 1);
-        assertTrue(layer1.parents().get(0) == Layer.empty());
-
-        assertTrue(layer2.parents().size() == 1);
-        assertTrue(layer2.parents().get(0) == layer1);
-
-        Module m1 = layer2.findModule("m1").get();
-        Module m2 = layer2.findModule("m2").get();
-        Module m3 = layer2.findModule("m3").get();
-        Module m4 = layer2.findModule("m4").get();
-
-        assertTrue(m1.getLayer() == layer1);
-        assertTrue(m2.getLayer() == layer1);
-        assertTrue(m3.getLayer() == layer2);
-        assertTrue(m4.getLayer() == layer2);
-
-        assertTrue(m1.canRead(m1));
-        assertFalse(m1.canRead(m2));
-        assertFalse(m1.canRead(m3));
-        assertFalse(m1.canRead(m4));
-
-        assertTrue(m2.canRead(m1));
-        assertTrue(m2.canRead(m2));
-        assertFalse(m1.canRead(m3));
-        assertFalse(m1.canRead(m4));
-
-        assertTrue(m3.canRead(m1));
-        assertTrue(m3.canRead(m2));
-        assertTrue(m3.canRead(m3));
-        assertFalse(m3.canRead(m4));
-
-        assertTrue(m4.canRead(m1));
-        assertTrue(m4.canRead(m2));
-        assertTrue(m4.canRead(m3));
-        assertTrue(m4.canRead(m4));
-    }
-
-
-    /**
-     * Test layers with a qualified export. The module exporting the package
-     * does not read the target module.
-     *
-     * m1 { exports p to m2 }
-     * m2 { }
-     */
-    public void testQualifiedExports1() {
-        ModuleDescriptor descriptor1 = newBuilder("m1").
-                exports("p", Set.of("m2"))
-                .build();
-
-        ModuleDescriptor descriptor2 = newBuilder("m2")
-                .build();
-
-        ModuleFinder finder1 = ModuleUtils.finderOf(descriptor1, descriptor2);
-
-        Configuration cf = resolve(finder1, "m1", "m2");
-
-        ClassLoader cl = new ClassLoader() { };
-        Layer layer = Layer.empty().defineModules(cf, mn -> cl);
-        assertTrue(layer.modules().size() == 2);
-
-        Module m1 = layer.findModule("m1").get();
-        Module m2 = layer.findModule("m2").get();
-
-        // check m1 exports p to m2
-        assertFalse(m1.isExported("p"));
-        assertTrue(m1.isExported("p", m2));
-        assertFalse(m1.isOpen("p", m2));
-    }
-
-
-    /**
-     * Test layers with a qualified export. The module exporting the package
-     * reads the target module.
-     *
-     * m1 { exports p to m2; }
-     * m2 { requires m1; }
-     */
-    public void testQualifiedExports2() {
-        ModuleDescriptor descriptor1 = newBuilder("m1")
-                .exports("p", Set.of("m2"))
-                .build();
-
-        ModuleDescriptor descriptor2 = newBuilder("m2")
-                .requires("m1")
-                .build();
-
-        ModuleFinder finder1 = ModuleUtils.finderOf(descriptor1, descriptor2);
-
-        Configuration cf = resolve(finder1, "m2");
-        ClassLoader cl = new ClassLoader() { };
-        Layer layer = Layer.empty().defineModules(cf, mn -> cl);
-        assertTrue(layer.modules().size() == 2);
-
-        Module m1 = layer.findModule("m1").get();
-        Module m2 = layer.findModule("m2").get();
-
-        // check m1 exports p to m2
-        assertFalse(m1.isExported("p"));
-        assertTrue(m1.isExported("p", m2));
-        assertFalse(m1.isOpen("p", m2));
-    }
-
-
-    /**
-     * Test layers with a qualified export. The module exporting the package
-     * does not read the target module in the parent layer.
-     *
-     * - Configuration/layer1: m1 { }
-     * - Configuration/layer2: m2 { exports p to m1; }
-     */
-    public void testQualifiedExports3() {
-        // create layer1 with m1
-        ModuleDescriptor descriptor1 = newBuilder("m1").build();
-        ModuleFinder finder1 = ModuleUtils.finderOf(descriptor1);
-        Configuration cf1 = resolve(finder1, "m1");
-        ClassLoader cl1 = new ClassLoader() { };
-        Layer layer1 = Layer.empty().defineModules(cf1, mn -> cl1);
-        assertTrue(layer1.modules().size() == 1);
-
-        // create layer2 with m2
-        ModuleDescriptor descriptor2 = newBuilder("m2")
-                .exports("p", Set.of("m1"))
-                .build();
-        ModuleFinder finder2 = ModuleUtils.finderOf(descriptor2);
-        Configuration cf2 = resolve(cf1, finder2, "m2");
-        ClassLoader cl2 = new ClassLoader() { };
-        Layer layer2 = layer1.defineModules(cf2, mn -> cl2);
-        assertTrue(layer2.modules().size() == 1);
-
-        Module m1 = layer1.findModule("m1").get();
-        Module m2 = layer2.findModule("m2").get();
-
-        // check m2 exports p to layer1/m1
-        assertFalse(m2.isExported("p"));
-        assertTrue(m2.isExported("p", m1));
-        assertFalse(m2.isOpen("p", m1));
-    }
-
-
-    /**
-     * Test layers with a qualified export. The module exporting the package
-     * reads the target module in the parent layer.
-     *
-     * - Configuration/layer1: m1 { }
-     * - Configuration/layer2: m2 { requires m1; exports p to m1; }
-     */
-    public void testQualifiedExports4() {
-        // create layer1 with m1
-        ModuleDescriptor descriptor1 = newBuilder("m1").build();
-        ModuleFinder finder1 = ModuleUtils.finderOf(descriptor1);
-        Configuration cf1 = resolve(finder1, "m1");
-        ClassLoader cl1 = new ClassLoader() { };
-        Layer layer1 = Layer.empty().defineModules(cf1, mn -> cl1);
-        assertTrue(layer1.modules().size() == 1);
-
-        // create layer2 with m2
-        ModuleDescriptor descriptor2 = newBuilder("m2")
-                .requires("m1")
-                .exports("p", Set.of("m1"))
-                .build();
-        ModuleFinder finder2 = ModuleUtils.finderOf(descriptor2);
-        Configuration cf2 = resolve(cf1, finder2, "m2");
-        ClassLoader cl2 = new ClassLoader() { };
-        Layer layer2 = layer1.defineModules(cf2, mn -> cl2);
-        assertTrue(layer2.modules().size() == 1);
-
-        Module m1 = layer1.findModule("m1").get();
-        Module m2 = layer2.findModule("m2").get();
-
-        // check m2 exports p to layer1/m1
-        assertFalse(m2.isExported("p"));
-        assertTrue(m2.isExported("p", m1));
-        assertFalse(m2.isOpen("p", m1));
-    }
-
-    /**
-     * Test layers with a qualified export. The module exporting the package
-     * does not read the target module.
-     *
-     * - Configuration/layer1: m1
-     * - Configuration/layer2: m1, m2 { exports p to m1; }
-     */
-    public void testQualifiedExports5() {
-        // create layer1 with m1
-        ModuleDescriptor descriptor1 = newBuilder("m1").build();
-        ModuleFinder finder1 = ModuleUtils.finderOf(descriptor1);
-        Configuration cf1 = resolve(finder1, "m1");
-        ClassLoader cl1 = new ClassLoader() { };
-        Layer layer1 = Layer.empty().defineModules(cf1, mn -> cl1);
-        assertTrue(layer1.modules().size() == 1);
-
-        // create layer2 with m1 and m2
-        ModuleDescriptor descriptor2 = newBuilder("m2").exports("p", Set.of("m1")).build();
-        ModuleFinder finder2 = ModuleUtils.finderOf(descriptor1, descriptor2);
-        Configuration cf2 = resolve(cf1, finder2, "m1", "m2");
-        ClassLoader cl2 = new ClassLoader() { };
-        Layer layer2 = layer1.defineModules(cf2, mn -> cl2);
-        assertTrue(layer2.modules().size() == 2);
-
-        Module m1_v1 = layer1.findModule("m1").get();
-        Module m1_v2 = layer2.findModule("m1").get();
-        Module m2 = layer2.findModule("m2").get();
-
-        // check m2 exports p to layer2/m2
-        assertFalse(m2.isExported("p"));
-        assertTrue(m2.isExported("p", m1_v2));
-        assertFalse(m2.isExported("p", m1_v1));
-    }
-
-
-    /**
-     * Test layers with a qualified export. The module exporting the package
-     * reads the target module in the parent layer (due to requires transitive).
-     *
-     * - Configuration/layer1: m1, m2 { requires transitive m1; }
-     * - Configuration/layer2: m1, m3 { requires m2; exports p to m1; }
-     */
-    public void testQualifiedExports6() {
-        // create layer1 with m1 and m2
-        ModuleDescriptor descriptor1 = newBuilder("m1").build();
-        ModuleDescriptor descriptor2 = newBuilder("m2")
-                .requires(Set.of(Requires.Modifier.TRANSITIVE), "m1")
-                .build();
-        ModuleFinder finder1 = ModuleUtils.finderOf(descriptor1, descriptor2);
-        Configuration cf1 = resolve(finder1, "m2");
-        ClassLoader loader1 = new ClassLoader() { };
-        Layer layer1 = Layer.empty().defineModules(cf1, mn -> loader1);
-        assertTrue(layer1.modules().size() == 2);
-
-        // create layer2 with m1 and m3
-        ModuleDescriptor descriptor3 = newBuilder("m3")
-                .requires("m2")
-                .exports("p", Set.of("m1"))
-                .build();
-        ModuleFinder finder2 = ModuleUtils.finderOf(descriptor1, descriptor3);
-        Configuration cf2 = resolve(cf1, finder2, "m1", "m3");
-        ClassLoader loader2 = new ClassLoader() { };
-        Layer layer2 = layer1.defineModules(cf2, mn -> loader2);
-        assertTrue(layer2.modules().size() == 2);
-
-        Module m1_v1 = layer1.findModule("m1").get();
-        Module m2 = layer1.findModule("m2").get();
-
-        Module m1_v2 = layer2.findModule("m1").get();
-        Module m3 = layer2.findModule("m3").get();
-
-        assertTrue(m3.canRead(m1_v1));
-        assertFalse(m3.canRead(m1_v2));
-
-        assertFalse(m3.isExported("p"));
-        assertTrue(m3.isExported("p", m1_v1));
-        assertFalse(m3.isExported("p", m1_v2));
-        assertFalse(m3.isExported("p", m2));
-    }
-
-
-    /**
-     * Test layers with a qualified export. The target module is not in any layer.
-     *
-     * - Configuration/layer1: m1 { }
-     * - Configuration/layer2: m2 { exports p to m3; }
-     */
-    public void testQualifiedExports7() {
-        // create layer1 with m1
-        ModuleDescriptor descriptor1 = newBuilder("m1").build();
-        ModuleFinder finder1 = ModuleUtils.finderOf(descriptor1);
-        Configuration cf1 = resolve(finder1, "m1");
-        ClassLoader cl1 = new ClassLoader() { };
-        Layer layer1 = Layer.empty().defineModules(cf1, mn -> cl1);
-        assertTrue(layer1.modules().size() == 1);
-
-        // create layer2 with m2
-        ModuleDescriptor descriptor2 = newBuilder("m2")
-                .exports("p", Set.of("m3"))
-                .build();
-        ModuleFinder finder2 = ModuleUtils.finderOf(descriptor2);
-        Configuration cf2 = resolve(cf1, finder2, "m2");
-        ClassLoader cl2 = new ClassLoader() { };
-        Layer layer2 = layer1.defineModules(cf2, mn -> cl2);
-        assertTrue(layer2.modules().size() == 1);
-
-        Module m1 = layer1.findModule("m1").get();
-        Module m2 = layer2.findModule("m2").get();
-
-        // check m2 does not export p to anyone
-        assertFalse(m2.isExported("p"));
-        assertFalse(m2.isExported("p", m1));
-    }
-
-    /**
-     * Attempt to use Layer defineModules to create a layer with a module
-     * defined to a class loader that already has a module of the same name
-     * defined to the class loader.
-     */
-    @Test(expectedExceptions = { LayerInstantiationException.class })
-    public void testModuleAlreadyDefinedToLoader() {
-
-        ModuleDescriptor md = newBuilder("m")
-                .requires("java.base")
-                .build();
-
-        ModuleFinder finder = ModuleUtils.finderOf(md);
-
-        Configuration parent = Layer.boot().configuration();
-
-        Configuration cf = parent.resolve(finder, ModuleFinder.of(), Set.of("m"));
-
-        ClassLoader loader = new ClassLoader() { };
-
-        Layer.boot().defineModules(cf, mn -> loader);
-
-        // should throw LayerInstantiationException as m1 already defined to loader
-        Layer.boot().defineModules(cf, mn -> loader);
-
-    }
-
-
-    /**
-     * Attempt to use Layer defineModules to create a Layer with a module
-     * containing package {@code p} where the class loader already has a module
-     * defined to it containing package {@code p}.
-     */
-    @Test(expectedExceptions = { LayerInstantiationException.class })
-    public void testPackageAlreadyInNamedModule() {
-
-        ModuleDescriptor md1 = newBuilder("m1")
-                .packages(Set.of("p"))
-                .requires("java.base")
-                .build();
-
-        ModuleDescriptor md2 = newBuilder("m2")
-                .packages(Set.of("p"))
-                .requires("java.base")
-                .build();
-
-        ModuleFinder finder = ModuleUtils.finderOf(md1, md2);
-
-        ClassLoader loader = new ClassLoader() { };
-
-        // define m1 containing package p to class loader
-
-        Configuration parent = Layer.boot().configuration();
-
-        Configuration cf1 = parent.resolve(finder, ModuleFinder.of(), Set.of("m1"));
-
-        Layer layer1 = Layer.boot().defineModules(cf1, mn -> loader);
-
-        // attempt to define m2 containing package p to class loader
-
-        Configuration cf2 = parent.resolve(finder, ModuleFinder.of(), Set.of("m2"));
-
-        // should throw exception because p already in m1
-        Layer layer2 = Layer.boot().defineModules(cf2, mn -> loader);
-
-    }
-
-
-    /**
-     * Attempt to use Layer defineModules to create a Layer with a module
-     * containing a package in which a type is already loaded by the class
-     * loader.
-     */
-    @Test(expectedExceptions = { LayerInstantiationException.class })
-    public void testPackageAlreadyInUnnamedModule() throws Exception {
-
-        Class<?> c = layertest.Test.class;
-        assertFalse(c.getModule().isNamed());  // in unnamed module
-
-        ModuleDescriptor md = newBuilder("m")
-                .packages(Set.of(c.getPackageName()))
-                .requires("java.base")
-                .build();
-
-        ModuleFinder finder = ModuleUtils.finderOf(md);
-
-        Configuration parent = Layer.boot().configuration();
-        Configuration cf = parent.resolve(finder, ModuleFinder.of(), Set.of("m"));
-
-        Layer.boot().defineModules(cf, mn -> c.getClassLoader());
-    }
-
-
-    /**
-     * Attempt to create a Layer with a module named "java.base".
-     */
-    public void testLayerWithJavaBase() {
-        ModuleDescriptor descriptor = newBuilder("java.base")
-                .exports("java.lang")
-                .build();
-
-        ModuleFinder finder = ModuleUtils.finderOf(descriptor);
-
-        Configuration cf = Layer.boot()
-            .configuration()
-            .resolve(finder, ModuleFinder.of(), Set.of("java.base"));
-        assertTrue(cf.modules().size() == 1);
-
-        ClassLoader scl = ClassLoader.getSystemClassLoader();
-
-        try {
-            Layer.boot().defineModules(cf, mn -> new ClassLoader() { });
-            assertTrue(false);
-        } catch (LayerInstantiationException e) { }
-
-        try {
-            Layer.boot().defineModulesWithOneLoader(cf, scl);
-            assertTrue(false);
-        } catch (LayerInstantiationException e) { }
-
-        try {
-            Layer.boot().defineModulesWithManyLoaders(cf, scl);
-            assertTrue(false);
-        } catch (LayerInstantiationException e) { }
-    }
-
-
-    @DataProvider(name = "javaPackages")
-    public Object[][] javaPackages() {
-        return new Object[][] { { "m1", "java" }, { "m2", "java.x" } };
-    }
-
-    /**
-     * Attempt to create a Layer with a module containing a "java" package.
-     * This should only be allowed when the module is defined to the platform
-     * class loader.
-     */
-    @Test(dataProvider = "javaPackages")
-    public void testLayerWithJavaPackage(String mn, String pn) {
-        ModuleDescriptor descriptor = newBuilder(mn).packages(Set.of(pn)).build();
-        ModuleFinder finder = ModuleUtils.finderOf(descriptor);
-
-        Configuration cf = Layer.boot()
-                .configuration()
-                .resolve(finder, ModuleFinder.of(), Set.of(mn));
-        assertTrue(cf.modules().size() == 1);
-
-        ClassLoader pcl = ClassLoader.getPlatformClassLoader();
-        ClassLoader scl = ClassLoader.getSystemClassLoader();
-
-        try {
-            Layer.boot().defineModules(cf, _mn -> new ClassLoader() { });
-            assertTrue(false);
-        } catch (LayerInstantiationException e) { }
-
-        try {
-            Layer.boot().defineModulesWithOneLoader(cf, scl);
-            assertTrue(false);
-        } catch (LayerInstantiationException e) { }
-
-        try {
-            Layer.boot().defineModulesWithManyLoaders(cf, scl);
-            assertTrue(false);
-        } catch (LayerInstantiationException e) { }
-
-        // create layer with module defined to platform class loader
-        Layer layer = Layer.boot().defineModules(cf, _mn -> pcl);
-        Optional<Module> om = layer.findModule(mn);
-        assertTrue(om.isPresent());
-        Module foo = om.get();
-        assertTrue(foo.getClassLoader() == pcl);
-        assertTrue(foo.getPackages().length == 1);
-        assertTrue(foo.getPackages()[0].equals(pn));
-    }
-
-
-    /**
-     * Attempt to create a Layer with a module defined to the boot loader
-     */
-    @Test(expectedExceptions = { LayerInstantiationException.class })
-    public void testLayerWithBootLoader() {
-        ModuleDescriptor descriptor = newBuilder("m1")
-                .build();
-
-        ModuleFinder finder = ModuleUtils.finderOf(descriptor);
-
-        Configuration cf = Layer.boot()
-            .configuration()
-            .resolve(finder, ModuleFinder.of(), Set.of("m1"));
-        assertTrue(cf.modules().size() == 1);
-
-        Layer.boot().defineModules(cf, mn -> null );
-    }
-
-
-    /**
-     * Parent of configuration != configuration of parent Layer
-     */
-    @Test(expectedExceptions = { IllegalArgumentException.class })
-    public void testIncorrectParent1() {
-
-        ModuleDescriptor descriptor1 = newBuilder("m1")
-                .requires("java.base")
-                .build();
-
-        ModuleFinder finder = ModuleUtils.finderOf(descriptor1);
-
-        Configuration parent = Layer.boot().configuration();
-        Configuration cf = parent.resolve(finder, ModuleFinder.of(), Set.of("m1"));
-
-        ClassLoader loader = new ClassLoader() { };
-        Layer.empty().defineModules(cf, mn -> loader);
-    }
-
-
-    /**
-     * Parent of configuration != configuration of parent Layer
-     */
-    @Test(expectedExceptions = { IllegalArgumentException.class })
-    public void testIncorrectParent2() {
-
-        ModuleDescriptor descriptor1 = newBuilder("m1")
-                .build();
-
-        ModuleFinder finder = ModuleUtils.finderOf(descriptor1);
-
-        Configuration cf = resolve(finder, "m1");
-
-        ClassLoader loader = new ClassLoader() { };
-        Layer.boot().defineModules(cf, mn -> loader);
-    }
-
-
-    // null handling
-
-    @Test(expectedExceptions = { NullPointerException.class })
-    public void testCreateWithNull1() {
-        ClassLoader loader = new ClassLoader() { };
-        Layer.empty().defineModules(null, mn -> loader);
-    }
-
-    @Test(expectedExceptions = { NullPointerException.class })
-    public void testCreateWithNull2() {
-        Configuration cf = resolve(Layer.boot().configuration(), ModuleFinder.of());
-        Layer.boot().defineModules(cf, null);
-    }
-
-    @Test(expectedExceptions = { NullPointerException.class })
-    public void testCreateWithNull3() {
-        ClassLoader scl = ClassLoader.getSystemClassLoader();
-        Layer.empty().defineModulesWithOneLoader(null, scl);
-    }
-
-    @Test(expectedExceptions = { NullPointerException.class })
-    public void testCreateWithNull4() {
-        ClassLoader scl = ClassLoader.getSystemClassLoader();
-        Layer.empty().defineModulesWithManyLoaders(null, scl);
-    }
-
-    @Test(expectedExceptions = { NullPointerException.class })
-    public void testFindModuleWithNull() {
-        Layer.boot().findModule(null);
-    }
-
-    @Test(expectedExceptions = { NullPointerException.class })
-    public void testFindLoaderWithNull() {
-        Layer.boot().findLoader(null);
-    }
-
-
-    // immutable sets
-
-    @Test(expectedExceptions = { UnsupportedOperationException.class })
-    public void testImmutableSet() {
-        Module base = Object.class.getModule();
-        Layer.boot().modules().add(base);
-    }
-
-
-    /**
-     * Resolve the given modules, by name, and returns the resulting
-     * Configuration.
-     */
-    private static Configuration resolve(Configuration cf,
-                                         ModuleFinder finder,
-                                         String... roots) {
-        return cf.resolve(finder, ModuleFinder.of(), Set.of(roots));
-    }
-
-    private static Configuration resolve(ModuleFinder finder,
-                                         String... roots) {
-        return resolve(Configuration.empty(), finder, roots);
-    }
-}
--- a/jdk/test/java/lang/reflect/Layer/LayerAndLoadersTest.java	Tue Apr 18 13:19:42 2017 -0400
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,724 +0,0 @@
-/*
- * 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
- * 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
- * @library /lib/testlibrary
- * @modules jdk.compiler
- * @build LayerAndLoadersTest CompilerUtils ModuleUtils
- * @run testng LayerAndLoadersTest
- * @summary Tests for java.lang.reflect.Layer@createWithXXX methods
- */
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.lang.module.Configuration;
-import java.lang.module.ModuleDescriptor;
-import java.lang.module.ModuleFinder;
-import java.lang.module.ModuleReference;
-import java.lang.reflect.Layer;
-import java.lang.reflect.LayerInstantiationException;
-import java.lang.reflect.Method;
-import java.lang.reflect.Module;
-import java.net.URL;
-import java.nio.file.Path;
-import java.nio.file.Paths;
-import java.util.Enumeration;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.Map;
-import java.util.Optional;
-import java.util.ServiceLoader;
-import java.util.Set;
-import java.util.stream.Collectors;
-
-import org.testng.annotations.BeforeTest;
-import org.testng.annotations.Test;
-import static org.testng.Assert.*;
-
-@Test
-public class LayerAndLoadersTest {
-
-    private static final String TEST_SRC = System.getProperty("test.src");
-
-    private static final Path SRC_DIR = Paths.get(TEST_SRC, "src");
-    private static final Path MODS_DIR = Paths.get("mods");
-
-    @BeforeTest
-    public void setup() throws Exception {
-
-        // javac -d mods --module-source-path src src/**
-        assertTrue(CompilerUtils.compile(SRC_DIR, MODS_DIR,
-                "--module-source-path", SRC_DIR.toString()));
-    }
-
-
-    /**
-     * Basic test of Layer defineModulesWithOneLoader
-     *
-     * Test scenario:
-     *   m1 requires m2 and m3
-     */
-    public void testWithOneLoader() throws Exception {
-
-        Configuration cf = resolve("m1");
-
-        ClassLoader scl = ClassLoader.getSystemClassLoader();
-
-        Layer layer = Layer.boot().defineModulesWithOneLoader(cf, scl);
-
-        checkLayer(layer, "m1", "m2", "m3");
-
-        ClassLoader cl1 = layer.findLoader("m1");
-        ClassLoader cl2 = layer.findLoader("m2");
-        ClassLoader cl3 = layer.findLoader("m3");
-
-        assertTrue(cl1.getParent() == scl);
-        assertTrue(cl2 == cl1);
-        assertTrue(cl3 == cl1);
-
-        invoke(layer, "m1", "p.Main");
-
-    }
-
-
-    /**
-     * Basic test of Layer defineModulesWithManyLoaders
-     *
-     * Test scenario:
-     *   m1 requires m2 and m3
-     */
-    public void testWithManyLoaders() throws Exception {
-
-        Configuration cf = resolve("m1");
-
-        ClassLoader scl = ClassLoader.getSystemClassLoader();
-
-        Layer layer = Layer.boot().defineModulesWithManyLoaders(cf, scl);
-
-        checkLayer(layer, "m1", "m2", "m3");
-
-        ClassLoader cl1 = layer.findLoader("m1");
-        ClassLoader cl2 = layer.findLoader("m2");
-        ClassLoader cl3 = layer.findLoader("m3");
-
-        assertTrue(cl1.getParent() == scl);
-        assertTrue(cl2.getParent() == scl);
-        assertTrue(cl3.getParent() == scl);
-        assertTrue(cl2 != cl1);
-        assertTrue(cl3 != cl1);
-        assertTrue(cl3 != cl2);
-
-        invoke(layer, "m1", "p.Main");
-
-    }
-
-
-    /**
-     * Basic test of Layer defineModulesWithOneLoader where one of the modules
-     * is a service provider module.
-     *
-     * Test scenario:
-     *    m1 requires m2 and m3
-     *    m1 uses S
-     *    m4 provides S with ...
-     */
-    public void testServicesWithOneLoader() throws Exception {
-
-        Configuration cf = resolveAndBind("m1");
-
-        ClassLoader scl = ClassLoader.getSystemClassLoader();
-
-        Layer layer = Layer.boot().defineModulesWithOneLoader(cf, scl);
-
-        checkLayer(layer, "m1", "m2", "m3", "m4");
-
-        ClassLoader cl1 = layer.findLoader("m1");
-        ClassLoader cl2 = layer.findLoader("m2");
-        ClassLoader cl3 = layer.findLoader("m3");
-        ClassLoader cl4 = layer.findLoader("m4");
-
-        assertTrue(cl1.getParent() == scl);
-        assertTrue(cl2 == cl1);
-        assertTrue(cl3 == cl1);
-        assertTrue(cl4 == cl1);
-
-        Class<?> serviceType = cl1.loadClass("p.Service");
-        assertTrue(serviceType.getClassLoader() == cl1);
-
-        Iterator<?> iter = ServiceLoader.load(serviceType, cl1).iterator();
-        Object provider = iter.next();
-        assertTrue(serviceType.isInstance(provider));
-        assertTrue(provider.getClass().getClassLoader() == cl1);
-        assertFalse(iter.hasNext());
-
-    }
-
-
-    /**
-     * Basic test of Layer defineModulesWithManyLoaders where one of the
-     * modules is a service provider module.
-     *
-     * Test scenario:
-     *    m1 requires m2 and m3
-     *    m1 uses S
-     *    m4 provides S with ...
-     */
-    public void testServicesWithManyLoaders() throws Exception {
-
-        Configuration cf = resolveAndBind("m1");
-
-        ClassLoader scl = ClassLoader.getSystemClassLoader();
-
-        Layer layer = Layer.boot().defineModulesWithManyLoaders(cf, scl);
-
-        checkLayer(layer, "m1", "m2", "m3", "m4");
-
-        ClassLoader cl1 = layer.findLoader("m1");
-        ClassLoader cl2 = layer.findLoader("m2");
-        ClassLoader cl3 = layer.findLoader("m3");
-        ClassLoader cl4 = layer.findLoader("m4");
-
-        assertTrue(cl1.getParent() == scl);
-        assertTrue(cl2.getParent() == scl);
-        assertTrue(cl3.getParent() == scl);
-        assertTrue(cl4.getParent() == scl);
-        assertTrue(cl2 != cl1);
-        assertTrue(cl3 != cl1);
-        assertTrue(cl3 != cl2);
-        assertTrue(cl4 != cl1);
-        assertTrue(cl4 != cl2);
-        assertTrue(cl4 != cl3);
-
-        Class<?> serviceType = cl1.loadClass("p.Service");
-        assertTrue(serviceType.getClassLoader() == cl1);
-
-        // Test that the service provider can be located via any of
-        // the class loaders in the layer
-        for (Module m : layer.modules()) {
-            ClassLoader loader = m.getClassLoader();
-            Iterator<?> iter = ServiceLoader.load(serviceType, loader).iterator();
-            Object provider = iter.next();
-            assertTrue(serviceType.isInstance(provider));
-            assertTrue(provider.getClass().getClassLoader() == cl4);
-            assertFalse(iter.hasNext());
-        }
-
-    }
-
-
-    /**
-     * Tests that the class loaders created by defineModulesWithXXX delegate
-     * to the given parent class loader.
-     */
-    public void testDelegationToParent() throws Exception {
-
-        Configuration cf = resolve("m1");
-
-        ClassLoader parent = this.getClass().getClassLoader();
-        String cn = this.getClass().getName();
-
-        // one loader
-        Layer layer = Layer.boot().defineModulesWithOneLoader(cf, parent);
-        testLoad(layer, cn);
-
-         // one loader with boot loader as parent
-        layer = Layer.boot().defineModulesWithOneLoader(cf, null);
-        testLoadFail(layer, cn);
-
-        // many loaders
-        layer = Layer.boot().defineModulesWithManyLoaders(cf, parent);
-        testLoad(layer, cn);
-
-        // many loader with boot loader as parent
-        layer = Layer.boot().defineModulesWithManyLoaders(cf, null);
-        testLoadFail(layer, cn);
-
-    }
-
-
-    /**
-     * Test defineModulesWithXXX when modules that have overlapping packages.
-     *
-     * Test scenario:
-     *   m1 exports p
-     *   m2 exports p
-     */
-    public void testOverlappingPackages() {
-
-        ModuleDescriptor descriptor1
-            = ModuleDescriptor.newModule("m1").exports("p").build();
-
-        ModuleDescriptor descriptor2
-            = ModuleDescriptor.newModule("m2").exports("p").build();
-
-        ModuleFinder finder = ModuleUtils.finderOf(descriptor1, descriptor2);
-
-        Configuration cf = Layer.boot()
-            .configuration()
-            .resolve(finder, ModuleFinder.of(), Set.of("m1", "m2"));
-
-        // cannot define both module m1 and m2 to the same class loader
-        try {
-            Layer.boot().defineModulesWithOneLoader(cf, null);
-            assertTrue(false);
-        } catch (LayerInstantiationException expected) { }
-
-        // should be okay to have one module per class loader
-        Layer layer = Layer.boot().defineModulesWithManyLoaders(cf, null);
-        checkLayer(layer, "m1", "m2");
-
-    }
-
-
-    /**
-     * Test Layer defineModulesWithXXX with split delegation.
-     *
-     * Test scenario:
-     *   layer1: m1 exports p, m2 exports p
-     *   layer2: m3 reads m1, m4 reads m2
-     */
-    public void testSplitDelegation() {
-
-        ModuleDescriptor descriptor1
-            = ModuleDescriptor.newModule("m1").exports("p").build();
-
-        ModuleDescriptor descriptor2
-            = ModuleDescriptor.newModule("m2").exports("p").build();
-
-        ModuleFinder finder1 = ModuleUtils.finderOf(descriptor1, descriptor2);
-
-        Configuration cf1 = Layer.boot()
-            .configuration()
-            .resolve(finder1, ModuleFinder.of(), Set.of("m1", "m2"));
-
-        Layer layer1 = Layer.boot().defineModulesWithManyLoaders(cf1, null);
-        checkLayer(layer1, "m1", "m2");
-
-        ModuleDescriptor descriptor3
-            = ModuleDescriptor.newModule("m3").requires("m1").build();
-
-        ModuleDescriptor descriptor4
-            = ModuleDescriptor.newModule("m4").requires("m2").build();
-
-        ModuleFinder finder2 = ModuleUtils.finderOf(descriptor3, descriptor4);
-
-        Configuration cf2 = cf1.resolve(finder2, ModuleFinder.of(),
-                                                Set.of("m3", "m4"));
-
-        // package p cannot be supplied by two class loaders
-        try {
-            layer1.defineModulesWithOneLoader(cf2, null);
-            assertTrue(false);
-        } catch (LayerInstantiationException expected) { }
-
-        // no split delegation when modules have their own class loader
-        Layer layer2 = layer1.defineModulesWithManyLoaders(cf2, null);
-        checkLayer(layer2, "m3", "m4");
-
-    }
-
-
-    /**
-     * Test Layer defineModulesWithXXX when the modules that override same
-     * named modules in the parent layer.
-     *
-     * Test scenario:
-     *   layer1: m1, m2, m3 => same loader
-     *   layer2: m1, m2, m4 => same loader
-     */
-    public void testOverriding1() throws Exception {
-
-        Configuration cf1 = resolve("m1");
-
-        Layer layer1 = Layer.boot().defineModulesWithOneLoader(cf1, null);
-        checkLayer(layer1, "m1", "m2", "m3");
-
-        ModuleFinder finder = ModuleFinder.of(MODS_DIR);
-        Configuration cf2 = cf1.resolve(finder, ModuleFinder.of(),
-                                                Set.of("m1"));
-
-        Layer layer2 = layer1.defineModulesWithOneLoader(cf2, null);
-        checkLayer(layer2, "m1", "m2", "m3");
-        invoke(layer1, "m1", "p.Main");
-
-        ClassLoader loader1 = layer1.findLoader("m1");
-        ClassLoader loader2 = layer1.findLoader("m2");
-        ClassLoader loader3 = layer1.findLoader("m3");
-
-        ClassLoader loader4 = layer2.findLoader("m1");
-        ClassLoader loader5 = layer2.findLoader("m2");
-        ClassLoader loader6 = layer2.findLoader("m3");
-
-        assertTrue(loader1 == loader2);
-        assertTrue(loader1 == loader3);
-
-        assertTrue(loader4 == loader5);
-        assertTrue(loader4 == loader6);
-        assertTrue(loader4 != loader1);
-
-        assertTrue(loader1.loadClass("p.Main").getClassLoader() == loader1);
-        assertTrue(loader1.loadClass("q.Hello").getClassLoader() == loader1);
-        assertTrue(loader1.loadClass("w.Hello").getClassLoader() == loader1);
-
-        assertTrue(loader4.loadClass("p.Main").getClassLoader() == loader4);
-        assertTrue(loader4.loadClass("q.Hello").getClassLoader() == loader4);
-        assertTrue(loader4.loadClass("w.Hello").getClassLoader() == loader4);
-
-    }
-
-
-    /**
-     * Test Layer defineModulesWithXXX when the modules that override same
-     * named modules in the parent layer.
-     *
-     * Test scenario:
-     *   layer1: m1, m2, m3 => loader pool
-     *   layer2: m1, m2, m3 => loader pool
-     */
-    public void testOverriding2() throws Exception {
-
-        Configuration cf1 = resolve("m1");
-
-        Layer layer1 = Layer.boot().defineModulesWithManyLoaders(cf1, null);
-        checkLayer(layer1, "m1", "m2", "m3");
-
-        ModuleFinder finder = ModuleFinder.of(MODS_DIR);
-        Configuration cf2 = cf1.resolve(finder, ModuleFinder.of(),
-                                                Set.of("m1"));
-
-        Layer layer2 = layer1.defineModulesWithManyLoaders(cf2, null);
-        checkLayer(layer2, "m1", "m2", "m3");
-        invoke(layer1, "m1", "p.Main");
-
-        ClassLoader loader1 = layer1.findLoader("m1");
-        ClassLoader loader2 = layer1.findLoader("m2");
-        ClassLoader loader3 = layer1.findLoader("m3");
-
-        ClassLoader loader4 = layer2.findLoader("m1");
-        ClassLoader loader5 = layer2.findLoader("m2");
-        ClassLoader loader6 = layer2.findLoader("m3");
-
-        assertTrue(loader4 != loader1);
-        assertTrue(loader5 != loader2);
-        assertTrue(loader6 != loader3);
-
-        assertTrue(loader1.loadClass("p.Main").getClassLoader() == loader1);
-        assertTrue(loader1.loadClass("q.Hello").getClassLoader() == loader2);
-        assertTrue(loader1.loadClass("w.Hello").getClassLoader() == loader3);
-
-        // p.Main is not visible via loader2
-        try {
-            loader2.loadClass("p.Main");
-            assertTrue(false);
-        } catch (ClassNotFoundException expected) { }
-
-        // w.Hello is not visible via loader2
-        try {
-            loader2.loadClass("w.Hello");
-            assertTrue(false);
-        } catch (ClassNotFoundException expected) { }
-
-        // p.Main is not visible via loader3
-        try {
-            loader3.loadClass("p.Main");
-            assertTrue(false);
-        } catch (ClassNotFoundException expected) { }
-
-        // q.Hello is not visible via loader3
-        try {
-            loader3.loadClass("q.Hello");
-            assertTrue(false);
-        } catch (ClassNotFoundException expected) { }
-
-
-        assertTrue(loader4.loadClass("p.Main").getClassLoader() == loader4);
-        assertTrue(loader5.loadClass("q.Hello").getClassLoader() == loader5);
-        assertTrue(loader6.loadClass("w.Hello").getClassLoader() == loader6);
-
-        // p.Main is not visible via loader5
-        try {
-            loader5.loadClass("p.Main");
-            assertTrue(false);
-        } catch (ClassNotFoundException expected) { }
-
-        // w.Hello is not visible via loader5
-        try {
-            loader5.loadClass("w.Hello");
-            assertTrue(false);
-        } catch (ClassNotFoundException expected) { }
-
-        // p.Main is not visible via loader6
-        try {
-            loader6.loadClass("p.Main");
-            assertTrue(false);
-        } catch (ClassNotFoundException expected) { }
-
-        // q.Hello is not visible via loader6
-        try {
-            loader6.loadClass("q.Hello");
-            assertTrue(false);
-        } catch (ClassNotFoundException expected) { }
-
-    }
-
-
-    /**
-     * Test Layer defineModulesWithXXX when the modules that override same
-     * named modules in the parent layer.
-     *
-     * layer1: m1, m2, m3 => same loader
-     * layer2: m1, m3 => same loader
-     */
-    public void testOverriding3() throws Exception {
-
-        Configuration cf1 = resolve("m1");
-
-        Layer layer1 = Layer.boot().defineModulesWithOneLoader(cf1, null);
-        checkLayer(layer1, "m1", "m2", "m3");
-
-        ModuleFinder finder = finderFor("m1", "m3");
-
-        Configuration cf2 = cf1.resolve(finder, ModuleFinder.of(),
-                                                Set.of("m1"));
-
-        Layer layer2 = layer1.defineModulesWithOneLoader(cf2, null);
-        checkLayer(layer2, "m1", "m3");
-        invoke(layer1, "m1", "p.Main");
-
-        ClassLoader loader1 = layer1.findLoader("m1");
-        ClassLoader loader2 = layer2.findLoader("m1");
-
-        assertTrue(loader1.loadClass("p.Main").getClassLoader() == loader1);
-        assertTrue(loader1.loadClass("q.Hello").getClassLoader() == loader1);
-        assertTrue(loader1.loadClass("w.Hello").getClassLoader() == loader1);
-
-        assertTrue(loader2.loadClass("p.Main").getClassLoader() == loader2);
-        assertTrue(loader2.loadClass("q.Hello").getClassLoader() == loader1);
-        assertTrue(loader2.loadClass("w.Hello").getClassLoader() == loader2);
-
-    }
-
-
-    /**
-     * Test Layer defineModulesWithXXX when the modules that override same
-     * named modules in the parent layer.
-     *
-     * layer1: m1, m2, m3 => loader pool
-     * layer2: m1, m3 => loader pool
-     */
-    public void testOverriding4() throws Exception {
-
-        Configuration cf1 = resolve("m1");
-
-        Layer layer1 = Layer.boot().defineModulesWithManyLoaders(cf1, null);
-        checkLayer(layer1, "m1", "m2", "m3");
-
-        ModuleFinder finder = finderFor("m1", "m3");
-
-        Configuration cf2 = cf1.resolve(finder, ModuleFinder.of(),
-                                                Set.of("m1"));
-
-        Layer layer2 = layer1.defineModulesWithManyLoaders(cf2, null);
-        checkLayer(layer2, "m1", "m3");
-        invoke(layer1, "m1", "p.Main");
-
-        ClassLoader loader1 = layer1.findLoader("m1");
-        ClassLoader loader2 = layer1.findLoader("m2");
-        ClassLoader loader3 = layer1.findLoader("m3");
-
-        ClassLoader loader4 = layer2.findLoader("m1");
-        ClassLoader loader5 = layer2.findLoader("m2");
-        ClassLoader loader6 = layer2.findLoader("m3");
-
-        assertTrue(loader4 != loader1);
-        assertTrue(loader5 == loader2);  // m2 not overridden
-        assertTrue(loader6 != loader3);
-
-        assertTrue(loader1.loadClass("p.Main").getClassLoader() == loader1);
-        assertTrue(loader1.loadClass("q.Hello").getClassLoader() == loader2);
-        assertTrue(loader1.loadClass("w.Hello").getClassLoader() == loader3);
-
-        assertTrue(loader2.loadClass("q.Hello").getClassLoader() == loader2);
-
-        assertTrue(loader3.loadClass("w.Hello").getClassLoader() == loader3);
-
-        assertTrue(loader4.loadClass("p.Main").getClassLoader() == loader4);
-        assertTrue(loader4.loadClass("q.Hello").getClassLoader() == loader2);
-        assertTrue(loader4.loadClass("w.Hello").getClassLoader() == loader6);
-
-        assertTrue(loader6.loadClass("w.Hello").getClassLoader() == loader6);
-
-    }
-
-
-    /**
-     * Basic test of resource loading with a class loader created by
-     * Layer.defineModulesWithOneLoader.
-     */
-    public void testResourcesOneLoader() throws Exception {
-        Configuration cf = resolve("m1");
-        ClassLoader scl = ClassLoader.getSystemClassLoader();
-        Layer layer = Layer.boot().defineModulesWithOneLoader(cf, scl);
-        ClassLoader loader = layer.findLoader("m1");
-        testResourceLoading(loader, "p/Main.class");
-    }
-
-    /**
-     * Basic test of resource loading with a class loader created by
-     * Layer.defineModulesWithOneLoader.
-     */
-    public void testResourcesManyLoaders() throws Exception {
-        Configuration cf = resolve("m1");
-        ClassLoader scl = ClassLoader.getSystemClassLoader();
-        Layer layer = Layer.boot().defineModulesWithManyLoaders(cf, scl);
-        ClassLoader loader = layer.findLoader("m1");
-        testResourceLoading(loader, "p/Main.class");
-    }
-
-    /**
-     * Test that a resource is located by a class loader.
-     */
-    private void testResourceLoading(ClassLoader loader, String name)
-        throws IOException
-    {
-        URL url = loader.getResource(name);
-        assertNotNull(url);
-
-        try (InputStream in = loader.getResourceAsStream(name)) {
-            assertNotNull(in);
-        }
-
-        Enumeration<URL> urls = loader.getResources(name);
-        assertTrue(urls.hasMoreElements());
-    }
-
-
-    // -- supporting methods --
-
-
-    /**
-     * Resolve the given modules, by name, and returns the resulting
-     * Configuration.
-     */
-    private static Configuration resolve(String... roots) {
-        ModuleFinder finder = ModuleFinder.of(MODS_DIR);
-        return Layer.boot()
-            .configuration()
-            .resolve(finder, ModuleFinder.of(), Set.of(roots));
-    }
-
-    /**
-     * Resolve the given modules, by name, and returns the resulting
-     * Configuration.
-     */
-    private static Configuration resolveAndBind(String... roots) {
-        ModuleFinder finder = ModuleFinder.of(MODS_DIR);
-        return Layer.boot()
-            .configuration()
-            .resolveAndBind(finder, ModuleFinder.of(), Set.of(roots));
-    }
-
-
-    /**
-     * Invokes the static void main(String[]) method on the given class
-     * in the given module.
-     */
-    private static void invoke(Layer layer, String mn, String mc) throws Exception {
-        ClassLoader loader = layer.findLoader(mn);
-        Class<?> c = loader.loadClass(mc);
-        Method mainMethod = c.getMethod("main", String[].class);
-        mainMethod.invoke(null, (Object)new String[0]);
-    }
-
-
-    /**
-     * Checks that the given layer contains exactly the expected modules
-     * (by name).
-     */
-    private void checkLayer(Layer layer, String ... expected) {
-        Set<String> names = layer.modules().stream()
-                .map(Module::getName)
-                .collect(Collectors.toSet());
-        assertTrue(names.size() == expected.length);
-        for (String name : expected) {
-            assertTrue(names.contains(name));
-        }
-    }
-
-
-    /**
-     * Test that a class can be loaded via the class loader of all modules
-     * in the given layer.
-     */
-    static void testLoad(Layer layer, String cn) throws Exception {
-        for (Module m : layer.modules()) {
-            ClassLoader l = m.getClassLoader();
-            l.loadClass(cn);
-        }
-    }
-
-
-    /**
-     * Test that a class cannot be loaded via any of the class loaders of
-     * the modules in the given layer.
-     */
-    static void testLoadFail(Layer layer, String cn) throws Exception {
-        for (Module m : layer.modules()) {
-            ClassLoader l = m.getClassLoader();
-            try {
-                l.loadClass(cn);
-                assertTrue(false);
-            } catch (ClassNotFoundException expected) { }
-        }
-    }
-
-
-    /**
-     * Returns a ModuleFinder that only finds the given test modules
-     */
-    static ModuleFinder finderFor(String... names) {
-
-        ModuleFinder finder = ModuleFinder.of(MODS_DIR);
-
-        Map<String, ModuleReference> mrefs = new HashMap<>();
-        for (String name : names) {
-            Optional<ModuleReference> omref = finder.find(name);
-            assert omref.isPresent();
-            mrefs.put(name, omref.get());
-        }
-
-        return new ModuleFinder() {
-            @Override
-            public Optional<ModuleReference> find(String name) {
-                ModuleReference mref = mrefs.get(name);
-                return Optional.ofNullable(mref);
-            }
-            @Override
-            public Set<ModuleReference> findAll() {
-                return mrefs.values().stream().collect(Collectors.toSet());
-            }
-        };
-    }
-
-}
--- a/jdk/test/java/lang/reflect/Layer/LayerControllerTest.java	Tue Apr 18 13:19:42 2017 -0400
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,196 +0,0 @@
-/*
- * 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
- * @library /lib/testlibrary
- * @build LayerControllerTest ModuleUtils
- * @run testng LayerControllerTest
- * @summary Basic tests for java.lang.reflect.Layer.Controller
- */
-
-import java.lang.module.Configuration;
-import java.lang.module.ModuleDescriptor;
-import java.lang.module.ModuleFinder;
-import java.lang.reflect.Layer;
-import java.lang.reflect.Module;
-import java.util.List;
-import java.util.Set;
-
-import org.testng.annotations.Test;
-import static org.testng.Assert.*;
-
-@Test
-public class LayerControllerTest {
-
-    /**
-     * Creates a Controller for a module layer containing modules m1 and m2.
-     * Module m1 contains p1, reads java.base, does not export/open any package
-     * Module m2 contains p2, reads java.base, does not export/open any package
-     */
-    private Layer.Controller createTestLayer() {
-        ModuleDescriptor descriptor1
-            = ModuleDescriptor.newModule("m1")
-                .packages(Set.of("p1"))
-                .requires("java.base")
-                .build();
-
-        ModuleDescriptor descriptor2
-            = ModuleDescriptor.newModule("m2")
-                .requires("java.base")
-                .packages(Set.of("p2"))
-                .build();
-
-        ModuleFinder finder = ModuleUtils.finderOf(descriptor1, descriptor2);
-        Layer bootLayer = Layer.boot();
-
-        Configuration cf = bootLayer.configuration()
-                .resolve(finder, ModuleFinder.of(), Set.of("m1", "m2"));
-
-        ClassLoader scl = ClassLoader.getSystemClassLoader();
-
-        Layer.Controller controller
-                = Layer.defineModulesWithOneLoader(cf, List.of(bootLayer), scl);
-
-        Layer layer = controller.layer();
-
-        assertTrue(layer.modules().size() == 2);
-        assertTrue(layer.findModule("m1").isPresent());
-        assertTrue(layer.findModule("m2").isPresent());
-
-        return controller;
-    }
-
-    /**
-     * Basic test of Layer.Controller to update modules m1 and m2 to read and
-     * open packages to each other.
-     */
-    public void testBasic() {
-        Layer.Controller controller = createTestLayer();
-        Layer layer = controller.layer();
-        Module m1 = layer.findModule("m1").orElseThrow(RuntimeException::new);
-        Module m2 = layer.findModule("m2").orElseThrow(RuntimeException::new);
-
-        assertFalse(m1.canRead(m2));
-        assertFalse(m1.isExported("p1"));
-        assertFalse(m1.isOpen("p1"));
-        assertFalse(m1.isExported("p1", m2));
-        assertFalse(m1.isOpen("p1", m2));
-
-        assertFalse(m2.canRead(m1));
-        assertFalse(m2.isExported("p2"));
-        assertFalse(m2.isOpen("p2"));
-        assertFalse(m2.isExported("p2", m1));
-        assertFalse(m2.isOpen("p2", m1));
-
-        // update m1 to read m2
-        assertTrue(controller.addReads(m1, m2) == controller);
-        assertTrue(m1.canRead(m2));
-        assertFalse(m2.canRead(m1));
-
-        // update m2 to read m1
-        assertTrue(controller.addReads(m2, m1) == controller);
-        assertTrue(m1.canRead(m2));
-        assertTrue(m1.canRead(m1));
-
-        // update m1 to open p1 to m2
-        assertTrue(controller.addOpens(m1, "p1", m2) == controller);
-        assertTrue(m1.isExported("p1", m2));
-        assertTrue(m1.isOpen("p1", m2));
-        assertFalse(m1.isExported("p1"));
-        assertFalse(m1.isOpen("p1"));
-
-        // update m2 to open p2 to m1
-        assertTrue(controller.addOpens(m2, "p2", m1) == controller);
-        assertTrue(m2.isExported("p2", m1));
-        assertTrue(m2.isOpen("p2", m1));
-        assertFalse(m2.isExported("p2"));
-        assertFalse(m2.isOpen("p2"));
-    }
-
-    /**
-     * Test invalid argument handling
-     */
-    public void testBadArguments() {
-        Layer.Controller controller = createTestLayer();
-        Layer layer = controller.layer();
-        Module m1 = layer.findModule("m1").orElseThrow(RuntimeException::new);
-        Module m2 = layer.findModule("m2").orElseThrow(RuntimeException::new);
-        Module base = Object.class.getModule();
-
-        // java.base is not in layer
-        try {
-            controller.addReads(base, m2);
-            assertTrue(false);
-        } catch (IllegalArgumentException expected) { }
-
-        // java.base is not in layer
-        try {
-            controller.addOpens(base, "java.lang", m2);
-            assertTrue(false);
-        } catch (IllegalArgumentException expected) { }
-
-        // m1 does not contain java.lang
-        try {
-            controller.addOpens(m1, "java.lang", m2);
-            assertTrue(false);
-        } catch (IllegalArgumentException expected) { }
-    }
-
-    /**
-     * Test null handling
-     */
-    public void testNulls() {
-        Layer.Controller controller = createTestLayer();
-        Layer layer = controller.layer();
-        Module m1 = layer.findModule("m1").orElseThrow(RuntimeException::new);
-        Module m2 = layer.findModule("m2").orElseThrow(RuntimeException::new);
-        assertTrue(m1 != null);
-        assertTrue(m2 != null);
-
-        try {
-            controller.addReads(null, m2);
-            assertTrue(false);
-        } catch (NullPointerException expected) { }
-
-        try {
-            controller.addReads(m1, null);
-            assertTrue(false);
-        } catch (NullPointerException expected) { }
-
-        try {
-            controller.addOpens(null, "p1", m2);
-            assertTrue(false);
-        } catch (NullPointerException expected) { }
-
-        try {
-            controller.addOpens(m1, null, m2);
-            assertTrue(false);
-        } catch (NullPointerException expected) { }
-
-        try {
-            controller.addOpens(m1, "p1", null);
-            assertTrue(false);
-        } catch (NullPointerException expected) { }
-    }
-}
--- a/jdk/test/java/lang/reflect/Layer/layertest/Test.java	Tue Apr 18 13:19:42 2017 -0400
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,31 +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.
- *
- * 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.
- */
-
-/**
- * Supporting class for tests of java.lang.reflect.Layer.
- */
-
-package layertest;
-
-public class Test { }
-
--- a/jdk/test/java/lang/reflect/Layer/src/m1/module-info.java	Tue Apr 18 13:19:42 2017 -0400
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,29 +0,0 @@
-/*
- * 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
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-module m1 {
-    requires m2;
-    requires m3;
-    exports p;
-    uses p.Service;
-}
--- a/jdk/test/java/lang/reflect/Layer/src/m1/p/Main.java	Tue Apr 18 13:19:42 2017 -0400
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,39 +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.
- *
- * 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 p;
-
-import java.net.URL;
-
-public class Main {
-    public static void main(String[] args) {
-
-        URL url1 = Main.class.getResource("Main.class");
-        if (url1 == null) throw new RuntimeException();
-        URL url2 = Main.class.getResource("/p/Main.class");
-        if (url2 == null) throw new RuntimeException();
-
-        q.Hello.hello();
-        w.Hello.hello();
-    }
-}
--- a/jdk/test/java/lang/reflect/Layer/src/m1/p/Service.java	Tue Apr 18 13:19:42 2017 -0400
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,26 +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.
- *
- * 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 p;
-
-public interface Service { }
--- a/jdk/test/java/lang/reflect/Layer/src/m2/module-info.java	Tue Apr 18 13:19:42 2017 -0400
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,26 +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.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-module m2 {
-    exports q;
-}
--- a/jdk/test/java/lang/reflect/Layer/src/m2/q/Hello.java	Tue Apr 18 13:19:42 2017 -0400
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,40 +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.
- *
- * 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 q;
-
-import java.net.URL;
-
-public class Hello {
-
-    public static void hello() {
-
-        URL url1 = Hello.class.getResource("Hello.class");
-        if (url1 == null) throw new RuntimeException();
-        URL url2 = Hello.class.getResource("/q/Hello.class");
-        if (url2 == null) throw new RuntimeException();
-
-        System.out.println("Hello!");
-    }
-
-}
--- a/jdk/test/java/lang/reflect/Layer/src/m3/module-info.java	Tue Apr 18 13:19:42 2017 -0400
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,27 +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.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-module m3 {
-    // qualified export
-    exports w to m1;
-}
--- a/jdk/test/java/lang/reflect/Layer/src/m3/w/Hello.java	Tue Apr 18 13:19:42 2017 -0400
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,40 +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.
- *
- * 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 w;
-
-import java.net.URL;
-
-public class Hello {
-
-    public static void hello() {
-
-        URL url1 = Hello.class.getResource("Hello.class");
-        if (url1 == null) throw new RuntimeException();
-        URL url2 = Hello.class.getResource("/w/Hello.class");
-        if (url2 == null) throw new RuntimeException();
-
-        System.out.println("Hello!");
-    }
-
-}
--- a/jdk/test/java/lang/reflect/Layer/src/m4/impl/ServiceImpl.java	Tue Apr 18 13:19:42 2017 -0400
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,27 +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.
- *
- * 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 impl;
-
-public class ServiceImpl implements p.Service {
-}
--- a/jdk/test/java/lang/reflect/Layer/src/m4/module-info.java	Tue Apr 18 13:19:42 2017 -0400
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,27 +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.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-module m4 {
-    requires m1;
-    provides p.Service with impl.ServiceImpl;
-}
--- a/jdk/test/java/lang/reflect/Module/AddExportsTest.java	Tue Apr 18 13:19:42 2017 -0400
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,128 +0,0 @@
-/*
- * 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
- * @modules java.base/jdk.internal.misc
- *          java.desktop
- * @run main/othervm --add-exports=java.desktop/sun.awt=java.base AddExportsTest
- * @run main/othervm --add-exports=java.desktop/sun.awt=ALL-UNNAMED AddExportsTest
- * @summary Test Module isExported methods with exports changed by -AddExportsTest
- */
-
-import java.lang.reflect.Layer;
-import java.lang.reflect.Module;
-import java.util.Optional;
-import java.util.stream.Stream;
-
-import jdk.internal.misc.VM;
-
-public class AddExportsTest {
-    /*
-     * jtreg sets -Dtest.modules system property to the internal APIs
-     * specified at @modules tag.  The test will exclude --add-exports set
-     * for @modules.
-     */
-    private static final String TEST_MODULES = System.getProperty("test.modules");
-
-    public static void main(String[] args) {
-
-        Optional<String> oaddExports = Stream.of(VM.getRuntimeArguments())
-            .filter(arg -> arg.startsWith("--add-exports="))
-            .filter(arg -> !arg.equals("--add-exports=" + TEST_MODULES + "=ALL-UNNAMED"))
-            .map(arg -> arg.substring("--add-exports=".length(), arg.length()))
-            .findFirst();
-
-        assertTrue(oaddExports.isPresent());
-
-        Layer bootLayer = Layer.boot();
-
-        Module unnamedModule = AddExportsTest.class.getModule();
-        assertFalse(unnamedModule.isNamed());
-
-        for (String expr : oaddExports.get().split(",")) {
-
-            String[] s = expr.split("=");
-            assertTrue(s.length == 2);
-
-            // $MODULE/$PACKAGE
-            String[] moduleAndPackage = s[0].split("/");
-            assertTrue(moduleAndPackage.length == 2);
-
-            String mn = moduleAndPackage[0];
-            String pn = moduleAndPackage[1];
-
-            // source module
-            Module source;
-            Optional<Module> om = bootLayer.findModule(mn);
-            assertTrue(om.isPresent(), mn + " not in boot layer");
-            source = om.get();
-
-            // package should not be exported unconditionally
-            assertFalse(source.isExported(pn),
-                        pn + " should not be exported unconditionally");
-
-            // $TARGET
-            String tn = s[1];
-            if ("ALL-UNNAMED".equals(tn)) {
-
-                // package is exported to all unnamed modules
-                assertTrue(source.isExported(pn, unnamedModule),
-                           pn + " should be exported to all unnamed modules");
-
-            } else {
-
-                om = bootLayer.findModule(tn);
-                assertTrue(om.isPresent());
-                Module target = om.get();
-
-                // package should be exported to target module
-                assertTrue(source.isExported(pn, target),
-                           pn + " should be exported to " + target);
-
-                // package should not be exported to unnamed modules
-                assertFalse(source.isExported(pn, unnamedModule),
-                            pn + " should not be exported to unnamed modules");
-
-            }
-
-        }
-    }
-
-    static void assertTrue(boolean cond) {
-        if (!cond) throw new RuntimeException();
-    }
-
-    static void assertTrue(boolean cond, String msg) {
-        if (!cond) throw new RuntimeException(msg);
-    }
-
-    static void assertFalse(boolean cond) {
-        if (cond) throw new RuntimeException();
-    }
-
-    static void assertFalse(boolean cond, String msg) {
-        if (cond) throw new RuntimeException(msg);
-    }
-
-}
--- a/jdk/test/java/lang/reflect/Module/AnnotationsTest.java	Tue Apr 18 13:19:42 2017 -0400
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,156 +0,0 @@
-/*
- * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.lang.annotation.Annotation;
-import java.lang.module.Configuration;
-import java.lang.module.ModuleFinder;
-import java.lang.reflect.Layer;
-import java.lang.reflect.Module;
-import java.nio.file.Files;
-import java.nio.file.Path;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Set;
-
-import jdk.internal.module.ClassFileAttributes;
-import jdk.internal.org.objectweb.asm.AnnotationVisitor;
-import jdk.internal.org.objectweb.asm.Attribute;
-import jdk.internal.org.objectweb.asm.ClassReader;
-import jdk.internal.org.objectweb.asm.ClassVisitor;
-import jdk.internal.org.objectweb.asm.ClassWriter;
-import jdk.internal.org.objectweb.asm.Opcodes;
-
-import org.testng.annotations.Test;
-import static org.testng.Assert.*;
-
-/**
- * @test
- * @modules java.base/jdk.internal.org.objectweb.asm
- *          java.base/jdk.internal.module
- *          java.xml
- * @run testng AnnotationsTest
- * @summary Basic test of annotations on modules
- */
-
-public class AnnotationsTest {
-
-    /**
-     * Test that there are no annotations on an unnamed module.
-     */
-    @Test
-    public void testUnnamedModule() {
-        Module module = this.getClass().getModule();
-        assertTrue(module.getAnnotations().length == 0);
-    }
-
-    /**
-     * Test loading a module with a RuntimeVisibleAnnotation attribute.
-     * The test copies the module-info.class for java.xml, adds the attribute,
-     * and then loads the updated module.
-     */
-    @Test
-    public void testNamedModule() throws IOException {
-
-        // "deprecate" java.xml
-        Path dir = Files.createTempDirectory("mods");
-        deprecateModule("java.xml", true, "9", dir);
-
-        // "load" the cloned java.xml
-        Module module = loadModule(dir, "java.xml");
-
-        // check the annotation is present
-        assertTrue(module.isAnnotationPresent(Deprecated.class));
-        Deprecated d = module.getAnnotation(Deprecated.class);
-        assertNotNull(d, "@Deprecated not found");
-        assertTrue(d.forRemoval());
-        assertEquals(d.since(), "9");
-        Annotation[] a = module.getAnnotations();
-        assertTrue(a.length == 1);
-        assertTrue(a[0] instanceof Deprecated);
-    }
-
-
-    /**
-     * Copy the module-info.class for the given module, add the
-     * Deprecated annotation, and write the updated module-info.class
-     * to a directory.
-     */
-    static void deprecateModule(String name,
-                                boolean forRemoval,
-                                String since,
-                                Path output) throws IOException {
-        Module module = Layer.boot().findModule(name).orElse(null);
-        assertNotNull(module, name + " not found");
-
-        InputStream in = module.getResourceAsStream("module-info.class");
-        assertNotNull(in, "No module-info.class for " + name);
-
-        try (in) {
-            ClassWriter cw = new ClassWriter(ClassWriter.COMPUTE_MAXS
-                                             + ClassWriter.COMPUTE_FRAMES);
-
-            ClassVisitor cv = new ClassVisitor(Opcodes.ASM5, cw) { };
-
-            ClassReader cr = new ClassReader(in);
-
-            List<Attribute> attrs = new ArrayList<>();
-            attrs.add(new ClassFileAttributes.ModuleAttribute());
-            attrs.add(new ClassFileAttributes.ModulePackagesAttribute());
-            attrs.add(new ClassFileAttributes.ModuleTargetAttribute());
-            cr.accept(cv, attrs.toArray(new Attribute[0]), 0);
-
-            AnnotationVisitor annotationVisitor
-                = cv.visitAnnotation("Ljava/lang/Deprecated;", true);
-            annotationVisitor.visit("forRemoval", forRemoval);
-            annotationVisitor.visit("since", since);
-            annotationVisitor.visitEnd();
-
-            byte[] bytes = cw.toByteArray();
-            Path mi = output.resolve("module-info.class");
-            Files.write(mi, bytes);
-        }
-    }
-
-    /**
-     * Load the module of the given name in the given directory into a
-     * child layer.
-     */
-    static Module loadModule(Path dir, String name) throws IOException {
-        ModuleFinder finder = ModuleFinder.of(dir);
-
-        Layer bootLayer = Layer.boot();
-
-        Configuration cf = bootLayer.configuration()
-                .resolve(finder, ModuleFinder.of(), Set.of(name));
-
-        ClassLoader scl = ClassLoader.getSystemClassLoader();
-        Layer layer = bootLayer.defineModulesWithOneLoader(cf, scl);
-
-        Module module = layer.findModule(name).orElse(null);
-        assertNotNull(module, name + " not loaded");
-        return module;
-    }
-}
--- a/jdk/test/java/lang/reflect/Module/BasicModuleTest.java	Tue Apr 18 13:19:42 2017 -0400
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,338 +0,0 @@
-/*
- * Copyright (c) 2014, 2017, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-import java.lang.module.ModuleDescriptor.Exports;
-import java.lang.module.ResolvedModule;
-import java.lang.reflect.Layer;
-import java.lang.reflect.Module;
-import java.nio.file.spi.FileSystemProvider;  // service type in java.base
-import java.util.function.Predicate;
-import java.util.stream.Stream;
-import javax.print.PrintServiceLookup;        // service type in java.desktop
-
-import org.testng.annotations.Test;
-import static org.testng.Assert.*;
-
-/*
- * @test
- * @summary Basic test of java.lang.reflect.Module
- * @modules java.desktop java.xml
- * @run testng BasicModuleTest
- */
-
-public class BasicModuleTest {
-
-    /**
-     * Tests that the given module reads all modules in the boot Layer.
-     */
-    private void testReadsAllBootModules(Module m) {
-        Layer bootLayer = Layer.boot();
-        bootLayer.configuration()
-            .modules()
-            .stream()
-            .map(ResolvedModule::name)
-            .map(bootLayer::findModule)
-            .forEach(target -> assertTrue(m.canRead(target.get())));
-    }
-
-    /**
-     * Returns {@code true} if the array contains the given object.
-     */
-    private <T> boolean contains(T[] array, T obj) {
-        return Stream.of(array).anyMatch(obj::equals);
-    }
-
-    /**
-     * Returns a {@code Predicate} to test if a package is exported.
-     */
-    private Predicate<Exports> doesExport(String pn) {
-        return e -> (e.source().equals(pn) && !e.isQualified());
-    }
-
-
-
-    @Test
-    public void testThisModule() {
-        Module thisModule = BasicModuleTest.class.getModule();
-        Module baseModule = Object.class.getModule();
-
-        assertFalse(thisModule.isNamed());
-        assertTrue(thisModule.getName() == null);
-        assertTrue(thisModule.getDescriptor() == null);
-        assertTrue(thisModule.getLayer() == null);
-        assertTrue(thisModule.toString().startsWith("unnamed module "));
-
-        ClassLoader thisLoader = BasicModuleTest.class.getClassLoader();
-        assertTrue(thisLoader == thisModule.getClassLoader());
-        assertTrue(thisLoader.getUnnamedModule() == thisModule);
-
-        // unnamed modules read all other modules
-        ClassLoader cl;
-        cl = ClassLoader.getPlatformClassLoader();
-        assertTrue(thisModule.canRead(cl.getUnnamedModule()));
-        cl = ClassLoader.getSystemClassLoader();
-        assertTrue(thisModule.canRead(cl.getUnnamedModule()));
-        testReadsAllBootModules(thisModule);
-
-        // unnamed modules export all packages
-        assertTrue(thisModule.isExported(""));
-        assertTrue(thisModule.isExported("", thisModule));
-        assertTrue(thisModule.isExported("", baseModule));
-        assertTrue(thisModule.isExported("p"));
-        assertTrue(thisModule.isExported("p", thisModule));
-        assertTrue(thisModule.isExported("p", baseModule));
-
-        // this test is in the unnamed package
-        assertTrue(contains(thisModule.getPackages(), ""));
-    }
-
-
-    @Test
-    public void testUnnamedModules() {
-        Module thisModule = BasicModuleTest.class.getModule();
-        Module baseModule = Object.class.getModule();
-
-        ClassLoader loader1 = ClassLoader.getSystemClassLoader();
-        ClassLoader loader2 = loader1.getParent();
-
-        Module m1 = loader1.getUnnamedModule();
-        Module m2 = loader2.getUnnamedModule();
-
-        assertTrue(m1 != m2);
-
-        assertFalse(m1.isNamed());
-        assertFalse(m2.isNamed());
-
-        assertTrue(m1.getLayer() == null);
-        assertTrue(m2.getLayer() == null);
-
-        assertTrue(m1.toString().startsWith("unnamed module "));
-        assertTrue(m2.toString().startsWith("unnamed module "));
-
-        // unnamed module reads all modules
-        assertTrue(m1.canRead(m2));
-        assertTrue(m2.canRead(m1));
-
-        testReadsAllBootModules(m1);
-        testReadsAllBootModules(m2);
-
-        assertTrue(m1.isExported(""));
-        assertTrue(m1.isExported("", thisModule));
-        assertTrue(m1.isExported("", baseModule));
-        assertTrue(m1.isExported("p"));
-        assertTrue(m1.isExported("p", thisModule));
-        assertTrue(m1.isExported("p", baseModule));
-    }
-
-
-
-    @Test
-    public void testBaseModule() {
-        Module base = Object.class.getModule();
-        Module thisModule = BasicModuleTest.class.getModule();
-
-        // getName
-        assertTrue(base.getName().equals("java.base"));
-
-        // getDescriptor
-        assertTrue(base.getDescriptor().exports().stream()
-                .anyMatch(doesExport("java.lang")));
-
-        // getClassLoader
-        assertTrue(base.getClassLoader() == null);
-
-        // getLayer
-        assertTrue(base.getLayer() == Layer.boot());
-
-        // toString
-        assertEquals(base.toString(), "module java.base");
-
-        // getPackages
-        assertTrue(contains(base.getPackages(), "java.lang"));
-
-        // canRead
-        assertTrue(base.canRead(base));
-        assertFalse(base.canRead(thisModule));
-
-        // addReads
-        try {
-            base.addReads(thisModule);
-            assertTrue(false);
-        } catch (IllegalCallerException expected) { }
-        assertFalse(base.canRead(thisModule));
-
-        // isExported
-        assertTrue(base.isExported("java.lang"));
-        assertTrue(base.isExported("java.lang", thisModule));
-        assertTrue(base.isExported("java.lang", base));
-        assertFalse(base.isExported("jdk.internal.misc"));
-        assertFalse(base.isExported("jdk.internal.misc", thisModule));
-        assertTrue(base.isExported("jdk.internal.misc", base));
-        assertFalse(base.isExported("java.wombat"));
-        assertFalse(base.isExported("java.wombat", thisModule));
-        assertFalse(base.isExported("java.wombat", base));
-
-        // addExports
-        try {
-            base.addExports("java.lang", thisModule);
-            assertTrue(false);
-        } catch (IllegalCallerException expected) { }
-        try {
-            base.addExports("jdk.internal.misc", thisModule);
-            assertTrue(false);
-        } catch (IllegalCallerException expected) { }
-        assertFalse(base.isExported("jdk.internal.misc"));
-        assertFalse(base.isExported("jdk.internal.misc", thisModule));
-
-        // isOpen
-        assertFalse(base.isOpen("java.lang"));
-        assertFalse(base.isOpen("java.lang", thisModule));
-        assertTrue(base.isOpen("java.lang", base));
-        assertFalse(base.isOpen("jdk.internal.misc"));
-        assertFalse(base.isOpen("jdk.internal.misc", thisModule));
-        assertTrue(base.isOpen("jdk.internal.misc", base));
-        assertFalse(base.isOpen("java.wombat"));
-        assertFalse(base.isOpen("java.wombat", thisModule));
-        assertFalse(base.isOpen("java.wombat", base));
-
-        // addOpens
-        try {
-            base.addOpens("jdk.internal.misc", thisModule);
-            assertTrue(false);
-        } catch (IllegalCallerException expected) { }
-        assertFalse(base.isOpen("jdk.internal.misc"));
-        assertFalse(base.isOpen("jdk.internal.misc", thisModule));
-
-        // canUse
-        assertTrue(base.canUse(FileSystemProvider.class));
-        assertFalse(base.canUse(Thread.class));
-
-        // addUses
-        try {
-            base.addUses(FileSystemProvider.class);
-            assertTrue(false);
-        } catch (IllegalCallerException expected) { }
-        try {
-            base.addUses(Thread.class);
-            assertTrue(false);
-        } catch (IllegalCallerException expected) { }
-        assertFalse(base.canUse(Thread.class));
-    }
-
-
-    @Test
-    public void testDesktopModule() {
-        Module desktop = java.awt.Component.class.getModule();
-        Module base = Object.class.getModule();
-        Module xml = javax.xml.XMLConstants.class.getModule();
-        Module thisModule = BasicModuleTest.class.getModule();
-
-        // name
-        assertTrue(desktop.getName().equals("java.desktop"));
-
-        // descriptor
-        assertTrue(desktop.getDescriptor().exports().stream()
-                   .anyMatch(doesExport("java.awt")));
-
-        // getClassLoader
-        assertTrue(desktop.getClassLoader() == null);
-
-        // getLayer
-        assertTrue(desktop.getLayer() == Layer.boot());
-
-        // toString
-        assertEquals(desktop.toString(), "module java.desktop");
-
-        // getPackages
-        assertTrue(contains(desktop.getPackages(), "java.awt"));
-        assertTrue(contains(desktop.getPackages(), "sun.awt"));
-
-        // canRead
-        assertTrue(desktop.canRead(base));
-        assertTrue(desktop.canRead(xml));
-
-        // addReads
-        try {
-            desktop.addReads(thisModule);
-            assertTrue(false);
-        } catch (IllegalCallerException expected) { }
-        assertFalse(desktop.canRead(thisModule));
-
-        // isExported
-        assertTrue(desktop.isExported("java.awt"));
-        assertTrue(desktop.isExported("java.awt", thisModule));
-        assertFalse(desktop.isExported("sun.awt"));
-        assertFalse(desktop.isExported("sun.awt", thisModule));
-        assertTrue(desktop.isExported("sun.awt", desktop));
-        assertFalse(desktop.isExported("java.wombat"));
-        assertFalse(desktop.isExported("java.wombat", thisModule));
-        assertFalse(desktop.isExported("java.wombat", base));
-
-        // addExports
-        try {
-            desktop.addExports("java.awt", thisModule);
-            assertTrue(false);
-        } catch (IllegalCallerException expected) { }
-        try {
-            desktop.addExports("sun.awt", thisModule);
-            assertTrue(false);
-        } catch (IllegalCallerException expected) { }
-        assertFalse(desktop.isExported("sun.awt"));
-        assertFalse(desktop.isExported("sun.awt", thisModule));
-
-        // isOpen
-        assertFalse(desktop.isOpen("java.awt"));
-        assertFalse(desktop.isOpen("java.awt", thisModule));
-        assertTrue(desktop.isOpen("java.awt", desktop));
-        assertFalse(desktop.isOpen("sun.awt"));
-        assertFalse(desktop.isOpen("sun.awt", thisModule));
-        assertTrue(desktop.isOpen("sun.awt", desktop));
-        assertFalse(desktop.isOpen("java.wombat"));
-        assertFalse(desktop.isOpen("java.wombat", thisModule));
-        assertFalse(desktop.isOpen("java.wombat", desktop));
-
-        // addOpens
-        try {
-            base.addOpens("sun.awt", thisModule);
-            assertTrue(false);
-        } catch (IllegalCallerException expected) { }
-        assertFalse(desktop.isOpen("sun.awt"));
-        assertFalse(desktop.isOpen("sun.awt", thisModule));
-
-        // canUse
-        assertTrue(base.canUse(FileSystemProvider.class));
-        assertFalse(base.canUse(Thread.class));
-
-        // addUses
-        try {
-            desktop.addUses(PrintServiceLookup.class);
-            assertTrue(false);
-        } catch (IllegalCallerException expected) { }
-        try {
-            desktop.addUses(Thread.class);
-            assertTrue(false);
-        } catch (IllegalCallerException expected) { }
-        assertFalse(desktop.canUse(Thread.class));
-    }
-
-}
--- a/jdk/test/java/lang/reflect/Module/WithSecurityManager.java	Tue Apr 18 13:19:42 2017 -0400
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,147 +0,0 @@
-/*
- * 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
- * @modules jdk.compiler
- * @summary Test java.lang.reflect.Module methods that specify permission checks
- * @run main/othervm -Djava.security.policy=${test.src}/allow.policy WithSecurityManager allow
- * @run main/othervm WithSecurityManager deny
- */
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.lang.module.Configuration;
-import java.lang.module.ModuleFinder;
-import java.lang.module.ModuleReference;
-import java.lang.reflect.Layer;
-import java.lang.reflect.Module;
-import java.util.Collections;
-import java.util.Optional;
-import java.util.Set;
-
-/**
- * Test java.lang.reflect.Module methods that specify permission checks.
- */
-
-public class WithSecurityManager {
-
-    // a module that will be loaded into a child layer
-    static final String ANOTHER_MODULE          = "jdk.compiler";
-    static final String ANOTHER_MODULE_RESOURCE = "com/sun/tools/javac/Main.class";
-
-    public static void main(String[] args) throws IOException {
-        boolean allow = args[0].equals("allow");
-
-        // base module, in the boot layer
-        Module base = Object.class.getModule();
-
-        // another module, in a child layer
-        Module other = loadModuleInChildLayer(ANOTHER_MODULE);
-        assertTrue(other.getLayer() != Layer.boot());
-
-        System.setSecurityManager(new SecurityManager());
-
-        test(base, "java/lang/Object.class", allow);
-        test(other, ANOTHER_MODULE_RESOURCE, allow);
-    }
-
-    /**
-     * Test the permission checks by invoking methods on the given module.
-     *
-     * If {@code allow} is {@code true} then the permission checks should succeed.
-     */
-    static void test(Module m, String name, boolean allow) throws IOException {
-
-        // test Module::getClassLoader
-        System.out.format("Test getClassLoader on %s ...%n", m);
-        try {
-            ClassLoader cl = m.getClassLoader();
-            System.out.println(cl);
-            if (!allow)
-                assertTrue("getClassLoader should have failed", false);
-        } catch (SecurityException e) {
-            System.out.println(e + " thrown");
-            if (allow)
-                throw e;
-        }
-
-        // test Module::getResourceAsStream
-        System.out.format("Test getResourceAsStream(\"%s\") on %s ...%n", name, m);
-        try (InputStream in = m.getResourceAsStream(name)) {
-            System.out.println(in);
-            if (allow && (in == null))
-                assertTrue(name + " not found", false);
-            if (!allow && (in != null))
-                assertTrue(name + " should not be found", false);
-        }
-
-    }
-
-    /**
-     * Create a module layer that contains the given system module.
-     */
-    static Module loadModuleInChildLayer(String mn) {
-        Optional<ModuleReference> omref = ModuleFinder.ofSystem().find(mn);
-        assertTrue("module " + mn + " not a system module", omref.isPresent());
-
-        // create a ModuleFinder that only finds this module
-        ModuleReference mref = omref.get();
-        ModuleFinder finder = new ModuleFinder() {
-            @Override
-            public Optional<ModuleReference> find(String name) {
-                if (name.equals(mn))
-                    return Optional.of(mref);
-                else
-                    return Optional.empty();
-            }
-
-            @Override
-            public Set<ModuleReference> findAll() {
-                return Collections.singleton(mref);
-            }
-        };
-
-        // create a child configuration and layer with this module
-        Layer bootLayer = Layer.boot();
-        Configuration cf = bootLayer
-            .configuration()
-            .resolve(finder, ModuleFinder.of(), Set.of(ANOTHER_MODULE));
-        Layer layer = bootLayer.defineModulesWithOneLoader(cf, null);
-
-        Optional<Module> om = layer.findModule(mn);
-        assertTrue("module " + mn + " not in child layer", om.isPresent());
-        return om.get();
-    }
-
-    static void assertTrue(String msg, boolean e) {
-        if (!e)
-            throw new RuntimeException(msg);
-    }
-
-    static void assertTrue(boolean e) {
-        if (!e)
-            throw new RuntimeException();
-    }
-
-}
--- a/jdk/test/java/lang/reflect/Module/access/AccessTest.java	Tue Apr 18 13:19:42 2017 -0400
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,86 +0,0 @@
-/*
- * 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
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-import java.nio.file.Path;
-import java.nio.file.Paths;
-import java.util.Arrays;
-import java.util.List;
-
-import static jdk.testlibrary.ProcessTools.executeTestJava;
-
-import org.testng.annotations.BeforeTest;
-import org.testng.annotations.Test;
-import static org.testng.Assert.*;
-
-/**
- * @test
- * @library /lib/testlibrary
- * @modules jdk.compiler
- * @build AccessTest CompilerUtils jdk.testlibrary.*
- * @run testng AccessTest
- * @summary Driver for test that checks access to access to types in
- *          exported and non-exported packages.
- */
-
-@Test
-public class AccessTest {
-
-    private static final String TEST_SRC = System.getProperty("test.src");
-
-    private static final Path SRC_DIR = Paths.get(TEST_SRC, "src");
-    private static final Path MODS_DIR = Paths.get("mods");
-
-
-    // the names of the modules in this test
-    private static List<String> modules = Arrays.asList("test", "target");
-
-
-    /**
-     * Compiles all modules used by the test
-     */
-    @BeforeTest
-    public void compileAll() throws Exception {
-        for (String mn : modules) {
-            Path src = SRC_DIR.resolve(mn);
-            Path mods = MODS_DIR.resolve(mn);
-            assertTrue(CompilerUtils.compile(src, mods));
-        }
-    }
-
-    /**
-     * Run the test
-     */
-    public void runTest() throws Exception {
-        int exitValue
-            = executeTestJava("--module-path", MODS_DIR.toString(),
-                              "--add-modules", "target",
-                              "-Dsun.reflect.enableStrictMode=true",
-                              "-m", "test/test.Main")
-                .outputTo(System.out)
-                .errorTo(System.out)
-                .getExitValue();
-
-        assertTrue(exitValue == 0);
-    }
-
-}
--- a/jdk/test/java/lang/reflect/Module/access/src/target/module-info.java	Tue Apr 18 13:19:42 2017 -0400
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,27 +0,0 @@
-/*
- * 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
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-module target {
-    exports p1;
-    exports p2;
-}
--- a/jdk/test/java/lang/reflect/Module/access/src/target/p1/Helper.java	Tue Apr 18 13:19:42 2017 -0400
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,42 +0,0 @@
-/*
- * 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
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package p1;
-
-import java.lang.reflect.Module;
-
-/**
- * Helper class in target module to allow test invoke addExports[Private]
- */
-
-public class Helper {
-    Helper() { }
-
-    public static void addExports(String pn, Module who) {
-        Helper.class.getModule().addExports(pn, who);
-    }
-
-    public static void addOpens(String pn, Module who) {
-        Helper.class.getModule().addOpens(pn, who);
-    }
-}
--- a/jdk/test/java/lang/reflect/Module/access/src/target/p1/Public.java	Tue Apr 18 13:19:42 2017 -0400
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,45 +0,0 @@
-/*
- * 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
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package p1;
-
-public class Public {
-
-    // public constructor
-    public Public() { }
-
-    // non-public constructor
-    private Public(Void ignore) { }
-
-    // public field
-    public static Object f1;
-
-    // non-public field
-    private static Object f2;
-
-    // public method
-    public static void foo() { }
-
-    // non-public method
-    private static void bar() { }
-}
--- a/jdk/test/java/lang/reflect/Module/access/src/target/p2/NonPublic.java	Tue Apr 18 13:19:42 2017 -0400
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,45 +0,0 @@
-/*
- * 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
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package p2;
-
-class NonPublic {
-
-    // public constructor
-    public NonPublic() { }
-
-    // non-public constructor
-    private NonPublic(Void ignore) { }
-
-    // public field
-    public static Object f1;
-
-    // non-public field
-    private static Object f2;
-
-    // public method
-    public static void foo() { }
-
-    // non-public method
-    private static void bar() { }
-}
--- a/jdk/test/java/lang/reflect/Module/access/src/target/q1/Public.java	Tue Apr 18 13:19:42 2017 -0400
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,45 +0,0 @@
-/*
- * 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
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package q1;
-
-public class Public {
-
-    // public constructor
-    public Public() { }
-
-    // non-public constructor
-    private Public(Void ignore) { }
-
-    // public field
-    public static Object f1;
-
-    // non-public field
-    private static Object f2;
-
-    // public method
-    public static void foo() { }
-
-    // non-public method
-    private static void bar() { }
-}
--- a/jdk/test/java/lang/reflect/Module/access/src/target/q2/NonPublic.java	Tue Apr 18 13:19:42 2017 -0400
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,45 +0,0 @@
-/*
- * 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
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package q2;
-
-class NonPublic {
-
-    // public constructor
-    public NonPublic() { }
-
-    // non-public constructor
-    private NonPublic(Void ignore) { }
-
-    // public field
-    public static Object f1;
-
-    // non-public field
-    private static Object f2;
-
-    // public method
-    public static void foo() { }
-
-    // non-public method
-    private static void bar() { }
-}
--- a/jdk/test/java/lang/reflect/Module/access/src/test/module-info.java	Tue Apr 18 13:19:42 2017 -0400
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,24 +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.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-module test { }
--- a/jdk/test/java/lang/reflect/Module/access/src/test/test/Main.java	Tue Apr 18 13:19:42 2017 -0400
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,379 +0,0 @@
-/*
- * 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
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package test;
-
-import java.lang.reflect.AccessibleObject;
-import java.lang.reflect.Constructor;
-import java.lang.reflect.Field;
-import java.lang.reflect.Layer;
-import java.lang.reflect.Method;
-import java.lang.reflect.Module;
-
-/**
- * Test access to public/non-public members of public/non-public classes in
- * exported and non-exported packages.
- */
-
-public class Main {
-
-    public static void main(String[] args) throws Exception {
-        testPublicClassInExportedPackage();
-        testNonPublicClassInExportedPackage();
-        testPublicClassInNonExportedPackage();
-        testNonPublicClassInNonExportedPackage();
-    }
-
-    static void testPublicClassInExportedPackage() throws Exception {
-        Module thisModule = Main.class.getModule();
-        Module targetModule = getTargetModule();
-
-        assertTrue(targetModule.isExported("p1"));
-        assertTrue(targetModule.isExported("p1", thisModule));
-        assertTrue(targetModule.isExported("p1", targetModule));
-
-        assertFalse(targetModule.isOpen("p1"));
-        assertFalse(targetModule.isOpen("p1", thisModule));
-        assertTrue(targetModule.isOpen("p1", targetModule));
-
-        Class<?> clazz = Class.forName("p1.Public");
-        Constructor<?> ctor1 = clazz.getConstructor();   // public
-        Constructor<?> ctor2 = clazz.getDeclaredConstructor(Void.class); // non-public
-
-        Field f1 = clazz.getField("f1");    // public
-        Field f2 = clazz.getDeclaredField("f2");    // non-public
-
-        Method m1 = clazz.getMethod("foo");  // public
-        Method m2 = clazz.getDeclaredMethod("bar");  // non-public
-
-        tryAccessConstructor(ctor1, true);
-        tryAccessConstructor(ctor2, false);
-        tryAccessMethod(m1, true);
-        tryAccessMethod(m2, false);
-        tryAccessObjectField(f1, true);
-        tryAccessObjectField(f2, false);
-
-        trySetAccessible(ctor1, true);
-        trySetAccessible(ctor2, false);
-        trySetAccessible(m1, true);
-        trySetAccessible(m2, false);
-        trySetAccessible(f1, true);
-        trySetAccessible(f2, false);
-
-        targetAddOpens("p1", thisModule);
-
-        tryAccessConstructor(ctor1, true);
-        tryAccessConstructor(ctor2, false);
-        tryAccessMethod(m1, true);
-        tryAccessMethod(m2, false);
-        tryAccessObjectField(f1, true);
-        tryAccessObjectField(f2, false);
-
-        trySetAccessible(ctor1, true);
-        trySetAccessible(ctor2, true);
-        trySetAccessible(m1, true);
-        trySetAccessible(m2, true);
-        trySetAccessible(f1, true);
-        trySetAccessible(f2, true);
-    }
-
-    static void testNonPublicClassInExportedPackage() throws Exception {
-        Module thisModule = Main.class.getModule();
-        Module targetModule = getTargetModule();
-
-        assertTrue(targetModule.isExported("p2"));
-        assertTrue(targetModule.isExported("p2", thisModule));
-        assertTrue(targetModule.isExported("p2", targetModule));
-
-        assertFalse(targetModule.isOpen("p2"));
-        assertFalse(targetModule.isOpen("p2", thisModule));
-        assertTrue(targetModule.isOpen("p1", targetModule));
-
-        Class<?> clazz = Class.forName("p2.NonPublic");
-        Constructor<?> ctor1 = clazz.getConstructor();
-        Constructor<?> ctor2 = clazz.getDeclaredConstructor(Void.class);
-
-        Field f1 = clazz.getField("f1");    // public
-        Field f2 = clazz.getDeclaredField("f2");    // non-public
-
-        Method m1 = clazz.getMethod("foo");  // public
-        Method m2 = clazz.getDeclaredMethod("bar");  // non-public
-
-        tryAccessConstructor(ctor1, false);
-        tryAccessConstructor(ctor2, false);
-        tryAccessMethod(m1, false);
-        tryAccessMethod(m2, false);
-        tryAccessObjectField(f1, false);
-        tryAccessObjectField(f2, false);
-
-        trySetAccessible(ctor1, false);
-        trySetAccessible(ctor2, false);
-        trySetAccessible(m1, false);
-        trySetAccessible(m2, false);
-        trySetAccessible(f1, false);
-        trySetAccessible(f2, false);
-
-        targetAddExports("p2", thisModule);
-
-        tryAccessConstructor(ctor1, false);
-        tryAccessConstructor(ctor2, false);
-        tryAccessMethod(m1, false);
-        tryAccessMethod(m2, false);
-        tryAccessObjectField(f1, false);
-        tryAccessObjectField(f2, false);
-
-        trySetAccessible(ctor1, false);
-        trySetAccessible(ctor2, false);
-        trySetAccessible(m1, false);
-        trySetAccessible(m2, false);
-        trySetAccessible(f1, false);
-        trySetAccessible(f2, false);
-
-        targetAddOpens("p2", thisModule);
-
-        tryAccessConstructor(ctor1, false);
-        tryAccessConstructor(ctor2, false);
-        tryAccessMethod(m1, false);
-        tryAccessMethod(m2, false);
-        tryAccessObjectField(f1, false);
-        tryAccessObjectField(f2, false);
-
-        trySetAccessible(ctor1, true);
-        trySetAccessible(ctor2, true);
-        trySetAccessible(m1, true);
-        trySetAccessible(m2, true);
-        trySetAccessible(f1, true);
-        trySetAccessible(f2, true);
-    }
-
-    static void testPublicClassInNonExportedPackage() throws Exception {
-        Module thisModule = Main.class.getModule();
-        Module targetModule = getTargetModule();
-
-        assertFalse(targetModule.isExported("q1"));
-        assertFalse(targetModule.isExported("q1", thisModule));
-        assertTrue(targetModule.isExported("q1", targetModule));
-
-        assertFalse(targetModule.isOpen("q1"));
-        assertFalse(targetModule.isOpen("q1", thisModule));
-        assertTrue(targetModule.isOpen("q1", targetModule));
-
-        Class<?> clazz = Class.forName("q1.Public");
-        Constructor<?> ctor1 = clazz.getConstructor();  // public
-        Constructor<?> ctor2 = clazz.getDeclaredConstructor(Void.class);  // non-public
-
-        Field f1 = clazz.getField("f1");    // public
-        Field f2 = clazz.getDeclaredField("f2");    // non-public
-
-        Method m1 = clazz.getMethod("foo");  // public
-        Method m2 = clazz.getDeclaredMethod("bar");  // non-public
-
-        tryAccessConstructor(ctor1, false);
-        tryAccessConstructor(ctor2, false);
-        tryAccessMethod(m1, false);
-        tryAccessMethod(m2, false);
-        tryAccessObjectField(f1, false);
-        tryAccessObjectField(f2, false);
-
-        trySetAccessible(ctor1, false);
-        trySetAccessible(ctor2, false);
-        trySetAccessible(m1, false);
-        trySetAccessible(m2, false);
-        trySetAccessible(f1, false);
-        trySetAccessible(f2, false);
-
-        targetAddExports("q1", thisModule);
-
-        tryAccessConstructor(ctor1, true);
-        tryAccessConstructor(ctor2, false);
-        tryAccessMethod(m1, true);
-        tryAccessMethod(m2, false);
-        tryAccessObjectField(f1, true);
-        tryAccessObjectField(f2, false);
-
-        trySetAccessible(ctor1, true);
-        trySetAccessible(ctor2, false);
-        trySetAccessible(m1, true);
-        trySetAccessible(m2, false);
-        trySetAccessible(f1, true);
-        trySetAccessible(f2, false);
-
-        targetAddOpens("q1", thisModule);
-
-        tryAccessConstructor(ctor1, true);
-        tryAccessConstructor(ctor1, false);
-        tryAccessMethod(m1, true);
-        tryAccessMethod(m2, false);
-        tryAccessObjectField(f1, true);
-        tryAccessObjectField(f2, false);
-
-        trySetAccessible(ctor1, true);
-        trySetAccessible(ctor2, true);
-        trySetAccessible(m1, true);
-        trySetAccessible(m2, true);
-        trySetAccessible(f1, true);
-        trySetAccessible(f2, true);
-    }
-
-    static void testNonPublicClassInNonExportedPackage() throws Exception {
-        Module thisModule = Main.class.getModule();
-        Module targetModule = getTargetModule();
-
-        assertFalse(targetModule.isExported("q2"));
-        assertFalse(targetModule.isExported("q2", thisModule));
-        assertTrue(targetModule.isExported("q2", targetModule));
-
-        assertFalse(targetModule.isOpen("q2"));
-        assertFalse(targetModule.isOpen("q2", thisModule));
-        assertTrue(targetModule.isOpen("q2", targetModule));
-
-        Class<?> clazz = Class.forName("q2.NonPublic");
-        Constructor<?> ctor1 = clazz.getConstructor();  // public
-        Constructor<?> ctor2 = clazz.getDeclaredConstructor(Void.class);  // non-public
-
-        Field f1 = clazz.getField("f1");    // public
-        Field f2 = clazz.getDeclaredField("f2");    // non-public
-
-        Method m1 = clazz.getMethod("foo");  // public
-        Method m2 = clazz.getDeclaredMethod("bar");  // non-public
-
-        tryAccessConstructor(ctor1, false);
-        tryAccessConstructor(ctor2, false);
-        tryAccessMethod(m1, false);
-        tryAccessMethod(m2, false);
-        tryAccessObjectField(f1, false);
-        tryAccessObjectField(f2, false);
-
-        trySetAccessible(ctor1, false);
-        trySetAccessible(ctor2, false);
-        trySetAccessible(m1, false);
-        trySetAccessible(m2, false);
-        trySetAccessible(f1, false);
-        trySetAccessible(f2, false);
-
-        targetAddExports("q2", thisModule);
-
-        tryAccessConstructor(ctor1, false);
-        tryAccessConstructor(ctor2, false);
-        tryAccessMethod(m1, false);
-        tryAccessMethod(m2, false);
-        tryAccessObjectField(f1, false);
-        tryAccessObjectField(f2, false);
-
-        trySetAccessible(ctor1, false);
-        trySetAccessible(ctor2, false);
-        trySetAccessible(m1, false);
-        trySetAccessible(m2, false);
-        trySetAccessible(f1, false);
-        trySetAccessible(f2, false);
-
-        targetAddOpens("q2", thisModule);
-
-        tryAccessConstructor(ctor1, false);
-        tryAccessConstructor(ctor2, false);
-        tryAccessMethod(m1, false);
-        tryAccessMethod(m2, false);
-        tryAccessObjectField(f1, false);
-        tryAccessObjectField(f2, false);
-
-        trySetAccessible(ctor1, true);
-        trySetAccessible(m1, true);
-        trySetAccessible(m2, true);
-        trySetAccessible(f1, true);
-        trySetAccessible(f2, true);
-    }
-
-
-    static Module getTargetModule() {
-        return Layer.boot().findModule("target").get();
-    }
-
-    static void tryAccessConstructor(Constructor<?> ctor, boolean shouldSucceed) {
-        try {
-            ctor.newInstance();
-            assertTrue(shouldSucceed);
-        } catch (Exception e) {
-            assertFalse(shouldSucceed);
-        }
-    }
-
-    static void tryAccessMethod(Method method, boolean shouldSucceed) {
-        try {
-            method.invoke(null);
-            assertTrue(shouldSucceed);
-        } catch (Exception e) {
-            e.printStackTrace();
-            assertFalse(shouldSucceed);
-        }
-    }
-
-    static void tryAccessObjectField(Field f, boolean shouldSucceed) {
-        try {
-            f.get(null);
-            assertTrue(shouldSucceed);
-        } catch (Exception e) {
-            assertFalse(shouldSucceed);
-        }
-        try {
-            f.set(null, new Object());
-            assertTrue(shouldSucceed);
-        } catch (Exception e) {
-            assertFalse(shouldSucceed);
-        }
-    }
-
-    static void trySetAccessible(AccessibleObject ao, boolean shouldSucceed) {
-        try {
-            ao.setAccessible(true);
-            assertTrue(shouldSucceed);
-        } catch (Exception e) {
-            assertFalse(shouldSucceed);
-        }
-    }
-
-    /**
-     * Update target module to export a package to the given module.
-     */
-    static void targetAddExports(String pn, Module who) throws Exception {
-        Class<?> helper = Class.forName("p1.Helper");
-        Method m = helper.getMethod("addExports", String.class, Module.class);
-        m.invoke(null, pn, who);
-    }
-
-    /**
-     * Update target module to open a package to the given module.
-     */
-    static void targetAddOpens(String pn, Module who) throws Exception {
-        Class<?> helper = Class.forName("p1.Helper");
-        Method m = helper.getMethod("addOpens", String.class, Module.class);
-        m.invoke(null, pn, who);
-    }
-
-    static void assertTrue(boolean expr) {
-        if (!expr) throw new RuntimeException();
-    }
-
-    static void assertFalse(boolean expr) {
-        assertTrue(!expr);
-    }
-}
--- a/jdk/test/java/lang/reflect/Module/addXXX/Driver.java	Tue Apr 18 13:19:42 2017 -0400
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,29 +0,0 @@
-/*
- * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-/**
- * @test
- * @build test/* m1/* m2/* m3/* m4/*
- * @run testng/othervm test/test.Main
- * @summary Basic test case for Module::addXXX methods
- */
--- a/jdk/test/java/lang/reflect/Module/addXXX/m1/module-info.java	Tue Apr 18 13:19:42 2017 -0400
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,25 +0,0 @@
-/*
- * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-module m1 {
-    exports p1;
-}
--- a/jdk/test/java/lang/reflect/Module/addXXX/m1/p1/C.java	Tue Apr 18 13:19:42 2017 -0400
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,27 +0,0 @@
-/*
- * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-package p1;
-
-public class C {
-    public C() { }
-}
--- a/jdk/test/java/lang/reflect/Module/addXXX/m2/module-info.java	Tue Apr 18 13:19:42 2017 -0400
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,25 +0,0 @@
-/*
- * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-module m2 {
-    exports p2;
-}
--- a/jdk/test/java/lang/reflect/Module/addXXX/m2/p2/C.java	Tue Apr 18 13:19:42 2017 -0400
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,32 +0,0 @@
-/*
- * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-package p2;
-
-import java.lang.reflect.Module;
-
-public class C {
-
-    public static void export(String pn, Module m) {
-        C.class.getModule().addExports(pn, m);
-    }
-}
--- a/jdk/test/java/lang/reflect/Module/addXXX/m2/p2/internal/C.java	Tue Apr 18 13:19:42 2017 -0400
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,26 +0,0 @@
-/*
- * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-package p2.internal;
-
-public class C {
-}
--- a/jdk/test/java/lang/reflect/Module/addXXX/m3/module-info.java	Tue Apr 18 13:19:42 2017 -0400
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,26 +0,0 @@
-/*
- * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-module m3 {
-    exports p3 to test;
-    opens p3 to test;
-}
--- a/jdk/test/java/lang/reflect/Module/addXXX/m3/p3/C.java	Tue Apr 18 13:19:42 2017 -0400
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,26 +0,0 @@
-/*
- * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-package p3;
-
-public class C {
-}
--- a/jdk/test/java/lang/reflect/Module/addXXX/m4/module-info.java	Tue Apr 18 13:19:42 2017 -0400
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,25 +0,0 @@
-/*
- * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-module m4 {
-    exports p4;
-}
--- a/jdk/test/java/lang/reflect/Module/addXXX/m4/p4/C.java	Tue Apr 18 13:19:42 2017 -0400
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,32 +0,0 @@
-/*
- * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-package p4;
-
-import java.lang.reflect.Constructor;
-
-public class C {
-    public static Object tryNewInstance(Class<?> clazz) throws Exception {
-        Constructor<?> ctor = clazz.getDeclaredConstructor();
-        return ctor.newInstance();
-    }
-}
--- a/jdk/test/java/lang/reflect/Module/addXXX/test/module-info.java	Tue Apr 18 13:19:42 2017 -0400
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,30 +0,0 @@
-/*
- * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-module test {
-    exports test to testng;
-
-    requires m2;
-    requires m3;
-    requires m4;
-    requires testng;
-}
--- a/jdk/test/java/lang/reflect/Module/addXXX/test/test/C.java	Tue Apr 18 13:19:42 2017 -0400
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,26 +0,0 @@
-/*
- * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package test;
-
-public class C { }
--- a/jdk/test/java/lang/reflect/Module/addXXX/test/test/Main.java	Tue Apr 18 13:19:42 2017 -0400
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,196 +0,0 @@
-/*
- * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package test;
-
-import java.lang.invoke.MethodHandle;
-import java.lang.invoke.MethodHandles;
-import java.lang.invoke.MethodType;
-import java.lang.reflect.Constructor;
-import java.lang.reflect.Module;
-import java.util.ServiceConfigurationError;
-import java.util.ServiceLoader;
-
-import org.testng.annotations.Test;
-import static org.testng.Assert.*;
-
-/**
- * Basic test case for Module::addXXXX methods
- */
-
-@Test
-public class Main {
-
-    /**
-     * Test Module::addReads
-     *
-     *     module test { }
-     *
-     *     module m1 {
-     *         exports p1;
-     *     }
-     */
-    public void testAddReads() throws Throwable {
-        Module thisModule = Main.class.getModule();
-        Class<?> clazz = Class.forName("p1.C");
-        Module m1 = clazz.getModule();
-
-        // test does not read m1
-        assertFalse(thisModule.canRead(m1));
-        MethodHandles.Lookup lookup = MethodHandles.lookup();
-        MethodType mt = MethodType.methodType(void.class);
-        try {
-            lookup.findConstructor(clazz, mt);
-            assertTrue(false);
-        } catch (IllegalAccessException expected) { }
-
-        // update test to read m1
-        Module result = thisModule.addReads(m1);
-        assertTrue(result== thisModule);
-        assertTrue(thisModule.canRead(m1));
-        MethodHandle mh = lookup.findConstructor(clazz, mt);
-        Object obj = mh.invoke();
-
-        // attempt to update m1 to read test
-        try {
-            m1.addReads(thisModule);
-            assertTrue(false);
-        } catch (IllegalCallerException expected) { }
-    }
-
-
-    /**
-     * Test Module::addExports
-     *
-     *     module test {
-     *         requires m2;
-     *     }
-     *     module m2 {
-     *         exports p2;
-     *         contains package p2.internal;
-     *     }
-     */
-    public void testAddExports() throws Exception {
-        Module thisModule = Main.class.getModule();
-        Module m2 = p2.C.class.getModule();
-        Class<?> targetClass = Class.forName("p2.internal.C");
-        String p2Internal = targetClass.getPackageName();
-        assertTrue(targetClass.getModule() == m2);
-
-        // m2 does not export p2.internal to test
-        assertFalse(m2.isExported(p2Internal, thisModule));
-        Constructor<?> ctor = targetClass.getDeclaredConstructor();
-        try {
-            ctor.newInstance();
-            assertTrue(false);
-        } catch (IllegalAccessException expected) { }
-
-        // update m2 to export p2.internal to test
-        p2.C.export(p2Internal, thisModule);
-        assertTrue(m2.isExported(p2Internal, thisModule));
-        ctor.newInstance(); // should succeed
-
-        // attempt to update m2 to export a package to test
-        try {
-            m2.addExports("p2.other", thisModule);
-            assertTrue(false);
-        } catch (IllegalCallerException expected) { }
-    }
-
-    /**
-     * Test Module::addOpens
-     *
-     *     module test {
-     *         requires m3;
-     *         requires m4;
-     *     }
-     *
-     *     module m3 {
-     *         exports p3 to test;
-     *         opens p3 to test;
-     *     }
-     *
-     *     module m4 {
-     *         exports p4;
-     *     }
-     */
-    public void testAddOpens() throws Exception {
-        Module thisModule = Main.class.getModule();
-        Module m3 = p3.C.class.getModule();
-        Module m4 = p4.C.class.getModule();
-
-        // test does not open package test to m4
-        assertFalse(thisModule.isOpen("test", m4));
-        try {
-            p4.C.tryNewInstance(test.C.class);
-            assertTrue(false);
-        } catch (IllegalAccessException expected) { }
-
-        // open test to m4
-        thisModule.addOpens("test", m4);
-        p4.C.tryNewInstance(test.C.class);  // should succeed
-
-
-        // m3 does not open p3 to m4
-        assertFalse(m3.isOpen("p3", m4));
-        try {
-            p4.C.tryNewInstance(p3.C.class);
-            assertTrue(false);
-        } catch (IllegalAccessException expected) { }
-
-
-        // m3 opens p3 to test => test allowed to open m3/p3 to m4
-        assertTrue(m3.isOpen("p3", thisModule));
-        m3.addOpens("p3", m4);
-        assertTrue(m3.isOpen("p3", m4));
-        p4.C.tryNewInstance(p3.C.class);   // should succeed
-
-
-        // attempt to update m4 to open package to m3
-        try {
-            m4.addOpens("p4", m3);
-            assertTrue(false);
-        } catch (IllegalCallerException expected) { }
-    }
-
-
-    /**
-     * Test Module::addUses
-     */
-    public void testAddUses() {
-        Module thisModule = Main.class.getModule();
-
-        assertFalse(thisModule.canUse(Service.class));
-        try {
-            ServiceLoader.load(Service.class);
-            assertTrue(false);
-        } catch (ServiceConfigurationError expected) { }
-
-        Module result = thisModule.addUses(Service.class);
-        assertTrue(result== thisModule);
-
-        assertTrue(thisModule.canUse(Service.class));
-        ServiceLoader.load(Service.class); // no exception
-    }
-
-}
--- a/jdk/test/java/lang/reflect/Module/addXXX/test/test/Service.java	Tue Apr 18 13:19:42 2017 -0400
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,29 +0,0 @@
-/*
- * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package test;
-
-/**
- * Simple service type
- */
-public interface Service { }
--- a/jdk/test/java/lang/reflect/Module/allow.policy	Tue Apr 18 13:19:42 2017 -0400
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,28 +0,0 @@
-/*
- * Copyright (c) 2016, 2017, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * 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.
- */
-
-grant {
-    permission java.lang.RuntimePermission "getClassLoader";
-    permission java.lang.RuntimePermission "accessSystemModules";
-    permission java.io.FilePermission "${java.home}/modules/-", "read";    // exploded build
-};
--- a/jdk/test/java/lang/reflect/Module/annotation/Basic.java	Tue Apr 18 13:19:42 2017 -0400
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,77 +0,0 @@
-/*
- * 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
- * @library src
- * @build m/* Basic
- * @run testng/othervm Basic
- * @summary Basic test for annotations on modules
- */
-
-import java.lang.reflect.Module;
-import java.util.Arrays;
-
-import p.annotation.Foo;
-import p.annotation.Bar;
-import p.annotation.Baz;
-
-import org.testng.annotations.Test;
-import static org.testng.Assert.*;
-
-public class Basic {
-
-    final Module module = Foo.class.getModule();
-
-    /**
-     * {@code @Foo} does not have RUNTIME retention policy.
-     */
-    @Test
-    public void testInvisibleAnnotation() {
-        assertFalse(module.isAnnotationPresent(Foo.class));
-        assertNull(module.getAnnotation(Foo.class));
-    }
-
-    /**
-     * {@code @Bar} has RUNTIME retention policy and value "bar"
-     */
-    @Test
-    public void testBarAnnotation() {
-        assertTrue(module.isAnnotationPresent(Bar.class));
-        Bar bar = module.getAnnotation(Bar.class);
-        assertNotNull(bar);
-        assertEquals(bar.value(), "bar");
-    }
-
-    /**
-     * {@code @Baz} has RUNTIME retention policy has a repeating value
-     */
-    @Test
-    public void testBazAnnotation() {
-        assertTrue(module.isAnnotationPresent(Baz.class));
-        Baz baz = module.getAnnotation(Baz.class);
-        assertNotNull(baz);
-        String[] expected = { "one", "two", "three" };
-        assertTrue(Arrays.equals(baz.value(), expected));
-    }
-}
--- a/jdk/test/java/lang/reflect/Module/annotation/src/m/module-info.java	Tue Apr 18 13:19:42 2017 -0400
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,31 +0,0 @@
-/*
- * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-import p.annotation.*;
-
-@Foo
-@Bar("bar")
-@Baz({"one", "two", "three"})
-module m {
-    exports p.annotation;
-}
--- a/jdk/test/java/lang/reflect/Module/annotation/src/m/p/annotation/Bar.java	Tue Apr 18 13:19:42 2017 -0400
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,35 +0,0 @@
-/*
- * 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.
- */
-
-package p.annotation;
-
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-import static java.lang.annotation.ElementType.MODULE;
-
-@Retention(RetentionPolicy.RUNTIME)
-@Target(value={MODULE})
-public @interface Bar {
-   String value();
-}
--- a/jdk/test/java/lang/reflect/Module/annotation/src/m/p/annotation/Baz.java	Tue Apr 18 13:19:42 2017 -0400
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,35 +0,0 @@
-/*
- * 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.
- */
-
-package p.annotation;
-
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-import static java.lang.annotation.ElementType.MODULE;
-
-@Target(value={MODULE})
-@Retention(RetentionPolicy.RUNTIME)
-public @interface Baz {
-   String[] value();
-}
--- a/jdk/test/java/lang/reflect/Module/annotation/src/m/p/annotation/Foo.java	Tue Apr 18 13:19:42 2017 -0400
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,30 +0,0 @@
-/*
- * 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.
- */
-
-package p.annotation;
-
-import java.lang.annotation.Target;
-import static java.lang.annotation.ElementType.MODULE;
-
-@Target(value={MODULE})
-public @interface Foo {}
--- a/jdk/test/java/lang/reflect/Proxy/ProxyClassAccessTest.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/jdk/test/java/lang/reflect/Proxy/ProxyClassAccessTest.java	Tue Apr 18 22:25:33 2017 +0200
@@ -23,7 +23,6 @@
 
 import java.lang.module.Configuration;
 import java.lang.module.ModuleFinder;
-import java.lang.reflect.Layer;
 import java.lang.reflect.Proxy;
 import java.nio.file.Path;
 import java.nio.file.Paths;
@@ -88,12 +87,12 @@
     @Test
     public void testNoReadAccess() throws Exception {
         ModuleFinder finder = ModuleFinder.of(MODS_DIR);
-        Layer bootLayer = Layer.boot();
+        ModuleLayer bootLayer = ModuleLayer.boot();
         Configuration cf = bootLayer
                 .configuration()
                 .resolveAndBind(ModuleFinder.of(), finder, modules);
         ClassLoader parentLoader = this.getClass().getClassLoader();
-        Layer layer = bootLayer.defineModulesWithOneLoader(cf, parentLoader);
+        ModuleLayer layer = bootLayer.defineModulesWithOneLoader(cf, parentLoader);
 
         ClassLoader loader = layer.findLoader("m1");
         Class<?>[] interfaces = new Class<?>[] {
--- a/jdk/test/java/lang/reflect/Proxy/ProxyForMethodHandle.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/jdk/test/java/lang/reflect/Proxy/ProxyForMethodHandle.java	Tue Apr 18 22:25:33 2017 +0200
@@ -28,7 +28,6 @@
 import java.lang.reflect.Constructor;
 import java.lang.reflect.InvocationHandler;
 import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Module;
 
 import org.testng.annotations.BeforeTest;
 import org.testng.annotations.Test;
--- a/jdk/test/java/lang/reflect/Proxy/ProxyLayerTest.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/jdk/test/java/lang/reflect/Proxy/ProxyLayerTest.java	Tue Apr 18 22:25:33 2017 +0200
@@ -24,7 +24,6 @@
 import java.lang.module.Configuration;
 import java.lang.module.ModuleFinder;
 import java.lang.reflect.InvocationHandler;
-import java.lang.reflect.Layer;
 import java.lang.reflect.Proxy;
 import java.nio.file.Path;
 import java.nio.file.Paths;
@@ -70,18 +69,18 @@
     }
 
     /**
-     * Test proxy implementing interfaces in a Layer defined in
+     * Test proxy implementing interfaces in a layer defined in
      * an unnamed module
      */
     @Test
     public void testProxyInUnnamed() throws Exception {
         ModuleFinder finder = ModuleFinder.of(MODS_DIR);
-        Layer bootLayer = Layer.boot();
+        ModuleLayer bootLayer = ModuleLayer.boot();
         Configuration cf = bootLayer
                 .configuration()
                 .resolveAndBind(ModuleFinder.of(), finder, Arrays.asList(modules));
         ClassLoader scl = ClassLoader.getSystemClassLoader();
-        Layer layer = bootLayer.defineModulesWithOneLoader(cf, scl);
+        ModuleLayer layer = bootLayer.defineModulesWithOneLoader(cf, scl);
 
         ClassLoader loader = layer.findLoader("m1");
 
@@ -110,12 +109,12 @@
     @Test
     public void testProxyInDynamicModule() throws Exception {
         ModuleFinder finder = ModuleFinder.of(MODS_DIR);
-        Layer bootLayer = Layer.boot();
+        ModuleLayer bootLayer = ModuleLayer.boot();
         Configuration cf = bootLayer
                 .configuration()
                 .resolveAndBind(ModuleFinder.of(), finder, Arrays.asList(modules));
         ClassLoader scl = ClassLoader.getSystemClassLoader();
-        Layer layer = bootLayer.defineModulesWithOneLoader(cf, scl);
+        ModuleLayer layer = bootLayer.defineModulesWithOneLoader(cf, scl);
 
         ClassLoader loader = layer.findLoader("m1");
 
@@ -140,12 +139,12 @@
     @Test
     public void testNoReadAccess() throws Exception {
         ModuleFinder finder = ModuleFinder.of(MODS_DIR);
-        Layer bootLayer = Layer.boot();
+        ModuleLayer bootLayer = ModuleLayer.boot();
         Configuration cf = bootLayer
                 .configuration()
                 .resolveAndBind(ModuleFinder.of(), finder, Arrays.asList(modules));
         ClassLoader scl = ClassLoader.getSystemClassLoader();
-        Layer layer = bootLayer.defineModulesWithOneLoader(cf, scl);
+        ModuleLayer layer = bootLayer.defineModulesWithOneLoader(cf, scl);
 
         ClassLoader loader = layer.findLoader("m1");
 
--- a/jdk/test/java/lang/reflect/Proxy/ProxyModuleMapping.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/jdk/test/java/lang/reflect/Proxy/ProxyModuleMapping.java	Tue Apr 18 22:25:33 2017 +0200
@@ -23,7 +23,6 @@
 
 import java.lang.reflect.Constructor;
 import java.lang.reflect.InvocationHandler;
-import java.lang.reflect.Module;
 import java.lang.reflect.Proxy;
 
 /*
--- a/jdk/test/java/lang/reflect/Proxy/src/test/jdk/test/Main.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/jdk/test/java/lang/reflect/Proxy/src/test/jdk/test/Main.java	Tue Apr 18 22:25:33 2017 +0200
@@ -25,7 +25,6 @@
 
 import java.net.URL;
 import java.net.URLClassLoader;
-import java.lang.reflect.Module;
 import static jdk.test.ProxyTest.*;
 
 public class Main {
--- a/jdk/test/java/lang/reflect/Proxy/src/test/jdk/test/ProxyTest.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/jdk/test/java/lang/reflect/Proxy/src/test/jdk/test/ProxyTest.java	Tue Apr 18 22:25:33 2017 +0200
@@ -26,7 +26,6 @@
 import java.lang.reflect.Constructor;
 import java.lang.reflect.InvocationHandler;
 import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Module;
 import java.lang.reflect.Proxy;
 import java.util.Arrays;
 
--- a/jdk/test/java/lang/reflect/WeakPairMap/Driver.java	Tue Apr 18 13:19:42 2017 -0400
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,35 +0,0 @@
-/*
- * 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 8888888
- * @summary Functional test for WeakPairMap
- * @build java.base/java.lang.reflect.WeakPairMapTest
- * @run main Driver
- */
-public class Driver {
-    public static void main(String[] args) {
-        java.lang.reflect.WeakPairMapTest.main(args);
-    }
-}
--- a/jdk/test/java/lang/reflect/WeakPairMap/java.base/java/lang/reflect/WeakPairMapTest.java	Tue Apr 18 13:19:42 2017 -0400
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,175 +0,0 @@
-/*
- * 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.
- */
-
-package java.lang.reflect;
-
-import java.lang.ref.Reference;
-import java.util.Objects;
-
-/**
- * Functional test for WeakPairMap
- *
- * @author Peter Levart
- */
-public class WeakPairMapTest {
-    public static void main(String[] args) {
-        WeakPairMap<Object, Object, String> pm = new WeakPairMap<>();
-        Object key1 = new Object();
-        Object key2 = new Object();
-
-        // check for emptiness
-        assertEquals(pm.containsKeyPair(key1, key2), false);
-        assertEquals(pm.get(key1, key2), null);
-
-        // check for NPE(s)
-        for (Object k1 : new Object[]{null, key1}) {
-            for (Object k2 : new Object[]{null, key2}) {
-                for (String v : new String[]{null, "abc"}) {
-
-                    if (k1 != null && k2 != null && v != null) {
-                        // skip non-null args
-                        continue;
-                    }
-
-                    try {
-                        pm.put(k1, k2, v);
-                        throw new AssertionError("Unexpected code path, k1=" +
-                                                 k1 + ", k2=" + k2 + ", v=" + v);
-                    } catch (NullPointerException e) {
-                        // expected
-                    }
-
-                    try {
-                        pm.putIfAbsent(k1, k2, v);
-                        throw new AssertionError("Unexpected code path, k1=" +
-                                                 k1 + ", k2=" + k2 + ", v=" + v);
-                    } catch (NullPointerException e) {
-                        // expected
-                    }
-
-                    if (k1 != null && k2 != null) {
-                        // skip non-null args
-                        continue;
-                    }
-
-                    try {
-                        pm.computeIfAbsent(k1, k2, (_k1, _k2) -> v);
-                        throw new AssertionError("Unexpected code path, k1=" +
-                                                 k1 + ", k2=" + k2 + ", v=" + v);
-                    } catch (NullPointerException e) {
-                        // expected
-                    }
-
-                    try {
-                        pm.containsKeyPair(k1, k2);
-                        throw new AssertionError("Unexpected code path, k1=" +
-                                                 k1 + ", k2=" + k2);
-                    } catch (NullPointerException e) {
-                        // expected
-                    }
-
-                    try {
-                        pm.get(k1, k2);
-                        throw new AssertionError("Unexpected code path, k1=" +
-                                                 k1 + ", k2=" + k2);
-                    } catch (NullPointerException e) {
-                        // expected
-                    }
-                }
-            }
-        }
-
-        // how much to wait when it is expected for entry to be retained
-        final long retentionTimeout = 500L;
-        // how much to wait when it is expected for entry to be removed
-        final long cleanupTimeout = 30_000L;
-
-        // check insertion
-        assertEquals(pm.putIfAbsent(key1, key2, "abc"), null);
-        assertEquals(pm.get(key1, key2), "abc");
-
-        // check retention while both keys are still reachable
-        assertEquals(gcAndWaitRemoved(pm, "abc", retentionTimeout), false);
-        assertEquals(pm.get(key1, key2), "abc");
-
-        // check cleanup when both keys are unreachable
-        key1 = null;
-        key2 = null;
-        assertEquals(gcAndWaitRemoved(pm, "abc", cleanupTimeout), true);
-
-        // new insertion
-        key1 = new Object();
-        key2 = new Object();
-        assertEquals(pm.putIfAbsent(key1, key2, "abc"), null);
-        assertEquals(pm.get(key1, key2), "abc");
-
-        // check retention while both keys are still reachable
-        assertEquals(gcAndWaitRemoved(pm, "abc", retentionTimeout), false);
-        assertEquals(pm.get(key1, key2), "abc");
-
-        // check cleanup when 1st key is unreachable
-        key1 = null;
-        assertEquals(gcAndWaitRemoved(pm, "abc", cleanupTimeout), true);
-        Reference.reachabilityFence(key2);
-
-        // new insertion
-        key1 = new Object();
-        key2 = new Object();
-        assertEquals(pm.putIfAbsent(key1, key2, "abc"), null);
-        assertEquals(pm.get(key1, key2), "abc");
-
-        // check retention while both keys are still reachable
-        assertEquals(gcAndWaitRemoved(pm, "abc", retentionTimeout), false);
-        assertEquals(pm.get(key1, key2), "abc");
-
-        // check cleanup when 2nd key is unreachable
-        key2 = null;
-        assertEquals(gcAndWaitRemoved(pm, "abc", cleanupTimeout), true);
-        Reference.reachabilityFence(key1);
-    }
-
-    /**
-     * Trigger GC and wait for at most {@code millis} ms for given value to
-     * be removed from given WeakPairMap.
-     *
-     * @return true if element has been removed or false if not
-     */
-    static <V> boolean gcAndWaitRemoved(WeakPairMap<?, ?, V> pm, V value,
-                                        long millis) {
-        System.gc();
-        for (int i = 0; i < (millis + 99) / 100 && pm.values().contains(value); i++) {
-            try {
-                Thread.sleep(100L);
-            } catch (InterruptedException e) {
-                throw new AssertionError("Interrupted");
-            }
-        }
-        return !pm.values().contains(value);
-    }
-
-    static void assertEquals(Object actual, Object expected) {
-        if (!Objects.equals(actual, expected)) {
-            throw new AssertionError("Expected: " + expected + ", actual: " + actual);
-        }
-    }
-}
--- a/jdk/test/java/nio/channels/SocketChannel/VectorIO.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/jdk/test/java/nio/channels/SocketChannel/VectorIO.java	Tue Apr 18 22:25:33 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -22,8 +22,10 @@
  */
 
 /* @test
- * @summary Test socketchannel vector IO
- * @library ..
+ * @summary Test socketchannel vector IO (use -Dseed=X to set PRNG seed)
+ * @library .. /lib/testlibrary/
+ * @build jdk.testlibrary.RandomFactory
+ * @run main VectorIO
  * @key randomness
  */
 
@@ -32,11 +34,11 @@
 import java.nio.*;
 import java.nio.channels.*;
 import java.util.*;
-
+import jdk.testlibrary.RandomFactory;
 
 public class VectorIO {
 
-    static Random generator = new Random();
+    private static Random generator = RandomFactory.getRandom();
 
     static int testSize;
 
@@ -100,8 +102,6 @@
     static class Server
         extends TestThread
     {
-        static Random generator = new Random();
-
         final int testSize;
         final ServerSocketChannel ssc;
 
--- a/jdk/test/java/nio/channels/etc/AdaptorCloseAndInterrupt.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/jdk/test/java/nio/channels/etc/AdaptorCloseAndInterrupt.java	Tue Apr 18 22:25:33 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2012, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -36,6 +36,7 @@
 import java.util.concurrent.Executors;
 import java.util.concurrent.ScheduledExecutorService;
 import java.util.concurrent.TimeUnit;
+import java.util.concurrent.atomic.AtomicBoolean;
 import java.util.Random;
 
 
@@ -46,6 +47,9 @@
     final DatagramChannel peer;
     final int port;
 
+    final AtomicBoolean isClosed = new AtomicBoolean();
+    final AtomicBoolean isInterrupted = new AtomicBoolean();
+
     public AdaptorCloseAndInterrupt() {
         listener = null;
         peer = null;
@@ -96,6 +100,7 @@
 
             try {
                 sc.socket().getInputStream().read(new byte[100]);
+                System.err.format("close() was invoked: %s%n", isClosed.get());
                 throw new RuntimeException("read should not have completed");
             } catch (ClosedChannelException expected) {}
 
@@ -119,7 +124,10 @@
                 sc.socket().getInputStream().read(new byte[100]);
                 throw new RuntimeException("read should not have completed");
             } catch (ClosedByInterruptException expected) {
-                Thread.currentThread().interrupted();
+                System.out.format("interrupt() was invoked: %s%n",
+                    isInterrupted.get());
+                System.out.format("scReadAsyncInterrupt was interrupted: %s%n",
+                    Thread.currentThread().interrupted());
             }
 
             if (!sc.socket().isClosed())
@@ -140,6 +148,7 @@
 
         try {
             dc.socket().receive(new DatagramPacket(new byte[100], 100));
+            System.err.format("close() was invoked: %s%n", isClosed.get());
             throw new RuntimeException("receive should not have completed");
         } catch (ClosedChannelException expected) {}
 
@@ -159,7 +168,16 @@
             dc.socket().receive(new DatagramPacket(new byte[100], 100));
             throw new RuntimeException("receive should not have completed");
         } catch (ClosedByInterruptException expected) {
-            Thread.currentThread().interrupted();
+            System.out.format("interrupt() was invoked: %s%n",
+                isInterrupted.get());
+            System.out.format("dcReceiveAsyncInterrupt was interrupted: %s%n",
+                Thread.currentThread().interrupted());
+        } catch (SocketTimeoutException unexpected) {
+            System.err.format("Receive thread interrupt invoked: %s%n",
+                isInterrupted.get());
+            System.err.format("Receive thread was interrupted: %s%n",
+                Thread.currentThread().isInterrupted());
+            throw unexpected;
         }
 
         if (!dc.socket().isClosed())
@@ -175,6 +193,7 @@
 
         try {
             ssc.socket().accept();
+            System.err.format("close() was invoked: %s%n", isClosed.get());
             throw new RuntimeException("accept should not have completed");
         } catch (ClosedChannelException expected) {}
 
@@ -193,7 +212,10 @@
             ssc.socket().accept();
             throw new RuntimeException("accept should not have completed");
         } catch (ClosedByInterruptException expected) {
-            Thread.currentThread().interrupted();
+            System.out.format("interrupt() was invoked: %s%n",
+                isInterrupted.get());
+            System.out.format("ssAcceptAsyncInterrupt was interrupted: %s%n",
+                Thread.currentThread().interrupted());
         }
 
         if (!ssc.socket().isClosed())
@@ -204,6 +226,7 @@
         AdaptorCloseAndInterrupt.pool.schedule(new Callable<Void>() {
             public Void call() throws Exception {
                 sc.close();
+                isClosed.set(true);
                 return null;
             }
         }, new Random().nextInt(1000), TimeUnit.MILLISECONDS);
@@ -214,6 +237,7 @@
         AdaptorCloseAndInterrupt.pool.schedule(new Callable<Void>() {
             public Void call() throws Exception {
                 current.interrupt();
+                isInterrupted.set(true);
                 return null;
             }
         }, new Random().nextInt(1000), TimeUnit.MILLISECONDS);
--- a/jdk/test/java/security/Provider/DefaultProviderList.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/jdk/test/java/security/Provider/DefaultProviderList.java	Tue Apr 18 22:25:33 2017 +0200
@@ -33,7 +33,6 @@
 import java.util.Arrays;
 import java.util.Iterator;
 import java.util.ServiceLoader;
-import java.lang.reflect.Module;
 
 public class DefaultProviderList {
 
--- a/jdk/test/java/util/ResourceBundle/modules/cache/src/test/jdk/test/Main.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/jdk/test/java/util/ResourceBundle/modules/cache/src/test/jdk/test/Main.java	Tue Apr 18 22:25:33 2017 +0200
@@ -23,7 +23,6 @@
 
 package jdk.test;
 
-import java.lang.reflect.Module;
 import java.util.MissingResourceException;
 import java.util.ResourceBundle;
 
@@ -56,4 +55,4 @@
             jdk.test.util.Bundles.getBundle();
         }
     }
-}
\ No newline at end of file
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/util/ResourceBundle/modules/casesensitive/CaseInsensitiveNameClash.java	Tue Apr 18 22:25:33 2017 +0200
@@ -0,0 +1,72 @@
+/*
+ * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 8177980
+ * @library /lib/testlibrary
+ * @modules jdk.compiler
+ * @build CompilerUtils jdk.testlibrary.ProcessTools CaseInsensitiveNameClash
+ * @run testng CaseInsensitiveNameClash
+ */
+
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import jdk.testlibrary.ProcessTools;
+
+import org.testng.annotations.BeforeTest;
+import org.testng.annotations.Test;
+import static org.testng.Assert.*;
+
+public class CaseInsensitiveNameClash {
+
+    private static final String TEST_SRC = System.getProperty("test.src");
+
+    private static final Path SRC_DIR = Paths.get(TEST_SRC, "src");
+    private static final Path MODS_DIR = Paths.get("mods");
+
+    private static final String MODULE = "resbundle";
+    private static final String MAIN_CLASS = MODULE + "/jdk.test.Main";
+
+    /**
+     * Compiles the module used by the test
+     */
+    @BeforeTest
+    public void compileAll() throws Exception {
+        Path msrc = SRC_DIR.resolve(MODULE);
+        assertTrue(CompilerUtils.compile(msrc, MODS_DIR,
+                                         "--module-source-path", SRC_DIR.toString()));
+        Path propsFile = Paths.get("jdk", "test", "main.properties");
+        Files.copy(msrc.resolve(propsFile), MODS_DIR.resolve(MODULE).resolve(propsFile));
+    }
+
+    @Test
+    public void test() throws Exception {
+        assertTrue(ProcessTools.executeTestJava("--module-path", MODS_DIR.toString(),
+                                                "-m", MAIN_CLASS)
+                               .outputTo(System.out)
+                               .errorTo(System.out)
+                               .getExitValue() == 0);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/util/ResourceBundle/modules/casesensitive/src/resbundle/jdk/test/Main.java	Tue Apr 18 22:25:33 2017 +0200
@@ -0,0 +1,35 @@
+/*
+ * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package jdk.test;
+
+import java.util.ResourceBundle;
+
+public class Main {
+    public static void main(String[] args) throws Exception {
+        ResourceBundle bundle = ResourceBundle.getBundle("jdk.test.main");
+        if (!bundle.getString("key").equals("value")) {
+            throw new RuntimeException("Expected: value but get " + bundle.getString("key"));
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/util/ResourceBundle/modules/casesensitive/src/resbundle/jdk/test/main.properties	Tue Apr 18 22:25:33 2017 +0200
@@ -0,0 +1,1 @@
+key=value
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/util/ResourceBundle/modules/casesensitive/src/resbundle/module-info.java	Tue Apr 18 22:25:33 2017 +0200
@@ -0,0 +1,25 @@
+/*
+ * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+module resbundle {
+}
--- a/jdk/test/java/util/ResourceBundle/modules/security/src/test/jdk/test/Main.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/jdk/test/java/util/ResourceBundle/modules/security/src/test/jdk/test/Main.java	Tue Apr 18 22:25:33 2017 +0200
@@ -24,7 +24,6 @@
 package jdk.test;
 
 import p1.Bundle;
-import java.lang.reflect.Module;
 import java.util.ResourceBundle;
 
 public class Main {
--- a/jdk/test/java/util/ResourceBundle/modules/visibility/src/embargo/jdk/embargo/TestWithNoModuleArg.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/jdk/test/java/util/ResourceBundle/modules/visibility/src/embargo/jdk/embargo/TestWithNoModuleArg.java	Tue Apr 18 22:25:33 2017 +0200
@@ -23,7 +23,6 @@
 
 package jdk.embargo;
 
-import java.lang.reflect.Module;
 import java.util.Locale;
 import java.util.MissingResourceException;
 import java.util.ResourceBundle;
--- a/jdk/test/java/util/ResourceBundle/modules/visibility/src/embargo/jdk/embargo/TestWithUnnamedModuleArg.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/jdk/test/java/util/ResourceBundle/modules/visibility/src/embargo/jdk/embargo/TestWithUnnamedModuleArg.java	Tue Apr 18 22:25:33 2017 +0200
@@ -23,7 +23,6 @@
 
 package jdk.embargo;
 
-import java.lang.reflect.Module;
 import java.util.Locale;
 import java.util.MissingResourceException;
 import java.util.ResourceBundle;
--- a/jdk/test/java/util/ResourceBundle/modules/visibility/src/pkg/jdk/pkg/test/Main.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/jdk/test/java/util/ResourceBundle/modules/visibility/src/pkg/jdk/pkg/test/Main.java	Tue Apr 18 22:25:33 2017 +0200
@@ -23,7 +23,6 @@
 
 package jdk.pkg.test;
 
-import java.lang.reflect.Module;
 import java.util.Locale;
 import java.util.MissingResourceException;
 import java.util.ResourceBundle;
--- a/jdk/test/java/util/ResourceBundle/modules/visibility/src/test/jdk/test/TestWithNoModuleArg.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/jdk/test/java/util/ResourceBundle/modules/visibility/src/test/jdk/test/TestWithNoModuleArg.java	Tue Apr 18 22:25:33 2017 +0200
@@ -23,7 +23,6 @@
 
 package jdk.test;
 
-import java.lang.reflect.Module;
 import java.util.Locale;
 import java.util.MissingResourceException;
 import java.util.ResourceBundle;
--- a/jdk/test/java/util/ResourceBundle/modules/visibility/src/test/jdk/test/TestWithUnnamedModuleArg.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/jdk/test/java/util/ResourceBundle/modules/visibility/src/test/jdk/test/TestWithUnnamedModuleArg.java	Tue Apr 18 22:25:33 2017 +0200
@@ -23,7 +23,6 @@
 
 package jdk.test;
 
-import java.lang.reflect.Module;
 import java.util.Locale;
 import java.util.MissingResourceException;
 import java.util.ResourceBundle;
--- a/jdk/test/java/util/ServiceLoader/modules/BadProvidersTest.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/jdk/test/java/util/ServiceLoader/modules/BadProvidersTest.java	Tue Apr 18 22:25:33 2017 +0200
@@ -33,7 +33,6 @@
 
 import java.lang.module.Configuration;
 import java.lang.module.ModuleFinder;
-import java.lang.reflect.Layer;
 import java.nio.file.Files;
 import java.nio.file.Path;
 import java.nio.file.Paths;
@@ -87,14 +86,14 @@
     private List<Provider> loadProviders(Path mp, String moduleName) throws Exception {
         ModuleFinder finder = ModuleFinder.of(mp);
 
-        Layer bootLayer = Layer.boot();
+        ModuleLayer bootLayer = ModuleLayer.boot();
 
         Configuration cf = bootLayer.configuration()
                 .resolveAndBind(finder, ModuleFinder.of(), Set.of(moduleName));
 
         ClassLoader scl = ClassLoader.getSystemClassLoader();
 
-        Layer layer = Layer.boot().defineModulesWithOneLoader(cf, scl);
+        ModuleLayer layer = ModuleLayer.boot().defineModulesWithOneLoader(cf, scl);
 
         Class<?> service = layer.findLoader(moduleName).loadClass(TEST_SERVICE);
 
--- a/jdk/test/java/util/ServiceLoader/modules/Basic.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/jdk/test/java/util/ServiceLoader/modules/Basic.java	Tue Apr 18 22:25:33 2017 +0200
@@ -34,7 +34,6 @@
 
 import java.lang.module.Configuration;
 import java.lang.module.ModuleFinder;
-import java.lang.reflect.Layer;
 import java.nio.file.Files;
 import java.nio.file.Path;
 import java.nio.file.Paths;
@@ -229,7 +228,7 @@
      */
     @Test
     public void testWithCustomLayer1() {
-        Layer layer = createCustomLayer("bananascript");
+        ModuleLayer layer = createCustomLayer("bananascript");
 
         ClassLoader loader = layer.findLoader("bananascript");
         List<ScriptEngineFactory> providers
@@ -258,7 +257,7 @@
      */
     @Test
     public void testWithCustomLayer2() {
-        Layer layer = createCustomLayer("bananascript");
+        ModuleLayer layer = createCustomLayer("bananascript");
 
         List<ScriptEngineFactory> factories
             = collectAll(ServiceLoader.load(layer, ScriptEngineFactory.class));
@@ -293,7 +292,7 @@
      */
     @Test
     public void testWithCustomLayer3() {
-        Layer bootLayer = Layer.boot();
+        ModuleLayer bootLayer = ModuleLayer.boot();
         Configuration cf0 = bootLayer.configuration();
 
         // boot layer should contain "bananascript"
@@ -313,12 +312,12 @@
 
         // layer1
         Configuration cf1 = cf0.resolveAndBind(finder, ModuleFinder.of(), Set.of());
-        Layer layer1 = bootLayer.defineModulesWithOneLoader(cf1, scl);
+        ModuleLayer layer1 = bootLayer.defineModulesWithOneLoader(cf1, scl);
         assertTrue(layer1.modules().size() == 1);
 
         // layer2
         Configuration cf2 = cf0.resolveAndBind(finder, ModuleFinder.of(), Set.of());
-        Layer layer2 = bootLayer.defineModulesWithOneLoader(cf2, scl);
+        ModuleLayer layer2 = bootLayer.defineModulesWithOneLoader(cf2, scl);
         assertTrue(layer2.modules().size() == 1);
 
         // layer3 with layer1 and layer2 as parents
@@ -326,7 +325,8 @@
                 List.of(cf1, cf2),
                 ModuleFinder.of(),
                 Set.of());
-        Layer layer3 = Layer.defineModulesWithOneLoader(cf3, List.of(layer1, layer2), scl).layer();
+        ModuleLayer layer3
+            = ModuleLayer.defineModulesWithOneLoader(cf3, List.of(layer1, layer2), scl).layer();
         assertTrue(layer3.modules().size() == 1);
 
 
@@ -390,12 +390,12 @@
     @Test(expectedExceptions = { NullPointerException.class })
     public void testLoadNull3() {
         class S { }
-        ServiceLoader.load((Layer) null, S.class);
+        ServiceLoader.load((ModuleLayer) null, S.class);
     }
 
     @Test(expectedExceptions = { NullPointerException.class })
     public void testLoadNull4() {
-        ServiceLoader.load(Layer.empty(), null);
+        ServiceLoader.load(ModuleLayer.empty(), null);
     }
 
     @Test(expectedExceptions = { NullPointerException.class })
@@ -404,19 +404,19 @@
     }
 
     /**
-     * Create a custom Layer by resolving the given module names. The modules
+     * Create a custom layer by resolving the given module names. The modules
      * are located in the {@code ${test.classes}/modules} directory.
      */
-    private Layer createCustomLayer(String... modules) {
+    private ModuleLayer createCustomLayer(String... modules) {
         Path dir = Paths.get(System.getProperty("test.classes", "."), "modules");
         ModuleFinder finder = ModuleFinder.of(dir);
         Set<String> roots = new HashSet<>();
         Collections.addAll(roots, modules);
-        Layer bootLayer = Layer.boot();
+        ModuleLayer bootLayer = ModuleLayer.boot();
         Configuration parent = bootLayer.configuration();
         Configuration cf = parent.resolve(finder, ModuleFinder.of(), roots);
         ClassLoader scl = ClassLoader.getSystemClassLoader();
-        Layer layer = bootLayer.defineModulesWithOneLoader(cf, scl);
+        ModuleLayer layer = bootLayer.defineModulesWithOneLoader(cf, scl);
         assertTrue(layer.modules().size() == 1);
         return layer;
     }
--- a/jdk/test/java/util/concurrent/tck/ArrayDeque8Test.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/jdk/test/java/util/concurrent/tck/ArrayDeque8Test.java	Tue Apr 18 22:25:33 2017 +0200
@@ -37,7 +37,6 @@
 import java.util.Spliterator;
 
 import junit.framework.Test;
-import junit.framework.TestSuite;
 
 public class ArrayDeque8Test extends JSR166TestCase {
     public static void main(String[] args) {
--- a/jdk/test/java/util/concurrent/tck/ArrayDequeTest.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/jdk/test/java/util/concurrent/tck/ArrayDequeTest.java	Tue Apr 18 22:25:33 2017 +0200
@@ -35,7 +35,6 @@
 import java.util.ArrayDeque;
 import java.util.Arrays;
 import java.util.Collection;
-import java.util.Collections;
 import java.util.Deque;
 import java.util.Iterator;
 import java.util.NoSuchElementException;
@@ -44,7 +43,6 @@
 import java.util.concurrent.ThreadLocalRandom;
 
 import junit.framework.Test;
-import junit.framework.TestSuite;
 
 public class ArrayDequeTest extends JSR166TestCase {
     public static void main(String[] args) {
--- a/jdk/test/java/util/concurrent/tck/ArrayListTest.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/jdk/test/java/util/concurrent/tck/ArrayListTest.java	Tue Apr 18 22:25:33 2017 +0200
@@ -33,11 +33,9 @@
  */
 
 import java.util.ArrayList;
-import java.util.Collection;
 import java.util.List;
 
 import junit.framework.Test;
-import junit.framework.TestSuite;
 
 public class ArrayListTest extends JSR166TestCase {
     public static void main(String[] args) {
--- a/jdk/test/java/util/concurrent/tck/AtomicReferenceFieldUpdaterTest.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/jdk/test/java/util/concurrent/tck/AtomicReferenceFieldUpdaterTest.java	Tue Apr 18 22:25:33 2017 +0200
@@ -75,7 +75,7 @@
             assertTrue(a.compareAndSet(this, two, m4));
             assertSame(m4, a.get(this));
             assertFalse(a.compareAndSet(this, m5, seven));
-            assertFalse(seven == a.get(this));
+            assertNotSame(seven, a.get(this));
             assertTrue(a.compareAndSet(this, m4, seven));
             assertSame(seven, a.get(this));
         }
@@ -208,7 +208,7 @@
         assertTrue(a.compareAndSet(this, two, m4));
         assertSame(m4, a.get(this));
         assertFalse(a.compareAndSet(this, m5, seven));
-        assertFalse(seven == a.get(this));
+        assertNotSame(seven, a.get(this));
         assertTrue(a.compareAndSet(this, m4, seven));
         assertSame(seven, a.get(this));
     }
--- a/jdk/test/java/util/concurrent/tck/AtomicReferenceTest.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/jdk/test/java/util/concurrent/tck/AtomicReferenceTest.java	Tue Apr 18 22:25:33 2017 +0200
@@ -153,7 +153,7 @@
         AtomicReference z = serialClone(x);
         assertNotSame(y, z);
         assertEquals(one, x.get());
-        assertEquals(null, y.get());
+        assertNull(y.get());
         assertEquals(one, z.get());
     }
 
--- a/jdk/test/java/util/concurrent/tck/CompletableFutureTest.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/jdk/test/java/util/concurrent/tck/CompletableFutureTest.java	Tue Apr 18 22:25:33 2017 +0200
@@ -2589,28 +2589,28 @@
 
         // unspecified behavior - both source completions available
         try {
-            assertEquals(null, h0.join());
+            assertNull(h0.join());
             rs[0].assertValue(v1);
         } catch (CompletionException ok) {
             checkCompletedWithWrappedException(h0, ex);
             rs[0].assertNotInvoked();
         }
         try {
-            assertEquals(null, h1.join());
+            assertNull(h1.join());
             rs[1].assertValue(v1);
         } catch (CompletionException ok) {
             checkCompletedWithWrappedException(h1, ex);
             rs[1].assertNotInvoked();
         }
         try {
-            assertEquals(null, h2.join());
+            assertNull(h2.join());
             rs[2].assertValue(v1);
         } catch (CompletionException ok) {
             checkCompletedWithWrappedException(h2, ex);
             rs[2].assertNotInvoked();
         }
         try {
-            assertEquals(null, h3.join());
+            assertNull(h3.join());
             rs[3].assertValue(v1);
         } catch (CompletionException ok) {
             checkCompletedWithWrappedException(h3, ex);
@@ -2849,28 +2849,28 @@
 
         // unspecified behavior - both source completions available
         try {
-            assertEquals(null, h0.join());
+            assertNull(h0.join());
             rs[0].assertInvoked();
         } catch (CompletionException ok) {
             checkCompletedWithWrappedException(h0, ex);
             rs[0].assertNotInvoked();
         }
         try {
-            assertEquals(null, h1.join());
+            assertNull(h1.join());
             rs[1].assertInvoked();
         } catch (CompletionException ok) {
             checkCompletedWithWrappedException(h1, ex);
             rs[1].assertNotInvoked();
         }
         try {
-            assertEquals(null, h2.join());
+            assertNull(h2.join());
             rs[2].assertInvoked();
         } catch (CompletionException ok) {
             checkCompletedWithWrappedException(h2, ex);
             rs[2].assertNotInvoked();
         }
         try {
-            assertEquals(null, h3.join());
+            assertNull(h3.join());
             rs[3].assertInvoked();
         } catch (CompletionException ok) {
             checkCompletedWithWrappedException(h3, ex);
--- a/jdk/test/java/util/concurrent/tck/ConcurrentHashMap8Test.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/jdk/test/java/util/concurrent/tck/ConcurrentHashMap8Test.java	Tue Apr 18 22:25:33 2017 +0200
@@ -237,8 +237,8 @@
         Set set1 = map.keySet();
         Set set2 = map.keySet(true);
         set2.add(six);
-        assertTrue(((ConcurrentHashMap.KeySetView)set2).getMap() == map);
-        assertTrue(((ConcurrentHashMap.KeySetView)set1).getMap() == map);
+        assertSame(map, ((ConcurrentHashMap.KeySetView)set2).getMap());
+        assertSame(map, ((ConcurrentHashMap.KeySetView)set1).getMap());
         assertEquals(set2.size(), map.size());
         assertEquals(set1.size(), map.size());
         assertTrue((Boolean)map.get(six));
@@ -332,10 +332,10 @@
         assertFalse(set.add(one));
         assertTrue(set.add(six));
         assertTrue(set.add(seven));
-        assertTrue(set.getMappedValue() == one);
-        assertTrue(map.get(one) != one);
-        assertTrue(map.get(six) == one);
-        assertTrue(map.get(seven) == one);
+        assertSame(one, set.getMappedValue());
+        assertNotSame(one, map.get(one));
+        assertSame(one, map.get(six));
+        assertSame(one, map.get(seven));
     }
 
     void checkSpliteratorCharacteristics(Spliterator<?> sp,
--- a/jdk/test/java/util/concurrent/tck/ConcurrentHashMapTest.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/jdk/test/java/util/concurrent/tck/ConcurrentHashMapTest.java	Tue Apr 18 22:25:33 2017 +0200
@@ -43,8 +43,6 @@
 import java.util.Random;
 import java.util.Set;
 import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Executors;
 
 import junit.framework.Test;
 import junit.framework.TestSuite;
@@ -148,7 +146,7 @@
         ConcurrentHashMap<BI, Boolean> m =
             new ConcurrentHashMap<BI, Boolean>();
         for (int i = 0; i < size; i++) {
-            assertTrue(m.put(new CI(i), true) == null);
+            assertNull(m.put(new CI(i), true));
         }
         for (int i = 0; i < size; i++) {
             assertTrue(m.containsKey(new CI(i)));
@@ -169,7 +167,7 @@
             BS bs = new BS(String.valueOf(i));
             LexicographicList<BI> bis = new LexicographicList<BI>(bi);
             LexicographicList<BS> bss = new LexicographicList<BS>(bs);
-            assertTrue(m.putIfAbsent(bis, true) == null);
+            assertNull(m.putIfAbsent(bis, true));
             assertTrue(m.containsKey(bis));
             if (m.putIfAbsent(bss, true) == null)
                 assertTrue(m.containsKey(bss));
--- a/jdk/test/java/util/concurrent/tck/ConcurrentLinkedDequeTest.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/jdk/test/java/util/concurrent/tck/ConcurrentLinkedDequeTest.java	Tue Apr 18 22:25:33 2017 +0200
@@ -43,7 +43,6 @@
 import java.util.concurrent.ConcurrentLinkedDeque;
 
 import junit.framework.Test;
-import junit.framework.TestSuite;
 
 public class ConcurrentLinkedDequeTest extends JSR166TestCase {
 
@@ -67,7 +66,7 @@
      * Returns a new deque of given size containing consecutive
      * Integers 0 ... n - 1.
      */
-    private ConcurrentLinkedDeque<Integer> populatedDeque(int n) {
+    private static ConcurrentLinkedDeque<Integer> populatedDeque(int n) {
         ConcurrentLinkedDeque<Integer> q = new ConcurrentLinkedDeque<>();
         assertTrue(q.isEmpty());
         for (int i = 0; i < n; ++i)
--- a/jdk/test/java/util/concurrent/tck/ConcurrentLinkedQueueTest.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/jdk/test/java/util/concurrent/tck/ConcurrentLinkedQueueTest.java	Tue Apr 18 22:25:33 2017 +0200
@@ -41,7 +41,6 @@
 import java.util.concurrent.ConcurrentLinkedQueue;
 
 import junit.framework.Test;
-import junit.framework.TestSuite;
 
 public class ConcurrentLinkedQueueTest extends JSR166TestCase {
 
@@ -65,7 +64,7 @@
      * Returns a new queue of given size containing consecutive
      * Integers 0 ... n - 1.
      */
-    private ConcurrentLinkedQueue<Integer> populatedQueue(int n) {
+    private static ConcurrentLinkedQueue<Integer> populatedQueue(int n) {
         ConcurrentLinkedQueue<Integer> q = new ConcurrentLinkedQueue<>();
         assertTrue(q.isEmpty());
         for (int i = 0; i < n; ++i)
--- a/jdk/test/java/util/concurrent/tck/ConcurrentSkipListSetTest.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/jdk/test/java/util/concurrent/tck/ConcurrentSkipListSetTest.java	Tue Apr 18 22:25:33 2017 +0200
@@ -64,7 +64,7 @@
      * Returns a new set of given size containing consecutive
      * Integers 0 ... n - 1.
      */
-    private ConcurrentSkipListSet<Integer> populatedSet(int n) {
+    private static ConcurrentSkipListSet<Integer> populatedSet(int n) {
         ConcurrentSkipListSet<Integer> q =
             new ConcurrentSkipListSet<Integer>();
         assertTrue(q.isEmpty());
@@ -80,7 +80,7 @@
     /**
      * Returns a new set of first 5 ints.
      */
-    private ConcurrentSkipListSet set5() {
+    private static ConcurrentSkipListSet set5() {
         ConcurrentSkipListSet q = new ConcurrentSkipListSet();
         assertTrue(q.isEmpty());
         q.add(one);
@@ -229,7 +229,7 @@
         } catch (ClassCastException success) {
             assertTrue(q.size() < 2);
             for (int i = 0, size = q.size(); i < size; i++)
-                assertTrue(q.pollFirst().getClass() == Object.class);
+                assertSame(Object.class, q.pollFirst().getClass());
             assertNull(q.pollFirst());
             assertTrue(q.isEmpty());
             assertEquals(0, q.size());
--- a/jdk/test/java/util/concurrent/tck/ConcurrentSkipListSubSetTest.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/jdk/test/java/util/concurrent/tck/ConcurrentSkipListSubSetTest.java	Tue Apr 18 22:25:33 2017 +0200
@@ -59,7 +59,7 @@
      * Returns a new set of given size containing consecutive
      * Integers 0 ... n - 1.
      */
-    private NavigableSet<Integer> populatedSet(int n) {
+    private static NavigableSet<Integer> populatedSet(int n) {
         ConcurrentSkipListSet<Integer> q =
             new ConcurrentSkipListSet<Integer>();
         assertTrue(q.isEmpty());
@@ -79,7 +79,7 @@
     /**
      * Returns a new set of first 5 ints.
      */
-    private NavigableSet set5() {
+    private static NavigableSet set5() {
         ConcurrentSkipListSet q = new ConcurrentSkipListSet();
         assertTrue(q.isEmpty());
         q.add(one);
@@ -97,7 +97,7 @@
     /**
      * Returns a new set of first 5 negative ints.
      */
-    private NavigableSet dset5() {
+    private static NavigableSet dset5() {
         ConcurrentSkipListSet q = new ConcurrentSkipListSet();
         assertTrue(q.isEmpty());
         q.add(m1);
--- a/jdk/test/java/util/concurrent/tck/CopyOnWriteArrayListTest.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/jdk/test/java/util/concurrent/tck/CopyOnWriteArrayListTest.java	Tue Apr 18 22:25:33 2017 +0200
@@ -44,7 +44,6 @@
 import java.util.concurrent.CopyOnWriteArrayList;
 
 import junit.framework.Test;
-import junit.framework.TestSuite;
 
 public class CopyOnWriteArrayListTest extends JSR166TestCase {
 
--- a/jdk/test/java/util/concurrent/tck/CountedCompleter8Test.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/jdk/test/java/util/concurrent/tck/CountedCompleter8Test.java	Tue Apr 18 22:25:33 2017 +0200
@@ -32,9 +32,6 @@
  * http://creativecommons.org/publicdomain/zero/1.0/
  */
 
-import static java.util.concurrent.TimeUnit.MILLISECONDS;
-import static java.util.concurrent.TimeUnit.SECONDS;
-
 import java.util.concurrent.CountedCompleter;
 import java.util.concurrent.ThreadLocalRandom;
 import java.util.concurrent.atomic.AtomicInteger;
--- a/jdk/test/java/util/concurrent/tck/CountedCompleterTest.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/jdk/test/java/util/concurrent/tck/CountedCompleterTest.java	Tue Apr 18 22:25:33 2017 +0200
@@ -40,7 +40,6 @@
 import java.util.concurrent.ExecutionException;
 import java.util.concurrent.ForkJoinPool;
 import java.util.concurrent.ForkJoinTask;
-import java.util.concurrent.ThreadLocalRandom;
 import java.util.concurrent.TimeoutException;
 import java.util.concurrent.atomic.AtomicInteger;
 import java.util.concurrent.atomic.AtomicReference;
--- a/jdk/test/java/util/concurrent/tck/ExchangerTest.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/jdk/test/java/util/concurrent/tck/ExchangerTest.java	Tue Apr 18 22:25:33 2017 +0200
@@ -160,12 +160,12 @@
             public void realRun() throws InterruptedException {
                 assertSame(one, e.exchange(two));
                 exchanged.countDown();
-                interrupted.await();
+                await(interrupted);
                 assertSame(three, e.exchange(one));
             }});
         Thread t3 = newStartedThread(new CheckedRunnable() {
             public void realRun() throws InterruptedException {
-                interrupted.await();
+                await(interrupted);
                 assertSame(one, e.exchange(three));
             }});
 
--- a/jdk/test/java/util/concurrent/tck/ExecutorCompletionService9Test.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/jdk/test/java/util/concurrent/tck/ExecutorCompletionService9Test.java	Tue Apr 18 22:25:33 2017 +0200
@@ -37,7 +37,6 @@
 import java.util.Comparator;
 import java.util.List;
 import java.util.Set;
-import java.util.HashSet;
 import java.util.concurrent.Callable;
 import java.util.concurrent.CompletionService;
 import java.util.concurrent.ExecutionException;
--- a/jdk/test/java/util/concurrent/tck/ExecutorCompletionServiceTest.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/jdk/test/java/util/concurrent/tck/ExecutorCompletionServiceTest.java	Tue Apr 18 22:25:33 2017 +0200
@@ -172,7 +172,7 @@
         CompletionService cs = new ExecutorCompletionService(cachedThreadPool);
         final CountDownLatch proceed = new CountDownLatch(1);
         cs.submit(new Callable() { public String call() throws Exception {
-            proceed.await();
+            await(proceed);
             return TEST_STRING;
         }});
         assertNull(cs.poll());
--- a/jdk/test/java/util/concurrent/tck/ExecutorsTest.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/jdk/test/java/util/concurrent/tck/ExecutorsTest.java	Tue Apr 18 22:25:33 2017 +0200
@@ -333,16 +333,12 @@
             public void realRun() {
                 try {
                     Thread current = Thread.currentThread();
-                    assertTrue(!current.isDaemon());
+                    assertFalse(current.isDaemon());
                     assertTrue(current.getPriority() <= Thread.NORM_PRIORITY);
-                    ThreadGroup g = current.getThreadGroup();
                     SecurityManager s = System.getSecurityManager();
-                    if (s != null)
-                        assertTrue(g == s.getThreadGroup());
-                    else
-                        assertTrue(g == egroup);
-                    String name = current.getName();
-                    assertTrue(name.endsWith("thread-1"));
+                    assertSame(current.getThreadGroup(),
+                               (s == null) ? egroup : s.getThreadGroup());
+                    assertTrue(current.getName().endsWith("thread-1"));
                 } catch (SecurityException ok) {
                     // Also pass if not allowed to change setting
                 }
@@ -370,16 +366,12 @@
                 Runnable r = new CheckedRunnable() {
                     public void realRun() {
                         Thread current = Thread.currentThread();
-                        assertTrue(!current.isDaemon());
+                        assertFalse(current.isDaemon());
                         assertTrue(current.getPriority() <= Thread.NORM_PRIORITY);
-                        ThreadGroup g = current.getThreadGroup();
                         SecurityManager s = System.getSecurityManager();
-                        if (s != null)
-                            assertTrue(g == s.getThreadGroup());
-                        else
-                            assertTrue(g == egroup);
-                        String name = current.getName();
-                        assertTrue(name.endsWith("thread-1"));
+                        assertSame(current.getThreadGroup(),
+                                   (s == null) ? egroup : s.getThreadGroup());
+                        assertTrue(current.getName().endsWith("thread-1"));
                         assertSame(thisccl, current.getContextClassLoader());
                         assertEquals(thisacc, AccessController.getContext());
                         done.countDown();
--- a/jdk/test/java/util/concurrent/tck/ForkJoinPool8Test.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/jdk/test/java/util/concurrent/tck/ForkJoinPool8Test.java	Tue Apr 18 22:25:33 2017 +0200
@@ -206,7 +206,7 @@
         public FJException(Throwable cause) { super(cause); }
     }
 
-    // A simple recursive action for testing
+    /** A simple recursive action for testing. */
     final class FibAction extends CheckedRecursiveAction {
         final int number;
         int result;
@@ -224,7 +224,7 @@
         }
     }
 
-    // A recursive action failing in base case
+    /** A recursive action failing in base case. */
     static final class FailingFibAction extends RecursiveAction {
         final int number;
         int result;
@@ -932,7 +932,7 @@
         }
     }
 
-    // Version of CCF with forced failure in left completions
+    /** Version of CCF with forced failure in left completions. */
     abstract static class FailingCCF extends CountedCompleter {
         int number;
         int rnumber;
--- a/jdk/test/java/util/concurrent/tck/ForkJoinPool9Test.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/jdk/test/java/util/concurrent/tck/ForkJoinPool9Test.java	Tue Apr 18 22:25:33 2017 +0200
@@ -32,8 +32,6 @@
  * http://creativecommons.org/publicdomain/zero/1.0/
  */
 
-import static java.util.concurrent.TimeUnit.MILLISECONDS;
-
 import java.lang.invoke.MethodHandles;
 import java.lang.invoke.VarHandle;
 import java.util.concurrent.CountDownLatch;
@@ -93,7 +91,7 @@
         Future<?> f = ForkJoinPool.commonPool().submit(runInCommonPool);
         // Ensure runInCommonPool is truly running in the common pool,
         // by giving this thread no opportunity to "help" on get().
-        assertTrue(taskStarted.await(LONG_DELAY_MS, MILLISECONDS));
+        await(taskStarted);
         assertNull(f.get());
     }
 
--- a/jdk/test/java/util/concurrent/tck/ForkJoinPoolTest.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/jdk/test/java/util/concurrent/tck/ForkJoinPoolTest.java	Tue Apr 18 22:25:33 2017 +0200
@@ -244,7 +244,7 @@
                     taskStarted.countDown();
                     assertEquals(1, p.getPoolSize());
                     assertEquals(1, p.getActiveThreadCount());
-                    done.await();
+                    await(done);
                 }};
             Future<?> future = p.submit(task);
             await(taskStarted);
--- a/jdk/test/java/util/concurrent/tck/ForkJoinTask8Test.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/jdk/test/java/util/concurrent/tck/ForkJoinTask8Test.java	Tue Apr 18 22:25:33 2017 +0200
@@ -127,7 +127,8 @@
         assertNull(a.getException());
         assertNull(a.getRawResult());
         if (a instanceof BinaryAsyncAction)
-            assertTrue(((BinaryAsyncAction)a).getForkJoinTaskTag() == INITIAL_STATE);
+            assertEquals(INITIAL_STATE,
+                         ((BinaryAsyncAction)a).getForkJoinTaskTag());
 
         try {
             a.get(0L, SECONDS);
@@ -148,7 +149,8 @@
         assertNull(a.getException());
         assertSame(expected, a.getRawResult());
         if (a instanceof BinaryAsyncAction)
-            assertTrue(((BinaryAsyncAction)a).getForkJoinTaskTag() == COMPLETE_STATE);
+            assertEquals(COMPLETE_STATE,
+                         ((BinaryAsyncAction)a).getForkJoinTaskTag());
 
         {
             Thread.currentThread().interrupt();
--- a/jdk/test/java/util/concurrent/tck/JSR166TestCase.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/jdk/test/java/util/concurrent/tck/JSR166TestCase.java	Tue Apr 18 22:25:33 2017 +0200
@@ -26,8 +26,9 @@
  * However, the following notice accompanied the original version of this
  * file:
  *
- * Written by Doug Lea with assistance from members of JCP JSR-166
- * Expert Group and released to the public domain, as explained at
+ * Written by Doug Lea and Martin Buchholz with assistance from
+ * members of JCP JSR-166 Expert Group and released to the public
+ * domain, as explained at
  * http://creativecommons.org/publicdomain/zero/1.0/
  * Other contributors include Andrew Wright, Jeffrey Hayes,
  * Pat Fisher, Mike Judd.
@@ -35,32 +36,33 @@
 
 /*
  * @test
- * @summary JSR-166 tck tests (conformance testing mode)
+ * @summary JSR-166 tck tests, in a number of variations.
+ *          The first is the conformance testing variant,
+ *          while others also test implementation details.
  * @build *
  * @modules java.management
  * @run junit/othervm/timeout=1000 JSR166TestCase
- */
-
-/*
- * @test
- * @summary JSR-166 tck tests (whitebox tests allowed)
- * @build *
- * @modules java.base/java.util.concurrent:open
- *          java.base/java.lang:open
- *          java.management
  * @run junit/othervm/timeout=1000
+ *      --add-opens java.base/java.util.concurrent=ALL-UNNAMED
+ *      --add-opens java.base/java.lang=ALL-UNNAMED
  *      -Djsr166.testImplementationDetails=true
  *      JSR166TestCase
  * @run junit/othervm/timeout=1000
+ *      --add-opens java.base/java.util.concurrent=ALL-UNNAMED
+ *      --add-opens java.base/java.lang=ALL-UNNAMED
  *      -Djsr166.testImplementationDetails=true
  *      -Djava.util.concurrent.ForkJoinPool.common.parallelism=0
  *      JSR166TestCase
  * @run junit/othervm/timeout=1000
+ *      --add-opens java.base/java.util.concurrent=ALL-UNNAMED
+ *      --add-opens java.base/java.lang=ALL-UNNAMED
  *      -Djsr166.testImplementationDetails=true
  *      -Djava.util.concurrent.ForkJoinPool.common.parallelism=1
  *      -Djava.util.secureRandomSeed=true
  *      JSR166TestCase
  * @run junit/othervm/timeout=1000/policy=tck.policy
+ *      --add-opens java.base/java.util.concurrent=ALL-UNNAMED
+ *      --add-opens java.base/java.lang=ALL-UNNAMED
  *      -Djsr166.testImplementationDetails=true
  *      JSR166TestCase
  */
@@ -79,8 +81,6 @@
 import java.lang.reflect.Constructor;
 import java.lang.reflect.Method;
 import java.lang.reflect.Modifier;
-import java.nio.file.Files;
-import java.nio.file.Paths;
 import java.security.CodeSource;
 import java.security.Permission;
 import java.security.PermissionCollection;
@@ -118,7 +118,6 @@
 import java.util.concurrent.TimeoutException;
 import java.util.concurrent.atomic.AtomicBoolean;
 import java.util.concurrent.atomic.AtomicReference;
-import java.util.regex.Matcher;
 import java.util.regex.Pattern;
 
 import junit.framework.AssertionFailedError;
@@ -328,9 +327,11 @@
 
 //     public static String cpuModel() {
 //         try {
-//             Matcher matcher = Pattern.compile("model name\\s*: (.*)")
+//             java.util.regex.Matcher matcher
+//               = Pattern.compile("model name\\s*: (.*)")
 //                 .matcher(new String(
-//                      Files.readAllBytes(Paths.get("/proc/cpuinfo")), "UTF-8"));
+//                     java.nio.file.Files.readAllBytes(
+//                         java.nio.file.Paths.get("/proc/cpuinfo")), "UTF-8"));
 //             matcher.find();
 //             return matcher.group(1);
 //         } catch (Exception ex) { return null; }
--- a/jdk/test/java/util/concurrent/tck/LinkedBlockingDeque8Test.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/jdk/test/java/util/concurrent/tck/LinkedBlockingDeque8Test.java	Tue Apr 18 22:25:33 2017 +0200
@@ -36,7 +36,6 @@
 import java.util.Spliterator;
 
 import junit.framework.Test;
-import junit.framework.TestSuite;
 
 public class LinkedBlockingDeque8Test extends JSR166TestCase {
     public static void main(String[] args) {
--- a/jdk/test/java/util/concurrent/tck/LinkedBlockingDequeTest.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/jdk/test/java/util/concurrent/tck/LinkedBlockingDequeTest.java	Tue Apr 18 22:25:33 2017 +0200
@@ -85,7 +85,7 @@
      * Returns a new deque of given size containing consecutive
      * Integers 0 ... n - 1.
      */
-    private LinkedBlockingDeque<Integer> populatedDeque(int n) {
+    private static LinkedBlockingDeque<Integer> populatedDeque(int n) {
         LinkedBlockingDeque<Integer> q =
             new LinkedBlockingDeque<Integer>(n);
         assertTrue(q.isEmpty());
@@ -801,7 +801,7 @@
                 }
             }});
 
-        aboutToWait.await();
+        await(aboutToWait);
         waitForThreadToEnterWaitState(t);
         t.interrupt();
         awaitTermination(t);
--- a/jdk/test/java/util/concurrent/tck/LinkedBlockingQueue8Test.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/jdk/test/java/util/concurrent/tck/LinkedBlockingQueue8Test.java	Tue Apr 18 22:25:33 2017 +0200
@@ -36,7 +36,6 @@
 import java.util.Spliterator;
 
 import junit.framework.Test;
-import junit.framework.TestSuite;
 
 public class LinkedBlockingQueue8Test extends JSR166TestCase {
     public static void main(String[] args) {
--- a/jdk/test/java/util/concurrent/tck/LinkedBlockingQueueTest.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/jdk/test/java/util/concurrent/tck/LinkedBlockingQueueTest.java	Tue Apr 18 22:25:33 2017 +0200
@@ -85,7 +85,7 @@
      * Returns a new queue of given size containing consecutive
      * Integers 0 ... n - 1.
      */
-    private LinkedBlockingQueue<Integer> populatedQueue(int n) {
+    private static LinkedBlockingQueue<Integer> populatedQueue(int n) {
         LinkedBlockingQueue<Integer> q =
             new LinkedBlockingQueue<Integer>(n);
         assertTrue(q.isEmpty());
--- a/jdk/test/java/util/concurrent/tck/LinkedListTest.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/jdk/test/java/util/concurrent/tck/LinkedListTest.java	Tue Apr 18 22:25:33 2017 +0200
@@ -40,7 +40,6 @@
 import java.util.NoSuchElementException;
 
 import junit.framework.Test;
-import junit.framework.TestSuite;
 
 public class LinkedListTest extends JSR166TestCase {
     public static void main(String[] args) {
@@ -70,7 +69,7 @@
      * Returns a new queue of given size containing consecutive
      * Integers 0 ... n - 1.
      */
-    private LinkedList<Integer> populatedQueue(int n) {
+    private static LinkedList<Integer> populatedQueue(int n) {
         LinkedList<Integer> q = new LinkedList<>();
         assertTrue(q.isEmpty());
         for (int i = 0; i < n; ++i)
--- a/jdk/test/java/util/concurrent/tck/LinkedTransferQueueTest.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/jdk/test/java/util/concurrent/tck/LinkedTransferQueueTest.java	Tue Apr 18 22:25:33 2017 +0200
@@ -321,7 +321,7 @@
                 assertTrue(millisElapsedSince(startTime) < LONG_DELAY_MS);
             }});
 
-        aboutToWait.await();
+        await(aboutToWait);
         waitForThreadToEnterWaitState(t);
         t.interrupt();
         awaitTermination(t);
@@ -826,7 +826,7 @@
         Thread first = newStartedThread(new CheckedRunnable() {
             public void realRun() throws InterruptedException {
                 q.transfer(four);
-                assertTrue(!q.contains(four));
+                assertFalse(q.contains(four));
                 assertEquals(1, q.size());
             }});
 
--- a/jdk/test/java/util/concurrent/tck/PriorityBlockingQueueTest.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/jdk/test/java/util/concurrent/tck/PriorityBlockingQueueTest.java	Tue Apr 18 22:25:33 2017 +0200
@@ -93,7 +93,7 @@
      * Returns a new queue of given size containing consecutive
      * Integers 0 ... n - 1.
      */
-    private PriorityBlockingQueue<Integer> populatedQueue(int n) {
+    private static PriorityBlockingQueue<Integer> populatedQueue(int n) {
         PriorityBlockingQueue<Integer> q =
             new PriorityBlockingQueue<Integer>(n);
         assertTrue(q.isEmpty());
@@ -445,7 +445,7 @@
                 }
             }});
 
-        aboutToWait.await();
+        await(aboutToWait);
         waitForThreadToEnterWaitState(t);
         t.interrupt();
         awaitTermination(t);
--- a/jdk/test/java/util/concurrent/tck/PriorityQueueTest.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/jdk/test/java/util/concurrent/tck/PriorityQueueTest.java	Tue Apr 18 22:25:33 2017 +0200
@@ -42,7 +42,6 @@
 import java.util.Queue;
 
 import junit.framework.Test;
-import junit.framework.TestSuite;
 
 public class PriorityQueueTest extends JSR166TestCase {
     public static void main(String[] args) {
@@ -70,7 +69,7 @@
      * Returns a new queue of given size containing consecutive
      * Integers 0 ... n - 1.
      */
-    private PriorityQueue<Integer> populatedQueue(int n) {
+    private static PriorityQueue<Integer> populatedQueue(int n) {
         PriorityQueue<Integer> q = new PriorityQueue<>(n);
         assertTrue(q.isEmpty());
         for (int i = n - 1; i >= 0; i -= 2)
--- a/jdk/test/java/util/concurrent/tck/RecursiveActionTest.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/jdk/test/java/util/concurrent/tck/RecursiveActionTest.java	Tue Apr 18 22:25:33 2017 +0200
@@ -195,7 +195,7 @@
         public FJException(Throwable cause) { super(cause); }
     }
 
-    // A simple recursive action for testing
+    /** A simple recursive action for testing. */
     final class FibAction extends CheckedRecursiveAction {
         final int number;
         int result;
@@ -213,7 +213,7 @@
         }
     }
 
-    // A recursive action failing in base case
+    /** A recursive action failing in base case. */
     static final class FailingFibAction extends RecursiveAction {
         final int number;
         int result;
--- a/jdk/test/java/util/concurrent/tck/RecursiveTaskTest.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/jdk/test/java/util/concurrent/tck/RecursiveTaskTest.java	Tue Apr 18 22:25:33 2017 +0200
@@ -210,10 +210,10 @@
         public FJException() { super(); }
     }
 
-    // An invalid return value for Fib
+    /** An invalid return value for Fib. */
     static final Integer NoResult = Integer.valueOf(-17);
 
-    // A simple recursive task for testing
+    /** A simple recursive task for testing. */
     final class FibTask extends CheckedRecursiveTask<Integer> {
         final int number;
         FibTask(int n) { number = n; }
@@ -231,7 +231,7 @@
         }
     }
 
-    // A recursive action failing in base case
+    /** A recursive action failing in base case. */
     final class FailingFibTask extends RecursiveTask<Integer> {
         final int number;
         int result;
--- a/jdk/test/java/util/concurrent/tck/StampedLockTest.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/jdk/test/java/util/concurrent/tck/StampedLockTest.java	Tue Apr 18 22:25:33 2017 +0200
@@ -518,7 +518,7 @@
                 lock.unlockWrite(s);
             }});
 
-        aboutToLock.await();
+        await(aboutToLock);
         waitForThreadToEnterWaitState(t);
         assertFalse(lock.isWriteLocked());
         assertTrue(lock.isReadLocked());
@@ -777,7 +777,7 @@
                 lock.writeLockInterruptibly();
             }});
 
-        locked.await();
+        await(locked);
         assertFalse(lock.validate(p));
         assertEquals(0L, lock.tryOptimisticRead());
         waitForThreadToEnterWaitState(t);
--- a/jdk/test/java/util/concurrent/tck/SubmissionPublisherTest.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/jdk/test/java/util/concurrent/tck/SubmissionPublisherTest.java	Tue Apr 18 22:25:33 2017 +0200
@@ -519,7 +519,7 @@
         s1.request = false;
         p.subscribe(s1);
         s1.awaitSubscribe();
-        assertTrue(p.estimateMinimumDemand() == 0);
+        assertEquals(0, p.estimateMinimumDemand());
         TestSubscriber s2 = new TestSubscriber();
         p.subscribe(s2);
         p.submit(1);
--- a/jdk/test/java/util/concurrent/tck/SynchronousQueueTest.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/jdk/test/java/util/concurrent/tck/SynchronousQueueTest.java	Tue Apr 18 22:25:33 2017 +0200
@@ -596,7 +596,7 @@
                 fail("timed out");
             Thread.yield();
         }
-        assertTrue(l.size() == 1);
+        assertEquals(1, l.size());
         assertSame(one, l.get(0));
         awaitTermination(t);
     }
--- a/jdk/test/java/util/concurrent/tck/ThreadPoolExecutorSubclassTest.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/jdk/test/java/util/concurrent/tck/ThreadPoolExecutorSubclassTest.java	Tue Apr 18 22:25:33 2017 +0200
@@ -265,7 +265,7 @@
             final Runnable task = new CheckedRunnable() {
                 public void realRun() { done.countDown(); }};
             p.execute(task);
-            assertTrue(done.await(LONG_DELAY_MS, MILLISECONDS));
+            await(done);
         }
     }
 
@@ -359,13 +359,13 @@
                 public void realRun() throws InterruptedException {
                     threadStarted.countDown();
                     assertEquals(0, p.getCompletedTaskCount());
-                    threadProceed.await();
+                    await(threadProceed);
                     threadDone.countDown();
                 }});
             await(threadStarted);
             assertEquals(0, p.getCompletedTaskCount());
             threadProceed.countDown();
-            threadDone.await();
+            await(threadDone);
             long startTime = System.nanoTime();
             while (p.getCompletedTaskCount() != 1) {
                 if (millisElapsedSince(startTime) > LONG_DELAY_MS)
@@ -1953,7 +1953,7 @@
                     public void realRun() {
                         done.countDown();
                     }});
-            assertTrue(done.await(LONG_DELAY_MS, MILLISECONDS));
+            await(done);
         }
     }
 
--- a/jdk/test/java/util/concurrent/tck/ThreadPoolExecutorTest.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/jdk/test/java/util/concurrent/tck/ThreadPoolExecutorTest.java	Tue Apr 18 22:25:33 2017 +0200
@@ -45,7 +45,6 @@
 import java.util.concurrent.CancellationException;
 import java.util.concurrent.CountDownLatch;
 import java.util.concurrent.ExecutionException;
-import java.util.concurrent.Executors;
 import java.util.concurrent.ExecutorService;
 import java.util.concurrent.Future;
 import java.util.concurrent.FutureTask;
@@ -118,7 +117,7 @@
             final Runnable task = new CheckedRunnable() {
                 public void realRun() { done.countDown(); }};
             p.execute(task);
-            assertTrue(done.await(LONG_DELAY_MS, MILLISECONDS));
+            await(done);
         }
     }
 
@@ -212,13 +211,13 @@
                 public void realRun() throws InterruptedException {
                     threadStarted.countDown();
                     assertEquals(0, p.getCompletedTaskCount());
-                    threadProceed.await();
+                    await(threadProceed);
                     threadDone.countDown();
                 }});
             await(threadStarted);
             assertEquals(0, p.getCompletedTaskCount());
             threadProceed.countDown();
-            threadDone.await();
+            await(threadDone);
             long startTime = System.nanoTime();
             while (p.getCompletedTaskCount() != 1) {
                 if (millisElapsedSince(startTime) > LONG_DELAY_MS)
@@ -302,6 +301,20 @@
     }
 
     /**
+     * The default rejected execution handler is AbortPolicy.
+     */
+    public void testDefaultRejectedExecutionHandler() {
+        final ThreadPoolExecutor p =
+            new ThreadPoolExecutor(1, 2,
+                                   LONG_DELAY_MS, MILLISECONDS,
+                                   new ArrayBlockingQueue<Runnable>(10));
+        try (PoolCleaner cleaner = cleaner(p)) {
+            assertTrue(p.getRejectedExecutionHandler()
+                       instanceof ThreadPoolExecutor.AbortPolicy);
+        }
+    }
+
+    /**
      * getRejectedExecutionHandler returns handler in constructor if not set
      */
     public void testGetRejectedExecutionHandler() {
@@ -1139,7 +1152,7 @@
                     await(done);
                 }};
             for (int i = 0; i < 2; ++i)
-                p.submit(Executors.callable(task));
+                p.execute(task);
             for (int i = 0; i < 2; ++i) {
                 try {
                     p.execute(task);
@@ -1955,7 +1968,7 @@
                     public void realRun() {
                         done.countDown();
                     }});
-            assertTrue(done.await(LONG_DELAY_MS, MILLISECONDS));
+            await(done);
         }
     }
 
@@ -2048,7 +2061,7 @@
                 }
             }
             // enough time to run all tasks
-            assertTrue(done.await(nTasks * SHORT_DELAY_MS, MILLISECONDS));
+            await(done, nTasks * SHORT_DELAY_MS);
         }
     }
 
--- a/jdk/test/java/util/concurrent/tck/ThreadTest.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/jdk/test/java/util/concurrent/tck/ThreadTest.java	Tue Apr 18 22:25:33 2017 +0200
@@ -76,7 +76,7 @@
      * setDefaultUncaughtExceptionHandler.
      */
     public void testGetAndSetDefaultUncaughtExceptionHandler() {
-        assertEquals(null, Thread.getDefaultUncaughtExceptionHandler());
+        assertNull(Thread.getDefaultUncaughtExceptionHandler());
         // failure due to SecurityException is OK.
         // Would be nice to explicitly test both ways, but cannot yet.
         Thread.UncaughtExceptionHandler defaultHandler
--- a/jdk/test/java/util/concurrent/tck/TreeSetTest.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/jdk/test/java/util/concurrent/tck/TreeSetTest.java	Tue Apr 18 22:25:33 2017 +0200
@@ -69,7 +69,7 @@
      * Returns a new set of given size containing consecutive
      * Integers 0 ... n - 1.
      */
-    private TreeSet<Integer> populatedSet(int n) {
+    private static TreeSet<Integer> populatedSet(int n) {
         TreeSet<Integer> q = new TreeSet<>();
         assertTrue(q.isEmpty());
         for (int i = n - 1; i >= 0; i -= 2)
@@ -84,7 +84,7 @@
     /**
      * Returns a new set of first 5 ints.
      */
-    private TreeSet set5() {
+    private static TreeSet set5() {
         TreeSet q = new TreeSet();
         assertTrue(q.isEmpty());
         q.add(one);
--- a/jdk/test/java/util/concurrent/tck/TreeSubSetTest.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/jdk/test/java/util/concurrent/tck/TreeSubSetTest.java	Tue Apr 18 22:25:33 2017 +0200
@@ -60,7 +60,7 @@
      * Returns a new set of given size containing consecutive
      * Integers 0 ... n - 1.
      */
-    private NavigableSet<Integer> populatedSet(int n) {
+    private static NavigableSet<Integer> populatedSet(int n) {
         TreeSet<Integer> q = new TreeSet<>();
         assertTrue(q.isEmpty());
 
@@ -79,7 +79,7 @@
     /**
      * Returns a new set of first 5 ints.
      */
-    private NavigableSet set5() {
+    private static NavigableSet set5() {
         TreeSet q = new TreeSet();
         assertTrue(q.isEmpty());
         q.add(one);
@@ -94,7 +94,7 @@
         return s;
     }
 
-    private NavigableSet dset5() {
+    private static NavigableSet dset5() {
         TreeSet q = new TreeSet();
         assertTrue(q.isEmpty());
         q.add(m1);
--- a/jdk/test/java/util/concurrent/tck/VectorTest.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/jdk/test/java/util/concurrent/tck/VectorTest.java	Tue Apr 18 22:25:33 2017 +0200
@@ -33,11 +33,9 @@
  */
 
 import java.util.Vector;
-import java.util.Collection;
 import java.util.List;
 
 import junit.framework.Test;
-import junit.framework.TestSuite;
 
 public class VectorTest extends JSR166TestCase {
     public static void main(String[] args) {
--- a/jdk/test/java/util/logging/LocalizedLevelName.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/jdk/test/java/util/logging/LocalizedLevelName.java	Tue Apr 18 22:25:33 2017 +0200
@@ -21,7 +21,6 @@
  * questions.
  */
 
-import java.lang.reflect.Module;
 import java.util.*;
 import java.util.logging.*;
 
--- a/jdk/test/java/util/logging/modules/pkgs/p3/test/ResourceBundleTest.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/jdk/test/java/util/logging/modules/pkgs/p3/test/ResourceBundleTest.java	Tue Apr 18 22:25:33 2017 +0200
@@ -23,7 +23,6 @@
 
 package p3.test;
 
-import java.lang.reflect.Module;
 import java.util.logging.Logger;
 import java.util.MissingResourceException;
 import java.util.PropertyResourceBundle;
--- a/jdk/test/java/util/spi/ResourceBundleControlProvider/test/jdk/test/ResourceBundleDelegate.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/jdk/test/java/util/spi/ResourceBundleControlProvider/test/jdk/test/ResourceBundleDelegate.java	Tue Apr 18 22:25:33 2017 +0200
@@ -23,7 +23,6 @@
 
 package jdk.test;
 
-import java.lang.reflect.Module;
 import java.util.Locale;
 import java.util.ResourceBundle;
 
--- a/jdk/test/javax/xml/jaxp/Encodings/CheckEncodingPropertiesFile.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/jdk/test/javax/xml/jaxp/Encodings/CheckEncodingPropertiesFile.java	Tue Apr 18 22:25:33 2017 +0200
@@ -39,7 +39,6 @@
 import com.sun.org.apache.xml.internal.serializer.EncodingInfo;
 import com.sun.org.apache.xml.internal.serializer.Encodings;
 import java.io.InputStreamReader;
-import java.lang.reflect.Module;
 import java.lang.reflect.Method;
 import java.nio.charset.Charset;
 import java.util.ArrayList;
--- a/jdk/test/jdk/internal/jimage/JImageOpenTest.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/jdk/test/jdk/internal/jimage/JImageOpenTest.java	Tue Apr 18 22:25:33 2017 +0200
@@ -21,7 +21,6 @@
  * questions.
  */
 
-import java.lang.reflect.Layer;
 import java.net.URI;
 import java.nio.file.FileSystem;
 import java.nio.file.FileSystems;
@@ -48,7 +47,7 @@
 
         final List<String> names = Files.walk(root)
                 .filter(p -> p.getNameCount() > 2)
-                .filter(p -> Layer.boot().findModule(p.getName(1).toString()).isPresent())
+                .filter(p -> ModuleLayer.boot().findModule(p.getName(1).toString()).isPresent())
                 .map(p -> p.subpath(2, p.getNameCount()))
                 .map(p -> p.toString())
                 .filter(s -> s.endsWith(".class") && !s.endsWith("module-info.class"))
--- a/jdk/test/jdk/internal/util/jar/TestVersionedStream.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/jdk/test/jdk/internal/util/jar/TestVersionedStream.java	Tue Apr 18 22:25:33 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2016, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -40,7 +40,6 @@
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.UncheckedIOException;
-import java.net.URI;
 import java.nio.file.Files;
 import java.nio.file.Path;
 import java.nio.file.Paths;
@@ -168,23 +167,23 @@
 
             // verify the contents
             Map<String,String> contents = new HashMap<>();
-            contents.put("p/Bar.class", "base/p/Bar.class\n");
-            contents.put("p/Main.class", "base/p/Main.class\n");
+            contents.put("p/Bar.class", "base/p/Bar.class");
+            contents.put("p/Main.class", "base/p/Main.class");
             switch (version.major()) {
                 case 8:
-                    contents.put("p/Foo.class", "base/p/Foo.class\n");
+                    contents.put("p/Foo.class", "base/p/Foo.class");
                     break;
                 case 9:
-                    contents.put("p/Foo.class", "v9/p/Foo.class\n");
+                    contents.put("p/Foo.class", "v9/p/Foo.class");
                     break;
                 case 10:
-                    contents.put("p/Foo.class", "v10/p/Foo.class\n");
-                    contents.put("q/Bar.class", "v10/q/Bar.class\n");
+                    contents.put("p/Foo.class", "v10/p/Foo.class");
+                    contents.put("q/Bar.class", "v10/q/Bar.class");
                     break;
                 case 11:
-                    contents.put("p/Bar.class", "v11/p/Bar.class\n");
-                    contents.put("p/Foo.class", "v11/p/Foo.class\n");
-                    contents.put("q/Bar.class", "v10/q/Bar.class\n");
+                    contents.put("p/Bar.class", "v11/p/Bar.class");
+                    contents.put("p/Foo.class", "v11/p/Foo.class");
+                    contents.put("q/Bar.class", "v10/q/Bar.class");
                     break;
                 default:
                     Assert.fail("Test out of date, please add more cases");
@@ -196,7 +195,7 @@
                 Assert.assertTrue(i != -1, name + " not in enames");
                 JarEntry je = versionedEntries.get(i);
                 try (InputStream is = jf.getInputStream(je)) {
-                    String s = new String(is.readAllBytes());
+                    String s = new String(is.readAllBytes()).replaceAll(System.lineSeparator(), "");
                     Assert.assertTrue(s.endsWith(e.getValue()), s);
                 } catch (IOException x) {
                     throw new UncheckedIOException(x);
@@ -208,16 +207,13 @@
     private void createFiles(String... files) {
         ArrayList<String> list = new ArrayList();
         Arrays.stream(files)
-                .map(f -> "file:///" + userdir + "/" + f)
-                .map(f -> URI.create(f))
-                .filter(u -> u != null)
-                .map(u -> Paths.get(u))
+                .map(f -> Paths.get(userdir.toAbsolutePath().toString(), f))
                 .forEach(p -> {
                     try {
                         Files.createDirectories(p.getParent());
                         Files.createFile(p);
                         list.clear();
-                        list.add(p.toString());
+                        list.add(p.toString().replace(File.separatorChar, '/'));
                         Files.write(p, list);
                     } catch (IOException x) {
                         throw new UncheckedIOException(x);
--- a/jdk/test/jdk/modules/etc/JdkQualifiedExportTest.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/jdk/test/jdk/modules/etc/JdkQualifiedExportTest.java	Tue Apr 18 22:25:33 2017 +0200
@@ -40,7 +40,6 @@
 import java.lang.module.ModuleDescriptor.Opens;
 import java.lang.module.ModuleFinder;
 import java.lang.module.ModuleReference;
-import java.lang.reflect.Module;
 import java.util.Collections;
 import java.util.Comparator;
 import java.util.HashMap;
--- a/jdk/test/jdk/modules/etc/VerifyModuleDelegation.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/jdk/test/jdk/modules/etc/VerifyModuleDelegation.java	Tue Apr 18 22:25:33 2017 +0200
@@ -31,8 +31,6 @@
 import java.lang.module.ModuleDescriptor;
 import java.lang.module.ModuleFinder;
 import java.lang.module.ModuleReference;
-import java.lang.reflect.Layer;
-import java.lang.reflect.Module;
 import java.util.Set;
 import static java.util.stream.Collectors.toSet;
 
@@ -49,7 +47,7 @@
         = ModuleDescriptor.newModule(JAVA_BASE).build();
 
     private static final Set<ModuleDescriptor> MREFS
-            = Layer.boot().modules().stream().map(Module::getDescriptor)
+            = ModuleLayer.boot().modules().stream().map(Module::getDescriptor)
                 .collect(toSet());
 
     private void check(ModuleDescriptor md, ModuleDescriptor ref) {
@@ -69,7 +67,7 @@
 
     @Test
     public void checkLoaderDelegation() {
-        Layer boot = Layer.boot();
+        ModuleLayer boot = ModuleLayer.boot();
         MREFS.stream()
              .forEach(md -> md.requires().stream().forEach(req ->
                  {
--- a/jdk/test/jdk/modules/incubator/DefaultImage.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/jdk/test/jdk/modules/incubator/DefaultImage.java	Tue Apr 18 22:25:33 2017 +0200
@@ -34,6 +34,9 @@
 import java.io.ByteArrayOutputStream;
 import java.io.IOException;
 import java.io.PrintStream;
+import java.lang.module.ModuleDescriptor;
+import java.lang.module.ModuleFinder;
+import java.lang.module.ModuleReference;
 import java.nio.file.Files;
 import java.nio.file.Path;
 import java.nio.file.Paths;
@@ -41,13 +44,13 @@
 import java.util.stream.Stream;
 
 import org.testng.annotations.BeforeTest;
-import org.testng.annotations.DataProvider;
 import org.testng.annotations.Test;
 
 import static java.nio.charset.StandardCharsets.UTF_8;
 import static jdk.testlibrary.ProcessTools.executeCommand;
 import static org.testng.Assert.*;
 
+@Test
 public class DefaultImage {
     private static final String JAVA_HOME = System.getProperty("java.home");
     private static final Path TEST_SRC = Paths.get(System.getProperty("test.src"));
@@ -72,19 +75,13 @@
             .resultChecker(r -> r.assertOutputDoesNotContain("jdk.incubator"));
     }
 
-    @DataProvider(name = "tokens")
-    public Object[][] singleModuleValues() throws IOException {
-        return new Object[][]{ { "ALL-DEFAULT" }, { "ALL-SYSTEM"} };
-    }
-
-    @Test(dataProvider = "tokens")
-    public void testAddMods(String addModsToken) throws Throwable {
+    public void testAllDefault() throws Throwable {
         if (isExplodedBuild()) {
             System.out.println("Test cannot run on exploded build");
             return;
         }
 
-        java("--add-modules", addModsToken,
+        java("--add-modules", "ALL-DEFAULT",
              "-cp", CP_DIR.toString(),
              "listmods.ListModules")
             .assertSuccess()
@@ -92,6 +89,22 @@
             .resultChecker(r -> r.assertOutputDoesNotContain("jdk.incubator"));
     }
 
+    public void testAllSystem() throws Throwable {
+        if (isExplodedBuild()) {
+            System.out.println("Test cannot run on exploded build");
+            return;
+        }
+
+        if (containsAnyIncubatorModules()) {
+            java("--add-modules", "ALL-SYSTEM",
+                 "-cp", CP_DIR.toString(),
+                 "listmods.ListModules")
+                .assertSuccess()
+                .resultChecker(r -> r.assertOutputContains("java.base"))
+                .resultChecker(r -> r.assertOutputContains("jdk.incubator"));
+        }
+    }
+
     static ToolResult java(String... opts) throws Throwable {
         ByteArrayOutputStream baos = new ByteArrayOutputStream();
         PrintStream ps = new PrintStream(baos);
@@ -155,4 +168,14 @@
         Path modulesPath = Paths.get(JAVA_HOME).resolve("lib").resolve("modules");
         return Files.notExists(modulesPath);
     }
+
+    static boolean containsAnyIncubatorModules() {
+        return ModuleFinder.ofSystem().findAll().stream()
+                .map(ModuleReference::descriptor)
+                .map(ModuleDescriptor::name)
+                .filter(mn -> mn.startsWith("jdk.incubator"))
+                .map(mn -> true)
+                .findAny()
+                .orElse(false);
+    }
 }
--- a/jdk/test/jdk/modules/incubator/ImageModules.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/jdk/test/jdk/modules/incubator/ImageModules.java	Tue Apr 18 22:25:33 2017 +0200
@@ -98,7 +98,7 @@
               List.of("hello world", "message.converter", "java.base"),
               List.of("WARNING") },
             { "--do-not-resolve-by-default",
-              List.of("ALL-DEFAULT", "ALL-SYSTEM"),
+              List.of("ALL-DEFAULT"),
               ToolResult.ASSERT_FAILURE,
               List.of("java.base", "java.lang.ClassNotFoundException: converter.MessageConverter"),
               List.of("WARNING", "message.converter") },
@@ -109,7 +109,7 @@
                       "WARNING: Using incubator modules: message.converter"),
               List.of() },
             { "--do-not-resolve-by-default --warn-if-resolved=incubating",
-              List.of("ALL-DEFAULT", "ALL-SYSTEM"),
+              List.of("ALL-DEFAULT"),
               ToolResult.ASSERT_FAILURE,
               List.of("java.base", "java.lang.ClassNotFoundException: converter.MessageConverter"),
               List.of("WARNING", "message.converter") },
@@ -215,13 +215,13 @@
               List.of() },
             { "--do-not-resolve-by-default",
               "",
-              List.of("ALL-DEFAULT", "ALL-SYSTEM"),
+              List.of("ALL-DEFAULT"),
               ToolResult.ASSERT_FAILURE,
               List.of("java.lang.ClassNotFoundException: writer.MessageWriter", "java.base"),
               List.of("message.writer") },
             { "--do-not-resolve-by-default",
               "--do-not-resolve-by-default",
-              List.of("ALL-DEFAULT", "ALL-SYSTEM"),
+              List.of("ALL-DEFAULT"),
               ToolResult.ASSERT_FAILURE,
               List.of("java.lang.ClassNotFoundException: writer.MessageWriter", "java.base"),
               List.of("message.converter", "message.writer") },
@@ -239,7 +239,8 @@
               ToolResult.ASSERT_SUCCESS,
               List.of("HELLO CHEGAR !!!", "message.writer", "message.converter", "java.base",
                       "WARNING: Using incubator modules: message.converter"),
-              List.of() } };
+              List.of() }
+            };
         return values;
     }
 
--- a/jdk/test/jdk/modules/incubator/src/cp/listmods/ListModules.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/jdk/test/jdk/modules/incubator/src/cp/listmods/ListModules.java	Tue Apr 18 22:25:33 2017 +0200
@@ -23,13 +23,11 @@
 
 package listmods;
 
-import java.lang.reflect.Layer;
-import java.lang.reflect.Module;
 import static java.util.stream.Collectors.joining;
 
 public class ListModules {
     public static void main(String[] args) throws Exception {
-        System.out.println(Layer.boot()
+        System.out.println(ModuleLayer.boot()
                                 .modules()
                                 .stream()
                                 .map(Module::getName)
--- a/jdk/test/jdk/modules/incubator/src/cp/test/ConvertToLowerCase.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/jdk/test/jdk/modules/incubator/src/cp/test/ConvertToLowerCase.java	Tue Apr 18 22:25:33 2017 +0200
@@ -23,13 +23,11 @@
 
 package test;
 
-import java.lang.reflect.Layer;
-import java.lang.reflect.Module;
 import static java.util.stream.Collectors.joining;
 
 public class ConvertToLowerCase {
     public static void main(String[] args) {
-        System.out.println(Layer.boot()
+        System.out.println(ModuleLayer.boot()
                                 .modules()
                                 .stream()
                                 .map(Module::getName)
--- a/jdk/test/jdk/modules/incubator/src/cp/test/WriteUpperCase.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/jdk/test/jdk/modules/incubator/src/cp/test/WriteUpperCase.java	Tue Apr 18 22:25:33 2017 +0200
@@ -23,13 +23,11 @@
 
 package test;
 
-import java.lang.reflect.Layer;
-import java.lang.reflect.Module;
 import static java.util.stream.Collectors.joining;
 
 public class WriteUpperCase {
     public static void main(String[] args) {
-        System.out.println(Layer.boot()
+        System.out.println(ModuleLayer.boot()
                                 .modules()
                                 .stream()
                                 .map(Module::getName)
--- a/jdk/test/jdk/modules/open/Basic.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/jdk/test/jdk/modules/open/Basic.java	Tue Apr 18 22:25:33 2017 +0200
@@ -36,7 +36,6 @@
 import java.lang.module.ModuleDescriptor;
 import java.lang.reflect.Constructor;
 import java.lang.reflect.InaccessibleObjectException;
-import java.lang.reflect.Module;
 
 import org.testng.annotations.Test;
 import org.testng.annotations.BeforeTest;
--- a/jdk/test/jdk/modules/scenarios/automaticmodules/src/basictest/test/Main.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/jdk/test/jdk/modules/scenarios/automaticmodules/src/basictest/test/Main.java	Tue Apr 18 22:25:33 2017 +0200
@@ -23,9 +23,6 @@
 
 package test;
 
-import java.lang.reflect.Layer;
-import java.lang.reflect.Module;
-
 import http.HttpServer;
 
 /**
@@ -47,8 +44,8 @@
         cl = ClassLoader.getSystemClassLoader();
         assertTrue(httpModule.canRead(cl.getUnnamedModule()));
 
-        // and read all modules in the boot Layer
-        Layer layer = Layer.boot();
+        // and read all modules in the boot layer
+        ModuleLayer layer = ModuleLayer.boot();
         layer.modules().forEach(m -> assertTrue(httpModule.canRead(m)));
 
         // run code in the automatic modue, ensures access is allowed
--- a/jdk/test/jdk/modules/scenarios/automaticmodules/src/sptest/test/Main.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/jdk/test/jdk/modules/scenarios/automaticmodules/src/sptest/test/Main.java	Tue Apr 18 22:25:33 2017 +0200
@@ -26,8 +26,6 @@
 import java.lang.module.ModuleDescriptor;
 import java.lang.module.ModuleDescriptor.Requires;
 import java.lang.module.ModuleDescriptor.Provides;
-import java.lang.reflect.Layer;
-import java.lang.reflect.Module;
 import java.util.Map;
 import java.util.Optional;
 import java.util.ServiceLoader;
@@ -36,7 +34,7 @@
 import javax.script.ScriptEngineFactory;
 
 /**
- * Test that the automatic module "bananascript" is in the boot Layer and
+ * Test that the automatic module "bananascript" is in the boot layer and
  * it behaves as a service provider.
  */
 
@@ -44,7 +42,7 @@
 
     public static void main(String[] args) throws Exception {
 
-        Optional<Module> om = Layer.boot().findModule("bananascript");
+        Optional<Module> om = ModuleLayer.boot().findModule("bananascript");
         assertTrue(om.isPresent());
 
         ModuleDescriptor descriptor = om.get().getDescriptor();
--- a/jdk/test/jdk/modules/scenarios/container/src/container/container/Main.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/jdk/test/jdk/modules/scenarios/container/src/container/container/Main.java	Tue Apr 18 22:25:33 2017 +0200
@@ -27,9 +27,7 @@
 import java.lang.module.Configuration;
 import java.lang.module.ModuleFinder;
 import java.lang.module.ResolvedModule;
-import java.lang.reflect.Layer;
 import java.lang.reflect.Method;
-import java.lang.reflect.Module;
 import java.nio.file.Path;
 import java.nio.file.Paths;
 import java.util.Set;
@@ -43,7 +41,7 @@
     public static void main(String[] args) throws Exception {
 
         System.out.println("Boot layer");
-        Layer.boot()
+        ModuleLayer.boot()
              .modules()
              .stream()
              .map(Module::getName)
@@ -70,7 +68,7 @@
 
         ModuleFinder finder = ModuleFinder.of(paths);
 
-        Configuration cf = Layer.boot().configuration()
+        Configuration cf = ModuleLayer.boot().configuration()
             .resolveAndBind(finder,
                             ModuleFinder.of(),
                             Set.of(appModuleName));
@@ -81,9 +79,9 @@
           .sorted()
           .forEach(mn -> System.out.format("  %s%n", mn));
 
-        // reify the configuration as a Layer
+        // reify the configuration as a module layer
         ClassLoader scl = ClassLoader.getSystemClassLoader();
-        Layer layer = Layer.boot().defineModulesWithManyLoaders(cf, scl);
+        ModuleLayer layer = ModuleLayer.boot().defineModulesWithManyLoaders(cf, scl);
 
         // invoke application main method
         ClassLoader loader = layer.findLoader(appModuleName);
--- a/jdk/test/lib/testlibrary/jdk/testlibrary/JDKToolLauncher.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/jdk/test/lib/testlibrary/jdk/testlibrary/JDKToolLauncher.java	Tue Apr 18 22:25:33 2017 +0200
@@ -24,7 +24,6 @@
 package jdk.testlibrary;
 
 import java.util.ArrayList;
-import java.util.Arrays;
 import java.util.List;
 
 /**
@@ -60,7 +59,6 @@
         } else {
             executable = JDKToolFinder.getTestJDKTool(tool);
         }
-        vmArgs.addAll(Arrays.asList(ProcessTools.getPlatformSpecificVMArgs()));
     }
 
     /**
--- a/jdk/test/lib/testlibrary/jdk/testlibrary/ProcessTools.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/jdk/test/lib/testlibrary/jdk/testlibrary/ProcessTools.java	Tue Apr 18 22:25:33 2017 +0200
@@ -260,31 +260,13 @@
     }
 
     /**
-     * Get platform specific VM arguments (e.g. -d64 on 64bit Solaris)
-     *
-     * @return String[] with platform specific arguments, empty if there are
-     *         none
-     */
-    public static String[] getPlatformSpecificVMArgs() {
-        String osName = System.getProperty("os.name");
-        String dataModel = System.getProperty("sun.arch.data.model");
-
-        if (osName.equals("SunOS") && dataModel.equals("64")) {
-            return new String[] { "-d64" };
-        }
-
-        return new String[] {};
-    }
-
-    /**
      * Create ProcessBuilder using the java launcher from the jdk to be tested,
      * and with any platform specific arguments prepended.
      *
      * @param command Arguments to pass to the java command.
      * @return The ProcessBuilder instance representing the java command.
      */
-    public static ProcessBuilder createJavaProcessBuilder(String... command)
-            throws Exception {
+    public static ProcessBuilder createJavaProcessBuilder(String... command) {
         return createJavaProcessBuilder(false, command);
     }
 
@@ -297,12 +279,11 @@
      * @param command Arguments to pass to the java command.
      * @return The ProcessBuilder instance representing the java command.
      */
-    public static ProcessBuilder createJavaProcessBuilder(boolean addTestVmAndJavaOptions, String... command) throws Exception {
+    public static ProcessBuilder createJavaProcessBuilder(boolean addTestVmAndJavaOptions, String... command) {
         String javapath = JDKToolFinder.getJDKTool("java");
 
         ArrayList<String> args = new ArrayList<>();
         args.add(javapath);
-        Collections.addAll(args, getPlatformSpecificVMArgs());
 
         if (addTestVmAndJavaOptions) {
             // -cp is needed to make sure the same classpath is used whether the test is
--- a/jdk/test/sun/management/LoggingTest/test.loggerfinder/test/loggerfinder/TestLoggerFinder.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/jdk/test/sun/management/LoggingTest/test.loggerfinder/test/loggerfinder/TestLoggerFinder.java	Tue Apr 18 22:25:33 2017 +0200
@@ -26,7 +26,6 @@
 import java.lang.System.Logger;
 import java.lang.System.Logger.Level;
 import java.lang.System.LoggerFinder;
-import java.lang.reflect.Module;
 import java.security.AccessController;
 import java.security.PrivilegedAction;
 import java.util.Optional;
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/sun/security/ssl/CertPathRestrictions/JSSEClient.java	Tue Apr 18 22:25:33 2017 +0200
@@ -0,0 +1,48 @@
+/*
+ * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
+ * ORACLE PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
+ */
+
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.net.InetSocketAddress;
+
+import javax.net.ssl.SSLContext;
+import javax.net.ssl.SSLSocket;
+import javax.net.ssl.SSLSocketFactory;
+
+/*
+ * A SSL socket client.
+ */
+public class JSSEClient {
+
+    public static void main(String[] args) throws Exception {
+        System.out.println("Client: arguments=" + String.join("; ", args));
+
+        int port = Integer.valueOf(args[0]);
+        String[] trustNames = args[1].split(TLSRestrictions.DELIMITER);
+        String[] certNames = args[2].split(TLSRestrictions.DELIMITER);
+        String constraint = args[3];
+
+        TLSRestrictions.setConstraint("Client", constraint);
+
+        SSLContext context = TLSRestrictions.createSSLContext(
+                trustNames, certNames);
+        SSLSocketFactory socketFactory = context.getSocketFactory();
+        try (SSLSocket socket = (SSLSocket) socketFactory.createSocket()) {
+            socket.connect(new InetSocketAddress("localhost", port),
+                    TLSRestrictions.TIMEOUT);
+            socket.setSoTimeout(TLSRestrictions.TIMEOUT);
+            System.out.println("Client: connected");
+
+            InputStream sslIS = socket.getInputStream();
+            OutputStream sslOS = socket.getOutputStream();
+            sslOS.write('C');
+            sslOS.flush();
+            sslIS.read();
+            System.out.println("Client: finished");
+        } catch (Exception e) {
+            throw new RuntimeException("Client: failed.", e);
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/sun/security/ssl/CertPathRestrictions/JSSEServer.java	Tue Apr 18 22:25:33 2017 +0200
@@ -0,0 +1,65 @@
+/*
+ * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
+ * ORACLE PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
+ */
+
+import java.io.InputStream;
+import java.io.OutputStream;
+
+import javax.net.ssl.SSLContext;
+import javax.net.ssl.SSLServerSocket;
+import javax.net.ssl.SSLServerSocketFactory;
+import javax.net.ssl.SSLSocket;
+
+/*
+ * A SSL socket server.
+ */
+public class JSSEServer {
+
+    private SSLServerSocket server = null;
+
+    private Exception exception = null;
+
+    public JSSEServer(SSLContext context, String constraint,
+            boolean needClientAuth) throws Exception {
+        TLSRestrictions.setConstraint("Server", constraint);
+
+        SSLServerSocketFactory serverFactory = context.getServerSocketFactory();
+        server = (SSLServerSocket) serverFactory.createServerSocket(0);
+        server.setSoTimeout(TLSRestrictions.TIMEOUT);
+        server.setNeedClientAuth(needClientAuth); // for dual authentication
+        System.out.println("Server: port=" + getPort());
+    }
+
+    public void start() {
+        new Thread(new Runnable() {
+
+            @Override
+            public void run() {
+                try {
+                    System.out.println("Server: started");
+                    try (SSLSocket socket = (SSLSocket) server.accept()) {
+                        socket.setSoTimeout(TLSRestrictions.TIMEOUT);
+                        InputStream sslIS = socket.getInputStream();
+                        OutputStream sslOS = socket.getOutputStream();
+                        sslIS.read();
+                        sslOS.write('S');
+                        sslOS.flush();
+                        System.out.println("Server: finished");
+                    }
+                } catch (Exception e) {
+                    e.printStackTrace(System.out);
+                    exception = e;
+                }
+            }
+        }).start();
+    }
+
+    public int getPort() {
+        return server.getLocalPort();
+    }
+
+    public Exception getException() {
+        return exception;
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/sun/security/ssl/CertPathRestrictions/TLSRestrictions.java	Tue Apr 18 22:25:33 2017 +0200
@@ -0,0 +1,544 @@
+/*
+ * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.SocketTimeoutException;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.security.KeyFactory;
+import java.security.KeyStore;
+import java.security.PrivateKey;
+import java.security.Security;
+import java.security.cert.Certificate;
+import java.security.cert.CertificateFactory;
+import java.security.spec.PKCS8EncodedKeySpec;
+import java.util.Base64;
+import java.util.stream.Collectors;
+
+import javax.net.ssl.KeyManagerFactory;
+import javax.net.ssl.SSLContext;
+import javax.net.ssl.SSLHandshakeException;
+import javax.net.ssl.TrustManagerFactory;
+
+import jdk.test.lib.process.OutputAnalyzer;
+import jdk.test.lib.process.ProcessTools;
+
+/*
+ * @test
+ * @summary Verify the restrictions for certificate path on JSSE with custom trust store.
+ * @library /test/lib
+ * @compile JSSEClient.java
+ * @run main/othervm -Djava.security.debug=certpath TLSRestrictions DEFAULT
+ * @run main/othervm -Djava.security.debug=certpath TLSRestrictions C1
+ * @run main/othervm -Djava.security.debug=certpath TLSRestrictions S1
+ * @run main/othervm -Djava.security.debug=certpath TLSRestrictions C2
+ * @run main/othervm -Djava.security.debug=certpath TLSRestrictions S2
+ * @run main/othervm -Djava.security.debug=certpath TLSRestrictions C3
+ * @run main/othervm -Djava.security.debug=certpath TLSRestrictions S3
+ * @run main/othervm -Djava.security.debug=certpath TLSRestrictions C4
+ * @run main/othervm -Djava.security.debug=certpath TLSRestrictions S4
+ * @run main/othervm -Djava.security.debug=certpath TLSRestrictions C5
+ * @run main/othervm -Djava.security.debug=certpath TLSRestrictions S5
+ * @run main/othervm -Djava.security.debug=certpath TLSRestrictions C6
+ * @run main/othervm -Djava.security.debug=certpath TLSRestrictions S6
+ * @run main/othervm -Djava.security.debug=certpath TLSRestrictions C7
+ * @run main/othervm -Djava.security.debug=certpath TLSRestrictions S7
+ * @run main/othervm -Djava.security.debug=certpath TLSRestrictions C8
+ * @run main/othervm -Djava.security.debug=certpath TLSRestrictions S8
+ * @run main/othervm -Djava.security.debug=certpath TLSRestrictions C9
+ * @run main/othervm -Djava.security.debug=certpath TLSRestrictions S9
+ */
+public class TLSRestrictions {
+
+    private static final String TEST_CLASSES = System.getProperty("test.classes");
+    private static final char[] PASSWORD = "".toCharArray();
+    private static final String CERT_DIR = System.getProperty("cert.dir",
+            System.getProperty("test.src") + "/certs");
+
+    static final String PROP = "jdk.certpath.disabledAlgorithms";
+    static final String NOSHA1 = "MD2, MD5";
+    private static final String TLSSERVER = "SHA1 usage TLSServer";
+    private static final String TLSCLIENT = "SHA1 usage TLSClient";
+    static final String JDKCATLSSERVER = "SHA1 jdkCA & usage TLSServer";
+    static final String JDKCATLSCLIENT = "SHA1 jdkCA & usage TLSClient";
+
+    // This is a space holder in command arguments, and stands for none certificate.
+    static final String NONE_CERT = "NONE_CERT";
+
+    static final String DELIMITER = ",";
+    static final int TIMEOUT = 30000;
+
+    // It checks if java.security contains constraint "SHA1 jdkCA & usage TLSServer"
+    // for jdk.certpath.disabledAlgorithms by default.
+    private static void checkDefaultConstraint() {
+        System.out.println(
+                "Case: Checks the default value of jdk.certpath.disabledAlgorithms");
+        if (!Security.getProperty(PROP).contains(JDKCATLSSERVER)) {
+            throw new RuntimeException(String.format(
+                    "%s doesn't contain constraint \"%s\", the real value is \"%s\".",
+                    PROP, JDKCATLSSERVER, Security.getProperty(PROP)));
+        }
+    }
+
+    /*
+     * This method creates trust store and key store with specified certificates
+     * respectively. And then it creates SSL context with the stores.
+     * If trustNames contains NONE_CERT only, it does not create a custom trust
+     * store, but the default one in JDK.
+     *
+     * @param trustNames Trust anchors, which are used to create custom trust store.
+     *                   If null, no custom trust store is created and the default
+     *                   trust store in JDK is used.
+     * @param certNames Certificate chain, which is used to create key store.
+     *                  It cannot be null.
+     */
+    static SSLContext createSSLContext(String[] trustNames,
+            String[] certNames) throws Exception {
+        CertificateFactory certFactory = CertificateFactory.getInstance("X.509");
+
+        TrustManagerFactory tmf = null;
+        if (trustNames != null && trustNames.length > 0
+                && !trustNames[0].equals(NONE_CERT)) {
+            KeyStore trustStore = KeyStore.getInstance("JKS");
+            trustStore.load(null, null);
+            for (int i = 0; i < trustNames.length; i++) {
+                try (InputStream is = new ByteArrayInputStream(
+                        loadCert(trustNames[i]).getBytes())) {
+                    Certificate trustCert = certFactory.generateCertificate(is);
+                    trustStore.setCertificateEntry("trustCert-" + i, trustCert);
+                }
+            }
+
+            tmf = TrustManagerFactory.getInstance("PKIX");
+            tmf.init(trustStore);
+        }
+
+        Certificate[] certChain = new Certificate[certNames.length];
+        for (int i = 0; i < certNames.length; i++) {
+            try (InputStream is = new ByteArrayInputStream(
+                    loadCert(certNames[i]).getBytes())) {
+                Certificate cert = certFactory.generateCertificate(is);
+                certChain[i] = cert;
+            }
+        }
+
+        PKCS8EncodedKeySpec privKeySpec = new PKCS8EncodedKeySpec(
+                Base64.getMimeDecoder().decode(loadPrivKey(certNames[0])));
+        KeyFactory keyFactory = KeyFactory.getInstance("RSA");
+        PrivateKey privKey = keyFactory.generatePrivate(privKeySpec);
+
+        KeyStore keyStore = KeyStore.getInstance("JKS");
+        keyStore.load(null, null);
+        keyStore.setKeyEntry("keyCert", privKey, PASSWORD, certChain);
+
+        KeyManagerFactory kmf = KeyManagerFactory.getInstance("NewSunX509");
+        kmf.init(keyStore, PASSWORD);
+
+        SSLContext context = SSLContext.getInstance("TLS");
+        context.init(kmf.getKeyManagers(),
+                tmf == null ? null : tmf.getTrustManagers(), null);
+        return context;
+    }
+
+    /*
+     * This method sets jdk.certpath.disabledAlgorithms, and then retrieves
+     * and prints its value.
+     */
+    static void setConstraint(String side, String constraint) {
+        System.out.printf("%s: Old %s=%s%n", side, PROP,
+                Security.getProperty(PROP));
+        Security.setProperty(PROP, constraint);
+        System.out.printf("%s: New %s=%s%n", side, PROP,
+                Security.getProperty(PROP));
+    }
+
+    /*
+     * This method is used to run a variety of cases.
+     * It launches a server, and then takes a client to connect the server.
+     * Both of server and client use the same certificates.
+     *
+     * @param trustNames Trust anchors, which are used to create custom trust store.
+     *                   If null, the default trust store in JDK is used.
+     * @param certNames Certificate chain, which is used to create key store.
+     *                  It cannot be null. The first certificate is regarded as
+     *                  the end entity.
+     * @param serverConstraint jdk.certpath.disabledAlgorithms value on server side.
+     * @param clientConstraint jdk.certpath.disabledAlgorithms value on client side.
+     * @param needClientAuth If true, server side acquires client authentication;
+     *                       otherwise, false.
+     * @param pass If true, the connection should be blocked; otherwise, false.
+     */
+    static void testConstraint(String[] trustNames, String[] certNames,
+            String serverConstraint, String clientConstraint,
+            boolean needClientAuth, boolean pass) throws Exception {
+        String trustNameStr = trustNames == null ? ""
+                : String.join(DELIMITER, trustNames);
+        String certNameStr = certNames == null ? ""
+                : String.join(DELIMITER, certNames);
+
+        System.out.printf("Case:%n"
+                + "  trustNames=%s; certNames=%s%n"
+                + "  serverConstraint=%s; clientConstraint=%s%n"
+                + "  needClientAuth=%s%n"
+                + "  pass=%s%n%n",
+                trustNameStr, certNameStr,
+                serverConstraint, clientConstraint,
+                needClientAuth,
+                pass);
+
+        JSSEServer server = new JSSEServer(
+                createSSLContext(trustNames, certNames),
+                serverConstraint,
+                needClientAuth);
+        int port = server.getPort();
+        server.start();
+
+        // Run client on another JVM so that its properties cannot be in conflict
+        // with server's.
+        OutputAnalyzer outputAnalyzer = ProcessTools.executeTestJvm(
+                "-Dcert.dir=" + CERT_DIR,
+                "-Djava.security.debug=certpath",
+                "-classpath",
+                TEST_CLASSES,
+                "JSSEClient",
+                port + "",
+                trustNameStr,
+                certNameStr,
+                clientConstraint);
+        int exitValue = outputAnalyzer.getExitValue();
+        String clientOut = outputAnalyzer.getOutput();
+
+        Exception serverException = server.getException();
+        if (serverException != null) {
+            System.out.println("Server: failed");
+        }
+
+        System.out.println("---------- Client output start ----------");
+        System.out.println(clientOut);
+        System.out.println("---------- Client output end ----------");
+
+        if (serverException instanceof SocketTimeoutException
+                || clientOut.contains("SocketTimeoutException")) {
+            System.out.println("The communication gets timeout and skips the test.");
+            return;
+        }
+
+        if (pass) {
+            if (serverException != null || exitValue != 0) {
+                throw new RuntimeException(
+                        "Unexpected failure. Operation was blocked.");
+            }
+        } else {
+            if (serverException == null && exitValue == 0) {
+                throw new RuntimeException(
+                        "Unexpected pass. Operation was allowed.");
+            }
+
+            // The test may encounter non-SSL issues, like network problem.
+            if (!(serverException instanceof SSLHandshakeException
+                    || clientOut.contains("SSLHandshakeException"))) {
+                throw new RuntimeException("Failure with unexpected exception.");
+            }
+        }
+    }
+
+    /*
+     * This method is used to run a variety of cases, which don't require client
+     * authentication by default.
+     */
+    static void testConstraint(String[] trustNames, String[] certNames,
+            String serverConstraint, String clientConstraint, boolean pass)
+            throws Exception {
+        testConstraint(trustNames, certNames, serverConstraint, clientConstraint,
+                false, pass);
+    }
+
+    public static void main(String[] args) throws Exception {
+        switch (args[0]) {
+        // Case DEFAULT only checks one of default settings for
+        // jdk.certpath.disabledAlgorithms in JDK/conf/security/java.security.
+        case "DEFAULT":
+            checkDefaultConstraint();
+            break;
+
+        // Cases C1 and S1 use SHA256 root CA in trust store,
+        // and use SHA256 end entity in key store.
+        // C1 only sets constraint "SHA1 usage TLSServer" on client side;
+        // S1 only sets constraint "SHA1 usage TLSClient" on server side with client auth.
+        // The connection of the both cases should not be blocked.
+        case "C1":
+            testConstraint(
+                    new String[] { "ROOT_CA_SHA256" },
+                    new String[] { "INTER_CA_SHA256-ROOT_CA_SHA256" },
+                    NOSHA1,
+                    TLSSERVER,
+                    true);
+            break;
+        case "S1":
+            testConstraint(
+                    new String[] { "ROOT_CA_SHA256" },
+                    new String[] { "INTER_CA_SHA256-ROOT_CA_SHA256" },
+                    TLSCLIENT,
+                    NOSHA1,
+                    true,
+                    true);
+            break;
+
+        // Cases C2 and S2 use SHA256 root CA in trust store,
+        // and use SHA1 end entity in key store.
+        // C2 only sets constraint "SHA1 usage TLSServer" on client side;
+        // S2 only sets constraint "SHA1 usage TLSClient" on server side with client auth.
+        // The connection of the both cases should be blocked.
+        case "C2":
+            testConstraint(
+                    new String[] { "ROOT_CA_SHA256" },
+                    new String[] { "INTER_CA_SHA1-ROOT_CA_SHA256" },
+                    NOSHA1,
+                    TLSSERVER,
+                    false);
+            break;
+        case "S2":
+            testConstraint(
+                    new String[] { "ROOT_CA_SHA256" },
+                    new String[] { "INTER_CA_SHA1-ROOT_CA_SHA256" },
+                    TLSCLIENT,
+                    NOSHA1,
+                    true,
+                    false);
+            break;
+
+        // Cases C3 and S3 use SHA1 root CA in trust store,
+        // and use SHA1 end entity in key store.
+        // C3 only sets constraint "SHA1 usage TLSServer" on client side;
+        // S3 only sets constraint "SHA1 usage TLSClient" on server side with client auth.
+        // The connection of the both cases should be blocked.
+        case "C3":
+            testConstraint(
+                    new String[] { "ROOT_CA_SHA1" },
+                    new String[] { "INTER_CA_SHA1-ROOT_CA_SHA1" },
+                    NOSHA1,
+                    TLSSERVER,
+                    false);
+            break;
+        case "S3":
+            testConstraint(
+                    new String[] { "ROOT_CA_SHA1" },
+                    new String[] { "INTER_CA_SHA1-ROOT_CA_SHA1" },
+                    TLSCLIENT,
+                    NOSHA1,
+                    true,
+                    false);
+            break;
+
+        // Cases C4 and S4 use SHA1 root CA as trust store,
+        // and use SHA256 end entity in key store.
+        // C4 only sets constraint "SHA1 usage TLSServer" on client side;
+        // S4 only sets constraint "SHA1 usage TLSClient" on server side with client auth.
+        // The connection of the both cases should not be blocked.
+        case "C4":
+            testConstraint(
+                    new String[] { "ROOT_CA_SHA1" },
+                    new String[] { "INTER_CA_SHA256-ROOT_CA_SHA1" },
+                    NOSHA1,
+                    TLSSERVER,
+                    true);
+            break;
+        case "S4":
+            testConstraint(
+                    new String[] { "ROOT_CA_SHA1" },
+                    new String[] { "INTER_CA_SHA256-ROOT_CA_SHA1" },
+                    TLSCLIENT,
+                    NOSHA1,
+                    true,
+                    true);
+            break;
+
+        // Cases C5 and S5 use SHA1 root CA in trust store,
+        // and use SHA256 intermediate CA and SHA256 end entity in key store.
+        // C5 only sets constraint "SHA1 usage TLSServer" on client side;
+        // S5 only sets constraint "SHA1 usage TLSClient" on server side with client auth.
+        // The connection of the both cases should not be blocked.
+        case "C5":
+            testConstraint(
+                    new String[] { "ROOT_CA_SHA1" },
+                    new String[] {
+                            "END_ENTITY_SHA256-INTER_CA_SHA256-ROOT_CA_SHA1",
+                            "INTER_CA_SHA256-ROOT_CA_SHA1" },
+                    NOSHA1,
+                    TLSSERVER,
+                    true);
+            break;
+        case "S5":
+            testConstraint(
+                    new String[] { "ROOT_CA_SHA1" },
+                    new String[] {
+                            "END_ENTITY_SHA256-INTER_CA_SHA256-ROOT_CA_SHA1",
+                            "INTER_CA_SHA256-ROOT_CA_SHA1" },
+                    TLSCLIENT,
+                    NOSHA1,
+                    true,
+                    true);
+            break;
+
+        // Cases C6 and S6 use SHA1 root CA as trust store,
+        // and use SHA1 intermediate CA and SHA256 end entity in key store.
+        // C6 only sets constraint "SHA1 usage TLSServer" on client side;
+        // S6 only sets constraint "SHA1 usage TLSClient" on server side with client auth.
+        // The connection of the both cases should be blocked.
+        case "C6":
+            testConstraint(
+                    new String[] { "ROOT_CA_SHA1" },
+                    new String[] {
+                            "END_ENTITY_SHA256-INTER_CA_SHA1-ROOT_CA_SHA1",
+                            "INTER_CA_SHA1-ROOT_CA_SHA1" },
+                    NOSHA1,
+                    TLSSERVER,
+                    false);
+            break;
+        case "S6":
+            testConstraint(
+                    new String[] { "ROOT_CA_SHA1" },
+                    new String[] {
+                            "END_ENTITY_SHA256-INTER_CA_SHA1-ROOT_CA_SHA1",
+                            "INTER_CA_SHA1-ROOT_CA_SHA1" },
+                    TLSCLIENT,
+                    NOSHA1,
+                    true,
+                    false);
+            break;
+
+        // Cases C7 and S7 use SHA256 root CA in trust store,
+        // and use SHA256 intermediate CA and SHA1 end entity in key store.
+        // C7 only sets constraint "SHA1 usage TLSServer" on client side;
+        // S7 only sets constraint "SHA1 usage TLSClient" on server side with client auth.
+        // The connection of the both cases should be blocked.
+        case "C7":
+            testConstraint(
+                    new String[] { "ROOT_CA_SHA256" },
+                    new String[] {
+                            "END_ENTITY_SHA1-INTER_CA_SHA256-ROOT_CA_SHA256",
+                            "INTER_CA_SHA256-ROOT_CA_SHA256" },
+                    NOSHA1,
+                    TLSSERVER,
+                    false);
+            break;
+        case "S7":
+            testConstraint(
+                    new String[] { "ROOT_CA_SHA256" },
+                    new String[] {
+                            "END_ENTITY_SHA1-INTER_CA_SHA256-ROOT_CA_SHA256",
+                            "INTER_CA_SHA256-ROOT_CA_SHA256" },
+                    TLSCLIENT,
+                    NOSHA1,
+                    true,
+                    false);
+            break;
+
+        // Cases C8 and S8 use SHA256 root CA in trust store,
+        // and use SHA1 intermediate CA and SHA256 end entity in key store.
+        // C8 only sets constraint "SHA1 usage TLSServer" on client side;
+        // S8 only sets constraint "SHA1 usage TLSClient" on server side with client auth.
+        // The connection of the both cases should be blocked.
+        case "C8":
+            testConstraint(
+                    new String[] { "ROOT_CA_SHA256" },
+                    new String[] {
+                            "END_ENTITY_SHA256-INTER_CA_SHA1-ROOT_CA_SHA256",
+                            "INTER_CA_SHA1-ROOT_CA_SHA256" },
+                    NOSHA1,
+                    TLSSERVER,
+                    false);
+            break;
+        case "S8":
+            testConstraint(
+                    new String[] { "ROOT_CA_SHA256" },
+                    new String[] {
+                            "END_ENTITY_SHA256-INTER_CA_SHA1-ROOT_CA_SHA256",
+                            "INTER_CA_SHA1-ROOT_CA_SHA256" },
+                    TLSCLIENT,
+                    NOSHA1,
+                    true,
+                    false);
+            break;
+
+        // Cases C9 and S9 use SHA256 root CA and SHA1 intermediate CA in trust store,
+        // and use SHA256 end entity in key store.
+        // C9 only sets constraint "SHA1 usage TLSServer" on client side;
+        // S9 only sets constraint "SHA1 usage TLSClient" on server side with client auth.
+        // The connection of the both cases should not be blocked.
+        case "C9":
+            testConstraint(
+                    new String[] {
+                            "ROOT_CA_SHA256",
+                            "INTER_CA_SHA1-ROOT_CA_SHA256" },
+                    new String[] {
+                            "END_ENTITY_SHA256-INTER_CA_SHA1-ROOT_CA_SHA256" },
+                    NOSHA1,
+                    TLSSERVER,
+                    true);
+            break;
+        case "S9":
+            testConstraint(
+                    new String[] {
+                            "ROOT_CA_SHA256",
+                            "INTER_CA_SHA1-ROOT_CA_SHA256" },
+                    new String[] {
+                            "END_ENTITY_SHA256-INTER_CA_SHA1-ROOT_CA_SHA256" },
+                    TLSCLIENT,
+                    NOSHA1,
+                    true,
+                    true);
+            break;
+        }
+
+        System.out.println("Case passed");
+        System.out.println("========================================");
+    }
+
+    private static String loadCert(String certName) {
+        try {
+            Path certFilePath = Paths.get(CERT_DIR, certName + ".cer");
+            return String.join("\n",
+                    Files.lines(certFilePath).filter((String line) -> {
+                        return !line.startsWith("Certificate")
+                                && !line.startsWith(" ");
+                    }).collect(Collectors.toList()));
+        } catch (IOException e) {
+            throw new RuntimeException("Load certificate failed", e);
+        }
+    }
+
+    private static String loadPrivKey(String certName) {
+        Path priveKeyFilePath = Paths.get(CERT_DIR, certName + "-PRIV.key");
+        try {
+            return new String(Files.readAllBytes(priveKeyFilePath));
+        } catch (IOException e) {
+            throw new RuntimeException("Load private key failed", e);
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/sun/security/ssl/CertPathRestrictions/certs/END_ENTITY_SHA1-INTER_CA_SHA256-ROOT_CA_SHA256-PRIV.key	Tue Apr 18 22:25:33 2017 +0200
@@ -0,0 +1,26 @@
+MIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQCYQDZxHxNJV8dQ
+I6mfJjuIZxAe5CX9GCrS3Fajh5DXIQwdcvQ4s6YdKzwFn+8dUdspdNTnS+bWjfYw
+0iAbsMt6L6ewutaZf6aufh1EBYiwNOvN8C8Cx0iiE8NiBo833AYWHKhDC4qu63QR
+dYwb9j+Jg8t6p0lQ64sFLDN/RJOcWlaPQbJbSNBKePQR7WOFvdJgFAdQmQjL+ND6
+PSui9QByyXQ+3nfs7ID4paUxYbCrJMh5/AJqaT04DYDEumfmURUn5+ZOIqmqvI2I
+pNXN5gVzL3b8mM2WGr5dpRY5cZ1X//BQ91SNjrKNJlmKFr7nMCfAdzxIW4b/sArv
+eYNE2Vy7AgMBAAECggEBAJNtkopFoiJiKnFypxyiJAG4cwbGu/ZxwX3/uLGPY3S9
+3oJhvxVs+IzEQdHchempSwTAyizS9cuLGfs6bbcConZF0Sa0NXvb/SZ4npQwm6St
+Ci2Xx530JWQ0qPyyB1r65rXguBp8AaXR/8msPqkQ8YOSqKWzea4u96Zhn9g8Koe6
+AD/8FeSzJBDVbJ+C7jKX/7sKsHbYqulzLMQf0lqXFxpGW+5UJaozoQOWXnnmqU3T
+0i4uaGUCXHbQM8eh3fvMFCU4UQMYVS1QOSvZJTnO5bSb8SqeQnCMnQ18ltq4sL43
+qFsEcmAjrlhNoBwslqvfY1bX9NtXyFZ8PuD8OvoFxPkCgYEAxlVfD2qcrAoOcbDe
+Em9hDVPizRuzGuCHi9K2YLDrLVDNd6NF3Pk65JiTsd1fA2AZdi+ljKGEwBhNFOyk
+qwmK2K4sYy7zvyV3Blmwvyo7+OaeexYF8RIw5keGlRsgHTGarzlQAlJu91UmyAmE
+C/99fZbSWo9QndJ0FVR6G3ti71UCgYEAxITBJqVtNFnv4PGdc3FNsYXlRQcSWjs9
+/1lsppLQjC6HMsb6JpxYUF3D4oFiUESKe/9kZzl1H/65Cm2mYq8sj+7lug8P5tz7
+DQa91dFM02r8JLO6TitSuZfbc0XH0K450ntuQlKX581icYSGBUwQHGApespuNVlh
+Mg7CmwNse88CgYAienrhEjaUTdc++nFQoR4tE/UslPEo7fmCXCoqWvc3VIGzl6Ww
+iX8seD3MwOAglRc4DYZpETcjsdXMmmrx9OG3U2gSAfqLszai2vq38N6mIWlRmn2D
+8BaiIbMKvsFxccsjRQJctPnnc10fj0/uSgcFyy9cYOex2AEoKBxmJKgJVQKBgA0c
+HhaJ6qMXbN1AwRQ2dsxk9kqIkjzavuQN/yWNncP8RqCojX+N5oZV+v9dSkW4jNSA
+0R3hw2KDB60ea38h2IMxmLm0z4bDLyxLSta8w7dG59M6+i7EzRv8eXNTMGVHeiwE
+d/KMt/2Kwgp4oMgxrtF1yM6cOoXslINWYL0emVoZAoGAcEKzO8LgPJsIVjRFz3ri
+0AQqiXQzYek2WAXYhlQCvBVn8in3MYcxKhjA3Og3Lym0xvZ+/8SbII9QNaidbgIH
+HDreeJW4KE5EfVnDaYcxwK/9LXZXndIxrpR0YKNSvZT7DuuQtFCoxJcASxb1k9Tc
+5MPT+pyPL+9v2q56ry56qas=
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/sun/security/ssl/CertPathRestrictions/certs/END_ENTITY_SHA1-INTER_CA_SHA256-ROOT_CA_SHA256.cer	Tue Apr 18 22:25:33 2017 +0200
@@ -0,0 +1,81 @@
+Certificate:
+    Data:
+        Version: 3 (0x2)
+        Serial Number:
+            e8:33:78:c7:69:9c:28:c2
+    Signature Algorithm: sha1WithRSAEncryption
+        Issuer: C=US, ST=CA, L=City, O=Org, OU=Java, CN=INTER_CA_SHA256-ROOT_CA_SHA256
+        Validity
+            Not Before: Mar 30 04:51:07 2017 GMT
+            Not After : Mar 28 04:51:07 2027 GMT
+        Subject: C=US, ST=CA, L=City, O=Org, OU=Java, CN=END_ENTITY_SHA1-INTER_CA_SHA256-ROOT_CA_SHA256
+        Subject Public Key Info:
+            Public Key Algorithm: rsaEncryption
+                Public-Key: (2048 bit)
+                Modulus:
+                    00:98:40:36:71:1f:13:49:57:c7:50:23:a9:9f:26:
+                    3b:88:67:10:1e:e4:25:fd:18:2a:d2:dc:56:a3:87:
+                    90:d7:21:0c:1d:72:f4:38:b3:a6:1d:2b:3c:05:9f:
+                    ef:1d:51:db:29:74:d4:e7:4b:e6:d6:8d:f6:30:d2:
+                    20:1b:b0:cb:7a:2f:a7:b0:ba:d6:99:7f:a6:ae:7e:
+                    1d:44:05:88:b0:34:eb:cd:f0:2f:02:c7:48:a2:13:
+                    c3:62:06:8f:37:dc:06:16:1c:a8:43:0b:8a:ae:eb:
+                    74:11:75:8c:1b:f6:3f:89:83:cb:7a:a7:49:50:eb:
+                    8b:05:2c:33:7f:44:93:9c:5a:56:8f:41:b2:5b:48:
+                    d0:4a:78:f4:11:ed:63:85:bd:d2:60:14:07:50:99:
+                    08:cb:f8:d0:fa:3d:2b:a2:f5:00:72:c9:74:3e:de:
+                    77:ec:ec:80:f8:a5:a5:31:61:b0:ab:24:c8:79:fc:
+                    02:6a:69:3d:38:0d:80:c4:ba:67:e6:51:15:27:e7:
+                    e6:4e:22:a9:aa:bc:8d:88:a4:d5:cd:e6:05:73:2f:
+                    76:fc:98:cd:96:1a:be:5d:a5:16:39:71:9d:57:ff:
+                    f0:50:f7:54:8d:8e:b2:8d:26:59:8a:16:be:e7:30:
+                    27:c0:77:3c:48:5b:86:ff:b0:0a:ef:79:83:44:d9:
+                    5c:bb
+                Exponent: 65537 (0x10001)
+        X509v3 extensions:
+            X509v3 Authority Key Identifier: 
+                DirName:/C=US/ST=CA/L=City/O=Org/OU=Java/CN=ROOT_CA_SHA256
+                serial:84:A1:70:1D:0A:92:D3:CC
+
+            X509v3 Basic Constraints: 
+                CA:TRUE
+    Signature Algorithm: sha1WithRSAEncryption
+         22:63:2a:de:80:70:92:f7:53:e4:7f:ea:01:2b:13:b3:1b:02:
+         2e:10:b4:1d:b7:33:7f:6f:0d:88:46:5a:b8:db:83:95:77:e2:
+         db:da:2e:31:0a:85:c6:9a:75:84:ca:73:5c:be:e3:30:22:7e:
+         bc:60:43:49:7c:69:06:14:4a:89:e4:23:ca:25:99:85:d6:06:
+         16:d5:9e:a8:fd:25:43:88:07:12:0a:7e:de:24:33:71:ab:a4:
+         23:aa:4e:dc:0f:89:ef:a9:09:89:55:a1:1d:ee:48:35:ea:10:
+         42:ff:98:15:2a:e8:5c:46:e0:e4:4f:4c:b9:07:e0:da:08:6f:
+         ce:4a:fe:98:3e:ae:c5:e5:6a:6e:50:0f:2d:39:01:55:ed:59:
+         0b:65:30:54:e8:72:26:ee:9f:cf:3f:ce:6a:20:c8:87:c9:81:
+         bc:f8:b3:ec:77:bb:bc:5b:8c:3f:18:fd:08:76:ad:27:59:fc:
+         b8:74:96:0d:cd:ed:97:91:6b:95:89:3a:f3:78:de:9f:06:a6:
+         ce:36:01:f0:be:ae:d8:d6:c4:3d:51:8a:2a:e0:43:59:8c:b4:
+         eb:63:93:9d:53:72:f8:4b:a3:c7:4a:da:2e:56:33:b6:46:1b:
+         45:a8:23:1b:82:de:6d:4e:e0:18:cf:9b:ba:22:68:8b:8c:de:
+         6f:08:2d:bc
+-----BEGIN CERTIFICATE-----
+MIID/jCCAuagAwIBAgIJAOgzeMdpnCjCMA0GCSqGSIb3DQEBBQUAMG8xCzAJBgNV
+BAYTAlVTMQswCQYDVQQIDAJDQTENMAsGA1UEBwwEQ2l0eTEMMAoGA1UECgwDT3Jn
+MQ0wCwYDVQQLDARKYXZhMScwJQYDVQQDDB5JTlRFUl9DQV9TSEEyNTYtUk9PVF9D
+QV9TSEEyNTYwHhcNMTcwMzMwMDQ1MTA3WhcNMjcwMzI4MDQ1MTA3WjB/MQswCQYD
+VQQGEwJVUzELMAkGA1UECAwCQ0ExDTALBgNVBAcMBENpdHkxDDAKBgNVBAoMA09y
+ZzENMAsGA1UECwwESmF2YTE3MDUGA1UEAwwuRU5EX0VOVElUWV9TSEExLUlOVEVS
+X0NBX1NIQTI1Ni1ST09UX0NBX1NIQTI1NjCCASIwDQYJKoZIhvcNAQEBBQADggEP
+ADCCAQoCggEBAJhANnEfE0lXx1AjqZ8mO4hnEB7kJf0YKtLcVqOHkNchDB1y9Diz
+ph0rPAWf7x1R2yl01OdL5taN9jDSIBuwy3ovp7C61pl/pq5+HUQFiLA0683wLwLH
+SKITw2IGjzfcBhYcqEMLiq7rdBF1jBv2P4mDy3qnSVDriwUsM39Ek5xaVo9BsltI
+0Ep49BHtY4W90mAUB1CZCMv40Po9K6L1AHLJdD7ed+zsgPilpTFhsKskyHn8Ampp
+PTgNgMS6Z+ZRFSfn5k4iqaq8jYik1c3mBXMvdvyYzZYavl2lFjlxnVf/8FD3VI2O
+so0mWYoWvucwJ8B3PEhbhv+wCu95g0TZXLsCAwEAAaOBjDCBiTB5BgNVHSMEcjBw
+oWOkYTBfMQswCQYDVQQGEwJVUzELMAkGA1UECAwCQ0ExDTALBgNVBAcMBENpdHkx
+DDAKBgNVBAoMA09yZzENMAsGA1UECwwESmF2YTEXMBUGA1UEAwwOUk9PVF9DQV9T
+SEEyNTaCCQCEoXAdCpLTzDAMBgNVHRMEBTADAQH/MA0GCSqGSIb3DQEBBQUAA4IB
+AQAiYyregHCS91Pkf+oBKxOzGwIuELQdtzN/bw2IRlq424OVd+Lb2i4xCoXGmnWE
+ynNcvuMwIn68YENJfGkGFEqJ5CPKJZmF1gYW1Z6o/SVDiAcSCn7eJDNxq6Qjqk7c
+D4nvqQmJVaEd7kg16hBC/5gVKuhcRuDkT0y5B+DaCG/OSv6YPq7F5WpuUA8tOQFV
+7VkLZTBU6HIm7p/PP85qIMiHyYG8+LPsd7u8W4w/GP0Idq0nWfy4dJYNze2XkWuV
+iTrzeN6fBqbONgHwvq7Y1sQ9UYoq4ENZjLTrY5OdU3L4S6PHStouVjO2RhtFqCMb
+gt5tTuAYz5u6ImiLjN5vCC28
+-----END CERTIFICATE-----
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/sun/security/ssl/CertPathRestrictions/certs/END_ENTITY_SHA256-INTER_CA_SHA1-ROOT_CA_SHA1-PRIV.key	Tue Apr 18 22:25:33 2017 +0200
@@ -0,0 +1,26 @@
+MIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQDaYlKNTU1iQes/
+BtivvM1ixjCk1muM1RdMkJQItZB21y1kM1OLp3EmGKqVqwKbS5OTrMIxjPUwD9Ly
+aRJMvSP1xve7zwmNXOngA8eukmQ2olQU58ble6IAHcj4qg7a38E1ITvDmAswhTzK
+fI4Z6okLCjKfYafnfbi5JA+E6fiArB3zimjne+tiUNYZh2eYspsOOw6cmaLtIbMP
+ZyXy4iP6OCNIikb08Da27zjVn04i1SeUEv1YFmn4B9GWcNLAXyM1LmCNi70+SATp
+aZYRjr/BBR6LNZMBsNKJblWFXK3UtfYFiypyirgQjzPtLb1XsuMhfqMt8QZDh8n3
+YvYTW59xAgMBAAECggEAb4NPdhnoDulsL5XWZf55vhtH0ZQv/Qz+xbj57myQJS8B
+Xa4b1i8dRv/Hc3+MaDIyXHEWBGle9jjOVbwzfP4D88eyzrMMxKOSRTKI72qPQ5qm
+ZrpnxNzZv0d2TQvBZCBnrzKWKu1joVYX0anCghdR/VIqwVoDe+Clx9xTFGLI4yKO
+7v0dkr4Hxn3NT6bTV18V6PoGbUgIsmpNYQPFyUM/IHG2ewDffLP+tm7RsEfKYmcx
+Hr70pmWBpM9hwTAC+uXHuNXnsX4IjEQOXmm4PJ/A/sm2Bad93SPwi15e29MV8YbO
+vvirGLaepa7AUvqoK0DFNCLU6vCeFJ7DUZ/u2P8x8QKBgQDxNOWvy3EV4/P/ocSf
+itMtXZWj4driT4vUGwFZWfr3CVpZVaUmqXYeVdzNGuoWlmXOiOAuOepnlA36FCb5
+aGE4cq/hbdtbr+v6awEj5/A2me/ax1W1z6lD0pg0QJ7KvqFCBzVol5yTiWZKBVE+
+jp2waPfes770AUHczw9KKvEGtQKBgQDnxxiZAxtoNmOaB/NZmPNBKvWDw858+QX2
++u/jEH3pW393tUnipgIoo6yvd6djhJ6/4ViOxdioMIQCBab/xuSB4lfQsrJsWvS9
+uYB794s7CV2r3kUa3ux8wAovW6Fc369nD7JjUPX/Cq3zdlyTDt9LVLRCpZ6Li1xB
+r0ZVlpgPTQKBgQCgKay+X0tW6sdxHfyOp8Lz46liaa1LCuDhVZE+wHXZpXc9zJXe
+JzZMjF0SQGXh27n8O30IlOJmJrRlMw5yG/I6ZkUNXkIDDryVyom2SuOBjhPrZOMv
+15UgeO0h/Sqzm4M+ccTwD4Qjn1+xlPhOnqpsoja8xQPtyAvwz/jqGbtz5QKBgH01
+pSgj8Y5es3fmi6P/aInv9ynzgX0p2fsOnMEBi8Og1j+JBB0YqVni8crozNiKMGhg
+CEM4xk41x1qASzMp8w/ngqEPqCu5BzXnHG3b0K9X4+6Q6KwXeZH6/IWQ7p8Jh+wZ
+IrlcZ0gcMNSxQFmBU0eSvr6yUe/4nSIu2cQq0oKRAoGAUEFd0LxZw50BdCdpJlcQ
++oTbSUYQhAzPF2ybfR6i8IxXoOjVxpvRehlbwXIQV7XEqamXFTmBLIvuAlF1yWoH
+hzxNJuEgPRTPztnHD6LVzvuf2ain+CFZuDrXBT2l8PyF9BNL4/DMRrbgdCxr9F0O
+Ti0VJo1TRE8vVzUfVc9w1RI=
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/sun/security/ssl/CertPathRestrictions/certs/END_ENTITY_SHA256-INTER_CA_SHA1-ROOT_CA_SHA1.cer	Tue Apr 18 22:25:33 2017 +0200
@@ -0,0 +1,81 @@
+Certificate:
+    Data:
+        Version: 3 (0x2)
+        Serial Number:
+            86:09:85:57:41:bf:86:65
+    Signature Algorithm: sha256WithRSAEncryption
+        Issuer: C=US, ST=CA, L=City, O=Org, OU=Java, CN=INTER_CA_SHA1-ROOT_CA_SHA1
+        Validity
+            Not Before: Mar 30 04:51:06 2017 GMT
+            Not After : Mar 28 04:51:06 2027 GMT
+        Subject: C=US, ST=CA, L=City, O=Org, OU=Java, CN=END_ENTITY_SHA256-INTER_CA_SHA1-ROOT_CA_SHA1
+        Subject Public Key Info:
+            Public Key Algorithm: rsaEncryption
+                Public-Key: (2048 bit)
+                Modulus:
+                    00:da:62:52:8d:4d:4d:62:41:eb:3f:06:d8:af:bc:
+                    cd:62:c6:30:a4:d6:6b:8c:d5:17:4c:90:94:08:b5:
+                    90:76:d7:2d:64:33:53:8b:a7:71:26:18:aa:95:ab:
+                    02:9b:4b:93:93:ac:c2:31:8c:f5:30:0f:d2:f2:69:
+                    12:4c:bd:23:f5:c6:f7:bb:cf:09:8d:5c:e9:e0:03:
+                    c7:ae:92:64:36:a2:54:14:e7:c6:e5:7b:a2:00:1d:
+                    c8:f8:aa:0e:da:df:c1:35:21:3b:c3:98:0b:30:85:
+                    3c:ca:7c:8e:19:ea:89:0b:0a:32:9f:61:a7:e7:7d:
+                    b8:b9:24:0f:84:e9:f8:80:ac:1d:f3:8a:68:e7:7b:
+                    eb:62:50:d6:19:87:67:98:b2:9b:0e:3b:0e:9c:99:
+                    a2:ed:21:b3:0f:67:25:f2:e2:23:fa:38:23:48:8a:
+                    46:f4:f0:36:b6:ef:38:d5:9f:4e:22:d5:27:94:12:
+                    fd:58:16:69:f8:07:d1:96:70:d2:c0:5f:23:35:2e:
+                    60:8d:8b:bd:3e:48:04:e9:69:96:11:8e:bf:c1:05:
+                    1e:8b:35:93:01:b0:d2:89:6e:55:85:5c:ad:d4:b5:
+                    f6:05:8b:2a:72:8a:b8:10:8f:33:ed:2d:bd:57:b2:
+                    e3:21:7e:a3:2d:f1:06:43:87:c9:f7:62:f6:13:5b:
+                    9f:71
+                Exponent: 65537 (0x10001)
+        X509v3 extensions:
+            X509v3 Authority Key Identifier: 
+                DirName:/C=US/ST=CA/L=City/O=Org/OU=Java/CN=ROOT_CA_SHA1
+                serial:8D:A0:D2:8A:EE:0B:CF:65
+
+            X509v3 Basic Constraints: 
+                CA:TRUE
+    Signature Algorithm: sha256WithRSAEncryption
+         29:b0:10:dc:45:ee:68:77:5f:12:9b:fc:de:eb:70:41:2e:6a:
+         a2:5f:a9:cc:ca:97:24:01:4a:1d:c2:78:52:57:34:9c:83:7f:
+         60:f5:d9:68:a2:32:89:e9:d7:25:71:72:71:e5:76:e3:37:af:
+         41:25:cc:8b:a4:fd:81:ef:6b:15:2b:91:3c:68:a5:25:53:cf:
+         c1:b9:aa:49:b4:cd:e3:3c:a2:8e:38:ea:e8:51:7c:7b:92:41:
+         bd:a3:22:7d:97:59:ad:55:e2:7d:9d:6a:bb:1f:95:84:1c:50:
+         00:e9:6c:74:1d:bb:6c:07:ca:bc:6a:a2:dd:c1:66:37:64:bd:
+         fe:1a:c0:8c:a7:8c:a1:60:b8:c3:d2:5f:92:80:ee:ad:79:29:
+         f2:ad:e2:9f:74:39:bf:3b:a4:b6:25:2a:87:3f:36:49:b9:52:
+         fd:91:33:be:1d:41:a9:76:29:47:6e:c7:db:a8:ab:6e:78:91:
+         c0:13:56:1c:25:41:51:a7:64:4f:07:c0:2a:a8:80:63:8d:98:
+         e0:54:7d:a6:f4:22:6b:70:fa:1c:16:82:f4:07:2e:e1:ba:94:
+         96:ec:c7:9e:8e:0a:24:1e:a4:e9:c0:92:ca:bd:32:98:ef:1f:
+         e1:a6:e6:4d:1f:c5:68:1b:77:d0:e0:35:1a:a9:c9:ee:98:72:
+         7b:c3:e7:51
+-----BEGIN CERTIFICATE-----
+MIID9jCCAt6gAwIBAgIJAIYJhVdBv4ZlMA0GCSqGSIb3DQEBCwUAMGsxCzAJBgNV
+BAYTAlVTMQswCQYDVQQIDAJDQTENMAsGA1UEBwwEQ2l0eTEMMAoGA1UECgwDT3Jn
+MQ0wCwYDVQQLDARKYXZhMSMwIQYDVQQDDBpJTlRFUl9DQV9TSEExLVJPT1RfQ0Ff
+U0hBMTAeFw0xNzAzMzAwNDUxMDZaFw0yNzAzMjgwNDUxMDZaMH0xCzAJBgNVBAYT
+AlVTMQswCQYDVQQIDAJDQTENMAsGA1UEBwwEQ2l0eTEMMAoGA1UECgwDT3JnMQ0w
+CwYDVQQLDARKYXZhMTUwMwYDVQQDDCxFTkRfRU5USVRZX1NIQTI1Ni1JTlRFUl9D
+QV9TSEExLVJPT1RfQ0FfU0hBMTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoC
+ggEBANpiUo1NTWJB6z8G2K+8zWLGMKTWa4zVF0yQlAi1kHbXLWQzU4uncSYYqpWr
+AptLk5OswjGM9TAP0vJpEky9I/XG97vPCY1c6eADx66SZDaiVBTnxuV7ogAdyPiq
+DtrfwTUhO8OYCzCFPMp8jhnqiQsKMp9hp+d9uLkkD4Tp+ICsHfOKaOd762JQ1hmH
+Z5iymw47DpyZou0hsw9nJfLiI/o4I0iKRvTwNrbvONWfTiLVJ5QS/VgWafgH0ZZw
+0sBfIzUuYI2LvT5IBOlplhGOv8EFHos1kwGw0oluVYVcrdS19gWLKnKKuBCPM+0t
+vVey4yF+oy3xBkOHyfdi9hNbn3ECAwEAAaOBijCBhzB3BgNVHSMEcDBuoWGkXzBd
+MQswCQYDVQQGEwJVUzELMAkGA1UECAwCQ0ExDTALBgNVBAcMBENpdHkxDDAKBgNV
+BAoMA09yZzENMAsGA1UECwwESmF2YTEVMBMGA1UEAwwMUk9PVF9DQV9TSEExggkA
+jaDSiu4Lz2UwDAYDVR0TBAUwAwEB/zANBgkqhkiG9w0BAQsFAAOCAQEAKbAQ3EXu
+aHdfEpv83utwQS5qol+pzMqXJAFKHcJ4Ulc0nIN/YPXZaKIyienXJXFyceV24zev
+QSXMi6T9ge9rFSuRPGilJVPPwbmqSbTN4zyijjjq6FF8e5JBvaMifZdZrVXifZ1q
+ux+VhBxQAOlsdB27bAfKvGqi3cFmN2S9/hrAjKeMoWC4w9JfkoDurXkp8q3in3Q5
+vzuktiUqhz82SblS/ZEzvh1BqXYpR27H26irbniRwBNWHCVBUadkTwfAKqiAY42Y
+4FR9pvQia3D6HBaC9Acu4bqUluzHno4KJB6k6cCSyr0ymO8f4abmTR/FaBt30OA1
+GqnJ7phye8PnUQ==
+-----END CERTIFICATE-----
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/sun/security/ssl/CertPathRestrictions/certs/END_ENTITY_SHA256-INTER_CA_SHA1-ROOT_CA_SHA256-PRIV.key	Tue Apr 18 22:25:33 2017 +0200
@@ -0,0 +1,26 @@
+MIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQDaCsiXcNnu7WpV
+t+FarvFhtaRr4RMQbKGhiIHi4aV0vqWmpX/eFde01eQZTZcPGJzEnjJrkyFo3Wbd
+31bjBLpt40kkI7kbODHrA2L+vY/hoCQeXK8+BrGioX9qHOpD7OLI3Esm1+KDiPPK
+w6qr9O9nS/fOID3zly92r+obY2ZuW6jQC0Yah3K9INrSIjH+rHXsmj2U5dCnktfi
+LzRcocvqtQHASYXFXEhWr1TCMnSz7h+l07O5YgYpmhwkRIPCkcdP+9wGhO2eOJYU
+kfaBteodDh7vHj2F+A6Lheosa4mi/nysyhQJl8uBFw97dqab9ul5Tb03iHmaY/q0
+xJKcEohnAgMBAAECggEBAJsa6K6yHJWWVfo8IBb+M7+qExiat5ELdb8O+DaJBcYS
+iIwPVvKI3zVIokZNp5OZkotbbcqQk0ehl7dlVM2RY30gHbuTne36/6eKdTV5a4y4
++niOviqFYH+sGpNFlnBTZtAzxVIQaJXhKmum3RYN2u/EXrdGwEsz1RO89/AbuZXu
+VdtEKkjPHXrIjnBkiT4271sm3OiPwOe6g0NKBMJ4InTyB+YtpgxlXtF+vv5cv6Vt
+ayT3sNsdsD8HLrenMmwv/k7nTYgNbhaJX2YCs9W7ZEscU2th6F7Cx6Z0z9h1SElC
++OKKhU6HnG/pWFMfWu80ZNjb3NTpXzTv4CLKjEYvz6ECgYEA8qEe+Ga7+XD0XwPB
+bFjoKmhOQhv0VCIiu9RgvIxQn5DuGX4H2hO1GP8LYOQZBm25nICIa+DyDZEaFGgL
+QgfPI4boK/rdV8syFTUNfw1Wq+W/pHhqzgUGHAnzRpX8jBQa9of14O+B7//ZFdGj
+5nt0qFTOAgNGslXMvSicKD/g0mMCgYEA5g7MpMmZI8zPf/PKLBkrQegdX2TBBiI5
+3KzvQuA29tEFdVwUIuhkgQkmy1u9Ujw0jZZ8NVBOsqfg7e7XkVr6/OF+MVWBjWl3
+Jn3DMCHl/HCLIZ4ZOM6/ydIMpBX6Ii53nvpO6vxRaOUg2T2gVHadVjjQAN9Oj68r
+TKUHfs4rTy0CgYB/g5QuQnfqKaYUxXmDQtqJZxYyAlUPXn1Yr85DaY75vYaVGTpx
+L0hPIcNOIbLRQRt6l8aaw7cS0D6fmOrJwibn6f/dFVP8zwq8QIyeSFlTsERe4PZo
+3hUO6V/UqgD3cZ2WEXB0zgtBIfpqUCpOeHWf/inivuwJz7PxegVP1fqHNwKBgA0p
+CZHfqm/+1lvmcUlGg0/43D1JwTT9nju+dM1pkBtcZ6iIBOreSmmLQXnenJzorsTu
+t9pA5s+XhOl3gUNiZfszVwmxb4DMaLF9/j1xovtm4L6ikaTLRvNfnbOBQlbUO6mP
+fhY5KtsKSG/E87gBNQzqoRN7sr3Lcnmm8x/Q4W9dAoGAITDcOI7UgPcnKMO8JUI5
+96Po3c/S7nBilVZRFOwjn0z6jrjzNTd+1IqkzIKBWfs5WlRkzXI6LPJVghwPUqUa
+q2C/3hQATD3FchEIohLfd8bj/wObaZNlKJB59a1RjxRZxuVQl3jvovvpn/hdXuJB
+nGIx7MryEG/yRpfrk2DL0bI=
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/sun/security/ssl/CertPathRestrictions/certs/END_ENTITY_SHA256-INTER_CA_SHA1-ROOT_CA_SHA256.cer	Tue Apr 18 22:25:33 2017 +0200
@@ -0,0 +1,81 @@
+Certificate:
+    Data:
+        Version: 3 (0x2)
+        Serial Number:
+            9e:f7:d7:79:1c:06:83:d5
+    Signature Algorithm: sha256WithRSAEncryption
+        Issuer: C=US, ST=CA, L=City, O=Org, OU=Java, CN=INTER_CA_SHA1-ROOT_CA_SHA256
+        Validity
+            Not Before: Mar 30 04:51:05 2017 GMT
+            Not After : Mar 28 04:51:05 2027 GMT
+        Subject: C=US, ST=CA, L=City, O=Org, OU=Java, CN=END_ENTITY_SHA256-INTER_CA_SHA1-ROOT_CA_SHA256-PRIV
+        Subject Public Key Info:
+            Public Key Algorithm: rsaEncryption
+                Public-Key: (2048 bit)
+                Modulus:
+                    00:da:0a:c8:97:70:d9:ee:ed:6a:55:b7:e1:5a:ae:
+                    f1:61:b5:a4:6b:e1:13:10:6c:a1:a1:88:81:e2:e1:
+                    a5:74:be:a5:a6:a5:7f:de:15:d7:b4:d5:e4:19:4d:
+                    97:0f:18:9c:c4:9e:32:6b:93:21:68:dd:66:dd:df:
+                    56:e3:04:ba:6d:e3:49:24:23:b9:1b:38:31:eb:03:
+                    62:fe:bd:8f:e1:a0:24:1e:5c:af:3e:06:b1:a2:a1:
+                    7f:6a:1c:ea:43:ec:e2:c8:dc:4b:26:d7:e2:83:88:
+                    f3:ca:c3:aa:ab:f4:ef:67:4b:f7:ce:20:3d:f3:97:
+                    2f:76:af:ea:1b:63:66:6e:5b:a8:d0:0b:46:1a:87:
+                    72:bd:20:da:d2:22:31:fe:ac:75:ec:9a:3d:94:e5:
+                    d0:a7:92:d7:e2:2f:34:5c:a1:cb:ea:b5:01:c0:49:
+                    85:c5:5c:48:56:af:54:c2:32:74:b3:ee:1f:a5:d3:
+                    b3:b9:62:06:29:9a:1c:24:44:83:c2:91:c7:4f:fb:
+                    dc:06:84:ed:9e:38:96:14:91:f6:81:b5:ea:1d:0e:
+                    1e:ef:1e:3d:85:f8:0e:8b:85:ea:2c:6b:89:a2:fe:
+                    7c:ac:ca:14:09:97:cb:81:17:0f:7b:76:a6:9b:f6:
+                    e9:79:4d:bd:37:88:79:9a:63:fa:b4:c4:92:9c:12:
+                    88:67
+                Exponent: 65537 (0x10001)
+        X509v3 extensions:
+            X509v3 Authority Key Identifier: 
+                DirName:/C=US/ST=CA/L=City/O=Org/OU=Java/CN=ROOT_CA_SHA256
+                serial:84:A1:70:1D:0A:92:D3:CD
+
+            X509v3 Basic Constraints: 
+                CA:TRUE
+    Signature Algorithm: sha256WithRSAEncryption
+         89:84:ce:6d:80:83:e7:19:80:21:a5:d3:79:ac:c4:2f:5c:5f:
+         47:f1:1c:e7:40:2a:57:ec:76:01:a9:10:b6:a2:2b:1b:02:ac:
+         f7:46:b1:67:b3:36:0f:fa:f0:a3:40:c2:5a:38:00:67:a9:9d:
+         e8:59:be:2f:5b:d0:c6:6c:20:90:c0:3b:6b:af:75:8c:93:ac:
+         5a:1e:8b:66:2c:79:0b:6d:9d:0d:d3:68:b5:b6:df:d6:04:6b:
+         24:f7:5a:b9:f0:18:08:81:b1:50:1c:ac:1b:7a:b7:b8:d8:8e:
+         6f:15:78:7e:23:5f:41:5c:df:76:09:1a:67:36:15:35:6a:77:
+         36:09:19:50:12:6d:60:20:c1:7a:36:cb:4c:ee:a8:d7:b7:c7:
+         29:26:31:04:0a:44:48:25:be:dd:00:92:ea:8c:00:ee:b4:eb:
+         52:4a:da:47:97:d7:42:df:dd:7d:17:de:e3:a1:14:49:3b:2d:
+         aa:ac:e7:83:0f:c0:2d:3f:31:c5:af:bb:b1:1e:53:d1:a7:13:
+         55:e3:25:f6:67:95:a1:75:e9:b8:a1:81:eb:d0:de:8a:a3:af:
+         78:dc:d0:39:d0:e7:d6:61:9e:39:7b:8b:f9:ee:44:48:78:92:
+         e7:22:fa:9c:a4:d0:6b:2b:89:0a:fa:78:3d:7a:af:44:91:e5:
+         8a:40:2f:10
+-----BEGIN CERTIFICATE-----
+MIIEAjCCAuqgAwIBAgIJAJ7313kcBoPVMA0GCSqGSIb3DQEBCwUAMG0xCzAJBgNV
+BAYTAlVTMQswCQYDVQQIDAJDQTENMAsGA1UEBwwEQ2l0eTEMMAoGA1UECgwDT3Jn
+MQ0wCwYDVQQLDARKYXZhMSUwIwYDVQQDDBxJTlRFUl9DQV9TSEExLVJPT1RfQ0Ff
+U0hBMjU2MB4XDTE3MDMzMDA0NTEwNVoXDTI3MDMyODA0NTEwNVowgYQxCzAJBgNV
+BAYTAlVTMQswCQYDVQQIDAJDQTENMAsGA1UEBwwEQ2l0eTEMMAoGA1UECgwDT3Jn
+MQ0wCwYDVQQLDARKYXZhMTwwOgYDVQQDDDNFTkRfRU5USVRZX1NIQTI1Ni1JTlRF
+Ul9DQV9TSEExLVJPT1RfQ0FfU0hBMjU2LVBSSVYwggEiMA0GCSqGSIb3DQEBAQUA
+A4IBDwAwggEKAoIBAQDaCsiXcNnu7WpVt+FarvFhtaRr4RMQbKGhiIHi4aV0vqWm
+pX/eFde01eQZTZcPGJzEnjJrkyFo3Wbd31bjBLpt40kkI7kbODHrA2L+vY/hoCQe
+XK8+BrGioX9qHOpD7OLI3Esm1+KDiPPKw6qr9O9nS/fOID3zly92r+obY2ZuW6jQ
+C0Yah3K9INrSIjH+rHXsmj2U5dCnktfiLzRcocvqtQHASYXFXEhWr1TCMnSz7h+l
+07O5YgYpmhwkRIPCkcdP+9wGhO2eOJYUkfaBteodDh7vHj2F+A6Lheosa4mi/nys
+yhQJl8uBFw97dqab9ul5Tb03iHmaY/q0xJKcEohnAgMBAAGjgYwwgYkweQYDVR0j
+BHIwcKFjpGEwXzELMAkGA1UEBhMCVVMxCzAJBgNVBAgMAkNBMQ0wCwYDVQQHDARD
+aXR5MQwwCgYDVQQKDANPcmcxDTALBgNVBAsMBEphdmExFzAVBgNVBAMMDlJPT1Rf
+Q0FfU0hBMjU2ggkAhKFwHQqS080wDAYDVR0TBAUwAwEB/zANBgkqhkiG9w0BAQsF
+AAOCAQEAiYTObYCD5xmAIaXTeazEL1xfR/Ec50AqV+x2AakQtqIrGwKs90axZ7M2
+D/rwo0DCWjgAZ6md6Fm+L1vQxmwgkMA7a691jJOsWh6LZix5C22dDdNotbbf1gRr
+JPdaufAYCIGxUBysG3q3uNiObxV4fiNfQVzfdgkaZzYVNWp3NgkZUBJtYCDBejbL
+TO6o17fHKSYxBApESCW+3QCS6owA7rTrUkraR5fXQt/dfRfe46EUSTstqqzngw/A
+LT8xxa+7sR5T0acTVeMl9meVoXXpuKGB69DeiqOveNzQOdDn1mGeOXuL+e5ESHiS
+5yL6nKTQayuJCvp4PXqvRJHlikAvEA==
+-----END CERTIFICATE-----
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/sun/security/ssl/CertPathRestrictions/certs/END_ENTITY_SHA256-INTER_CA_SHA256-ROOT_CA_SHA1-PRIV.key	Tue Apr 18 22:25:33 2017 +0200
@@ -0,0 +1,26 @@
+MIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQDHC0ieOFNTJjP+
+HMlFQ/w50Hx/+FYh9z9w3i08dVvi8oEhGUop7fvsqEyuAj3U/BYG87Wsv27wfa9l
+qSJRSgqUT3yI4jsMY/ozUInuKpp/yL97abyZVDUZc3diDZqryA/Qur8HNVLyA2hD
+DA9x8Ioeu5EDFl7AeqV3jx+A8fbulwVeCa29GByVkWRUEVF/48a1jpazBf2YQvrm
+5ElWoG8fuMrz6vgj+gYZYb1GPXmJQrtAIRp4Z1/AquPS4A/O21DnPLEM8WSw+rSC
+KGGKMqefJw74zeVyPlOiOmjFTeNfeVDViQrDgU++CTDjFa8XhweU6v+MtY5Mmzmf
+2AETGyd9AgMBAAECggEANCdMu8hebOcRsH+ybSfHKw7p0E4to3C5esV8bN8DWI/a
+LeYGfL4SyIvAq8eClBAJZYDuFXmDhBgqoSSUDWCtLPc21lcQycpYgKGVwoX/PYRI
+R/oIpNRfpW+P1G1kHaaqHjMQYr8iIK+r3gWG9n/kcPEMqhZudVitiopB4vODlDgf
+OI0goNWwYOPzoBkJSBbgfYC7vSz0dg+j9ooYPDnyUnHjykhu95mkmBHYc/MVMP8s
+ntFB5pgtWuLQATZImW4A1dtZiqCsF6APvJIQASxVq+wv3dwhejF9xMZR96QchVZJ
+QvPOcH76njIH4fThb0e46Dn54+KBpCnveSnDtAz5sQKBgQD2u6gWOK/Z4VqGlff1
+diLqzesdalCJhydKzOGRzRiJeW4E4MhEpUjIo44zPGkQ64zq6nefqIltdiaE7T9C
+Fnyu/+vd0zE1v3Ipgv0wD3NgTj3gGrBwl2gkY5sfSbCR+8vS/DhRU+s3KN45m3s4
+XfM27Uw/Zh/DFIe7jmGezfe/3wKBgQDOhRjDfxDDLCEXw4QFQb7Sp/43EGfoTd8h
+m700T/QXUTGx6qRhzHF9mUVea7FT+3I6CEqYNnZtFlYsJlq1g457rnvUJnTjJZb7
+wFl1h+u4u3IKo/lUUh2vD89PPOkMUF/uamJLh5jK7KNkOjwEDN2yPkRgaedY++nv
+NBcUPpGUIwKBgEkFmOWauVC+hVA3qj8XS5Y6g08dW+CYA2T75faEwLJPIeSHsj2+
+vR/EaB15z46WaApOgkDaXHHs+dF1dbdVeGlCjMgF7RZ/JoZqogxLRlZGUcG1pGpu
+JQBACnTkFkHeR6CVzQUk1QRqL/rUrU8tXwHukRZiXxwZQ2Ka7QFW6+/5AoGAHGem
+Dk2NyqppKtGTeP2f921vw7cX85WyWPcIwQc2NXbPdP8m+OSbv4CzT9dUHo75GQ5G
+5ESpaTunQo9L7qdXk59eHMHlVdC3wYylQUsemtv9RYVkJ7rbplZwVx+zliP/7dTo
+DCdsVozRtFlmI9B5Najm0rP+Q/jyJhpuCjTI5S0CgYEAsYcmFZZotwOyT4oJ/1Fu
+BtSOsoxnCa1vPJTVXEoX3F28ZUP4X0iWgGDO1e3aoWWYxWusf1fUj9BWbVnbtJfb
+gJ5JtQTAuMvmjCwFRWcBUytdxTUsWFbuDc5fw7DMW7YqjkCCISkd6Q8JyaFsJPy1
+7uFzumBnFtZGUIo2w4l8yrQ=
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/sun/security/ssl/CertPathRestrictions/certs/END_ENTITY_SHA256-INTER_CA_SHA256-ROOT_CA_SHA1.cer	Tue Apr 18 22:25:33 2017 +0200
@@ -0,0 +1,81 @@
+Certificate:
+    Data:
+        Version: 3 (0x2)
+        Serial Number:
+            9e:b3:99:30:15:24:2c:69
+    Signature Algorithm: sha256WithRSAEncryption
+        Issuer: C=US, ST=CA, L=City, O=Org, OU=Java, CN=INTER_CA_SHA256-ROOT_CA_SHA1
+        Validity
+            Not Before: Mar 30 04:51:06 2017 GMT
+            Not After : Mar 28 04:51:06 2027 GMT
+        Subject: C=US, ST=CA, L=City, O=Org, OU=Java, CN=END_ENTITY_SHA256-INTER_CA_SHA256-ROOT_CA_SHA1
+        Subject Public Key Info:
+            Public Key Algorithm: rsaEncryption
+                Public-Key: (2048 bit)
+                Modulus:
+                    00:c7:0b:48:9e:38:53:53:26:33:fe:1c:c9:45:43:
+                    fc:39:d0:7c:7f:f8:56:21:f7:3f:70:de:2d:3c:75:
+                    5b:e2:f2:81:21:19:4a:29:ed:fb:ec:a8:4c:ae:02:
+                    3d:d4:fc:16:06:f3:b5:ac:bf:6e:f0:7d:af:65:a9:
+                    22:51:4a:0a:94:4f:7c:88:e2:3b:0c:63:fa:33:50:
+                    89:ee:2a:9a:7f:c8:bf:7b:69:bc:99:54:35:19:73:
+                    77:62:0d:9a:ab:c8:0f:d0:ba:bf:07:35:52:f2:03:
+                    68:43:0c:0f:71:f0:8a:1e:bb:91:03:16:5e:c0:7a:
+                    a5:77:8f:1f:80:f1:f6:ee:97:05:5e:09:ad:bd:18:
+                    1c:95:91:64:54:11:51:7f:e3:c6:b5:8e:96:b3:05:
+                    fd:98:42:fa:e6:e4:49:56:a0:6f:1f:b8:ca:f3:ea:
+                    f8:23:fa:06:19:61:bd:46:3d:79:89:42:bb:40:21:
+                    1a:78:67:5f:c0:aa:e3:d2:e0:0f:ce:db:50:e7:3c:
+                    b1:0c:f1:64:b0:fa:b4:82:28:61:8a:32:a7:9f:27:
+                    0e:f8:cd:e5:72:3e:53:a2:3a:68:c5:4d:e3:5f:79:
+                    50:d5:89:0a:c3:81:4f:be:09:30:e3:15:af:17:87:
+                    07:94:ea:ff:8c:b5:8e:4c:9b:39:9f:d8:01:13:1b:
+                    27:7d
+                Exponent: 65537 (0x10001)
+        X509v3 extensions:
+            X509v3 Authority Key Identifier: 
+                DirName:/C=US/ST=CA/L=City/O=Org/OU=Java/CN=ROOT_CA_SHA1
+                serial:8D:A0:D2:8A:EE:0B:CF:64
+
+            X509v3 Basic Constraints: 
+                CA:TRUE
+    Signature Algorithm: sha256WithRSAEncryption
+         2b:43:e4:c1:37:36:00:a3:ed:25:15:c7:9f:6b:25:0e:24:cd:
+         1c:e8:d2:8c:a6:11:05:a9:2b:b5:dc:7b:fd:55:8e:be:1d:15:
+         d7:8b:a8:a6:44:cf:03:ba:ba:78:74:26:b9:19:11:c0:03:9b:
+         4d:2f:f9:f7:ea:da:a3:2f:82:f9:9e:d0:77:d6:bf:eb:fd:57:
+         c8:eb:03:54:0a:0c:2b:36:0c:e5:99:b7:93:4d:a9:9d:e9:50:
+         80:66:4e:73:c1:bd:83:13:09:ee:b9:01:62:ed:90:0e:4f:ff:
+         9d:92:f3:cd:db:1f:ba:da:fc:67:9d:cb:a0:09:99:8b:3e:ea:
+         9d:61:55:ac:6f:fb:11:5c:c0:fe:fb:ff:5b:15:7d:a7:c1:aa:
+         3a:cd:30:43:35:ea:44:8a:21:ae:9f:af:bc:5c:ae:3a:01:2c:
+         3b:eb:b6:8c:6a:e1:1c:4e:55:0a:84:5b:f8:68:71:aa:97:02:
+         9b:5d:c4:c9:42:df:19:91:28:4a:12:35:8d:2e:3d:10:ec:35:
+         8a:b1:d7:e0:e2:a6:f9:f6:47:4b:17:75:84:8e:2d:66:e8:74:
+         be:d6:27:6b:a2:28:23:26:41:70:92:c2:7c:50:e2:81:c9:e0:
+         10:84:5d:87:4f:db:93:ce:dd:09:d2:48:63:3d:53:66:31:64:
+         5a:13:b5:a6
+-----BEGIN CERTIFICATE-----
+MIID+jCCAuKgAwIBAgIJAJ6zmTAVJCxpMA0GCSqGSIb3DQEBCwUAMG0xCzAJBgNV
+BAYTAlVTMQswCQYDVQQIDAJDQTENMAsGA1UEBwwEQ2l0eTEMMAoGA1UECgwDT3Jn
+MQ0wCwYDVQQLDARKYXZhMSUwIwYDVQQDDBxJTlRFUl9DQV9TSEEyNTYtUk9PVF9D
+QV9TSEExMB4XDTE3MDMzMDA0NTEwNloXDTI3MDMyODA0NTEwNlowfzELMAkGA1UE
+BhMCVVMxCzAJBgNVBAgMAkNBMQ0wCwYDVQQHDARDaXR5MQwwCgYDVQQKDANPcmcx
+DTALBgNVBAsMBEphdmExNzA1BgNVBAMMLkVORF9FTlRJVFlfU0hBMjU2LUlOVEVS
+X0NBX1NIQTI1Ni1ST09UX0NBX1NIQTEwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAw
+ggEKAoIBAQDHC0ieOFNTJjP+HMlFQ/w50Hx/+FYh9z9w3i08dVvi8oEhGUop7fvs
+qEyuAj3U/BYG87Wsv27wfa9lqSJRSgqUT3yI4jsMY/ozUInuKpp/yL97abyZVDUZ
+c3diDZqryA/Qur8HNVLyA2hDDA9x8Ioeu5EDFl7AeqV3jx+A8fbulwVeCa29GByV
+kWRUEVF/48a1jpazBf2YQvrm5ElWoG8fuMrz6vgj+gYZYb1GPXmJQrtAIRp4Z1/A
+quPS4A/O21DnPLEM8WSw+rSCKGGKMqefJw74zeVyPlOiOmjFTeNfeVDViQrDgU++
+CTDjFa8XhweU6v+MtY5Mmzmf2AETGyd9AgMBAAGjgYowgYcwdwYDVR0jBHAwbqFh
+pF8wXTELMAkGA1UEBhMCVVMxCzAJBgNVBAgMAkNBMQ0wCwYDVQQHDARDaXR5MQww
+CgYDVQQKDANPcmcxDTALBgNVBAsMBEphdmExFTATBgNVBAMMDFJPT1RfQ0FfU0hB
+MYIJAI2g0oruC89kMAwGA1UdEwQFMAMBAf8wDQYJKoZIhvcNAQELBQADggEBACtD
+5ME3NgCj7SUVx59rJQ4kzRzo0oymEQWpK7Xce/1Vjr4dFdeLqKZEzwO6unh0JrkZ
+EcADm00v+ffq2qMvgvme0HfWv+v9V8jrA1QKDCs2DOWZt5NNqZ3pUIBmTnPBvYMT
+Ce65AWLtkA5P/52S883bH7ra/Gedy6AJmYs+6p1hVaxv+xFcwP77/1sVfafBqjrN
+MEM16kSKIa6fr7xcrjoBLDvrtoxq4RxOVQqEW/hocaqXAptdxMlC3xmRKEoSNY0u
+PRDsNYqx1+Dipvn2R0sXdYSOLWbodL7WJ2uiKCMmQXCSwnxQ4oHJ4BCEXYdP25PO
+3QnSSGM9U2YxZFoTtaY=
+-----END CERTIFICATE-----
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/sun/security/ssl/CertPathRestrictions/certs/END_ENTITY_SHA256-INTER_CA_SHA256-ROOT_CA_SHA256-PRIV.key	Tue Apr 18 22:25:33 2017 +0200
@@ -0,0 +1,26 @@
+MIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQDuH2+6I/ytoLeW
+AG3J0xMQafYmxYDZNaDjiWBl7TGpL4TjRY84FuHI/G8ib0VY9DKtyUixm7qZev+b
+ExrfQGk9ZV7Dn41uBvmGcUMSqwb0QV/5/hneP7/3EXhoWjsCFUe0r0zOgCM7O9+F
+jUlSuxEHyaFE09PxWGVZpU4Yu71PeoI/JJGITV81o2Fst7Urz65NE5OWrvbO+pfD
+EiRvjLv/uil7znYV28lCbH7U1K8q5nGVtnpgTguhGL6/N3lIgvxoBtoXEQwdMV59
+APsH8anA19rHn5h/ZmknryxAs0c6Rg9Plo30MonIU/eAVZwNw8TczD276Rc02xnW
+RmbmxToRAgMBAAECggEAbK3OWV9JWJlMkNqbQQzj247w+FsV5ozSZGbzpzFtg/Eb
+Lns11XykCg4kTswIE4RIiQaf9efEb34yoL1Ee3YzUgEtEg2FCB2IzvJskV2ba+lW
+e4uclNH1tDa2BLKB0f6SXoXPgUP8UHGQH60PNQIJ0MsWnoorZjBY+WQ305QD3/yB
+fMonkjpWN+ZNTY8Y3vA2SsS4EoY0Ndy2FpmWPwKKMCcqXw6xzVjKvq+jpFfsGpcj
+i3MlKsCG5koreWrXdyt28CVOc6eMW5rsJfAHRw+OSn7PdLaGyZCUUsFXCjG0Vq2G
+YwuMfTJprrZk+lbi3XUXWk7XUEURB7Q4lIBxAcskAQKBgQD8pVj0OIsVHAGjQQ7C
+ZAnxFlON7XX3fgPdLtil9c+a1GlcPA2K52fBp8YlKlAS4bmZIQHbbkEBjh8KfG1P
+x7zBHoUXV8ruo/axzRPoeBVQat5NQKcKnlITrqdf8J3a+8iMxpMpd53h97HGiayq
+W04ZQNf7wjXvR+pJVluTEaoVUQKBgQDxSLruMmCsYvD+sipaQ3rBEMIAI3kc7ctl
+fEnipEk5wtPkKKldw+rvbh/AwY2i2JMUDcW92hkB5vCvbcKmCEkEO3FbawNkJnJi
+qfwbvHP/fGThMV3gbWWF3GZvBKY2+toSa2rwoR5kYTT1e4+byk38NAp/HAItFHIT
+DgAgMy6owQKBgQCjd8jKnBtBmVFl9B48oMXd+/gsCM0fSaXuYvVCzH17TJyvVRve
+GEQGBSwrt+j/jpWsArNU602cV/y1qDSCPlZfDgRHSkK/jc9805hh/fCsi7kyevaZ
+5D5vBb6+UM2Sdv8YNxPY7NB2+PFJ6KKTx2gM5uvYtZx4KivpL7souXE3QQKBgDxg
+FZ5q7rPUIjepP13MyteqqNC+D51Eh4PCgP58W3JfpQPPhOnYj14QMVPbWuSnys3W
+0Gc8PsuyDQHoti8znYm4khntAjE6SZ8Up+gM1P3WE6wh3Tq+RQwk5WDcSfcx+AVp
+6Z2Cw4ccp9LRc1LpYXA9WW8LBCRhnFXWSAPGquNBAoGAdCsvFzSipQ5qxWPlClRM
+lKqDdQheRl9IKCuImXZAvdX952VhmP7QV5PUwLV/CkVquvSdRSshrMO/fqFjfkjr
+puajXghFXa+YppQW42tPYBmKDnNVgxW5d5sC62AYaykh2iNw3v4BJyN+MMmkSf0M
+4/mKvs5m8N2OkOpY6r2wCp8=
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/sun/security/ssl/CertPathRestrictions/certs/END_ENTITY_SHA256-INTER_CA_SHA256-ROOT_CA_SHA256.cer	Tue Apr 18 22:25:33 2017 +0200
@@ -0,0 +1,81 @@
+Certificate:
+    Data:
+        Version: 3 (0x2)
+        Serial Number:
+            e8:33:78:c7:69:9c:28:c1
+    Signature Algorithm: sha256WithRSAEncryption
+        Issuer: C=US, ST=CA, L=City, O=Org, OU=Java, CN=INTER_CA_SHA256-ROOT_CA_SHA256
+        Validity
+            Not Before: Mar 30 04:51:04 2017 GMT
+            Not After : Mar 28 04:51:04 2027 GMT
+        Subject: C=US, ST=CA, L=City, O=Org, OU=Java, CN=END_ENTITY_SHA256-INTER_CA_SHA256-ROOT_CA_SHA256
+        Subject Public Key Info:
+            Public Key Algorithm: rsaEncryption
+                Public-Key: (2048 bit)
+                Modulus:
+                    00:ee:1f:6f:ba:23:fc:ad:a0:b7:96:00:6d:c9:d3:
+                    13:10:69:f6:26:c5:80:d9:35:a0:e3:89:60:65:ed:
+                    31:a9:2f:84:e3:45:8f:38:16:e1:c8:fc:6f:22:6f:
+                    45:58:f4:32:ad:c9:48:b1:9b:ba:99:7a:ff:9b:13:
+                    1a:df:40:69:3d:65:5e:c3:9f:8d:6e:06:f9:86:71:
+                    43:12:ab:06:f4:41:5f:f9:fe:19:de:3f:bf:f7:11:
+                    78:68:5a:3b:02:15:47:b4:af:4c:ce:80:23:3b:3b:
+                    df:85:8d:49:52:bb:11:07:c9:a1:44:d3:d3:f1:58:
+                    65:59:a5:4e:18:bb:bd:4f:7a:82:3f:24:91:88:4d:
+                    5f:35:a3:61:6c:b7:b5:2b:cf:ae:4d:13:93:96:ae:
+                    f6:ce:fa:97:c3:12:24:6f:8c:bb:ff:ba:29:7b:ce:
+                    76:15:db:c9:42:6c:7e:d4:d4:af:2a:e6:71:95:b6:
+                    7a:60:4e:0b:a1:18:be:bf:37:79:48:82:fc:68:06:
+                    da:17:11:0c:1d:31:5e:7d:00:fb:07:f1:a9:c0:d7:
+                    da:c7:9f:98:7f:66:69:27:af:2c:40:b3:47:3a:46:
+                    0f:4f:96:8d:f4:32:89:c8:53:f7:80:55:9c:0d:c3:
+                    c4:dc:cc:3d:bb:e9:17:34:db:19:d6:46:66:e6:c5:
+                    3a:11
+                Exponent: 65537 (0x10001)
+        X509v3 extensions:
+            X509v3 Authority Key Identifier: 
+                DirName:/C=US/ST=CA/L=City/O=Org/OU=Java/CN=ROOT_CA_SHA256
+                serial:84:A1:70:1D:0A:92:D3:CC
+
+            X509v3 Basic Constraints: 
+                CA:TRUE
+    Signature Algorithm: sha256WithRSAEncryption
+         1d:1a:87:7d:11:0e:cc:cd:7f:6c:ed:21:1a:2c:35:de:09:b8:
+         c4:cf:0c:31:00:3d:f5:bd:d4:6e:f0:4f:7e:c2:8d:d6:c5:28:
+         ed:38:9d:d7:52:32:e2:8d:7b:64:c8:1d:4e:69:7e:49:5f:e1:
+         5e:04:c7:d3:96:d2:63:ef:2c:35:4f:eb:08:2b:9d:b0:15:df:
+         33:d8:1c:59:8e:bb:f1:28:4f:f0:85:bb:3c:56:e1:86:a4:75:
+         2b:44:8a:1c:98:ae:94:f3:b6:76:a9:a3:e7:d6:bc:58:ef:fe:
+         32:11:6f:76:5b:85:f8:14:91:83:2c:b6:20:a5:48:48:8b:6e:
+         ee:a8:6c:2b:12:18:94:3e:59:5e:a6:66:53:dc:40:b2:da:fd:
+         a4:5f:16:35:b6:20:2b:31:86:9b:91:55:b2:35:63:d2:47:bd:
+         91:7e:43:bc:d6:0e:dc:95:1a:f0:8d:08:e5:66:cd:d1:0b:32:
+         d6:92:26:3e:78:e8:70:74:e1:14:64:b0:39:5d:7c:d0:28:23:
+         c7:83:53:02:90:fe:fc:9e:aa:9a:fb:c4:ef:9d:d5:22:f6:c1:
+         fd:e4:07:04:25:4f:8f:b2:13:6f:0d:51:cc:54:b4:38:d3:ac:
+         31:aa:94:c5:d0:c8:5a:58:35:13:87:3e:f6:74:26:8c:2b:7d:
+         6c:8e:36:a5
+-----BEGIN CERTIFICATE-----
+MIIEATCCAumgAwIBAgIJAOgzeMdpnCjBMA0GCSqGSIb3DQEBCwUAMG8xCzAJBgNV
+BAYTAlVTMQswCQYDVQQIDAJDQTENMAsGA1UEBwwEQ2l0eTEMMAoGA1UECgwDT3Jn
+MQ0wCwYDVQQLDARKYXZhMScwJQYDVQQDDB5JTlRFUl9DQV9TSEEyNTYtUk9PVF9D
+QV9TSEEyNTYwHhcNMTcwMzMwMDQ1MTA0WhcNMjcwMzI4MDQ1MTA0WjCBgTELMAkG
+A1UEBhMCVVMxCzAJBgNVBAgMAkNBMQ0wCwYDVQQHDARDaXR5MQwwCgYDVQQKDANP
+cmcxDTALBgNVBAsMBEphdmExOTA3BgNVBAMMMEVORF9FTlRJVFlfU0hBMjU2LUlO
+VEVSX0NBX1NIQTI1Ni1ST09UX0NBX1NIQTI1NjCCASIwDQYJKoZIhvcNAQEBBQAD
+ggEPADCCAQoCggEBAO4fb7oj/K2gt5YAbcnTExBp9ibFgNk1oOOJYGXtMakvhONF
+jzgW4cj8byJvRVj0Mq3JSLGbupl6/5sTGt9AaT1lXsOfjW4G+YZxQxKrBvRBX/n+
+Gd4/v/cReGhaOwIVR7SvTM6AIzs734WNSVK7EQfJoUTT0/FYZVmlThi7vU96gj8k
+kYhNXzWjYWy3tSvPrk0Tk5au9s76l8MSJG+Mu/+6KXvOdhXbyUJsftTUryrmcZW2
+emBOC6EYvr83eUiC/GgG2hcRDB0xXn0A+wfxqcDX2sefmH9maSevLECzRzpGD0+W
+jfQyichT94BVnA3DxNzMPbvpFzTbGdZGZubFOhECAwEAAaOBjDCBiTB5BgNVHSME
+cjBwoWOkYTBfMQswCQYDVQQGEwJVUzELMAkGA1UECAwCQ0ExDTALBgNVBAcMBENp
+dHkxDDAKBgNVBAoMA09yZzENMAsGA1UECwwESmF2YTEXMBUGA1UEAwwOUk9PVF9D
+QV9TSEEyNTaCCQCEoXAdCpLTzDAMBgNVHRMEBTADAQH/MA0GCSqGSIb3DQEBCwUA
+A4IBAQAdGod9EQ7MzX9s7SEaLDXeCbjEzwwxAD31vdRu8E9+wo3WxSjtOJ3XUjLi
+jXtkyB1OaX5JX+FeBMfTltJj7yw1T+sIK52wFd8z2BxZjrvxKE/whbs8VuGGpHUr
+RIocmK6U87Z2qaPn1rxY7/4yEW92W4X4FJGDLLYgpUhIi27uqGwrEhiUPllepmZT
+3ECy2v2kXxY1tiArMYabkVWyNWPSR72RfkO81g7clRrwjQjlZs3RCzLWkiY+eOhw
+dOEUZLA5XXzQKCPHg1MCkP78nqqa+8TvndUi9sH95AcEJU+PshNvDVHMVLQ406wx
+qpTF0MhaWDUThz72dCaMK31sjjal
+-----END CERTIFICATE-----
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/sun/security/ssl/CertPathRestrictions/certs/INTER_CA_SHA1-ROOT_CA_SHA1-PRIV.key	Tue Apr 18 22:25:33 2017 +0200
@@ -0,0 +1,26 @@
+MIIEvgIBADANBgkqhkiG9w0BAQEFAASCBKgwggSkAgEAAoIBAQDX1pPNXGpnPQNc
+x9ReXrjbcHkIoyXcdXbhO0TnUBV5aGJTEn5/meDsK76Y2KDVyU/EO2jXpaQ5QiGn
+UzY6vKIn6boqTov4NLYwBsVPdAG/xZyr5q7p6bnJ8WRj40A2JeOeZ3FMglRtBCNg
+rYeEC4MDp2F41OVxsJZ4huodq94arqhD/hjE40g06UNa0I+/2dIpI2cSamIC5b3L
+/DK3ol+gIw/OOxMCgzAUSjeH6nTrrW1hUeSKx0NPGWRLWzLQ2yxhYcXlsedNuKHo
+ux/p3EkGXoGPajK7s7IlKj9CPQYwlQez37jCLJGovArqTr/8hxfrKMdZOl5bp+6H
+6uWh6af7AgMBAAECggEAXrUsM79qfRR7pjmVCTe9G6T1pwGXum3clSYhrPIqChTw
+mA0Ubr9Bv7/OKVlc8ZIdKzj6Xy2yquFGzRopQIrHCIZ5htjieC4BB3/hEmUP42s9
+vPxDIibJvD/s0hvEcD4d68LuJylFDHT1ZRWf0iQPAApxLckVSNa4n/hrQEvK8J+G
+HIH8VATq9iHp/GQmmFB8b3ubqn46zDGqly14+TGP2KtVJlY9FuCpvmtZZZjJ+K09
+vYM+BATwje6N6PqX5a3Z+NFC1NK9CmC+U6ECJ27uhySn8kvlU/i/SOAnrPftByO7
+g7K8p2Qzq1LlVIUU/JTidNZGXTaTMOVg8eHLmyt92QKBgQD9a94rLqk9BUtVsTYa
+AImt+KbUMB+Zi83cYDiCfNBkfIYw4dVUFJecmqZwg7IeqNwuSmXP41fASOvDel/L
+8bOj/rPccVSG9pmU0ir5WK9n8zobogfAzvaFr8cmo+TVv0FOZZA8e/+UfVsiKAsW
+3nwhwxN8ieILU1dtaNV1IfnAPwKBgQDaCM9URf+DFILI2WpuzKpk1loF6HrlklIn
++N0IFFcalqUpC8GhXTw7suypRBCZ+cp32h7WEcN9aHLMrnkDQP3bGTv53pJT5N9k
+7nk9Bfrk0CJCxeMRKwtuMhLkOmT0eh2aB1lWR0owA5b1Gjtiz5kTW7NN2+paJCDz
+SiDLVoFpRQKBgQCHvt0N4nuy/QACkd86BGm7b8LlTDXRCMsnrb73XqY9/VngG0gr
+NrCTqV9YS6MAu1Dd1uo8djnN/QGU/xsLYpfoU4nCnk450SQpTH7Ke8/Rbb8FiECA
+7hutNqAFuardOApiVRLy4zTfNFq5rBtsj5aMezMX9b/Ic0cUiyA0ExP1/wKBgQCp
+SDvI34wRdqRQUtWa7xbAsdg1TBnXEjLtTAA4nKpAP4Q+CR2uLlhstW+fv/PvyIwV
+X+mfJS2VubmgBzp3d0dhjAcP6mnL7yAvGiRRZ8ozSxG+rCuvEa+PQBuAzYHCeulu
+xJPtM+56tt7GsDY5cpsT95eQNNWQZQqcOgqaNTDGzQKBgCmMwRP1HN0qUSSVO1d8
+8N17OoZe5yntppEjesYQrLf4AEgPS3Qj8dv0qfe3z1B0gAKlG9+OR8cUBCMGVyum
+b51SiSi3LSm1VeuMfT7JDMSxTkbaI5CY7v+/5yCRFqikgBtCkHM9m4K95d3dVDO8
+JGrlKiKVIbu5LnQZMkPHRIEX
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/sun/security/ssl/CertPathRestrictions/certs/INTER_CA_SHA1-ROOT_CA_SHA1.cer	Tue Apr 18 22:25:33 2017 +0200
@@ -0,0 +1,80 @@
+Certificate:
+    Data:
+        Version: 3 (0x2)
+        Serial Number:
+            8d:a0:d2:8a:ee:0b:cf:65
+    Signature Algorithm: sha1WithRSAEncryption
+        Issuer: C=US, ST=CA, L=City, O=Org, OU=Java, CN=ROOT_CA_SHA1
+        Validity
+            Not Before: Mar 30 04:51:04 2017 GMT
+            Not After : Mar 28 04:51:04 2027 GMT
+        Subject: C=US, ST=CA, L=City, O=Org, OU=Java, CN=INTER_CA_SHA1-ROOT_CA_SHA1
+        Subject Public Key Info:
+            Public Key Algorithm: rsaEncryption
+                Public-Key: (2048 bit)
+                Modulus:
+                    00:d7:d6:93:cd:5c:6a:67:3d:03:5c:c7:d4:5e:5e:
+                    b8:db:70:79:08:a3:25:dc:75:76:e1:3b:44:e7:50:
+                    15:79:68:62:53:12:7e:7f:99:e0:ec:2b:be:98:d8:
+                    a0:d5:c9:4f:c4:3b:68:d7:a5:a4:39:42:21:a7:53:
+                    36:3a:bc:a2:27:e9:ba:2a:4e:8b:f8:34:b6:30:06:
+                    c5:4f:74:01:bf:c5:9c:ab:e6:ae:e9:e9:b9:c9:f1:
+                    64:63:e3:40:36:25:e3:9e:67:71:4c:82:54:6d:04:
+                    23:60:ad:87:84:0b:83:03:a7:61:78:d4:e5:71:b0:
+                    96:78:86:ea:1d:ab:de:1a:ae:a8:43:fe:18:c4:e3:
+                    48:34:e9:43:5a:d0:8f:bf:d9:d2:29:23:67:12:6a:
+                    62:02:e5:bd:cb:fc:32:b7:a2:5f:a0:23:0f:ce:3b:
+                    13:02:83:30:14:4a:37:87:ea:74:eb:ad:6d:61:51:
+                    e4:8a:c7:43:4f:19:64:4b:5b:32:d0:db:2c:61:61:
+                    c5:e5:b1:e7:4d:b8:a1:e8:bb:1f:e9:dc:49:06:5e:
+                    81:8f:6a:32:bb:b3:b2:25:2a:3f:42:3d:06:30:95:
+                    07:b3:df:b8:c2:2c:91:a8:bc:0a:ea:4e:bf:fc:87:
+                    17:eb:28:c7:59:3a:5e:5b:a7:ee:87:ea:e5:a1:e9:
+                    a7:fb
+                Exponent: 65537 (0x10001)
+        X509v3 extensions:
+            X509v3 Authority Key Identifier: 
+                DirName:/C=US/ST=CA/L=City/O=Org/OU=Java/CN=ROOT_CA_SHA1
+                serial:F1:3B:B7:FB:28:3F:52:09
+
+            X509v3 Basic Constraints: 
+                CA:TRUE
+    Signature Algorithm: sha1WithRSAEncryption
+         d3:ce:da:23:e1:7c:73:fb:7f:26:d7:a4:3c:7b:17:01:75:ce:
+         a5:bd:75:f1:65:1b:56:27:ae:f8:97:a6:c4:ca:94:93:c9:12:
+         bb:c7:ec:2b:d5:38:d5:43:3a:6c:c2:51:3a:79:2f:d7:4e:da:
+         2d:12:1f:b8:c2:4f:c8:ba:33:d3:f5:0c:78:cc:26:69:24:47:
+         3f:ed:17:a0:7f:d0:20:fe:11:ca:75:50:1a:61:e1:91:b5:fa:
+         91:04:e9:14:59:77:d4:29:0f:43:19:e0:dc:dd:a6:18:14:f4:
+         33:3e:f0:cb:36:7b:18:04:03:dd:be:35:41:c4:3e:65:d2:67:
+         44:73:ab:7f:d1:b9:26:7e:b3:1e:d0:e4:a4:52:83:60:a9:e6:
+         e1:bf:62:bb:9b:16:0c:97:ad:11:1a:2f:eb:92:ca:7e:98:15:
+         46:23:59:5d:26:d9:ec:57:85:51:5b:09:f1:9b:1b:d3:5d:53:
+         02:67:1a:e4:24:49:67:87:04:75:66:13:56:1b:8b:a1:08:de:
+         c8:4b:f8:87:73:6e:c2:31:ee:f6:32:14:45:32:a3:3f:e4:b1:
+         0f:23:28:29:b4:a3:86:65:4f:2e:57:ad:8f:44:77:f8:4b:ea:
+         7b:9d:8e:dc:cb:07:ee:b4:78:46:db:cd:12:eb:ad:ef:9b:8f:
+         22:ba:83:7b
+-----BEGIN CERTIFICATE-----
+MIID1jCCAr6gAwIBAgIJAI2g0oruC89lMA0GCSqGSIb3DQEBBQUAMF0xCzAJBgNV
+BAYTAlVTMQswCQYDVQQIDAJDQTENMAsGA1UEBwwEQ2l0eTEMMAoGA1UECgwDT3Jn
+MQ0wCwYDVQQLDARKYXZhMRUwEwYDVQQDDAxST09UX0NBX1NIQTEwHhcNMTcwMzMw
+MDQ1MTA0WhcNMjcwMzI4MDQ1MTA0WjBrMQswCQYDVQQGEwJVUzELMAkGA1UECAwC
+Q0ExDTALBgNVBAcMBENpdHkxDDAKBgNVBAoMA09yZzENMAsGA1UECwwESmF2YTEj
+MCEGA1UEAwwaSU5URVJfQ0FfU0hBMS1ST09UX0NBX1NIQTEwggEiMA0GCSqGSIb3
+DQEBAQUAA4IBDwAwggEKAoIBAQDX1pPNXGpnPQNcx9ReXrjbcHkIoyXcdXbhO0Tn
+UBV5aGJTEn5/meDsK76Y2KDVyU/EO2jXpaQ5QiGnUzY6vKIn6boqTov4NLYwBsVP
+dAG/xZyr5q7p6bnJ8WRj40A2JeOeZ3FMglRtBCNgrYeEC4MDp2F41OVxsJZ4huod
+q94arqhD/hjE40g06UNa0I+/2dIpI2cSamIC5b3L/DK3ol+gIw/OOxMCgzAUSjeH
+6nTrrW1hUeSKx0NPGWRLWzLQ2yxhYcXlsedNuKHoux/p3EkGXoGPajK7s7IlKj9C
+PQYwlQez37jCLJGovArqTr/8hxfrKMdZOl5bp+6H6uWh6af7AgMBAAGjgYowgYcw
+dwYDVR0jBHAwbqFhpF8wXTELMAkGA1UEBhMCVVMxCzAJBgNVBAgMAkNBMQ0wCwYD
+VQQHDARDaXR5MQwwCgYDVQQKDANPcmcxDTALBgNVBAsMBEphdmExFTATBgNVBAMM
+DFJPT1RfQ0FfU0hBMYIJAPE7t/soP1IJMAwGA1UdEwQFMAMBAf8wDQYJKoZIhvcN
+AQEFBQADggEBANPO2iPhfHP7fybXpDx7FwF1zqW9dfFlG1YnrviXpsTKlJPJErvH
+7CvVONVDOmzCUTp5L9dO2i0SH7jCT8i6M9P1DHjMJmkkRz/tF6B/0CD+Ecp1UBph
+4ZG1+pEE6RRZd9QpD0MZ4NzdphgU9DM+8Ms2exgEA92+NUHEPmXSZ0Rzq3/RuSZ+
+sx7Q5KRSg2Cp5uG/YrubFgyXrREaL+uSyn6YFUYjWV0m2exXhVFbCfGbG9NdUwJn
+GuQkSWeHBHVmE1Ybi6EI3shL+IdzbsIx7vYyFEUyoz/ksQ8jKCm0o4ZlTy5XrY9E
+d/hL6nudjtzLB+60eEbbzRLrre+bjyK6g3s=
+-----END CERTIFICATE-----
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/sun/security/ssl/CertPathRestrictions/certs/INTER_CA_SHA1-ROOT_CA_SHA256-PRIV.key	Tue Apr 18 22:25:33 2017 +0200
@@ -0,0 +1,26 @@
+MIIEvgIBADANBgkqhkiG9w0BAQEFAASCBKgwggSkAgEAAoIBAQDWN68vV57EPqPZ
+Dtvi2+NI4tfxUgkaWJXbqrLKuAJC8bff9edZpMXGAyqMpDDr7MAjs/3TDYpVaWYN
+Id5iwqamImbBLYf/K0LOkaX6+TyogaqwwdNVryR5eYcGXEiJY1MJ2mgzCNeGJ091
+4qwll3xkjAFolB6o9QoIbLB3cctl0vw6oAoi3TKWQxJ+UI6/uBotX5eQ9z1b/MDs
+6PNXHB22jYAj4tOePMZxq7AVCwTFpWbHK8j5ftXxpVoU5ECNHfIAHLprJqc/lKdf
+7rMyflbsjD8nV7TwY+FW7WfOQgiJhk0OK3VaBeSsovpOOwjS4Lpsazh3eUXeZJUk
+lrYrMfI3AgMBAAECggEAEpXmNx9NAQ3GPXDSlw4o3AwCXEeXzpdc+SAIPxpT5+b8
+4wt8tQRcvF9N88HTFMUHrpFRNlx4Ygyw8/a6SqtEtilJ7Py8TeE8/JsaYXn6T0xg
+uNE4OrjlWzy2AFFFYdYiQDqYy8S6nkMO29V8xg4slrSm8qHXPyVzZ2O2s8ZFtWG+
+ItAMb+Gv7FU2M4te/TwRnadljFAoyWry0XCXle1fN1Y3QJXtu3VDdmLmU0t+VGfa
+wuZ5k0FIb9TFIQuxtgUNXJZmIjZw4Ych3luUc1bMSn9FPHeOzk8J3yo1tGqQu15M
+KMLHxASTgt6opfhDbYIpD0fJJqCPdiJlMrqXHBPYwQKBgQDy8lrmsjBE97H0U2sS
+tqlJq+7VOe2ien+z6seXFxd6XHBI8D/wTi2Q/7BpIGbpek3xc0ujxaFbcqo/RJZA
+TUzYmc5leQLTwy4a54Neo33+sOuYPg8fQIMPT1OGa3DXv3EPSC8FdQrweNjn/bDX
+YXbXJ2nKc3RgdTVehuMh6mw25wKBgQDhuitrTL3dlyHMGhO+djxW3cgjsUbJXQsK
+1GnkGw5mzzL67M6ixw4WNxNJjuXEUI5Vat8iJzhZOA+Ae84DDbeN2FCM7UBpUsyB
+9T9aApBYLLMflZhl4PXK/zkh1J9vA5NqqJbAcw6a5uH0kjtuJOSvP5CVQc2xsX9i
+U9+eZesQMQKBgHo4Znasqg/oNIRf+vvdHOlNL8fhbqVQzzHqKSLfoRYTrwFirCfu
+jInnuA4LGPrYZqHTiPgJEpX456EQli4fNUu6hNUTvdJe3LD4S2SvB1G8G6npfp4Q
+TF7FX5W+M3S2gOBZRh6OtUQo56Y+QFr6U1kGIPiSgLeN/51gap/DWVF9AoGBAMmL
+hMEloFF+Y/rtPbvNrkqRc+YKn32jyfw9dN7rGYzKbGaHkmjc+sLzIhGHubfzhWLX
+Law9AJ8I4y6BXIx1bvMDtche/igMefV/mLUxnNhd8QG+fHhayJwcDlMamdBxjOqq
+5Q+oq927UP0ipFXQMzAWvW3Hd3W1WlvdL8kqjxvBAoGBAMaZ9JZO48Zn17IUweZC
+oVfM99YaHa+dm3L47PdQN6Ag6UjQ+sZ/6SLGIIg67SDhUQ+nuPCL8PH3Rf7PCuqW
+oHW3F+44SIrVdLlMkWb444dxdP6Xvb9aOMpvopBDuvzYPR3xzZ202DZbZ0sIEVu8
+8a+09JbRmEI2/Ee+em6a/Y4T
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/sun/security/ssl/CertPathRestrictions/certs/INTER_CA_SHA1-ROOT_CA_SHA256.cer	Tue Apr 18 22:25:33 2017 +0200
@@ -0,0 +1,80 @@
+Certificate:
+    Data:
+        Version: 3 (0x2)
+        Serial Number:
+            84:a1:70:1d:0a:92:d3:cd
+    Signature Algorithm: sha1WithRSAEncryption
+        Issuer: C=US, ST=CA, L=City, O=Org, OU=Java, CN=ROOT_CA_SHA256
+        Validity
+            Not Before: Mar 30 04:51:03 2017 GMT
+            Not After : Mar 28 04:51:03 2027 GMT
+        Subject: C=US, ST=CA, L=City, O=Org, OU=Java, CN=INTER_CA_SHA1-ROOT_CA_SHA256
+        Subject Public Key Info:
+            Public Key Algorithm: rsaEncryption
+                Public-Key: (2048 bit)
+                Modulus:
+                    00:d6:37:af:2f:57:9e:c4:3e:a3:d9:0e:db:e2:db:
+                    e3:48:e2:d7:f1:52:09:1a:58:95:db:aa:b2:ca:b8:
+                    02:42:f1:b7:df:f5:e7:59:a4:c5:c6:03:2a:8c:a4:
+                    30:eb:ec:c0:23:b3:fd:d3:0d:8a:55:69:66:0d:21:
+                    de:62:c2:a6:a6:22:66:c1:2d:87:ff:2b:42:ce:91:
+                    a5:fa:f9:3c:a8:81:aa:b0:c1:d3:55:af:24:79:79:
+                    87:06:5c:48:89:63:53:09:da:68:33:08:d7:86:27:
+                    4f:75:e2:ac:25:97:7c:64:8c:01:68:94:1e:a8:f5:
+                    0a:08:6c:b0:77:71:cb:65:d2:fc:3a:a0:0a:22:dd:
+                    32:96:43:12:7e:50:8e:bf:b8:1a:2d:5f:97:90:f7:
+                    3d:5b:fc:c0:ec:e8:f3:57:1c:1d:b6:8d:80:23:e2:
+                    d3:9e:3c:c6:71:ab:b0:15:0b:04:c5:a5:66:c7:2b:
+                    c8:f9:7e:d5:f1:a5:5a:14:e4:40:8d:1d:f2:00:1c:
+                    ba:6b:26:a7:3f:94:a7:5f:ee:b3:32:7e:56:ec:8c:
+                    3f:27:57:b4:f0:63:e1:56:ed:67:ce:42:08:89:86:
+                    4d:0e:2b:75:5a:05:e4:ac:a2:fa:4e:3b:08:d2:e0:
+                    ba:6c:6b:38:77:79:45:de:64:95:24:96:b6:2b:31:
+                    f2:37
+                Exponent: 65537 (0x10001)
+        X509v3 extensions:
+            X509v3 Authority Key Identifier: 
+                DirName:/C=US/ST=CA/L=City/O=Org/OU=Java/CN=ROOT_CA_SHA256
+                serial:A3:52:9D:82:6F:DD:C6:1D
+
+            X509v3 Basic Constraints: 
+                CA:TRUE
+    Signature Algorithm: sha1WithRSAEncryption
+         56:fb:b0:ab:a6:bb:3a:55:04:ed:5c:3b:ae:0c:0d:32:8f:aa:
+         ec:b7:24:2c:d5:37:b9:1f:91:64:21:c2:c0:6d:bc:d4:d4:5e:
+         e2:f1:12:ad:34:02:93:65:10:6c:93:93:2c:23:53:e8:ed:96:
+         c7:3b:6b:44:df:ff:24:8b:c1:cc:26:b2:1e:8f:26:66:34:3a:
+         bb:7d:ef:4e:a6:7e:b2:c8:93:c9:f7:46:5a:de:40:88:70:28:
+         c7:d1:fd:27:c3:99:fd:6a:a1:a5:e1:6d:c3:5a:bc:99:28:95:
+         e9:17:ed:a4:56:a5:04:ad:fb:74:a2:01:26:2a:5a:45:bc:7b:
+         0d:df:0c:41:79:8b:b4:15:50:cd:88:ce:f5:a7:ee:cb:d2:5b:
+         76:81:4c:1b:09:92:0e:e9:c6:42:df:b7:81:9e:89:3d:49:ed:
+         17:fa:d2:2f:bd:8b:74:d5:cb:ce:af:46:6a:74:b3:34:a0:c5:
+         a0:64:66:7a:80:59:15:1e:de:16:df:11:3d:1e:96:e2:e5:2d:
+         f1:4d:20:f3:f6:f1:19:aa:ac:f8:b4:6e:76:a0:26:6c:cd:90:
+         f2:23:35:a0:8b:c8:e8:5d:27:5d:34:d3:69:74:61:c5:ac:6a:
+         54:e9:86:8d:ca:ca:16:03:48:7f:cd:23:43:41:e2:77:3a:5d:
+         f2:3e:de:fa
+-----BEGIN CERTIFICATE-----
+MIID3DCCAsSgAwIBAgIJAIShcB0KktPNMA0GCSqGSIb3DQEBBQUAMF8xCzAJBgNV
+BAYTAlVTMQswCQYDVQQIDAJDQTENMAsGA1UEBwwEQ2l0eTEMMAoGA1UECgwDT3Jn
+MQ0wCwYDVQQLDARKYXZhMRcwFQYDVQQDDA5ST09UX0NBX1NIQTI1NjAeFw0xNzAz
+MzAwNDUxMDNaFw0yNzAzMjgwNDUxMDNaMG0xCzAJBgNVBAYTAlVTMQswCQYDVQQI
+DAJDQTENMAsGA1UEBwwEQ2l0eTEMMAoGA1UECgwDT3JnMQ0wCwYDVQQLDARKYXZh
+MSUwIwYDVQQDDBxJTlRFUl9DQV9TSEExLVJPT1RfQ0FfU0hBMjU2MIIBIjANBgkq
+hkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA1jevL1eexD6j2Q7b4tvjSOLX8VIJGliV
+26qyyrgCQvG33/XnWaTFxgMqjKQw6+zAI7P90w2KVWlmDSHeYsKmpiJmwS2H/ytC
+zpGl+vk8qIGqsMHTVa8keXmHBlxIiWNTCdpoMwjXhidPdeKsJZd8ZIwBaJQeqPUK
+CGywd3HLZdL8OqAKIt0ylkMSflCOv7gaLV+XkPc9W/zA7OjzVxwdto2AI+LTnjzG
+cauwFQsExaVmxyvI+X7V8aVaFORAjR3yABy6ayanP5SnX+6zMn5W7Iw/J1e08GPh
+Vu1nzkIIiYZNDit1WgXkrKL6TjsI0uC6bGs4d3lF3mSVJJa2KzHyNwIDAQABo4GM
+MIGJMHkGA1UdIwRyMHChY6RhMF8xCzAJBgNVBAYTAlVTMQswCQYDVQQIDAJDQTEN
+MAsGA1UEBwwEQ2l0eTEMMAoGA1UECgwDT3JnMQ0wCwYDVQQLDARKYXZhMRcwFQYD
+VQQDDA5ST09UX0NBX1NIQTI1NoIJAKNSnYJv3cYdMAwGA1UdEwQFMAMBAf8wDQYJ
+KoZIhvcNAQEFBQADggEBAFb7sKumuzpVBO1cO64MDTKPquy3JCzVN7kfkWQhwsBt
+vNTUXuLxEq00ApNlEGyTkywjU+jtlsc7a0Tf/ySLwcwmsh6PJmY0Ort9706mfrLI
+k8n3RlreQIhwKMfR/SfDmf1qoaXhbcNavJkolekX7aRWpQSt+3SiASYqWkW8ew3f
+DEF5i7QVUM2IzvWn7svSW3aBTBsJkg7pxkLft4GeiT1J7Rf60i+9i3TVy86vRmp0
+szSgxaBkZnqAWRUe3hbfET0eluLlLfFNIPP28RmqrPi0bnagJmzNkPIjNaCLyOhd
+J10002l0YcWsalTpho3KyhYDSH/NI0NB4nc6XfI+3vo=
+-----END CERTIFICATE-----
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/sun/security/ssl/CertPathRestrictions/certs/INTER_CA_SHA256-ROOT_CA_SHA1-PRIV.key	Tue Apr 18 22:25:33 2017 +0200
@@ -0,0 +1,26 @@
+MIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQDh12cWta4H1sY6
+KHyfvxSJk1JIUAe08JFmHwvO0Eb6LRmKrqwbXEyGs0CPGhMlnmxjvrfXbKkUjodY
+9ByxSBa7zYaVdPDGKDQ3HvPxyjZ0npPrHDII2wR+0UOD0ftkDbPHWQFBsl0OY/sI
+pRzihYRh8MwCrADdza3vHPrNBz2umuM5jnN20FVIGKhGMGbg5eackBmgvcaWT6BW
+B67iYRWVRwLywdSE+imOIS4P7ivndBe1DlB+z4oBmbBwYkM+5WyR3yT4+stdByyn
+naL+kExsC/TWDw+sE9TQUo2zqRbNI1j8UhBaQZz1pbX5YeGPTq/Z2J8EGvPxz6VY
+PmkDyMl3AgMBAAECggEAKrlDKUqpZ5Y73di26smNKxGRqVhqfNJdz0HkS/We18kc
+Yd31dR+a4oial/fI038K5ju4L6rAucDU3gEgRHFsy45v/Won+nS0nBDg+UbV0m4F
+cZ7d4Er+qLcR3KgmtKDa98VgtXr2m7hSTypdMoUrrBOPpJnBeDRmyStkTtEl3Bfa
+Fh72SZXNauGvB5+qrbPhls1HoWVbzZ3i6oUCBDrfmLD6G0ipGM+AQICmXjYX8OxT
+Ye5u/6DU4TkWu5A6/1m0Q4clGZXSeMx2d4PkZ0jZKOXdhwvzAaGh7I0AkuA4ZlCj
+slXENyAzQhm4EHHWxvld11e8oEh4DUfWtUXeLttawQKBgQDybE5gjAZdv+5BJXWV
+l2G+zb5tKHWd0XQQ2epktX+i+iA5lA0bLkAA4rrmZVsDEc4D2yjINsopBHTjwvtV
+F/LBBWIynm6MkIyjY6+0fBfoikz9ebKikuf1YRoRC5Dl0pd2Wa/ps2wowDbQnj3o
+4e6x+z0WviyL+uRr1JyotR2J5wKBgQDufVw64Z6AdWThlnP8qXqW12QQBd5qChPr
+fHJEkx0ViBoM97yalVzDssXn4X2ESVDqtsxH21SzKzDGzLoCG3PwCPgp9zWk9GS/
+HfhXFzI3qHIlI+s6481vjqDnXtvJ7oHutxYkkYQXSMgC69jeRY0nW78Bz03BAYjQ
+boRmeK1x8QKBgQDw9VBOTMADLUPvQwGGKAsC8VQHAgEuVcONAF0nrvPoFcA0GwGP
+87+wYayuVy5IdckVMiBuKW91p7VbsjHJGd2zl9tMPwfY9dCkkvBRcEr/W4A9Llqt
+l2GyF8smCB4FIfZkr67Xlvy54Jxbbf5RXUi5ZeUJlwuGM2IaACGa2zM6HwKBgEmW
+iOTqRTwh/RTWlcd6jAcLQybmiLBzl53r8l5SfoDsVA14S8vvFoaUHRjlrRMqhDtI
+WFQ7yzDVvOE6vpJz4hxIyDo6u2TAvG10U/Kbh7VA1qe7I5QyQmuPuPprfKocXB9K
+gxyZggalQIIWP/6lu15PoupuCvHpBUw7LcNorSwhAoGAXXBcp4U369B3ld+M+hC9
+G+2VttaC2917iqoM8R7WOiwez+10s+fNv89B6DjZxeX5haa7bbB+RvfqN8OysIRK
+m0Bh4w6q/JuRydj9T5sJLk9oUrEFLncqihlNT+1WEwR5x50OODYjpHz1YORo5HzL
+cnXKk8xTZFE7mXD1ZJoRLxc=
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/sun/security/ssl/CertPathRestrictions/certs/INTER_CA_SHA256-ROOT_CA_SHA1.cer	Tue Apr 18 22:25:33 2017 +0200
@@ -0,0 +1,80 @@
+Certificate:
+    Data:
+        Version: 3 (0x2)
+        Serial Number:
+            8d:a0:d2:8a:ee:0b:cf:64
+    Signature Algorithm: sha256WithRSAEncryption
+        Issuer: C=US, ST=CA, L=City, O=Org, OU=Java, CN=ROOT_CA_SHA1
+        Validity
+            Not Before: Mar 30 04:51:03 2017 GMT
+            Not After : Mar 28 04:51:03 2027 GMT
+        Subject: C=US, ST=CA, L=City, O=Org, OU=Java, CN=INTER_CA_SHA256-ROOT_CA_SHA1
+        Subject Public Key Info:
+            Public Key Algorithm: rsaEncryption
+                Public-Key: (2048 bit)
+                Modulus:
+                    00:e1:d7:67:16:b5:ae:07:d6:c6:3a:28:7c:9f:bf:
+                    14:89:93:52:48:50:07:b4:f0:91:66:1f:0b:ce:d0:
+                    46:fa:2d:19:8a:ae:ac:1b:5c:4c:86:b3:40:8f:1a:
+                    13:25:9e:6c:63:be:b7:d7:6c:a9:14:8e:87:58:f4:
+                    1c:b1:48:16:bb:cd:86:95:74:f0:c6:28:34:37:1e:
+                    f3:f1:ca:36:74:9e:93:eb:1c:32:08:db:04:7e:d1:
+                    43:83:d1:fb:64:0d:b3:c7:59:01:41:b2:5d:0e:63:
+                    fb:08:a5:1c:e2:85:84:61:f0:cc:02:ac:00:dd:cd:
+                    ad:ef:1c:fa:cd:07:3d:ae:9a:e3:39:8e:73:76:d0:
+                    55:48:18:a8:46:30:66:e0:e5:e6:9c:90:19:a0:bd:
+                    c6:96:4f:a0:56:07:ae:e2:61:15:95:47:02:f2:c1:
+                    d4:84:fa:29:8e:21:2e:0f:ee:2b:e7:74:17:b5:0e:
+                    50:7e:cf:8a:01:99:b0:70:62:43:3e:e5:6c:91:df:
+                    24:f8:fa:cb:5d:07:2c:a7:9d:a2:fe:90:4c:6c:0b:
+                    f4:d6:0f:0f:ac:13:d4:d0:52:8d:b3:a9:16:cd:23:
+                    58:fc:52:10:5a:41:9c:f5:a5:b5:f9:61:e1:8f:4e:
+                    af:d9:d8:9f:04:1a:f3:f1:cf:a5:58:3e:69:03:c8:
+                    c9:77
+                Exponent: 65537 (0x10001)
+        X509v3 extensions:
+            X509v3 Authority Key Identifier: 
+                DirName:/C=US/ST=CA/L=City/O=Org/OU=Java/CN=ROOT_CA_SHA1
+                serial:F1:3B:B7:FB:28:3F:52:09
+
+            X509v3 Basic Constraints: 
+                CA:TRUE
+    Signature Algorithm: sha256WithRSAEncryption
+         24:74:94:0a:7d:81:62:16:ed:4e:0f:e2:19:06:bd:8b:7a:e4:
+         35:63:4c:73:ec:3a:45:d7:2a:8c:80:e6:6b:d9:26:7d:78:9f:
+         6b:36:f9:fd:94:f7:ac:86:3c:0e:95:66:80:f3:0b:93:0f:44:
+         0a:05:76:d9:1d:c6:37:6f:ea:02:b9:29:e9:96:11:d1:e6:1e:
+         70:95:31:77:22:ed:3c:96:ad:9f:74:8c:41:f5:44:47:a2:4e:
+         d4:58:86:92:31:36:94:90:05:9d:94:16:8c:f8:c8:18:7b:45:
+         dc:49:45:53:63:06:bb:c6:a9:33:72:fe:48:7b:0e:21:89:e2:
+         6c:44:29:3c:10:65:c6:7d:8e:6c:cb:95:ea:a1:ae:3b:c1:12:
+         98:ce:b9:c8:98:12:0d:ac:a7:bd:31:cc:aa:ac:51:b4:a7:33:
+         5b:60:0d:d6:ed:e0:29:5a:29:f5:fc:e0:27:db:77:88:fd:59:
+         0c:02:70:d8:f4:1d:89:88:13:94:55:5b:77:a3:a6:8e:18:9a:
+         b8:82:5b:64:27:8c:ef:10:6a:df:ed:fd:a4:b5:2b:44:0f:5f:
+         89:08:15:48:df:b0:13:08:7c:08:cc:07:ea:b8:a6:17:ab:35:
+         65:07:2c:b9:ec:9a:d0:1f:e7:b9:a7:36:9e:24:f7:73:10:e0:
+         70:6c:78:6e
+-----BEGIN CERTIFICATE-----
+MIID2DCCAsCgAwIBAgIJAI2g0oruC89kMA0GCSqGSIb3DQEBCwUAMF0xCzAJBgNV
+BAYTAlVTMQswCQYDVQQIDAJDQTENMAsGA1UEBwwEQ2l0eTEMMAoGA1UECgwDT3Jn
+MQ0wCwYDVQQLDARKYXZhMRUwEwYDVQQDDAxST09UX0NBX1NIQTEwHhcNMTcwMzMw
+MDQ1MTAzWhcNMjcwMzI4MDQ1MTAzWjBtMQswCQYDVQQGEwJVUzELMAkGA1UECAwC
+Q0ExDTALBgNVBAcMBENpdHkxDDAKBgNVBAoMA09yZzENMAsGA1UECwwESmF2YTEl
+MCMGA1UEAwwcSU5URVJfQ0FfU0hBMjU2LVJPT1RfQ0FfU0hBMTCCASIwDQYJKoZI
+hvcNAQEBBQADggEPADCCAQoCggEBAOHXZxa1rgfWxjoofJ+/FImTUkhQB7TwkWYf
+C87QRvotGYqurBtcTIazQI8aEyWebGO+t9dsqRSOh1j0HLFIFrvNhpV08MYoNDce
+8/HKNnSek+scMgjbBH7RQ4PR+2QNs8dZAUGyXQ5j+wilHOKFhGHwzAKsAN3Nre8c
++s0HPa6a4zmOc3bQVUgYqEYwZuDl5pyQGaC9xpZPoFYHruJhFZVHAvLB1IT6KY4h
+Lg/uK+d0F7UOUH7PigGZsHBiQz7lbJHfJPj6y10HLKedov6QTGwL9NYPD6wT1NBS
+jbOpFs0jWPxSEFpBnPWltflh4Y9Or9nYnwQa8/HPpVg+aQPIyXcCAwEAAaOBijCB
+hzB3BgNVHSMEcDBuoWGkXzBdMQswCQYDVQQGEwJVUzELMAkGA1UECAwCQ0ExDTAL
+BgNVBAcMBENpdHkxDDAKBgNVBAoMA09yZzENMAsGA1UECwwESmF2YTEVMBMGA1UE
+AwwMUk9PVF9DQV9TSEExggkA8Tu3+yg/UgkwDAYDVR0TBAUwAwEB/zANBgkqhkiG
+9w0BAQsFAAOCAQEAJHSUCn2BYhbtTg/iGQa9i3rkNWNMc+w6RdcqjIDma9kmfXif
+azb5/ZT3rIY8DpVmgPMLkw9ECgV22R3GN2/qArkp6ZYR0eYecJUxdyLtPJatn3SM
+QfVER6JO1FiGkjE2lJAFnZQWjPjIGHtF3ElFU2MGu8apM3L+SHsOIYnibEQpPBBl
+xn2ObMuV6qGuO8ESmM65yJgSDaynvTHMqqxRtKczW2AN1u3gKVop9fzgJ9t3iP1Z
+DAJw2PQdiYgTlFVbd6OmjhiauIJbZCeM7xBq3+39pLUrRA9fiQgVSN+wEwh8CMwH
+6rimF6s1ZQcsueya0B/nuac2niT3cxDgcGx4bg==
+-----END CERTIFICATE-----
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/sun/security/ssl/CertPathRestrictions/certs/INTER_CA_SHA256-ROOT_CA_SHA256-PRIV.key	Tue Apr 18 22:25:33 2017 +0200
@@ -0,0 +1,26 @@
+MIIEvgIBADANBgkqhkiG9w0BAQEFAASCBKgwggSkAgEAAoIBAQDbXbqJwTisc3wF
+Z6MYWonNxMsWBfNfwFB/KLQfEfZ+phvReORvJZ5lVT/1gTVs5/QhREU0qW48OxyM
+NXKgkcBZGLkRvVlDaOEcbTIDa4PYf7rnsTtU8DWYuyqqmeBnJ2ViKJ3ZGA750ctm
+ZsDZlWdwE5iCqX3hA/pfHGu+CNiW2jWSulookdIPqdJeLiwgnntm5tZFxoZ9hD1h
+J88iRqmqpS4joYXPxUNxfJ49Nx4iRfrx7HpyUVg3i5Q2q/AVuVSwbbPfNaQrG71V
+EbK0K7EjtL8Gw8DCS8Gvr0ApIpabA644BueWA9skjns9lvfSuH76Y5e2nHGJiOz7
+LWMFV24LAgMBAAECggEAD546u7gQCucl+1SHniJEEWxjcSv3SeftU0BYoqWqwRWe
+gWl0Ch3Jizlollger6RME1pC+x7dBFjJDYp4oMn/wdgqxQKQKmZ7MITtvKSY/H8L
+lZdevAtmJXud7AuMmIuLglOV+XDnEA5Jxv6l2Ff0x1v9zb+3gJ/B4aeqXBtRIFxD
+CfCcvcN1Bl+jj2fvS8iRrqofGa6DGXZVZvtIVjIvJnR1YBVMVYBNs6kcscM5Nblr
+PJFDDsg+Ph7hq5gpwj7pyb4e54sn06pdfBLgGkHJ82tCNkc+f4Ee2M7MoS//m4IC
+ajV+xht4REHuB7h5GM50TF5Gziianyc3g8//M7sC8QKBgQD7tvSzJK1N0w9NPK1e
+Q5zfEWxU1c7dJ/hr81OpvEzUut1vZeKT1mydtA0YJftDTFTXe5fsPKNTIrL4BWUw
+PLa3jWQNNDSLDNhdoqKrno+017pD7+p8G8x3AfyHxn6x2Shoz0jHTnGf+Q0vnvdT
+ZTFpWU+3J8Wp4+1Nx2lwGGEJXwKBgQDfGcnk/fTSs/QQNgzkC1HaQ35b66eEBwK3
+yi8KNsNxDByvdYGxaK/tLRiZIsKMxAV+3jebfA4WSgDkenmzGLn4gYUr5gkkmEW5
+irETT+HDK8LeM2iIbCROactwu3ytJrgpaoDXxRbDsGCUf98hjz1JDCR94wjGH78H
+K3Pmbm6e1QKBgEIuTVIYj5RJrNlC3dZN8p3Xx+LaQER3cOJ5HIMhJhY8d2IFqLf0
+BaTFJTg3LEP6esgZD82l988w7Vs2l+9B10yVWTv7gOEaZHzh+OEklGYY3jlkiANP
+j8eudwX/02nRTcWY0mrMniVQZv4hTqfXkFFBkSr3wwmzCr6LcpZtYn4DAoGBAIEm
+2bTBu1/aoxhbYd0GHI1g8x5dbm1E7bLdzZt5Fm00GMsOGFVOiEGiEJJeCAgbVh8a
+n1BYYYNPtfKOYDNoxgfxWtmN4o8Xw41kl5vZa5VjmPyu//2xtNbb8dTCBKvsNUJs
+kEfYpZQFX/O3jsFLvauy5tElhCfFqv2IjyC/nzQ9AoGBAJLCz62crl/AXqArSnAH
+efX9ozrNMJMQDMDtw5xB/EqRMazmTlqkYr0H4iTS69QNAPr8czdmpY6uO6BRE9+/
+f/tWZXQj7eT8pd1Dp2Ed1vHsOfiAUha0cYUMrqshsqKNXrCxl7144iRGZY7OjFI1
+USqVVNaci2IrtW5+NGV62BYP
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/sun/security/ssl/CertPathRestrictions/certs/INTER_CA_SHA256-ROOT_CA_SHA256.cer	Tue Apr 18 22:25:33 2017 +0200
@@ -0,0 +1,80 @@
+Certificate:
+    Data:
+        Version: 3 (0x2)
+        Serial Number:
+            84:a1:70:1d:0a:92:d3:cc
+    Signature Algorithm: sha256WithRSAEncryption
+        Issuer: C=US, ST=CA, L=City, O=Org, OU=Java, CN=ROOT_CA_SHA256
+        Validity
+            Not Before: Mar 30 04:51:02 2017 GMT
+            Not After : Mar 28 04:51:02 2027 GMT
+        Subject: C=US, ST=CA, L=City, O=Org, OU=Java, CN=INTER_CA_SHA256-ROOT_CA_SHA256
+        Subject Public Key Info:
+            Public Key Algorithm: rsaEncryption
+                Public-Key: (2048 bit)
+                Modulus:
+                    00:db:5d:ba:89:c1:38:ac:73:7c:05:67:a3:18:5a:
+                    89:cd:c4:cb:16:05:f3:5f:c0:50:7f:28:b4:1f:11:
+                    f6:7e:a6:1b:d1:78:e4:6f:25:9e:65:55:3f:f5:81:
+                    35:6c:e7:f4:21:44:45:34:a9:6e:3c:3b:1c:8c:35:
+                    72:a0:91:c0:59:18:b9:11:bd:59:43:68:e1:1c:6d:
+                    32:03:6b:83:d8:7f:ba:e7:b1:3b:54:f0:35:98:bb:
+                    2a:aa:99:e0:67:27:65:62:28:9d:d9:18:0e:f9:d1:
+                    cb:66:66:c0:d9:95:67:70:13:98:82:a9:7d:e1:03:
+                    fa:5f:1c:6b:be:08:d8:96:da:35:92:ba:5a:28:91:
+                    d2:0f:a9:d2:5e:2e:2c:20:9e:7b:66:e6:d6:45:c6:
+                    86:7d:84:3d:61:27:cf:22:46:a9:aa:a5:2e:23:a1:
+                    85:cf:c5:43:71:7c:9e:3d:37:1e:22:45:fa:f1:ec:
+                    7a:72:51:58:37:8b:94:36:ab:f0:15:b9:54:b0:6d:
+                    b3:df:35:a4:2b:1b:bd:55:11:b2:b4:2b:b1:23:b4:
+                    bf:06:c3:c0:c2:4b:c1:af:af:40:29:22:96:9b:03:
+                    ae:38:06:e7:96:03:db:24:8e:7b:3d:96:f7:d2:b8:
+                    7e:fa:63:97:b6:9c:71:89:88:ec:fb:2d:63:05:57:
+                    6e:0b
+                Exponent: 65537 (0x10001)
+        X509v3 extensions:
+            X509v3 Authority Key Identifier: 
+                DirName:/C=US/ST=CA/L=City/O=Org/OU=Java/CN=ROOT_CA_SHA256
+                serial:A3:52:9D:82:6F:DD:C6:1D
+
+            X509v3 Basic Constraints: 
+                CA:TRUE
+    Signature Algorithm: sha256WithRSAEncryption
+         3f:f2:91:96:59:da:c1:8a:8c:4d:eb:25:1f:74:87:6f:fc:2e:
+         92:7e:44:ff:a7:0b:78:aa:6d:2b:fe:b8:0a:b9:e9:bc:19:87:
+         44:15:e1:3a:e4:54:e6:4b:54:3c:75:d9:f8:c9:07:83:74:f4:
+         4c:ab:e4:6b:19:64:b6:4b:69:44:6e:74:f6:66:cf:16:43:8f:
+         9c:cb:20:e4:7a:5e:78:13:00:6f:28:78:8d:c5:05:46:a9:92:
+         0f:d0:38:c3:8b:0e:39:d4:87:e9:ee:35:07:78:dd:1a:1a:8c:
+         3a:36:56:4e:3b:96:7a:d1:2c:29:95:06:29:ac:b2:f7:5c:fc:
+         09:1c:72:24:e2:9e:72:bf:60:3a:7a:9b:59:35:48:6a:d2:3e:
+         76:7f:ad:41:45:a5:6f:93:96:10:c4:4c:cf:3f:f1:1d:00:5f:
+         d1:60:f1:88:86:d8:ef:ff:72:63:8f:4c:df:9e:35:cb:17:2c:
+         16:7b:d4:6c:0e:67:b6:ee:bc:68:07:b0:99:df:c5:f3:88:28:
+         a1:46:bb:6d:f5:2c:45:6b:e9:90:c0:78:35:20:73:14:5a:d0:
+         a5:56:cb:04:f4:43:a7:cf:28:f5:a3:5b:ac:f2:a3:4c:f6:39:
+         3c:ef:f4:b1:42:20:8e:2a:14:0d:a1:b4:38:b2:f2:6c:14:33:
+         05:04:bb:a7
+-----BEGIN CERTIFICATE-----
+MIID3jCCAsagAwIBAgIJAIShcB0KktPMMA0GCSqGSIb3DQEBCwUAMF8xCzAJBgNV
+BAYTAlVTMQswCQYDVQQIDAJDQTENMAsGA1UEBwwEQ2l0eTEMMAoGA1UECgwDT3Jn
+MQ0wCwYDVQQLDARKYXZhMRcwFQYDVQQDDA5ST09UX0NBX1NIQTI1NjAeFw0xNzAz
+MzAwNDUxMDJaFw0yNzAzMjgwNDUxMDJaMG8xCzAJBgNVBAYTAlVTMQswCQYDVQQI
+DAJDQTENMAsGA1UEBwwEQ2l0eTEMMAoGA1UECgwDT3JnMQ0wCwYDVQQLDARKYXZh
+MScwJQYDVQQDDB5JTlRFUl9DQV9TSEEyNTYtUk9PVF9DQV9TSEEyNTYwggEiMA0G
+CSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQDbXbqJwTisc3wFZ6MYWonNxMsWBfNf
+wFB/KLQfEfZ+phvReORvJZ5lVT/1gTVs5/QhREU0qW48OxyMNXKgkcBZGLkRvVlD
+aOEcbTIDa4PYf7rnsTtU8DWYuyqqmeBnJ2ViKJ3ZGA750ctmZsDZlWdwE5iCqX3h
+A/pfHGu+CNiW2jWSulookdIPqdJeLiwgnntm5tZFxoZ9hD1hJ88iRqmqpS4joYXP
+xUNxfJ49Nx4iRfrx7HpyUVg3i5Q2q/AVuVSwbbPfNaQrG71VEbK0K7EjtL8Gw8DC
+S8Gvr0ApIpabA644BueWA9skjns9lvfSuH76Y5e2nHGJiOz7LWMFV24LAgMBAAGj
+gYwwgYkweQYDVR0jBHIwcKFjpGEwXzELMAkGA1UEBhMCVVMxCzAJBgNVBAgMAkNB
+MQ0wCwYDVQQHDARDaXR5MQwwCgYDVQQKDANPcmcxDTALBgNVBAsMBEphdmExFzAV
+BgNVBAMMDlJPT1RfQ0FfU0hBMjU2ggkAo1Kdgm/dxh0wDAYDVR0TBAUwAwEB/zAN
+BgkqhkiG9w0BAQsFAAOCAQEAP/KRllnawYqMTeslH3SHb/wukn5E/6cLeKptK/64
+CrnpvBmHRBXhOuRU5ktUPHXZ+MkHg3T0TKvkaxlktktpRG509mbPFkOPnMsg5Hpe
+eBMAbyh4jcUFRqmSD9A4w4sOOdSH6e41B3jdGhqMOjZWTjuWetEsKZUGKayy91z8
+CRxyJOKecr9gOnqbWTVIatI+dn+tQUWlb5OWEMRMzz/xHQBf0WDxiIbY7/9yY49M
+3541yxcsFnvUbA5ntu68aAewmd/F84gooUa7bfUsRWvpkMB4NSBzFFrQpVbLBPRD
+p88o9aNbrPKjTPY5PO/0sUIgjioUDaG0OLLybBQzBQS7pw==
+-----END CERTIFICATE-----
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/sun/security/ssl/CertPathRestrictions/certs/ROOT_CA_SHA1-PRIV.key	Tue Apr 18 22:25:33 2017 +0200
@@ -0,0 +1,26 @@
+MIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQDhROyqYZ5UdQJ0
+xJdG4B+aXPHbIKV0w5AvJ7r4SuvIJ/4pEmV6fIU3+4CvN2sXKzW+0DppOBz99Oe6
+19jfMAx5t0pKHkwh5J0bduLf1k83lm8CvoX1a9lYY6ER4Y8wWtTcHG016onl8Lxq
+QVqlqbk9zsbNipvWxipIQOgzq7DmTXQ2Hrx0tg4DROlgwuarPBWcZjq6dG09nI0E
+zSY/Wis619L/6sdCxGFhvnJ0YbULvIqdR2J638KEO+rx1RXD66Jqc0KhnGZLf7NT
+YfTlY0zIMHE8oMkJPdH9tPKbyXMXhiG/u5x81RcJxT4gLi5fq2yrvMsaUC13bnJJ
+npFNy6XTAgMBAAECggEAPS4h9Jg0jw2EUEBAMaCXFK5fhTrVlOO0Ggp5TgvTA3ZR
+Ich8RQrih3TH2056yD0VCLC23HK/9Pz5npYWsW70RG5SP9UAqkfTn2znaxFiTF+P
+4Lfr296hlc7hJOEUqXZRz0HtKzJ6pzd9hIIhY1K4G6A4AATAFFGXlC4Eolvj3Hf0
+NgVFDYaFDEpEiin+fAsM5c1ZE0pxRZSVE5Emr9XvkvxLm5dK9lKOyyOQ+5RHhxQ6
+J4n+6Ct0O+FkeP9u3jTMtew9gxTwvHSgkf05hSRoqgMKcusKpqhHp6E4mT7sus7q
+AYzdv5sNIcx7PpojuHjploMH7ghhYxCmVOOFxXJ4CQKBgQD2naA8zZnh5BfbVC8p
+C9A6HfwnZ7cCjGtL30y8fh8OAMHbdGE4JXlhifPgW7PDxZ0Yho4rYd9MxLVcGl+p
+YPOKKcaKbzwdUJwZ4Zs1dJC+LTRqku6O3qlEofeojHN5IctLoLqDsiZBD7aT4l+O
+wmAWqwLZZQtiFpA/jbCb/Qw7tQKBgQDp11rFSHLKuVdMuSnUon3WN6lj9WNM3KFy
+C8R4EN/DTnuHrVL0MCff9eddBYvpQe0z/LA74oAD9fSjmtYe/24qIm2lAWVkwxBm
+yyspUmOybU8Q3GN8xw1Vrwg8JR5JVAOwKHwCGmybT7Zs+9eJRONnnZ6nUbTQ94cP
+sJVkyGUgZwKBgQCd/0CAk+xpl1tdbiLEtkfSZBF/IWhTXqkDM+2SuW6l5wBL29TJ
+RuDsB5jR/Y4+96T86H++9XY9Va0nc9IjzvRYaQlE+ZzW3yUTQ8HPTn3JCWcSfE4Q
+BEEHsojbWBhG28rGChRUeVceybVcK2SzLn6nJyqtIppXXkNOJDWoykcDHQKBgHzY
+27+k1JTjq3ZtDaZXMvQiN7AEnYW17gRjv/uSlsVBq7ZelYGGDGQIeAQ0J+Tbq/cr
+nDP80/hJYtnOmy9llL2uL/f+7NGFS8Z2Bo9DS7NBpQsNf5ho9fefQbhK4Qapcmak
+1sCQtxec0XsSYpsJSphRkRkoCG/hGB0KXFi4nTVVAoGAJrrh1rG1UMXmFUpraXIy
+Mc58lEYB87EkMOthyK8XklxLoYKPZlVS7AZZDtQMpRC6YnweiX6LmO4AamtlT71x
+BzQgmwHn4wOaysDPHFuf5hNCobXJREoiNzHb4AcqiZ7SNAW5Jd+0/PSY47hrDnRy
+wNFyg3O0k3kaXz5h3lVhxo4=
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/sun/security/ssl/CertPathRestrictions/certs/ROOT_CA_SHA1.cer	Tue Apr 18 22:25:33 2017 +0200
@@ -0,0 +1,80 @@
+Certificate:
+    Data:
+        Version: 3 (0x2)
+        Serial Number:
+            f1:3b:b7:fb:28:3f:52:09
+    Signature Algorithm: sha1WithRSAEncryption
+        Issuer: C=US, ST=CA, L=City, O=Org, OU=Java, CN=ROOT_CA_SHA1
+        Validity
+            Not Before: Mar 30 04:51:01 2017 GMT
+            Not After : Mar 28 04:51:01 2027 GMT
+        Subject: C=US, ST=CA, L=City, O=Org, OU=Java, CN=ROOT_CA_SHA1
+        Subject Public Key Info:
+            Public Key Algorithm: rsaEncryption
+                Public-Key: (2048 bit)
+                Modulus:
+                    00:e1:44:ec:aa:61:9e:54:75:02:74:c4:97:46:e0:
+                    1f:9a:5c:f1:db:20:a5:74:c3:90:2f:27:ba:f8:4a:
+                    eb:c8:27:fe:29:12:65:7a:7c:85:37:fb:80:af:37:
+                    6b:17:2b:35:be:d0:3a:69:38:1c:fd:f4:e7:ba:d7:
+                    d8:df:30:0c:79:b7:4a:4a:1e:4c:21:e4:9d:1b:76:
+                    e2:df:d6:4f:37:96:6f:02:be:85:f5:6b:d9:58:63:
+                    a1:11:e1:8f:30:5a:d4:dc:1c:6d:35:ea:89:e5:f0:
+                    bc:6a:41:5a:a5:a9:b9:3d:ce:c6:cd:8a:9b:d6:c6:
+                    2a:48:40:e8:33:ab:b0:e6:4d:74:36:1e:bc:74:b6:
+                    0e:03:44:e9:60:c2:e6:ab:3c:15:9c:66:3a:ba:74:
+                    6d:3d:9c:8d:04:cd:26:3f:5a:2b:3a:d7:d2:ff:ea:
+                    c7:42:c4:61:61:be:72:74:61:b5:0b:bc:8a:9d:47:
+                    62:7a:df:c2:84:3b:ea:f1:d5:15:c3:eb:a2:6a:73:
+                    42:a1:9c:66:4b:7f:b3:53:61:f4:e5:63:4c:c8:30:
+                    71:3c:a0:c9:09:3d:d1:fd:b4:f2:9b:c9:73:17:86:
+                    21:bf:bb:9c:7c:d5:17:09:c5:3e:20:2e:2e:5f:ab:
+                    6c:ab:bc:cb:1a:50:2d:77:6e:72:49:9e:91:4d:cb:
+                    a5:d3
+                Exponent: 65537 (0x10001)
+        X509v3 extensions:
+            X509v3 Authority Key Identifier: 
+                DirName:/C=US/ST=CA/L=City/O=Org/OU=Java/CN=ROOT_CA_SHA1
+                serial:F1:3B:B7:FB:28:3F:52:09
+
+            X509v3 Basic Constraints: 
+                CA:TRUE
+    Signature Algorithm: sha1WithRSAEncryption
+         0b:be:7b:c7:53:14:87:37:02:66:37:f5:6f:38:3c:75:b3:72:
+         f6:f8:9c:77:4d:9a:e4:5c:23:3a:4a:5f:aa:6e:90:23:e9:b8:
+         48:fd:6d:e1:88:b5:a2:a5:0a:30:c0:7d:33:a8:6f:79:42:52:
+         80:f8:87:4b:2a:15:0a:ff:14:88:97:21:12:89:1c:d3:33:bf:
+         fa:4f:5e:68:9a:c6:69:2f:aa:1d:31:aa:80:f5:b0:d3:72:c9:
+         fa:ce:3b:5f:15:a6:61:e0:f1:d1:ab:e7:40:48:c1:d4:30:bd:
+         0a:13:37:0d:ea:ac:38:b2:af:1b:78:3a:29:53:ee:90:71:3b:
+         2b:a4:8b:16:e9:da:94:59:44:3d:7f:34:fb:0a:d1:6b:db:3d:
+         66:01:a6:0f:98:b5:cc:57:39:b9:09:f2:01:cc:e5:89:86:7d:
+         f2:9a:b2:ad:08:3d:da:05:f9:24:1e:30:98:cc:92:a9:4c:4a:
+         cf:a3:53:6e:7f:5e:db:aa:43:9c:ac:b1:b5:80:ab:7e:a3:89:
+         71:37:c2:4a:c1:16:9d:26:d5:70:89:8a:8e:a8:cb:40:3b:b8:
+         f0:d2:31:54:c2:1f:fc:24:5e:29:c1:5e:86:48:1e:83:4e:44:
+         30:ff:8d:46:47:b6:0e:9c:77:bf:ba:08:8b:bd:eb:b7:ca:45:
+         0a:e3:0c:ec
+-----BEGIN CERTIFICATE-----
+MIIDyDCCArCgAwIBAgIJAPE7t/soP1IJMA0GCSqGSIb3DQEBBQUAMF0xCzAJBgNV
+BAYTAlVTMQswCQYDVQQIDAJDQTENMAsGA1UEBwwEQ2l0eTEMMAoGA1UECgwDT3Jn
+MQ0wCwYDVQQLDARKYXZhMRUwEwYDVQQDDAxST09UX0NBX1NIQTEwHhcNMTcwMzMw
+MDQ1MTAxWhcNMjcwMzI4MDQ1MTAxWjBdMQswCQYDVQQGEwJVUzELMAkGA1UECAwC
+Q0ExDTALBgNVBAcMBENpdHkxDDAKBgNVBAoMA09yZzENMAsGA1UECwwESmF2YTEV
+MBMGA1UEAwwMUk9PVF9DQV9TSEExMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIB
+CgKCAQEA4UTsqmGeVHUCdMSXRuAfmlzx2yCldMOQLye6+ErryCf+KRJlenyFN/uA
+rzdrFys1vtA6aTgc/fTnutfY3zAMebdKSh5MIeSdG3bi39ZPN5ZvAr6F9WvZWGOh
+EeGPMFrU3BxtNeqJ5fC8akFapam5Pc7GzYqb1sYqSEDoM6uw5k10Nh68dLYOA0Tp
+YMLmqzwVnGY6unRtPZyNBM0mP1orOtfS/+rHQsRhYb5ydGG1C7yKnUdiet/ChDvq
+8dUVw+uianNCoZxmS3+zU2H05WNMyDBxPKDJCT3R/bTym8lzF4Yhv7ucfNUXCcU+
+IC4uX6tsq7zLGlAtd25ySZ6RTcul0wIDAQABo4GKMIGHMHcGA1UdIwRwMG6hYaRf
+MF0xCzAJBgNVBAYTAlVTMQswCQYDVQQIDAJDQTENMAsGA1UEBwwEQ2l0eTEMMAoG
+A1UECgwDT3JnMQ0wCwYDVQQLDARKYXZhMRUwEwYDVQQDDAxST09UX0NBX1NIQTGC
+CQDxO7f7KD9SCTAMBgNVHRMEBTADAQH/MA0GCSqGSIb3DQEBBQUAA4IBAQALvnvH
+UxSHNwJmN/VvODx1s3L2+Jx3TZrkXCM6Sl+qbpAj6bhI/W3hiLWipQowwH0zqG95
+QlKA+IdLKhUK/xSIlyESiRzTM7/6T15omsZpL6odMaqA9bDTcsn6zjtfFaZh4PHR
+q+dASMHUML0KEzcN6qw4sq8beDopU+6QcTsrpIsW6dqUWUQ9fzT7CtFr2z1mAaYP
+mLXMVzm5CfIBzOWJhn3ymrKtCD3aBfkkHjCYzJKpTErPo1Nuf17bqkOcrLG1gKt+
+o4lxN8JKwRadJtVwiYqOqMtAO7jw0jFUwh/8JF4pwV6GSB6DTkQw/41GR7YOnHe/
+ugiLveu3ykUK4wzs
+-----END CERTIFICATE-----
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/sun/security/ssl/CertPathRestrictions/certs/ROOT_CA_SHA256-PRIV.key	Tue Apr 18 22:25:33 2017 +0200
@@ -0,0 +1,26 @@
+MIIEvgIBADANBgkqhkiG9w0BAQEFAASCBKgwggSkAgEAAoIBAQC2DzrIXts3huIs
+dtX+ZbY6RR5/S4yXUs3jJXc4mbITLn7PO1QVBT528NZVOu6jUxXsPTpTg1jgresh
+6Pcv1LNj7bP30uPXhmyawgQVUgLTGyU0+JWLJrpU7cEOTK4f/j58A+UHL255fM7T
+B3EvIj2Ad1MAYwIvVZnAXPSFt72YGz15doYiewp8dTXcX4TsFisCbypFikWxpXIF
+qjVqbAUx8fYgQxfPWFw4HbVvo3Nu1LqypswAfsmHd2v5nMv8wkAcPG5dIYHACN9r
+kPLMoUNUcBLn6QdIUrhk7dldRlR0TWT+VtRLKVWlGkMk9rRK+RnskNSuPg8fjb/Y
+gM0m5p0JAgMBAAECggEAPVk8cbClJjzpkhopWiRkF5abBEItCgD5KAXD+uqvuw77
+5FEVsE+oEORvFSFasOaaiJTJRsMH/A4fIbojMZb3LEE5V9VUuZeumSevwI92LDUF
+gKgTnGRcfanwWCU2t8kwvRGC57zv+Tg5aZskZMGg/901tvemENVDjjLEoxqbZNmX
+WZnhB8XiPxl9K32K0l+qNW3HvKJ8lkaW0L6/4HWWU4rYwbc9TZpzHDOXhAICQB76
+fCw4hcy1K6KjfGjfE/6afqMa76KSxxeCvUYorZlm2gk1WcEafkg9Jwzz2SWtsa8W
+L+YzbTd1GE8Z9bDA88Dw3vgdC1Pt0ywX/fJ/GCDHUQKBgQDjNaW/enKYXGTsM5C1
+I94OgSmgnjnjPZIBY0u89iCAf07ueqrNaLJgOEkGpCrLEa4tC2qc57ge1DO2rxTa
+6RowUzqG3Oqdsq21QaQZAmjjDC5mXlYPRpWvWVjBRaIDKw9zAUg9qEy24e/pRjdP
+cugR30d1OaxExdgoAt8iOqZ67wKBgQDNIPqF/+npd1UAqgdC9lOxnPQly1zjz/zY
+jbeJeww9Ut9aCXj0+we4gKhD37d178y1H2QBod+IPpqQ/uZmbNmN5JP+MIk2kZKB
+4jquQLa5jEc+y57h8UrWJBY+Ls7xiu/cw3aCAk0JaZRSrH/KzWE91x3s7o2yV43d
+dMkRmTTHhwKBgQCHaq4C1WP/UvIDpSgWDe6HDoxU4nj16vheQ2Qcl0T/0OCmWg36
+pu/JUUKU5rtqlHsO9cLxCVo/ZZH8y5TOdCfbrX8wafKbUqcdZKX9EeaZi+ULtiXs
+rNEB1WqEpo/M+5kVnioENY6jYT2v9t14SK/wFvdr8pet1YzjK/L5X6NhmQKBgFK4
+0u7I9k61Ve0vpEAH0FaXIgo/yZUBYkj+VZ62pYfxbKsFmObKeSGZmMHObVC9RMNi
+BlV2LwvlmzWP5eA2U0GahWgDsMH10KxaTCnLZSTMgkq7mLYrNW/IG8Q14jScQAC6
+PodNYD3EexEgCWUCkA19O885oKDkGAzPtOpI63TvAoGBAJvbKiJSFJNd3CIQlrOM
+wNw+Sww+c2Qw4PZZvIJNzjWumjesfUsuAyySrO2nXPzzSOrh7dRW98suaFi1Mih6
+ZwBpIll5VQsd2dwEa6vp6RFGWFNKPvDILEVgcCEOmckKRWDo+fb5bx2VHj1v4kfG
+MHDqy8Y2ercsU0Z5mEN8bUD7
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/sun/security/ssl/CertPathRestrictions/certs/ROOT_CA_SHA256.cer	Tue Apr 18 22:25:33 2017 +0200
@@ -0,0 +1,80 @@
+Certificate:
+    Data:
+        Version: 3 (0x2)
+        Serial Number:
+            a3:52:9d:82:6f:dd:c6:1d
+    Signature Algorithm: sha256WithRSAEncryption
+        Issuer: C=US, ST=CA, L=City, O=Org, OU=Java, CN=ROOT_CA_SHA256
+        Validity
+            Not Before: Mar 30 04:51:01 2017 GMT
+            Not After : Mar 28 04:51:01 2027 GMT
+        Subject: C=US, ST=CA, L=City, O=Org, OU=Java, CN=ROOT_CA_SHA256
+        Subject Public Key Info:
+            Public Key Algorithm: rsaEncryption
+                Public-Key: (2048 bit)
+                Modulus:
+                    00:b6:0f:3a:c8:5e:db:37:86:e2:2c:76:d5:fe:65:
+                    b6:3a:45:1e:7f:4b:8c:97:52:cd:e3:25:77:38:99:
+                    b2:13:2e:7e:cf:3b:54:15:05:3e:76:f0:d6:55:3a:
+                    ee:a3:53:15:ec:3d:3a:53:83:58:e0:ad:eb:21:e8:
+                    f7:2f:d4:b3:63:ed:b3:f7:d2:e3:d7:86:6c:9a:c2:
+                    04:15:52:02:d3:1b:25:34:f8:95:8b:26:ba:54:ed:
+                    c1:0e:4c:ae:1f:fe:3e:7c:03:e5:07:2f:6e:79:7c:
+                    ce:d3:07:71:2f:22:3d:80:77:53:00:63:02:2f:55:
+                    99:c0:5c:f4:85:b7:bd:98:1b:3d:79:76:86:22:7b:
+                    0a:7c:75:35:dc:5f:84:ec:16:2b:02:6f:2a:45:8a:
+                    45:b1:a5:72:05:aa:35:6a:6c:05:31:f1:f6:20:43:
+                    17:cf:58:5c:38:1d:b5:6f:a3:73:6e:d4:ba:b2:a6:
+                    cc:00:7e:c9:87:77:6b:f9:9c:cb:fc:c2:40:1c:3c:
+                    6e:5d:21:81:c0:08:df:6b:90:f2:cc:a1:43:54:70:
+                    12:e7:e9:07:48:52:b8:64:ed:d9:5d:46:54:74:4d:
+                    64:fe:56:d4:4b:29:55:a5:1a:43:24:f6:b4:4a:f9:
+                    19:ec:90:d4:ae:3e:0f:1f:8d:bf:d8:80:cd:26:e6:
+                    9d:09
+                Exponent: 65537 (0x10001)
+        X509v3 extensions:
+            X509v3 Authority Key Identifier: 
+                DirName:/C=US/ST=CA/L=City/O=Org/OU=Java/CN=ROOT_CA_SHA256
+                serial:A3:52:9D:82:6F:DD:C6:1D
+
+            X509v3 Basic Constraints: 
+                CA:TRUE
+    Signature Algorithm: sha256WithRSAEncryption
+         6f:2f:a4:56:d5:58:6d:20:74:6b:66:b7:41:eb:c2:8c:56:2e:
+         1b:51:79:b0:07:a6:63:28:8b:20:40:b9:72:4b:f5:e0:6b:18:
+         39:5b:b4:ae:50:58:25:81:86:e3:19:ec:b1:dd:fb:5c:f5:d4:
+         a8:7d:a0:50:46:ac:1e:80:dc:cc:aa:0c:61:f8:a3:41:af:03:
+         35:a4:02:4f:23:c7:5c:36:26:90:fe:51:07:58:0f:e7:14:26:
+         34:c2:a7:bd:f2:34:33:cf:67:e4:2d:82:b6:e8:94:85:d6:8b:
+         01:6f:ba:3d:78:f6:db:3d:dc:ba:6e:6d:83:fa:ea:d0:60:ab:
+         1b:ad:9b:e2:ba:e3:e3:9f:26:5b:9a:c7:fb:9f:c1:7d:cc:0b:
+         cf:23:e0:ac:e1:e4:09:08:84:98:d4:6e:16:34:a5:5e:74:d5:
+         a8:61:e1:65:f7:9a:51:9f:f0:9f:86:65:ce:4f:b8:b6:64:7d:
+         86:62:21:ec:71:50:70:ca:6b:2e:74:12:51:b1:68:b0:4a:66:
+         19:60:e9:f8:b0:bf:6e:d8:ad:75:29:c3:31:13:73:01:3d:d5:
+         d4:5b:c2:60:bb:c4:c8:e6:29:cf:a3:49:65:8d:c2:1d:7d:c9:
+         75:33:9b:97:73:38:99:5c:7d:b3:9f:b0:be:0d:f4:6a:c6:19:
+         8d:98:a1:ca
+-----BEGIN CERTIFICATE-----
+MIIDzjCCAragAwIBAgIJAKNSnYJv3cYdMA0GCSqGSIb3DQEBCwUAMF8xCzAJBgNV
+BAYTAlVTMQswCQYDVQQIDAJDQTENMAsGA1UEBwwEQ2l0eTEMMAoGA1UECgwDT3Jn
+MQ0wCwYDVQQLDARKYXZhMRcwFQYDVQQDDA5ST09UX0NBX1NIQTI1NjAeFw0xNzAz
+MzAwNDUxMDFaFw0yNzAzMjgwNDUxMDFaMF8xCzAJBgNVBAYTAlVTMQswCQYDVQQI
+DAJDQTENMAsGA1UEBwwEQ2l0eTEMMAoGA1UECgwDT3JnMQ0wCwYDVQQLDARKYXZh
+MRcwFQYDVQQDDA5ST09UX0NBX1NIQTI1NjCCASIwDQYJKoZIhvcNAQEBBQADggEP
+ADCCAQoCggEBALYPOshe2zeG4ix21f5ltjpFHn9LjJdSzeMldziZshMufs87VBUF
+Pnbw1lU67qNTFew9OlODWOCt6yHo9y/Us2Pts/fS49eGbJrCBBVSAtMbJTT4lYsm
+ulTtwQ5Mrh/+PnwD5Qcvbnl8ztMHcS8iPYB3UwBjAi9VmcBc9IW3vZgbPXl2hiJ7
+Cnx1NdxfhOwWKwJvKkWKRbGlcgWqNWpsBTHx9iBDF89YXDgdtW+jc27UurKmzAB+
+yYd3a/mcy/zCQBw8bl0hgcAI32uQ8syhQ1RwEufpB0hSuGTt2V1GVHRNZP5W1Esp
+VaUaQyT2tEr5GeyQ1K4+Dx+Nv9iAzSbmnQkCAwEAAaOBjDCBiTB5BgNVHSMEcjBw
+oWOkYTBfMQswCQYDVQQGEwJVUzELMAkGA1UECAwCQ0ExDTALBgNVBAcMBENpdHkx
+DDAKBgNVBAoMA09yZzENMAsGA1UECwwESmF2YTEXMBUGA1UEAwwOUk9PVF9DQV9T
+SEEyNTaCCQCjUp2Cb93GHTAMBgNVHRMEBTADAQH/MA0GCSqGSIb3DQEBCwUAA4IB
+AQBvL6RW1VhtIHRrZrdB68KMVi4bUXmwB6ZjKIsgQLlyS/Xgaxg5W7SuUFglgYbj
+Geyx3ftc9dSofaBQRqwegNzMqgxh+KNBrwM1pAJPI8dcNiaQ/lEHWA/nFCY0wqe9
+8jQzz2fkLYK26JSF1osBb7o9ePbbPdy6bm2D+urQYKsbrZviuuPjnyZbmsf7n8F9
+zAvPI+Cs4eQJCISY1G4WNKVedNWoYeFl95pRn/CfhmXOT7i2ZH2GYiHscVBwymsu
+dBJRsWiwSmYZYOn4sL9u2K11KcMxE3MBPdXUW8Jgu8TI5inPo0lljcIdfcl1M5uX
+cziZXH2zn7C+DfRqxhmNmKHK
+-----END CERTIFICATE-----
--- a/jdk/test/sun/tools/jconsole/ResourceCheckTest.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/jdk/test/sun/tools/jconsole/ResourceCheckTest.java	Tue Apr 18 22:25:33 2017 +0200
@@ -34,7 +34,6 @@
 
 import java.lang.reflect.Field;
 import java.lang.reflect.Modifier;
-import java.lang.reflect.Module;
 import java.util.ArrayList;
 import java.util.Collections;
 import java.util.List;
--- a/jdk/test/sun/util/calendar/zi/tzdata/VERSION	Tue Apr 18 13:19:42 2017 -0400
+++ b/jdk/test/sun/util/calendar/zi/tzdata/VERSION	Tue Apr 18 22:25:33 2017 +0200
@@ -21,4 +21,4 @@
 # or visit www.oracle.com if you need additional information or have any
 # questions.
 #
-tzdata2017a
+tzdata2017b
--- a/jdk/test/sun/util/calendar/zi/tzdata/africa	Tue Apr 18 13:19:42 2017 -0400
+++ b/jdk/test/sun/util/calendar/zi/tzdata/africa	Tue Apr 18 22:25:33 2017 +0200
@@ -443,18 +443,25 @@
 # See Africa/Johannesburg.
 
 # Liberia
-# From Paul Eggert (2006-03-22):
-# In 1972 Liberia was the last country to switch
-# from a UTC offset that was not a multiple of 15 or 20 minutes.
-# Howse reports that it was in honor of their president's birthday.
-# Shank & Pottenger report the date as May 1, whereas Howse reports Jan;
-# go with Shanks & Pottenger.
-# For Liberia before 1972, Shanks & Pottenger report -0:44, whereas Howse and
-# Whitman each report -0:44:30; go with the more precise figure.
+#
+# From Paul Eggert (2017-03-02):
+#
+# The Nautical Almanac for the Year 1970, p 264, is the source for -0:44:30.
+#
+# In 1972 Liberia was the last country to switch from a UTC offset
+# that was not a multiple of 15 or 20 minutes.  The 1972 change was on
+# 1972-01-07, according to an entry dated 1972-01-04 on p 330 of:
+# Presidential Papers: First year of the administration of
+# President William R. Tolbert, Jr., July 23, 1971-July 31, 1972.
+# Monrovia: Executive Mansion.
+#
+# Use the abbreviation "MMT" before 1972, as the more-accurate numeric
+# abbreviation "-004430" would be one byte over the POSIX limit.
+#
 # Zone	NAME		GMTOFF	RULES	FORMAT	[UNTIL]
 Zone	Africa/Monrovia	-0:43:08 -	LMT	1882
 			-0:43:08 -	MMT	1919 Mar # Monrovia Mean Time
-			-0:44:30 -	-004430	1972 May
+			-0:44:30 -	MMT	1972 Jan 7 # approximately MMT
 			 0:00	-	GMT
 
 ###############################################################################
--- a/jdk/test/sun/util/calendar/zi/tzdata/iso3166.tab	Tue Apr 18 13:19:42 2017 -0400
+++ b/jdk/test/sun/util/calendar/zi/tzdata/iso3166.tab	Tue Apr 18 22:25:33 2017 +0200
@@ -32,8 +32,8 @@
 # All text uses UTF-8 encoding.  The columns of the table are as follows:
 #
 # 1.  ISO 3166-1 alpha-2 country code, current as of
-#     ISO 3166-1 Newsletter VI-16 (2013-07-11).  See: Updates on ISO 3166
-#   http://www.iso.org/iso/home/standards/country_codes/updates_on_iso_3166.htm
+#     ISO 3166-1 N905 (2016-11-15).  See: Updates on ISO 3166-1
+#     http://isotc.iso.org/livelink/livelink/Open/16944257
 # 2.  The usual English name for the coded region,
 #     chosen so that alphabetic sorting of subsets produces helpful lists.
 #     This is not the same as the English name in the ISO 3166 tables.
--- a/jdk/test/sun/util/calendar/zi/tzdata/northamerica	Tue Apr 18 13:19:42 2017 -0400
+++ b/jdk/test/sun/util/calendar/zi/tzdata/northamerica	Tue Apr 18 22:25:33 2017 +0200
@@ -3162,6 +3162,12 @@
 # http://www.vantbefinfo.com/changement-dheure-pas-pour-haiti/
 # http://news.anmwe.com/haiti-lheure-nationale-ne-sera-ni-avancee-ni-reculee-cette-annee/
 
+# From Steffen Thorsen (2017-03-12):
+# We have received 4 mails from different people telling that Haiti
+# has started DST again today, and this source seems to confirm that,
+# I have not been able to find a more authoritative source:
+# https://www.haitilibre.com/en/news-20319-haiti-notices-time-change-in-haiti.html
+
 # Rule	NAME	FROM	TO	TYPE	IN	ON	AT	SAVE	LETTER/S
 Rule	Haiti	1983	only	-	May	8	0:00	1:00	D
 Rule	Haiti	1984	1987	-	Apr	lastSun	0:00	1:00	D
@@ -3174,6 +3180,8 @@
 Rule	Haiti	2005	2006	-	Oct	lastSun	0:00	0	S
 Rule	Haiti	2012	2015	-	Mar	Sun>=8	2:00	1:00	D
 Rule	Haiti	2012	2015	-	Nov	Sun>=1	2:00	0	S
+Rule	Haiti	2017	max	-	Mar	Sun>=8	2:00	1:00	D
+Rule	Haiti	2017	max	-	Nov	Sun>=1	2:00	0	S
 # Zone	NAME		GMTOFF	RULES	FORMAT	[UNTIL]
 Zone America/Port-au-Prince -4:49:20 -	LMT	1890
 			-4:49	-	PPMT	1917 Jan 24 12:00 # P-a-P MT
--- a/jdk/test/tools/jar/modularJar/Basic.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/jdk/test/tools/jar/modularJar/Basic.java	Tue Apr 18 22:25:33 2017 +0200
@@ -869,8 +869,8 @@
         return new Object[][] {
             // JAR file name                module-name[@version]
             { "foo.jar",                    "foo" },
+            { "foo1.jar",                   "foo1" },
             { "foo4j.jar",                  "foo4j", },
-            { "foo1.2.3.jar",               "foo" },
             { "foo-1.2.3.4.jar",            "foo@1.2.3.4" },
             { "foo-bar.jar",                "foo.bar" },
             { "foo-1.2-SNAPSHOT.jar",       "foo@1.2-SNAPSHOT" },
--- a/jdk/test/tools/jar/modularJar/src/bar/jdk/test/bar/Bar.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/jdk/test/tools/jar/modularJar/src/bar/jdk/test/bar/Bar.java	Tue Apr 18 22:25:33 2017 +0200
@@ -28,7 +28,6 @@
 import java.lang.module.ModuleDescriptor.Provides;
 import java.lang.module.ModuleReference;
 import java.lang.module.ResolvedModule;
-import java.lang.reflect.Module;
 import java.util.Optional;
 import java.util.StringJoiner;
 import java.util.HashSet;
--- a/jdk/test/tools/jlink/JLink2Test.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/jdk/test/tools/jlink/JLink2Test.java	Tue Apr 18 22:25:33 2017 +0200
@@ -39,7 +39,6 @@
 import java.io.File;
 import java.io.FileOutputStream;
 import java.io.IOException;
-import java.lang.reflect.Layer;
 import java.nio.file.Files;
 import java.nio.file.Path;
 import java.util.ArrayList;
@@ -88,7 +87,7 @@
 
     private static void testOptions() throws Exception {
         List<Plugin> builtInPlugins = new ArrayList<>();
-        builtInPlugins.addAll(PluginRepository.getPlugins(Layer.boot()));
+        builtInPlugins.addAll(PluginRepository.getPlugins(ModuleLayer.boot()));
         if(builtInPlugins.isEmpty()) {
             throw new Exception("No builtin plugins");
         }
--- a/jdk/test/tools/jlink/JLinkTest.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/jdk/test/tools/jlink/JLinkTest.java	Tue Apr 18 22:25:33 2017 +0200
@@ -25,7 +25,6 @@
 import java.io.PrintWriter;
 import java.io.StringWriter;
 import java.lang.module.ModuleDescriptor;
-import java.lang.reflect.Layer;
 import java.nio.file.Files;
 import java.nio.file.Path;
 import java.nio.file.Paths;
@@ -88,7 +87,7 @@
         {
             // number of built-in plugins
             List<Plugin> builtInPlugins = new ArrayList<>();
-            builtInPlugins.addAll(PluginRepository.getPlugins(Layer.boot()));
+            builtInPlugins.addAll(PluginRepository.getPlugins(ModuleLayer.boot()));
             totalPlugins = builtInPlugins.size();
             // actual num. of plugins loaded from jdk.jlink module
             int actualJLinkPlugins = 0;
--- a/jdk/test/tools/jlink/basic/src/test/jdk/test/Test.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/jdk/test/tools/jlink/basic/src/test/jdk/test/Test.java	Tue Apr 18 22:25:33 2017 +0200
@@ -23,9 +23,6 @@
 
 package jdk.test;
 
-import java.lang.reflect.Module;
-import java.lang.reflect.Layer;
-
 public class Test {
     public static void main(String[] args) {
         System.out.println(Test.class + " ...");
@@ -36,7 +33,7 @@
         ClassLoader scl = ClassLoader.getSystemClassLoader();
         ClassLoader cl1 = Test.class.getClassLoader();
         Module testModule = Test.class.getModule();
-        ClassLoader cl2 = Layer.boot().findLoader(testModule.getName());
+        ClassLoader cl2 = ModuleLayer.boot().findLoader(testModule.getName());
 
         if (cl1 != scl)
             throw new RuntimeException("Not loaded by system class loader");
--- a/jdk/test/tools/jlink/plugins/PluginsNegativeTest.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/jdk/test/tools/jlink/plugins/PluginsNegativeTest.java	Tue Apr 18 22:25:33 2017 +0200
@@ -30,7 +30,6 @@
  *          jdk.jlink/jdk.tools.jlink.plugin
  * @run main/othervm PluginsNegativeTest
  */
-import java.lang.reflect.Layer;
 import java.util.ArrayList;
 import java.util.Collections;
 import java.util.List;
@@ -63,7 +62,7 @@
 
     private void testDuplicateBuiltInProviders() {
         List<Plugin> javaPlugins = new ArrayList<>();
-        javaPlugins.addAll(PluginRepository.getPlugins(Layer.boot()));
+        javaPlugins.addAll(PluginRepository.getPlugins(ModuleLayer.boot()));
         for (Plugin javaPlugin : javaPlugins) {
             System.out.println("Registered plugin: " + javaPlugin.getName());
         }
@@ -72,7 +71,7 @@
             try {
                 PluginRepository.registerPlugin(new CustomPlugin(pluginName));
                 try {
-                    PluginRepository.getPlugin(pluginName, Layer.boot());
+                    PluginRepository.getPlugin(pluginName, ModuleLayer.boot());
                     throw new AssertionError("Exception is not thrown for duplicate plugin: " + pluginName);
                 } catch (Exception ignored) {
                 }
@@ -83,7 +82,7 @@
     }
 
     private void testUnknownProvider() {
-        if (PluginRepository.getPlugin("unknown", Layer.boot()) != null) {
+        if (PluginRepository.getPlugin("unknown", ModuleLayer.boot()) != null) {
             throw new AssertionError("Exception expected for unknown plugin name");
         }
     }
--- a/jdk/test/tools/jlink/plugins/SystemModuleDescriptors/UserModuleTest.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/jdk/test/tools/jlink/plugins/SystemModuleDescriptors/UserModuleTest.java	Tue Apr 18 22:25:33 2017 +0200
@@ -24,7 +24,6 @@
 import java.io.File;
 import java.io.IOException;
 import java.lang.module.ModuleDescriptor;
-import java.lang.reflect.Layer;
 import java.nio.file.Files;
 import java.nio.file.Path;
 import java.nio.file.Paths;
--- a/jdk/test/tools/jlink/plugins/SystemModuleDescriptors/src/m1/p1/Main.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/jdk/test/tools/jlink/plugins/SystemModuleDescriptors/src/m1/p1/Main.java	Tue Apr 18 22:25:33 2017 +0200
@@ -26,8 +26,6 @@
 import java.io.InputStream;
 import java.io.IOException;
 import java.lang.module.ModuleDescriptor;
-import java.lang.reflect.Layer;
-import java.lang.reflect.Module;
 import java.net.URI;
 import java.nio.file.FileSystem;
 import java.nio.file.FileSystems;
--- a/jdk/test/tools/jlink/plugins/SystemModuleDescriptors/src/m3/p3/Main.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/jdk/test/tools/jlink/plugins/SystemModuleDescriptors/src/m3/p3/Main.java	Tue Apr 18 22:25:33 2017 +0200
@@ -26,7 +26,6 @@
 import p4.Foo;
 import java.lang.module.ModuleDescriptor;
 import java.lang.reflect.Field;
-import java.lang.reflect.Module;
 
 import static java.lang.module.ModuleDescriptor.Exports.Modifier.*;
 
--- a/jdk/test/tools/jlink/plugins/SystemModuleDescriptors/src/m4/p4/Main.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/jdk/test/tools/jlink/plugins/SystemModuleDescriptors/src/m4/p4/Main.java	Tue Apr 18 22:25:33 2017 +0200
@@ -27,7 +27,6 @@
 import java.io.InputStream;
 import java.lang.module.ModuleDescriptor;
 import java.lang.module.ModuleFinder;
-import java.lang.reflect.Layer;
 import java.net.URI;
 import java.nio.file.FileSystem;
 import java.nio.file.FileSystems;
@@ -100,7 +99,7 @@
 
     private static void checkModule(String mn, String... packages) throws IOException {
         // verify ModuleDescriptor from the runtime module
-        ModuleDescriptor md = Layer.boot().findModule(mn).get()
+        ModuleDescriptor md = ModuleLayer.boot().findModule(mn).get()
                                    .getDescriptor();
         checkModuleDescriptor(md, packages);
 
--- a/jdk/test/tools/jlink/plugins/SystemModuleDescriptors/src/m5/p5/Main.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/jdk/test/tools/jlink/plugins/SystemModuleDescriptors/src/m5/p5/Main.java	Tue Apr 18 22:25:33 2017 +0200
@@ -23,7 +23,6 @@
 
 package p5;
 
-import java.lang.reflect.Layer;
 import p3.Foo;
 import p3.Lib;
 
@@ -32,7 +31,7 @@
  */
 public class Main {
     public static void main(String... args) {
-        boolean libPresent = Layer.boot().findModule("m3").isPresent();
+        boolean libPresent = ModuleLayer.boot().findModule("m3").isPresent();
         if (LibHelper.libClassFound != libPresent) {
             throw new RuntimeException("Expected module m3 not in the boot layer");
         }
--- a/jdk/test/tools/jlink/plugins/SystemModuleDescriptors/src/test/jdk/test/Main.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/jdk/test/tools/jlink/plugins/SystemModuleDescriptors/src/test/jdk/test/Main.java	Tue Apr 18 22:25:33 2017 +0200
@@ -24,8 +24,6 @@
 package jdk.test;
 
 import java.lang.module.ModuleDescriptor;
-import java.lang.reflect.Layer;
-import java.lang.reflect.Module;
 import java.net.URI;
 import java.nio.file.FileSystem;
 import java.nio.file.FileSystems;
@@ -65,7 +63,7 @@
         // check the module descriptor of a system module
         for (int i=0; i < modules.size(); i++) {
             String mn = modules.get(i);
-            Module module = Layer.boot().findModule(mn).orElseThrow(
+            Module module = ModuleLayer.boot().findModule(mn).orElseThrow(
                 () -> new RuntimeException(mn + " not found")
             );
 
--- a/jdk/test/tools/launcher/modules/dryrun/DryRunTest.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/jdk/test/tools/launcher/modules/dryrun/DryRunTest.java	Tue Apr 18 22:25:33 2017 +0200
@@ -167,22 +167,6 @@
         // test main method with and without --add-modules mm
         int exitValue = exec("--module-path", LIBS_DIR.toString(),
                              "-m", mid);
-        assertTrue(exitValue != 0);
-
-        exitValue = exec("--module-path", LIBS_DIR.toString(),
-                         "--add-modules", M_MODULE,
-                         "-m", mid);
-        assertTrue(exitValue == 0);
-
-        // test dry run with and without --add-modules m
-        // no resolution failure
-        exitValue = exec("--dry-run", "--module-path", LIBS_DIR.toString(),
-                         "-m", mid);
-        assertTrue(exitValue == 0);
-
-        exitValue = exec("--dry-run", "--module-path", LIBS_DIR.toString(),
-                         "--add-modules", M_MODULE,
-                         "-m", mid);
         assertTrue(exitValue == 0);
     }
 
--- a/jdk/test/tools/launcher/modules/listmods/ListModsTest.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/jdk/test/tools/launcher/modules/listmods/ListModsTest.java	Tue Apr 18 22:25:33 2017 +0200
@@ -115,7 +115,7 @@
                 .outputTo(System.out)
                 .errorTo(System.out);
         output.shouldNotContain("java.base");
-        output.shouldContain("java.rhubarb not observable");
+        output.shouldContain("java.rhubarb not found");
         assertTrue(output.getExitValue() == 0);
     }
 
--- a/jdk/test/tools/launcher/modules/patch/basic/src/test/jdk/test/Main.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/jdk/test/tools/launcher/modules/patch/basic/src/test/jdk/test/Main.java	Tue Apr 18 22:25:33 2017 +0200
@@ -28,8 +28,6 @@
 
 package jdk.test;
 
-import java.lang.reflect.Module;
-
 public class Main {
 
     public static void main(String[] args) throws Exception {
--- a/jdk/test/tools/launcher/modules/upgrademodulepath/src/test/jdk/test/Main.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/jdk/test/tools/launcher/modules/upgrademodulepath/src/test/jdk/test/Main.java	Tue Apr 18 22:25:33 2017 +0200
@@ -24,7 +24,6 @@
 package jdk.test;
 
 import java.lang.module.ModuleReference;
-import java.lang.reflect.Layer;
 import java.net.URI;
 
 import javax.enterprise.context.Scope;
@@ -53,7 +52,7 @@
 
         // javax.transaction should be found in boot layer.
         ModuleReference ref =
-                Layer.boot().configuration().findModule(TRANSACTION_MODULE).get().reference();
+                ModuleLayer.boot().configuration().findModule(TRANSACTION_MODULE).get().reference();
         // check uri of java.transaction found on the upgrade module path.
         URI uri = ref.location().get();
         System.out.println("uri: " + uri);
--- a/langtools/.hgtags	Tue Apr 18 13:19:42 2017 -0400
+++ b/langtools/.hgtags	Tue Apr 18 22:25:33 2017 +0200
@@ -408,3 +408,4 @@
 440c45c2e8cee78f6883fa6f2505a781505f323c jdk-9+162
 24582dd2649a155876de89273975ebe1adb5f18c jdk-9+163
 c7f3df19667b093538c6eecb73dcb3fb531706b4 jdk-9+164
+98108b7d4cb6078773e2d27ad8471dc25d4d6124 jdk-9+165
--- a/langtools/make/tools/crules/CodingRulesAnalyzerPlugin.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/langtools/make/tools/crules/CodingRulesAnalyzerPlugin.java	Tue Apr 18 22:25:33 2017 +0200
@@ -23,8 +23,6 @@
 
 package crules;
 
-import java.lang.reflect.Layer;
-import java.lang.reflect.Module;
 import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.List;
@@ -76,7 +74,7 @@
     private void addExports(String moduleName, String... packageNames) {
         for (String packageName : packageNames) {
             try {
-                Layer layer = Layer.boot();
+                ModuleLayer layer = ModuleLayer.boot();
                 Optional<Module> m = layer.findModule(moduleName);
                 if (!m.isPresent())
                     throw new Error("module not found: " + moduleName);
--- a/langtools/src/java.compiler/share/classes/javax/tools/ToolProvider.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/langtools/src/java.compiler/share/classes/javax/tools/ToolProvider.java	Tue Apr 18 22:25:33 2017 +0200
@@ -106,7 +106,7 @@
     static {
         Class<?> c = null;
         try {
-            c = Class.forName("java.lang.reflect.Module");
+            c = Class.forName("java.lang.Module");
         } catch (Throwable t) {
         }
         useLegacy = (c == null);
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Lint.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Lint.java	Tue Apr 18 22:25:33 2017 +0200
@@ -118,6 +118,7 @@
             if (source.compareTo(Source.JDK1_9) >= 0) {
                 values.add(LintCategory.DEP_ANN);
             }
+            values.add(LintCategory.REQUIRES_TRANSITIVE_AUTOMATIC);
             values.add(LintCategory.OPENS);
             values.add(LintCategory.MODULE);
             values.add(LintCategory.REMOVAL);
@@ -254,6 +255,16 @@
         REMOVAL("removal"),
 
         /**
+         * Warn about use of automatic modules in the requires clauses.
+         */
+        REQUIRES_AUTOMATIC("requires-automatic"),
+
+        /**
+         * Warn about automatic modules in requires transitive.
+         */
+        REQUIRES_TRANSITIVE_AUTOMATIC("requires-transitive-automatic"),
+
+        /**
          * Warn about Serializable classes that do not provide a serial version ID.
          */
         SERIAL("serial"),
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/ArgumentAttr.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/ArgumentAttr.java	Tue Apr 18 22:25:33 2017 +0200
@@ -105,7 +105,7 @@
     private Env<AttrContext> env;
 
     /** Result of method attribution. */
-    private Type result;
+    Type result;
 
     /** Cache for argument types; behavior is influences by the currrently selected cache policy. */
     Map<UniquePos, ArgumentType<?>> argumentTypeCache = new LinkedHashMap<>();
@@ -215,13 +215,8 @@
         processArg(that, () -> {
             T speculativeTree = (T)deferredAttr.attribSpeculative(that, env, attr.new MethodAttrInfo() {
                 @Override
-                protected void attr(JCTree tree, Env<AttrContext> env) {
-                    //avoid speculative attribution loops
-                    if (!new UniquePos(tree).equals(pos)) {
-                        super.attr(tree, env);
-                    } else {
-                        visitTree(tree);
-                    }
+                protected boolean needsArgumentAttr(JCTree tree) {
+                    return !new UniquePos(tree).equals(pos);
                 }
             });
             return argumentTypeFactory.apply(speculativeTree);
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Attr.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Attr.java	Tue Apr 18 22:25:33 2017 +0200
@@ -505,9 +505,12 @@
             this.checkMode = checkMode;
         }
 
-        protected void attr(JCTree tree, Env<AttrContext> env) {
-            tree.accept(Attr.this);
-        }
+        /**
+         * Should {@link Attr#attribTree} use the {@ArgumentAttr} visitor instead of this one?
+         * @param tree The tree to be type-checked.
+         * @return true if {@ArgumentAttr} should be used.
+         */
+        protected boolean needsArgumentAttr(JCTree tree) { return false; }
 
         protected Type check(final DiagnosticPosition pos, final Type found) {
             return chk.checkType(pos, found, pt, checkContext);
@@ -553,8 +556,8 @@
         }
 
         @Override
-        protected void attr(JCTree tree, Env<AttrContext> env) {
-            result = argumentAttr.attribArg(tree, env);
+        protected boolean needsArgumentAttr(JCTree tree) {
+            return true;
         }
 
         protected ResultInfo dup(Type newPt) {
@@ -644,7 +647,11 @@
         try {
             this.env = env;
             this.resultInfo = resultInfo;
-            resultInfo.attr(tree, env);
+            if (resultInfo.needsArgumentAttr(tree)) {
+                result = argumentAttr.attribArg(tree, env);
+            } else {
+                tree.accept(this);
+            }
             if (tree == breakTree &&
                     resultInfo.checkContext.deferredAttrContext().mode == AttrMode.CHECK) {
                 throw new BreakAttr(copyEnv(env));
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Check.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Check.java	Tue Apr 18 22:25:33 2017 +0200
@@ -2107,10 +2107,32 @@
         Name moduleName = tree.sym.name;
         Assert.checkNonNull(moduleName);
         if (lint.isEnabled(LintCategory.MODULE)) {
-            String moduleNameString = moduleName.toString();
-            int nameLength = moduleNameString.length();
-            if (nameLength > 0 && Character.isDigit(moduleNameString.charAt(nameLength - 1))) {
-                log.warning(Lint.LintCategory.MODULE, tree.qualId.pos(), Warnings.PoorChoiceForModuleName(moduleName));
+            JCExpression qualId = tree.qualId;
+            while (qualId != null) {
+                Name componentName;
+                DiagnosticPosition pos;
+                switch (qualId.getTag()) {
+                    case SELECT:
+                        JCFieldAccess selectNode = ((JCFieldAccess) qualId);
+                        componentName = selectNode.name;
+                        pos = selectNode.pos();
+                        qualId = selectNode.selected;
+                        break;
+                    case IDENT:
+                        componentName = ((JCIdent) qualId).name;
+                        pos = qualId.pos();
+                        qualId = null;
+                        break;
+                    default:
+                        throw new AssertionError("Unexpected qualified identifier: " + qualId.toString());
+                }
+                if (componentName != null) {
+                    String moduleNameComponentString = componentName.toString();
+                    int nameLength = moduleNameComponentString.length();
+                    if (nameLength > 0 && Character.isDigit(moduleNameComponentString.charAt(nameLength - 1))) {
+                        log.warning(Lint.LintCategory.MODULE, pos, Warnings.PoorChoiceForModuleName(componentName));
+                    }
+                }
             }
         }
     }
@@ -3886,4 +3908,16 @@
         }
     }
 
+    void checkModuleRequires(final DiagnosticPosition pos, final RequiresDirective rd) {
+        if ((rd.module.flags() & Flags.AUTOMATIC_MODULE) != 0) {
+            deferredLintHandler.report(() -> {
+                if (rd.isTransitive() && lint.isEnabled(LintCategory.REQUIRES_TRANSITIVE_AUTOMATIC)) {
+                    log.warning(pos, Warnings.RequiresTransitiveAutomatic);
+                } else if (lint.isEnabled(LintCategory.REQUIRES_AUTOMATIC)) {
+                    log.warning(pos, Warnings.RequiresAutomatic);
+                }
+            });
+        }
+    }
+
 }
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Modules.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Modules.java	Tue Apr 18 22:25:33 2017 +0200
@@ -1075,6 +1075,7 @@
         public void visitRequires(JCRequires tree) {
             if (tree.directive != null && allModules().contains(tree.directive.module)) {
                 chk.checkDeprecated(tree.moduleName.pos(), msym, tree.directive.module);
+                chk.checkModuleRequires(tree.moduleName.pos(), tree.directive);
                 msym.directives = msym.directives.prepend(tree.directive);
             }
         }
@@ -1231,7 +1232,7 @@
                     case ALL_SYSTEM:
                         modules = new HashSet<>(syms.getAllModules())
                                 .stream()
-                                .filter(systemModulePred.and(observablePred).and(noIncubatorPred));
+                                .filter(systemModulePred.and(observablePred));
                         break;
                     case ALL_MODULE_PATH:
                         modules = new HashSet<>(syms.getAllModules())
@@ -1256,6 +1257,15 @@
 
         result.add(syms.unnamedModule);
 
+        boolean hasAutomatic = result.stream().anyMatch(IS_AUTOMATIC);
+
+        if (hasAutomatic) {
+            syms.getAllModules()
+                .stream()
+                .filter(IS_AUTOMATIC)
+                .forEach(result::add);
+        }
+
         String incubatingModules = result.stream()
                 .filter(msym -> msym.resolutionFlags.contains(ModuleResolutionFlags.WARN_INCUBATING))
                 .map(msym -> msym.name.toString())
@@ -1273,6 +1283,9 @@
             rootModules.forEach(m -> m.version = version);
         }
     }
+    //where:
+        private static final Predicate<ModuleSymbol> IS_AUTOMATIC =
+                m -> (m.flags_field & Flags.AUTOMATIC_MODULE) != 0;
 
     public boolean isInModuleGraph(ModuleSymbol msym) {
         return allModules == null || allModules.contains(msym);
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/file/JavacFileManager.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/file/JavacFileManager.java	Tue Apr 18 22:25:33 2017 +0200
@@ -473,10 +473,14 @@
                     }
                 } else {
                     if (isValidFile(fname, fileKinds)) {
-                        RelativeFile file = new RelativeFile(subdirectory, fname);
-                        JavaFileObject fe = PathFileObject.forDirectoryPath(JavacFileManager.this,
-                                file.resolveAgainst(directory), userPath, file);
-                        resultList.append(fe);
+                        try {
+                            RelativeFile file = new RelativeFile(subdirectory, fname);
+                            JavaFileObject fe = PathFileObject.forDirectoryPath(JavacFileManager.this,
+                                    file.resolveAgainst(directory), userPath, file);
+                            resultList.append(fe);
+                        } catch (InvalidPathException e) {
+                            throw new IOException("error accessing directory " + directory + e);
+                        }
                     }
                 }
             }
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/file/Locations.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/file/Locations.java	Tue Apr 18 22:25:33 2017 +0200
@@ -1282,8 +1282,7 @@
                     }
 
                     // finally clean up the module name
-                    mn =  mn.replaceAll("(\\.|\\d)*$", "")    // remove trailing version
-                            .replaceAll("[^A-Za-z0-9]", ".")  // replace non-alphanumeric
+                    mn =  mn.replaceAll("[^A-Za-z0-9]", ".")  // replace non-alphanumeric
                             .replaceAll("(\\.)(\\1)+", ".")   // collapse repeating dots
                             .replaceAll("^\\.", "")           // drop leading dots
                             .replaceAll("\\.$", "");          // drop trailing dots
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/resources/compiler.properties	Tue Apr 18 13:19:42 2017 -0400
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/resources/compiler.properties	Tue Apr 18 22:25:33 2017 +0200
@@ -1537,7 +1537,7 @@
 
 # 0: name
 compiler.warn.poor.choice.for.module.name=\
-    module name {0} should avoid terminal digits
+    module name component {0} should avoid terminal digits
 
 # 0: string
 compiler.warn.incubating.modules=\
@@ -1664,6 +1664,12 @@
 compiler.warn.future.attr=\
     {0} attribute introduced in version {1}.{2} class files is ignored in version {3}.{4} class files
 
+compiler.warn.requires.automatic=\
+    requires directive for an automatic module
+
+compiler.warn.requires.transitive.automatic=\
+    requires transitive directive for an automatic module
+
 # Warnings related to annotation processing
 # 0: string
 compiler.warn.proc.package.does.not.exist=\
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/resources/javac.properties	Tue Apr 18 13:19:42 2017 -0400
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/resources/javac.properties	Tue Apr 18 22:25:33 2017 +0200
@@ -230,6 +230,12 @@
 javac.opt.Xlint.desc.removal=\
     Warn about use of API that has been marked for removal.
 
+javac.opt.Xlint.desc.requires-automatic=\
+    Warn about use of automatic modules in the requires clauses.
+
+javac.opt.Xlint.desc.requires-transitive-automatic=\
+    Warn about automatic modules in requires transitive.
+
 javac.opt.Xlint.desc.serial=\
     Warn about Serializable classes that do not provide a serial version ID. \n\
 \                             Also warn about access to non-public members from a serializable element.
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/util/JDK9Wrappers.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/util/JDK9Wrappers.java	Tue Apr 18 22:25:33 2017 +0200
@@ -183,7 +183,7 @@
     }
 
     /**
-     * Wrapper class for java.lang.reflect.Module. To materialize a handle use the static factory
+     * Wrapper class for java.lang.Module. To materialize a handle use the static factory
      * methods Module#getModule(Class<?>) or Module#getUnnamedModule(ClassLoader).
      */
     public static class Module {
@@ -236,9 +236,9 @@
         }
 
         // -----------------------------------------------------------------------------------------
-        // on java.lang.reflect.Module
+        // on java.lang.Module
         private static Method addExportsMethod = null;
-        // on java.lang.reflect.Module
+        // on java.lang.Module
         private static Method addUsesMethod = null;
         // on java.lang.Class
         private static Method getModuleMethod;
@@ -248,7 +248,7 @@
         private static void init() {
             if (addExportsMethod == null) {
                 try {
-                    Class<?> moduleClass = Class.forName("java.lang.reflect.Module", false, null);
+                    Class<?> moduleClass = Class.forName("java.lang.Module", false, null);
                     addUsesMethod = moduleClass.getDeclaredMethod("addUses", new Class<?>[] { Class.class });
                     addExportsMethod = moduleClass.getDeclaredMethod("addExports",
                                                         new Class<?>[] { String.class, moduleClass });
@@ -318,7 +318,7 @@
     }
 
     /**
-     * Wrapper class for java.lang.module.Layer.
+     * Wrapper class for java.lang.ModuleLayer.
      */
     public static final class Layer {
         private final Object theRealLayer;
@@ -372,7 +372,7 @@
         private static void init() {
             if (layerClass == null) {
                 try {
-                    layerClass = Class.forName("java.lang.reflect.Layer", false, null);
+                    layerClass = Class.forName("java.lang.ModuleLayer", false, null);
                     bootMethod = layerClass.getDeclaredMethod("boot");
                     defineModulesWithOneLoaderMethod = layerClass.getDeclaredMethod("defineModulesWithOneLoader",
                                 Configuration.getConfigurationClass(),
--- a/langtools/src/jdk.javadoc/share/classes/com/sun/tools/doclets/internal/toolkit/taglets/TagletManager.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/langtools/src/jdk.javadoc/share/classes/com/sun/tools/doclets/internal/toolkit/taglets/TagletManager.java	Tue Apr 18 22:25:33 2017 +0200
@@ -292,7 +292,7 @@
             Method getModuleMethod = Class.class.getDeclaredMethod("getModule");
             Object thisModule = getModuleMethod.invoke(getClass());
 
-            Class<?> moduleClass = Class.forName("java.lang.reflect.Module");
+            Class<?> moduleClass = Class.forName("java.lang.Module");
             Method addExportsMethod = moduleClass.getDeclaredMethod("addExports", String.class, moduleClass);
 
             Method getUnnamedModuleMethod = ClassLoader.class.getDeclaredMethod("getUnnamedModule");
--- a/langtools/src/jdk.javadoc/share/classes/com/sun/tools/javadoc/main/DocletInvoker.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/langtools/src/jdk.javadoc/share/classes/com/sun/tools/javadoc/main/DocletInvoker.java	Tue Apr 18 22:25:33 2017 +0200
@@ -379,7 +379,7 @@
             Method getModuleMethod = Class.class.getDeclaredMethod("getModule");
             Object thisModule = getModuleMethod.invoke(getClass());
 
-            Class<?> moduleClass = Class.forName("java.lang.reflect.Module");
+            Class<?> moduleClass = Class.forName("java.lang.Module");
             Method addExportsMethod = moduleClass.getDeclaredMethod("addExports", String.class, moduleClass);
 
             Method getUnnamedModuleMethod = ClassLoader.class.getDeclaredMethod("getUnnamedModule");
--- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ConstructorWriterImpl.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ConstructorWriterImpl.java	Tue Apr 18 22:25:33 2017 +0200
@@ -169,11 +169,7 @@
      */
     @Override
     public void setSummaryColumnStyleAndScope(HtmlTree thTree) {
-        if (foundNonPubConstructor) {
-            thTree.addStyle(HtmlStyle.colSecond);
-        } else {
-            thTree.addStyle(HtmlStyle.colFirst);
-        }
+        thTree.addStyle(HtmlStyle.colConstructorName);
         thTree.addAttr(HtmlAttr.SCOPE, "row");
     }
 
--- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/Contents.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/Contents.java	Tue Apr 18 22:25:33 2017 +0200
@@ -130,6 +130,7 @@
     public final Content nextPackageLabel;
     public final Content noFramesLabel;
     public final Content noScriptMessage;
+    public final Content openModuleLabel;
     public final Content overridesLabel;
     public final Content overviewLabel;
     public final Content packageHierarchies;
@@ -244,6 +245,7 @@
         nextPackageLabel = getNonBreakContent("doclet.Next_Package");
         noFramesLabel = getNonBreakContent("doclet.No_Frames");
         noScriptMessage = getContent("doclet.No_Script_Message");
+        openModuleLabel = getContent("doclet.Open_Module");
         overridesLabel = getContent("doclet.Overrides");
         overviewLabel = getContent("doclet.Overview");
         packageHierarchies = getContent("doclet.Package_Hierarchies");
--- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ModuleWriterImpl.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ModuleWriterImpl.java	Tue Apr 18 22:25:33 2017 +0200
@@ -98,19 +98,19 @@
             = new TreeMap<>(utils.makeModuleComparator());
 
     /**
-     * Map of additional modules and modifiers, transitive closure, required by this module.
+     * Map of indirect modules and modifiers, transitive closure, required by this module.
      */
-    private final Map<ModuleElement, Content> additionalModules
+    private final Map<ModuleElement, Content> indirectModules
             = new TreeMap<>(utils.makeModuleComparator());
 
     /**
-     * Map of packages exported by this module and the modules it's been exported to.
+     * Map of packages exported by this module and the modules it has been exported to.
      */
     private final Map<PackageElement, SortedSet<ModuleElement>> exportedPackages
             = new TreeMap<>(utils.makePackageComparator());
 
     /**
-     * Map of opened packages by this module and the modules it's been opened to.
+     * Map of opened packages by this module and the modules it has been opened to.
      */
     private final Map<PackageElement, SortedSet<ModuleElement>> openedPackages
             = new TreeMap<>(utils.makePackageComparator());
@@ -121,15 +121,15 @@
     private final SortedSet<PackageElement> concealedPackages = new TreeSet<>(utils.makePackageComparator());
 
     /**
-     * Map of additional modules (transitive closure) and its exported packages.
+     * Map of indirect modules (transitive closure) and their exported packages.
      */
-    private final Map<ModuleElement, SortedSet<PackageElement>> additionalPackages
+    private final Map<ModuleElement, SortedSet<PackageElement>> indirectPackages
             = new TreeMap<>(utils.makeModuleComparator());
 
     /**
-     * Map of additional modules (transitive closure) and its open packages.
+     * Map of indirect modules (transitive closure) and their open packages.
      */
-    private final Map<ModuleElement, SortedSet<PackageElement>> additionalOpenPackages
+    private final Map<ModuleElement, SortedSet<PackageElement>> indirectOpenPackages
             = new TreeMap<>(utils.makeModuleComparator());
 
     /**
@@ -212,8 +212,10 @@
         Content annotationContent = new HtmlTree(HtmlTag.P);
         addAnnotationInfo(mdle, annotationContent);
         div.addContent(annotationContent);
+        Content label = mdle.isOpen() && (configuration.docEnv.getModuleMode() == ModuleMode.ALL)
+                ? contents.openModuleLabel : contents.moduleLabel;
         Content tHeading = HtmlTree.HEADING(HtmlConstants.TITLE_HEADING, true,
-                HtmlStyle.title, contents.moduleLabel);
+                HtmlStyle.title, label);
         tHeading.addContent(Contents.SPACE);
         Content moduleHead = new RawHtml(heading);
         tHeading.addContent(moduleHead);
@@ -264,12 +266,12 @@
         CommentHelper ch = utils.getCommentHelper(mdle);
         // Get module dependencies using the module's transitive closure.
         Map<ModuleElement, String> dependentModules = utils.getDependentModules(mdle);
-        // Add all dependent modules to additional modules set. We will remove the modules,
-        // listed using the requires directive, from this set to come up with the table of additional
+        // Add all dependent modules to indirect modules set. We will remove the modules,
+        // listed using the requires directive, from this set to come up with the table of indirect
         // required modules.
         dependentModules.forEach((module, mod) -> {
             if (shouldDocument(module)) {
-                additionalModules.put(module, new StringContent(mod));
+                indirectModules.put(module, new StringContent(mod));
             }
         });
         (ElementFilter.requiresIn(mdle.getDirectives())).forEach((directive) -> {
@@ -278,11 +280,11 @@
                 if (moduleMode == ModuleMode.ALL || directive.isTransitive()) {
                     requires.put(m, new StringContent(utils.getModifiers(directive)));
             } else {
-                // For api mode, just keep the public requires in dependentModules for display of
-                    // additional packages in the "Packages" section.
+                    // For api mode, just keep the public requires in dependentModules for display of
+                    // indirect packages in the "Packages" section.
                     dependentModules.remove(m);
-            }
-                additionalModules.remove(m);
+                }
+                indirectModules.remove(m);
         }
         });
 
@@ -320,7 +322,7 @@
                     mdleList.addAll(targetMdles);
                 }
                 // Qualified opens should not be displayed in the api mode. So if mdleList is empty,
-                // it's opened to all modules and hence can be added.
+                // it is opened to all modules and hence can be added.
                 if (moduleMode == ModuleMode.ALL || mdleList.isEmpty()) {
                     openedPackages.put(p, mdleList);
                 }
@@ -331,7 +333,7 @@
         concealedPackages.removeAll(exportedPackages.keySet());
         concealedPackages.removeAll(openedPackages.keySet());
         // Get all the exported and opened packages, for the transitive closure of the module, to be displayed in
-        // the additional packages tables.
+        // the indirect packages tables.
         dependentModules.forEach((module, mod) -> {
             SortedSet<PackageElement> pkgList = new TreeSet<>(utils.makePackageComparator());
             (ElementFilter.exportsIn(module.getDirectives())).forEach((directive) -> {
@@ -343,7 +345,7 @@
             // If none of the transitive modules have exported packages to be displayed, we should not be
             // displaying the table and so it should not be added to the map.
             if (!pkgList.isEmpty()) {
-                additionalPackages.put(module, pkgList);
+                indirectPackages.put(module, pkgList);
             }
             SortedSet<PackageElement> openPkgList = new TreeSet<>(utils.makePackageComparator());
             (ElementFilter.opensIn(module.getDirectives())).forEach((directive) -> {
@@ -355,7 +357,7 @@
             // If none of the transitive modules have opened packages to be displayed, we should not be
             // displaying the table and so it should not be added to the map.
             if (!openPkgList.isEmpty()) {
-                additionalOpenPackages.put(module, openPkgList);
+                indirectOpenPackages.put(module, openPkgList);
             }
         });
         // Get all the services listed as uses directive.
@@ -471,31 +473,31 @@
      * {@inheritDoc}
      */
     public void addModulesSummary(Content summaryContentTree) {
-        if (display(requires) || display(additionalModules)) {
+        if (display(requires) || display(indirectModules)) {
             HtmlTree li = new HtmlTree(HtmlTag.LI);
             li.addStyle(HtmlStyle.blockList);
             addSummaryHeader(HtmlConstants.START_OF_MODULES_SUMMARY, SectionName.MODULES,
                     contents.navModules, li);
             if (display(requires)) {
-            String text = configuration.getText("doclet.Requires_Summary");
-            String tableSummary = configuration.getText("doclet.Member_Table_Summary",
-                    configuration.getText("doclet.Requires_Summary"),
-                    configuration.getText("doclet.modules"));
+                String text = configuration.getText("doclet.Requires_Summary");
+                String tableSummary = configuration.getText("doclet.Member_Table_Summary",
+                        configuration.getText("doclet.Requires_Summary"),
+                        configuration.getText("doclet.modules"));
                 Content table = getTableHeader(text, tableSummary, HtmlStyle.requiresSummary, requiresTableHeader);
                 Content tbody = new HtmlTree(HtmlTag.TBODY);
                 addModulesList(requires, tbody);
                 table.addContent(tbody);
                 li.addContent(table);
             }
-            // Display additional modules table in both "api" and "all" mode.
-            if (display(additionalModules)) {
-                String amrText = configuration.getText("doclet.Additional_Modules_Required_Summary");
+            // Display indirect modules table in both "api" and "all" mode.
+            if (display(indirectModules)) {
+                String amrText = configuration.getText("doclet.Indirect_Requires_Summary");
                 String amrTableSummary = configuration.getText("doclet.Member_Table_Summary",
-                        configuration.getText("doclet.Additional_Modules_Required_Summary"),
+                        configuration.getText("doclet.Indirect_Requires_Summary"),
                         configuration.getText("doclet.modules"));
                 Content amrTable = getTableHeader(amrText, amrTableSummary, HtmlStyle.requiresSummary, requiresTableHeader);
                 Content amrTbody = new HtmlTree(HtmlTag.TBODY);
-                addModulesList(additionalModules, amrTbody);
+                addModulesList(indirectModules, amrTbody);
                 amrTable.addContent(amrTbody);
                 li.addContent(amrTable);
             }
@@ -530,7 +532,7 @@
 
     public void addPackagesSummary(Content summaryContentTree) {
         if (display(exportedPackages) || display(openedPackages) || display(concealedPackages)
-                || display(additionalPackages) || display(additionalOpenPackages)) {
+                || display(indirectPackages) || display(indirectOpenPackages)) {
             HtmlTree li = new HtmlTree(HtmlTag.LI);
             li.addStyle(HtmlStyle.blockList);
             addSummaryHeader(HtmlConstants.START_OF_PACKAGES_SUMMARY, SectionName.PACKAGES,
@@ -541,29 +543,29 @@
             if (display(exportedPackages) || display(openedPackages) || display(concealedPackages)) {
                 addPackageSummary(tableSummary, li);
             }
-            if (display(additionalPackages)) {
-                String aepText = configuration.getText("doclet.Additional_Exported_Packages_Summary");
-                String aepTableSummary = configuration.getText("doclet.Additional_Packages_Table_Summary",
-                        configuration.getText("doclet.Additional_Exported_Packages_Summary"),
+            if (display(indirectPackages)) {
+                String aepText = configuration.getText("doclet.Indirect_Exports_Summary");
+                String aepTableSummary = configuration.getText("doclet.Indirect_Packages_Table_Summary",
+                        configuration.getText("doclet.Indirect_Exports_Summary"),
                         configuration.getText("doclet.modules"),
                         configuration.getText("doclet.packages"));
                 Content aepTable = getTableHeader(aepText, aepTableSummary, HtmlStyle.packagesSummary,
-                        additionalPackagesTableHeader);
+                        indirectPackagesTableHeader);
                 Content aepTbody = new HtmlTree(HtmlTag.TBODY);
-                addAdditionalPackages(aepTbody, additionalPackages);
+                addIndirectPackages(aepTbody, indirectPackages);
                 aepTable.addContent(aepTbody);
                 li.addContent(aepTable);
             }
-            if (display(additionalOpenPackages)) {
-                String aopText = configuration.getText("doclet.Additional_Opened_Packages_Summary");
-                String aopTableSummary = configuration.getText("doclet.Additional_Packages_Table_Summary",
-                        configuration.getText("doclet.Additional_Opened_Packages_Summary"),
+            if (display(indirectOpenPackages)) {
+                String aopText = configuration.getText("doclet.Indirect_Opens_Summary");
+                String aopTableSummary = configuration.getText("doclet.Indirect_Packages_Table_Summary",
+                        configuration.getText("doclet.Indirect_Opens_Summary"),
                         configuration.getText("doclet.modules"),
                         configuration.getText("doclet.packages"));
                 Content aopTable = getTableHeader(aopText, aopTableSummary, HtmlStyle.packagesSummary,
-                        additionalPackagesTableHeader);
+                        indirectPackagesTableHeader);
                 Content aopTbody = new HtmlTree(HtmlTag.TBODY);
-                addAdditionalPackages(aopTbody, additionalOpenPackages);
+                addIndirectPackages(aopTbody, indirectOpenPackages);
                 aopTable.addContent(aopTbody);
                 li.addContent(aopTable);
             }
@@ -734,14 +736,14 @@
     }
 
     /**
-     * Add the additional packages for the module being documented.
+     * Add the indirect packages for the module being documented.
      *
      * @param tbody the content tree to which the table will be added
-     * @param ap additional packages to be added
+     * @param ip indirect packages to be added
      */
-    public void addAdditionalPackages(Content tbody, Map<ModuleElement, SortedSet<PackageElement>> ap) {
+    public void addIndirectPackages(Content tbody, Map<ModuleElement, SortedSet<PackageElement>> ip) {
         boolean altColor = true;
-        for (Map.Entry<ModuleElement, SortedSet<PackageElement>> entry : ap.entrySet()) {
+        for (Map.Entry<ModuleElement, SortedSet<PackageElement>> entry : ip.entrySet()) {
             ModuleElement m = entry.getKey();
             SortedSet<PackageElement> pkgList = entry.getValue();
             Content moduleLinkContent = getModuleLink(m, new StringContent(m.getQualifiedName()));
@@ -773,6 +775,19 @@
                     contents.navServices, li);
             String text;
             String tableSummary;
+            if (display(provides)) {
+                text = configuration.getText("doclet.Provides_Summary");
+                tableSummary = configuration.getText("doclet.Member_Table_Summary",
+                        configuration.getText("doclet.Provides_Summary"),
+                        configuration.getText("doclet.types"));
+                Content table = getTableHeader(text, tableSummary, HtmlStyle.providesSummary, providesTableHeader);
+                Content tbody = new HtmlTree(HtmlTag.TBODY);
+                addProvidesList(tbody);
+                if (!tbody.isEmpty()) {
+                    table.addContent(tbody);
+                    li.addContent(table);
+                }
+            }
             if (display(uses)) {
                 text = configuration.getText("doclet.Uses_Summary");
                 tableSummary = configuration.getText("doclet.Member_Table_Summary",
@@ -784,19 +799,6 @@
                 if (!tbody.isEmpty()) {
                     table.addContent(tbody);
                     li.addContent(table);
-            }
-            }
-            if (display(provides)) {
-                text = configuration.getText("doclet.Provides_Summary");
-                tableSummary = configuration.getText("doclet.Member_Table_Summary",
-                        configuration.getText("doclet.Provides_Summary"),
-                        configuration.getText("doclet.types"));
-                Content table = getTableHeader(text, tableSummary, HtmlStyle.providesSummary, providesTableHeader);
-                Content tbody = new HtmlTree(HtmlTag.TBODY);
-                addProvidesList(tbody);
-                if (!tbody.isEmpty()) {
-                    table.addContent(tbody);
-                    li.addContent(table);
                 }
             }
             HtmlTree ul = HtmlTree.UL(HtmlStyle.blockList, li);
@@ -975,12 +977,12 @@
                 ? getHyperLink(SectionName.MODULE_DESCRIPTION, contents.navModuleDescription)
                 : contents.navModuleDescription);
         addNavGap(liNav);
-        liNav.addContent((display(requires) || display(additionalModules))
+        liNav.addContent((display(requires) || display(indirectModules))
                 ? getHyperLink(SectionName.MODULES, contents.navModules)
                 : contents.navModules);
         addNavGap(liNav);
         liNav.addContent((display(exportedPackages) || display(openedPackages) || display(concealedPackages)
-                || display(additionalPackages) || display(additionalOpenPackages))
+                || display(indirectPackages) || display(indirectOpenPackages))
                 ? getHyperLink(SectionName.PACKAGES, contents.navPackages)
                 : contents.navPackages);
         addNavGap(liNav);
--- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/TagletWriterImpl.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/TagletWriterImpl.java	Tue Apr 18 22:25:33 2017 +0200
@@ -106,7 +106,7 @@
         String desc = ch.getText(itt.getDescription());
 
         String anchorName = htmlWriter.getName(tagText);
-        Content result = HtmlTree.A_ID(anchorName, new StringContent(tagText));
+        Content result = HtmlTree.A_ID(HtmlStyle.searchTagResult, anchorName, new StringContent(tagText));
         if (configuration.createindex && !tagText.isEmpty()) {
             SearchIndexItem si = new SearchIndexItem();
             si.setLabel(tagText);
--- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/markup/HtmlStyle.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/markup/HtmlStyle.java	Tue Apr 18 22:25:33 2017 +0200
@@ -46,6 +46,7 @@
     bottomNav,
     circle,
     classUseContainer,
+    colConstructorName,
     colFirst,
     colLast,
     colSecond,
@@ -98,6 +99,7 @@
     rightIframe,
     rowColor,
     searchTagLink,
+    searchTagResult,
     seeLabel,
     serializedFormContainer,
     simpleTagLabel,
--- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/markup/HtmlTree.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/markup/HtmlTree.java	Tue Apr 18 22:25:33 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2010, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -265,6 +265,21 @@
     }
 
     /**
+     * Generates an HTML anchor tag with a style class, id attribute and a body.
+     *
+     * @param styleClass stylesheet class for the tag
+     * @param id id for the anchor tag
+     * @param body body for the anchor tag
+     * @return an HtmlTree object
+     */
+    public static HtmlTree A_ID(HtmlStyle styleClass, String id, Content body) {
+        HtmlTree htmltree = A_ID(id, body);
+        if (styleClass != null)
+            htmltree.addStyle(styleClass);
+        return htmltree;
+    }
+
+    /**
      * Generates a CAPTION tag with some content.
      *
      * @param body content for the tag
--- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/markup/HtmlWriter.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/markup/HtmlWriter.java	Tue Apr 18 22:25:33 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -36,7 +36,6 @@
 import jdk.javadoc.internal.doclets.toolkit.util.DocFileIOException;
 import jdk.javadoc.internal.doclets.toolkit.util.DocPath;
 import jdk.javadoc.internal.doclets.toolkit.util.DocletConstants;
-import jdk.javadoc.internal.doclets.toolkit.util.ModulePackageTypes;
 import jdk.javadoc.internal.doclets.toolkit.util.TableTabTypes;
 
 
@@ -88,7 +87,7 @@
     /**
      * Header for tables displaying modules and exported packages.
      */
-    protected final List<String> additionalPackagesTableHeader;
+    protected final List<String> indirectPackagesTableHeader;
 
     /**
      * Header for tables displaying types and description.
@@ -136,18 +135,18 @@
         packageTableHeader.add(resources.getText("doclet.Package"));
         packageTableHeader.add(resources.getText("doclet.Description"));
         requiresTableHeader = new ArrayList<>();
-        requiresTableHeader.add(resources.getText("doclet.Modifier"));
+            requiresTableHeader.add(resources.getText("doclet.Modifier"));
         requiresTableHeader.add(resources.getText("doclet.Module"));
         requiresTableHeader.add(resources.getText("doclet.Description"));
         exportedPackagesTableHeader = new ArrayList<>();
         exportedPackagesTableHeader.add(resources.getText("doclet.Package"));
         if (configuration.docEnv.getModuleMode() == ModuleMode.ALL) {
-        exportedPackagesTableHeader.add(resources.getText("doclet.Module"));
+            exportedPackagesTableHeader.add(resources.getText("doclet.Module"));
         }
         exportedPackagesTableHeader.add(resources.getText("doclet.Description"));
-        additionalPackagesTableHeader = new ArrayList<>();
-        additionalPackagesTableHeader.add(resources.getText("doclet.Module"));
-        additionalPackagesTableHeader.add(resources.getText("doclet.Packages"));
+        indirectPackagesTableHeader = new ArrayList<>();
+        indirectPackagesTableHeader.add(resources.getText("doclet.From"));
+        indirectPackagesTableHeader.add(resources.getText("doclet.Packages"));
         usesTableHeader = new ArrayList<>();
         usesTableHeader.add(resources.getText("doclet.Type"));
         usesTableHeader.add(resources.getText("doclet.Description"));
--- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/resources/standard.properties	Tue Apr 18 13:19:42 2017 -0400
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/resources/standard.properties	Tue Apr 18 22:25:33 2017 +0200
@@ -6,6 +6,7 @@
 doclet.Element=Element
 doclet.Package=Package
 doclet.Module=Module
+doclet.Open_Module=Open Module
 doclet.All_Packages=All Packages
 doclet.All_Modules=All Modules
 doclet.None=None
--- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/resources/doclet.xml	Tue Apr 18 13:19:42 2017 -0400
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/resources/doclet.xml	Tue Apr 18 22:25:33 2017 +0200
@@ -1,7 +1,7 @@
 <?xml version='1.0' encoding='utf-8'?>
 
 <!--
- Copyright (c) 2003, 2015, Oracle and/or its affiliates. All rights reserved.
+ Copyright (c) 2003, 2017, Oracle and/or its affiliates. All rights reserved.
  DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 
  This code is free software; you can redistribute it and/or modify it
@@ -33,8 +33,8 @@
             <ModuleDescription/>
             <ModuleTags/>
             <Summary>
+                <PackagesSummary/>
                 <ModulesSummary/>
-                <PackagesSummary/>
                 <ServicesSummary/>
             </Summary>
         </Content>
--- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/resources/doclets.properties	Tue Apr 18 13:19:42 2017 -0400
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/resources/doclets.properties	Tue Apr 18 22:25:33 2017 +0200
@@ -86,12 +86,13 @@
 doclet.javafx_tag_misuse=Tags @propertyGetter, @propertySetter and @propertyDescription can only be used in JavaFX properties getters and setters.
 doclet.Package_Summary=Package Summary
 doclet.Requires_Summary=Requires
-doclet.Additional_Modules_Required_Summary=Additional Modules Required
-doclet.Additional_Exported_Packages_Summary=Additional Exported Packages
-doclet.Additional_Opened_Packages_Summary=Additional Opened Packages
-doclet.Exported_Packages_Summary=Exported Packages
-doclet.Opened_Packages_Summary=Opened Packages
-doclet.Concealed_Packages_Summary=Concealed Packages
+doclet.Indirect_Requires_Summary=Indirect Requires
+doclet.Indirect_Exports_Summary=Indirect Exports
+doclet.Indirect_Opens_Summary=Indirect Opens
+doclet.Exported_Packages_Summary=Exports
+doclet.Opened_Packages_Summary=Opens
+doclet.Concealed_Packages_Summary=Concealed
+doclet.From=From
 doclet.Packages_Summary=Packages
 doclet.Uses_Summary=Uses
 doclet.Provides_Summary=Provides
@@ -160,7 +161,7 @@
 doclet.Method_Detail=Method Detail
 doclet.Constructor_Detail=Constructor Detail
 doclet.Deprecated=Deprecated.
-doclet.DeprecatedForRemoval=Deprecated, for removal: This API element is subject to removal in a future version. 
+doclet.DeprecatedForRemoval=Deprecated, for removal: This API element is subject to removal in a future version.
 doclet.Hidden=Hidden
 doclet.Groupname_already_used=In -group option, groupname already used: {0}
 doclet.value_tag_invalid_reference={0} (referenced by @value tag) is an unknown reference.
@@ -171,7 +172,7 @@
 doclet.Use_Table_Summary=Use table, listing {0}, and an explanation
 doclet.Constants_Table_Summary={0} table, listing constant fields, and values
 doclet.Member_Table_Summary={0} table, listing {1}, and an explanation
-doclet.Additional_Packages_Table_Summary={0} table, listing {1}, and {2}
+doclet.Indirect_Packages_Table_Summary={0} table, listing {1}, and {2}
 doclet.fields=fields
 doclet.Fields=Fields
 doclet.properties=properties
--- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/resources/stylesheet.css	Tue Apr 18 13:19:42 2017 -0400
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/resources/stylesheet.css	Tue Apr 18 22:25:33 2017 +0200
@@ -42,15 +42,14 @@
     text-decoration:none;
     color:#353833;
 }
-a[name]:before, a[name]:target {
+a[name]:before, a[name]:target, a[id]:before, a[id]:target {
     content:"";
-    display:block;
-    height:120px;
-    margin:-120px 0 0;
-}
-a[id]:before, a[id]:target {
+    display:inline-block;
+    position:relative;
     padding-top:129px;
     margin-top:-129px;
+}
+.searchTagResult:before, .searchTagResult:target {
     color:red;
 }
 pre {
@@ -540,14 +539,14 @@
     text-align:left;
     padding:0px 0px 12px 10px;
 }
-th.colFirst, th.colSecond, th.colLast, .useSummary th, .constantsSummary th, .packagesSummary th,
+th.colFirst, th.colSecond, th.colLast, th.colConstructorName, .useSummary th, .constantsSummary th, .packagesSummary th,
 td.colFirst, td.colSecond, td.colLast, .useSummary td, .constantsSummary td {
     vertical-align:top;
     padding-right:0px;
     padding-top:8px;
     padding-bottom:3px;
 }
-th.colFirst, th.colSecond, th.colLast, .constantsSummary th, .packagesSummary th {
+th.colFirst, th.colSecond, th.colLast, th.colConstructorName, .constantsSummary th, .packagesSummary th {
     background:#dee3e9;
     text-align:left;
     padding:8px 3px 3px 7px;
@@ -556,7 +555,7 @@
     white-space:nowrap;
     font-size:13px;
 }
-td.colSecond, th.colSecond, td.colLast, th.colLast {
+td.colSecond, th.colSecond, td.colLast, th.colConstructorName, th.colLast {
     font-size:13px;
 }
 .constantsSummary th, .packagesSummary th {
@@ -573,8 +572,8 @@
 .usesSummary td.colFirst, .usesSummary th.colFirst,
 .providesSummary td.colFirst, .providesSummary th.colFirst,
 .memberSummary td.colFirst, .memberSummary th.colFirst,
-.memberSummary td.colSecond, .memberSummary th.colSecond,
-.typeSummary td.colFirst{
+.memberSummary td.colSecond, .memberSummary th.colSecond, .memberSummary th.colConstructorName,
+.typeSummary td.colFirst {
     vertical-align:top;
 }
 .packagesSummary th.colLast, .packagesSummary td.colLast {
@@ -584,6 +583,8 @@
 td.colSecond a:link, td.colSecond a:active, td.colSecond a:visited, td.colSecond a:hover,
 th.colFirst a:link, th.colFirst a:active, th.colFirst a:visited, th.colFirst a:hover,
 th.colSecond a:link, th.colSecond a:active, th.colSecond a:visited, th.colSecond a:hover,
+th.colConstructorName a:link, th.colConstructorName a:active, th.colConstructorName a:visited,
+th.colConstructorName a:hover,
 td.colLast a:link, td.colLast a:active, td.colLast a:visited, td.colLast a:hover,
 .constantValuesContainer td a:link, .constantValuesContainer td a:active,
 .constantValuesContainer td a:visited, .constantValuesContainer td a:hover {
--- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/util/JavaScriptScanner.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/util/JavaScriptScanner.java	Tue Apr 18 22:25:33 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2016, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -95,7 +95,7 @@
             case "datasrc":  case "for":  case "href":  case "longdesc":  case "profile":
             case "src":  case "usemap":
                 List<? extends DocTree> value = tree.getValue();
-                if (!value.isEmpty() && value.get(0).getKind() == Kind.TEXT) {
+                if (value != null && !value.isEmpty() && value.get(0).getKind() == Kind.TEXT) {
                     String v = value.get(0).toString().trim().toLowerCase(Locale.ENGLISH);
                     if (v.startsWith("javascript:")) {
                         f.accept(getCurrentPath());
--- a/langtools/src/jdk.jshell/share/classes/jdk/internal/jshell/tool/JShellTool.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/langtools/src/jdk.jshell/share/classes/jdk/internal/jshell/tool/JShellTool.java	Tue Apr 18 22:25:33 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -1440,7 +1440,7 @@
                                 : c.command) + " ")
                         .toArray(String[]::new))
                         .completionSuggestions(code, cursor, anchor);
-            } else if (code.startsWith("/se")) {
+            } else if (code.startsWith("/se") || code.startsWith("se")) {
                 result = new FixedCompletionProvider(SET_SUBCOMMANDS)
                         .completionSuggestions(code.substring(pastSpace), cursor - pastSpace, anchor);
             } else {
--- a/langtools/src/jdk.jshell/share/classes/jdk/internal/jshell/tool/resources/l10n.properties	Tue Apr 18 13:19:42 2017 -0400
+++ b/langtools/src/jdk.jshell/share/classes/jdk/internal/jshell/tool/resources/l10n.properties	Tue Apr 18 22:25:33 2017 +0200
@@ -1,5 +1,5 @@
 #
-# Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2016, 2017, Oracle and/or its affiliates. All rights reserved.
 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 #
 # This code is free software; you can redistribute it and/or modify it
@@ -500,11 +500,11 @@
 Shift-<tab> v\n\t\t\
         After a complete expression, hold down <shift> while pressing <tab>,\n\t\t\
         then release and press "v", the expression will be converted to\n\t\t\
-        a variable declaration whose type is based on the type of the expression.\n\t\t\
+        a variable declaration whose type is based on the type of the expression.\n\n\
 Shift-<tab> i\n\t\t\
         After an unresolvable identifier, hold down <shift> while pressing <tab>,\n\t\t\
         then release and press "i", and jshell will propose possible imports\n\t\t\
-        which will resolve the identifier based on the content of the specified classpath.\n\t\t\
+        which will resolve the identifier based on the content of the specified classpath.
 
 help.context.summary = the evaluation context options for /env /reload and /reset
 help.context =\
@@ -928,5 +928,5 @@
 /set format silent display ''    \n
 
 jshell.fix.wrong.shortcut =\
-Invalid <fix> character.  Use "i" for auto-import or "v" for variable creation.  For more information see:\n\
+Unexpected character after Shift-Tab.  Use "i" for auto-import or "v" for variable creation.  For more information see:\n\
    /help shortcuts
--- a/langtools/test/TEST.ROOT	Tue Apr 18 13:19:42 2017 -0400
+++ b/langtools/test/TEST.ROOT	Tue Apr 18 22:25:33 2017 +0200
@@ -14,8 +14,8 @@
 # Group definitions
 groups=TEST.groups
 
-# Tests using jtreg 4.2 b05 features
-requiredVersion=4.2 b05
+# Tests using jtreg 4.2 b07 features
+requiredVersion=4.2 b07
 
 # Use new module options
 useNewOptions=true
--- a/langtools/test/com/sun/javadoc/testCustomTag/taglets/CustomTag.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/langtools/test/com/sun/javadoc/testCustomTag/taglets/CustomTag.java	Tue Apr 18 22:25:33 2017 +0200
@@ -23,8 +23,6 @@
 
 package taglets;
 
-import java.lang.reflect.Layer;
-import java.lang.reflect.Module;
 import java.util.*;
 
 import com.sun.javadoc.*;
--- a/langtools/test/com/sun/javadoc/testNestedInlineTag/testtaglets/BoldTaglet.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/langtools/test/com/sun/javadoc/testNestedInlineTag/testtaglets/BoldTaglet.java	Tue Apr 18 22:25:33 2017 +0200
@@ -23,8 +23,6 @@
 
 package testtaglets;
 
-import java.lang.reflect.Layer;
-import java.lang.reflect.Module;
 import java.util.*;
 
 import com.sun.javadoc.*;
--- a/langtools/test/com/sun/javadoc/testNestedInlineTag/testtaglets/GreenTaglet.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/langtools/test/com/sun/javadoc/testNestedInlineTag/testtaglets/GreenTaglet.java	Tue Apr 18 22:25:33 2017 +0200
@@ -23,8 +23,6 @@
 
 package testtaglets;
 
-import java.lang.reflect.Layer;
-import java.lang.reflect.Module;
 import java.util.*;
 
 import com.sun.javadoc.*;
--- a/langtools/test/com/sun/javadoc/testNestedInlineTag/testtaglets/UnderlineTaglet.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/langtools/test/com/sun/javadoc/testNestedInlineTag/testtaglets/UnderlineTaglet.java	Tue Apr 18 22:25:33 2017 +0200
@@ -23,8 +23,6 @@
 
 package testtaglets;
 
-import java.lang.reflect.Layer;
-import java.lang.reflect.Module;
 import java.util.*;
 
 import com.sun.javadoc.*;
--- a/langtools/test/com/sun/javadoc/testTaglets/taglets/Foo.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/langtools/test/com/sun/javadoc/testTaglets/taglets/Foo.java	Tue Apr 18 22:25:33 2017 +0200
@@ -23,8 +23,6 @@
 
 package taglets;
 
-import java.lang.reflect.Layer;
-import java.lang.reflect.Module;
 import java.util.*;
 
 import com.sun.javadoc.*;
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/jdk/javadoc/doclet/testBadHtml/TestBadHtml.java	Tue Apr 18 22:25:33 2017 +0200
@@ -0,0 +1,52 @@
+/*
+ * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 8176901
+ * @summary The doclet should cope with bad HTML form
+ * @library ../lib
+ * @modules jdk.javadoc/jdk.javadoc.internal.tool
+ * @build JavadocTester
+ * @run main TestBadHtml
+ */
+
+public class TestBadHtml extends JavadocTester {
+
+    public static void main(String... args) throws Exception {
+        TestBadHtml tester = new TestBadHtml();
+        tester.runTests();
+    }
+
+    @Test
+    void testNegative() {
+        javadoc("-d", "out1",
+                "-sourcepath", testSrc,
+                "pkg1");
+
+        checkExit(Exit.ERROR);
+
+        checkOutput(Output.STDERR, false, "NullPointerException");
+        checkOutput(Output.OUT, false, "NullPointerException");
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/jdk/javadoc/doclet/testBadHtml/pkg1/A.java	Tue Apr 18 22:25:33 2017 +0200
@@ -0,0 +1,42 @@
+/*
+ * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package pkg1;
+
+/**
+ * The first sentence.
+ * <parameters the word action is crucial here object>
+ * <parameters the word cite is crucial here object>
+ * <parameters the word classid is crucial here object>
+ * <parameters the word codebase is crucial here object>
+ * <parameters the word data is crucial here object>
+ * <parameters the word datasrc is crucial here object>
+ * <parameters the word for is crucial here object>
+ * <parameters the word href is crucial here object>
+ * <parameters the word longdesc is crucial here object>
+ * <parameters the word profile is crucial here object>
+ * <parameters the word src is crucial here object>
+ * <parameters the word usemap is crucial here object>
+ */
+
+public class A {}
--- a/langtools/test/jdk/javadoc/doclet/testDeprecatedDocs/TestDeprecatedDocs.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/langtools/test/jdk/javadoc/doclet/testDeprecatedDocs/TestDeprecatedDocs.java	Tue Apr 18 22:25:33 2017 +0200
@@ -23,7 +23,7 @@
 
 /*
  * @test
- * @bug      4927552 8026567 8071982 8162674 8175200
+ * @bug      4927552 8026567 8071982 8162674 8175200 8175218
  * @summary  <DESC>
  * @author   jamieh
  * @library  ../lib
@@ -81,16 +81,16 @@
                 + "extends java.lang.Object</pre>",
                 "<pre>@Deprecated(forRemoval=true)\n"
                 + "public&nbsp;int field</pre>\n"
-                + "<div class=\"block\"><span class=\"deprecatedLabel\">Deprecated, for removal: This API element is subject to removal in a future version. </span>&nbsp;</div>",
+                + "<div class=\"block\"><span class=\"deprecatedLabel\">Deprecated, for removal: This API element is subject to removal in a future version.</span>&nbsp;</div>",
                 "<pre>@Deprecated(forRemoval=true)\n"
                 + "public&nbsp;DeprecatedClassByAnnotation&#8203;()</pre>\n"
-                + "<div class=\"block\"><span class=\"deprecatedLabel\">Deprecated, for removal: This API element is subject to removal in a future version. </span>&nbsp;</div>",
+                + "<div class=\"block\"><span class=\"deprecatedLabel\">Deprecated, for removal: This API element is subject to removal in a future version.</span>&nbsp;</div>",
                 "<pre>@Deprecated\n"
                 + "public&nbsp;void&nbsp;method&#8203;()</pre>\n"
                 + "<div class=\"block\"><span class=\"deprecatedLabel\">Deprecated.</span>&nbsp;</div>");
 
         checkOutput("pkg/TestAnnotationType.html", true,
-                "<div class=\"block\"><span class=\"deprecatedLabel\">Deprecated, for removal: This API element is subject to removal in a future version. </span>&nbsp;\n"
+                "<div class=\"block\"><span class=\"deprecatedLabel\">Deprecated, for removal: This API element is subject to removal in a future version.</span>&nbsp;\n"
                 + "<div class=\"block\"><span class=\"deprecationComment\">annotation_test1 passes.</span></div>\n"
                 + "</div>\n"
                 + "<br>\n"
@@ -100,16 +100,16 @@
                 "<pre>@Deprecated(forRemoval=true)\n"
                 + "static final&nbsp;int&nbsp;field</pre>\n"
                 + "<div class=\"block\"><span class=\"deprecatedLabel\">Deprecated, for removal: This "
-                + "API element is subject to removal in a future version. </span>&nbsp;<span class=\"deprecationComment\">annotation_test4 passes.</span></div>",
+                + "API element is subject to removal in a future version.</span>&nbsp;<span class=\"deprecationComment\">annotation_test4 passes.</span></div>",
                 "<pre>@Deprecated(forRemoval=true)\n"
                 + "int&nbsp;required</pre>\n"
-                + "<div class=\"block\"><span class=\"deprecatedLabel\">Deprecated, for removal: This API element is subject to removal in a future version. </span>&nbsp;"
+                + "<div class=\"block\"><span class=\"deprecatedLabel\">Deprecated, for removal: This API element is subject to removal in a future version.</span>&nbsp;"
                 + "<span class=\"deprecationComment\">annotation_test3 passes.</span></div>",
                 "<pre>java.lang.String&nbsp;optional</pre>\n"
                 + "<div class=\"block\"><span class=\"deprecatedLabel\">Deprecated.</span>&nbsp;<span class=\"deprecationComment\">annotation_test2 passes.</span></div>");
 
         checkOutput("pkg/TestClass.html", true,
-                "<div class=\"block\"><span class=\"deprecatedLabel\">Deprecated, for removal: This API element is subject to removal in a future version. </span>&nbsp;\n"
+                "<div class=\"block\"><span class=\"deprecatedLabel\">Deprecated, for removal: This API element is subject to removal in a future version.</span>&nbsp;\n"
                 + "<div class=\"block\"><span class=\"deprecationComment\">class_test1 passes.</span></div>\n"
                 + "</div>\n"
                 + "<br>\n"
@@ -118,11 +118,11 @@
                 + "extends java.lang.Object</pre>",
                 "<pre>@Deprecated(forRemoval=true)\n"
                 + "public&nbsp;TestClass&#8203;()</pre>\n"
-                + "<div class=\"block\"><span class=\"deprecatedLabel\">Deprecated, for removal: This API element is subject to removal in a future version. </span>&nbsp;"
+                + "<div class=\"block\"><span class=\"deprecatedLabel\">Deprecated, for removal: This API element is subject to removal in a future version.</span>&nbsp;"
                 + "<span class=\"deprecationComment\">class_test3 passes.</span></div>");
 
         checkOutput("pkg/TestEnum.html", true,
-                "<div class=\"block\"><span class=\"deprecatedLabel\">Deprecated, for removal: This API element is subject to removal in a future version. </span>&nbsp;\n"
+                "<div class=\"block\"><span class=\"deprecatedLabel\">Deprecated, for removal: This API element is subject to removal in a future version.</span>&nbsp;\n"
                 + "<div class=\"block\"><span class=\"deprecationComment\">enum_test1 passes.</span></div>\n"
                 + "</div>\n"
                 + "<br>\n"
@@ -131,11 +131,11 @@
                 + "extends java.lang.Enum&lt;<a href=\"../pkg/TestEnum.html\" title=\"enum in pkg\">TestEnum</a>&gt;</pre>",
                 "<pre>@Deprecated(forRemoval=true)\n"
                 + "public static final&nbsp;<a href=\"../pkg/TestEnum.html\" title=\"enum in pkg\">TestEnum</a> FOR_REMOVAL</pre>\n"
-                + "<div class=\"block\"><span class=\"deprecatedLabel\">Deprecated, for removal: This API element is subject to removal in a future version. </span>&nbsp;"
+                + "<div class=\"block\"><span class=\"deprecatedLabel\">Deprecated, for removal: This API element is subject to removal in a future version.</span>&nbsp;"
                 + "<span class=\"deprecationComment\">enum_test3 passes.</span></div>");
 
         checkOutput("pkg/TestError.html", true,
-                "<div class=\"block\"><span class=\"deprecatedLabel\">Deprecated, for removal: This API element is subject to removal in a future version. </span>&nbsp;\n"
+                "<div class=\"block\"><span class=\"deprecatedLabel\">Deprecated, for removal: This API element is subject to removal in a future version.</span>&nbsp;\n"
                 + "<div class=\"block\"><span class=\"deprecationComment\">error_test1 passes.</span></div>\n"
                 + "</div>\n"
                 + "<br>\n"
@@ -144,7 +144,7 @@
                 + "extends java.lang.Error</pre>");
 
         checkOutput("pkg/TestException.html", true,
-                "<div class=\"block\"><span class=\"deprecatedLabel\">Deprecated, for removal: This API element is subject to removal in a future version. </span>&nbsp;\n"
+                "<div class=\"block\"><span class=\"deprecatedLabel\">Deprecated, for removal: This API element is subject to removal in a future version.</span>&nbsp;\n"
                 + "<div class=\"block\"><span class=\"deprecationComment\">exception_test1 passes.</span></div>\n"
                 + "</div>\n"
                 + "<br>\n"
@@ -153,7 +153,7 @@
                 + "extends java.lang.Exception</pre>");
 
         checkOutput("pkg/TestInterface.html", true,
-                "<div class=\"block\"><span class=\"deprecatedLabel\">Deprecated, for removal: This API element is subject to removal in a future version. </span>&nbsp;\n"
+                "<div class=\"block\"><span class=\"deprecatedLabel\">Deprecated, for removal: This API element is subject to removal in a future version.</span>&nbsp;\n"
                 + "<div class=\"block\"><span class=\"deprecationComment\">interface_test1 passes.</span></div>\n"
                 + "</div>\n"
                 + "<br>\n"
--- a/langtools/test/jdk/javadoc/doclet/testMemberSummary/TestMemberSummary.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/langtools/test/jdk/javadoc/doclet/testMemberSummary/TestMemberSummary.java	Tue Apr 18 22:25:33 2017 +0200
@@ -23,7 +23,7 @@
 
 /*
  * @test
- * @bug      4951228 6290760 8025633 8026567 8081854 8162363 8175200
+ * @bug      4951228 6290760 8025633 8026567 8081854 8162363 8175200 8177417
  * @summary  Test the case where the overriden method returns a different
  *           type than the method in the child class.  Make sure the
  *           documentation is inherited but the return type isn't.
@@ -43,7 +43,7 @@
 
     @Test
     void test() {
-        javadoc("-d", "out",
+        javadoc("-d", "out", "-private",
                 "-sourcepath", testSrc,
                 "pkg","pkg2");
         checkExit(Exit.OK);
@@ -55,7 +55,15 @@
                 + "returnTypeTest</a></span>&#8203;()</code>",
                 // Check return type in member detail.
                 "<pre>public&nbsp;<a href=\"../pkg/PublicChild.html\" title=\"class in pkg\">"
-                + "PublicChild</a>&nbsp;returnTypeTest&#8203;()</pre>");
+                + "PublicChild</a>&nbsp;returnTypeTest&#8203;()</pre>",
+                "<th class=\"colConstructorName\" scope=\"row\"><code><span class=\"memberNameLink\">"
+                + "<a href=\"../pkg/PublicChild.html#PublicChild--\">PublicChild</a></span>&#8203;()</code></th>");
+
+        checkOutput("pkg/PrivateParent.html", true,
+                "<td class=\"colFirst\"><code>private </code></td>\n"
+                + "<th class=\"colConstructorName\" scope=\"row\"><code><span class=\"memberNameLink\">"
+                + "<a href=\"../pkg/PrivateParent.html#PrivateParent-int-\">PrivateParent</a></span>&#8203;(int&nbsp;i)</code>"
+                + "</th>");
 
         // Legacy anchor dimensions (6290760)
         checkOutput("pkg2/A.html", true,
--- a/langtools/test/jdk/javadoc/doclet/testMemberSummary/pkg/PrivateParent.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/langtools/test/jdk/javadoc/doclet/testMemberSummary/pkg/PrivateParent.java	Tue Apr 18 22:25:33 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -24,6 +24,12 @@
 package pkg;
 
 class PrivateParent {
+    /**
+     * Test private constructor.
+     * @param i a test parameter.
+     */
+    private PrivateParent(int i) {
+    }
 
     /**
      * Test to make sure the member summary inherits documentation
--- a/langtools/test/jdk/javadoc/doclet/testModules/TestModules.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/langtools/test/jdk/javadoc/doclet/testModules/TestModules.java	Tue Apr 18 22:25:33 2017 +0200
@@ -24,7 +24,7 @@
 /*
  * @test
  * @bug 8154119 8154262 8156077 8157987 8154261 8154817 8135291 8155995 8162363
- *      8168766 8168688 8162674 8160196 8175799 8174974 8176778
+ *      8168766 8168688 8162674 8160196 8175799 8174974 8176778 8177562 8175218
  * @summary Test modules support in javadoc.
  * @author bpatel
  * @library ../lib
@@ -277,14 +277,14 @@
                 + "<!--   -->\n"
                 + "</a>\n"
                 + "<div class=\"block\">This is a test description for the moduleA module. Search "
-                + "phrase <a id=\"searchphrase\">search phrase</a>.</div>");
+                + "phrase <a id=\"searchphrase\" class=\"searchTagResult\">search phrase</a>.</div>");
         checkOutput("moduleB-summary.html", found,
                 "<!-- ============ MODULE DESCRIPTION =========== -->\n"
                 + "<a name=\"module.description\">\n"
                 + "<!--   -->\n"
                 + "</a>\n"
                 + "<div class=\"block\">This is a test description for the moduleB module. Search "
-                + "word <a id=\"search_word\">search_word</a> with no description.</div>");
+                + "word <a id=\"search_word\" class=\"searchTagResult\">search_word</a> with no description.</div>");
         checkOutput("overview-summary.html", found,
                 "</script>\n"
                 + "<div class=\"contentContainer\">\n"
@@ -311,7 +311,7 @@
                 + "<li class=\"blockList\">\n"
                 + "<ul class=\"blockList\">\n"
                 + "<li class=\"blockList\">\n"
-                + "<!-- ============ MODULES SUMMARY =========== -->");
+                + "<!-- ============ PACKAGES SUMMARY =========== -->");
         checkOutput("moduleB-summary.html", found,
                 "<div class=\"contentContainer\">\n"
                 + "<ul class=\"blockList\">\n"
@@ -325,7 +325,7 @@
         checkOutput("moduleA-summary.html", found,
                 "<section role=\"region\">\n"
                 + "<div class=\"deprecatedContent\"><span class=\"deprecatedLabel\">Deprecated, for removal:"
-                + " This API element is subject to removal in a future version. </span>\n"
+                + " This API element is subject to removal in a future version.</span>\n"
                 + "<div class=\"block\"><span class=\"deprecationComment\">This module is deprecated.</span></div>\n"
                 + "</div>\n"
                 + "<!-- ============ MODULE DESCRIPTION =========== -->\n"
@@ -333,7 +333,7 @@
                 + "<!--   -->\n"
                 + "</a>\n"
                 + "<div class=\"block\">This is a test description for the moduleA module. Search "
-                + "phrase <a id=\"searchphrase\">search phrase</a>.</div>");
+                + "phrase <a id=\"searchphrase\" class=\"searchTagResult\">search phrase</a>.</div>");
         checkOutput("moduleB-summary.html", found,
                 "<section role=\"region\">\n"
                 + "<!-- ============ MODULE DESCRIPTION =========== -->\n"
@@ -341,7 +341,7 @@
                 + "<!--   -->\n"
                 + "</a>\n"
                 + "<div class=\"block\">This is a test description for the moduleB module. Search "
-                + "word <a id=\"search_word\">search_word</a> with no description.</div>");
+                + "word <a id=\"search_word\" class=\"searchTagResult\">search_word</a> with no description.</div>");
         checkOutput("overview-summary.html", found,
                 "</nav>\n"
                 + "</header>\n"
@@ -372,7 +372,7 @@
                 + "<li class=\"blockList\">\n"
                 + "<ul class=\"blockList\">\n"
                 + "<li class=\"blockList\">\n"
-                + "<!-- ============ MODULES SUMMARY =========== -->");
+                + "<!-- ============ PACKAGES SUMMARY =========== -->");
         checkOutput("moduleB-summary.html", found,
                 "<div class=\"contentContainer\">\n"
                 + "<ul class=\"blockList\">\n"
@@ -595,7 +595,7 @@
                 + "<th class=\"colFirst\" scope=\"row\"><a href=\"testpkg2mdlB/TestInterface2InModuleB.html\" title=\"interface in testpkg2mdlB\">TestInterface2InModuleB</a></th>\n"
                 + "<td class=\"colLast\">&nbsp;</td>\n"
                 + "</tr>",
-                "<caption><span>Opened Packages</span><span class=\"tabEnd\">&nbsp;</span></caption>\n"
+                "<caption><span>Opens</span><span class=\"tabEnd\">&nbsp;</span></caption>\n"
                 + "<tr>\n"
                 + "<th class=\"colFirst\" scope=\"col\">Package</th>\n"
                 + "<th class=\"colLast\" scope=\"col\">Description</th>\n"
@@ -618,7 +618,7 @@
                 + "<h1 title=\"Module\" class=\"title\">Module&nbsp;moduleT</h1>\n"
                 + "</div>",
                 "<div class=\"block\">This is a test description for the moduleT module. "
-                + "Search phrase <a id=\"searchphrase\">search phrase</a>. "
+                + "Search phrase <a id=\"searchphrase\" class=\"searchTagResult\">search phrase</a>. "
                 + "Make sure there are no exported packages.</div>",
                 "<tbody>\n"
                 + "<tr class=\"altColor\">\n"
@@ -730,17 +730,12 @@
         checkOutput("moduleA-summary.html", true,
                 "<li><a href=\"#module.description\">Description</a>&nbsp;|&nbsp;<a href=\"#modules.summary\">"
                 + "Modules</a>&nbsp;|&nbsp;<a href=\"#packages.summary\">Packages</a>&nbsp;|&nbsp;Services</li>",
-                "<td class=\"colFirst\">transitive</td>\n"
-                + "<th class=\"colSecond\" scope=\"row\"><a href=\"moduleB-summary.html\">moduleB</a></th>\n"
-                + "<td class=\"colLast\">\n"
-                + "<div class=\"block\">This is a test description for the moduleB module.</div>\n"
-                + "</td>",
-                "<table class=\"packagesSummary\" summary=\"Additional Exported Packages table, listing modules, and packages\">\n"
-                + "<caption><span>Additional Exported Packages</span><span class=\"tabEnd\">&nbsp;</span></caption>",
-                "<table class=\"packagesSummary\" summary=\"Additional Opened Packages table, listing modules, and packages\">\n"
-                + "<caption><span>Additional Opened Packages</span><span class=\"tabEnd\">&nbsp;</span></caption>\n"
+                "<table class=\"packagesSummary\" summary=\"Indirect Exports table, listing modules, and packages\">\n"
+                + "<caption><span>Indirect Exports</span><span class=\"tabEnd\">&nbsp;</span></caption>",
+                "<table class=\"packagesSummary\" summary=\"Indirect Opens table, listing modules, and packages\">\n"
+                + "<caption><span>Indirect Opens</span><span class=\"tabEnd\">&nbsp;</span></caption>\n"
                 + "<tr>\n"
-                + "<th class=\"colFirst\" scope=\"col\">Module</th>\n"
+                + "<th class=\"colFirst\" scope=\"col\">From</th>\n"
                 + "<th class=\"colLast\" scope=\"col\">Packages</th>\n"
                 + "</tr>\n",
                 "<th class=\"colFirst\" scope=\"row\"><a href=\"moduleB-summary.html\">moduleB</a></th>\n"
@@ -751,15 +746,15 @@
         checkOutput("moduletags-summary.html", true,
                 "<li><a href=\"#module.description\">Description</a>&nbsp;|&nbsp;<a href=\"#modules.summary\">Modules"
                 + "</a>&nbsp;|&nbsp;<a href=\"#packages.summary\">Packages</a>&nbsp;|&nbsp;Services</li>",
-                "<table class=\"requiresSummary\" summary=\"Additional Modules Required table, listing modules, and an explanation\">\n"
-                + "<caption><span>Additional Modules Required</span><span class=\"tabEnd\">&nbsp;</span></caption>",
+                "<table class=\"requiresSummary\" summary=\"Indirect Requires table, listing modules, and an explanation\">\n"
+                + "<caption><span>Indirect Requires</span><span class=\"tabEnd\">&nbsp;</span></caption>",
                 "<td class=\"colFirst\">transitive</td>\n"
                 + "<th class=\"colSecond\" scope=\"row\"><a href=\"moduleB-summary.html\">moduleB</a></th>\n"
                 + "<td class=\"colLast\">\n"
                 + "<div class=\"block\">This is a test description for the moduleB module.</div>\n"
                 + "</td>",
-                "<table class=\"packagesSummary\" summary=\"Additional Exported Packages table, listing modules, and packages\">\n"
-                + "<caption><span>Additional Exported Packages</span><span class=\"tabEnd\">&nbsp;</span></caption>",
+                "<table class=\"packagesSummary\" summary=\"Indirect Exports table, listing modules, and packages\">\n"
+                + "<caption><span>Indirect Exports</span><span class=\"tabEnd\">&nbsp;</span></caption>",
                 "<td class=\"colFirst\">transitive static</td>\n"
                 + "<th class=\"colSecond\" scope=\"row\"><a href=\"moduleA-summary.html\">moduleA</a></th>\n"
                 + "<td class=\"colLast\">\n"
@@ -771,16 +766,16 @@
                 + "<th class=\"colFirst\" scope=\"col\">Modifier</th>\n"
                 + "<th class=\"colSecond\" scope=\"col\">Module</th>\n"
                 + "<th class=\"colLast\" scope=\"col\">Description</th>",
-                "<table class=\"requiresSummary\" summary=\"Additional Modules Required table, listing modules, and an explanation\">\n"
-                + "<caption><span>Additional Modules Required</span><span class=\"tabEnd\">&nbsp;</span></caption>\n"
+                "<table class=\"requiresSummary\" summary=\"Indirect Requires table, listing modules, and an explanation\">\n"
+                + "<caption><span>Indirect Requires</span><span class=\"tabEnd\">&nbsp;</span></caption>\n"
                 + "<tr>\n"
                 + "<th class=\"colFirst\" scope=\"col\">Modifier</th>\n"
                 + "<th class=\"colSecond\" scope=\"col\">Module</th>\n"
                 + "<th class=\"colLast\" scope=\"col\">Description</th>",
-                "<table class=\"packagesSummary\" summary=\"Additional Opened Packages table, listing modules, and packages\">\n"
-                + "<caption><span>Additional Opened Packages</span><span class=\"tabEnd\">&nbsp;</span></caption>\n"
+                "<table class=\"packagesSummary\" summary=\"Indirect Opens table, listing modules, and packages\">\n"
+                + "<caption><span>Indirect Opens</span><span class=\"tabEnd\">&nbsp;</span></caption>\n"
                 + "<tr>\n"
-                + "<th class=\"colFirst\" scope=\"col\">Module</th>\n"
+                + "<th class=\"colFirst\" scope=\"col\">From</th>\n"
                 + "<th class=\"colLast\" scope=\"col\">Packages</th>\n"
                 + "</tr>\n",
                 "<th class=\"colFirst\" scope=\"row\"><a href=\"moduleB-summary.html\">moduleB</a></th>\n"
@@ -797,7 +792,7 @@
                 "<th class=\"colFirst\" scope=\"row\"><a href=\"testpkgmdlB/package-summary.html\">testpkgmdlB</a></th>\n"
                 + "<td class=\"colLast\">&nbsp;</td>",
                 "<table class=\"packagesSummary\" summary=\"Packages table, listing packages, and an explanation\">\n"
-                + "<caption><span>Opened Packages</span><span class=\"tabEnd\">&nbsp;</span></caption>\n"
+                + "<caption><span>Opens</span><span class=\"tabEnd\">&nbsp;</span></caption>\n"
                 + "<tr>\n"
                 + "<th class=\"colFirst\" scope=\"col\">Package</th>\n"
                 + "<th class=\"colLast\" scope=\"col\">Description</th>\n"
@@ -830,9 +825,9 @@
                 + "<td class=\"colSecond\">All Modules</td>\n"
                 + "<td class=\"colLast\">&nbsp;</td>",
                 "<caption><span id=\"t0\" class=\"activeTableTab\"><span>All Packages</span><span class=\"tabEnd\">&nbsp;</span></span>"
-                + "<span id=\"t1\" class=\"tableTab\"><span><a href=\"javascript:showPkgs(1);\">Exported Packages</a></span>"
+                + "<span id=\"t1\" class=\"tableTab\"><span><a href=\"javascript:showPkgs(1);\">Exports</a></span>"
                 + "<span class=\"tabEnd\">&nbsp;</span></span><span id=\"t3\" class=\"tableTab\"><span><a href=\"javascript:showPkgs(4);\">"
-                + "Concealed Packages</a></span><span class=\"tabEnd\">&nbsp;</span></span></caption>",
+                + "Concealed</a></span><span class=\"tabEnd\">&nbsp;</span></span></caption>",
                 "<th class=\"colFirst\" scope=\"row\"><a href=\"concealedpkgmdlA/package-summary.html\">concealedpkgmdlA</a></th>\n"
                 + "<td class=\"colSecond\">None</td>\n"
                 + "<td class=\"colLast\">&nbsp;</td>");
@@ -854,10 +849,10 @@
                 + "<td class=\"colLast\">&nbsp;<br>(<span class=\"implementationLabel\">Implementation(s):</span>&nbsp;<a href=\"testpkgmdlB/TestClassInModuleB.html\" "
                 + "title=\"class in testpkgmdlB\">TestClassInModuleB</a>)</td>",
                 "<caption><span id=\"t0\" class=\"activeTableTab\"><span>All Packages</span><span class=\"tabEnd\">&nbsp;</span></span><span id=\"t1\" class=\"tableTab\"><span>"
-                + "<a href=\"javascript:showPkgs(1);\">Exported Packages</a></span><span class=\"tabEnd\">&nbsp;</span></span><span id=\"t2\" class=\"tableTab\"><span>"
-                + "<a href=\"javascript:showPkgs(2);\">Opened Packages</a></span><span class=\"tabEnd\">&nbsp;</span></span></caption>");
+                + "<a href=\"javascript:showPkgs(1);\">Exports</a></span><span class=\"tabEnd\">&nbsp;</span></span><span id=\"t2\" class=\"tableTab\"><span>"
+                + "<a href=\"javascript:showPkgs(2);\">Opens</a></span><span class=\"tabEnd\">&nbsp;</span></span></caption>");
         checkOutput("moduleC-summary.html", found,
-                "<caption><span>Exported Packages</span><span class=\"tabEnd\">&nbsp;</span></caption>\n"
+                "<caption><span>Exports</span><span class=\"tabEnd\">&nbsp;</span></caption>\n"
                 + "<tr>\n"
                 + "<th class=\"colFirst\" scope=\"col\">Package</th>\n"
                 + "<th class=\"colSecond\" scope=\"col\">Module</th>\n"
@@ -872,7 +867,7 @@
     void checkModuleDeprecation(boolean found) {
         checkOutput("moduleA-summary.html", found,
                 "<div class=\"deprecatedContent\"><span class=\"deprecatedLabel\">Deprecated, for removal:"
-                + " This API element is subject to removal in a future version. </span>\n"
+                + " This API element is subject to removal in a future version.</span>\n"
                 + "<div class=\"block\"><span class=\"deprecationComment\">This module is deprecated.</span></div>\n"
                 + "</div>");
         checkOutput("deprecated-list.html", found,
--- a/langtools/test/jdk/javadoc/doclet/testSearch/TestSearch.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/langtools/test/jdk/javadoc/doclet/testSearch/TestSearch.java	Tue Apr 18 22:25:33 2017 +0200
@@ -23,7 +23,7 @@
 
 /*
  * @test
- * @bug 8141492 8071982 8141636 8147890 8166175 8168965 8176794
+ * @bug 8141492 8071982 8141636 8147890 8166175 8168965 8176794 8175218
  * @summary Test the search feature of javadoc.
  * @author bpatel
  * @library ../lib
@@ -321,9 +321,9 @@
                 + "pkg2.<a href=\"pkg2/TestEnum.html\" title=\"enum in pkg2\">TestEnum</a></dt>");
         checkOutput("index-all.html", true,
                 "<div class=\"block\"><span class=\"deprecationComment\">class_test1 passes. Search tag"
-                + " <a id=\"SearchTagDeprecatedClass\">SearchTagDeprecatedClass</a></span></div>",
+                + " <a id=\"SearchTagDeprecatedClass\" class=\"searchTagResult\">SearchTagDeprecatedClass</a></span></div>",
                 "<div class=\"block\"><span class=\"deprecationComment\">error_test3 passes. Search tag for\n"
-                + " method <a id=\"SearchTagDeprecatedMethod\">SearchTagDeprecatedMethod</a></span></div>");
+                + " method <a id=\"SearchTagDeprecatedMethod\" class=\"searchTagResult\">SearchTagDeprecatedMethod</a></span></div>");
     }
 
     void checkSplitIndex() {
--- a/langtools/test/jdk/javadoc/doclet/testStylesheet/TestStylesheet.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/langtools/test/jdk/javadoc/doclet/testStylesheet/TestStylesheet.java	Tue Apr 18 22:25:33 2017 +0200
@@ -23,7 +23,8 @@
 
 /*
  * @test
- * @bug      4494033 7028815 7052425 8007338 8023608 8008164 8016549 8072461 8154261 8162363 8160196 8151743
+ * @bug      4494033 7028815 7052425 8007338 8023608 8008164 8016549 8072461 8154261 8162363 8160196 8151743 8177417
+ *           8175218
  * @summary  Run tests on doclet stylesheet.
  * @author   jamieh
  * @library  ../lib
@@ -140,8 +141,8 @@
                 + ".usesSummary td.colFirst, .usesSummary th.colFirst,\n"
                 + ".providesSummary td.colFirst, .providesSummary th.colFirst,\n"
                 + ".memberSummary td.colFirst, .memberSummary th.colFirst,\n"
-                + ".memberSummary td.colSecond, .memberSummary th.colSecond,\n"
-                + ".typeSummary td.colFirst{\n"
+                + ".memberSummary td.colSecond, .memberSummary th.colSecond, .memberSummary th.colConstructorName,\n"
+                + ".typeSummary td.colFirst {\n"
                 + "    vertical-align:top;\n"
                 + "}",
                 ".overviewSummary td, .memberSummary td, .typeSummary td,\n"
@@ -162,6 +163,16 @@
                 "@import url('resources/fonts/dejavu.css');",
                 ".navPadding {\n"
                 + "    padding-top: 107px;\n"
+                + "}",
+                "a[name]:before, a[name]:target, a[id]:before, a[id]:target {\n"
+                + "    content:\"\";\n"
+                + "    display:inline-block;\n"
+                + "    position:relative;\n"
+                + "    padding-top:129px;\n"
+                + "    margin-top:-129px;\n"
+                + "}\n"
+                + ".searchTagResult:before, .searchTagResult:target {\n"
+                + "    color:red;\n"
                 + "}");
 
         // Test whether a link to the stylesheet file is inserted properly
--- a/langtools/test/jdk/javadoc/tool/CheckResourceKeys.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/langtools/test/jdk/javadoc/tool/CheckResourceKeys.java	Tue Apr 18 22:25:33 2017 +0200
@@ -33,8 +33,6 @@
  */
 
 import java.io.*;
-import java.lang.reflect.Layer;
-import java.lang.reflect.Module;
 import java.util.*;
 import javax.tools.*;
 import com.sun.tools.classfile.*;
@@ -265,7 +263,7 @@
      * Get the set of keys from the javadoc resource bundles.
      */
     Set<String> getResourceKeys() {
-        Module jdk_javadoc = Layer.boot().findModule("jdk.javadoc").get();
+        Module jdk_javadoc = ModuleLayer.boot().findModule("jdk.javadoc").get();
         String[] names = {
                 "jdk.javadoc.internal.doclets.formats.html.resources.standard",
                 "jdk.javadoc.internal.doclets.toolkit.resources.doclets",
--- a/langtools/test/jdk/jshell/CommandCompletionTest.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/langtools/test/jdk/jshell/CommandCompletionTest.java	Tue Apr 18 22:25:33 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -23,7 +23,7 @@
 
 /*
  * @test
- * @bug 8144095 8164825 8169818 8153402 8165405 8177079
+ * @bug 8144095 8164825 8169818 8153402 8165405 8177079 8178013
  * @summary Test Command Completion
  * @modules jdk.compiler/com.sun.tools.javac.api
  *          jdk.compiler/com.sun.tools.javac.main
@@ -173,6 +173,8 @@
                 "/save ", "/set "),
                 a -> assertCompletion(a, "/help /set |", false,
                 "editor", "feedback", "format", "mode", "prompt", "start", "truncation"),
+                a -> assertCompletion(a, "/help set |", false,
+                "editor", "feedback", "format", "mode", "prompt", "start", "truncation"),
                 a -> assertCompletion(a, "/help /edit |", false),
                 a -> assertCompletion(a, "/help dr|", false,
                 "drop ")
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/jdk/jshell/HistoryUITest.java	Tue Apr 18 22:25:33 2017 +0200
@@ -0,0 +1,83 @@
+/*
+ * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/**
+ * @test
+ * @bug 8178077
+ * @summary Check the UI behavior of editing history.
+ * @modules
+ *     jdk.compiler/com.sun.tools.javac.api
+ *     jdk.compiler/com.sun.tools.javac.main
+ *     jdk.jshell/jdk.jshell:open
+ * @library /tools/lib
+ * @build toolbox.ToolBox toolbox.JarTask toolbox.JavacTask
+ * @build Compiler UITesting
+ * @build HistoryUITest
+ * @run testng HistoryUITest
+ */
+
+import org.testng.annotations.Test;
+
+@Test
+public class HistoryUITest extends UITesting {
+
+    public void testPrevNextSnippet() throws Exception {
+        doRunTest((inputSink, out) -> {
+            inputSink.write("void test1() {\nSystem.err.println(1);\n}\n");
+            waitOutput(out, "\u0005");
+            inputSink.write("void test2() {\nSystem.err.println(2);\n}\n");
+            waitOutput(out, "\u0005");
+            inputSink.write(CTRL_UP);
+            waitOutput(out, "^void test2\\(\\) \\{");
+            inputSink.write(CTRL_UP);
+            waitOutput(out, "^" + clearOut("2() {") + "1\\(\\) \\{");
+            inputSink.write(CTRL_DOWN);
+            waitOutput(out, "^" + clearOut("1() {") + "2\\(\\) \\{");
+            inputSink.write(ENTER);
+            waitOutput(out, "^\n\u0006");
+            inputSink.write(UP);
+            waitOutput(out, "^}");
+            inputSink.write(UP);
+            waitOutput(out, "^" + clearOut("}") + "System.err.println\\(2\\);");
+            inputSink.write(UP);
+            waitOutput(out, "^" + clearOut("System.err.println(2);") + "void test2\\(\\) \\{");
+            inputSink.write(UP);
+            waitOutput(out, "^\u0007");
+            inputSink.write(DOWN);
+            waitOutput(out, "^" + clearOut("void test2() {") + "System.err.println\\(2\\);");
+            inputSink.write(DOWN);
+            waitOutput(out, "^" + clearOut("System.err.println(2);") + "}");
+            inputSink.write(DOWN);
+            waitOutput(out, "^" + clearOut("}"));
+            inputSink.write(DOWN);
+            waitOutput(out, "^\u0007");
+        });
+    }
+    //where:
+        private static final String CTRL_UP = "\033[1;5A";
+        private static final String CTRL_DOWN = "\033[1;5B";
+        private static final String UP = "\033[A";
+        private static final String DOWN = "\033[B";
+        private static final String ENTER = "\n";
+
+}
--- a/langtools/test/jdk/jshell/KullaTesting.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/langtools/test/jdk/jshell/KullaTesting.java	Tue Apr 18 22:25:33 2017 +0200
@@ -30,7 +30,6 @@
 import java.lang.reflect.Method;
 import java.lang.module.Configuration;
 import java.lang.module.ModuleFinder;
-import java.lang.reflect.Layer;
 import java.nio.file.Paths;
 import java.nio.file.Path;
 import java.util.ArrayList;
@@ -211,11 +210,11 @@
 
     public ClassLoader createAndRunFromModule(String moduleName, Path modPath) {
         ModuleFinder finder = ModuleFinder.of(modPath);
-        Layer parent = Layer.boot();
+        ModuleLayer parent = ModuleLayer.boot();
         Configuration cf = parent.configuration()
                 .resolve(finder, ModuleFinder.of(), Set.of(moduleName));
         ClassLoader scl = ClassLoader.getSystemClassLoader();
-        Layer layer = parent.defineModulesWithOneLoader(cf, scl);
+        ModuleLayer layer = parent.defineModulesWithOneLoader(cf, scl);
         ClassLoader loader = layer.findLoader(moduleName);
         ClassLoader ccl = Thread.currentThread().getContextClassLoader();
         Thread.currentThread().setContextClassLoader(loader);
--- a/langtools/test/jdk/jshell/MergedTabShiftTabTest.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/langtools/test/jdk/jshell/MergedTabShiftTabTest.java	Tue Apr 18 22:25:33 2017 +0200
@@ -31,37 +31,29 @@
  *     jdk.jshell/jdk.jshell:open
  * @library /tools/lib
  * @build toolbox.ToolBox toolbox.JarTask toolbox.JavacTask
- * @build Compiler
+ * @build Compiler UITesting
  * @build MergedTabShiftTabTest
  * @run testng MergedTabShiftTabTest
  */
 
 import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.io.OutputStreamWriter;
-import java.io.PrintStream;
-import java.io.Writer;
 import java.lang.reflect.Field;
 import java.nio.file.Files;
 import java.nio.file.Path;
 import java.nio.file.Paths;
 import java.text.MessageFormat;
 import java.util.Arrays;
-import java.util.HashMap;
 import java.util.Locale;
 import java.util.ResourceBundle;
 import java.util.jar.JarEntry;
 import java.util.jar.JarOutputStream;
-import java.util.regex.Matcher;
 import java.util.regex.Pattern;
 
 import jdk.jshell.JShell;
-import jdk.jshell.tool.JavaShellToolBuilder;
 import org.testng.annotations.Test;
 
 @Test
-public class MergedTabShiftTabTest {
+public class MergedTabShiftTabTest extends UITesting {
 
     public void testCommand() throws Exception {
         doRunTest((inputSink, out) -> {
@@ -281,60 +273,6 @@
         });
     }
 
-    private void doRunTest(Test test) throws Exception {
-        PipeInputStream input = new PipeInputStream();
-        StringBuilder out = new StringBuilder();
-        PrintStream outS = new PrintStream(new OutputStream() {
-            @Override public void write(int b) throws IOException {
-                synchronized (out) {
-                    System.out.print((char) b);
-                    out.append((char) b);
-                    out.notifyAll();
-                }
-            }
-        });
-        Thread runner = new Thread(() -> {
-            try {
-                JavaShellToolBuilder.builder()
-                        .in(input, input)
-                        .out(outS)
-                        .err(outS)
-                        .promptCapture(true)
-                        .persistence(new HashMap<>())
-                        .locale(Locale.US)
-                        .run("--no-startup");
-            } catch (Exception ex) {
-                throw new IllegalStateException(ex);
-            }
-        });
-
-        Writer inputSink = new OutputStreamWriter(input.createOutput()) {
-            @Override
-            public void write(String str) throws IOException {
-                super.write(str);
-                flush();
-            }
-        };
-
-        runner.start();
-
-        try {
-            waitOutput(out, "\u0005");
-            test.test(inputSink, out);
-        } finally {
-            inputSink.write("\003\003/exit");
-
-            runner.join(1000);
-            if (runner.isAlive()) {
-                runner.stop();
-            }
-        }
-    }
-
-    interface Test {
-        public void test(Writer inputSink, StringBuilder out) throws Exception;
-    }
-
     private Path prepareZip() {
         String clazz1 =
                 "package jshelltest;\n" +
@@ -404,162 +342,4 @@
         return MessageFormat.format(resources.getString(key), args);
     }
 
-    private static final long TIMEOUT;
-
-    static {
-        long factor;
-
-        try {
-            factor = (long) Double.parseDouble(System.getProperty("test.timeout.factor", "1"));
-        } catch (NumberFormatException ex) {
-            factor = 1;
-        }
-        TIMEOUT = 60_000 * factor;
-    }
-
-    private void waitOutput(StringBuilder out, String expected) {
-        expected = expected.replaceAll("\n", System.getProperty("line.separator"));
-        Pattern expectedPattern = Pattern.compile(expected, Pattern.DOTALL);
-        synchronized (out) {
-            long s = System.currentTimeMillis();
-
-            while (true) {
-                Matcher m = expectedPattern.matcher(out);
-                if (m.find()) {
-                    out.delete(0, m.end() + 1);
-                    return ;
-                }
-                long e =  System.currentTimeMillis();
-                if ((e - s) > TIMEOUT) {
-                    throw new IllegalStateException("Timeout waiting for: " + quote(expected) + ", actual output so far: " + quote(out.toString()));
-                }
-                try {
-                    out.wait(TIMEOUT);
-                } catch (InterruptedException ex) {
-                    ex.printStackTrace();
-                }
-            }
-        }
-    }
-
-    private String quote(String original) {
-        StringBuilder output = new StringBuilder();
-
-        for (char c : original.toCharArray()) {
-            if (c < 32) {
-                output.append(String.format("\\u%04X", (int) c));
-            } else {
-                output.append(c);
-            }
-        }
-
-        return output.toString();
-    }
-
-    private static class PipeInputStream extends InputStream {
-
-        private static final int INITIAL_SIZE = 128;
-        private int[] buffer = new int[INITIAL_SIZE];
-        private int start;
-        private int end;
-        private boolean closed;
-
-        @Override
-        public synchronized int read() throws IOException {
-            if (start == end && !closed) {
-                inputNeeded();
-            }
-            while (start == end) {
-                if (closed) {
-                    return -1;
-                }
-                try {
-                    wait();
-                } catch (InterruptedException ex) {
-                    //ignore
-                }
-            }
-            try {
-                return buffer[start];
-            } finally {
-                start = (start + 1) % buffer.length;
-            }
-        }
-
-        @Override
-        public synchronized int read(byte[] b, int off, int len) throws IOException {
-            if (b == null) {
-                throw new NullPointerException();
-            } else if (off < 0 || len < 0 || len > b.length - off) {
-                throw new IndexOutOfBoundsException();
-            } else if (len == 0) {
-                return 0;
-            }
-
-            int c = read();
-            if (c == -1) {
-                return -1;
-            }
-            b[off] = (byte)c;
-
-            int totalRead = 1;
-            while (totalRead < len && start != end) {
-                int r = read();
-                if (r == (-1))
-                    break;
-                b[off + totalRead++] = (byte) r;
-            }
-            return totalRead;
-        }
-
-        protected void inputNeeded() throws IOException {}
-
-        private synchronized void write(int b) {
-            if (closed) {
-                throw new IllegalStateException("Already closed.");
-            }
-            int newEnd = (end + 1) % buffer.length;
-            if (newEnd == start) {
-                //overflow:
-                int[] newBuffer = new int[buffer.length * 2];
-                int rightPart = (end > start ? end : buffer.length) - start;
-                int leftPart = end > start ? 0 : start - 1;
-                System.arraycopy(buffer, start, newBuffer, 0, rightPart);
-                System.arraycopy(buffer, 0, newBuffer, rightPart, leftPart);
-                buffer = newBuffer;
-                start = 0;
-                end = rightPart + leftPart;
-                newEnd = end + 1;
-            }
-            buffer[end] = b;
-            end = newEnd;
-            notifyAll();
-        }
-
-        @Override
-        public synchronized void close() {
-            closed = true;
-            notifyAll();
-        }
-
-        public OutputStream createOutput() {
-            return new OutputStream() {
-                @Override public void write(int b) throws IOException {
-                    PipeInputStream.this.write(b);
-                }
-                @Override
-                public void write(byte[] b, int off, int len) throws IOException {
-                    for (int i = 0 ; i < len ; i++) {
-                        write(Byte.toUnsignedInt(b[off + i]));
-                    }
-                }
-                @Override
-                public void close() throws IOException {
-                    PipeInputStream.this.close();
-                }
-            };
-        }
-
-    }
-
 }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/jdk/jshell/UITesting.java	Tue Apr 18 22:25:33 2017 +0200
@@ -0,0 +1,272 @@
+/*
+ * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.io.OutputStreamWriter;
+import java.io.PrintStream;
+import java.io.Writer;
+import java.util.HashMap;
+import java.util.Locale;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import jdk.jshell.tool.JavaShellToolBuilder;
+
+public class UITesting {
+
+    protected void doRunTest(Test test) throws Exception {
+        PipeInputStream input = new PipeInputStream();
+        StringBuilder out = new StringBuilder();
+        PrintStream outS = new PrintStream(new OutputStream() {
+            @Override public void write(int b) throws IOException {
+                synchronized (out) {
+                    System.out.print((char) b);
+                    out.append((char) b);
+                    out.notifyAll();
+                }
+            }
+        });
+        Thread runner = new Thread(() -> {
+            try {
+                JavaShellToolBuilder.builder()
+                        .in(input, input)
+                        .out(outS)
+                        .err(outS)
+                        .promptCapture(true)
+                        .persistence(new HashMap<>())
+                        .locale(Locale.US)
+                        .run("--no-startup");
+            } catch (Exception ex) {
+                throw new IllegalStateException(ex);
+            }
+        });
+
+        Writer inputSink = new OutputStreamWriter(input.createOutput()) {
+            @Override
+            public void write(String str) throws IOException {
+                super.write(str);
+                flush();
+            }
+        };
+
+        runner.start();
+
+        try {
+            waitOutput(out, "\u0005");
+            test.test(inputSink, out);
+        } finally {
+            inputSink.write("\003\003/exit");
+
+            runner.join(1000);
+            if (runner.isAlive()) {
+                runner.stop();
+            }
+        }
+    }
+
+    protected interface Test {
+        public void test(Writer inputSink, StringBuilder out) throws Exception;
+    }
+
+    private static final long TIMEOUT;
+
+    static {
+        long factor;
+
+        try {
+            factor = (long) Double.parseDouble(System.getProperty("test.timeout.factor", "1"));
+        } catch (NumberFormatException ex) {
+            factor = 1;
+        }
+        TIMEOUT = 60_000 * factor;
+    }
+
+    protected void waitOutput(StringBuilder out, String expected) {
+        expected = expected.replaceAll("\n", System.getProperty("line.separator"));
+        Pattern expectedPattern = Pattern.compile(expected, Pattern.DOTALL);
+        synchronized (out) {
+            long s = System.currentTimeMillis();
+
+            while (true) {
+                Matcher m = expectedPattern.matcher(out);
+                if (m.find()) {
+                    out.delete(0, m.end() + 1);
+                    return ;
+                }
+                long e =  System.currentTimeMillis();
+                if ((e - s) > TIMEOUT) {
+                    throw new IllegalStateException("Timeout waiting for: " + quote(expected) + ", actual output so far: " + quote(out.toString()));
+                }
+                try {
+                    out.wait(TIMEOUT);
+                } catch (InterruptedException ex) {
+                    ex.printStackTrace();
+                }
+            }
+        }
+    }
+
+    private String quote(String original) {
+        StringBuilder output = new StringBuilder();
+
+        for (char c : original.toCharArray()) {
+            if (c < 32) {
+                output.append(String.format("\\u%04X", (int) c));
+            } else {
+                output.append(c);
+            }
+        }
+
+        return output.toString();
+    }
+
+    protected String clearOut(String what) {
+        return backspace(what.length()) + space(what.length()) + backspace(what.length());
+    }
+
+    protected String backspace(int n) {
+        return fill(n, '\010');
+    }
+
+    protected String space(int n) {
+        return fill(n, ' ');
+    }
+
+    private String fill(int n, char c) {
+        StringBuilder result = new StringBuilder(n);
+
+        while (n-- > 0)
+            result.append(c);
+
+        return result.toString();
+    }
+
+    private static class PipeInputStream extends InputStream {
+
+        private static final int INITIAL_SIZE = 128;
+        private int[] buffer = new int[INITIAL_SIZE];
+        private int start;
+        private int end;
+        private boolean closed;
+
+        @Override
+        public synchronized int read() throws IOException {
+            if (start == end && !closed) {
+                inputNeeded();
+            }
+            while (start == end) {
+                if (closed) {
+                    return -1;
+                }
+                try {
+                    wait();
+                } catch (InterruptedException ex) {
+                    //ignore
+                }
+            }
+            try {
+                return buffer[start];
+            } finally {
+                start = (start + 1) % buffer.length;
+            }
+        }
+
+        @Override
+        public synchronized int read(byte[] b, int off, int len) throws IOException {
+            if (b == null) {
+                throw new NullPointerException();
+            } else if (off < 0 || len < 0 || len > b.length - off) {
+                throw new IndexOutOfBoundsException();
+            } else if (len == 0) {
+                return 0;
+            }
+
+            int c = read();
+            if (c == -1) {
+                return -1;
+            }
+            b[off] = (byte)c;
+
+            int totalRead = 1;
+            while (totalRead < len && start != end) {
+                int r = read();
+                if (r == (-1))
+                    break;
+                b[off + totalRead++] = (byte) r;
+            }
+            return totalRead;
+        }
+
+        protected void inputNeeded() throws IOException {}
+
+        private synchronized void write(int b) {
+            if (closed) {
+                throw new IllegalStateException("Already closed.");
+            }
+            int newEnd = (end + 1) % buffer.length;
+            if (newEnd == start) {
+                //overflow:
+                int[] newBuffer = new int[buffer.length * 2];
+                int rightPart = (end > start ? end : buffer.length) - start;
+                int leftPart = end > start ? 0 : start - 1;
+                System.arraycopy(buffer, start, newBuffer, 0, rightPart);
+                System.arraycopy(buffer, 0, newBuffer, rightPart, leftPart);
+                buffer = newBuffer;
+                start = 0;
+                end = rightPart + leftPart;
+                newEnd = end + 1;
+            }
+            buffer[end] = b;
+            end = newEnd;
+            notifyAll();
+        }
+
+        @Override
+        public synchronized void close() {
+            closed = true;
+            notifyAll();
+        }
+
+        public OutputStream createOutput() {
+            return new OutputStream() {
+                @Override public void write(int b) throws IOException {
+                    PipeInputStream.this.write(b);
+                }
+                @Override
+                public void write(byte[] b, int off, int len) throws IOException {
+                    for (int i = 0 ; i < len ; i++) {
+                        write(Byte.toUnsignedInt(b[off + i]));
+                    }
+                }
+                @Override
+                public void close() throws IOException {
+                    PipeInputStream.this.close();
+                }
+            };
+        }
+
+    }
+
+}
--- a/langtools/test/tools/javac/6410653/T6410653.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/langtools/test/tools/javac/6410653/T6410653.java	Tue Apr 18 22:25:33 2017 +0200
@@ -31,7 +31,6 @@
  */
 
 import java.lang.reflect.Field;
-import java.lang.reflect.Module;
 import java.io.File;
 import java.io.ByteArrayOutputStream;
 import javax.tools.*;
--- a/langtools/test/tools/javac/T6406771.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/langtools/test/tools/javac/T6406771.java	Tue Apr 18 22:25:33 2017 +0200
@@ -11,9 +11,9 @@
 // Editing the imports and other leading text may affect the golden text in the tests field.
 // Also beware of scripts that auto-expand tabs to spaces.
 
+
+
 import java.io.*;
-import java.lang.reflect.Layer;
-import java.lang.reflect.Module;
 import java.util.*;
 import javax.annotation.processing.*;
 import javax.lang.model.*;
--- a/langtools/test/tools/javac/diags/CheckExamples.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/langtools/test/tools/javac/diags/CheckExamples.java	Tue Apr 18 22:25:33 2017 +0200
@@ -39,8 +39,6 @@
  */
 
 import java.io.*;
-import java.lang.reflect.Layer;
-import java.lang.reflect.Module;
 import java.nio.file.*;
 import java.nio.file.attribute.BasicFileAttributes;
 import java.util.*;
@@ -111,7 +109,7 @@
             }
         }
 
-        Module jdk_compiler = Layer.boot().findModule("jdk.compiler").get();
+        Module jdk_compiler = ModuleLayer.boot().findModule("jdk.compiler").get();
         ResourceBundle b =
             ResourceBundle.getBundle("com.sun.tools.javac.resources.compiler", jdk_compiler);
         Set<String> resourceKeys = new TreeSet<String>(b.keySet());
--- a/langtools/test/tools/javac/diags/CheckResourceKeys.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/langtools/test/tools/javac/diags/CheckResourceKeys.java	Tue Apr 18 22:25:33 2017 +0200
@@ -31,8 +31,6 @@
  */
 
 import java.io.*;
-import java.lang.reflect.Layer;
-import java.lang.reflect.Module;
 import java.util.*;
 import javax.tools.*;
 import com.sun.tools.classfile.*;
@@ -395,7 +393,7 @@
      * Get the set of keys from the javac resource bundles.
      */
     Set<String> getResourceKeys() {
-        Module jdk_compiler = Layer.boot().findModule("jdk.compiler").get();
+        Module jdk_compiler = ModuleLayer.boot().findModule("jdk.compiler").get();
         Set<String> results = new TreeSet<String>();
         for (String name : new String[]{"javac", "compiler"}) {
             ResourceBundle b =
--- a/langtools/test/tools/javac/diags/Example.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/langtools/test/tools/javac/diags/Example.java	Tue Apr 18 22:25:33 2017 +0200
@@ -24,8 +24,18 @@
 import java.io.*;
 import java.net.URL;
 import java.net.URLClassLoader;
+import java.nio.file.Files;
+import java.nio.file.Path;
 import java.util.*;
+import java.util.Map.Entry;
+import java.util.jar.JarFile;
+import java.util.jar.JarOutputStream;
+import java.util.logging.Level;
+import java.util.logging.Logger;
 import java.util.regex.*;
+import java.util.stream.Collectors;
+import java.util.zip.ZipEntry;
+
 import javax.annotation.processing.Processor;
 import javax.tools.Diagnostic;
 import javax.tools.DiagnosticCollector;
@@ -210,9 +220,53 @@
             File modulepathDir = new File(tempDir, "modulepath");
             modulepathDir.mkdirs();
             clean(modulepathDir);
-            List<String> sOpts = Arrays.asList("-d", modulepathDir.getPath(),
-                                               "--module-source-path", new File(file, "modulepath").getAbsolutePath());
-            new Jsr199Compiler(verbose).run(null, null, false, sOpts, modulePathFiles);
+            boolean hasModuleInfo =
+                    modulePathFiles.stream()
+                                   .anyMatch(f -> f.getName().equalsIgnoreCase("module-info.java"));
+            Path modulePath = new File(file, "modulepath").toPath().toAbsolutePath();
+            if (hasModuleInfo) {
+                //ordinary modules
+                List<String> sOpts =
+                        Arrays.asList("-d", modulepathDir.getPath(),
+                                      "--module-source-path", modulePath.toString());
+                new Jsr199Compiler(verbose).run(null, null, false, sOpts, modulePathFiles);
+            } else {
+                //automatic modules:
+                Map<String, List<Path>> module2Files =
+                        modulePathFiles.stream()
+                                       .map(f -> f.toPath())
+                                       .collect(Collectors.groupingBy(p -> modulePath.relativize(p)
+                                                                            .getName(0)
+                                                                            .toString()));
+                for (Entry<String, List<Path>> e : module2Files.entrySet()) {
+                    File scratchDir = new File(tempDir, "scratch");
+                    scratchDir.mkdirs();
+                    clean(scratchDir);
+                    List<String> sOpts =
+                            Arrays.asList("-d", scratchDir.getPath());
+                    new Jsr199Compiler(verbose).run(null,
+                                                    null,
+                                                    false,
+                                                    sOpts,
+                                                    e.getValue().stream()
+                                                                .map(p -> p.toFile())
+                                                                .collect(Collectors.toList()));
+                    try (JarOutputStream jarOut =
+                            new JarOutputStream(new FileOutputStream(new File(modulepathDir, e.getKey() + ".jar")))) {
+                        Files.find(scratchDir.toPath(), Integer.MAX_VALUE, (p, attr) -> attr.isRegularFile())
+                                .forEach(p -> {
+                                    try (InputStream in = Files.newInputStream(p)) {
+                                        jarOut.putNextEntry(new ZipEntry(scratchDir.toPath()
+                                                                                   .relativize(p)
+                                                                                   .toString()));
+                                        jarOut.write(in.readAllBytes());
+                                    } catch (IOException ex) {
+                                        throw new IllegalStateException(ex);
+                                    }
+                                });
+                    }
+                }
+            }
             opts.add("--module-path");
             opts.add(modulepathDir.getAbsolutePath());
         }
--- a/langtools/test/tools/javac/diags/examples/NoJavaLang.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/langtools/test/tools/javac/diags/examples/NoJavaLang.java	Tue Apr 18 22:25:33 2017 +0200
@@ -22,7 +22,7 @@
  */
 
 // key: compiler.misc.fatal.err.no.java.lang
-// options: -source 8 -target 8 -Xbootclasspath:
+// options: -source 8 -target 8 -Xbootclasspath: -classpath .
 // run: backdoor
 
 class NoJavaLang { }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/diags/examples/RequiresAutomatic/module-info.java	Tue Apr 18 22:25:33 2017 +0200
@@ -0,0 +1,28 @@
+/*
+ * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+//options: -Xlint:requires-automatic
+//key: compiler.warn.requires.automatic
+module RequiresAutomatic {
+    requires a;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/diags/examples/RequiresAutomatic/modulepath/a/A.java	Tue Apr 18 22:25:33 2017 +0200
@@ -0,0 +1,24 @@
+/*
+ * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+public class A {}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/diags/examples/RequiresTransitiveAutomatic/module-info.java	Tue Apr 18 22:25:33 2017 +0200
@@ -0,0 +1,27 @@
+/*
+ * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+//key: compiler.warn.requires.transitive.automatic
+module RequiresTransitiveAutomatic {
+    requires transitive a;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/diags/examples/RequiresTransitiveAutomatic/modulepath/a/A.java	Tue Apr 18 22:25:33 2017 +0200
@@ -0,0 +1,24 @@
+/*
+ * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+public class A {}
--- a/langtools/test/tools/javac/fatalErrors/NoJavaLangTest.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/langtools/test/tools/javac/fatalErrors/NoJavaLangTest.java	Tue Apr 18 22:25:33 2017 +0200
@@ -74,7 +74,7 @@
 
     // test with bootclasspath, for as long as its around
     void testBootClassPath() {
-        String[] bcpOpts = { "-Xlint:-options", "-source", "8", "-bootclasspath", "." };
+        String[] bcpOpts = { "-Xlint:-options", "-source", "8", "-bootclasspath", ".", "-classpath", "." };
         test(bcpOpts, compilerErrorMessage);
     }
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/speculative/T8177933.java	Tue Apr 18 22:25:33 2017 +0200
@@ -0,0 +1,90 @@
+/*
+ * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 8177933
+ * @summary Stackoverflow during compilation, starting jdk-9+163
+ *
+ * @library /tools/javac/lib
+ * @requires !(os.family == "solaris")
+ * @modules jdk.compiler/com.sun.tools.javac.api
+ *          jdk.compiler/com.sun.tools.javac.code
+ *          jdk.compiler/com.sun.tools.javac.comp
+ *          jdk.compiler/com.sun.tools.javac.main
+ *          jdk.compiler/com.sun.tools.javac.tree
+ *          jdk.compiler/com.sun.tools.javac.util
+ * @build combo.ComboTestHelper
+
+ * @run main/othervm -Xss512K T8177933
+ */
+
+import combo.ComboInstance;
+import combo.ComboParameter;
+import combo.ComboTask.Result;
+import combo.ComboTestHelper;
+
+import javax.lang.model.element.Element;
+
+public class T8177933 extends ComboInstance<T8177933> {
+
+    static final int MAX_DEPTH = 350;
+
+    static class CallExpr implements ComboParameter {
+        @Override
+        public String expand(String optParameter) {
+            Integer n = Integer.parseInt(optParameter);
+            if (n == MAX_DEPTH) {
+                return "m()";
+            } else {
+                return "m().#{CALL." + (n + 1) + "}";
+            }
+        }
+    }
+
+    static final String sourceTemplate =
+            "class Test {\n" +
+            "   Test m() { return null; }\n" +
+            "   void test() {\n" +
+            "       #{CALL.0};\n" +
+            "} }\n";
+
+    public static void main(String[] args) {
+        new ComboTestHelper<T8177933>()
+                .withDimension("CALL", new CallExpr())
+                .run(T8177933::new);
+    }
+
+    @Override
+    protected void doWork() throws Throwable {
+        Result<Iterable<? extends Element>> result = newCompilationTask()
+                    .withOption("-XDdev")
+                    .withSourceFromTemplate(sourceTemplate)
+                    .analyze();
+        if (!result.get().iterator().hasNext()) {
+            fail("Exception occurred when compiling combo. " + result.compilationInfo());
+        }
+    }
+}
--- a/langtools/test/tools/javac/lib/JavacTestingAbstractProcessor.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/langtools/test/tools/javac/lib/JavacTestingAbstractProcessor.java	Tue Apr 18 22:25:33 2017 +0200
@@ -21,8 +21,6 @@
  * questions.
  */
 
-import java.lang.reflect.Layer;
-import java.lang.reflect.Module;
 import java.util.*;
 import javax.annotation.processing.*;
 import javax.lang.model.SourceVersion;
@@ -102,7 +100,7 @@
     protected void addExports(String moduleName, String... packageNames) {
         for (String packageName : packageNames) {
             try {
-                Layer layer = Layer.boot();
+                ModuleLayer layer = ModuleLayer.boot();
                 Optional<Module> m = layer.findModule(moduleName);
                 if (!m.isPresent())
                     throw new Error("module not found: " + moduleName);
--- a/langtools/test/tools/javac/modules/AddLimitMods.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/langtools/test/tools/javac/modules/AddLimitMods.java	Tue Apr 18 22:25:33 2017 +0200
@@ -418,13 +418,13 @@
                                       "    public static void main(String... args) throws Exception {\n");
 
                 for (Entry<String, String> e : MODULES_TO_CHECK_TO_SAMPLE_CLASS.entrySet()) {
-                    testClassNamed.append("        System.err.println(\"visible:" + e.getKey() + ":\" + java.lang.reflect.Layer.boot().findModule(\"" + e.getKey() + "\").isPresent());\n");
+                    testClassNamed.append("        System.err.println(\"visible:" + e.getKey() + ":\" + ModuleLayer.boot().findModule(\"" + e.getKey() + "\").isPresent());\n");
                 }
 
                 testClassNamed.append("        Class<?> cp = Class.forName(Test.class.getClassLoader().getUnnamedModule(), \"cp.CP\");\n");
                 testClassNamed.append("        cp.getDeclaredMethod(\"runMe\").invoke(null);\n");
 
-                testClassNamed.append("        Class<?> automatic = Class.forName(java.lang.reflect.Layer.boot().findModule(\"automatic\").get(), \"automatic.Automatic\");\n");
+                testClassNamed.append("        Class<?> automatic = Class.forName(ModuleLayer.boot().findModule(\"automatic\").get(), \"automatic.Automatic\");\n");
                 testClassNamed.append("        automatic.getDeclaredMethod(\"runMe\").invoke(null);\n");
 
                 testClassNamed.append("    }\n" +
--- a/langtools/test/tools/javac/modules/AutomaticModules.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/langtools/test/tools/javac/modules/AutomaticModules.java	Tue Apr 18 22:25:33 2017 +0200
@@ -23,7 +23,7 @@
 
 /**
  * @test
- * @bug 8155026
+ * @bug 8155026 8178011
  * @summary Test automatic modules
  * @library /tools/lib
  * @modules
@@ -300,9 +300,8 @@
                 .writeAll()
                 .getOutputLines(Task.OutputKind.DIRECT);
 
-        expected = Arrays.asList("Impl.java:1:47: compiler.err.package.not.visible: apiB, (compiler.misc.not.def.access.does.not.read: m1x, apiB, automaticB)",
-                                 "Impl.java:1:59: compiler.err.package.not.visible: m2x, (compiler.misc.not.def.access.does.not.read: m1x, m2x, m2x)",
-                                 "2 errors");
+        expected = Arrays.asList("Impl.java:1:59: compiler.err.package.not.visible: m2x, (compiler.misc.not.def.access.does.not.read: m1x, m2x, m2x)",
+                                 "1 error");
 
         if (!expected.equals(log)) {
             throw new Exception("expected output not found: " + log);
@@ -310,7 +309,7 @@
     }
 
     @Test
-    public void testDropTrailingVersion(Path base) throws Exception {
+    public void testWithTrailingVersion(Path base) throws Exception {
         Path legacySrc = base.resolve("legacy-src");
         tb.writeJavaFiles(legacySrc,
                           "package api; public class Api {}");
@@ -348,7 +347,7 @@
         Files.createDirectories(classes);
 
         tb.writeJavaFiles(m,
-                          "module m { requires test; }",
+                          "module m { requires test1; }",
                           "package impl; public class Impl { public void e(api.Api api) { } }");
 
         new JavacTask(tb)
@@ -358,4 +357,261 @@
                 .run()
                 .writeAll();
     }
+
+    @Test
+    public void testMultipleAutomatic(Path base) throws Exception {
+        Path modulePath = base.resolve("module-path");
+
+        Files.createDirectories(modulePath);
+
+        for (char c : new char[] {'A', 'B'}) {
+            Path automaticSrc = base.resolve("automaticSrc" + c);
+            tb.writeJavaFiles(automaticSrc, "package api" + c + "; public class Api {}");
+            Path automaticClasses = base.resolve("automaticClasses" + c);
+            tb.createDirectories(automaticClasses);
+
+            String automaticLog = new JavacTask(tb)
+                                    .outdir(automaticClasses)
+                                    .files(findJavaFiles(automaticSrc))
+                                    .run()
+                                    .writeAll()
+                                    .getOutput(Task.OutputKind.DIRECT);
+
+            if (!automaticLog.isEmpty())
+                throw new Exception("expected output not found: " + automaticLog);
+
+            Path automaticJar = modulePath.resolve("automatic" + c + "-1.0.jar");
+
+            new JarTask(tb, automaticJar)
+              .baseDir(automaticClasses)
+              .files("api" + c + "/Api.class")
+              .run();
+        }
+
+        Path src = base.resolve("src");
+
+        tb.writeJavaFiles(src.resolve("m1x"),
+                          "package impl; public class Impl { apiA.Api a; apiB.Api b; }");
+
+        Path classes = base.resolve("classes");
+
+        Files.createDirectories(classes);
+
+        List<String> log = new JavacTask(tb)
+                .options("--module-path", modulePath.toString(),
+                         "-XDrawDiagnostics")
+                .outdir(classes)
+                .files(findJavaFiles(src))
+                .run(Task.Expect.FAIL)
+                .writeAll()
+                .getOutputLines(Task.OutputKind.DIRECT);
+
+        List<String> expected = Arrays.asList("Impl.java:1:35: compiler.err.package.not.visible: apiA, (compiler.misc.not.def.access.does.not.read.from.unnamed: apiA, automaticA)",
+                                              "Impl.java:1:47: compiler.err.package.not.visible: apiB, (compiler.misc.not.def.access.does.not.read.from.unnamed: apiB, automaticB)",
+                                              "2 errors");
+
+        if (!expected.equals(log)) {
+            throw new Exception("expected output not found: " + log);
+        }
+
+        new JavacTask(tb)
+                .options("--module-path", modulePath.toString(),
+                         "--add-modules", "automaticA",
+                         "-XDrawDiagnostics")
+                .outdir(classes)
+                .files(findJavaFiles(src))
+                .run()
+                .writeAll();
+    }
+
+    @Test
+    public void testLintRequireAutomatic(Path base) throws Exception {
+        Path modulePath = base.resolve("module-path");
+
+        Files.createDirectories(modulePath);
+
+        for (char c : new char[] {'A', 'B'}) {
+            Path automaticSrc = base.resolve("automaticSrc" + c);
+            tb.writeJavaFiles(automaticSrc, "package api" + c + "; public class Api {}");
+            Path automaticClasses = base.resolve("automaticClasses" + c);
+            tb.createDirectories(automaticClasses);
+
+            String automaticLog = new JavacTask(tb)
+                                    .outdir(automaticClasses)
+                                    .files(findJavaFiles(automaticSrc))
+                                    .run()
+                                    .writeAll()
+                                    .getOutput(Task.OutputKind.DIRECT);
+
+            if (!automaticLog.isEmpty())
+                throw new Exception("expected output not found: " + automaticLog);
+
+            Path automaticJar = modulePath.resolve("automatic" + c + "-1.0.jar");
+
+            new JarTask(tb, automaticJar)
+              .baseDir(automaticClasses)
+              .files("api" + c + "/Api.class")
+              .run();
+        }
+
+        Path src = base.resolve("src");
+
+        tb.writeJavaFiles(src,
+                          "module m1x {\n" +
+                          "    requires transitive automaticA;\n" +
+                          "    requires automaticB;\n" +
+                          "}");
+
+        Path classes = base.resolve("classes");
+
+        Files.createDirectories(classes);
+
+        List<String> expected;
+        List<String> log;
+
+        log = new JavacTask(tb)
+            .options("--source-path", src.toString(),
+                     "--module-path", modulePath.toString(),
+                     "-XDrawDiagnostics",
+                     "-Werror")
+            .outdir(classes)
+            .files(findJavaFiles(src))
+            .run(Task.Expect.FAIL)
+            .writeAll()
+            .getOutputLines(Task.OutputKind.DIRECT);
+
+        expected = Arrays.asList("module-info.java:2:25: compiler.warn.requires.transitive.automatic",
+                                 "- compiler.err.warnings.and.werror",
+                                 "1 error",
+                                 "1 warning");
+
+        if (!expected.equals(log)) {
+            throw new Exception("expected output not found: " + log);
+        }
+
+        log = new JavacTask(tb)
+            .options("--source-path", src.toString(),
+                     "--module-path", modulePath.toString(),
+                     "-Xlint:requires-automatic",
+                     "-XDrawDiagnostics",
+                     "-Werror")
+            .outdir(classes)
+            .files(findJavaFiles(src))
+            .run(Task.Expect.FAIL)
+            .writeAll()
+            .getOutputLines(Task.OutputKind.DIRECT);
+
+        expected = Arrays.asList("module-info.java:2:25: compiler.warn.requires.transitive.automatic",
+                                 "module-info.java:3:14: compiler.warn.requires.automatic",
+                                 "- compiler.err.warnings.and.werror",
+                                 "1 error",
+                                 "2 warnings");
+
+        if (!expected.equals(log)) {
+            throw new Exception("expected output not found: " + log);
+        }
+
+        log = new JavacTask(tb)
+            .options("--source-path", src.toString(),
+                     "--module-path", modulePath.toString(),
+                     "-Xlint:-requires-transitive-automatic,requires-automatic",
+                     "-XDrawDiagnostics",
+                     "-Werror")
+            .outdir(classes)
+            .files(findJavaFiles(src))
+            .run(Task.Expect.FAIL)
+            .writeAll()
+            .getOutputLines(Task.OutputKind.DIRECT);
+
+        expected = Arrays.asList("module-info.java:2:25: compiler.warn.requires.automatic",
+                                 "module-info.java:3:14: compiler.warn.requires.automatic",
+                                 "- compiler.err.warnings.and.werror",
+                                 "1 error",
+                                 "2 warnings");
+
+        if (!expected.equals(log)) {
+            throw new Exception("expected output not found: " + log);
+        }
+
+        new JavacTask(tb)
+            .options("--source-path", src.toString(),
+                     "--module-path", modulePath.toString(),
+                     "-Xlint:-requires-transitive-automatic",
+                     "-XDrawDiagnostics",
+                     "-Werror")
+            .outdir(classes)
+            .files(findJavaFiles(src))
+            .run(Task.Expect.SUCCESS)
+            .writeAll()
+            .getOutputLines(Task.OutputKind.DIRECT);
+
+        tb.writeJavaFiles(src,
+                          "@SuppressWarnings(\"requires-transitive-automatic\")\n" +
+                          "module m1x {\n" +
+                          "    requires transitive automaticA;\n" +
+                          "    requires automaticB;\n" +
+                          "}");
+
+        new JavacTask(tb)
+            .options("--source-path", src.toString(),
+                     "--module-path", modulePath.toString(),
+                     "-XDrawDiagnostics",
+                     "-Werror")
+            .outdir(classes)
+            .files(findJavaFiles(src))
+            .run(Task.Expect.SUCCESS)
+            .writeAll()
+            .getOutputLines(Task.OutputKind.DIRECT);
+
+        log = new JavacTask(tb)
+            .options("--source-path", src.toString(),
+                     "--module-path", modulePath.toString(),
+                     "-Xlint:requires-automatic",
+                     "-XDrawDiagnostics",
+                     "-Werror")
+            .outdir(classes)
+            .files(findJavaFiles(src))
+            .run(Task.Expect.FAIL)
+            .writeAll()
+            .getOutputLines(Task.OutputKind.DIRECT);
+
+        expected = Arrays.asList("module-info.java:3:25: compiler.warn.requires.automatic",
+                                 "module-info.java:4:14: compiler.warn.requires.automatic",
+                                 "- compiler.err.warnings.and.werror",
+                                 "1 error",
+                                 "2 warnings");
+
+        if (!expected.equals(log)) {
+            throw new Exception("expected output not found: " + log);
+        }
+
+        tb.writeJavaFiles(src,
+                          "@SuppressWarnings(\"requires-automatic\")\n" +
+                          "module m1x {\n" +
+                          "    requires transitive automaticA;\n" +
+                          "    requires automaticB;\n" +
+                          "}");
+
+        log = new JavacTask(tb)
+            .options("--source-path", src.toString(),
+                     "--module-path", modulePath.toString(),
+                     "-Xlint:requires-automatic",
+                     "-XDrawDiagnostics",
+                     "-Werror")
+            .outdir(classes)
+            .files(findJavaFiles(src))
+            .run(Task.Expect.FAIL)
+            .writeAll()
+            .getOutputLines(Task.OutputKind.DIRECT);
+
+        expected = Arrays.asList("module-info.java:3:25: compiler.warn.requires.transitive.automatic",
+                                 "- compiler.err.warnings.and.werror",
+                                 "1 error",
+                                 "1 warning");
+
+        if (!expected.equals(log)) {
+            throw new Exception("expected output not found: " + log);
+        }
+    }
+
 }
--- a/langtools/test/tools/javac/modules/IncubatingTest.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/langtools/test/tools/javac/modules/IncubatingTest.java	Tue Apr 18 22:25:33 2017 +0200
@@ -122,14 +122,11 @@
                          "-XDrawDiagnostics")
                 .outdir(testClasses)
                 .files(findJavaFiles(testSrc))
-                .run(Expect.FAIL)
+                .run(Expect.SUCCESS)
                 .writeAll()
                 .getOutputLines(Task.OutputKind.DIRECT);
 
-        expected = Arrays.asList(
-                "T.java:1:11: compiler.err.package.not.visible: api, (compiler.misc.not.def.access.does.not.read.from.unnamed: api, jdk.i)",
-                "1 error"
-        );
+        expected = Arrays.asList("");
 
         if (!expected.equals(log)) {
             throw new AssertionError("Unexpected output: " + log);
--- a/langtools/test/tools/javac/modules/PoorChoiceForModuleNameTest.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/langtools/test/tools/javac/modules/PoorChoiceForModuleNameTest.java	Tue Apr 18 22:25:33 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2016, 2017 Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -23,7 +23,7 @@
 
 /*
  * @test
- * @bug 8160181
+ * @bug 8160181 8176572
  * @summary Add lint warning for digits in module names
  * @library /tools/lib
  * @modules
@@ -63,6 +63,22 @@
         Path src_m3 = src.resolve("mango100");
         tb.writeJavaFiles(src_m3, "@SuppressWarnings(\"module\") module mango100 { }");
 
+        // Check that there is no warning at use site.
+        Path src_m4 = src.resolve("mangouser");
+        tb.writeJavaFiles(src_m4, "module mangouser { requires mango19; }");
+
+        // Check that we warn about component names ending in digit also
+        Path src_m5 = src.resolve("mango1000.mangofruit.mangomodule");
+        tb.writeJavaFiles(src_m5, "module mango1000.mangofruit.mangomodule { }");
+
+        // Check that we warn about component names ending in digit also
+        Path src_m6 = src.resolve("mangofruit.mango1000.mangomodule");
+        tb.writeJavaFiles(src_m6, "module mangofruit.mango1000.mangomodule { }");
+
+        // Check that we warn about component names ending in digit also
+        Path src_m7 = src.resolve("mangomodule.mangofruit.mango1000");
+        tb.writeJavaFiles(src_m7, "module mangomodule.mangofruit.mango1000 { }");
+
         Path classes = base.resolve("classes");
         tb.createDirectories(classes);
 
@@ -78,9 +94,12 @@
                 .getOutput(Task.OutputKind.DIRECT);
 
         if (!log.contains("module-info.java:1:8: compiler.warn.poor.choice.for.module.name: mango19") ||
+            !log.contains("module-info.java:1:8: compiler.warn.poor.choice.for.module.name: mango1000") ||
+            !log.contains("module-info.java:1:18: compiler.warn.poor.choice.for.module.name: mango1000") ||
+            !log.contains("module-info.java:1:30: compiler.warn.poor.choice.for.module.name: mango1000") ||
             !log.contains("- compiler.err.warnings.and.werror") ||
             !log.contains("1 error") ||
-            !log.contains("1 warning"))
+            !log.contains("4 warning"))
             throw new Exception("expected output not found: " + log);
     }
 }
--- a/langtools/test/tools/javac/treeannotests/TestProcessor.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/langtools/test/tools/javac/treeannotests/TestProcessor.java	Tue Apr 18 22:25:33 2017 +0200
@@ -21,8 +21,6 @@
  * questions.
  */
 
-import java.lang.reflect.Layer;
-import java.lang.reflect.Module;
 import java.io.*;
 import java.util.*;
 import javax.annotation.processing.*;
--- a/langtools/test/tools/javac/warnings/VerifyLintDescriptions.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/langtools/test/tools/javac/warnings/VerifyLintDescriptions.java	Tue Apr 18 22:25:33 2017 +0200
@@ -30,8 +30,6 @@
  *          jdk.compiler/com.sun.tools.javac.util
  */
 
-import java.lang.reflect.Layer;
-import java.lang.reflect.Module;
 import java.util.ArrayList;
 import java.util.List;
 import java.util.Locale;
@@ -42,7 +40,7 @@
 
 public class VerifyLintDescriptions {
     public static void main(String... args) {
-        Layer boot = Layer.boot();
+        ModuleLayer boot = ModuleLayer.boot();
         Module jdk_compiler = boot.findModule("jdk.compiler").get();
         ResourceBundle b = ResourceBundle.getBundle("com.sun.tools.javac.resources.javac",
                                                     Locale.US,
--- a/langtools/test/tools/javadoc/CheckResourceKeys.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/langtools/test/tools/javadoc/CheckResourceKeys.java	Tue Apr 18 22:25:33 2017 +0200
@@ -32,8 +32,6 @@
  */
 
 import java.io.*;
-import java.lang.reflect.Layer;
-import java.lang.reflect.Module;
 import java.util.*;
 import javax.tools.*;
 import com.sun.tools.classfile.*;
@@ -229,7 +227,7 @@
      * Get the set of keys from the javadoc resource bundles.
      */
     Set<String> getResourceKeys() {
-        Module jdk_javadoc = Layer.boot().findModule("jdk.javadoc").get();
+        Module jdk_javadoc = ModuleLayer.boot().findModule("jdk.javadoc").get();
         String[] names = {
                 "com.sun.tools.doclets.formats.html.resources.standard",
                 "com.sun.tools.doclets.internal.toolkit.resources.doclets",
--- a/make/RunTests.gmk	Tue Apr 18 13:19:42 2017 -0400
+++ b/make/RunTests.gmk	Tue Apr 18 22:25:33 2017 +0200
@@ -160,6 +160,7 @@
 ifeq ($(TEST), )
   $(info No test selection given in TEST!)
   $(info Please use e.g. 'run-test TEST=tier1' or 'run-test-tier1')
+  $(info See common/doc/testing.[md|html] for help)
   $(error Cannot continue)
 endif
 
@@ -182,6 +183,7 @@
 
 ifneq ($(UNKNOWN_TEST), )
   $(info Unknown test selection: '$(UNKNOWN_TEST)')
+  $(info See common/doc/testing.[md|html] for help)
   $(error Cannot continue)
 endif
 
--- a/make/UpdateBuildDocs.gmk	Tue Apr 18 13:19:42 2017 -0400
+++ b/make/UpdateBuildDocs.gmk	Tue Apr 18 22:25:33 2017 +0200
@@ -47,6 +47,7 @@
 # Remaining parameters are named arguments. These include:
 #   SOURCE_FILE  The markdown source file
 #   TARGET_DIR   The directory where to store the generated html file
+#   OPTIONS      Additional options to pandoc
 #
 SetupMarkdownToHtml = $(NamedParamsMacroTemplate)
 define SetupMarkdownToHtmlBody
@@ -65,12 +66,13 @@
 	$$(call LogInfo, Converting $$(notdir $1) to html)
 	$$(call MakeDir, $$($1_TARGET_DIR) $$(MAKESUPPORT_OUTPUTDIR)/markdown)
 	$$(call ExecuteWithLog, $$(MAKESUPPORT_OUTPUTDIR)/markdown/$1, \
-	    $$(PANDOC) -f markdown -t html --standalone '$$<' -o '$$@')
-	TOO_LONG_LINES=`$$(GREP) -E -e '^.{80}.+$$$$' $$<` ; \
-	if [ "x$$TOO_LONG_LINES" != x ]; then \
+	    $$(PANDOC) $$($1_OPTIONS) -f markdown -t html --standalone \
+	    --css 'http://openjdk.java.net/page.css' '$$<' -o '$$@')
+	TOO_LONG_LINES=`$$(GREP) -E -e '^.{80}.+$$$$' $$<` || true ; \
+	if [ "x$$$$TOO_LONG_LINES" != x ]; then \
 	  $$(ECHO) "Warning: Unsuitable markdown in $$<:" ; \
 	  $$(ECHO) "The following lines are longer than 80 characters:" ; \
-	  $$(GREP) -E -e '^.{80}.+$$$$' $$< ; \
+	  $$(GREP) -E -n -e '^.{80}.+$$$$' $$< || true ; \
 	fi
 
   $1 := $$($1_OUTPUT_FILE)
@@ -80,12 +82,17 @@
 
 ################################################################################
 
-BUILD_DOCS_DIR := $(TOPDIR)/common/doc
-BUILD_DOCS_MD_FILE := building.md
+DOCS_DIR := $(TOPDIR)/common/doc
 
 $(eval $(call SetupMarkdownToHtml, building, \
-  SOURCE_FILE := $(BUILD_DOCS_DIR)/$(BUILD_DOCS_MD_FILE), \
-  TARGET_DIR := $(BUILD_DOCS_DIR), \
+  SOURCE_FILE := $(DOCS_DIR)/building.md, \
+  TARGET_DIR := $(DOCS_DIR), \
+))
+
+$(eval $(call SetupMarkdownToHtml, testing, \
+  SOURCE_FILE := $(DOCS_DIR)/testing.md, \
+  TARGET_DIR := $(DOCS_DIR), \
+  OPTIONS := --toc, \
 ))
 
 ################################################################################
--- a/nashorn/.hgtags	Tue Apr 18 13:19:42 2017 -0400
+++ b/nashorn/.hgtags	Tue Apr 18 22:25:33 2017 +0200
@@ -399,3 +399,4 @@
 2cd29b339692524de64d049b329873facaff9727 jdk-9+162
 5e5e436543daea0c174d878d5e3ff8dd791e538a jdk-9+163
 b473fab09baab51a06ffba02eb06c7f5ee8578f7 jdk-9+164
+e36e62d3ea53c316f295b37bcc19867fbf510235 jdk-9+165
--- a/nashorn/src/jdk.dynalink/share/classes/jdk/dynalink/beans/CallerSensitiveDynamicMethod.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/nashorn/src/jdk.dynalink/share/classes/jdk/dynalink/beans/CallerSensitiveDynamicMethod.java	Tue Apr 18 22:25:33 2017 +0200
@@ -92,7 +92,6 @@
 import java.lang.reflect.Member;
 import java.lang.reflect.Method;
 import java.lang.reflect.Modifier;
-import java.lang.reflect.Module;
 import java.security.AccessControlContext;
 import java.security.AccessController;
 import java.security.PrivilegedAction;
--- a/nashorn/src/jdk.dynalink/share/classes/jdk/dynalink/beans/CheckRestrictedPackage.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/nashorn/src/jdk.dynalink/share/classes/jdk/dynalink/beans/CheckRestrictedPackage.java	Tue Apr 18 22:25:33 2017 +0200
@@ -84,7 +84,6 @@
 package jdk.dynalink.beans;
 
 import java.lang.reflect.Modifier;
-import java.lang.reflect.Module;
 import java.security.AccessControlContext;
 import java.security.AccessController;
 import java.security.PrivilegedAction;
--- a/nashorn/src/jdk.dynalink/share/classes/jdk/dynalink/linker/support/Lookup.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/nashorn/src/jdk.dynalink/share/classes/jdk/dynalink/linker/support/Lookup.java	Tue Apr 18 22:25:33 2017 +0200
@@ -89,7 +89,6 @@
 import java.lang.reflect.Constructor;
 import java.lang.reflect.Executable;
 import java.lang.reflect.Field;
-import java.lang.reflect.Module;
 import java.lang.reflect.Method;
 
 /**
--- a/nashorn/src/jdk.dynalink/share/classes/module-info.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/nashorn/src/jdk.dynalink/share/classes/module-info.java	Tue Apr 18 22:25:33 2017 +0200
@@ -217,6 +217,7 @@
  * from B will get a chance to link the call site in A when it encounters the
  * object from B.
  *
+ * @moduleGraph
  * @since 9
  */
 module jdk.dynalink {
--- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/Context.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/Context.java	Tue Apr 18 22:25:33 2017 +0200
@@ -51,9 +51,7 @@
 import java.lang.module.ModuleReader;
 import java.lang.module.ModuleReference;
 import java.lang.reflect.Field;
-import java.lang.reflect.Layer;
 import java.lang.reflect.Modifier;
-import java.lang.reflect.Module;
 import java.net.MalformedURLException;
 import java.net.URL;
 import java.nio.file.Path;
@@ -378,7 +376,7 @@
     static final boolean javaSqlFound, javaSqlRowsetFound;
 
     static {
-        final Layer boot = Layer.boot();
+        final ModuleLayer boot = ModuleLayer.boot();
         javaSqlFound = boot.findModule("java.sql").isPresent();
         javaSqlRowsetFound = boot.findModule("java.sql.rowset").isPresent();
     }
@@ -1334,7 +1332,7 @@
      * @return the new Module
      */
     static Module createModuleTrusted(final ModuleDescriptor descriptor, final ClassLoader loader) {
-        return createModuleTrusted(Layer.boot(), descriptor, loader);
+        return createModuleTrusted(ModuleLayer.boot(), descriptor, loader);
     }
 
     /**
@@ -1346,7 +1344,7 @@
      * @param loader the class loader of the module
      * @return the new Module
      */
-    static Module createModuleTrusted(final Layer parent, final ModuleDescriptor descriptor, final ClassLoader loader) {
+    static Module createModuleTrusted(final ModuleLayer parent, final ModuleDescriptor descriptor, final ClassLoader loader) {
         final String mn = descriptor.name();
 
         final ModuleReference mref = new ModuleReference(descriptor, null) {
@@ -1374,8 +1372,8 @@
         final Configuration cf = parent.configuration()
                 .resolve(finder, ModuleFinder.of(), Set.of(mn));
 
-        final PrivilegedAction<Layer> pa = () -> parent.defineModules(cf, name -> loader);
-        final Layer layer = AccessController.doPrivileged(pa, GET_LOADER_ACC_CTXT);
+        final PrivilegedAction<ModuleLayer> pa = () -> parent.defineModules(cf, name -> loader);
+        final ModuleLayer layer = AccessController.doPrivileged(pa, GET_LOADER_ACC_CTXT);
 
         final Module m = layer.findModule(mn).get();
         assert m.getLayer() == layer;
@@ -1796,7 +1794,7 @@
                 collect(Collectors.toSet());
         }
 
-        final Layer boot = Layer.boot();
+        final ModuleLayer boot = ModuleLayer.boot();
         final Configuration conf = boot.configuration().
             resolve(mf, ModuleFinder.of(), rootMods);
         final String firstMod = rootMods.iterator().next();
--- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/NashornLoader.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/NashornLoader.java	Tue Apr 18 22:25:33 2017 +0200
@@ -34,7 +34,6 @@
 import java.net.MalformedURLException;
 import java.net.URL;
 import java.net.URLClassLoader;
-import java.lang.reflect.Module;
 import java.security.AccessController;
 import java.security.CodeSource;
 import java.security.Permission;
--- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/ScriptLoader.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/ScriptLoader.java	Tue Apr 18 22:25:33 2017 +0200
@@ -27,7 +27,6 @@
 
 import java.lang.module.ModuleDescriptor;
 import java.lang.module.ModuleDescriptor.Modifier;
-import java.lang.reflect.Module;
 import java.security.CodeSource;
 import java.util.Objects;
 import java.util.Set;
--- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/StructureLoader.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/StructureLoader.java	Tue Apr 18 22:25:33 2017 +0200
@@ -32,7 +32,6 @@
 
 import java.lang.module.ModuleDescriptor;
 import java.lang.module.ModuleDescriptor.Modifier;
-import java.lang.reflect.Module;
 import java.security.ProtectionDomain;
 import java.util.Set;
 import jdk.nashorn.internal.codegen.ObjectClassGenerator;
--- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/linker/JavaAdapterClassLoader.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/linker/JavaAdapterClassLoader.java	Tue Apr 18 22:25:33 2017 +0200
@@ -27,7 +27,6 @@
 
 import java.lang.reflect.InvocationTargetException;
 import java.lang.reflect.Method;
-import java.lang.reflect.Module;
 import java.security.AccessControlContext;
 import java.security.AccessController;
 import java.security.PrivilegedAction;
--- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/scripts/ModuleGraphManipulator.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/scripts/ModuleGraphManipulator.java	Tue Apr 18 22:25:33 2017 +0200
@@ -25,7 +25,6 @@
 
 package jdk.nashorn.internal.scripts;
 
-import java.lang.reflect.Module;
 import jdk.nashorn.api.scripting.JSObject;
 
 /**
--- a/nashorn/src/jdk.scripting.nashorn/share/classes/module-info.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/nashorn/src/jdk.scripting.nashorn/share/classes/module-info.java	Tue Apr 18 22:25:33 2017 +0200
@@ -90,6 +90,7 @@
 In addition to {@code Java}, Nashorn also exposes some other non-standard built-in objects:
 {@code JSAdapter}, {@code JavaImporter}, {@code Packages}
 
+@moduleGraph
 @since 9
  */
 module jdk.scripting.nashorn {
--- a/nashorn/test/TEST.ROOT	Tue Apr 18 13:19:42 2017 -0400
+++ b/nashorn/test/TEST.ROOT	Tue Apr 18 22:25:33 2017 +0200
@@ -8,7 +8,7 @@
 groups=TEST.groups
 
 # Minimum jtreg version
-requiredVersion=4.2 b04
+requiredVersion=4.2 b07
 
 # Use new module options
 useNewOptions=true
--- a/nashorn/test/src/jdk/nashorn/test/models/Reflector.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/nashorn/test/src/jdk/nashorn/test/models/Reflector.java	Tue Apr 18 22:25:33 2017 +0200
@@ -29,7 +29,6 @@
 import java.lang.reflect.Executable;
 import java.lang.reflect.Field;
 import java.lang.reflect.Method;
-import java.lang.reflect.Module;
 import jdk.nashorn.internal.runtime.Context;
 
 /**
--- a/test/lib/jdk/test/lib/JDKToolLauncher.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/test/lib/jdk/test/lib/JDKToolLauncher.java	Tue Apr 18 22:25:33 2017 +0200
@@ -24,9 +24,7 @@
 package jdk.test.lib;
 
 import java.util.ArrayList;
-import java.util.Arrays;
 import java.util.List;
-import jdk.test.lib.process.ProcessTools;
 
 /**
  * A utility for constructing command lines for starting JDK tool processes.
@@ -59,7 +57,6 @@
         } else {
             executable = JDKToolFinder.getTestJDKTool(tool);
         }
-        vmArgs.addAll(Arrays.asList(ProcessTools.getPlatformSpecificVMArgs()));
     }
 
     /**
--- a/test/lib/jdk/test/lib/cli/CommandLineOptionTest.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/test/lib/jdk/test/lib/cli/CommandLineOptionTest.java	Tue Apr 18 22:25:33 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -28,6 +28,7 @@
 import java.util.Collections;
 import java.util.function.BooleanSupplier;
 
+import jdk.test.lib.management.InputArguments;
 import jdk.test.lib.process.ExitCode;
 import jdk.test.lib.process.ProcessTools;
 import jdk.test.lib.process.OutputAnalyzer;
@@ -105,7 +106,7 @@
                     throws Throwable {
         List<String> finalOptions = new ArrayList<>();
         if (addTestVMOptions) {
-            Collections.addAll(finalOptions, ProcessTools.getVmInputArgs());
+            Collections.addAll(finalOptions, InputArguments.getVmInputArgs());
             Collections.addAll(finalOptions, Utils.getTestJavaOpts());
         }
         Collections.addAll(finalOptions, options);
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/lib/jdk/test/lib/management/InputArguments.java	Tue Apr 18 22:25:33 2017 +0200
@@ -0,0 +1,41 @@
+/*
+ * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package jdk.test.lib.management;
+
+import java.lang.management.ManagementFactory;
+import java.lang.management.RuntimeMXBean;
+import java.util.List;
+
+public class InputArguments {
+    /**
+     * Gets the array of strings containing input arguments passed to the VM
+     *
+     * @return arguments
+     */
+    public static String[] getVmInputArgs() {
+        RuntimeMXBean runtime = ManagementFactory.getRuntimeMXBean();
+        List<String> args = runtime.getInputArguments();
+        return args.toArray(new String[args.size()]);
+    }
+}
--- a/test/lib/jdk/test/lib/process/ProcessTools.java	Tue Apr 18 13:19:42 2017 -0400
+++ b/test/lib/jdk/test/lib/process/ProcessTools.java	Tue Apr 18 22:25:33 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2013, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -28,13 +28,10 @@
 import java.io.InputStream;
 import java.io.OutputStream;
 import java.io.PrintStream;
-import java.lang.management.ManagementFactory;
-import java.lang.management.RuntimeMXBean;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Collections;
 import java.util.concurrent.CountDownLatch;
-import java.util.List;
 import java.util.Map;
 import java.util.concurrent.ExecutionException;
 import java.util.concurrent.Future;
@@ -45,7 +42,6 @@
 import java.util.stream.Collectors;
 
 import jdk.test.lib.JDKToolFinder;
-import jdk.test.lib.Platform;
 import jdk.test.lib.Utils;
 
 public final class ProcessTools {
@@ -66,23 +62,23 @@
     }
 
     /**
-    * Pumps stdout and stderr from running the process into a String.
-    *
-    * @param processHandler ProcessHandler to run.
-    * @return Output from process.
-    * @throws IOException If an I/O error occurs.
-    */
+     * Pumps stdout and stderr from running the process into a String.
+     *
+     * @param processHandler ProcessHandler to run.
+     * @return Output from process.
+     * @throws IOException If an I/O error occurs.
+     */
     public static OutputBuffer getOutput(ProcessBuilder processBuilder) throws IOException {
         return getOutput(processBuilder.start());
     }
 
     /**
-    * Pumps stdout and stderr the running process into a String.
-    *
-    * @param process Process to pump.
-    * @return Output from process.
-    * @throws IOException If an I/O error occurs.
-    */
+     * Pumps stdout and stderr the running process into a String.
+     *
+     * @param process Process to pump.
+     * @return Output from process.
+     * @throws IOException If an I/O error occurs.
+     */
     public static OutputBuffer getOutput(Process process) throws IOException {
         ByteArrayOutputStream stderrBuffer = new ByteArrayOutputStream();
         ByteArrayOutputStream stdoutBuffer = new ByteArrayOutputStream();
@@ -304,38 +300,14 @@
     public static long getProcessId() throws Exception {
         return ProcessHandle.current().getPid();
     }
-    /**
-     * Gets the array of strings containing input arguments passed to the VM
-     *
-     * @return arguments
-     */
-    public static String[] getVmInputArgs() {
-        RuntimeMXBean runtime = ManagementFactory.getRuntimeMXBean();
-        List<String> args = runtime.getInputArguments();
-        return args.toArray(new String[args.size()]);
-    }
 
-    /**
-     * Get platform specific VM arguments (e.g. -d64 on 64bit Solaris)
-     *
-     * @return String[] with platform specific arguments, empty if there are
-     *         none
-     */
-    public static String[] getPlatformSpecificVMArgs() {
-
-    if (Platform.is64bit() && Platform.isSolaris()) {
-            return new String[] { "-d64" };
-        }
-
-        return new String[] {};
-    }
 
 
     /**
      * Create ProcessBuilder using the java launcher from the jdk to be tested and
      * with any platform specific arguments prepended
      */
-    public static ProcessBuilder createJavaProcessBuilder(String... command) throws Exception {
+    public static ProcessBuilder createJavaProcessBuilder(String... command) {
         return createJavaProcessBuilder(false, command);
     }
 
@@ -348,12 +320,11 @@
      * @param command Arguments to pass to the java command.
      * @return The ProcessBuilder instance representing the java command.
      */
-    public static ProcessBuilder createJavaProcessBuilder(boolean addTestVmAndJavaOptions, String... command) throws Exception {
+    public static ProcessBuilder createJavaProcessBuilder(boolean addTestVmAndJavaOptions, String... command) {
         String javapath = JDKToolFinder.getJDKTool("java");
 
         ArrayList<String> args = new ArrayList<>();
         args.add(javapath);
-        Collections.addAll(args, getPlatformSpecificVMArgs());
 
         args.add("-cp");
         args.add(System.getProperty("java.class.path"));
@@ -386,26 +357,6 @@
 
     /**
      * Executes a test jvm process, waits for it to finish and returns the process output.
-     * The default jvm options from the test's run command, jtreg, test.vm.opts and test.java.opts, are added.
-     * The java from the test.jdk is used to execute the command.
-     *
-     * The command line will be like:
-     * {test.jdk}/bin/java {test.fromRun.opts} {test.vm.opts} {test.java.opts} cmds
-     *
-     * @param cmds User specifed arguments.
-     * @return The output from the process.
-     */
-    public static OutputAnalyzer executeTestJvmAllArgs(String... cmds) throws Throwable {
-        List<String> argsList = new ArrayList<>();
-        String[] testArgs = getVmInputArgs();
-        Collections.addAll(argsList, testArgs);
-        Collections.addAll(argsList, Utils.addTestJavaOpts(cmds));
-        ProcessBuilder pb = createJavaProcessBuilder(argsList.toArray(new String[argsList.size()]));
-        return executeProcess(pb);
-    }
-
-    /**
-     * Executes a test jvm process, waits for it to finish and returns the process output.
      * The default jvm options from jtreg, test.vm.opts and test.java.opts, are added.
      * The java from the test.jdk is used to execute the command.
      *