This commit is contained in:
Vladimir Kozlov 2017-07-05 18:14:48 -07:00
commit 62b03921aa
1655 changed files with 28941 additions and 130144 deletions

View file

@ -1,3 +1,4 @@
994036e74ab805bcc09afa0646be17a725bec42f jdk-9+175
94680c6d60ecd9ed3ffd1847706efde7eb947afc jdk-9+174 94680c6d60ecd9ed3ffd1847706efde7eb947afc jdk-9+174
6dd7fda42bab7ecf648cafb0a4e9b4ca11b3094f jdk-9+173 6dd7fda42bab7ecf648cafb0a4e9b4ca11b3094f jdk-9+173
dad6746278facbbea57dd462cb56fb743dc0a5f0 jdk-9+172 dad6746278facbbea57dd462cb56fb743dc0a5f0 jdk-9+172
@ -430,3 +431,4 @@ aa5b01f5e5620438fd39efdb2e2f6365a2c7d898 jdk-10+9
b0f2b8ff25a2209b2c807785d75f20e5086bbfc2 jdk-10+10 b0f2b8ff25a2209b2c807785d75f20e5086bbfc2 jdk-10+10
036dbf8b381798e5d31065109714d04d97bf98a4 jdk-10+11 036dbf8b381798e5d31065109714d04d97bf98a4 jdk-10+11
e6d70017f5b9adbb2ec82d826973d0251800a3c3 jdk-10+12 e6d70017f5b9adbb2ec82d826973d0251800a3c3 jdk-10+12
9927a9f16738e240ab7014f0118f41e314ef8f99 jdk-10+13

View file

@ -430,3 +430,5 @@ b94be69cbb1d2943b886bf2d458745756df146e4 jdk-10+9
88d7fd969e7df0e07a53b201cfd29393ca33ede9 jdk-9+173 88d7fd969e7df0e07a53b201cfd29393ca33ede9 jdk-9+173
5466f409346e0446ee9a6daeb7f5d75c8fc76823 jdk-9+174 5466f409346e0446ee9a6daeb7f5d75c8fc76823 jdk-9+174
8d4ed1e06fe184c9cb08c5b708e7d6f5c066644f jdk-10+12 8d4ed1e06fe184c9cb08c5b708e7d6f5c066644f jdk-10+12
8f7227c6012b0051ea4e0bcee040c627bf699b88 jdk-9+175
d67a3f1f057f7e31e12f33ebe3667cb73d252268 jdk-10+13

View file

@ -1 +1,2 @@
project=jdk10 project=jdk10
bugids=dup

View file

@ -18,14 +18,16 @@
</header> </header>
<nav id="TOC"> <nav id="TOC">
<ul> <ul>
<li><a href="#using-the-run-test-framework">Using the run-test framework</a></li> <li><a href="#using-the-run-test-framework">Using the run-test framework</a><ul>
<li><a href="#configuration">Configuration</a></li>
</ul></li>
<li><a href="#test-selection">Test selection</a><ul> <li><a href="#test-selection">Test selection</a><ul>
<li><a href="#jtreg">JTreg</a></li> <li><a href="#jtreg">JTReg</a></li>
<li><a href="#gtest">Gtest</a></li> <li><a href="#gtest">Gtest</a></li>
</ul></li> </ul></li>
<li><a href="#test-results-and-summary">Test results and summary</a></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="#test-suite-control">Test suite control</a><ul>
<li><a href="#jtreg-keywords">JTreg keywords</a></li> <li><a href="#jtreg-keywords">JTReg keywords</a></li>
<li><a href="#gtest-keywords">Gtest keywords</a></li> <li><a href="#gtest-keywords">Gtest keywords</a></li>
</ul></li> </ul></li>
</ul> </ul>
@ -41,14 +43,17 @@ $ make run-test-only TEST=&quot;gtest:LogTagSet gtest:LogTagSetDescriptions&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;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; $ make run-test TEST=&quot;jtreg:hotspot/test:hotspot_gc hotspot/test/native_sanity/JniVersion.java&quot;
$ make exploded-run-test TEST=hotspot_tier1</code></pre> $ make exploded-run-test TEST=hotspot_tier1</code></pre>
<h3 id="configuration">Configuration</h3>
<p>To be able to run JTReg tests, <code>configure</code> needs to know where to find the JTReg test framework. If it is not picked up automatically by configure, use the <code>--with-jtreg=&lt;path to jtreg home&gt;</code> option to point to the JTReg framework. Note that this option should point to the JTReg home, i.e. the top directory, containing <code>lib/jtreg.jar</code> etc. (An alternative is to set the <code>JT_HOME</code> environment variable to point to the JTReg home before running <code>configure</code>.)</p>
<h2 id="test-selection">Test selection</h2> <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>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>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> <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> <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>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>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>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> <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> <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>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>
@ -67,15 +72,15 @@ 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>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>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>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>All tests have their result stored in <code>build/$BUILD/test-results/$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> <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> <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>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>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>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>(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> <p>As far as possible, the names of the keywords have been standardized between test suites.</p>
<h3 id="jtreg-keywords">JTreg keywords</h3> <h3 id="jtreg-keywords">JTReg keywords</h3>
<h4 id="jobs">JOBS</h4> <h4 id="jobs">JOBS</h4>
<p>The test concurrency (<code>-concurrency</code>).</p> <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> <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>
@ -96,15 +101,15 @@ TEST FAILURE</code></pre>
<p>Defaults to <code>fail,error</code>.</p> <p>Defaults to <code>fail,error</code>.</p>
<h4 id="max_mem">MAX_MEM</h4> <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 (<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>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> <p>Defaults to 512m, except for hotspot, where it defaults to 0 (no limit).</p>
<h4 id="options">OPTIONS</h4> <h4 id="options">OPTIONS</h4>
<p>Additional options to the JTreg test framework.</p> <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> <p>Use <code>JTREG=&quot;OPTIONS=--help all&quot;</code> to see all available JTReg options.</p>
<h4 id="java_options">JAVA_OPTIONS</h4> <h4 id="java_options">JAVA_OPTIONS</h4>
<p>Additional Java options to JTreg (<code>-javaoption</code>).</p> <p>Additional Java options to JTReg (<code>-javaoption</code>).</p>
<h4 id="vm_options">VM_OPTIONS</h4> <h4 id="vm_options">VM_OPTIONS</h4>
<p>Additional VM options to JTreg (<code>-vmoption</code>).</p> <p>Additional VM options to JTReg (<code>-vmoption</code>).</p>
<h3 id="gtest-keywords">Gtest keywords</h3> <h3 id="gtest-keywords">Gtest keywords</h3>
<h4 id="repeat">REPEAT</h4> <h4 id="repeat">REPEAT</h4>
<p>The number of times to repeat the tests (<code>--gtest_repeat</code>).</p> <p>The number of times to repeat the tests (<code>--gtest_repeat</code>).</p>

View file

@ -22,6 +22,15 @@ Some example command-lines:
$ make run-test TEST="jtreg:hotspot/test:hotspot_gc hotspot/test/native_sanity/JniVersion.java" $ make run-test TEST="jtreg:hotspot/test:hotspot_gc hotspot/test/native_sanity/JniVersion.java"
$ make exploded-run-test TEST=hotspot_tier1 $ make exploded-run-test TEST=hotspot_tier1
### Configuration
To be able to run JTReg tests, `configure` needs to know where to find the
JTReg test framework. If it is not picked up automatically by configure, use
the `--with-jtreg=<path to jtreg home>` option to point to the JTReg framework.
Note that this option should point to the JTReg home, i.e. the top directory,
containing `lib/jtreg.jar` etc. (An alternative is to set the `JT_HOME`
environment variable to point to the JTReg home before running `configure`.)
## Test selection ## Test selection
All functionality is available using the run-test make target. In this use All functionality is available using the run-test make target. In this use
@ -30,7 +39,7 @@ 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. 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 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 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 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="tier1"`, but the latter is more tab-completion friendly. For more complex
test runs, the `run-test TEST="x"` solution needs to be used. test runs, the `run-test TEST="x"` solution needs to be used.
@ -42,9 +51,9 @@ 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` can always submit a list of fully qualified test descriptors in the `TEST`
variable if you want to shortcut the parser. variable if you want to shortcut the parser.
### JTreg ### JTReg
JTreg test groups can be specified either without a test root, e.g. `:tier1` 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. (or `tier1`, the initial colon is optional), or with, e.g.
`hotspot/test:tier1`, `jdk/test:jdk_util`. `hotspot/test:tier1`, `jdk/test:jdk_util`.
@ -52,10 +61,10 @@ 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 will be added. Otherwise, only the group from the specified test root will be
added. added.
Individual JTreg tests or directories containing JTreg tests can also be Individual JTReg tests or directories containing JTReg tests can also be
specified, like `hotspot/test/native_sanity/JniVersion.java` or specified, like `hotspot/test/native_sanity/JniVersion.java` or
`hotspot/test/native_sanity`. You can also specify an absolute path, to point `hotspot/test/native_sanity`. You can also specify an absolute path, to point
to a JTreg test outside the source tree. to a JTReg test outside the source tree.
As long as the test groups or test paths can be uniquely resolved, you do not 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 need to enter the `jtreg:` prefix. If this is not possible, or if you want to
@ -99,7 +108,7 @@ error, timeout or other problems.
In case of test failures, `make run-test` will exit with a non-zero exit value. 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`, All tests have their result stored in `build/$BUILD/test-results/$TEST_ID`,
where TEST_ID is a path-safe conversion from the fully qualified test 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 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 `jtreg_jdk_test_tier1`. This path is also printed in the log at the end of the
@ -115,7 +124,7 @@ It is possible to control various aspects of the test suites using make control
variables. variables.
These variables use a keyword=value approach to allow multiple values to be 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 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 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 setting `JTREG_JOBS=1 JTREG_TIMEOUT=8`, but using the keyword format means that
the `JTREG` variable is parsed and verified for correctness, so the `JTREG` variable is parsed and verified for correctness, so
@ -136,7 +145,7 @@ proper quoting of command line arguments through.)
As far as possible, the names of the keywords have been standardized between As far as possible, the names of the keywords have been standardized between
test suites. test suites.
### JTreg keywords ### JTReg keywords
#### JOBS #### JOBS
The test concurrency (`-concurrency`). The test concurrency (`-concurrency`).
@ -174,21 +183,21 @@ Defaults to `fail,error`.
#### MAX_MEM #### MAX_MEM
Limit memory consumption (`-Xmx` and `-vmoption:-Xmx`, or none). Limit memory consumption (`-Xmx` and `-vmoption:-Xmx`, or none).
Limit memory consumption for JTreg test framework and VM under test. Set to 0 Limit memory consumption for JTReg test framework and VM under test. Set to 0
to disable the limits. to disable the limits.
Defaults to 512m, except for hotspot, where it defaults to 0 (no limit). Defaults to 512m, except for hotspot, where it defaults to 0 (no limit).
#### OPTIONS #### OPTIONS
Additional options to the JTreg test framework. Additional options to the JTReg test framework.
Use `JTREG="OPTIONS=--help all"` to see all available JTreg options. Use `JTREG="OPTIONS=--help all"` to see all available JTReg options.
#### JAVA_OPTIONS #### JAVA_OPTIONS
Additional Java options to JTreg (`-javaoption`). Additional Java options to JTReg (`-javaoption`).
#### VM_OPTIONS #### VM_OPTIONS
Additional VM options to JTreg (`-vmoption`). Additional VM options to JTReg (`-vmoption`).
### Gtest keywords ### Gtest keywords

View file

@ -430,3 +430,5 @@ c62e5964cfcf144d8f72e9ba69757897785349a9 jdk-9+171
534ba4f8cfcf12accc5b9adb943103f2ff79fe16 jdk-9+173 534ba4f8cfcf12accc5b9adb943103f2ff79fe16 jdk-9+173
3615768c12904e29bb2ec1b506cd4633cd8a9ced jdk-9+174 3615768c12904e29bb2ec1b506cd4633cd8a9ced jdk-9+174
00ae6307d78bac49883ddc85d687aa88c49f3971 jdk-10+12 00ae6307d78bac49883ddc85d687aa88c49f3971 jdk-10+12
dc78a3dd6b3a4f11cdae8a3e3d160e6a78bc7838 jdk-9+175
564fced058bd2c8375e9104aa8f9494642cd7bdd jdk-10+13

View file

@ -1 +1,2 @@
project=jdk10 project=jdk10
bugids=dup

View file

@ -26,18 +26,21 @@
/** /**
* Defines the Java binding of the OMG CORBA APIs, and the RMI-IIOP API. * Defines the Java binding of the OMG CORBA APIs, and the RMI-IIOP API.
* *
* <p> This module is upgradeble.
*
* @moduleGraph * @moduleGraph
* @since 9 * @since 9
*/ */
@Deprecated(since="9", forRemoval=true) @Deprecated(since="9", forRemoval=true)
module java.corba { module java.corba {
requires transitive java.desktop;
requires transitive java.rmi;
requires java.logging; requires java.logging;
requires java.naming; requires java.naming;
requires java.transaction; requires java.transaction;
requires jdk.unsupported; requires jdk.unsupported;
requires transitive java.desktop;
requires transitive java.rmi;
exports javax.activity; exports javax.activity;
exports javax.rmi; exports javax.rmi;
exports javax.rmi.CORBA; exports javax.rmi.CORBA;

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2014, 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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -29,7 +29,7 @@ package org.omg.CORBA;
/** /**
* This Helper class is used to facilitate the marshalling of {@code Bounds}. * This Helper class is used to facilitate the marshalling of {@code Bounds}.
* For more information on Helper files, see * For more information on Helper files, see
* <a href="doc-files/generatedfiles.html#helper"> * <a href="{@docRoot}/org/omg/CORBA/doc-files/generatedfiles.html#helper">
* "Generated Files: Helper Files"</a>. * "Generated Files: Helper Files"</a>.
*/ */

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2014, 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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -30,7 +30,7 @@ package org.omg.CORBA.ORBPackage;
* This Helper class is used to facilitate the marshalling of * This Helper class is used to facilitate the marshalling of
* {@code ORBPackage/InvalidName}. * {@code ORBPackage/InvalidName}.
* For more information on Helper files, see * For more information on Helper files, see
* <a href="doc-files/generatedfiles.html#helper"> * <a href="{@docRoot}/org/omg/CORBA/doc-files/generatedfiles.html#helper">
* "Generated Files: Helper Files"</a>. * "Generated Files: Helper Files"</a>.
*/ */

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2014, 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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -30,7 +30,7 @@ package org.omg.CORBA.TypeCodePackage;
* This Helper class is used to facilitate the marshalling of * This Helper class is used to facilitate the marshalling of
* {@code TypeCodePackage/BadKind}. * {@code TypeCodePackage/BadKind}.
* For more information on Helper files, see * For more information on Helper files, see
* <a href="doc-files/generatedfiles.html#helper"> * <a href="{@docRoot}/org/omg/CORBA/doc-files/generatedfiles.html#helper">
* "Generated Files: Helper Files"</a>. * "Generated Files: Helper Files"</a>.
*/ */

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2014, 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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -30,7 +30,7 @@ package org.omg.CORBA.TypeCodePackage;
* This Helper class is used to facilitate the marshalling of * This Helper class is used to facilitate the marshalling of
* {@code TypeCodePackage/Bounds}. * {@code TypeCodePackage/Bounds}.
* For more information on Helper files, see * For more information on Helper files, see
* <a href="doc-files/generatedfiles.html#helper"> * <a href="{@docRoot}/org/omg/CORBA/doc-files/generatedfiles.html#helper">
* "Generated Files: Helper Files"</a>. * "Generated Files: Helper Files"</a>.
*/ */

View file

@ -590,3 +590,5 @@ c6cd3ec8d46b034e57c86399380ffcf7f25706e4 jdk-10+10
e64b1cb48d6e7703928a9d1da106fc27f8cb65fd jdk-9+173 e64b1cb48d6e7703928a9d1da106fc27f8cb65fd jdk-9+173
944791f8160185bffa13fbb821fc09b6198f1f25 jdk-9+174 944791f8160185bffa13fbb821fc09b6198f1f25 jdk-9+174
070aa7a2eb14c4645f7eb31384cba0a2ba72a4b5 jdk-10+12 070aa7a2eb14c4645f7eb31384cba0a2ba72a4b5 jdk-10+12
8f04d457168b9f1f4a1b2c37f49e0513ca9d33a7 jdk-9+175
a9da03357f190807591177fe9846d6e68ad64fc0 jdk-10+13

View file

@ -1 +1,2 @@
project=jdk10 project=jdk10
bugids=dup

View file

@ -188,7 +188,6 @@ JVM_Yield
JVM_AddModuleExports JVM_AddModuleExports
JVM_AddModuleExportsToAll JVM_AddModuleExportsToAll
JVM_AddModuleExportsToAllUnnamed JVM_AddModuleExportsToAllUnnamed
JVM_AddModulePackage
JVM_AddReadsModule JVM_AddReadsModule
JVM_DefineModule JVM_DefineModule
JVM_SetBootLoaderUnnamedModule JVM_SetBootLoaderUnnamedModule

View file

@ -62,6 +62,7 @@ BUILD_HOTSPOT_JTREG_NATIVE_SRC += \
$(HOTSPOT_TOPDIR)/test/compiler/floatingpoint/ \ $(HOTSPOT_TOPDIR)/test/compiler/floatingpoint/ \
$(HOTSPOT_TOPDIR)/test/compiler/calls \ $(HOTSPOT_TOPDIR)/test/compiler/calls \
$(HOTSPOT_TOPDIR)/test/serviceability/jvmti/GetNamedModule \ $(HOTSPOT_TOPDIR)/test/serviceability/jvmti/GetNamedModule \
$(HOTSPOT_TOPDIR)/test/serviceability/jvmti/IsModifiableModule \
$(HOTSPOT_TOPDIR)/test/serviceability/jvmti/AddModuleReads \ $(HOTSPOT_TOPDIR)/test/serviceability/jvmti/AddModuleReads \
$(HOTSPOT_TOPDIR)/test/serviceability/jvmti/AddModuleExportsAndOpens \ $(HOTSPOT_TOPDIR)/test/serviceability/jvmti/AddModuleExportsAndOpens \
$(HOTSPOT_TOPDIR)/test/serviceability/jvmti/AddModuleUsesAndProvides \ $(HOTSPOT_TOPDIR)/test/serviceability/jvmti/AddModuleUsesAndProvides \
@ -92,6 +93,7 @@ ifeq ($(TOOLCHAIN_TYPE), solstudio)
BUILD_HOTSPOT_JTREG_LIBRARIES_LIBS_liboverflow := -lc BUILD_HOTSPOT_JTREG_LIBRARIES_LIBS_liboverflow := -lc
BUILD_HOTSPOT_JTREG_LIBRARIES_LIBS_libSimpleClassFileLoadHook := -lc BUILD_HOTSPOT_JTREG_LIBRARIES_LIBS_libSimpleClassFileLoadHook := -lc
BUILD_HOTSPOT_JTREG_LIBRARIES_LIBS_libGetNamedModuleTest := -lc BUILD_HOTSPOT_JTREG_LIBRARIES_LIBS_libGetNamedModuleTest := -lc
BUILD_HOTSPOT_JTREG_LIBRARIES_LIBS_libIsModifiableModuleTest := -lc
BUILD_HOTSPOT_JTREG_LIBRARIES_LDFLAGS_libAddModuleReadsTest := -lc BUILD_HOTSPOT_JTREG_LIBRARIES_LDFLAGS_libAddModuleReadsTest := -lc
BUILD_HOTSPOT_JTREG_LIBRARIES_LDFLAGS_libAddModuleExportsAndOpensTest := -lc BUILD_HOTSPOT_JTREG_LIBRARIES_LDFLAGS_libAddModuleExportsAndOpensTest := -lc
BUILD_HOTSPOT_JTREG_LIBRARIES_LDFLAGS_libAddModuleUsesAndProvidesTest := -lc BUILD_HOTSPOT_JTREG_LIBRARIES_LDFLAGS_libAddModuleUsesAndProvidesTest := -lc

View file

@ -598,12 +598,12 @@ void LIRGenerator::do_ArithmeticOp_Int(ArithmeticOp* x) {
} else { } else {
assert (x->op() == Bytecodes::_imul, "expect imul"); assert (x->op() == Bytecodes::_imul, "expect imul");
if (right.is_constant()) { if (right.is_constant()) {
int c = right.get_jint_constant(); jint c = right.get_jint_constant();
if (! is_power_of_2(c) && ! is_power_of_2(c + 1) && ! is_power_of_2(c - 1)) { if (c > 0 && c < max_jint && (is_power_of_2(c) || is_power_of_2(c - 1) || is_power_of_2(c + 1))) {
// Cannot use constant op. right_arg->dont_load_item();
right.load_item();
} else { } else {
right.dont_load_item(); // Cannot use constant op.
right_arg->load_item();
} }
} else { } else {
right.load_item(); right.load_item();

View file

@ -923,8 +923,8 @@ void LIRGenerator::do_ArithmeticOp_Int(ArithmeticOp* x) {
} else { } else {
left_arg->load_item(); left_arg->load_item();
if (x->op() == Bytecodes::_imul && right_arg->is_constant()) { if (x->op() == Bytecodes::_imul && right_arg->is_constant()) {
int c = right_arg->get_jint_constant(); jint c = right_arg->get_jint_constant();
if (c > 0 && (is_power_of_2(c) || is_power_of_2(c - 1) || is_power_of_2(c + 1))) { if (c > 0 && c < max_jint && (is_power_of_2(c) || is_power_of_2(c - 1) || is_power_of_2(c + 1))) {
right_arg->dont_load_item(); right_arg->dont_load_item();
} else { } else {
right_arg->load_item(); right_arg->load_item();

View file

@ -234,8 +234,8 @@ void LIRGenerator::cmp_reg_mem(LIR_Condition condition, LIR_Opr reg, LIR_Opr bas
} }
bool LIRGenerator::strength_reduce_multiply(LIR_Opr left, int c, LIR_Opr result, LIR_Opr tmp) { bool LIRGenerator::strength_reduce_multiply(LIR_Opr left, jint c, LIR_Opr result, LIR_Opr tmp) {
if (tmp->is_valid()) { if (tmp->is_valid() && c > 0 && c < max_jint) {
if (is_power_of_2(c + 1)) { if (is_power_of_2(c + 1)) {
__ move(left, tmp); __ move(left, tmp);
__ shift_left(left, log2_intptr(c + 1), left); __ shift_left(left, log2_intptr(c + 1), left);
@ -603,8 +603,8 @@ void LIRGenerator::do_ArithmeticOp_Int(ArithmeticOp* x) {
bool use_constant = false; bool use_constant = false;
bool use_tmp = false; bool use_tmp = false;
if (right_arg->is_constant()) { if (right_arg->is_constant()) {
int iconst = right_arg->get_jint_constant(); jint iconst = right_arg->get_jint_constant();
if (iconst > 0) { if (iconst > 0 && iconst < max_jint) {
if (is_power_of_2(iconst)) { if (is_power_of_2(iconst)) {
use_constant = true; use_constant = true;
} else if (is_power_of_2(iconst - 1) || is_power_of_2(iconst + 1)) { } else if (is_power_of_2(iconst - 1) || is_power_of_2(iconst + 1)) {

View file

@ -23,8 +23,15 @@
* questions. * questions.
*/ */
/**
* Defines the Ahead-of-Time (AOT) compiler, <em>{@index jaotc jaotc tool}</em>,
* for compiling Java classes into AOT library.
*
* @moduleGraph
* @since 9
*/
module jdk.aot { module jdk.aot {
requires jdk.management;
requires jdk.internal.vm.ci; requires jdk.internal.vm.ci;
requires jdk.internal.vm.compiler; requires jdk.internal.vm.compiler;
requires jdk.management;
} }

View file

@ -644,4 +644,9 @@ final class CompilerToVM {
* {@link Long} * {@link Long}
*/ */
native Object getFlagValue(String name); native Object getFlagValue(String name);
/**
* Gets the host class for {@code type}.
*/
native HotSpotResolvedObjectTypeImpl getHostClass(HotSpotResolvedObjectTypeImpl type);
} }

View file

@ -411,6 +411,14 @@ final class HotSpotResolvedObjectTypeImpl extends HotSpotResolvedJavaType implem
return false; return false;
} }
@Override
public ResolvedJavaType getHostClass() {
if (isArray()) {
return null;
}
return compilerToVM().getHostClass(this);
}
@Override @Override
public boolean isJavaLangObject() { public boolean isJavaLangObject() {
return javaClass.equals(Object.class); return javaClass.equals(Object.class);

View file

@ -153,6 +153,11 @@ public final class HotSpotResolvedPrimitiveType extends HotSpotResolvedJavaType
return other.equals(this); return other.equals(this);
} }
@Override
public ResolvedJavaType getHostClass() {
return null;
}
@Override @Override
public JavaKind getJavaKind() { public JavaKind getJavaKind() {
return kind; return kind;

View file

@ -104,6 +104,13 @@ public interface ResolvedJavaType extends JavaType, ModifiersProvider, Annotated
*/ */
boolean isAssignableFrom(ResolvedJavaType other); boolean isAssignableFrom(ResolvedJavaType other);
/**
* Returns the {@link ResolvedJavaType} object representing the host class of this VM anonymous
* class (as opposed to the unrelated concept specified by {@link Class#isAnonymousClass()}) or
* {@code null} if this object does not represent a VM anonymous class.
*/
ResolvedJavaType getHostClass();
/** /**
* Returns true if this type is exactly the type {@link java.lang.Object}. * Returns true if this type is exactly the type {@link java.lang.Object}.
*/ */

View file

@ -26,11 +26,9 @@
module jdk.internal.vm.compiler { module jdk.internal.vm.compiler {
requires java.instrument; requires java.instrument;
requires java.management; requires java.management;
requires jdk.management;
requires jdk.internal.vm.ci; requires jdk.internal.vm.ci;
requires jdk.management;
// sun.misc.Unsafe is used requires jdk.unsupported; // sun.misc.Unsafe is used
requires jdk.unsupported;
uses org.graalvm.compiler.code.DisassemblerProvider; uses org.graalvm.compiler.code.DisassemblerProvider;
uses org.graalvm.compiler.core.match.MatchStatementSet; uses org.graalvm.compiler.core.match.MatchStatementSet;

View file

@ -548,8 +548,8 @@ void LIRGenerator::arithmetic_op(Bytecodes::Code code, LIR_Opr result, LIR_Opr l
bool did_strength_reduce = false; bool did_strength_reduce = false;
if (right->is_constant()) { if (right->is_constant()) {
int c = right->as_jint(); jint c = right->as_jint();
if (is_power_of_2(c)) { if (c > 0 && is_power_of_2(c)) {
// do not need tmp here // do not need tmp here
__ shift_left(left_op, exact_log2(c), result_op); __ shift_left(left_op, exact_log2(c), result_op);
did_strength_reduce = true; did_strength_reduce = true;

View file

@ -313,7 +313,7 @@ class LIRGenerator: public InstructionVisitor, public BlockClosure {
// is_strictfp is only needed for mul and div (and only generates different code on i486) // is_strictfp is only needed for mul and div (and only generates different code on i486)
void arithmetic_op(Bytecodes::Code code, LIR_Opr result, LIR_Opr left, LIR_Opr right, bool is_strictfp, LIR_Opr tmp, CodeEmitInfo* info = NULL); void arithmetic_op(Bytecodes::Code code, LIR_Opr result, LIR_Opr left, LIR_Opr right, bool is_strictfp, LIR_Opr tmp, CodeEmitInfo* info = NULL);
// machine dependent. returns true if it emitted code for the multiply // machine dependent. returns true if it emitted code for the multiply
bool strength_reduce_multiply(LIR_Opr left, int constant, LIR_Opr result, LIR_Opr tmp); bool strength_reduce_multiply(LIR_Opr left, jint constant, LIR_Opr result, LIR_Opr tmp);
void store_stack_parameter (LIR_Opr opr, ByteSize offset_from_sp_in_bytes); void store_stack_parameter (LIR_Opr opr, ByteSize offset_from_sp_in_bytes);

View file

@ -680,74 +680,6 @@ jobject Modules::get_module(Symbol* package_name, Handle h_loader, TRAPS) {
return NULL; return NULL;
} }
void Modules::add_module_package(jobject module, const char* package_name, TRAPS) {
ResourceMark rm(THREAD);
if (module == NULL) {
THROW_MSG(vmSymbols::java_lang_NullPointerException(),
"module is null");
}
if (package_name == NULL) {
THROW_MSG(vmSymbols::java_lang_NullPointerException(),
"package is null");
}
ModuleEntry* module_entry = get_module_entry(module, CHECK);
if (module_entry == NULL) {
THROW_MSG(vmSymbols::java_lang_IllegalArgumentException(),
"module is invalid");
}
if (!module_entry->is_named()) {
THROW_MSG(vmSymbols::java_lang_IllegalArgumentException(),
"module cannot be an unnamed module");
}
if (!verify_package_name(package_name)) {
THROW_MSG(vmSymbols::java_lang_IllegalArgumentException(),
err_msg("Invalid package name: %s", package_name));
}
ClassLoaderData *loader_data = module_entry->loader_data();
// Only modules defined to either the boot or platform class loader, can define a "java/" package.
if (!loader_data->is_the_null_class_loader_data() &&
!loader_data->is_platform_class_loader_data() &&
(strncmp(package_name, JAVAPKG, JAVAPKG_LEN) == 0 &&
(package_name[JAVAPKG_LEN] == '/' || package_name[JAVAPKG_LEN] == '\0'))) {
const char* class_loader_name = SystemDictionary::loader_name(loader_data);
size_t pkg_len = strlen(package_name);
char* pkg_name = NEW_RESOURCE_ARRAY_IN_THREAD(THREAD, char, pkg_len);
strncpy(pkg_name, package_name, pkg_len);
StringUtils::replace_no_expand(pkg_name, "/", ".");
const char* msg_text1 = "Class loader (instance of): ";
const char* msg_text2 = " tried to define prohibited package name: ";
size_t len = strlen(msg_text1) + strlen(class_loader_name) + strlen(msg_text2) + pkg_len + 1;
char* message = NEW_RESOURCE_ARRAY_IN_THREAD(THREAD, char, len);
jio_snprintf(message, len, "%s%s%s%s", msg_text1, class_loader_name, msg_text2, pkg_name);
THROW_MSG(vmSymbols::java_lang_IllegalArgumentException(), message);
}
log_debug(module)("add_module_package(): Adding package %s to module %s",
package_name, module_entry->name()->as_C_string());
TempNewSymbol pkg_symbol = SymbolTable::new_symbol(package_name, CHECK);
PackageEntryTable* package_table = loader_data->packages();
assert(package_table != NULL, "Missing package_table");
PackageEntry* existing_pkg = NULL;
{
MutexLocker ml(Module_lock, THREAD);
// Check that the package does not exist in the class loader's package table.
existing_pkg = package_table->lookup_only(pkg_symbol);
if (existing_pkg == NULL) {
PackageEntry* pkg = package_table->locked_create_entry_or_null(pkg_symbol, module_entry);
assert(pkg != NULL, "Unable to create a module's package entry");
}
}
if (existing_pkg != NULL) {
throw_dup_pkg_exception(module_entry->name()->as_C_string(), existing_pkg, CHECK);
}
}
// Export package in module to all unnamed modules. // Export package in module to all unnamed modules.
void Modules::add_module_exports_to_all_unnamed(jobject module, const char* package_name, TRAPS) { void Modules::add_module_exports_to_all_unnamed(jobject module, const char* package_name, TRAPS) {
if (module == NULL) { if (module == NULL) {

View file

@ -111,14 +111,6 @@ public:
// Returns NULL if package is invalid or not defined by loader. // Returns NULL if package is invalid or not defined by loader.
static jobject get_module(Symbol* package_name, Handle h_loader, TRAPS); static jobject get_module(Symbol* package_name, Handle h_loader, TRAPS);
// This adds package to module.
// It throws IllegalArgumentException if:
// * Module is bad
// * Module is unnamed
// * Package is not syntactically correct
// * Package is already defined for module's class loader.
static void add_module_package(jobject module, const char* package, TRAPS);
// Marks the specified package as exported to all unnamed modules. // Marks the specified package as exported to all unnamed modules.
// If either module or package is null then NullPointerException is thrown. // If either module or package is null then NullPointerException is thrown.
// If module or package is bad, or module is unnamed, or package is not in // If module or package is bad, or module is unnamed, or package is not in

View file

@ -132,6 +132,7 @@ class CodeBlob_sizes {
// Iterate over all CodeHeaps // Iterate over all CodeHeaps
#define FOR_ALL_HEAPS(heap) for (GrowableArrayIterator<CodeHeap*> heap = _heaps->begin(); heap != _heaps->end(); ++heap) #define FOR_ALL_HEAPS(heap) for (GrowableArrayIterator<CodeHeap*> heap = _heaps->begin(); heap != _heaps->end(); ++heap)
#define FOR_ALL_NMETHOD_HEAPS(heap) for (GrowableArrayIterator<CodeHeap*> heap = _nmethod_heaps->begin(); heap != _nmethod_heaps->end(); ++heap) #define FOR_ALL_NMETHOD_HEAPS(heap) for (GrowableArrayIterator<CodeHeap*> heap = _nmethod_heaps->begin(); heap != _nmethod_heaps->end(); ++heap)
#define FOR_ALL_ALLOCABLE_HEAPS(heap) for (GrowableArrayIterator<CodeHeap*> heap = _allocable_heaps->begin(); heap != _allocable_heaps->end(); ++heap)
// Iterate over all CodeBlobs (cb) on the given CodeHeap // Iterate over all CodeBlobs (cb) on the given CodeHeap
#define FOR_ALL_BLOBS(cb, heap) for (CodeBlob* cb = first_blob(heap); cb != NULL; cb = next_blob(heap, cb)) #define FOR_ALL_BLOBS(cb, heap) for (CodeBlob* cb = first_blob(heap); cb != NULL; cb = next_blob(heap, cb))
@ -142,10 +143,11 @@ int CodeCache::_number_of_nmethods_with_dependencies = 0;
bool CodeCache::_needs_cache_clean = false; bool CodeCache::_needs_cache_clean = false;
nmethod* CodeCache::_scavenge_root_nmethods = NULL; nmethod* CodeCache::_scavenge_root_nmethods = NULL;
// Initialize array of CodeHeaps // Initialize arrays of CodeHeap subsets
GrowableArray<CodeHeap*>* CodeCache::_heaps = new(ResourceObj::C_HEAP, mtCode) GrowableArray<CodeHeap*> (CodeBlobType::All, true); GrowableArray<CodeHeap*>* CodeCache::_heaps = new(ResourceObj::C_HEAP, mtCode) GrowableArray<CodeHeap*> (CodeBlobType::All, true);
GrowableArray<CodeHeap*>* CodeCache::_compiled_heaps = new(ResourceObj::C_HEAP, mtCode) GrowableArray<CodeHeap*> (CodeBlobType::All, true); GrowableArray<CodeHeap*>* CodeCache::_compiled_heaps = new(ResourceObj::C_HEAP, mtCode) GrowableArray<CodeHeap*> (CodeBlobType::All, true);
GrowableArray<CodeHeap*>* CodeCache::_nmethod_heaps = new(ResourceObj::C_HEAP, mtCode) GrowableArray<CodeHeap*> (CodeBlobType::All, true); GrowableArray<CodeHeap*>* CodeCache::_nmethod_heaps = new(ResourceObj::C_HEAP, mtCode) GrowableArray<CodeHeap*> (CodeBlobType::All, true);
GrowableArray<CodeHeap*>* CodeCache::_allocable_heaps = new(ResourceObj::C_HEAP, mtCode) GrowableArray<CodeHeap*> (CodeBlobType::All, true);
void CodeCache::check_heap_sizes(size_t non_nmethod_size, size_t profiled_size, size_t non_profiled_size, size_t cache_size, bool all_set) { void CodeCache::check_heap_sizes(size_t non_nmethod_size, size_t profiled_size, size_t non_profiled_size, size_t cache_size, bool all_set) {
size_t total_size = non_nmethod_size + profiled_size + non_profiled_size; size_t total_size = non_nmethod_size + profiled_size + non_profiled_size;
@ -340,6 +342,7 @@ ReservedCodeSpace CodeCache::reserve_heap_memory(size_t size) {
return rs; return rs;
} }
// Heaps available for allocation
bool CodeCache::heap_available(int code_blob_type) { bool CodeCache::heap_available(int code_blob_type) {
if (!SegmentedCodeCache) { if (!SegmentedCodeCache) {
// No segmentation: use a single code heap // No segmentation: use a single code heap
@ -393,6 +396,9 @@ void CodeCache::add_heap(CodeHeap* heap) {
if (code_blob_type_accepts_nmethod(type)) { if (code_blob_type_accepts_nmethod(type)) {
_nmethod_heaps->insert_sorted<code_heap_compare>(heap); _nmethod_heaps->insert_sorted<code_heap_compare>(heap);
} }
if (code_blob_type_accepts_allocable(type)) {
_allocable_heaps->insert_sorted<code_heap_compare>(heap);
}
} }
void CodeCache::add_heap(ReservedSpace rs, const char* name, int code_blob_type) { void CodeCache::add_heap(ReservedSpace rs, const char* name, int code_blob_type) {
@ -665,7 +671,7 @@ void CodeCache::do_unloading(BoolObjectClosure* is_alive, bool unloading_occurre
void CodeCache::blobs_do(CodeBlobClosure* f) { void CodeCache::blobs_do(CodeBlobClosure* f) {
assert_locked_or_safepoint(CodeCache_lock); assert_locked_or_safepoint(CodeCache_lock);
FOR_ALL_NMETHOD_HEAPS(heap) { FOR_ALL_ALLOCABLE_HEAPS(heap) {
FOR_ALL_BLOBS(cb, *heap) { FOR_ALL_BLOBS(cb, *heap) {
if (cb->is_alive()) { if (cb->is_alive()) {
f->do_code_blob(cb); f->do_code_blob(cb);
@ -962,7 +968,7 @@ address CodeCache::high_bound(int code_blob_type) {
size_t CodeCache::capacity() { size_t CodeCache::capacity() {
size_t cap = 0; size_t cap = 0;
FOR_ALL_NMETHOD_HEAPS(heap) { FOR_ALL_ALLOCABLE_HEAPS(heap) {
cap += (*heap)->capacity(); cap += (*heap)->capacity();
} }
return cap; return cap;
@ -975,7 +981,7 @@ size_t CodeCache::unallocated_capacity(int code_blob_type) {
size_t CodeCache::unallocated_capacity() { size_t CodeCache::unallocated_capacity() {
size_t unallocated_cap = 0; size_t unallocated_cap = 0;
FOR_ALL_NMETHOD_HEAPS(heap) { FOR_ALL_ALLOCABLE_HEAPS(heap) {
unallocated_cap += (*heap)->unallocated_capacity(); unallocated_cap += (*heap)->unallocated_capacity();
} }
return unallocated_cap; return unallocated_cap;
@ -983,7 +989,7 @@ size_t CodeCache::unallocated_capacity() {
size_t CodeCache::max_capacity() { size_t CodeCache::max_capacity() {
size_t max_cap = 0; size_t max_cap = 0;
FOR_ALL_NMETHOD_HEAPS(heap) { FOR_ALL_ALLOCABLE_HEAPS(heap) {
max_cap += (*heap)->max_capacity(); max_cap += (*heap)->max_capacity();
} }
return max_cap; return max_cap;
@ -1009,7 +1015,7 @@ double CodeCache::reverse_free_ratio(int code_blob_type) {
size_t CodeCache::bytes_allocated_in_freelists() { size_t CodeCache::bytes_allocated_in_freelists() {
size_t allocated_bytes = 0; size_t allocated_bytes = 0;
FOR_ALL_NMETHOD_HEAPS(heap) { FOR_ALL_ALLOCABLE_HEAPS(heap) {
allocated_bytes += (*heap)->allocated_in_freelist(); allocated_bytes += (*heap)->allocated_in_freelist();
} }
return allocated_bytes; return allocated_bytes;
@ -1017,7 +1023,7 @@ size_t CodeCache::bytes_allocated_in_freelists() {
int CodeCache::allocated_segments() { int CodeCache::allocated_segments() {
int number_of_segments = 0; int number_of_segments = 0;
FOR_ALL_NMETHOD_HEAPS(heap) { FOR_ALL_ALLOCABLE_HEAPS(heap) {
number_of_segments += (*heap)->allocated_segments(); number_of_segments += (*heap)->allocated_segments();
} }
return number_of_segments; return number_of_segments;
@ -1025,7 +1031,7 @@ int CodeCache::allocated_segments() {
size_t CodeCache::freelists_length() { size_t CodeCache::freelists_length() {
size_t length = 0; size_t length = 0;
FOR_ALL_NMETHOD_HEAPS(heap) { FOR_ALL_ALLOCABLE_HEAPS(heap) {
length += (*heap)->freelist_length(); length += (*heap)->freelist_length();
} }
return length; return length;
@ -1375,7 +1381,7 @@ PRAGMA_DIAG_POP
void CodeCache::print_memory_overhead() { void CodeCache::print_memory_overhead() {
size_t wasted_bytes = 0; size_t wasted_bytes = 0;
FOR_ALL_NMETHOD_HEAPS(heap) { FOR_ALL_ALLOCABLE_HEAPS(heap) {
CodeHeap* curr_heap = *heap; CodeHeap* curr_heap = *heap;
for (CodeBlob* cb = (CodeBlob*)curr_heap->first(); cb != NULL; cb = (CodeBlob*)curr_heap->next(cb)) { for (CodeBlob* cb = (CodeBlob*)curr_heap->first(); cb != NULL; cb = (CodeBlob*)curr_heap->next(cb)) {
HeapBlock* heap_block = ((HeapBlock*)cb) - 1; HeapBlock* heap_block = ((HeapBlock*)cb) - 1;
@ -1421,7 +1427,7 @@ void CodeCache::print_internals() {
ResourceMark rm; ResourceMark rm;
int i = 0; int i = 0;
FOR_ALL_NMETHOD_HEAPS(heap) { FOR_ALL_ALLOCABLE_HEAPS(heap) {
if ((_nmethod_heaps->length() >= 1) && Verbose) { if ((_nmethod_heaps->length() >= 1) && Verbose) {
tty->print_cr("-- %s --", (*heap)->name()); tty->print_cr("-- %s --", (*heap)->name());
} }
@ -1518,7 +1524,7 @@ void CodeCache::print() {
CodeBlob_sizes live; CodeBlob_sizes live;
CodeBlob_sizes dead; CodeBlob_sizes dead;
FOR_ALL_NMETHOD_HEAPS(heap) { FOR_ALL_ALLOCABLE_HEAPS(heap) {
FOR_ALL_BLOBS(cb, *heap) { FOR_ALL_BLOBS(cb, *heap) {
if (!cb->is_alive()) { if (!cb->is_alive()) {
dead.add(cb); dead.add(cb);
@ -1544,7 +1550,7 @@ void CodeCache::print() {
int number_of_blobs = 0; int number_of_blobs = 0;
int number_of_oop_maps = 0; int number_of_oop_maps = 0;
int map_size = 0; int map_size = 0;
FOR_ALL_NMETHOD_HEAPS(heap) { FOR_ALL_ALLOCABLE_HEAPS(heap) {
FOR_ALL_BLOBS(cb, *heap) { FOR_ALL_BLOBS(cb, *heap) {
if (cb->is_alive()) { if (cb->is_alive()) {
number_of_blobs++; number_of_blobs++;

View file

@ -85,6 +85,7 @@ class CodeCache : AllStatic {
static GrowableArray<CodeHeap*>* _heaps; static GrowableArray<CodeHeap*>* _heaps;
static GrowableArray<CodeHeap*>* _compiled_heaps; static GrowableArray<CodeHeap*>* _compiled_heaps;
static GrowableArray<CodeHeap*>* _nmethod_heaps; static GrowableArray<CodeHeap*>* _nmethod_heaps;
static GrowableArray<CodeHeap*>* _allocable_heaps;
static address _low_bound; // Lower bound of CodeHeap addresses static address _low_bound; // Lower bound of CodeHeap addresses
static address _high_bound; // Upper bound of CodeHeap addresses static address _high_bound; // Upper bound of CodeHeap addresses
@ -237,6 +238,11 @@ class CodeCache : AllStatic {
return type == CodeBlobType::All || type <= CodeBlobType::MethodProfiled; return type == CodeBlobType::All || type <= CodeBlobType::MethodProfiled;
} }
static bool code_blob_type_accepts_allocable(int type) {
return type <= CodeBlobType::All;
}
// Returns the CodeBlobType for the given compilation level // Returns the CodeBlobType for the given compilation level
static int get_code_blob_type(int comp_level) { static int get_code_blob_type(int comp_level) {
if (comp_level == CompLevel_none || if (comp_level == CompLevel_none ||

View file

@ -1560,7 +1560,7 @@ void CompileBroker::compiler_thread_loop() {
// First thread to get here will initialize the compiler interface // First thread to get here will initialize the compiler interface
if (!ciObjectFactory::is_initialized()) { {
ASSERT_IN_VM; ASSERT_IN_VM;
MutexLocker only_one (CompileThread_lock, thread); MutexLocker only_one (CompileThread_lock, thread);
if (!ciObjectFactory::is_initialized()) { if (!ciObjectFactory::is_initialized()) {

View file

@ -1692,6 +1692,13 @@ C2V_VMENTRY(jlong, getFingerprint, (JNIEnv*, jobject, jlong metaspace_klass))
} }
C2V_END C2V_END
C2V_VMENTRY(jobject, getHostClass, (JNIEnv*, jobject, jobject jvmci_type))
InstanceKlass* k = InstanceKlass::cast(CompilerToVM::asKlass(jvmci_type));
InstanceKlass* host = k->host_klass();
oop result = CompilerToVM::get_jvmci_type(host, CHECK_NULL);
return JNIHandles::make_local(THREAD, result);
C2V_END
C2V_VMENTRY(int, interpreterFrameSize, (JNIEnv*, jobject, jobject bytecode_frame_handle)) C2V_VMENTRY(int, interpreterFrameSize, (JNIEnv*, jobject, jobject bytecode_frame_handle))
if (bytecode_frame_handle == NULL) { if (bytecode_frame_handle == NULL) {
THROW_0(vmSymbols::java_lang_NullPointerException()); THROW_0(vmSymbols::java_lang_NullPointerException());
@ -1822,6 +1829,7 @@ JNINativeMethod CompilerToVM::methods[] = {
{CC "flushDebugOutput", CC "()V", FN_PTR(flushDebugOutput)}, {CC "flushDebugOutput", CC "()V", FN_PTR(flushDebugOutput)},
{CC "methodDataProfileDataSize", CC "(JI)I", FN_PTR(methodDataProfileDataSize)}, {CC "methodDataProfileDataSize", CC "(JI)I", FN_PTR(methodDataProfileDataSize)},
{CC "getFingerprint", CC "(J)J", FN_PTR(getFingerprint)}, {CC "getFingerprint", CC "(J)J", FN_PTR(getFingerprint)},
{CC "getHostClass", CC "(" HS_RESOLVED_KLASS ")" HS_RESOLVED_KLASS, FN_PTR(getHostClass)},
{CC "interpreterFrameSize", CC "(" BYTECODE_FRAME ")I", FN_PTR(interpreterFrameSize)}, {CC "interpreterFrameSize", CC "(" BYTECODE_FRAME ")I", FN_PTR(interpreterFrameSize)},
{CC "compileToBytecode", CC "(" OBJECT ")V", FN_PTR(compileToBytecode)}, {CC "compileToBytecode", CC "(" OBJECT ")V", FN_PTR(compileToBytecode)},
{CC "getFlagValue", CC "(" STRING ")" OBJECT, FN_PTR(getFlagValue)}, {CC "getFlagValue", CC "(" STRING ")" OBJECT, FN_PTR(getFlagValue)},

View file

@ -1036,11 +1036,6 @@ JVM_ENTRY (void, JVM_AddReadsModule(JNIEnv *env, jobject from_module, jobject so
Modules::add_reads_module(from_module, source_module, CHECK); Modules::add_reads_module(from_module, source_module, CHECK);
JVM_END JVM_END
JVM_ENTRY (void, JVM_AddModulePackage(JNIEnv *env, jobject module, const char* package))
JVMWrapper("JVM_AddModulePackage");
Modules::add_module_package(module, package, CHECK);
JVM_END
// Reflection support ////////////////////////////////////////////////////////////////////////////// // Reflection support //////////////////////////////////////////////////////////////////////////////
JVM_ENTRY(jstring, JVM_GetClassName(JNIEnv *env, jclass cls)) JVM_ENTRY(jstring, JVM_GetClassName(JNIEnv *env, jclass cls))

View file

@ -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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -466,14 +466,6 @@ JVM_AddModuleExportsToAll(JNIEnv *env, jobject from_module, const char* package)
JNIEXPORT void JNICALL JNIEXPORT void JNICALL
JVM_AddReadsModule(JNIEnv *env, jobject from_module, jobject source_module); JVM_AddReadsModule(JNIEnv *env, jobject from_module, jobject source_module);
/*
* Add a package to a module.
* module: module that will contain the package
* package: package to add to the module
*/
JNIEXPORT void JNICALL
JVM_AddModulePackage(JNIEnv* env, jobject module, const char* package);
/* /*
* Reflection support functions * Reflection support functions
*/ */

View file

@ -1522,15 +1522,6 @@ WB_ENTRY(void, WB_AddReadsModule(JNIEnv* env, jobject o, jobject from_module, jo
Modules::add_reads_module(from_module, source_module, CHECK); Modules::add_reads_module(from_module, source_module, CHECK);
WB_END WB_END
WB_ENTRY(void, WB_AddModulePackage(JNIEnv* env, jobject o, jclass module, jstring package))
ResourceMark rm(THREAD);
char* package_name = NULL;
if (package != NULL) {
package_name = java_lang_String::as_utf8_string(JNIHandles::resolve_non_null(package));
}
Modules::add_module_package(module, package_name, CHECK);
WB_END
WB_ENTRY(jlong, WB_IncMetaspaceCapacityUntilGC(JNIEnv* env, jobject wb, jlong inc)) WB_ENTRY(jlong, WB_IncMetaspaceCapacityUntilGC(JNIEnv* env, jobject wb, jlong inc))
if (inc < 0) { if (inc < 0) {
THROW_MSG_0(vmSymbols::java_lang_IllegalArgumentException(), THROW_MSG_0(vmSymbols::java_lang_IllegalArgumentException(),
@ -1966,8 +1957,6 @@ static JNINativeMethod methods[] = {
(void*)&WB_AddModuleExports }, (void*)&WB_AddModuleExports },
{CC"AddReadsModule", CC"(Ljava/lang/Object;Ljava/lang/Object;)V", {CC"AddReadsModule", CC"(Ljava/lang/Object;Ljava/lang/Object;)V",
(void*)&WB_AddReadsModule }, (void*)&WB_AddReadsModule },
{CC"AddModulePackage", CC"(Ljava/lang/Object;Ljava/lang/String;)V",
(void*)&WB_AddModulePackage },
{CC"AddModuleExportsToAllUnnamed", CC"(Ljava/lang/Object;Ljava/lang/String;)V", {CC"AddModuleExportsToAllUnnamed", CC"(Ljava/lang/Object;Ljava/lang/String;)V",
(void*)&WB_AddModuleExportsToAllUnnamed }, (void*)&WB_AddModuleExportsToAllUnnamed },
{CC"AddModuleExportsToAll", CC"(Ljava/lang/Object;Ljava/lang/String;)V", {CC"AddModuleExportsToAll", CC"(Ljava/lang/Object;Ljava/lang/String;)V",

View file

@ -2921,8 +2921,8 @@ jint Arguments::parse_each_vm_init_arg(const JavaVMInitArgs* args, bool* patch_m
if (res != JNI_OK) { if (res != JNI_OK) {
return res; return res;
} }
} else if (match_option(option, "--permit-illegal-access")) { } else if (match_option(option, "--illegal-access=", &tail)) {
if (!create_property("jdk.module.permitIllegalAccess", "true", ExternalProperty)) { if (!create_property("jdk.module.illegalAccess", tail, ExternalProperty)) {
return JNI_ENOMEM; return JNI_ENOMEM;
} }
// -agentlib and -agentpath // -agentlib and -agentpath

View file

@ -295,19 +295,41 @@ void SensorInfo::trigger(int count, TRAPS) {
if (_sensor_obj != NULL) { if (_sensor_obj != NULL) {
InstanceKlass* sensorKlass = Management::sun_management_Sensor_klass(CHECK); InstanceKlass* sensorKlass = Management::sun_management_Sensor_klass(CHECK);
Handle sensor_h(THREAD, _sensor_obj); Handle sensor_h(THREAD, _sensor_obj);
Handle usage_h = MemoryService::create_MemoryUsage_obj(_usage, CHECK);
Symbol* trigger_method_signature;
JavaValue result(T_VOID); JavaValue result(T_VOID);
JavaCallArguments args(sensor_h); JavaCallArguments args(sensor_h);
args.push_int((int) count); args.push_int((int) count);
Handle usage_h = MemoryService::create_MemoryUsage_obj(_usage, THREAD);
// Call Sensor::trigger(int, MemoryUsage) to send notification to listeners.
// When OOME occurs and fails to allocate MemoryUsage object, call
// Sensor::trigger(int) instead. The pending request will be processed
// but no notification will be sent.
if (HAS_PENDING_EXCEPTION) {
assert((PENDING_EXCEPTION->is_a(SystemDictionary::OutOfMemoryError_klass())), "we expect only an OOME here");
CLEAR_PENDING_EXCEPTION;
trigger_method_signature = vmSymbols::int_void_signature();
} else {
trigger_method_signature = vmSymbols::trigger_method_signature();
args.push_oop(usage_h); args.push_oop(usage_h);
}
JavaCalls::call_virtual(&result, JavaCalls::call_virtual(&result,
sensorKlass, sensorKlass,
vmSymbols::trigger_name(), vmSymbols::trigger_name(),
vmSymbols::trigger_method_signature(), trigger_method_signature,
&args, &args,
CHECK); THREAD);
if (HAS_PENDING_EXCEPTION) {
// We just clear the OOM pending exception that we might have encountered
// in Java's tiggerAction(), and continue with updating the counters since
// the Java counters have been updated too.
assert((PENDING_EXCEPTION->is_a(SystemDictionary::OutOfMemoryError_klass())), "we expect only an OOME here");
CLEAR_PENDING_EXCEPTION;
}
} }
{ {

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2004, 2015, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -23,18 +23,31 @@
/* /*
* @test * @test
* @bug 4983023 * @bug 8181872
* @summary A bad superclass shouldn't throw the standard doclet into a loop *
* @modules jdk.javadoc * @run main/othervm -XX:+IgnoreUnrecognizedVMOptions
* -XX:CompileThreshold=100 -XX:+TieredCompilation -XX:TieredStopAtLevel=1
* -XX:-BackgroundCompilation -XX:CompileCommand=dontinline,compiler.c1.MultiplyByMaxInt::test
* compiler.c1.MultiplyByMaxInt
* @run main/othervm -XX:+IgnoreUnrecognizedVMOptions -XX:-BackgroundCompilation
* -XX:CompileThreshold=100 -XX:+TieredCompilation -XX:TieredStopAtLevel=3
* -XX:CompileCommand=dontinline,compiler.c1.MultiplyByMaxInt::test
* compiler.c1.MultiplyByMaxInt
*/ */
package compiler.c1;
public class BadSuper { public class MultiplyByMaxInt {
static int test(int x) {
int loops = (x >>> 4) & 7;
while (loops-- > 0) {
x = (x * 2147483647) % 16807;
}
return x;
}
public static void main(String[] args) { public static void main(String[] args) {
String srcpath = System.getProperty("test.src", "."); for (int i = 0; i < 20000; i++) {
test(i);
if (com.sun.tools.javadoc.Main.execute( }
new String[] {"-d", "doc", "-sourcepath", srcpath, "p"}) != 0)
throw new Error("Javadoc encountered warnings or errors.");
} }
} }

View file

@ -108,8 +108,8 @@ public class TestAnonymousClassUnloading {
*/ */
static public void main(String[] args) throws Exception { static public void main(String[] args) throws Exception {
// (1) Load an anonymous version of this class using the corresponding Unsafe method // (1) Load an anonymous version of this class using the corresponding Unsafe method
URL classUrl = TestAnonymousClassUnloading.class.getResource( String rn = TestAnonymousClassUnloading.class.getSimpleName() + ".class";
TestAnonymousClassUnloading.class.getName().replace('.', '/') + ".class"); URL classUrl = TestAnonymousClassUnloading.class.getResource(rn);
URLConnection connection = classUrl.openConnection(); URLConnection connection = classUrl.openConnection();
int length = connection.getContentLength(); int length = connection.getContentLength();

View file

@ -54,6 +54,7 @@ import java.lang.reflect.Method;
import java.lang.reflect.Modifier; import java.lang.reflect.Modifier;
import java.util.Arrays; import java.util.Arrays;
import java.util.Collections; import java.util.Collections;
import java.util.function.Supplier;
import java.util.HashMap; import java.util.HashMap;
import java.util.HashSet; import java.util.HashSet;
import java.util.Map; import java.util.Map;
@ -142,6 +143,27 @@ public class TestResolvedJavaType extends TypeUniverse {
} }
} }
@Test
public void getHostClassTest() {
for (Class<?> c : classes) {
ResolvedJavaType type = metaAccess.lookupJavaType(c);
ResolvedJavaType host = type.getHostClass();
assertNull(host);
}
class LocalClass {}
Cloneable clone = new Cloneable() {};
assertNull(metaAccess.lookupJavaType(LocalClass.class).getHostClass());
assertNull(metaAccess.lookupJavaType(clone.getClass()).getHostClass());
Supplier<Runnable> lambda = () -> () -> System.out.println("run");
ResolvedJavaType lambdaType = metaAccess.lookupJavaType(lambda.getClass());
ResolvedJavaType nestedLambdaType = metaAccess.lookupJavaType(lambda.get().getClass());
assertNotNull(lambdaType.getHostClass());
assertNotNull(nestedLambdaType.getHostClass());
assertEquals(lambdaType.getHostClass(), nestedLambdaType.getHostClass());
}
@Test @Test
public void getModifiersTest() { public void getModifiersTest() {
for (Class<?> c : classes) { for (Class<?> c : classes) {

View file

@ -74,7 +74,7 @@ public class ClassLoadUnloadTest {
List<String> argsList = new ArrayList<>(); List<String> argsList = new ArrayList<>();
Collections.addAll(argsList, args); Collections.addAll(argsList, args);
Collections.addAll(argsList, "-Xmn8m"); Collections.addAll(argsList, "-Xmn8m");
Collections.addAll(argsList, "-Dtest.classes=" + System.getProperty("test.classes",".")); Collections.addAll(argsList, "-Dtest.class.path=" + System.getProperty("test.class.path", "."));
Collections.addAll(argsList, ClassUnloadTestMain.class.getName()); Collections.addAll(argsList, ClassUnloadTestMain.class.getName());
return ProcessTools.createJavaProcessBuilder(argsList.toArray(new String[argsList.size()])); return ProcessTools.createJavaProcessBuilder(argsList.toArray(new String[argsList.size()]));
} }

View file

@ -1,154 +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.
*/
/*
* @test
* @modules java.base/jdk.internal.misc
* @library /test/lib ..
* @build sun.hotspot.WhiteBox
* @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
*/
import static jdk.test.lib.Asserts.*;
import java.sql.Time;
public class JVMAddModulePackage {
public static void main(String args[]) throws Throwable {
MyClassLoader cl1 = new MyClassLoader();
MyClassLoader cl3 = new MyClassLoader();
Object module_one, module_two, module_three;
boolean result;
module_one = ModuleHelper.ModuleObject("module_one", cl1, new String[] { "mypackage" });
assertNotNull(module_one, "Module should not be null");
ModuleHelper.DefineModule(module_one, false, "9.0", "module_one/here", new String[] { "mypackage" });
module_two = ModuleHelper.ModuleObject("module_two", cl1, new String[] { "yourpackage" });
assertNotNull(module_two, "Module should not be null");
ModuleHelper.DefineModule(module_two, false, "9.0", "module_two/here", new String[] { "yourpackage" });
module_three = ModuleHelper.ModuleObject("module_three", cl3, new String[] { "apackage/num3" });
assertNotNull(module_three, "Module should not be null");
ModuleHelper.DefineModule(module_three, false, "9.0", "module_three/here", new String[] { "apackage/num3" });
// Simple call
ModuleHelper.AddModulePackage(module_one, "new_package");
// Add a package and export it
ModuleHelper.AddModulePackage(module_one, "apackage/num3");
ModuleHelper.AddModuleExportsToAll(module_one, "apackage/num3");
// Null module argument, expect an NPE
try {
ModuleHelper.AddModulePackage(null, "new_package");
throw new RuntimeException("Failed to get the expected NPE");
} catch(NullPointerException e) {
// Expected
}
// Bad module argument, expect an IAE
try {
ModuleHelper.AddModulePackage(cl1, "new_package");
throw new RuntimeException("Failed to get the expected IAE");
} catch(IllegalArgumentException e) {
// Expected
}
// Null package argument, expect an NPE
try {
ModuleHelper.AddModulePackage(module_one, null);
throw new RuntimeException("Failed to get the expected NPE");
} catch(NullPointerException e) {
// Expected
}
// Existing package, expect an ISE
try {
ModuleHelper.AddModulePackage(module_one, "yourpackage");
throw new RuntimeException("Failed to get the expected ISE");
} catch(IllegalStateException e) {
// Expected
}
// Invalid package name, expect an IAE
try {
ModuleHelper.AddModulePackage(module_one, "your.apackage");
throw new RuntimeException("Failed to get the expected IAE");
} catch(IllegalArgumentException e) {
// Expected
}
// Invalid package name, expect an IAE
try {
ModuleHelper.AddModulePackage(module_one, ";your/apackage");
throw new RuntimeException("Failed to get the expected IAE");
} catch(IllegalArgumentException e) {
// Expected
}
// Invalid package name, expect an IAE
try {
ModuleHelper.AddModulePackage(module_one, "7[743");
throw new RuntimeException("Failed to get the expected IAE");
} catch(IllegalArgumentException e) {
// Expected
}
// Empty package name, expect an IAE
try {
ModuleHelper.AddModulePackage(module_one, "");
throw new RuntimeException("Failed to get the expected IAE");
} catch(IllegalArgumentException e) {
// Expected
}
// Add package named "java" to an module defined to a class loader other than the boot or platform loader.
try {
// module_one is defined to a MyClassLoader class loader.
ModuleHelper.AddModulePackage(module_one, "java/foo");
throw new RuntimeException("Failed to get the expected IAE");
} catch(IllegalArgumentException e) {
if (!e.getMessage().contains("prohibited package name")) {
throw new RuntimeException("Failed to get expected IAE message for prohibited package name: " + e.getMessage());
}
}
// Package "javabar" should be ok
ModuleHelper.AddModulePackage(module_one, "javabar");
// Package named "java" defined to the boot class loader, should be ok
Object module_javabase = module_one.getClass().getModule();
ModuleHelper.AddModulePackage(module_javabase, "java/foo");
// Package named "java" defined to the platform class loader, should be ok
// The module java.sql is defined to the platform class loader.
java.sql.Time jst = new java.sql.Time(45000); // milliseconds
Object module_javasql = jst.getClass().getModule();
ModuleHelper.AddModulePackage(module_javasql, "java/foo");
}
static class MyClassLoader extends ClassLoader { }
}

View file

@ -49,12 +49,6 @@ public class ModuleHelper {
java.lang.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.ModuleHelper.addPackageNoSync((Module)m, pkg);
}
public static void AddModuleExportsToAllUnnamed(Object m, String pkg) throws Throwable { public static void AddModuleExportsToAllUnnamed(Object m, String pkg) throws Throwable {
WhiteBox wb = WhiteBox.getWhiteBox(); WhiteBox wb = WhiteBox.getWhiteBox();
wb.AddModuleExportsToAllUnnamed(m, pkg); wb.AddModuleExportsToAllUnnamed(m, pkg);

View file

@ -63,11 +63,4 @@ public final class ModuleHelper {
} }
} }
/**
* Adds a package to a module without notifying the VM.
*/
public static void addPackageNoSync(Module m, String pkg) {
m.implAddPackageNoSync(pkg);
}
} }

View file

@ -31,8 +31,10 @@ import java.io.File;
import java.net.MalformedURLException; import java.net.MalformedURLException;
import java.net.URL; import java.net.URL;
import java.net.URLClassLoader; import java.net.URLClassLoader;
import java.nio.file.Path;
import java.nio.file.Paths; import java.nio.file.Paths;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.stream.Stream;
public class ClassUnloadCommon { public class ClassUnloadCommon {
public static class TestFailure extends RuntimeException { public static class TestFailure extends RuntimeException {
@ -61,14 +63,45 @@ public class ClassUnloadCommon {
System.gc(); System.gc();
} }
/**
* Creates a class loader that loads classes from {@code ${test.class.path}}
* before delegating to the system class loader.
*/
public static ClassLoader newClassLoader() { public static ClassLoader newClassLoader() {
String cp = System.getProperty("test.class.path", ".");
URL[] urls = Stream.of(cp.split(File.pathSeparator))
.map(Paths::get)
.map(ClassUnloadCommon::toURL)
.toArray(URL[]::new);
return new URLClassLoader(urls) {
@Override
public Class<?> loadClass(String cn, boolean resolve)
throws ClassNotFoundException
{
synchronized (getClassLoadingLock(cn)) {
Class<?> c = findLoadedClass(cn);
if (c == null) {
try { try {
return new URLClassLoader(new URL[] { c = findClass(cn);
Paths.get(System.getProperty("test.classes",".") + File.separatorChar + "classes").toUri().toURL(), } catch (ClassNotFoundException e) {
}, null); c = getParent().loadClass(cn);
} catch (MalformedURLException e){
throw new RuntimeException("Unexpected URL conversion failure", e);
}
} }
} }
if (resolve) {
resolveClass(c);
}
return c;
}
}
};
}
static URL toURL(Path path) {
try {
return path.toUri().toURL();
} catch (MalformedURLException e) {
throw new RuntimeException(e);
}
}
}

View file

@ -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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -26,6 +26,7 @@ package MyPackage;
/** /**
* @test * @test
* @summary Verifies the JVMTI GetNamedModule API * @summary Verifies the JVMTI GetNamedModule API
* @modules jdk.jdi
* @compile GetNamedModuleTest.java * @compile GetNamedModuleTest.java
* @run main/othervm/native -agentlib:GetNamedModuleTest MyPackage.GetNamedModuleTest * @run main/othervm/native -agentlib:GetNamedModuleTest MyPackage.GetNamedModuleTest
*/ */

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -21,40 +21,37 @@
* questions. * questions.
*/ */
package pkg1; package MyPackage;
import java.io.*;
/** /**
* A test class where the outer class is package private and the inner class is private * @test
* and a nested inner class is protected. * @summary Verifies the JVMTI IsModifiableModule API
* * @modules jdk.jdi
* @author Bhavesh Patel * @compile IsModifiableModuleTest.java
* @run main/othervm/native -agentlib:IsModifiableModuleTest MyPackage.IsModifiableModuleTest
*/ */
class NestedInnerClass { import java.io.PrintStream;
private static class InnerClass { public class IsModifiableModuleTest {
protected static class ProNestedInnerClass implements java.io.Serializable { static {
try {
public final int SERIALIZABLE_CONSTANT = 1; System.loadLibrary("IsModifiableModuleTest");
} catch (UnsatisfiedLinkError ule) {
/** System.err.println("Could not load IsModifiableModuleTest library");
* @param s ObjectInputStream. System.err.println("java.library.path: "
* @throws IOException when there is an I/O error. + System.getProperty("java.library.path"));
* @serial throw ule;
*/ }
private void readObject(ObjectInputStream s) throws IOException {
} }
/** native static int check();
* @param s ObjectOutputStream.
* @throws IOException when there is an I/O error. public static void main(String args[]) {
* @serial int status = check();
*/ if (status != 0) {
private void writeObject(ObjectOutputStream s) throws IOException { throw new RuntimeException("Non-zero status returned from the agent: " + status);
}
} }
} }
} }

View file

@ -0,0 +1,215 @@
/*
* 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.
*/
#include <stdio.h>
#include <string.h>
#include "jvmti.h"
#ifdef __cplusplus
extern "C" {
#endif
#ifndef JNI_ENV_ARG
#ifdef __cplusplus
#define JNI_ENV_ARG(x, y) y
#define JNI_ENV_PTR(x) x
#else
#define JNI_ENV_ARG(x,y) x, y
#define JNI_ENV_PTR(x) (*x)
#endif
#endif
#define TranslateError(err) "JVMTI error"
#define PASSED 0
#define FAILED 2
static const char *EXC_CNAME = "java/lang/AssertionError";
static jvmtiEnv *jvmti = NULL;
static jint result = PASSED;
static jboolean printdump = JNI_FALSE;
static jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved);
JNIEXPORT
jint JNICALL Agent_OnLoad(JavaVM *jvm, char *options, void *reserved) {
return Agent_Initialize(jvm, options, reserved);
}
JNIEXPORT
jint JNICALL Agent_OnAttach(JavaVM *jvm, char *options, void *reserved) {
return Agent_Initialize(jvm, options, reserved);
}
JNIEXPORT
jint JNICALL JNI_OnLoad(JavaVM *jvm, void *reserved) {
return JNI_VERSION_1_8;
}
static
jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) {
jint res;
if (options != NULL && strcmp(options, "printdump") == 0) {
printdump = JNI_TRUE;
}
res = JNI_ENV_PTR(jvm)->GetEnv(JNI_ENV_ARG(jvm, (void **) &jvmti),
JVMTI_VERSION_9);
if (res != JNI_OK || jvmti == NULL) {
printf(" Error: wrong result of a valid call to GetEnv!\n");
return JNI_ERR;
}
return JNI_OK;
}
static
jclass find_class(JNIEnv *env, const char* cname) {
jclass cls = JNI_ENV_PTR(env)->FindClass(JNI_ENV_ARG(env, cname));
if (cls == NULL) {
printf("find_class: Error: FindClass(env, \"%s\") returned NULL\n", cname);
}
return cls;
}
static
jint throw_exc(JNIEnv *env, char *msg) {
jclass exc_class = find_class(env, EXC_CNAME);
if (exc_class == NULL) {
printf("throw_exc: Error in find_class(env, \"%s\")\n", EXC_CNAME);
return -1;
}
return JNI_ENV_PTR(env)->ThrowNew(JNI_ENV_ARG(env, exc_class), msg);
}
static jobject get_module_by_class_name(JNIEnv *env, const char* cname) {
jobject module = NULL;
jclass cls = find_class(env, cname);
printf(">>> getting module by class name: \"%s\"\n", cname);
if (cls == NULL) {
printf("get_module_by_class_name: Error in find_class(env, \"%s\")\n", cname);
return NULL;
}
module = JNI_ENV_PTR(env)->GetModule(JNI_ENV_ARG(env, cls));
if (module == NULL) {
printf("get_module_by_class_name: Error in GetModule for class \"%s\"\n", cname);
}
return module;
}
static
jint check_is_modifiable_error_codes(jobject module, jobject not_a_module) {
jvmtiError err = JVMTI_ERROR_NONE;
jboolean is_modifiable = JNI_FALSE;
printf(">>> passing a bad module argument to JVMTI IsModifiableModule\n");
err = (*jvmti)->IsModifiableModule(jvmti, not_a_module, &is_modifiable);
if (err != JVMTI_ERROR_INVALID_MODULE) {
printf(" Error #EC0: Did not get expected INVALID_MODULE error code from"
" IsModifiableModule: %s (%d)\n", TranslateError(err), err);
return FAILED;
}
printf(">>> passing NULL module argument to JVMTI IsModifiableModule\n");
err = (*jvmti)->IsModifiableModule(jvmti, NULL, &is_modifiable);
if (err != JVMTI_ERROR_NULL_POINTER) {
printf(" Error #EC1: Did not get expected NULL_POINTER error code from"
" IsModifiableModule: %s (%d)\n", TranslateError(err), err);
return FAILED;
}
printf(">>> passing NULL status pointer to JVMTI IsModifiableModule\n");
err = (*jvmti)->IsModifiableModule(jvmti, module, NULL);
if (err != JVMTI_ERROR_NULL_POINTER) {
printf(" Error #EC2: Did not get expected NULL_POINTER error code from"
" IsModifiableModule: %s (%d)\n", TranslateError(err), err);
return FAILED;
}
return PASSED;
}
static
jint check_is_modifiable(jobject module) {
jvmtiError err = JVMTI_ERROR_NONE;
jboolean is_modifiable = JNI_FALSE;
printf(">>> checking module %p is modifiable\n", module);
err = (*jvmti)->IsModifiableModule(jvmti, module, &is_modifiable);
if (err != JVMTI_ERROR_NONE) {
printf(" Error in IsModifiableModule for module %p: %s (%d)\n",
module, TranslateError(err), err);
return FAILED;
}
if (is_modifiable == JNI_FALSE) {
printf(" unexpected non-modifiable status for module: %p\n", module);
return FAILED;
}
return PASSED;
}
JNIEXPORT jint JNICALL
Java_MyPackage_IsModifiableModuleTest_check(JNIEnv *env, jclass cls) {
jobject module = NULL;
if (jvmti == NULL) {
throw_exc(env, "JVMTI client was not properly loaded!\n");
return FAILED;
}
printf("\n*** Testing IsModifiableModule ***\n\n");
if (check_is_modifiable_error_codes(module, cls) == FAILED) {
throw_exc(env, "check #MM0: failed to return expected error code from "
"a bad call to JVMTI IsModifiableModule");
return FAILED;
}
module = get_module_by_class_name(env, "java/lang/Class");
if (check_is_modifiable(module) == FAILED) {
throw_exc(env, "check #MM1: failed to return modifiable module status");
return FAILED;
}
module = get_module_by_class_name(env, "com/sun/jdi/VirtualMachine");
if (check_is_modifiable(module) == FAILED) {
throw_exc(env, "check #MM2: failed to return modifiable module status");
return FAILED;
}
module = get_module_by_class_name(env, "MyPackage/IsModifiableModuleTest");
if (check_is_modifiable(module) == FAILED) {
throw_exc(env, "check #MM3: failed to return modifiable module status");
return FAILED;
}
return PASSED;
}
#ifdef __cplusplus
}
#endif

View file

@ -51,8 +51,7 @@ public class TestMutuallyExclusivePlatformPredicates {
VM_TYPE("isClient", "isServer", "isGraal", "isMinimal", "isZero", "isEmbedded"), VM_TYPE("isClient", "isServer", "isGraal", "isMinimal", "isZero", "isEmbedded"),
MODE("isInt", "isMixed", "isComp"), MODE("isInt", "isMixed", "isComp"),
IGNORED("isEmulatedClient", "isDebugBuild", "isFastDebugBuild", "isSlowDebugBuild", IGNORED("isEmulatedClient", "isDebugBuild", "isFastDebugBuild", "isSlowDebugBuild",
"shouldSAAttach", "canPtraceAttachLinux", "canAttachOSX", "shouldSAAttach", "isTieredSupported");
"isTieredSupported");
public final List<String> methodNames; public final List<String> methodNames;

View file

@ -430,3 +430,5 @@ eedb6e54c8bd6197ecba5fc0d8568bac8ae852dd jdk-9+172
9788347e0629d0cb3a0e55a903494ff741d4fa15 jdk-9+173 9788347e0629d0cb3a0e55a903494ff741d4fa15 jdk-9+173
b9c0b105002272d7414c8b34af9aded151f9cad6 jdk-9+174 b9c0b105002272d7414c8b34af9aded151f9cad6 jdk-9+174
ff293e39e83366c40a5687dacd1ccb2305ed2c1e jdk-10+12 ff293e39e83366c40a5687dacd1ccb2305ed2c1e jdk-10+12
736412a8dccee9d439044e6b1af2e7470d0a3563 jdk-9+175
5d374af9e78d02976e0e7f8dc2706f91a020f025 jdk-10+13

View file

@ -1 +1,2 @@
project=jdk10 project=jdk10
bugids=dup

View file

@ -67,6 +67,7 @@ module java.xml {
exports org.xml.sax; exports org.xml.sax;
exports org.xml.sax.ext; exports org.xml.sax.ext;
exports org.xml.sax.helpers; exports org.xml.sax.helpers;
exports com.sun.org.apache.xml.internal.dtm to exports com.sun.org.apache.xml.internal.dtm to
java.xml.crypto; java.xml.crypto;
exports com.sun.org.apache.xml.internal.utils to exports com.sun.org.apache.xml.internal.utils to
@ -81,8 +82,7 @@ module java.xml {
java.xml.crypto; java.xml.crypto;
exports com.sun.org.apache.xpath.internal.res to exports com.sun.org.apache.xpath.internal.res to
java.xml.crypto; java.xml.crypto;
// reflection access from com.sun.xml.internal.ws.api.streaming.XMLStreamWriterFactory
exports com.sun.xml.internal.stream.writers to java.xml.ws;
uses javax.xml.datatype.DatatypeFactory; uses javax.xml.datatype.DatatypeFactory;
uses javax.xml.parsers.DocumentBuilderFactory; uses javax.xml.parsers.DocumentBuilderFactory;
uses javax.xml.parsers.SAXParserFactory; uses javax.xml.parsers.SAXParserFactory;

View file

@ -32,6 +32,7 @@
*/ */
module jdk.xml.dom { module jdk.xml.dom {
requires transitive java.xml; requires transitive java.xml;
exports org.w3c.dom.css; exports org.w3c.dom.css;
exports org.w3c.dom.html; exports org.w3c.dom.html;
exports org.w3c.dom.stylesheets; exports org.w3c.dom.stylesheets;

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2007, 2013, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -24,12 +24,15 @@
*/ */
/** /**
This package contains classes that write HTML markup tags. * Provides interfaces for DOM Level 2 Style Specification. Refer to the
* <a href='http://www.w3.org/TR/2000/REC-DOM-Level-2-Style-20001113'>
<p><b>This is NOT part of any supported API. * Document Object Model (DOM) Level 2 Style Specification</a>,
If you write code that depends on this, you do so at your own risk. * the CSS and stylesheets modules define the Document Object Model Level 2 Style
This code and its internal interfaces are subject to change or * Sheets and Cascading Style Sheets (CSS) that allow programs and scripts to
deletion without notice.</b> * dynamically access and update the content of style sheets documents.
*
*
* @since 1.4
*/ */
package com.sun.tools.doclets.formats.html.markup; package org.w3c.dom.css;

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -23,17 +23,17 @@
* questions. * questions.
*/ */
package com.sun.tools.doclets.internal.toolkit.util;
/** /**
* <p><b>This is NOT part of any supported API. * Provides interfaces for DOM Level 2 HTML Specification. Refer to the
* If you write code that depends on this, you do so at your own risk. * <a href='http://www.w3.org/TR/2000/CR-DOM-Level-2-20000510'>
* This code and its internal interfaces are subject to change or * Document Object Model (DOM) Level 2 Specification</a>,
* deletion without notice.</b> * the HTML module extends the Core API to describe objects and methods specific
* to HTML documents that comply with
* <a href='https://www.w3.org/TR/1998/REC-html40-19980424/'>
* HTML 4.0 Specification</a>.
*
*
* @since 1.4
*/ */
@Deprecated
public class FatalError extends Error {
private static final long serialVersionUID = -9131058909576418984L;
public FatalError() { } package org.w3c.dom.html;
}

View file

@ -0,0 +1,38 @@
/*
* 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.
*/
/**
* Provides interfaces for DOM Level 2 Style Specification. Refer to the
* <a href='http://www.w3.org/TR/2000/REC-DOM-Level-2-Style-20001113'>
* Document Object Model (DOM) Level 2 Style Specification</a>,
* the CSS and stylesheets modules define the Document Object Model Level 2 Style
* Sheets and Cascading Style Sheets (CSS) that allow programs and scripts to
* dynamically access and update the content of style sheets documents.
*
*
* @since 1.4
*/
package org.w3c.dom.stylesheets;

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2001, 2012, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -23,28 +23,21 @@
* questions. * questions.
*/ */
package com.sun.tools.doclets.internal.toolkit.taglets;
/** /**
* An abstract inline taglet that outputs HTML. * Provides interfaces for DOM Level 3 XPath Specification. The XPath module
* provides simple functionalities to access a DOM tree using
* <a href='https://www.w3.org/TR/1999/REC-xpath-19991116/'>XPath 1.0</a>.
* <p>
* The interfaces and classes in this package came from
* Document Object Model (DOM) Level 3 XPath Specification,
* Working Draft 20 August 2002. Refer to
* <a href='https://www.w3.org/TR/DOM-Level-3-XPath/'>
* Document Object Model (DOM) Level 3 XPath Specification, Version 1.0,
* W3C Working Group Note 26 February 2004</a> except that the values of
* {@link XPathException#INVALID_EXPRESSION_ERR} and {@link XPathException#TYPE_ERR}
* are 1 and 2 respectively (instead of 51 and 52).
* *
* <p><b>This is NOT part of any supported API.
* If you write code that depends on this, you do so at your own risk.
* This code and its internal interfaces are subject to change or
* deletion without notice.</b>
*
* @author Jamie Ho
* @since 1.4 * @since 1.4
*/ */
@Deprecated package org.w3c.dom.xpath;
public abstract class BaseInlineTaglet extends BaseTaglet {
/**
* Will return true since this is an inline tag.
* @return true since this is an inline tag.
*/
public boolean isInlineTag() {
return true;
}
}

View file

@ -433,3 +433,5 @@ e705867d9989d00e4357f66f18b302c95e13b5e7 jdk-10+8
2bd967aa452c1e0e87a6173bef6fbb96ef1c521b jdk-9+173 2bd967aa452c1e0e87a6173bef6fbb96ef1c521b jdk-9+173
c2296642010f1b215ac35da89e92c3ce44104e32 jdk-9+174 c2296642010f1b215ac35da89e92c3ce44104e32 jdk-9+174
712a3a657654079514590d37a0f4894d43541d5c jdk-10+12 712a3a657654079514590d37a0f4894d43541d5c jdk-10+12
a5d361b9d1f7f78a675f3baef0d1fd32deee9ea2 jdk-9+175
46a14aad004aa0b980d5f4ff7810d894fd5a36ae jdk-10+13

View file

@ -1 +1,2 @@
project=jdk10 project=jdk10
bugids=dup

View file

@ -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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -118,6 +118,9 @@ public class CommandInfo {
* passed to the command. * passed to the command.
* @param loader The ClassLoader to be used to instantiate the bean. * @param loader The ClassLoader to be used to instantiate the bean.
* @return The bean * @return The bean
* @exception IOException for failures reading data
* @exception ClassNotFoundException if command object class can't
* be found
* @see java.beans.Beans#instantiate * @see java.beans.Beans#instantiate
* @see javax.activation.CommandObject * @see javax.activation.CommandObject
*/ */

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 1997, 2012, 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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -48,6 +48,7 @@ public interface CommandObject {
* *
* @param verb The Command Verb this object refers to. * @param verb The Command Verb this object refers to.
* @param dh The DataHandler. * @param dh The DataHandler.
* @exception IOException for failures accessing data
*/ */
public void setCommandContext(String verb, DataHandler dh) public void setCommandContext(String verb, DataHandler dh)
throws IOException; throws IOException;

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 1997, 2012, 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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -326,6 +326,7 @@ public class DataHandler implements Transferable {
* Otherwise, {@code null} is returned. * Otherwise, {@code null} is returned.
* *
* @return the OutputStream * @return the OutputStream
* @exception IOException for failures creating the OutputStream
* *
* @see javax.activation.DataSource#getOutputStream * @see javax.activation.DataSource#getOutputStream
* @see javax.activation.URLDataSource * @see javax.activation.URLDataSource

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 1997, 2012, 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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -49,6 +49,7 @@ public interface DataSource {
* positioned at the beginning of the data. * positioned at the beginning of the data.
* *
* @return an InputStream * @return an InputStream
* @exception IOException for failures creating the InputStream
*/ */
public InputStream getInputStream() throws IOException; public InputStream getInputStream() throws IOException;
@ -60,6 +61,7 @@ public interface DataSource {
* be positioned at the location the data is to be written. * be positioned at the location the data is to be written.
* *
* @return an OutputStream * @return an OutputStream
* @exception IOException for failures creating the OutputStream
*/ */
public OutputStream getOutputStream() throws IOException; public OutputStream getOutputStream() throws IOException;

View file

@ -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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -29,6 +29,8 @@ package javax.activation;
import java.util.*; import java.util.*;
import java.io.*; import java.io.*;
import java.net.*; import java.net.*;
import java.security.AccessController;
import java.security.PrivilegedAction;
import com.sun.activation.registries.MailcapFile; import com.sun.activation.registries.MailcapFile;
import com.sun.activation.registries.LogSupport; import com.sun.activation.registries.LogSupport;
@ -48,12 +50,19 @@ import com.sun.activation.registries.LogSupport;
* <ol> * <ol>
* <li> Programatically added entries to the MailcapCommandMap instance. * <li> Programatically added entries to the MailcapCommandMap instance.
* <li> The file {@code .mailcap} in the user's home directory. * <li> The file {@code .mailcap} in the user's home directory.
* <li> The file {@literal <}<i>java.home</i>{@literal >}{@code /lib/mailcap}. * <li> The file {@code mailcap} in the Java runtime.
* <li> The file or resources named {@code META-INF/mailcap}. * <li> The file or resources named {@code META-INF/mailcap}.
* <li> The file or resource named {@code META-INF/mailcap.default} * <li> The file or resource named {@code META-INF/mailcap.default}
* (usually found only in the {@code activation.jar} file). * (usually found only in the {@code activation.jar} file).
* </ol> * </ol>
* <p> * <p>
* (The current implementation looks for the {@code mailcap} file
* in the Java runtime in the directory <i>java.home</i>{@code /conf}
* if it exists, and otherwise in the directory
* <i>java.home</i>{@code /lib}, where <i>java.home</i> is the value
* of the "java.home" System property. Note that the "conf" directory was
* introduced in JDK 9.)
* <p>
* <b>Mailcap file format:</b><p> * <b>Mailcap file format:</b><p>
* *
* Mailcap files must conform to the mailcap * Mailcap files must conform to the mailcap
@ -120,6 +129,29 @@ public class MailcapCommandMap extends CommandMap {
private MailcapFile[] DB; private MailcapFile[] DB;
private static final int PROG = 0; // programmatically added entries private static final int PROG = 0; // programmatically added entries
private static final String confDir;
static {
String dir = null;
try {
dir = (String)AccessController.doPrivileged(
new PrivilegedAction() {
public Object run() {
String home = System.getProperty("java.home");
String newdir = home + File.separator + "conf";
File conf = new File(newdir);
if (conf.exists())
return newdir + File.separator;
else
return home + File.separator + "lib" + File.separator;
}
});
} catch (Exception ex) {
// ignore any exceptions
}
confDir = dir;
}
/** /**
* The default Constructor. * The default Constructor.
*/ */
@ -144,11 +176,11 @@ public class MailcapCommandMap extends CommandMap {
LogSupport.log("MailcapCommandMap: load SYS"); LogSupport.log("MailcapCommandMap: load SYS");
try { try {
// check system's home // check system's home
String system_mailcap = System.getProperty("java.home") + if (confDir != null) {
File.separator + "lib" + File.separator + "mailcap"; mf = loadFile(confDir + "mailcap");
mf = loadFile(system_mailcap);
if (mf != null) if (mf != null)
dbv.add(mf); dbv.add(mf);
}
} catch (SecurityException ex) {} } catch (SecurityException ex) {}
LogSupport.log("MailcapCommandMap: load JAR"); LogSupport.log("MailcapCommandMap: load JAR");
@ -633,6 +665,7 @@ public class MailcapCommandMap extends CommandMap {
* entries that specify a view command for the specified * entries that specify a view command for the specified
* MIME type are returned. * MIME type are returned.
* *
* @param mimeType the MIME type
* @return array of native command entries * @return array of native command entries
* @since 1.6, JAF 1.1 * @since 1.6, JAF 1.1
*/ */

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 1997, 2012, 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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -58,6 +58,7 @@ public class MimeType implements Externalizable {
* Constructor that builds a MimeType from a String. * Constructor that builds a MimeType from a String.
* *
* @param rawdata the MIME type string * @param rawdata the MIME type string
* @exception MimeTypeParseException if the MIME type can't be parsed
*/ */
public MimeType(String rawdata) throws MimeTypeParseException { public MimeType(String rawdata) throws MimeTypeParseException {
parse(rawdata); parse(rawdata);
@ -258,6 +259,7 @@ public class MimeType implements Externalizable {
* *
* @param rawdata the MIME type string to compare with * @param rawdata the MIME type string to compare with
* @return true if they match * @return true if they match
* @exception MimeTypeParseException if the MIME type can't be parsed
*/ */
public boolean match(String rawdata) throws MimeTypeParseException { public boolean match(String rawdata) throws MimeTypeParseException {
return match(new MimeType(rawdata)); return match(new MimeType(rawdata));

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 1997, 2012, 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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -58,6 +58,7 @@ public class MimeTypeParameterList {
* Constructs a new MimeTypeParameterList with the passed in data. * Constructs a new MimeTypeParameterList with the passed in data.
* *
* @param parameterList an RFC 2045, 2046 compliant parameter list. * @param parameterList an RFC 2045, 2046 compliant parameter list.
* @exception MimeTypeParseException if the MIME type can't be parsed
*/ */
public MimeTypeParameterList(String parameterList) public MimeTypeParameterList(String parameterList)
throws MimeTypeParseException { throws MimeTypeParseException {
@ -71,6 +72,7 @@ public class MimeTypeParameterList {
* A routine for parsing the parameter list out of a String. * A routine for parsing the parameter list out of a String.
* *
* @param parameterList an RFC 2045, 2046 compliant parameter list. * @param parameterList an RFC 2045, 2046 compliant parameter list.
* @exception MimeTypeParseException if the MIME type can't be parsed
*/ */
protected void parse(String parameterList) throws MimeTypeParseException { protected void parse(String parameterList) throws MimeTypeParseException {
if (parameterList == null) if (parameterList == null)

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 1997, 2012, 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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -28,6 +28,8 @@ package javax.activation;
import java.io.*; import java.io.*;
import java.net.*; import java.net.*;
import java.util.*; import java.util.*;
import java.security.AccessController;
import java.security.PrivilegedAction;
import com.sun.activation.registries.MimeTypeFile; import com.sun.activation.registries.MimeTypeFile;
import com.sun.activation.registries.LogSupport; import com.sun.activation.registries.LogSupport;
@ -43,12 +45,19 @@ import com.sun.activation.registries.LogSupport;
* <ol> * <ol>
* <li> Programmatically added entries to the MimetypesFileTypeMap instance. * <li> Programmatically added entries to the MimetypesFileTypeMap instance.
* <li> The file {@code .mime.types} in the user's home directory. * <li> The file {@code .mime.types} in the user's home directory.
* <li> The file {@literal <}<i>java.home</i>{@literal >}{@code /lib/mime.types}. * <li> The file {@code mime.types} in the Java runtime.
* <li> The file or resources named {@code META-INF/mime.types}. * <li> The file or resources named {@code META-INF/mime.types}.
* <li> The file or resource named {@code META-INF/mimetypes.default} * <li> The file or resource named {@code META-INF/mimetypes.default}
* (usually found only in the {@code activation.jar} file). * (usually found only in the {@code activation.jar} file).
* </ol> * </ol>
* <p> * <p>
* (The current implementation looks for the {@code mime.types} file
* in the Java runtime in the directory <i>java.home</i>{@code /conf}
* if it exists, and otherwise in the directory
* <i>java.home</i>{@code /lib}, where <i>java.home</i> is the value
* of the "java.home" System property. Note that the "conf" directory was
* introduced in JDK 9.)
* <p>
* <b>MIME types file format:</b> * <b>MIME types file format:</b>
* *
* <pre>{@code * <pre>{@code
@ -72,7 +81,30 @@ public class MimetypesFileTypeMap extends FileTypeMap {
private MimeTypeFile[] DB; private MimeTypeFile[] DB;
private static final int PROG = 0; // programmatically added entries private static final int PROG = 0; // programmatically added entries
private static String defaultType = "application/octet-stream"; private static final String defaultType = "application/octet-stream";
private static final String confDir;
static {
String dir = null;
try {
dir = (String)AccessController.doPrivileged(
new PrivilegedAction() {
public Object run() {
String home = System.getProperty("java.home");
String newdir = home + File.separator + "conf";
File conf = new File(newdir);
if (conf.exists())
return newdir + File.separator;
else
return home + File.separator + "lib" + File.separator;
}
});
} catch (Exception ex) {
// ignore any exceptions
}
confDir = dir;
}
/** /**
* The default constructor. * The default constructor.
@ -97,11 +129,11 @@ public class MimetypesFileTypeMap extends FileTypeMap {
LogSupport.log("MimetypesFileTypeMap: load SYS"); LogSupport.log("MimetypesFileTypeMap: load SYS");
try { try {
// check system's home // check system's home
String system_mimetypes = System.getProperty("java.home") + if (confDir != null) {
File.separator + "lib" + File.separator + "mime.types"; mf = loadFile(confDir + "mime.types");
mf = loadFile(system_mimetypes);
if (mf != null) if (mf != null)
dbv.addElement(mf); dbv.addElement(mf);
}
} catch (SecurityException ex) {} } catch (SecurityException ex) {}
LogSupport.log("MimetypesFileTypeMap: load JAR"); LogSupport.log("MimetypesFileTypeMap: load JAR");
@ -239,6 +271,7 @@ public class MimetypesFileTypeMap extends FileTypeMap {
* added from the named file. * added from the named file.
* *
* @param mimeTypeFileName the file name * @param mimeTypeFileName the file name
* @exception IOException for errors reading the file
*/ */
public MimetypesFileTypeMap(String mimeTypeFileName) throws IOException { public MimetypesFileTypeMap(String mimeTypeFileName) throws IOException {
this(); this();

View file

@ -26,14 +26,17 @@
/** /**
* Defines the JavaBeans Activation Framework (JAF) API. * Defines the JavaBeans Activation Framework (JAF) API.
* *
* <p> This module is upgradeble.
*
* @moduleGraph * @moduleGraph
* @since 9 * @since 9
*/ */
@Deprecated(since="9", forRemoval=true) @Deprecated(since="9", forRemoval=true)
module java.activation { module java.activation {
requires transitive java.datatransfer;
requires java.logging; requires java.logging;
requires transitive java.datatransfer;
exports javax.activation; exports javax.activation;
} }

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 1997, 2012, 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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -48,7 +48,7 @@ public class MinimumEscapeHandler implements CharacterEscapeHandler {
int limit = start+length; int limit = start+length;
for (int i = start; i < limit; i++) { for (int i = start; i < limit; i++) {
char c = ch[i]; char c = ch[i];
if(c == '&' || c == '<' || c == '>' || c == '\r' || (c == '\"' && isAttVal) ) { if (c == '&' || c == '<' || c == '>' || c == '\r' || (c == '\n' && isAttVal) || (c == '\"' && isAttVal)) {
if (i != start) if (i != start)
out.write(ch, start, i - start); out.write(ch, start, i - start);
start = i + 1; start = i + 1;
@ -65,6 +65,14 @@ public class MinimumEscapeHandler implements CharacterEscapeHandler {
case '\"': case '\"':
out.write("&quot;"); out.write("&quot;");
break; break;
case '\n':
case '\r':
out.write("&#");
out.write(Integer.toString(c));
out.write(';');
break;
default:
throw new IllegalArgumentException("Cannot escape: '" + c + "'");
} }
} }
} }

View file

@ -0,0 +1,45 @@
/*
* 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 com.sun.xml.internal.bind.marshaller;
import java.io.IOException;
import java.io.Writer;
/**
* Performs no character escaping.
*
* @author
* Roman Grigoriadi (roman.grigoriadi@oracle.com)
*/
public class NoEscapeHandler implements CharacterEscapeHandler {
public static final NoEscapeHandler theInstance = new NoEscapeHandler();
@Override
public void escape(char[] ch, int start, int length, boolean isAttVal, Writer out) throws IOException {
out.write(ch, start, length);
}
}

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 1997, 2012, 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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -76,7 +76,7 @@ final class BridgeImpl<T> extends InternalBridge<T> {
public void marshal(Marshaller _m, T t, XMLStreamWriter output) throws JAXBException { public void marshal(Marshaller _m, T t, XMLStreamWriter output) throws JAXBException {
MarshallerImpl m = (MarshallerImpl)_m; MarshallerImpl m = (MarshallerImpl)_m;
m.write(tagName,bi,t,XMLStreamWriterOutput.create(output,context),new StAXPostInitAction(output,m.serializer)); m.write(tagName,bi,t,XMLStreamWriterOutput.create(output,context, m.getEscapeHandler()),new StAXPostInitAction(output,m.serializer));
} }
public void marshal(Marshaller _m, T t, OutputStream output, NamespaceContext nsContext) throws JAXBException { public void marshal(Marshaller _m, T t, OutputStream output, NamespaceContext nsContext) throws JAXBException {

View file

@ -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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -165,7 +165,7 @@ public /*to make unit tests happy*/ final class MarshallerImpl extends AbstractM
@Override @Override
public void marshal(Object obj, XMLStreamWriter writer) throws JAXBException { public void marshal(Object obj, XMLStreamWriter writer) throws JAXBException {
write(obj, XMLStreamWriterOutput.create(writer,context), new StAXPostInitAction(writer,serializer)); write(obj, XMLStreamWriterOutput.create(writer,context, escapeHandler), new StAXPostInitAction(writer,serializer));
} }
@Override @Override
@ -371,6 +371,15 @@ public /*to make unit tests happy*/ final class MarshallerImpl extends AbstractM
} }
/**
* Returns escape handler provided with JAXB context parameters.
*
* @return escape handler
*/
CharacterEscapeHandler getEscapeHandler() {
return escapeHandler;
}
// //
// //
// create XMLWriter by specifing various type of output. // create XMLWriter by specifing various type of output.
@ -436,13 +445,14 @@ public /*to make unit tests happy*/ final class MarshallerImpl extends AbstractM
if(encoding.equals("UTF-8")) { if(encoding.equals("UTF-8")) {
Encoded[] table = context.getUTF8NameTable(); Encoded[] table = context.getUTF8NameTable();
final UTF8XmlOutput out; final UTF8XmlOutput out;
CharacterEscapeHandler ceh = createEscapeHandler(encoding);
if(isFormattedOutput()) if(isFormattedOutput())
out = new IndentingUTF8XmlOutput(os, indent, table, escapeHandler); out = new IndentingUTF8XmlOutput(os, indent, table, ceh);
else { else {
if(c14nSupport) if(c14nSupport)
out = new C14nXmlOutput(os, table, context.c14nSupport, escapeHandler); out = new C14nXmlOutput(os, table, context.c14nSupport, ceh);
else else
out = new UTF8XmlOutput(os, table, escapeHandler); out = new UTF8XmlOutput(os, table, ceh);
} }
if(header!=null) if(header!=null)
out.setHeader(header); out.setHeader(header);

View file

@ -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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -25,21 +25,22 @@
package com.sun.xml.internal.bind.v2.runtime.output; package com.sun.xml.internal.bind.v2.runtime.output;
import com.sun.xml.internal.bind.marshaller.NoEscapeHandler;
import com.sun.xml.internal.bind.v2.runtime.JAXBContextImpl; import com.sun.xml.internal.bind.v2.runtime.JAXBContextImpl;
import com.sun.xml.internal.bind.v2.runtime.Name; import com.sun.xml.internal.bind.v2.runtime.Name;
import com.sun.xml.internal.bind.v2.runtime.XMLSerializer; import com.sun.xml.internal.bind.v2.runtime.XMLSerializer;
import javax.xml.stream.XMLStreamException;
import com.sun.xml.internal.bind.v2.runtime.unmarshaller.Base64Data; import com.sun.xml.internal.bind.v2.runtime.unmarshaller.Base64Data;
import com.sun.xml.internal.fastinfoset.EncodingConstants; import com.sun.xml.internal.fastinfoset.EncodingConstants;
import com.sun.xml.internal.fastinfoset.stax.StAXDocumentSerializer; import com.sun.xml.internal.fastinfoset.stax.StAXDocumentSerializer;
import com.sun.xml.internal.org.jvnet.fastinfoset.VocabularyApplicationData;
import org.xml.sax.SAXException;
import javax.xml.bind.JAXBContext;
import javax.xml.stream.XMLStreamException;
import java.io.IOException; import java.io.IOException;
import java.util.Collection; import java.util.Collection;
import java.util.Map; import java.util.Map;
import java.util.WeakHashMap; import java.util.WeakHashMap;
import javax.xml.bind.JAXBContext;
import com.sun.xml.internal.org.jvnet.fastinfoset.VocabularyApplicationData;
import org.xml.sax.SAXException;
/** /**
* {@link XmlOutput} for {@link StAXDocumentSerializer}. * {@link XmlOutput} for {@link StAXDocumentSerializer}.
@ -220,7 +221,7 @@ public final class FastInfosetStreamWriterOutput extends XMLStreamWriterOutput {
public FastInfosetStreamWriterOutput(StAXDocumentSerializer out, public FastInfosetStreamWriterOutput(StAXDocumentSerializer out,
JAXBContextImpl context) { JAXBContextImpl context) {
super(out); super(out, NoEscapeHandler.theInstance);
this.fiout = out; this.fiout = out;
this.localNames = context.getUTF8NameTable(); this.localNames = context.getUTF8NameTable();

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 1997, 2012, 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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -27,6 +27,7 @@ package com.sun.xml.internal.bind.v2.runtime.output;
import javax.xml.stream.XMLStreamException; import javax.xml.stream.XMLStreamException;
import com.sun.xml.internal.bind.marshaller.NoEscapeHandler;
import com.sun.xml.internal.bind.v2.runtime.unmarshaller.Base64Data; import com.sun.xml.internal.bind.v2.runtime.unmarshaller.Base64Data;
import com.sun.xml.internal.org.jvnet.staxex.XMLStreamWriterEx; import com.sun.xml.internal.org.jvnet.staxex.XMLStreamWriterEx;
@ -40,7 +41,7 @@ public final class StAXExStreamWriterOutput extends XMLStreamWriterOutput {
private final XMLStreamWriterEx out; private final XMLStreamWriterEx out;
public StAXExStreamWriterOutput(XMLStreamWriterEx out) { public StAXExStreamWriterOutput(XMLStreamWriterEx out) {
super(out); super(out, NoEscapeHandler.theInstance);
this.out = out; this.out = out;
} }

View file

@ -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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -26,15 +26,16 @@
package com.sun.xml.internal.bind.v2.runtime.output; package com.sun.xml.internal.bind.v2.runtime.output;
import java.io.IOException; import java.io.IOException;
import java.io.Writer;
import java.lang.reflect.Constructor; import java.lang.reflect.Constructor;
import javax.xml.stream.XMLStreamException; import javax.xml.stream.XMLStreamException;
import javax.xml.stream.XMLStreamWriter; import javax.xml.stream.XMLStreamWriter;
import com.sun.xml.internal.bind.marshaller.CharacterEscapeHandler;
import com.sun.xml.internal.bind.v2.runtime.JAXBContextImpl; import com.sun.xml.internal.bind.v2.runtime.JAXBContextImpl;
import com.sun.xml.internal.bind.v2.runtime.XMLSerializer; import com.sun.xml.internal.bind.v2.runtime.XMLSerializer;
import com.sun.xml.internal.bind.v2.runtime.unmarshaller.UnmarshallerImpl;
import org.xml.sax.SAXException; import org.xml.sax.SAXException;
/** /**
@ -53,7 +54,7 @@ public class XMLStreamWriterOutput extends XmlOutputAbstractImpl {
* Creates a new {@link XmlOutput} from a {@link XMLStreamWriter}. * Creates a new {@link XmlOutput} from a {@link XMLStreamWriter}.
* This method recognizes an FI StAX writer. * This method recognizes an FI StAX writer.
*/ */
public static XmlOutput create(XMLStreamWriter out, JAXBContextImpl context) { public static XmlOutput create(XMLStreamWriter out, JAXBContextImpl context, CharacterEscapeHandler escapeHandler) {
// try optimized path // try optimized path
final Class writerClass = out.getClass(); final Class writerClass = out.getClass();
if (writerClass==FI_STAX_WRITER_CLASS) { if (writerClass==FI_STAX_WRITER_CLASS) {
@ -69,17 +70,26 @@ public class XMLStreamWriterOutput extends XmlOutputAbstractImpl {
} }
} }
CharacterEscapeHandler xmlStreamEscapeHandler = escapeHandler != null ?
escapeHandler : NewLineEscapeHandler.theInstance;
// otherwise the normal writer. // otherwise the normal writer.
return new XMLStreamWriterOutput(out); return new XMLStreamWriterOutput(out, xmlStreamEscapeHandler);
} }
private final XMLStreamWriter out; private final XMLStreamWriter out;
private final CharacterEscapeHandler escapeHandler;
private final XmlStreamOutWriterAdapter writerWrapper;
protected final char[] buf = new char[256]; protected final char[] buf = new char[256];
protected XMLStreamWriterOutput(XMLStreamWriter out) { protected XMLStreamWriterOutput(XMLStreamWriter out, CharacterEscapeHandler escapeHandler) {
this.out = out; this.out = out;
this.escapeHandler = escapeHandler;
this.writerWrapper = new XmlStreamOutWriterAdapter(out);
} }
// not called if we are generating fragments // not called if we are generating fragments
@ -137,7 +147,7 @@ public class XMLStreamWriterOutput extends XmlOutputAbstractImpl {
public void text(String value, boolean needsSeparatingWhitespace) throws IOException, SAXException, XMLStreamException { public void text(String value, boolean needsSeparatingWhitespace) throws IOException, SAXException, XMLStreamException {
if(needsSeparatingWhitespace) if(needsSeparatingWhitespace)
out.writeCharacters(" "); out.writeCharacters(" ");
out.writeCharacters(value); escapeHandler.escape(value.toCharArray(), 0, value.length(), false, writerWrapper);
} }
public void text(Pcdata value, boolean needsSeparatingWhitespace) throws IOException, SAXException, XMLStreamException { public void text(Pcdata value, boolean needsSeparatingWhitespace) throws IOException, SAXException, XMLStreamException {
@ -207,4 +217,81 @@ public class XMLStreamWriterOutput extends XmlOutputAbstractImpl {
} }
} }
/**
* Performs character escaping only for new lines.
*/
private static class NewLineEscapeHandler implements CharacterEscapeHandler {
public static final NewLineEscapeHandler theInstance = new NewLineEscapeHandler();
@Override
public void escape(char[] ch, int start, int length, boolean isAttVal, Writer out) throws IOException {
int limit = start+length;
int lastEscaped = start;
for (int i = start; i < limit; i++) {
char c = ch[i];
if (c == '\r' || c == '\n') {
if (i != lastEscaped) {
out.write(ch, lastEscaped, i - lastEscaped);
}
lastEscaped = i + 1;
if (out instanceof XmlStreamOutWriterAdapter) {
try {
((XmlStreamOutWriterAdapter)out).writeEntityRef("#x" + Integer.toHexString(c));
} catch (XMLStreamException e) {
throw new IOException("Error writing xml stream", e);
}
} else {
out.write("&#x");
out.write(Integer.toHexString(c));
out.write(';');
}
}
}
if (lastEscaped != limit) {
out.write(ch, lastEscaped, length - lastEscaped);
}
}
}
private static final class XmlStreamOutWriterAdapter extends Writer {
private final XMLStreamWriter writer;
private XmlStreamOutWriterAdapter(XMLStreamWriter writer) {
this.writer = writer;
}
@Override
public void write(char[] cbuf, int off, int len) throws IOException {
try {
writer.writeCharacters(cbuf, off, len);
} catch (XMLStreamException e) {
throw new IOException("Error writing XML stream", e);
}
}
public void writeEntityRef(String entityReference) throws XMLStreamException {
writer.writeEntityRef(entityReference);
}
@Override
public void flush() throws IOException {
try {
writer.flush();
} catch (XMLStreamException e) {
throw new IOException("Error flushing XML stream", e);
}
}
@Override
public void close() throws IOException {
try {
writer.close();
} catch (XMLStreamException e) {
throw new IOException("Error closing XML stream", e);
}
}
}
} }

View file

@ -150,13 +150,14 @@ class ContextFinder {
* Create an instance of a class using the specified ClassLoader * Create an instance of a class using the specified ClassLoader
*/ */
static JAXBContext newInstance(String contextPath, static JAXBContext newInstance(String contextPath,
Class[] contextPathClasses,
String className, String className,
ClassLoader classLoader, ClassLoader classLoader,
Map properties) throws JAXBException { Map properties) throws JAXBException {
try { try {
Class spFactory = ServiceLoaderUtil.safeLoadClass(className, PLATFORM_DEFAULT_FACTORY_CLASS, classLoader); Class spFactory = ServiceLoaderUtil.safeLoadClass(className, PLATFORM_DEFAULT_FACTORY_CLASS, classLoader);
return newInstance(contextPath, spFactory, classLoader, properties); return newInstance(contextPath, contextPathClasses, spFactory, classLoader, properties);
} catch (ClassNotFoundException x) { } catch (ClassNotFoundException x) {
throw new JAXBException(Messages.format(Messages.DEFAULT_PROVIDER_NOT_FOUND), x); throw new JAXBException(Messages.format(Messages.DEFAULT_PROVIDER_NOT_FOUND), x);
@ -175,6 +176,7 @@ class ContextFinder {
} }
static JAXBContext newInstance(String contextPath, static JAXBContext newInstance(String contextPath,
Class[] contextPathClasses,
Class spFactory, Class spFactory,
ClassLoader classLoader, ClassLoader classLoader,
Map properties) throws JAXBException { Map properties) throws JAXBException {
@ -212,6 +214,9 @@ class ContextFinder {
// the cast would fail, so generate an exception with a nice message // the cast would fail, so generate an exception with a nice message
throw handleClassCastException(context.getClass(), JAXBContext.class); throw handleClassCastException(context.getClass(), JAXBContext.class);
} }
ModuleUtil.delegateAddOpensToImplModule(contextPathClasses, spFactory);
return (JAXBContext) context; return (JAXBContext) context;
} catch (InvocationTargetException x) { } catch (InvocationTargetException x) {
// throw if it is exception not to be wrapped // throw if it is exception not to be wrapped
@ -277,6 +282,7 @@ class ContextFinder {
// the cast would fail, so generate an exception with a nice message // the cast would fail, so generate an exception with a nice message
throw handleClassCastException(context.getClass(), JAXBContext.class); throw handleClassCastException(context.getClass(), JAXBContext.class);
} }
ModuleUtil.delegateAddOpensToImplModule(classes, spFactory);
return (JAXBContext) context; return (JAXBContext) context;
} catch (NoSuchMethodException | IllegalAccessException e) { } catch (NoSuchMethodException | IllegalAccessException e) {
@ -295,50 +301,52 @@ class ContextFinder {
ClassLoader classLoader, ClassLoader classLoader,
Map properties) throws JAXBException { Map properties) throws JAXBException {
StringTokenizer packages = new StringTokenizer(contextPath, ":"); if (contextPath == null || contextPath.isEmpty()) {
if (!packages.hasMoreTokens()) {
// no context is specified // no context is specified
throw new JAXBException(Messages.format(Messages.NO_PACKAGE_IN_CONTEXTPATH)); throw new JAXBException(Messages.format(Messages.NO_PACKAGE_IN_CONTEXTPATH));
} }
// search for jaxb.properties in the class loader of each class first //ModuleUtil is mr-jar class, scans context path for jaxb classes on jdk9 and higher
logger.fine("Searching jaxb.properties"); Class[] contextPathClasses = ModuleUtil.getClassesFromContextPath(contextPath, classLoader);
while (packages.hasMoreTokens()) {
// com.acme.foo - > com/acme/foo/jaxb.properties //first try with classloader#getResource
String factoryClassName = String factoryClassName = jaxbProperties(contextPath, classLoader, factoryId);
classNameFromPackageProperties( if (factoryClassName == null && contextPathClasses != null) {
classLoader, //try with class#getResource
packages.nextToken(":").replace('.', '/'), factoryClassName = jaxbProperties(contextPathClasses, factoryId);
factoryId, }
JAXB_CONTEXT_FACTORY_DEPRECATED);
if (factoryClassName != null) { if (factoryClassName != null) {
return newInstance(contextPath, factoryClassName, classLoader, properties); return newInstance(contextPath, contextPathClasses, factoryClassName, classLoader, properties);
}
} }
String factoryName = classNameFromSystemProperties(); String factoryName = classNameFromSystemProperties();
if (factoryName != null) return newInstance(contextPath, factoryName, classLoader, properties); if (factoryName != null) return newInstance(contextPath, contextPathClasses, factoryName, classLoader, properties);
JAXBContextFactory obj = ServiceLoaderUtil.firstByServiceLoader( JAXBContextFactory obj = ServiceLoaderUtil.firstByServiceLoader(
JAXBContextFactory.class, logger, EXCEPTION_HANDLER); JAXBContextFactory.class, logger, EXCEPTION_HANDLER);
if (obj != null) return obj.createContext(contextPath, classLoader, properties); if (obj != null) {
JAXBContext context = obj.createContext(contextPath, classLoader, properties);
ModuleUtil.delegateAddOpensToImplModule(contextPathClasses, obj.getClass());
return context;
}
// to ensure backwards compatibility // to ensure backwards compatibility
factoryName = firstByServiceLoaderDeprecated(JAXBContext.class, classLoader); factoryName = firstByServiceLoaderDeprecated(JAXBContext.class, classLoader);
if (factoryName != null) return newInstance(contextPath, factoryName, classLoader, properties); if (factoryName != null) return newInstance(contextPath, contextPathClasses, factoryName, classLoader, properties);
Class ctxFactory = (Class) ServiceLoaderUtil.lookupUsingOSGiServiceLoader( Class ctxFactory = (Class) ServiceLoaderUtil.lookupUsingOSGiServiceLoader(
"javax.xml.bind.JAXBContext", logger); "javax.xml.bind.JAXBContext", logger);
if (ctxFactory != null) { if (ctxFactory != null) {
return newInstance(contextPath, ctxFactory, classLoader, properties); return newInstance(contextPath, contextPathClasses, ctxFactory, classLoader, properties);
} }
// else no provider found // else no provider found
logger.fine("Trying to create the platform default provider"); logger.fine("Trying to create the platform default provider");
return newInstance(contextPath, PLATFORM_DEFAULT_FACTORY_CLASS, classLoader, properties); return newInstance(contextPath, contextPathClasses, PLATFORM_DEFAULT_FACTORY_CLASS, classLoader, properties);
} }
static JAXBContext find(Class<?>[] classes, Map<String, ?> properties) throws JAXBException { static JAXBContext find(Class<?>[] classes, Map<String, ?> properties) throws JAXBException {
@ -356,13 +364,18 @@ class ContextFinder {
// TODO: it's easier to look things up from the class // TODO: it's easier to look things up from the class
// c.getResourceAsStream("jaxb.properties"); // c.getResourceAsStream("jaxb.properties");
URL jaxbPropertiesUrl = getResourceUrl(c, "jaxb.properties");
if (jaxbPropertiesUrl != null) {
String factoryClassName = String factoryClassName =
classNameFromPackageProperties( classNameFromPackageProperties(
getClassClassLoader(c), jaxbPropertiesUrl,
c.getPackage().getName().replace('.', '/'),
JAXBContext.JAXB_CONTEXT_FACTORY, JAXB_CONTEXT_FACTORY_DEPRECATED); JAXBContext.JAXB_CONTEXT_FACTORY, JAXB_CONTEXT_FACTORY_DEPRECATED);
if (factoryClassName != null) return newInstance(classes, properties, factoryClassName); return newInstance(classes, properties, factoryClassName);
}
} }
String factoryClassName = classNameFromSystemProperties(); String factoryClassName = classNameFromSystemProperties();
@ -371,7 +384,11 @@ class ContextFinder {
JAXBContextFactory factory = JAXBContextFactory factory =
ServiceLoaderUtil.firstByServiceLoader(JAXBContextFactory.class, logger, EXCEPTION_HANDLER); ServiceLoaderUtil.firstByServiceLoader(JAXBContextFactory.class, logger, EXCEPTION_HANDLER);
if (factory != null) return factory.createContext(classes, properties); if (factory != null) {
JAXBContext context = factory.createContext(classes, properties);
ModuleUtil.delegateAddOpensToImplModule(classes, factory.getClass());
return context;
}
// to ensure backwards compatibility // to ensure backwards compatibility
String className = firstByServiceLoaderDeprecated(JAXBContext.class, getContextClassLoader()); String className = firstByServiceLoaderDeprecated(JAXBContext.class, getContextClassLoader());
@ -395,23 +412,21 @@ class ContextFinder {
* first factoryId should be the preferred one, * first factoryId should be the preferred one,
* more of those can be provided to support backwards compatibility * more of those can be provided to support backwards compatibility
*/ */
private static String classNameFromPackageProperties(ClassLoader classLoader, private static String classNameFromPackageProperties(URL packagePropertiesUrl,
String packageName,
String ... factoryIds) throws JAXBException { String ... factoryIds) throws JAXBException {
String resourceName = packageName + "/jaxb.properties"; logger.log(Level.FINE, "Trying to locate {0}", packagePropertiesUrl.toString());
logger.log(Level.FINE, "Trying to locate {0}", resourceName); Properties props = loadJAXBProperties(packagePropertiesUrl);
Properties props = loadJAXBProperties(classLoader, resourceName);
if (props != null) {
for(String factoryId : factoryIds) { for(String factoryId : factoryIds) {
if (props.containsKey(factoryId)) { if (props.containsKey(factoryId)) {
return props.getProperty(factoryId); return props.getProperty(factoryId);
} }
} }
//Factory key not found
String propertiesUrl = packagePropertiesUrl.toExternalForm();
String packageName = propertiesUrl.substring(0, propertiesUrl.indexOf("/jaxb.properties"));
throw new JAXBException(Messages.format(Messages.MISSING_PROPERTY, packageName, factoryIds[0])); throw new JAXBException(Messages.format(Messages.MISSING_PROPERTY, packageName, factoryIds[0]));
} }
return null;
}
private static String classNameFromSystemProperties() throws JAXBException { private static String classNameFromSystemProperties() throws JAXBException {
@ -452,30 +467,40 @@ class ContextFinder {
return value; return value;
} }
private static Properties loadJAXBProperties(ClassLoader classLoader, private static Properties loadJAXBProperties(URL url) throws JAXBException {
String propFileName) throws JAXBException {
Properties props = null;
try { try {
URL url; Properties props;
if (classLoader == null)
url = ClassLoader.getSystemResource(propFileName);
else
url = classLoader.getResource(propFileName);
if (url != null) {
logger.log(Level.FINE, "loading props from {0}", url); logger.log(Level.FINE, "loading props from {0}", url);
props = new Properties(); props = new Properties();
InputStream is = url.openStream(); InputStream is = url.openStream();
props.load(is); props.load(is);
is.close(); is.close();
} return props;
} catch (IOException ioe) { } catch (IOException ioe) {
logger.log(Level.FINE, "Unable to load " + propFileName, ioe); logger.log(Level.FINE, "Unable to load " + url.toString(), ioe);
throw new JAXBException(ioe.toString(), ioe); throw new JAXBException(ioe.toString(), ioe);
} }
}
return props; /**
* If run on JPMS package containing resource must be open unconditionally.
*
* @param classLoader classloader to load resource with
* @param resourceName qualified name of the resource
* @return resource url if found
*/
private static URL getResourceUrl(ClassLoader classLoader, String resourceName) {
URL url;
if (classLoader == null)
url = ClassLoader.getSystemResource(resourceName);
else
url = classLoader.getResource(resourceName);
return url;
}
private static URL getResourceUrl(Class<?> clazz, String resourceName) {
return clazz.getResource(resourceName);
} }
@ -606,4 +631,28 @@ class ContextFinder {
} }
} }
private static String jaxbProperties(String contextPath, ClassLoader classLoader, String factoryId) throws JAXBException {
String[] packages = contextPath.split(":");
for (String pkg : packages) {
String pkgUrl = pkg.replace('.', '/');
URL jaxbPropertiesUrl = getResourceUrl(classLoader, pkgUrl + "/jaxb.properties");
if (jaxbPropertiesUrl != null) {
return classNameFromPackageProperties(jaxbPropertiesUrl,
factoryId, JAXB_CONTEXT_FACTORY_DEPRECATED);
}
}
return null;
}
private static String jaxbProperties(Class[] classesFromContextPath, String factoryId) throws JAXBException {
for (Class c : classesFromContextPath) {
URL jaxbPropertiesUrl = getResourceUrl(c, "jaxb.properties");
if (jaxbPropertiesUrl != null) {
return classNameFromPackageProperties(jaxbPropertiesUrl, factoryId, JAXB_CONTEXT_FACTORY_DEPRECATED);
}
}
return null;
}
} }

View file

@ -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.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -27,11 +27,11 @@ package javax.xml.bind;
import org.w3c.dom.Node; import org.w3c.dom.Node;
import java.io.IOException;
import java.io.InputStream;
import java.util.Collections; import java.util.Collections;
import java.util.Map; import java.util.Map;
import java.util.Properties; import java.util.Properties;
import java.io.IOException;
import java.io.InputStream;
/** /**
* The {@code JAXBContext} class provides the client's entry point to the * The {@code JAXBContext} class provides the client's entry point to the
@ -227,6 +227,9 @@ import java.io.InputStream;
* This phase of the look up allows some packages to force the use of a certain JAXB implementation. * This phase of the look up allows some packages to force the use of a certain JAXB implementation.
* (For example, perhaps the schema compiler has generated some vendor extension in the code.) * (For example, perhaps the schema compiler has generated some vendor extension in the code.)
* *
* <p>
* This configuration method is deprecated.
*
* <li> * <li>
* If the system property {@link #JAXB_CONTEXT_FACTORY} exists, then its value is assumed to be the provider * If the system property {@link #JAXB_CONTEXT_FACTORY} exists, then its value is assumed to be the provider
* factory class. If no such property exists, properties {@code "javax.xml.bind.context.factory"} and * factory class. If no such property exists, properties {@code "javax.xml.bind.context.factory"} and
@ -332,7 +335,14 @@ public abstract class JAXBContext {
* the context class loader of the current thread. * the context class loader of the current thread.
* *
* @throws JAXBException if an error was encountered while creating the * @throws JAXBException if an error was encountered while creating the
* {@code JAXBContext}. See {@link JAXBContext#newInstance(String, ClassLoader, Map)} for details. * {@code JAXBContext} such as
* <ol>
* <li>failure to locate either ObjectFactory.class or jaxb.index in the packages</li>
* <li>an ambiguity among global elements contained in the contextPath</li>
* <li>failure to locate a value for the context factory provider property</li>
* <li>mixing schema derived packages from different providers on the same contextPath</li>
* <li>packages are not open to {@code java.xml.bind} module</li>
* </ol>
*/ */
public static JAXBContext newInstance( String contextPath ) public static JAXBContext newInstance( String contextPath )
throws JAXBException { throws JAXBException {
@ -414,16 +424,26 @@ public abstract class JAXBContext {
* <p> * <p>
* The steps involved in discovering the JAXB implementation is discussed in the class javadoc. * The steps involved in discovering the JAXB implementation is discussed in the class javadoc.
* *
* @param contextPath list of java package names that contain schema * @param contextPath
* List of java package names that contain schema
* derived class and/or java to schema (JAXB-annotated) * derived class and/or java to schema (JAXB-annotated)
* mapped classes * mapped classes.
* Packages in {@code contextPath} that are in named modules must be
* {@linkplain java.lang.Module#isOpen open} to at least the {@code java.xml.bind} module.
* @param classLoader * @param classLoader
* This class loader will be used to locate the implementation * This class loader will be used to locate the implementation
* classes. * classes.
* *
* @return a new instance of a {@code JAXBContext} * @return a new instance of a {@code JAXBContext}
* @throws JAXBException if an error was encountered while creating the * @throws JAXBException if an error was encountered while creating the
* {@code JAXBContext}. See {@link JAXBContext#newInstance(String, ClassLoader, Map)} for details. * {@code JAXBContext} such as
* <ol>
* <li>failure to locate either ObjectFactory.class or jaxb.index in the packages</li>
* <li>an ambiguity among global elements contained in the contextPath</li>
* <li>failure to locate a value for the context factory provider property</li>
* <li>mixing schema derived packages from different providers on the same contextPath</li>
* <li>packages are not open to {@code java.xml.bind} module</li>
* </ol>
*/ */
public static JAXBContext newInstance( String contextPath, ClassLoader classLoader ) throws JAXBException { public static JAXBContext newInstance( String contextPath, ClassLoader classLoader ) throws JAXBException {
@ -442,7 +462,12 @@ public abstract class JAXBContext {
* The interpretation of properties is up to implementations. Implementations must * The interpretation of properties is up to implementations. Implementations must
* throw {@code JAXBException} if it finds properties that it doesn't understand. * throw {@code JAXBException} if it finds properties that it doesn't understand.
* *
* @param contextPath list of java package names that contain schema derived classes * @param contextPath
* List of java package names that contain schema
* derived class and/or java to schema (JAXB-annotated)
* mapped classes.
* Packages in {@code contextPath} that are in named modules must be
* {@linkplain java.lang.Module#isOpen open} to at least the {@code java.xml.bind} module.
* @param classLoader * @param classLoader
* This class loader will be used to locate the implementation classes. * This class loader will be used to locate the implementation classes.
* @param properties * @param properties
@ -457,6 +482,7 @@ public abstract class JAXBContext {
* <li>an ambiguity among global elements contained in the contextPath</li> * <li>an ambiguity among global elements contained in the contextPath</li>
* <li>failure to locate a value for the context factory provider property</li> * <li>failure to locate a value for the context factory provider property</li>
* <li>mixing schema derived packages from different providers on the same contextPath</li> * <li>mixing schema derived packages from different providers on the same contextPath</li>
* <li>packages are not open to {@code java.xml.bind} module</li>
* </ol> * </ol>
* @since 1.6, JAXB 2.0 * @since 1.6, JAXB 2.0
*/ */
@ -588,15 +614,27 @@ public abstract class JAXBContext {
* The steps involved in discovering the JAXB implementation is discussed in the class javadoc. * The steps involved in discovering the JAXB implementation is discussed in the class javadoc.
* *
* @param classesToBeBound * @param classesToBeBound
* list of java classes to be recognized by the new {@link JAXBContext}. * List of java classes to be recognized by the new {@link JAXBContext}.
* Classes in {@code classesToBeBound} that are in named modules must be in a package
* that is {@linkplain java.lang.Module#isOpen open} to at least the {@code java.xml.bind} module.
* Can be empty, in which case a {@link JAXBContext} that only knows about * Can be empty, in which case a {@link JAXBContext} that only knows about
* spec-defined classes will be returned. * spec-defined classes will be returned.
* *
* @return * @return
* A new instance of a {@code JAXBContext}. * A new instance of a {@code JAXBContext}.
* *
* @throws JAXBException if an error was encountered while creating the * @throws JAXBException
* {@code JAXBContext}. See {@link JAXBContext#newInstance(Class[], Map)} for details. * if an error was encountered while creating the
* {@code JAXBContext}, such as (but not limited to):
* <ol>
* <li>No JAXB implementation was discovered
* <li>Classes use JAXB annotations incorrectly
* <li>Classes have colliding annotations (i.e., two classes with the same type name)
* <li>The JAXB implementation was unable to locate
* provider-specific out-of-band information (such as additional
* files generated at the development time.)
* <li>{@code classesToBeBound} are not open to {@code java.xml.bind} module
* </ol>
* *
* @throws IllegalArgumentException * @throws IllegalArgumentException
* if the parameter contains {@code null} (i.e., {@code newInstance(null);}) * if the parameter contains {@code null} (i.e., {@code newInstance(null);})
@ -621,7 +659,9 @@ public abstract class JAXBContext {
* throw {@code JAXBException} if it finds properties that it doesn't understand. * throw {@code JAXBException} if it finds properties that it doesn't understand.
* *
* @param classesToBeBound * @param classesToBeBound
* list of java classes to be recognized by the new {@link JAXBContext}. * List of java classes to be recognized by the new {@link JAXBContext}.
* Classes in {@code classesToBeBound} that are in named modules must be in a package
* that is {@linkplain java.lang.Module#isOpen open} to at least the {@code java.xml.bind} module.
* Can be empty, in which case a {@link JAXBContext} that only knows about * Can be empty, in which case a {@link JAXBContext} that only knows about
* spec-defined classes will be returned. * spec-defined classes will be returned.
* @param properties * @param properties
@ -641,6 +681,7 @@ public abstract class JAXBContext {
* <li>The JAXB implementation was unable to locate * <li>The JAXB implementation was unable to locate
* provider-specific out-of-band information (such as additional * provider-specific out-of-band information (such as additional
* files generated at the development time.) * files generated at the development time.)
* <li>{@code classesToBeBound} are not open to {@code java.xml.bind} module
* </ol> * </ol>
* *
* @throws IllegalArgumentException * @throws IllegalArgumentException
@ -702,6 +743,7 @@ public abstract class JAXBContext {
* {@code Validator} object * {@code Validator} object
* @deprecated since JAXB2.0 * @deprecated since JAXB2.0
*/ */
@Deprecated
public abstract Validator createValidator() throws JAXBException; public abstract Validator createValidator() throws JAXBException;
/** /**

View file

@ -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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -44,7 +44,9 @@ public interface JAXBContextFactory {
* For semantics see {@link javax.xml.bind.JAXBContext#newInstance(Class[], java.util.Map)} * For semantics see {@link javax.xml.bind.JAXBContext#newInstance(Class[], java.util.Map)}
* *
* @param classesToBeBound * @param classesToBeBound
* list of java classes to be recognized by the new {@link JAXBContext}. * List of java classes to be recognized by the new {@link JAXBContext}.
* Classes in {@code classesToBeBound} that are in named modules must be in a package
* that is {@linkplain java.lang.Module#isOpen open} to at least the {@code java.xml.bind} module.
* Can be empty, in which case a {@link JAXBContext} that only knows about * Can be empty, in which case a {@link JAXBContext} that only knows about
* spec-defined classes will be returned. * spec-defined classes will be returned.
* @param properties * @param properties
@ -56,7 +58,16 @@ public interface JAXBContextFactory {
* *
* @throws JAXBException * @throws JAXBException
* if an error was encountered while creating the * if an error was encountered while creating the
* {@code JAXBContext}. See {@link JAXBContext#newInstance(Class[], Map)} for details. * {@code JAXBContext}, such as (but not limited to):
* <ol>
* <li>No JAXB implementation was discovered
* <li>Classes use JAXB annotations incorrectly
* <li>Classes have colliding annotations (i.e., two classes with the same type name)
* <li>The JAXB implementation was unable to locate
* provider-specific out-of-band information (such as additional
* files generated at the development time.)
* <li>{@code classesToBeBound} are not open to {@code java.xml.bind} module
* </ol>
* *
* @throws IllegalArgumentException * @throws IllegalArgumentException
* if the parameter contains {@code null} (i.e., {@code newInstance(null,someMap);}) * if the parameter contains {@code null} (i.e., {@code newInstance(null,someMap);})
@ -77,7 +88,10 @@ public interface JAXBContextFactory {
* The interpretation of properties is up to implementations. Implementations must * The interpretation of properties is up to implementations. Implementations must
* throw {@code JAXBException} if it finds properties that it doesn't understand. * throw {@code JAXBException} if it finds properties that it doesn't understand.
* *
* @param contextPath list of java package names that contain schema derived classes * @param contextPath
* List of java package names that contain schema derived classes.
* Classes in {@code classesToBeBound} that are in named modules must be in a package
* that is {@linkplain java.lang.Module#isOpen open} to at least the {@code java.xml.bind} module.
* @param classLoader * @param classLoader
* This class loader will be used to locate the implementation classes. * This class loader will be used to locate the implementation classes.
* @param properties * @param properties
@ -86,7 +100,14 @@ public interface JAXBContextFactory {
* *
* @return a new instance of a {@code JAXBContext} * @return a new instance of a {@code JAXBContext}
* @throws JAXBException if an error was encountered while creating the * @throws JAXBException if an error was encountered while creating the
* {@code JAXBContext}. See {@link JAXBContext#newInstance(String, ClassLoader, Map)} for details. * {@code JAXBContext} such as
* <ol>
* <li>failure to locate either ObjectFactory.class or jaxb.index in the packages</li>
* <li>an ambiguity among global elements contained in the contextPath</li>
* <li>failure to locate a value for the context factory provider property</li>
* <li>mixing schema derived packages from different providers on the same contextPath</li>
* <li>packages are not open to {@code java.xml.bind} module</li>
* </ol>
* *
* @since 9, JAXB 2.3 * @since 9, JAXB 2.3
*/ */

View file

@ -91,4 +91,10 @@ class Messages
static final String ILLEGAL_CAST = // 2 args static final String ILLEGAL_CAST = // 2 args
"JAXBContext.IllegalCast"; "JAXBContext.IllegalCast";
static final String ERROR_LOAD_CLASS = // 2 args
"ContextFinder.ErrorLoadClass";
static final String JAXB_CLASSES_NOT_OPEN = // 1 arg
"JAXBClasses.notOpen";
} }

View file

@ -44,6 +44,11 @@ ContextFinder.MissingProperty = \
ContextFinder.NoPackageInContextPath = \ ContextFinder.NoPackageInContextPath = \
No package name is given No package name is given
ContextFinder.ErrorLoadClass = \
Error loading class {0} listed in {1}, make sure that entries are accessable \
on CLASSPATH and of the form ClassName or OuterClass.InnerClass \
not ClassName.class or fully.qualified.ClassName
PropertyException.NameValue = \ PropertyException.NameValue = \
name: {0} value: {1} name: {0} value: {1}
@ -52,3 +57,6 @@ DatatypeConverter.ConverterMustNotBeNull = \
JAXBContext.IllegalCast = \ JAXBContext.IllegalCast = \
ClassCastException: attempting to cast {0} to {1}. Please make sure that you are specifying the proper ClassLoader. ClassCastException: attempting to cast {0} to {1}. Please make sure that you are specifying the proper ClassLoader.
JAXBClasses.notOpen = \
Package {0} with JAXB class {1} defined in a module {2} must be open to at least java.xml.bind module.

View file

@ -0,0 +1,160 @@
/*
* 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 javax.xml.bind;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.lang.Module;
import java.util.ArrayList;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
/**
* Propagates openness of JAXB annottated classess packages to JAXB impl module.
*
* @author Roman Grigoriadi
*/
class ModuleUtil {
private static Logger logger = Logger.getLogger("javax.xml.bind");
/**
* Resolves classes from context path.
* Only one class per package is needed to access its {@link java.lang.Module}
*/
static Class[] getClassesFromContextPath(String contextPath, ClassLoader classLoader) throws JAXBException {
List<Class> classes = new ArrayList<>();
if (contextPath == null || contextPath.isEmpty()){
return classes.toArray(new Class[]{});
}
String [] tokens = contextPath.split(":");
for (String pkg : tokens){
// look for ObjectFactory and load it
final Class<?> o;
try {
o = classLoader.loadClass(pkg+".ObjectFactory");
classes.add(o);
continue;
} catch (ClassNotFoundException e) {
// not necessarily an error
}
// look for jaxb.index and load the list of classes
try {
final Class firstByJaxbIndex = findFirstByJaxbIndex(pkg, classLoader);
if (firstByJaxbIndex != null) {
classes.add(firstByJaxbIndex);
}
} catch (IOException e) {
throw new JAXBException(e);
}
}
if (logger.isLoggable(Level.FINE)) {
logger.log(Level.FINE, "Resolved classes from context path: {0}", classes);
}
return classes.toArray(new Class[]{});
}
/**
* Find first class in package by {@code jaxb.index} file.
*/
static Class findFirstByJaxbIndex(String pkg, ClassLoader classLoader) throws IOException, JAXBException {
final String resource = pkg.replace('.', '/') + "/jaxb.index";
final InputStream resourceAsStream = classLoader.getResourceAsStream(resource);
if (resourceAsStream == null) {
return null;
}
BufferedReader in =
new BufferedReader(new InputStreamReader(resourceAsStream, "UTF-8"));
try {
String className = in.readLine();
while (className != null) {
className = className.trim();
if (className.startsWith("#") || (className.length() == 0)) {
className = in.readLine();
continue;
}
try {
return classLoader.loadClass(pkg + '.' + className);
} catch (ClassNotFoundException e) {
throw new JAXBException(Messages.format(Messages.ERROR_LOAD_CLASS, className, pkg), e);
}
}
} finally {
in.close();
}
return null;
}
/**
* Implementation may be defined in other module than {@code java.xml.bind}. In that case openness
* {@linkplain Module#isOpen open} of classes should be delegated to implementation module.
*
* @param classes used to resolve module for {@linkplain Module#addOpens(String, Module)}
* @param factorySPI used to resolve {@link Module} of the implementation.
*
* @throws JAXBException if ony of a classes package is not open to {@code java.xml.bind} module.
*/
static void delegateAddOpensToImplModule(Class[] classes, Class<?> factorySPI) throws JAXBException {
final Module implModule = factorySPI.getModule();
if (!implModule.isNamed()) {
return;
}
Module jaxbModule = JAXBContext.class.getModule();
for (Class cls : classes) {
final Module classModule = cls.getModule();
final String packageName = cls.getPackageName();
//no need for unnamed
if (!classModule.isNamed()) {
continue;
}
//report error if they are not open to java.xml.bind
if (!classModule.isOpen(packageName, jaxbModule)) {
throw new JAXBException(Messages.format(Messages.JAXB_CLASSES_NOT_OPEN,
packageName, cls.getName(), classModule.getName()));
}
//propagate openness to impl module
classModule.addOpens(packageName, implModule);
if (logger.isLoggable(Level.FINE)) {
logger.log(Level.FINE, "Propagating openness of package {0} in {1} to {2}.",
new String[]{ packageName, classModule.getName(), implModule.getName() });
}
}
}
}

View file

@ -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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -23,6 +23,8 @@
* questions. * questions.
*/ */
package javax.xml.bind; package javax.xml.bind;
import javax.xml.bind.annotation.adapters.XmlAdapter; import javax.xml.bind.annotation.adapters.XmlAdapter;
@ -975,7 +977,6 @@ public interface Unmarshaller {
* {@link #isValidating()} API as well as access to the Schema object. * {@link #isValidating()} API as well as access to the Schema object.
* To determine if the Unmarshaller has validation enabled, simply * To determine if the Unmarshaller has validation enabled, simply
* test the return type for null: * test the return type for null:
* <p>
* <pre>{@code * <pre>{@code
* boolean isValidating = u.getSchema()!=null; * boolean isValidating = u.getSchema()!=null;
* }</pre> * }</pre>

View file

@ -26,6 +26,8 @@
/** /**
* Defines the Java Architecture for XML Binding (JAXB) API. * Defines the Java Architecture for XML Binding (JAXB) API.
* *
* <p> This module is upgradeble.
*
* @uses javax.xml.bind.JAXBContextFactory * @uses javax.xml.bind.JAXBContextFactory
* *
* @moduleGraph * @moduleGraph
@ -33,14 +35,13 @@
*/ */
@Deprecated(since="9", forRemoval=true) @Deprecated(since="9", forRemoval=true)
module java.xml.bind { module java.xml.bind {
requires transitive java.activation;
requires transitive java.xml;
requires java.compiler; requires java.compiler;
requires java.desktop; requires java.desktop;
requires java.logging; requires java.logging;
requires jdk.unsupported; requires jdk.unsupported;
uses javax.xml.bind.JAXBContextFactory; requires transitive java.activation;
requires transitive java.xml;
exports javax.xml.bind; exports javax.xml.bind;
exports javax.xml.bind.annotation; exports javax.xml.bind.annotation;
@ -48,6 +49,7 @@ module java.xml.bind {
exports javax.xml.bind.attachment; exports javax.xml.bind.attachment;
exports javax.xml.bind.helpers; exports javax.xml.bind.helpers;
exports javax.xml.bind.util; exports javax.xml.bind.util;
exports com.sun.istack.internal to exports com.sun.istack.internal to
java.xml.ws, java.xml.ws,
jdk.xml.bind, jdk.xml.bind,
@ -147,4 +149,7 @@ module java.xml.bind {
java.xml.ws, java.xml.ws,
jdk.xml.bind, jdk.xml.bind,
jdk.xml.ws; jdk.xml.ws;
uses javax.xml.bind.JAXBContextFactory;
} }

View file

@ -27,6 +27,8 @@
* Defines a subset of the Common Annotations API to support programs running * Defines a subset of the Common Annotations API to support programs running
* on the Java SE Platform. * on the Java SE Platform.
* *
* <p> This module is upgradeble.
*
* @moduleGraph * @moduleGraph
* @since 9 * @since 9
*/ */

View file

@ -76,6 +76,7 @@ class HttpSOAPConnection extends SOAPConnection {
} }
} }
@Override
public void close() throws SOAPException { public void close() throws SOAPException {
if (closed) { if (closed) {
log.severe("SAAJ0002.p2p.close.already.closed.conn"); log.severe("SAAJ0002.p2p.close.already.closed.conn");
@ -86,6 +87,7 @@ class HttpSOAPConnection extends SOAPConnection {
closed = true; closed = true;
} }
@Override
public SOAPMessage call(SOAPMessage message, Object endPoint) public SOAPMessage call(SOAPMessage message, Object endPoint)
throws SOAPException { throws SOAPException {
if (closed) { if (closed) {
@ -348,6 +350,7 @@ class HttpSOAPConnection extends SOAPConnection {
// Object identifies where the request should be sent. // Object identifies where the request should be sent.
// It is required to support objects of type String and java.net.URL. // It is required to support objects of type String and java.net.URL.
@Override
public SOAPMessage get(Object endPoint) throws SOAPException { public SOAPMessage get(Object endPoint) throws SOAPException {
if (closed) { if (closed) {
log.severe("SAAJ0011.p2p.get.already.closed.conn"); log.severe("SAAJ0011.p2p.get.already.closed.conn");

View file

@ -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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -34,6 +34,7 @@ import javax.xml.soap.*;
*/ */
public class HttpSOAPConnectionFactory extends SOAPConnectionFactory { public class HttpSOAPConnectionFactory extends SOAPConnectionFactory {
@Override
public SOAPConnection createConnection() public SOAPConnection createConnection()
throws SOAPException throws SOAPException
{ {

View file

@ -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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -116,6 +116,7 @@ public class MessagingException extends Exception {
* Produce the message, include the message from the nested * Produce the message, include the message from the nested
* exception if there is one. * exception if there is one.
*/ */
@Override
public String getMessage() { public String getMessage() {
if (next == null) if (next == null)
return super.getMessage(); return super.getMessage();

View file

@ -28,18 +28,20 @@
*/ */
package com.sun.xml.internal.messaging.saaj.packaging.mime.internet; package com.sun.xml.internal.messaging.saaj.packaging.mime.internet;
import java.io.*; import com.sun.xml.internal.messaging.saaj.packaging.mime.MessagingException;
import java.util.BitSet; import com.sun.xml.internal.messaging.saaj.packaging.mime.util.ASCIIUtility;
import com.sun.xml.internal.messaging.saaj.packaging.mime.util.OutputUtil;
import com.sun.xml.internal.messaging.saaj.util.ByteOutputStream;
import javax.activation.DataSource; import javax.activation.DataSource;
import java.io.BufferedInputStream;
import com.sun.xml.internal.messaging.saaj.packaging.mime.*; import java.io.ByteArrayInputStream;
import com.sun.xml.internal.messaging.saaj.packaging.mime.util.*; import java.io.IOException;
import java.io.InputStream;
import com.sun.xml.internal.messaging.saaj.util.ByteOutputStream; import java.io.OutputStream;
import java.util.BitSet;
/** /**
* The MimeMultipart class is an implementation of the abstract Multipart * The MimeMultipart class is an implementation of the abstract Multipart
@ -67,7 +69,6 @@ import com.sun.xml.internal.messaging.saaj.util.ByteOutputStream;
* subtype by using the <code>MimeMultipart(String subtype)</code> * subtype by using the <code>MimeMultipart(String subtype)</code>
* constructor. For example, to create a "multipart/alternative" object, * constructor. For example, to create a "multipart/alternative" object,
* use <code>new MimeMultipart("alternative")</code>. * use <code>new MimeMultipart("alternative")</code>.
*
*/ */
//TODO: cleanup the SharedInputStream handling //TODO: cleanup the SharedInputStream handling
@ -144,9 +145,9 @@ public class BMMimeMultipart extends MimeMultipart {
* skips the 'preamble' and reads bytes till the terminating * skips the 'preamble' and reads bytes till the terminating
* boundary and creates MimeBodyParts for each part of the stream. * boundary and creates MimeBodyParts for each part of the stream.
* *
* @param ds DataSource, can be a MultipartDataSource.
* @param ct content type. * @param ct content type.
* @exception MessagingException in case of error. * @param ds DataSource, can be a MultipartDataSource.
* @throws MessagingException in case of error.
*/ */
public BMMimeMultipart(DataSource ds, ContentType ct) public BMMimeMultipart(DataSource ds, ContentType ct)
throws MessagingException { throws MessagingException {
@ -673,7 +674,8 @@ public class BMMimeMultipart extends MimeMultipart {
// Initialise Good Suffix Shift table // Initialise Good Suffix Shift table
gss = new int[l]; gss = new int[l];
NEXT: for (i = l; i > 0; i--) { NEXT:
for (i = l; i > 0; i--) {
// j is the beginning index of suffix being considered // j is the beginning index of suffix being considered
for (j = l - 1; j >= i; j--) { for (j = l - 1; j >= i; j--) {
// Testing for good suffix // Testing for good suffix
@ -756,6 +758,7 @@ public class BMMimeMultipart extends MimeMultipart {
this.contentType.setParameter("boundary", bnd); this.contentType.setParameter("boundary", bnd);
} }
} }
public String getBoundary() { public String getBoundary() {
return this.boundary; return this.boundary;
} }

View file

@ -31,15 +31,21 @@
package com.sun.xml.internal.messaging.saaj.packaging.mime.internet; package com.sun.xml.internal.messaging.saaj.packaging.mime.internet;
import java.io.*; import com.sun.xml.internal.messaging.saaj.packaging.mime.MessagingException;
import com.sun.xml.internal.messaging.saaj.packaging.mime.MultipartDataSource;
import com.sun.xml.internal.messaging.saaj.packaging.mime.util.ASCIIUtility;
import com.sun.xml.internal.messaging.saaj.packaging.mime.util.LineInputStream;
import com.sun.xml.internal.messaging.saaj.packaging.mime.util.OutputUtil;
import com.sun.xml.internal.messaging.saaj.util.ByteOutputStream;
import com.sun.xml.internal.messaging.saaj.util.FinalArrayList;
import com.sun.xml.internal.messaging.saaj.util.SAAJUtil;
import javax.activation.DataSource; import javax.activation.DataSource;
import java.io.BufferedInputStream;
import com.sun.xml.internal.messaging.saaj.packaging.mime.*; import java.io.ByteArrayInputStream;
import com.sun.xml.internal.messaging.saaj.packaging.mime.util.*; import java.io.IOException;
import com.sun.xml.internal.messaging.saaj.util.FinalArrayList; import java.io.InputStream;
import com.sun.xml.internal.messaging.saaj.util.ByteOutputStream; import java.io.OutputStream;
import com.sun.xml.internal.messaging.saaj.util.SAAJUtil;
/** /**
* The MimeMultipart class is an implementation * The MimeMultipart class is an implementation

View file

@ -28,15 +28,15 @@
*/ */
package com.sun.xml.internal.messaging.saaj.packaging.mime.internet; package com.sun.xml.internal.messaging.saaj.packaging.mime.internet;
import java.io.*; import com.sun.xml.internal.messaging.saaj.packaging.mime.MessagingException;
import java.net.UnknownServiceException;
import javax.activation.DataSource; import javax.activation.DataSource;
import java.io.IOException;
import com.sun.xml.internal.messaging.saaj.packaging.mime.MessagingException; import java.io.InputStream;
import java.io.OutputStream;
import java.net.UnknownServiceException;
/** /**
* A utility class that implements a DataSource out of * A utility class that implements a DataSource out of

View file

@ -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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -113,6 +113,7 @@ public class MimePullMultipart extends MimeMultipart {
parsed = true; parsed = true;
} }
@Override
protected void parse() throws MessagingException { protected void parse() throws MessagingException {
parseAll(); parseAll();
} }

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 1997, 2012, 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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -50,7 +50,7 @@ public final class ParameterList {
* No-arg Constructor. * No-arg Constructor.
*/ */
public ParameterList() { public ParameterList() {
this.list = new HashMap<String, String>(); this.list = new HashMap<>();
} }
private ParameterList(HashMap<String, String> m) { private ParameterList(HashMap<String, String> m) {
@ -73,7 +73,7 @@ public final class ParameterList {
int type; int type;
String name; String name;
list = new HashMap<String, String>(); list = new HashMap<>();
while (true) { while (true) {
tk = h.next(); tk = h.next();
type = tk.getType(); type = tk.getType();
@ -171,6 +171,7 @@ public final class ParameterList {
* *
* @return String * @return String
*/ */
@Override
public String toString() { public String toString() {
return toString(0); return toString(0);
} }
@ -232,6 +233,6 @@ public final class ParameterList {
} }
public ParameterList copy() { public ParameterList copy() {
return new ParameterList((HashMap)list.clone()); return new ParameterList((HashMap<String, String>)list.clone());
} }
} }

View file

@ -32,12 +32,14 @@ package com.sun.xml.internal.messaging.saaj.packaging.mime.util;
import com.sun.xml.internal.messaging.saaj.util.ByteOutputStream; import com.sun.xml.internal.messaging.saaj.util.ByteOutputStream;
import java.io.*; import java.io.IOException;
import java.io.InputStream;
public class ASCIIUtility { public class ASCIIUtility {
// Private constructor so that this class is not instantiated // Private constructor so that this class is not instantiated
private ASCIIUtility() { } private ASCIIUtility() {
}
/** /**
@ -51,9 +53,7 @@ public class ASCIIUtility {
* @param start start of the range. * @param start start of the range.
* @param end end of the range (not including). * @param end end of the range (not including).
* @param radix radix. * @param radix radix.
*
* @return integer. * @return integer.
*
*/ */
public static int parseInt(byte[] b, int start, int end, int radix) public static int parseInt(byte[] b, int start, int end, int radix)
throws NumberFormatException { throws NumberFormatException {
@ -123,9 +123,7 @@ public class ASCIIUtility {
* @param b bytes to convert to integer. * @param b bytes to convert to integer.
* @param start start of the range. * @param start start of the range.
* @param end end of the range (not including). * @param end end of the range (not including).
*
* @return integer. * @return integer.
*
*/ */
public static String toString(byte[] b, int start, int end) { public static String toString(byte[] b, int start, int end) {
int size = end - start; int size = end - start;
@ -142,9 +140,7 @@ public class ASCIIUtility {
* default charset, storing the result into a new byte array. * default charset, storing the result into a new byte array.
* *
* @param s string to encode into byte array. * @param s string to encode into byte array.
*
* @return byte array. * @return byte array.
*
*/ */
public static byte[] getBytes(String s) { public static byte[] getBytes(String s) {
char[] chars = s.toCharArray(); char[] chars = s.toCharArray();
@ -160,13 +156,9 @@ public class ASCIIUtility {
* Converts input stream to array. * Converts input stream to array.
* *
* @param is stream to convert to array. * @param is stream to convert to array.
*
* @return byte array. * @return byte array.
*
* @throws IOException if an I/O error occurs. * @throws IOException if an I/O error occurs.
* * @deprecated this is an expensive operation that require an additional
* @deprecated
* this is an expensive operation that require an additional
* buffer reallocation just to get the array of an exact size. * buffer reallocation just to get the array of an exact size.
* Unless you absolutely need the exact size array, don't use this. * Unless you absolutely need the exact size array, don't use this.
* Use {@link ByteOutputStream} and {@link ByteOutputStream#write(InputStream)}. * Use {@link ByteOutputStream} and {@link ByteOutputStream#write(InputStream)}.

View file

@ -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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -63,6 +63,7 @@ public class QDecoderStream extends QPDecoderStream {
* stream is reached. * stream is reached.
* @exception IOException if an I/O error occurs. * @exception IOException if an I/O error occurs.
*/ */
@Override
public int read() throws IOException { public int read() throws IOException {
int c = in.read(); int c = in.read();

View file

@ -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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -67,6 +67,7 @@ public class QPDecoderStream extends FilterInputStream {
* stream is reached. * stream is reached.
* @exception IOException if an I/O error occurs. * @exception IOException if an I/O error occurs.
*/ */
@Override
public int read() throws IOException { public int read() throws IOException {
if (spaces > 0) { if (spaces > 0) {
// We have cached space characters, return one // We have cached space characters, return one
@ -150,6 +151,7 @@ public class QPDecoderStream extends FilterInputStream {
* the stream has been reached. * the stream has been reached.
* @exception IOException if an I/O error occurs. * @exception IOException if an I/O error occurs.
*/ */
@Override
public int read(byte[] buf, int off, int len) throws IOException { public int read(byte[] buf, int off, int len) throws IOException {
int i, c; int i, c;
for (i = 0; i < len; i++) { for (i = 0; i < len; i++) {
@ -167,6 +169,7 @@ public class QPDecoderStream extends FilterInputStream {
* Tests if this input stream supports marks. Currently this class * Tests if this input stream supports marks. Currently this class
* does not support marks * does not support marks
*/ */
@Override
public boolean markSupported() { public boolean markSupported() {
return false; return false;
} }
@ -178,6 +181,7 @@ public class QPDecoderStream extends FilterInputStream {
* this method just invokes the <code>available</code> method * this method just invokes the <code>available</code> method
* of the original input stream. * of the original input stream.
*/ */
@Override
public int available() throws IOException { public int available() throws IOException {
// This is bogus ! We don't really know how much // This is bogus ! We don't really know how much
// bytes are available *after* decoding // bytes are available *after* decoding

View file

@ -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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -81,6 +81,7 @@ public class QPEncoderStream extends FilterOutputStream {
* @param len the number of bytes to write. * @param len the number of bytes to write.
* @exception IOException if an I/O error occurs. * @exception IOException if an I/O error occurs.
*/ */
@Override
public void write(byte[] b, int off, int len) throws IOException { public void write(byte[] b, int off, int len) throws IOException {
for (int i = 0; i < len; i++) for (int i = 0; i < len; i++)
write(b[off + i]); write(b[off + i]);
@ -91,6 +92,7 @@ public class QPEncoderStream extends FilterOutputStream {
* @param b the data to be written. * @param b the data to be written.
* @exception IOException if an I/O error occurs. * @exception IOException if an I/O error occurs.
*/ */
@Override
public void write(byte[] b) throws IOException { public void write(byte[] b) throws IOException {
write(b, 0, b.length); write(b, 0, b.length);
} }
@ -100,6 +102,7 @@ public class QPEncoderStream extends FilterOutputStream {
* @param c the <code>byte</code>. * @param c the <code>byte</code>.
* @exception IOException if an I/O error occurs. * @exception IOException if an I/O error occurs.
*/ */
@Override
public void write(int c) throws IOException { public void write(int c) throws IOException {
c = c & 0xff; // Turn off the MSB. c = c & 0xff; // Turn off the MSB.
if (gotSpace) { // previous character was <SPACE> if (gotSpace) { // previous character was <SPACE>
@ -139,6 +142,7 @@ public class QPEncoderStream extends FilterOutputStream {
* to be encoded out to the stream. * to be encoded out to the stream.
* @exception IOException if an I/O error occurs. * @exception IOException if an I/O error occurs.
*/ */
@Override
public void flush() throws IOException { public void flush() throws IOException {
out.flush(); out.flush();
} }
@ -147,6 +151,7 @@ public class QPEncoderStream extends FilterOutputStream {
* Forces any buffered output bytes to be encoded out to the stream * Forces any buffered output bytes to be encoded out to the stream
* and closes this output stream * and closes this output stream
*/ */
@Override
public void close() throws IOException { public void close() throws IOException {
out.close(); out.close();
} }

View file

@ -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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -78,6 +78,7 @@ public class UUDecoderStream extends FilterInputStream {
* @see java.io.FilterInputStream#in * @see java.io.FilterInputStream#in
*/ */
@Override
public int read() throws IOException { public int read() throws IOException {
if (index >= bufsize) { if (index >= bufsize) {
readPrefix(); readPrefix();
@ -88,6 +89,7 @@ public class UUDecoderStream extends FilterInputStream {
return buffer[index++] & 0xff; // return lower byte return buffer[index++] & 0xff; // return lower byte
} }
@Override
public int read(byte[] buf, int off, int len) throws IOException { public int read(byte[] buf, int off, int len) throws IOException {
int i, c; int i, c;
for (i = 0; i < len; i++) { for (i = 0; i < len; i++) {
@ -101,10 +103,12 @@ public class UUDecoderStream extends FilterInputStream {
return i; return i;
} }
@Override
public boolean markSupported() { public boolean markSupported() {
return false; return false;
} }
@Override
public int available() throws IOException { public int available() throws IOException {
// This is only an estimate, since in.available() // This is only an estimate, since in.available()
// might include CRLFs too .. // might include CRLFs too ..

View file

@ -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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -88,6 +88,7 @@ public class AttachmentPartImpl extends AttachmentPart {
} }
} }
@Override
public int getSize() throws SOAPException { public int getSize() throws SOAPException {
if (mimePart != null) { if (mimePart != null) {
try { try {
@ -124,6 +125,7 @@ public class AttachmentPartImpl extends AttachmentPart {
} }
} }
@Override
public void clearContent() { public void clearContent() {
if (mimePart != null) { if (mimePart != null) {
mimePart.close(); mimePart.close();
@ -133,6 +135,7 @@ public class AttachmentPartImpl extends AttachmentPart {
rawContent = null; rawContent = null;
} }
@Override
public Object getContent() throws SOAPException { public Object getContent() throws SOAPException {
try { try {
if (mimePart != null) { if (mimePart != null) {
@ -153,6 +156,7 @@ public class AttachmentPartImpl extends AttachmentPart {
} }
} }
@Override
public void setContent(Object object, String contentType) public void setContent(Object object, String contentType)
throws IllegalArgumentException { throws IllegalArgumentException {
if (mimePart != null) { if (mimePart != null) {
@ -165,23 +169,28 @@ public class AttachmentPartImpl extends AttachmentPart {
} }
@Override
public DataHandler getDataHandler() throws SOAPException { public DataHandler getDataHandler() throws SOAPException {
if (mimePart != null) { if (mimePart != null) {
//return an inputstream //return an inputstream
return new DataHandler(new DataSource() { return new DataHandler(new DataSource() {
@Override
public InputStream getInputStream() throws IOException { public InputStream getInputStream() throws IOException {
return mimePart.read(); return mimePart.read();
} }
@Override
public OutputStream getOutputStream() throws IOException { public OutputStream getOutputStream() throws IOException {
throw new UnsupportedOperationException("getOutputStream cannot be supported : You have enabled LazyAttachments Option"); throw new UnsupportedOperationException("getOutputStream cannot be supported : You have enabled LazyAttachments Option");
} }
@Override
public String getContentType() { public String getContentType() {
return mimePart.getContentType(); return mimePart.getContentType();
} }
@Override
public String getName() { public String getName() {
return "MIMEPart Wrapper DataSource"; return "MIMEPart Wrapper DataSource";
} }
@ -197,6 +206,7 @@ public class AttachmentPartImpl extends AttachmentPart {
return dataHandler; return dataHandler;
} }
@Override
public void setDataHandler(DataHandler dataHandler) public void setDataHandler(DataHandler dataHandler)
throws IllegalArgumentException { throws IllegalArgumentException {
if (mimePart != null) { if (mimePart != null) {
@ -216,35 +226,43 @@ public class AttachmentPartImpl extends AttachmentPart {
setMimeHeader("Content-Type", dataHandler.getContentType()); setMimeHeader("Content-Type", dataHandler.getContentType());
} }
@Override
public void removeAllMimeHeaders() { public void removeAllMimeHeaders() {
headers.removeAllHeaders(); headers.removeAllHeaders();
} }
@Override
public void removeMimeHeader(String header) { public void removeMimeHeader(String header) {
headers.removeHeader(header); headers.removeHeader(header);
} }
@Override
public String[] getMimeHeader(String name) { public String[] getMimeHeader(String name) {
return headers.getHeader(name); return headers.getHeader(name);
} }
@Override
public void setMimeHeader(String name, String value) { public void setMimeHeader(String name, String value) {
headers.setHeader(name, value); headers.setHeader(name, value);
} }
@Override
public void addMimeHeader(String name, String value) { public void addMimeHeader(String name, String value) {
headers.addHeader(name, value); headers.addHeader(name, value);
} }
public Iterator getAllMimeHeaders() { @Override
public Iterator<MimeHeader> getAllMimeHeaders() {
return headers.getAllHeaders(); return headers.getAllHeaders();
} }
public Iterator getMatchingMimeHeaders(String[] names) { @Override
public Iterator<MimeHeader> getMatchingMimeHeaders(String[] names) {
return headers.getMatchingHeaders(names); return headers.getMatchingHeaders(names);
} }
public Iterator getNonMatchingMimeHeaders(String[] names) { @Override
public Iterator<MimeHeader> getNonMatchingMimeHeaders(String[] names) {
return headers.getNonMatchingHeaders(names); return headers.getNonMatchingHeaders(names);
} }
@ -329,6 +347,7 @@ public class AttachmentPartImpl extends AttachmentPart {
} }
} }
@Override
public void setBase64Content(InputStream content, String contentType) public void setBase64Content(InputStream content, String contentType)
throws SOAPException { throws SOAPException {
@ -365,6 +384,7 @@ public class AttachmentPartImpl extends AttachmentPart {
} }
} }
@Override
public InputStream getBase64Content() throws SOAPException { public InputStream getBase64Content() throws SOAPException {
InputStream stream; InputStream stream;
if (mimePart != null) { if (mimePart != null) {
@ -425,6 +445,7 @@ public class AttachmentPartImpl extends AttachmentPart {
} }
} }
@Override
public void setRawContent(InputStream content, String contentType) public void setRawContent(InputStream content, String contentType)
throws SOAPException { throws SOAPException {
if (mimePart != null) { if (mimePart != null) {
@ -475,6 +496,7 @@ public class AttachmentPartImpl extends AttachmentPart {
} }
} */ } */
@Override
public void setRawContentBytes( public void setRawContentBytes(
byte[] content, int off, int len, String contentType) byte[] content, int off, int len, String contentType)
throws SOAPException { throws SOAPException {
@ -498,6 +520,7 @@ public class AttachmentPartImpl extends AttachmentPart {
} }
} }
@Override
public InputStream getRawContent() throws SOAPException { public InputStream getRawContent() throws SOAPException {
if (mimePart != null) { if (mimePart != null) {
return mimePart.read(); return mimePart.read();
@ -522,6 +545,7 @@ public class AttachmentPartImpl extends AttachmentPart {
} }
} }
@Override
public byte[] getRawContentBytes() throws SOAPException { public byte[] getRawContentBytes() throws SOAPException {
InputStream ret; InputStream ret;
if (mimePart != null) { if (mimePart != null) {
@ -556,12 +580,14 @@ public class AttachmentPartImpl extends AttachmentPart {
} }
// attachments are equal if they are the same reference // attachments are equal if they are the same reference
@Override
public boolean equals(Object o) { public boolean equals(Object o) {
return (this == o); return (this == o);
} }
// In JDK 8 we get a warning if we implement equals() but not hashCode(). // In JDK 8 we get a warning if we implement equals() but not hashCode().
// There is no intuitive value for this, the default one in Object is fine. // There is no intuitive value for this, the default one in Object is fine.
@Override
public int hashCode() { public int hashCode() {
return super.hashCode(); return super.hashCode();
} }

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2014, 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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -71,6 +71,7 @@ abstract class ContextClassloaderLocal<V> {
private static ClassLoader getContextClassLoader() { private static ClassLoader getContextClassLoader() {
return AccessController.doPrivileged(new PrivilegedAction<ClassLoader>() { return AccessController.doPrivileged(new PrivilegedAction<ClassLoader>() {
@Override
public ClassLoader run() { public ClassLoader run() {
ClassLoader cl = null; ClassLoader cl = null;
try { try {

Some files were not shown because too many files have changed in this diff Show more