This commit is contained in:
Vladimir Kozlov 2017-07-05 18:23:35 -07:00
commit b3b17f73e2
1654 changed files with 28914 additions and 130139 deletions
.hgtags.hgtags-top-repo
.jcheck
common/doc
corba
.hgtags
.jcheck
src/java.corba/share/classes
hotspot
jaxp
.hgtags
.jcheck
src
java.xml/share/classes
jdk.xml.dom/share/classes
jaxws

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

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

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

@ -18,14 +18,16 @@
</header>
<nav id="TOC">
<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="#jtreg">JTreg</a></li>
<li><a href="#jtreg">JTReg</a></li>
<li><a href="#gtest">Gtest</a></li>
</ul></li>
<li><a href="#test-results-and-summary">Test results and summary</a></li>
<li><a href="#test-suite-control">Test suite control</a><ul>
<li><a href="#jtreg-keywords">JTreg keywords</a></li>
<li><a href="#jtreg-keywords">JTReg keywords</a></li>
<li><a href="#gtest-keywords">Gtest keywords</a></li>
</ul></li>
</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;jtreg:hotspot/test:hotspot_gc hotspot/test/native_sanity/JniVersion.java&quot;
$ 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>
<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>
<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>
<h3 id="jtreg">JTReg</h3>
<p>JTReg test groups can be specified either without a test root, e.g. <code>:tier1</code> (or <code>tier1</code>, the initial colon is optional), or with, e.g. <code>hotspot/test:tier1</code>, <code>jdk/test:jdk_util</code>.</p>
<p>When specified without a test root, all matching groups from all tests roots will be added. Otherwise, only the group from the specified test root will be added.</p>
<p>Individual JTreg tests or directories containing JTreg tests can also be specified, like <code>hotspot/test/native_sanity/JniVersion.java</code> or <code>hotspot/test/native_sanity</code>. You can also specify an absolute path, to point to a JTreg test outside the source tree.</p>
<p>Individual JTReg tests or directories containing JTReg tests can also be specified, like <code>hotspot/test/native_sanity/JniVersion.java</code> or <code>hotspot/test/native_sanity</code>. You can also specify an absolute path, to point to a JTReg test outside the source tree.</p>
<p>As long as the test groups or test paths can be uniquely resolved, you do not need to enter the <code>jtreg:</code> prefix. If this is not possible, or if you want to use a fully qualified test descriptor, add <code>jtreg:</code>, e.g. <code>jtreg:hotspot/test/native_sanity</code>.</p>
<h3 id="gtest">Gtest</h3>
<p>Since the Hotspot Gtest suite is so quick, the default is to run all tests. This is specified by just <code>gtest</code>, or as a fully qualified test descriptor <code>gtest:all</code>.</p>
@ -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>The classification of non-passed tests differs a bit between test suites. In the summary, ERROR is used as a catch-all for tests that neither passed nor are classified as failed by the framework. This might indicate test framework error, timeout or other problems.</p>
<p>In case of test failures, <code>make run-test</code> will exit with a non-zero exit value.</p>
<p>All tests have their result stored in <code>build/$BUILD/test-result/$TEST_ID</code>, where TEST_ID is a path-safe conversion from the fully qualified test descriptor, e.g. for <code>jtreg:jdk/test:tier1</code> the TEST_ID is <code>jtreg_jdk_test_tier1</code>. This path is also printed in the log at the end of the test run.</p>
<p>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>
<h2 id="test-suite-control">Test suite control</h2>
<p>It is possible to control various aspects of the test suites using make control variables.</p>
<p>These variables use a keyword=value approach to allow multiple values to be set. So, for instance, <code>JTREG=&quot;JOBS=1;TIMEOUT=8&quot;</code> will set the JTreg concurrency level to 1 and the timeout factor to 8. This is equivalent to setting <code>JTREG_JOBS=1 JTREG_TIMEOUT=8</code>, but using the keyword format means that the <code>JTREG</code> variable is parsed and verified for correctness, so <code>JTREG=&quot;TMIEOUT=8&quot;</code> would give an error, while <code>JTREG_TMIEOUT=8</code> would just pass unnoticed.</p>
<p>These variables use a keyword=value approach to allow multiple values to be set. So, for instance, <code>JTREG=&quot;JOBS=1;TIMEOUT=8&quot;</code> will set the JTReg concurrency level to 1 and the timeout factor to 8. This is equivalent to setting <code>JTREG_JOBS=1 JTREG_TIMEOUT=8</code>, but using the keyword format means that the <code>JTREG</code> variable is parsed and verified for correctness, so <code>JTREG=&quot;TMIEOUT=8&quot;</code> would give an error, while <code>JTREG_TMIEOUT=8</code> would just pass unnoticed.</p>
<p>To separate multiple keyword=value pairs, use <code>;</code> (semicolon). Since the shell normally eats <code>;</code>, the recommended usage is to write the assignment inside qoutes, e.g. <code>JTREG=&quot;...;...&quot;</code>. This will also make sure spaces are preserved, as in <code>JTREG=&quot;VM_OTIONS=-XshowSettings -Xlog:gc+ref=debug&quot;</code>.</p>
<p>(Other ways are possible, e.g. using backslash: <code>JTREG=JOBS=1\;TIMEOUT=8</code>. Also, as a special technique, the string <code>%20</code> will be replaced with space for certain options, e.g. <code>JTREG=VM_OTIONS=-XshowSettings%20-Xlog:gc+ref=debug</code>. This can be useful if you have layers of scripts and have trouble getting proper quoting of command line arguments through.)</p>
<p>As far as possible, the names of the keywords have been standardized between test suites.</p>
<h3 id="jtreg-keywords">JTreg keywords</h3>
<h3 id="jtreg-keywords">JTReg keywords</h3>
<h4 id="jobs">JOBS</h4>
<p>The test concurrency (<code>-concurrency</code>).</p>
<p>Defaults to TEST_JOBS (if set by <code>--with-test-jobs=</code>), otherwise it defaults to JOBS, except for Hotspot, where the default is <em>number of CPU cores/2</em>, but never more than 12.</p>
@ -96,15 +101,15 @@ TEST FAILURE</code></pre>
<p>Defaults to <code>fail,error</code>.</p>
<h4 id="max_mem">MAX_MEM</h4>
<p>Limit memory consumption (<code>-Xmx</code> and <code>-vmoption:-Xmx</code>, or none).</p>
<p>Limit memory consumption for JTreg test framework and VM under test. Set to 0 to disable the limits.</p>
<p>Limit memory consumption for JTReg test framework and VM under test. Set to 0 to disable the limits.</p>
<p>Defaults to 512m, except for hotspot, where it defaults to 0 (no limit).</p>
<h4 id="options">OPTIONS</h4>
<p>Additional options to the JTreg test framework.</p>
<p>Use <code>JTREG=&quot;OPTIONS=--help all&quot;</code> to see all available JTreg options.</p>
<p>Additional options to the JTReg test framework.</p>
<p>Use <code>JTREG=&quot;OPTIONS=--help all&quot;</code> to see all available JTReg options.</p>
<h4 id="java_options">JAVA_OPTIONS</h4>
<p>Additional Java options to JTreg (<code>-javaoption</code>).</p>
<p>Additional Java options to JTReg (<code>-javaoption</code>).</p>
<h4 id="vm_options">VM_OPTIONS</h4>
<p>Additional VM options to JTreg (<code>-vmoption</code>).</p>
<p>Additional VM options to JTReg (<code>-vmoption</code>).</p>
<h3 id="gtest-keywords">Gtest keywords</h3>
<h4 id="repeat">REPEAT</h4>
<p>The number of times to repeat the tests (<code>--gtest_repeat</code>).</p>

@ -22,6 +22,15 @@ Some example command-lines:
$ make run-test TEST="jtreg:hotspot/test:hotspot_gc hotspot/test/native_sanity/JniVersion.java"
$ 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
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.
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
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.
@ -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`
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.
`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
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
`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
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.
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
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
@ -115,7 +124,7 @@ It is possible to control various aspects of the test suites using make control
variables.
These variables use a keyword=value approach to allow multiple values to be
set. So, for instance, `JTREG="JOBS=1;TIMEOUT=8"` will set the JTreg
set. So, for instance, `JTREG="JOBS=1;TIMEOUT=8"` will set the JTReg
concurrency level to 1 and the timeout factor to 8. This is equivalent to
setting `JTREG_JOBS=1 JTREG_TIMEOUT=8`, but using the keyword format means that
the `JTREG` variable is parsed and verified for correctness, so
@ -136,7 +145,7 @@ proper quoting of command line arguments through.)
As far as possible, the names of the keywords have been standardized between
test suites.
### JTreg keywords
### JTReg keywords
#### JOBS
The test concurrency (`-concurrency`).
@ -174,21 +183,21 @@ Defaults to `fail,error`.
#### MAX_MEM
Limit memory consumption (`-Xmx` and `-vmoption:-Xmx`, or none).
Limit memory consumption for JTreg test framework and VM under test. Set to 0
Limit memory consumption for JTReg test framework and VM under test. Set to 0
to disable the limits.
Defaults to 512m, except for hotspot, where it defaults to 0 (no limit).
#### OPTIONS
Additional options to the JTreg test framework.
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
Additional Java options to JTreg (`-javaoption`).
Additional Java options to JTReg (`-javaoption`).
#### VM_OPTIONS
Additional VM options to JTreg (`-vmoption`).
Additional VM options to JTReg (`-vmoption`).
### Gtest keywords

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

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

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

@ -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.
*
* 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}.
* 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>.
*/

@ -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.
*
* 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
* {@code ORBPackage/InvalidName}.
* 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>.
*/

@ -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.
*
* 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
* {@code TypeCodePackage/BadKind}.
* 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>.
*/

@ -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.
*
* 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
* {@code TypeCodePackage/Bounds}.
* 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>.
*/

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

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

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

@ -56,6 +56,7 @@ BUILD_HOTSPOT_JTREG_NATIVE_SRC := \
$(HOTSPOT_TOPDIR)/test/compiler/floatingpoint/ \
$(HOTSPOT_TOPDIR)/test/compiler/calls \
$(HOTSPOT_TOPDIR)/test/serviceability/jvmti/GetNamedModule \
$(HOTSPOT_TOPDIR)/test/serviceability/jvmti/IsModifiableModule \
$(HOTSPOT_TOPDIR)/test/serviceability/jvmti/AddModuleReads \
$(HOTSPOT_TOPDIR)/test/serviceability/jvmti/AddModuleExportsAndOpens \
$(HOTSPOT_TOPDIR)/test/serviceability/jvmti/AddModuleUsesAndProvides \
@ -85,6 +86,7 @@ ifeq ($(TOOLCHAIN_TYPE), solstudio)
BUILD_HOTSPOT_JTREG_LIBRARIES_LIBS_liboverflow := -lc
BUILD_HOTSPOT_JTREG_LIBRARIES_LIBS_libSimpleClassFileLoadHook := -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_libAddModuleExportsAndOpensTest := -lc
BUILD_HOTSPOT_JTREG_LIBRARIES_LDFLAGS_libAddModuleUsesAndProvidesTest := -lc

@ -109,9 +109,15 @@ int AbstractInterpreter::size_activation(int max_stack,
// for the callee's params we only need to account for the extra
// locals.
int size = overhead +
(callee_locals - callee_params)*Interpreter::stackElementWords +
(callee_locals - callee_params) +
monitors * frame::interpreter_frame_monitor_size() +
temps* Interpreter::stackElementWords + extra_args;
// On the top frame, at all times SP <= ESP, and SP is
// 16-aligned. We ensure this by adjusting SP on method
// entry and re-entry to allow room for the maximum size of
// the expression stack. When we call another method we bump
// SP so that no stack space is wasted. So, only on the top
// frame do we need to allow max_stack words.
(is_top_frame ? max_stack : temps + extra_args);
// On AArch64 we always keep the stack pointer 16-aligned, so we
// must round up here.

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

@ -51,6 +51,11 @@ extern "C" void bad_compiled_vtable_index(JavaThread* thread,
VtableStub* VtableStubs::create_vtable_stub(int vtable_index) {
const int aarch64_code_length = VtableStub::pd_code_size_limit(true);
VtableStub* s = new(aarch64_code_length) VtableStub(true, vtable_index);
// Can be NULL if there is no free space in the code cache.
if (s == NULL) {
return NULL;
}
ResourceMark rm;
CodeBuffer cb(s->entry_point(), aarch64_code_length);
MacroAssembler* masm = new MacroAssembler(&cb);

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

@ -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) {
if (tmp->is_valid()) {
bool LIRGenerator::strength_reduce_multiply(LIR_Opr left, jint c, LIR_Opr result, LIR_Opr tmp) {
if (tmp->is_valid() && c > 0 && c < max_jint) {
if (is_power_of_2(c + 1)) {
__ move(left, tmp);
__ 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_tmp = false;
if (right_arg->is_constant()) {
int iconst = right_arg->get_jint_constant();
if (iconst > 0) {
jint iconst = right_arg->get_jint_constant();
if (iconst > 0 && iconst < max_jint) {
if (is_power_of_2(iconst)) {
use_constant = true;
} else if (is_power_of_2(iconst - 1) || is_power_of_2(iconst + 1)) {

@ -23,8 +23,15 @@
* 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 {
requires jdk.management;
requires jdk.internal.vm.ci;
requires jdk.internal.vm.compiler;
requires jdk.management;
}

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

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

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

@ -104,6 +104,13 @@ public interface ResolvedJavaType extends JavaType, ModifiersProvider, Annotated
*/
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}.
*/

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

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

@ -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)
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
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);

@ -722,74 +722,6 @@ jobject Modules::get_module(Symbol* package_name, Handle h_loader, TRAPS) {
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.
void Modules::add_module_exports_to_all_unnamed(jobject module, const char* package_name, TRAPS) {
if (module == NULL) {

@ -113,14 +113,6 @@ public:
// Returns NULL if package is invalid or not defined by loader.
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.
// 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

@ -130,6 +130,7 @@ class CodeBlob_sizes {
// Iterate over all CodeHeaps
#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_ALLOCABLE_HEAPS(heap) for (GrowableArrayIterator<CodeHeap*> heap = _allocable_heaps->begin(); heap != _allocable_heaps->end(); ++heap)
// 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))
@ -140,10 +141,11 @@ int CodeCache::_number_of_nmethods_with_dependencies = 0;
bool CodeCache::_needs_cache_clean = false;
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::_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::_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) {
size_t total_size = non_nmethod_size + profiled_size + non_profiled_size;
@ -338,6 +340,7 @@ ReservedCodeSpace CodeCache::reserve_heap_memory(size_t size) {
return rs;
}
// Heaps available for allocation
bool CodeCache::heap_available(int code_blob_type) {
if (!SegmentedCodeCache) {
// No segmentation: use a single code heap
@ -391,6 +394,9 @@ void CodeCache::add_heap(CodeHeap* heap) {
if (code_blob_type_accepts_nmethod(type)) {
_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) {
@ -620,7 +626,7 @@ nmethod* CodeCache::find_nmethod(void* start) {
void CodeCache::blobs_do(void f(CodeBlob* nm)) {
assert_locked_or_safepoint(CodeCache_lock);
FOR_ALL_NMETHOD_HEAPS(heap) {
FOR_ALL_HEAPS(heap) {
FOR_ALL_BLOBS(cb, *heap) {
f(cb);
}
@ -663,7 +669,7 @@ void CodeCache::do_unloading(BoolObjectClosure* is_alive, bool unloading_occurre
void CodeCache::blobs_do(CodeBlobClosure* f) {
assert_locked_or_safepoint(CodeCache_lock);
FOR_ALL_NMETHOD_HEAPS(heap) {
FOR_ALL_ALLOCABLE_HEAPS(heap) {
FOR_ALL_BLOBS(cb, *heap) {
if (cb->is_alive()) {
f->do_code_blob(cb);
@ -960,7 +966,7 @@ address CodeCache::high_bound(int code_blob_type) {
size_t CodeCache::capacity() {
size_t cap = 0;
FOR_ALL_NMETHOD_HEAPS(heap) {
FOR_ALL_ALLOCABLE_HEAPS(heap) {
cap += (*heap)->capacity();
}
return cap;
@ -973,7 +979,7 @@ size_t CodeCache::unallocated_capacity(int code_blob_type) {
size_t CodeCache::unallocated_capacity() {
size_t unallocated_cap = 0;
FOR_ALL_NMETHOD_HEAPS(heap) {
FOR_ALL_ALLOCABLE_HEAPS(heap) {
unallocated_cap += (*heap)->unallocated_capacity();
}
return unallocated_cap;
@ -981,7 +987,7 @@ size_t CodeCache::unallocated_capacity() {
size_t CodeCache::max_capacity() {
size_t max_cap = 0;
FOR_ALL_NMETHOD_HEAPS(heap) {
FOR_ALL_ALLOCABLE_HEAPS(heap) {
max_cap += (*heap)->max_capacity();
}
return max_cap;
@ -1007,7 +1013,7 @@ double CodeCache::reverse_free_ratio(int code_blob_type) {
size_t CodeCache::bytes_allocated_in_freelists() {
size_t allocated_bytes = 0;
FOR_ALL_NMETHOD_HEAPS(heap) {
FOR_ALL_ALLOCABLE_HEAPS(heap) {
allocated_bytes += (*heap)->allocated_in_freelist();
}
return allocated_bytes;
@ -1015,7 +1021,7 @@ size_t CodeCache::bytes_allocated_in_freelists() {
int CodeCache::allocated_segments() {
int number_of_segments = 0;
FOR_ALL_NMETHOD_HEAPS(heap) {
FOR_ALL_ALLOCABLE_HEAPS(heap) {
number_of_segments += (*heap)->allocated_segments();
}
return number_of_segments;
@ -1023,7 +1029,7 @@ int CodeCache::allocated_segments() {
size_t CodeCache::freelists_length() {
size_t length = 0;
FOR_ALL_NMETHOD_HEAPS(heap) {
FOR_ALL_ALLOCABLE_HEAPS(heap) {
length += (*heap)->freelist_length();
}
return length;
@ -1354,7 +1360,7 @@ void CodeCache::report_codemem_full(int code_blob_type, bool print) {
void CodeCache::print_memory_overhead() {
size_t wasted_bytes = 0;
FOR_ALL_NMETHOD_HEAPS(heap) {
FOR_ALL_ALLOCABLE_HEAPS(heap) {
CodeHeap* curr_heap = *heap;
for (CodeBlob* cb = (CodeBlob*)curr_heap->first(); cb != NULL; cb = (CodeBlob*)curr_heap->next(cb)) {
HeapBlock* heap_block = ((HeapBlock*)cb) - 1;
@ -1400,7 +1406,7 @@ void CodeCache::print_internals() {
ResourceMark rm;
int i = 0;
FOR_ALL_NMETHOD_HEAPS(heap) {
FOR_ALL_ALLOCABLE_HEAPS(heap) {
if ((_nmethod_heaps->length() >= 1) && Verbose) {
tty->print_cr("-- %s --", (*heap)->name());
}
@ -1497,7 +1503,7 @@ void CodeCache::print() {
CodeBlob_sizes live;
CodeBlob_sizes dead;
FOR_ALL_NMETHOD_HEAPS(heap) {
FOR_ALL_ALLOCABLE_HEAPS(heap) {
FOR_ALL_BLOBS(cb, *heap) {
if (!cb->is_alive()) {
dead.add(cb);
@ -1523,7 +1529,7 @@ void CodeCache::print() {
int number_of_blobs = 0;
int number_of_oop_maps = 0;
int map_size = 0;
FOR_ALL_NMETHOD_HEAPS(heap) {
FOR_ALL_ALLOCABLE_HEAPS(heap) {
FOR_ALL_BLOBS(cb, *heap) {
if (cb->is_alive()) {
number_of_blobs++;

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

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

@ -1687,6 +1687,13 @@ C2V_VMENTRY(jlong, getFingerprint, (JNIEnv*, jobject, jlong metaspace_klass))
}
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))
if (bytecode_frame_handle == NULL) {
THROW_0(vmSymbols::java_lang_NullPointerException());
@ -1817,6 +1824,7 @@ JNINativeMethod CompilerToVM::methods[] = {
{CC "flushDebugOutput", CC "()V", FN_PTR(flushDebugOutput)},
{CC "methodDataProfileDataSize", CC "(JI)I", FN_PTR(methodDataProfileDataSize)},
{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 "compileToBytecode", CC "(" OBJECT ")V", FN_PTR(compileToBytecode)},
{CC "getFlagValue", CC "(" STRING ")" OBJECT, FN_PTR(getFlagValue)},

@ -1039,11 +1039,6 @@ JVM_ENTRY (void, JVM_AddReadsModule(JNIEnv *env, jobject from_module, jobject so
Modules::add_reads_module(from_module, source_module, CHECK);
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 //////////////////////////////////////////////////////////////////////////////
JVM_ENTRY(jstring, JVM_GetClassName(JNIEnv *env, jclass cls))

@ -1,5 +1,5 @@
/*
* Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1997, 2017, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -466,14 +466,6 @@ JVM_AddModuleExportsToAll(JNIEnv *env, jobject from_module, const char* package)
JNIEXPORT void JNICALL
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
*/

@ -1,5 +1,5 @@
/*
* Copyright (c) 2012, 2016, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2012, 2017, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -1457,15 +1457,6 @@ WB_ENTRY(void, WB_AddReadsModule(JNIEnv* env, jobject o, jobject from_module, jo
Modules::add_reads_module(from_module, source_module, CHECK);
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(jobject, WB_GetModuleByPackageName(JNIEnv* env, jobject o, jobject loader, jstring package))
ResourceMark rm(THREAD);
char* package_name = NULL;
@ -1910,8 +1901,6 @@ static JNINativeMethod methods[] = {
(void*)&WB_AddModuleExports },
{CC"AddReadsModule", CC"(Ljava/lang/Object;Ljava/lang/Object;)V",
(void*)&WB_AddReadsModule },
{CC"AddModulePackage", CC"(Ljava/lang/Object;Ljava/lang/String;)V",
(void*)&WB_AddModulePackage },
{CC"GetModuleByPackageName", CC"(Ljava/lang/Object;Ljava/lang/String;)Ljava/lang/Object;",
(void*)&WB_GetModuleByPackageName },
{CC"AddModuleExportsToAllUnnamed", CC"(Ljava/lang/Object;Ljava/lang/String;)V",

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

@ -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.
*
* This code is free software; you can redistribute it and/or modify it
@ -296,19 +296,41 @@ void SensorInfo::trigger(int count, TRAPS) {
Klass* k = Management::sun_management_Sensor_klass(CHECK);
instanceKlassHandle sensorKlass (THREAD, k);
Handle sensor_h(THREAD, _sensor_obj);
Handle usage_h = MemoryService::create_MemoryUsage_obj(_usage, CHECK);
Symbol* trigger_method_signature;
JavaValue result(T_VOID);
JavaCallArguments args(sensor_h);
args.push_int((int) count);
args.push_oop(usage_h);
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);
}
JavaCalls::call_virtual(&result,
sensorKlass,
vmSymbols::trigger_name(),
vmSymbols::trigger_method_signature(),
&args,
CHECK);
sensorKlass,
vmSymbols::trigger_name(),
trigger_method_signature,
&args,
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;
}
}
{

@ -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.
*
* This code is free software; you can redistribute it and/or modify it
@ -23,18 +23,31 @@
/*
* @test
* @bug 4983023
* @summary A bad superclass shouldn't throw the standard doclet into a loop
* @modules jdk.javadoc
* @bug 8181872
*
* @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) {
String srcpath = System.getProperty("test.src", ".");
if (com.sun.tools.javadoc.Main.execute(
new String[] {"-d", "doc", "-sourcepath", srcpath, "p"}) != 0)
throw new Error("Javadoc encountered warnings or errors.");
for (int i = 0; i < 20000; i++) {
test(i);
}
}
}

@ -54,6 +54,7 @@ import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
import java.util.Arrays;
import java.util.Collections;
import java.util.function.Supplier;
import java.util.HashMap;
import java.util.HashSet;
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
public void getModifiersTest() {
for (Class<?> c : classes) {

@ -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, "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, "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, "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 { }
}

@ -49,12 +49,6 @@ public class ModuleHelper {
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 Module GetModuleByPackageName(Object ldr, String pkg) throws Throwable {
WhiteBox wb = WhiteBox.getWhiteBox();
return (Module)wb.GetModuleByPackageName(ldr, pkg);

@ -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);
}
}

@ -1,5 +1,5 @@
/*
* Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2016, 2017, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -26,6 +26,7 @@ package MyPackage;
/**
* @test
* @summary Verifies the JVMTI GetNamedModule API
* @modules jdk.jdi
* @compile GetNamedModuleTest.java
* @run main/othervm/native -agentlib:GetNamedModuleTest MyPackage.GetNamedModuleTest
*/

@ -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.
*
* This code is free software; you can redistribute it and/or modify it
@ -21,40 +21,37 @@
* questions.
*/
package pkg1;
import java.io.*;
package MyPackage;
/**
* A test class where the outer class is package private and the inner class is private
* and a nested inner class is protected.
*
* @author Bhavesh Patel
* @test
* @summary Verifies the JVMTI IsModifiableModule API
* @modules jdk.jdi
* @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 {
System.loadLibrary("IsModifiableModuleTest");
} catch (UnsatisfiedLinkError ule) {
System.err.println("Could not load IsModifiableModuleTest library");
System.err.println("java.library.path: "
+ System.getProperty("java.library.path"));
throw ule;
}
}
public final int SERIALIZABLE_CONSTANT = 1;
native static int check();
/**
* @param s ObjectInputStream.
* @throws IOException when there is an I/O error.
* @serial
*/
private void readObject(ObjectInputStream s) throws IOException {
}
/**
* @param s ObjectOutputStream.
* @throws IOException when there is an I/O error.
* @serial
*/
private void writeObject(ObjectOutputStream s) throws IOException {
}
public static void main(String args[]) {
int status = check();
if (status != 0) {
throw new RuntimeException("Non-zero status returned from the agent: " + status);
}
}
}

@ -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

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

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

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

@ -67,6 +67,7 @@ module java.xml {
exports org.xml.sax;
exports org.xml.sax.ext;
exports org.xml.sax.helpers;
exports com.sun.org.apache.xml.internal.dtm to
java.xml.crypto;
exports com.sun.org.apache.xml.internal.utils to
@ -81,8 +82,7 @@ module java.xml {
java.xml.crypto;
exports com.sun.org.apache.xpath.internal.res to
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.parsers.DocumentBuilderFactory;
uses javax.xml.parsers.SAXParserFactory;

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

@ -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.
*
* 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.
<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>
* 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 com.sun.tools.doclets.formats.html.markup;
package org.w3c.dom.css;

@ -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.
*
* This code is free software; you can redistribute it and/or modify it
@ -23,17 +23,17 @@
* questions.
*/
package com.sun.tools.doclets.internal.toolkit.util;
/**
* <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>
* Provides interfaces for DOM Level 2 HTML Specification. Refer to the
* <a href='http://www.w3.org/TR/2000/CR-DOM-Level-2-20000510'>
* Document Object Model (DOM) Level 2 Specification</a>,
* 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;

@ -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;

@ -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.
*
* This code is free software; you can redistribute it and/or modify it
@ -23,28 +23,21 @@
* 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
*/
@Deprecated
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;
}
}
package org.w3c.dom.xpath;

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

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

@ -1,5 +1,5 @@
/*
* Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1997, 2017, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -118,6 +118,9 @@ public class CommandInfo {
* passed to the command.
* @param loader The ClassLoader to be used to instantiate 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 javax.activation.CommandObject
*/

@ -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.
*
* 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 dh The DataHandler.
* @exception IOException for failures accessing data
*/
public void setCommandContext(String verb, DataHandler dh)
throws IOException;

@ -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.
*
* 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.
*
* @return the OutputStream
* @exception IOException for failures creating the OutputStream
*
* @see javax.activation.DataSource#getOutputStream
* @see javax.activation.URLDataSource

@ -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.
*
* 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.
*
* @return an InputStream
* @exception IOException for failures creating the InputStream
*/
public InputStream getInputStream() throws IOException;
@ -60,6 +61,7 @@ public interface DataSource {
* be positioned at the location the data is to be written.
*
* @return an OutputStream
* @exception IOException for failures creating the OutputStream
*/
public OutputStream getOutputStream() throws IOException;

@ -1,5 +1,5 @@
/*
* Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1997, 2017, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -29,6 +29,8 @@ package javax.activation;
import java.util.*;
import java.io.*;
import java.net.*;
import java.security.AccessController;
import java.security.PrivilegedAction;
import com.sun.activation.registries.MailcapFile;
import com.sun.activation.registries.LogSupport;
@ -48,12 +50,19 @@ import com.sun.activation.registries.LogSupport;
* <ol>
* <li> Programatically added entries to the MailcapCommandMap instance.
* <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 resource named {@code META-INF/mailcap.default}
* (usually found only in the {@code activation.jar} file).
* </ol>
* <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>
*
* Mailcap files must conform to the mailcap
@ -120,6 +129,29 @@ public class MailcapCommandMap extends CommandMap {
private MailcapFile[] DB;
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.
*/
@ -144,11 +176,11 @@ public class MailcapCommandMap extends CommandMap {
LogSupport.log("MailcapCommandMap: load SYS");
try {
// check system's home
String system_mailcap = System.getProperty("java.home") +
File.separator + "lib" + File.separator + "mailcap";
mf = loadFile(system_mailcap);
if (mf != null)
dbv.add(mf);
if (confDir != null) {
mf = loadFile(confDir + "mailcap");
if (mf != null)
dbv.add(mf);
}
} catch (SecurityException ex) {}
LogSupport.log("MailcapCommandMap: load JAR");
@ -633,6 +665,7 @@ public class MailcapCommandMap extends CommandMap {
* entries that specify a view command for the specified
* MIME type are returned.
*
* @param mimeType the MIME type
* @return array of native command entries
* @since 1.6, JAF 1.1
*/

@ -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.
*
* 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.
*
* @param rawdata the MIME type string
* @exception MimeTypeParseException if the MIME type can't be parsed
*/
public MimeType(String rawdata) throws MimeTypeParseException {
parse(rawdata);
@ -258,6 +259,7 @@ public class MimeType implements Externalizable {
*
* @param rawdata the MIME type string to compare with
* @return true if they match
* @exception MimeTypeParseException if the MIME type can't be parsed
*/
public boolean match(String rawdata) throws MimeTypeParseException {
return match(new MimeType(rawdata));

@ -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.
*
* 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.
*
* @param parameterList an RFC 2045, 2046 compliant parameter list.
* @exception MimeTypeParseException if the MIME type can't be parsed
*/
public MimeTypeParameterList(String parameterList)
throws MimeTypeParseException {
@ -71,6 +72,7 @@ public class MimeTypeParameterList {
* A routine for parsing the parameter list out of a String.
*
* @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 {
if (parameterList == null)

@ -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.
*
* 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.net.*;
import java.util.*;
import java.security.AccessController;
import java.security.PrivilegedAction;
import com.sun.activation.registries.MimeTypeFile;
import com.sun.activation.registries.LogSupport;
@ -43,12 +45,19 @@ import com.sun.activation.registries.LogSupport;
* <ol>
* <li> Programmatically added entries to the MimetypesFileTypeMap instance.
* <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 resource named {@code META-INF/mimetypes.default}
* (usually found only in the {@code activation.jar} file).
* </ol>
* <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>
*
* <pre>{@code
@ -72,7 +81,30 @@ public class MimetypesFileTypeMap extends FileTypeMap {
private MimeTypeFile[] DB;
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.
@ -97,11 +129,11 @@ public class MimetypesFileTypeMap extends FileTypeMap {
LogSupport.log("MimetypesFileTypeMap: load SYS");
try {
// check system's home
String system_mimetypes = System.getProperty("java.home") +
File.separator + "lib" + File.separator + "mime.types";
mf = loadFile(system_mimetypes);
if (mf != null)
dbv.addElement(mf);
if (confDir != null) {
mf = loadFile(confDir + "mime.types");
if (mf != null)
dbv.addElement(mf);
}
} catch (SecurityException ex) {}
LogSupport.log("MimetypesFileTypeMap: load JAR");
@ -239,6 +271,7 @@ public class MimetypesFileTypeMap extends FileTypeMap {
* added from the named file.
*
* @param mimeTypeFileName the file name
* @exception IOException for errors reading the file
*/
public MimetypesFileTypeMap(String mimeTypeFileName) throws IOException {
this();

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

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

@ -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);
}
}

@ -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.
*
* 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 {
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 {

@ -1,5 +1,5 @@
/*
* Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1997, 2017, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -165,7 +165,7 @@ public /*to make unit tests happy*/ final class MarshallerImpl extends AbstractM
@Override
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
@ -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.
@ -436,13 +445,14 @@ public /*to make unit tests happy*/ final class MarshallerImpl extends AbstractM
if(encoding.equals("UTF-8")) {
Encoded[] table = context.getUTF8NameTable();
final UTF8XmlOutput out;
CharacterEscapeHandler ceh = createEscapeHandler(encoding);
if(isFormattedOutput())
out = new IndentingUTF8XmlOutput(os, indent, table, escapeHandler);
out = new IndentingUTF8XmlOutput(os, indent, table, ceh);
else {
if(c14nSupport)
out = new C14nXmlOutput(os, table, context.c14nSupport, escapeHandler);
out = new C14nXmlOutput(os, table, context.c14nSupport, ceh);
else
out = new UTF8XmlOutput(os, table, escapeHandler);
out = new UTF8XmlOutput(os, table, ceh);
}
if(header!=null)
out.setHeader(header);

@ -1,5 +1,5 @@
/*
* Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1997, 2017, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -25,21 +25,22 @@
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.Name;
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.fastinfoset.EncodingConstants;
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.util.Collection;
import java.util.Map;
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}.
@ -220,7 +221,7 @@ public final class FastInfosetStreamWriterOutput extends XMLStreamWriterOutput {
public FastInfosetStreamWriterOutput(StAXDocumentSerializer out,
JAXBContextImpl context) {
super(out);
super(out, NoEscapeHandler.theInstance);
this.fiout = out;
this.localNames = context.getUTF8NameTable();

@ -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.
*
* 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 com.sun.xml.internal.bind.marshaller.NoEscapeHandler;
import com.sun.xml.internal.bind.v2.runtime.unmarshaller.Base64Data;
import com.sun.xml.internal.org.jvnet.staxex.XMLStreamWriterEx;
@ -40,7 +41,7 @@ public final class StAXExStreamWriterOutput extends XMLStreamWriterOutput {
private final XMLStreamWriterEx out;
public StAXExStreamWriterOutput(XMLStreamWriterEx out) {
super(out);
super(out, NoEscapeHandler.theInstance);
this.out = out;
}

@ -1,5 +1,5 @@
/*
* Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1997, 2017, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -26,15 +26,16 @@
package com.sun.xml.internal.bind.v2.runtime.output;
import java.io.IOException;
import java.io.Writer;
import java.lang.reflect.Constructor;
import javax.xml.stream.XMLStreamException;
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.XMLSerializer;
import com.sun.xml.internal.bind.v2.runtime.unmarshaller.UnmarshallerImpl;
import org.xml.sax.SAXException;
/**
@ -53,7 +54,7 @@ public class XMLStreamWriterOutput extends XmlOutputAbstractImpl {
* Creates a new {@link XmlOutput} from a {@link XMLStreamWriter}.
* 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
final Class writerClass = out.getClass();
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.
return new XMLStreamWriterOutput(out);
return new XMLStreamWriterOutput(out, xmlStreamEscapeHandler);
}
private final XMLStreamWriter out;
private final CharacterEscapeHandler escapeHandler;
private final XmlStreamOutWriterAdapter writerWrapper;
protected final char[] buf = new char[256];
protected XMLStreamWriterOutput(XMLStreamWriter out) {
protected XMLStreamWriterOutput(XMLStreamWriter out, CharacterEscapeHandler escapeHandler) {
this.out = out;
this.escapeHandler = escapeHandler;
this.writerWrapper = new XmlStreamOutWriterAdapter(out);
}
// 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 {
if(needsSeparatingWhitespace)
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 {
@ -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);
}
}
}
}

@ -150,13 +150,14 @@ class ContextFinder {
* Create an instance of a class using the specified ClassLoader
*/
static JAXBContext newInstance(String contextPath,
Class[] contextPathClasses,
String className,
ClassLoader classLoader,
Map properties) throws JAXBException {
try {
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) {
throw new JAXBException(Messages.format(Messages.DEFAULT_PROVIDER_NOT_FOUND), x);
@ -175,6 +176,7 @@ class ContextFinder {
}
static JAXBContext newInstance(String contextPath,
Class[] contextPathClasses,
Class spFactory,
ClassLoader classLoader,
Map properties) throws JAXBException {
@ -212,6 +214,9 @@ class ContextFinder {
// the cast would fail, so generate an exception with a nice message
throw handleClassCastException(context.getClass(), JAXBContext.class);
}
ModuleUtil.delegateAddOpensToImplModule(contextPathClasses, spFactory);
return (JAXBContext) context;
} catch (InvocationTargetException x) {
// 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
throw handleClassCastException(context.getClass(), JAXBContext.class);
}
ModuleUtil.delegateAddOpensToImplModule(classes, spFactory);
return (JAXBContext) context;
} catch (NoSuchMethodException | IllegalAccessException e) {
@ -295,50 +301,52 @@ class ContextFinder {
ClassLoader classLoader,
Map properties) throws JAXBException {
StringTokenizer packages = new StringTokenizer(contextPath, ":");
if (!packages.hasMoreTokens()) {
if (contextPath == null || contextPath.isEmpty()) {
// no context is specified
throw new JAXBException(Messages.format(Messages.NO_PACKAGE_IN_CONTEXTPATH));
}
// search for jaxb.properties in the class loader of each class first
logger.fine("Searching jaxb.properties");
while (packages.hasMoreTokens()) {
// com.acme.foo - > com/acme/foo/jaxb.properties
String factoryClassName =
classNameFromPackageProperties(
classLoader,
packages.nextToken(":").replace('.', '/'),
factoryId,
JAXB_CONTEXT_FACTORY_DEPRECATED);
//ModuleUtil is mr-jar class, scans context path for jaxb classes on jdk9 and higher
Class[] contextPathClasses = ModuleUtil.getClassesFromContextPath(contextPath, classLoader);
if (factoryClassName != null) {
return newInstance(contextPath, factoryClassName, classLoader, properties);
}
//first try with classloader#getResource
String factoryClassName = jaxbProperties(contextPath, classLoader, factoryId);
if (factoryClassName == null && contextPathClasses != null) {
//try with class#getResource
factoryClassName = jaxbProperties(contextPathClasses, factoryId);
}
if (factoryClassName != null) {
return newInstance(contextPath, contextPathClasses, factoryClassName, classLoader, properties);
}
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.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
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(
"javax.xml.bind.JAXBContext", logger);
if (ctxFactory != null) {
return newInstance(contextPath, ctxFactory, classLoader, properties);
return newInstance(contextPath, contextPathClasses, ctxFactory, classLoader, properties);
}
// else no provider found
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 {
@ -356,13 +364,18 @@ class ContextFinder {
// TODO: it's easier to look things up from the class
// c.getResourceAsStream("jaxb.properties");
String factoryClassName =
classNameFromPackageProperties(
getClassClassLoader(c),
c.getPackage().getName().replace('.', '/'),
JAXBContext.JAXB_CONTEXT_FACTORY, JAXB_CONTEXT_FACTORY_DEPRECATED);
URL jaxbPropertiesUrl = getResourceUrl(c, "jaxb.properties");
if (jaxbPropertiesUrl != null) {
String factoryClassName =
classNameFromPackageProperties(
jaxbPropertiesUrl,
JAXBContext.JAXB_CONTEXT_FACTORY, JAXB_CONTEXT_FACTORY_DEPRECATED);
return newInstance(classes, properties, factoryClassName);
}
if (factoryClassName != null) return newInstance(classes, properties, factoryClassName);
}
String factoryClassName = classNameFromSystemProperties();
@ -371,7 +384,11 @@ class ContextFinder {
JAXBContextFactory factory =
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
String className = firstByServiceLoaderDeprecated(JAXBContext.class, getContextClassLoader());
@ -395,22 +412,20 @@ class ContextFinder {
* first factoryId should be the preferred one,
* more of those can be provided to support backwards compatibility
*/
private static String classNameFromPackageProperties(ClassLoader classLoader,
String packageName,
private static String classNameFromPackageProperties(URL packagePropertiesUrl,
String ... factoryIds) throws JAXBException {
String resourceName = packageName + "/jaxb.properties";
logger.log(Level.FINE, "Trying to locate {0}", resourceName);
Properties props = loadJAXBProperties(classLoader, resourceName);
if (props != null) {
for(String factoryId : factoryIds) {
if (props.containsKey(factoryId)) {
return props.getProperty(factoryId);
}
logger.log(Level.FINE, "Trying to locate {0}", packagePropertiesUrl.toString());
Properties props = loadJAXBProperties(packagePropertiesUrl);
for(String factoryId : factoryIds) {
if (props.containsKey(factoryId)) {
return props.getProperty(factoryId);
}
throw new JAXBException(Messages.format(Messages.MISSING_PROPERTY, packageName, factoryIds[0]));
}
return null;
//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]));
}
private static String classNameFromSystemProperties() throws JAXBException {
@ -452,30 +467,40 @@ class ContextFinder {
return value;
}
private static Properties loadJAXBProperties(ClassLoader classLoader,
String propFileName) throws JAXBException {
private static Properties loadJAXBProperties(URL url) throws JAXBException {
Properties props = null;
try {
URL url;
if (classLoader == null)
url = ClassLoader.getSystemResource(propFileName);
else
url = classLoader.getResource(propFileName);
if (url != null) {
logger.log(Level.FINE, "loading props from {0}", url);
props = new Properties();
InputStream is = url.openStream();
props.load(is);
is.close();
}
Properties props;
logger.log(Level.FINE, "loading props from {0}", url);
props = new Properties();
InputStream is = url.openStream();
props.load(is);
is.close();
return props;
} 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);
}
}
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;
}
}

@ -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.
*
* 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 java.io.IOException;
import java.io.InputStream;
import java.util.Collections;
import java.util.Map;
import java.util.Properties;
import java.io.IOException;
import java.io.InputStream;
/**
* 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.
* (For example, perhaps the schema compiler has generated some vendor extension in the code.)
*
* <p>
* This configuration method is deprecated.
*
* <li>
* 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
@ -332,7 +335,14 @@ public abstract class JAXBContext {
* the context class loader of the current thread.
*
* @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 )
throws JAXBException {
@ -414,16 +424,26 @@ public abstract class JAXBContext {
* <p>
* The steps involved in discovering the JAXB implementation is discussed in the class javadoc.
*
* @param contextPath list of java package names that contain schema
* derived class and/or java to schema (JAXB-annotated)
* mapped 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
* This class loader will be used to locate the implementation
* classes.
*
* @return a new instance of a {@code JAXBContext}
* @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 {
@ -442,7 +462,12 @@ public abstract class JAXBContext {
* The interpretation of properties is up to implementations. Implementations must
* 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
* This class loader will be used to locate the implementation classes.
* @param properties
@ -457,6 +482,7 @@ public abstract class JAXBContext {
* <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 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.
*
* @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
* spec-defined classes will be returned.
*
* @return
* A new instance of a {@code JAXBContext}.
*
* @throws JAXBException if an error was encountered while creating the
* {@code JAXBContext}. See {@link JAXBContext#newInstance(Class[], Map)} for details.
* @throws JAXBException
* 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
* 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.
*
* @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
* spec-defined classes will be returned.
* @param properties
@ -641,6 +681,7 @@ public abstract class JAXBContext {
* <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
@ -702,6 +743,7 @@ public abstract class JAXBContext {
* {@code Validator} object
* @deprecated since JAXB2.0
*/
@Deprecated
public abstract Validator createValidator() throws JAXBException;
/**

@ -1,5 +1,5 @@
/*
* Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -44,7 +44,9 @@ public interface JAXBContextFactory {
* For semantics see {@link javax.xml.bind.JAXBContext#newInstance(Class[], java.util.Map)}
*
* @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
* spec-defined classes will be returned.
* @param properties
@ -56,7 +58,16 @@ public interface JAXBContextFactory {
*
* @throws JAXBException
* 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
* 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
* 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
* This class loader will be used to locate the implementation classes.
* @param properties
@ -86,7 +100,14 @@ public interface JAXBContextFactory {
*
* @return a new instance of a {@code JAXBContext}
* @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
*/

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

@ -44,6 +44,11 @@ ContextFinder.MissingProperty = \
ContextFinder.NoPackageInContextPath = \
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 = \
name: {0} value: {1}
@ -52,3 +57,6 @@ DatatypeConverter.ConverterMustNotBeNull = \
JAXBContext.IllegalCast = \
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.

@ -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() });
}
}
}
}

@ -1,5 +1,5 @@
/*
* Copyright (c) 2003, 2015, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2003, 2017, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -23,6 +23,8 @@
* questions.
*/
package javax.xml.bind;
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.
* To determine if the Unmarshaller has validation enabled, simply
* test the return type for null:
* <p>
* <pre>{@code
* boolean isValidating = u.getSchema()!=null;
* }</pre>

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

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

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

@ -1,5 +1,5 @@
/*
* Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1997, 2017, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -34,6 +34,7 @@ import javax.xml.soap.*;
*/
public class HttpSOAPConnectionFactory extends SOAPConnectionFactory {
@Override
public SOAPConnection createConnection()
throws SOAPException
{

@ -1,5 +1,5 @@
/*
* Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1997, 2017, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -116,6 +116,7 @@ public class MessagingException extends Exception {
* Produce the message, include the message from the nested
* exception if there is one.
*/
@Override
public String getMessage() {
if (next == null)
return super.getMessage();

@ -28,18 +28,20 @@
*/
package com.sun.xml.internal.messaging.saaj.packaging.mime.internet;
import java.io.*;
import java.util.BitSet;
import com.sun.xml.internal.messaging.saaj.packaging.mime.MessagingException;
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 com.sun.xml.internal.messaging.saaj.packaging.mime.*;
import com.sun.xml.internal.messaging.saaj.packaging.mime.util.*;
import com.sun.xml.internal.messaging.saaj.util.ByteOutputStream;
import java.io.BufferedInputStream;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.BitSet;
/**
* The MimeMultipart class is an implementation of the abstract Multipart
@ -67,11 +69,10 @@ import com.sun.xml.internal.messaging.saaj.util.ByteOutputStream;
* subtype by using the <code>MimeMultipart(String subtype)</code>
* constructor. For example, to create a "multipart/alternative" object,
* use <code>new MimeMultipart("alternative")</code>.
*
*/
//TODO: cleanup the SharedInputStream handling
public class BMMimeMultipart extends MimeMultipart {
public class BMMimeMultipart extends MimeMultipart {
/*
* When true it indicates parsing hasnt been done at all
@ -120,12 +121,12 @@ public class BMMimeMultipart extends MimeMultipart {
*/
public BMMimeMultipart(String subtype) {
super(subtype);
/*
* Compute a boundary string.
String boundary = UniqueValue.getUniqueBoundaryValue();
ContentType cType = new ContentType("multipart", subtype, null);
/*
* Compute a boundary string.
String boundary = UniqueValue.getUniqueBoundaryValue();
ContentType cType = new ContentType("multipart", subtype, null);
contentType.setParameter("boundary", boundary);
*/
*/
}
/**
@ -144,25 +145,25 @@ public class BMMimeMultipart extends MimeMultipart {
* skips the 'preamble' and reads bytes till the terminating
* boundary and creates MimeBodyParts for each part of the stream.
*
* @param ds DataSource, can be a MultipartDataSource.
* @param ct content type.
* @exception MessagingException in case of error.
* @param ct content type.
* @param ds DataSource, can be a MultipartDataSource.
* @throws MessagingException in case of error.
*/
public BMMimeMultipart(DataSource ds, ContentType ct)
throws MessagingException {
super(ds,ct);
throws MessagingException {
super(ds, ct);
boundary = ct.getParameter("boundary");
/*
if (ds instanceof MultipartDataSource) {
// ask super to do this for us.
setMultipartDataSource((MultipartDataSource)ds);
return;
}
if (ds instanceof MultipartDataSource) {
// ask super to do this for us.
setMultipartDataSource((MultipartDataSource)ds);
return;
}
// 'ds' was not a MultipartDataSource, we have
// to parse this ourself.
parsed = false;
this.ds = ds;
// 'ds' was not a MultipartDataSource, we have
// to parse this ourself.
parsed = false;
this.ds = ds;
if (ct==null)
contentType = new ContentType(ds.getContentType());
else
@ -177,8 +178,8 @@ public class BMMimeMultipart extends MimeMultipart {
try {
in = ds.getInputStream();
if (!(in instanceof ByteArrayInputStream) &&
!(in instanceof BufferedInputStream) &&
!(in instanceof SharedInputStream))
!(in instanceof BufferedInputStream) &&
!(in instanceof SharedInputStream))
in = new BufferedInputStream(in);
} catch (Exception ex) {
throw new MessagingException("No inputstream from datasource");
@ -186,7 +187,7 @@ public class BMMimeMultipart extends MimeMultipart {
if (!in.markSupported()) {
throw new MessagingException(
"InputStream does not support Marking");
"InputStream does not support Marking");
}
}
return in;
@ -199,10 +200,10 @@ public class BMMimeMultipart extends MimeMultipart {
* method is called by all other methods that need data for
* the body parts, to make sure the data has been parsed.
*
* @since JavaMail 1.2
* @since JavaMail 1.2
*/
@Override
protected void parse() throws MessagingException {
protected void parse() throws MessagingException {
if (parsed)
return;
@ -210,7 +211,7 @@ public class BMMimeMultipart extends MimeMultipart {
SharedInputStream sin = null;
if (in instanceof SharedInputStream) {
sin = (SharedInputStream)in;
sin = (SharedInputStream) in;
}
String bnd = "--" + boundary;
@ -231,8 +232,8 @@ public class BMMimeMultipart extends MimeMultipart {
}
public MimeBodyPart getNextPart(
InputStream stream, byte[] pattern, SharedInputStream sin)
throws Exception {
InputStream stream, byte[] pattern, SharedInputStream sin)
throws Exception {
if (!stream.markSupported()) {
throw new Exception("InputStream does not support Marking");
@ -242,7 +243,7 @@ public class BMMimeMultipart extends MimeMultipart {
compile(pattern);
if (!skipPreamble(stream, pattern, sin)) {
throw new Exception(
"Missing Start Boundary, or boundary does not start on a new line");
"Missing Start Boundary, or boundary does not start on a new line");
}
begining = false;
}
@ -256,7 +257,7 @@ public class BMMimeMultipart extends MimeMultipart {
b = readHeaders(stream);
if (b == -1) {
throw new Exception(
"End of Stream encountered while reading part headers");
"End of Stream encountered while reading part headers");
}
long[] v = new long[1];
v[0] = -1; // just to ensure the code later sets it correctly
@ -276,7 +277,7 @@ public class BMMimeMultipart extends MimeMultipart {
} else {
InternetHeaders headers = createInternetHeaders(stream);
ByteOutputStream baos = new ByteOutputStream();
b = readBody(stream, pattern, null,baos, null);
b = readBody(stream, pattern, null, baos, null);
// looks like this check has to be disabled
// in the old impl it is allowed to have Mime Package
// without closing boundary
@ -286,7 +287,7 @@ public class BMMimeMultipart extends MimeMultipart {
}
}
MimeBodyPart mbp = createMimeBodyPart(
headers, baos.getBytes(), baos.getCount());
headers, baos.getBytes(), baos.getCount());
addBodyPart(mbp);
return mbp;
}
@ -294,11 +295,11 @@ public class BMMimeMultipart extends MimeMultipart {
}
public boolean parse(
InputStream stream, byte[] pattern, SharedInputStream sin)
throws Exception {
InputStream stream, byte[] pattern, SharedInputStream sin)
throws Exception {
while (!lastPartFound.get(0) && (b != -1)) {
getNextPart(stream, pattern, sin);
getNextPart(stream, pattern, sin);
}
return true;
}
@ -307,7 +308,7 @@ public class BMMimeMultipart extends MimeMultipart {
// if the headers are to end properly then there has to be CRLF
// actually we just need to mark the start and end positions
int b = is.read();
while(b != -1) {
while (b != -1) {
// when it is a shared input stream no need to copy
if (b == '\r') {
b = is.read();
@ -316,7 +317,7 @@ public class BMMimeMultipart extends MimeMultipart {
if (b == '\r') {
b = is.read();
if (b == '\n') {
return b;
return b;
} else {
continue;
}
@ -331,43 +332,43 @@ public class BMMimeMultipart extends MimeMultipart {
}
if (b == -1) {
throw new Exception(
"End of inputstream while reading Mime-Part Headers");
"End of inputstream while reading Mime-Part Headers");
}
return b;
}
private int readBody(
InputStream is, byte[] pattern, long[] posVector,
ByteOutputStream baos, SharedInputStream sin)
throws Exception {
InputStream is, byte[] pattern, long[] posVector,
ByteOutputStream baos, SharedInputStream sin)
throws Exception {
if (!find(is, pattern, posVector, baos, sin)) {
throw new Exception(
"Missing boundary delimitier while reading Body Part");
"Missing boundary delimitier while reading Body Part");
}
return b;
}
private boolean skipPreamble(
InputStream is, byte[] pattern, SharedInputStream sin)
throws Exception {
InputStream is, byte[] pattern, SharedInputStream sin)
throws Exception {
if (!find(is, pattern, sin)) {
return false;
}
if (lastPartFound.get(0)) {
throw new Exception(
"Found closing boundary delimiter while trying to skip preamble");
"Found closing boundary delimiter while trying to skip preamble");
}
return true;
}
public int readNext(InputStream is, byte[] buff, int patternLength,
BitSet eof, long[] posVector, SharedInputStream sin)
throws Exception {
public int readNext(InputStream is, byte[] buff, int patternLength,
BitSet eof, long[] posVector, SharedInputStream sin)
throws Exception {
int bufferLength = is.read(buffer, 0, patternLength);
if (bufferLength == -1) {
eof.flip(0);
eof.flip(0);
} else if (bufferLength < patternLength) {
//repeatedly read patternLength - bufferLength
int temp = 0;
@ -385,18 +386,18 @@ public class BMMimeMultipart extends MimeMultipart {
}
break;
}
buffer[i] = (byte)temp;
buffer[i] = (byte) temp;
}
bufferLength=i;
bufferLength = i;
}
return bufferLength;
}
public boolean find(InputStream is, byte[] pattern, SharedInputStream sin)
throws Exception {
throws Exception {
int i;
int l = pattern.length;
int lx = l -1;
int lx = l - 1;
BitSet eof = new BitSet(1);
long[] posVector = new long[1];
@ -409,12 +410,12 @@ public class BMMimeMultipart extends MimeMultipart {
}
/*
if (bufferLength < l) {
//is.reset();
return false;
}*/
if (bufferLength < l) {
//is.reset();
return false;
}*/
for(i = lx; i >= 0; i--) {
for (i = lx; i >= 0; i--) {
if (buffer[i] != pattern[i]) {
break;
}
@ -435,11 +436,11 @@ public class BMMimeMultipart extends MimeMultipart {
}
public boolean find(
InputStream is, byte[] pattern, long[] posVector,
ByteOutputStream out, SharedInputStream sin) throws Exception {
InputStream is, byte[] pattern, long[] posVector,
ByteOutputStream out, SharedInputStream sin) throws Exception {
int i;
int l = pattern.length;
int lx = l -1;
int lx = l - 1;
int bufferLength = 0;
int s = 0;
long endPos = -1;
@ -466,7 +467,7 @@ public class BMMimeMultipart extends MimeMultipart {
// looks like it is allowed to not have a closing boundary
//return false;
//if (sin != null) {
// posVector[0] = endPos;
// posVector[0] = endPos;
//}
b = -1;
if ((s == l) && (sin == null)) {
@ -482,7 +483,7 @@ public class BMMimeMultipart extends MimeMultipart {
} else {
// looks like it is allowed to not have a closing boundary
// in the old implementation
out.write(buffer, 0, bufferLength);
out.write(buffer, 0, bufferLength);
}
// looks like it is allowed to not have a closing boundary
// in the old implementation
@ -491,7 +492,7 @@ public class BMMimeMultipart extends MimeMultipart {
return true;
}
for(i = lx; i >= 0; i--) {
for (i = lx; i >= 0; i--) {
if (buffer[i] != pattern[i]) {
break;
}
@ -507,7 +508,7 @@ public class BMMimeMultipart extends MimeMultipart {
if (s == 2) {
if (prevBuffer[1] == '\n') {
if (prevBuffer[0] != '\r' && prevBuffer[0] != '\n') {
out.write(prevBuffer,0,1);
out.write(prevBuffer, 0, 1);
}
if (sin != null) {
posVector[0] = endPos;
@ -516,15 +517,15 @@ public class BMMimeMultipart extends MimeMultipart {
} else {
throw new Exception(
"Boundary characters encountered in part Body " +
"without a preceeding CRLF");
"without a preceeding CRLF");
}
} else if (s==1) {
} else if (s == 1) {
if (prevBuffer[0] != '\n') {
throw new Exception(
"Boundary characters encountered in part Body " +
"without a preceeding CRLF");
}else {
"without a preceeding CRLF");
} else {
if (sin != null) {
posVector[0] = endPos;
}
@ -532,13 +533,13 @@ public class BMMimeMultipart extends MimeMultipart {
}
} else if (s > 2) {
if ((prevBuffer[s-2] == '\r') && (prevBuffer[s-1] == '\n')) {
if ((prevBuffer[s - 2] == '\r') && (prevBuffer[s - 1] == '\n')) {
if (sin != null) {
posVector[0] = endPos - 2;
} else {
out.write(prevBuffer, 0, s - 2);
}
} else if (prevBuffer[s-1] == '\n') {
} else if (prevBuffer[s - 1] == '\n') {
//old impl allowed just a \n
if (sin != null) {
posVector[0] = endPos - 1;
@ -547,8 +548,8 @@ public class BMMimeMultipart extends MimeMultipart {
}
} else {
throw new Exception(
"Boundary characters encountered in part Body " +
"without a preceeding CRLF");
"Boundary characters encountered in part Body " +
"without a preceeding CRLF");
}
}
}
@ -561,22 +562,22 @@ public class BMMimeMultipart extends MimeMultipart {
}
if ((s > 0) && (sin == null)) {
if (prevBuffer[s-1] == (byte)13) {
if (prevBuffer[s - 1] == (byte) 13) {
// if buffer[0] == (byte)10
if (buffer[0] == (byte)10) {
if (buffer[0] == (byte) 10) {
int j;
for(j = lx-1; j > 0; j--) {
if (buffer[j+1] != pattern[j]) {
for (j = lx - 1; j > 0; j--) {
if (buffer[j + 1] != pattern[j]) {
break;
}
}
if (j == 0) {
// matched the pattern excluding the last char of the pattern
// so dont write the CR into stream
out.write(prevBuffer,0,s-1);
} else {
out.write(prevBuffer,0,s);
}
}
}
if (j == 0) {
// matched the pattern excluding the last char of the pattern
// so dont write the CR into stream
out.write(prevBuffer, 0, s - 1);
} else {
out.write(prevBuffer, 0, s);
}
} else {
out.write(prevBuffer, 0, s);
}
@ -612,20 +613,20 @@ public class BMMimeMultipart extends MimeMultipart {
return true;
} else {
throw new Exception(
"transport padding after a Mime Boundary should end in a CRLF, found CR only");
"transport padding after a Mime Boundary should end in a CRLF, found CR only");
}
}
if (b == '-') {
b = is.read();
if (b != '-') {
throw new Exception(
"Unexpected singular '-' character after Mime Boundary");
throw new Exception(
"Unexpected singular '-' character after Mime Boundary");
} else {
//System.out.println("Last Part Found");
lastPartFound.flip(0);
// read the next char
b = is.read();
b = is.read();
}
}
@ -641,7 +642,7 @@ public class BMMimeMultipart extends MimeMultipart {
b = is.read();
}
if (b == '\n') {
return true;
return true;
}
}
}
@ -673,7 +674,8 @@ public class BMMimeMultipart extends MimeMultipart {
// Initialise Good Suffix Shift table
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
for (j = l - 1; j >= i; j--) {
// Testing for good suffix
@ -681,9 +683,9 @@ public class BMMimeMultipart extends MimeMultipart {
// pattern[j..len] is a good suffix
gss[j - 1] = i;
} else {
// No match. The array has already been
// filled up with correct values before.
continue NEXT;
// No match. The array has already been
// filled up with correct values before.
continue NEXT;
}
}
while (j > 0) {
@ -756,6 +758,7 @@ public class BMMimeMultipart extends MimeMultipart {
this.contentType.setParameter("boundary", bnd);
}
}
public String getBoundary() {
return this.boundary;
}

@ -320,15 +320,15 @@ public final class InternetHeaders {
* @return list of header lines.
*/
public List<String> getAllHeaderLines() {
if(headerValueView==null)
if (headerValueView == null)
headerValueView = new AbstractList<String>() {
@Override
public String get(int index) {
public String get(int index) {
return headers.get(index).line;
}
@Override
public int size() {
public int size() {
return headers.size();
}
};

@ -31,15 +31,21 @@
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 com.sun.xml.internal.messaging.saaj.packaging.mime.*;
import com.sun.xml.internal.messaging.saaj.packaging.mime.util.*;
import com.sun.xml.internal.messaging.saaj.util.FinalArrayList;
import com.sun.xml.internal.messaging.saaj.util.ByteOutputStream;
import com.sun.xml.internal.messaging.saaj.util.SAAJUtil;
import java.io.BufferedInputStream;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
/**
* The MimeMultipart class is an implementation
@ -211,7 +217,7 @@ public class MimeMultipart {
* @exception MessagingException if no such MimeBodyPart exists
*/
public MimeBodyPart getBodyPart(int index)
throws MessagingException {
throws MessagingException {
parse();
if (parts == null)
throw new IndexOutOfBoundsException("No such BodyPart");
@ -228,19 +234,19 @@ public class MimeMultipart {
* @exception MessagingException if no such MimeBodyPart exists.
*/
public MimeBodyPart getBodyPart(String CID)
throws MessagingException {
throws MessagingException {
parse();
int count = getCount();
for (int i = 0; i < count; i++) {
MimeBodyPart part = getBodyPart(i);
String s = part.getContentID();
// Old versions of AXIS2 put angle brackets around the content
// id but not the start param
String sNoAngle = (s!= null) ? s.replaceFirst("^<", "").replaceFirst(">$", "")
:null;
// Old versions of AXIS2 put angle brackets around the content
// id but not the start param
String sNoAngle = (s!= null) ? s.replaceFirst("^<", "").replaceFirst(">$", "")
:null;
if (s != null && (s.equals(CID) || CID.equals(sNoAngle)))
return part;
return part;
}
return null;
}
@ -319,14 +325,14 @@ public class MimeMultipart {
try {
in = ds.getInputStream();
if (!(in instanceof ByteArrayInputStream) &&
!(in instanceof BufferedInputStream) &&
!(in instanceof SharedInputStream))
!(in instanceof BufferedInputStream) &&
!(in instanceof SharedInputStream))
in = new BufferedInputStream(in);
} catch (Exception ex) {
throw new MessagingException("No inputstream from datasource");
}
if (in instanceof SharedInputStream)
sin = (SharedInputStream)in;
sin = (SharedInputStream) in;
String boundary = "--" + contentType.getParameter("boundary");
byte[] bndbytes = ASCIIUtility.getBytes(boundary);
@ -338,12 +344,12 @@ public class MimeMultipart {
LineInputStream lin = new LineInputStream(in);
String line;
while ((line = lin.readLine()) != null) {
/*
* Strip trailing whitespace. Can't use trim method
* because it's too aggressive. Some bogus MIME
* messages will include control characters in the
* boundary string.
*/
/*
* Strip trailing whitespace. Can't use trim method
* because it's too aggressive. Some bogus MIME
* messages will include control characters in the
* boundary string.
*/
int i;
for (i = line.length() - 1; i >= 0; i--) {
char c = line.charAt(i);
@ -357,12 +363,12 @@ public class MimeMultipart {
if (line == null)
throw new MessagingException("Missing start boundary");
/*
* Read and process body parts until we see the
* terminating boundary line (or EOF).
*/
/*
* Read and process body parts until we see the
* terminating boundary line (or EOF).
*/
boolean done = false;
getparts:
getparts:
while (!done) {
InternetHeaders headers = null;
if (sin != null) {
@ -372,7 +378,7 @@ public class MimeMultipart {
;
if (line == null) {
if (!ignoreMissingEndBoundary) {
throw new MessagingException("Missing End Boundary for Mime Package : EOF while skipping headers");
throw new MessagingException("Missing End Boundary for Mime Package : EOF while skipping headers");
}
// assume there's just a missing end boundary
break getparts;
@ -397,7 +403,7 @@ public class MimeMultipart {
/*
* Read and save the content bytes in buf.
*/
for (;;) {
for (; ; ) {
if (bol) {
/*
* At the beginning of a line, check whether the
@ -416,7 +422,7 @@ public class MimeMultipart {
if (in.read() == '-') {
done = true;
foundClosingBoundary = true;
break; // ignore trailing text
break; // ignore trailing text
}
}
// skip linear whitespace
@ -424,12 +430,12 @@ public class MimeMultipart {
b2 = in.read();
// check for end of line
if (b2 == '\n')
break; // got it! break out of the loop
break; // got it! break out of the loop
if (b2 == '\r') {
in.mark(1);
if (in.read() != '\n')
in.reset();
break; // got it! break out of the loop
break; // got it! break out of the loop
}
}
// failed to match, reset and proceed normally
@ -491,7 +497,7 @@ public class MimeMultipart {
buf.close();
}
if (!ignoreMissingEndBoundary && !foundClosingBoundary && sin== null) {
if (!ignoreMissingEndBoundary && !foundClosingBoundary && sin == null) {
throw new MessagingException("Missing End Boundary for Mime Package : EOF while skipping headers");
}
parsed = true;
@ -510,7 +516,7 @@ public class MimeMultipart {
* @since JavaMail 1.2
*/
protected InternetHeaders createInternetHeaders(InputStream is)
throws MessagingException {
throws MessagingException {
return new InternetHeaders(is);
}
@ -523,12 +529,12 @@ public class MimeMultipart {
*
* @param headers the headers for the body part.
* @param content the content of the body part.
* @param len the content length.
* @param len the content length.
* @return MimeBodyPart
* @since JavaMail 1.2
*/
protected MimeBodyPart createMimeBodyPart(InternetHeaders headers, byte[] content, int len) {
return new MimeBodyPart(headers, content,len);
return new MimeBodyPart(headers, content,len);
}
/**
@ -544,7 +550,7 @@ public class MimeMultipart {
* @since JavaMail 1.2
*/
protected MimeBodyPart createMimeBodyPart(InputStream is) throws MessagingException {
return new MimeBodyPart(is);
return new MimeBodyPart(is);
}
/**
@ -564,7 +570,7 @@ public class MimeMultipart {
* @exception MessagingException in case of error.
*/
protected void setMultipartDataSource(MultipartDataSource mp)
throws MessagingException {
throws MessagingException {
contentType = new ContentType(mp.getContentType());
int count = mp.getCount();
@ -582,7 +588,7 @@ public class MimeMultipart {
* @see #contentType
*/
public ContentType getContentType() {
return contentType;
return contentType;
}
/**

@ -28,21 +28,21 @@
*/
package com.sun.xml.internal.messaging.saaj.packaging.mime.internet;
import java.io.*;
import java.net.UnknownServiceException;
import com.sun.xml.internal.messaging.saaj.packaging.mime.MessagingException;
import javax.activation.DataSource;
import com.sun.xml.internal.messaging.saaj.packaging.mime.MessagingException;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.UnknownServiceException;
/**
* A utility class that implements a DataSource out of
* a MimeBodyPart. This class is primarily meant for service providers.
*
* @author John Mani
* @author John Mani
*/
public final class MimePartDataSource implements DataSource {
@ -68,13 +68,13 @@ public final class MimePartDataSource implements DataSource {
* using the <code>getContentStream()</code> method and decodes
* it using the <code>MimeUtility.decode()</code> method.
*
* @return decoded input stream
* @return decoded input stream
*/
@Override
public InputStream getInputStream() throws IOException {
try {
InputStream is = part.getContentStream();
InputStream is = part.getContentStream();
String encoding = part.getEncoding();
if (encoding != null)
@ -92,7 +92,7 @@ public final class MimePartDataSource implements DataSource {
* This implementation throws the UnknownServiceException.
*/
@Override
public OutputStream getOutputStream() throws IOException {
public OutputStream getOutputStream() throws IOException {
throw new UnknownServiceException();
}
@ -113,11 +113,11 @@ public final class MimePartDataSource implements DataSource {
* This implementation just returns an empty string.
*/
@Override
public String getName() {
public String getName() {
try {
return part.getFileName();
return part.getFileName();
} catch (MessagingException mex) {
return "";
return "";
}
}
}

@ -1,5 +1,5 @@
/*
* Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1997, 2017, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -113,6 +113,7 @@ public class MimePullMultipart extends MimeMultipart {
parsed = true;
}
@Override
protected void parse() throws MessagingException {
parseAll();
}

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

@ -32,12 +32,14 @@ package com.sun.xml.internal.messaging.saaj.packaging.mime.util;
import com.sun.xml.internal.messaging.saaj.util.ByteOutputStream;
import java.io.*;
import java.io.IOException;
import java.io.InputStream;
public class ASCIIUtility {
// Private constructor so that this class is not instantiated
private ASCIIUtility() { }
private ASCIIUtility() {
}
/**
@ -47,16 +49,14 @@ public class ASCIIUtility {
*
* Based on java.lang.Integer.parseInt().
*
* @param b bytes to convert to integer.
* @param b bytes to convert to integer.
* @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.
*
* @return integer.
*
*/
public static int parseInt(byte[] b, int start, int end, int radix)
throws NumberFormatException {
throws NumberFormatException {
if (b == null)
throw new NumberFormatException("null");
@ -77,18 +77,18 @@ public class ASCIIUtility {
}
multmin = limit / radix;
if (i < end) {
digit = Character.digit((char)b[i++], radix);
digit = Character.digit((char) b[i++], radix);
if (digit < 0) {
throw new NumberFormatException(
"illegal number: " + toString(b, start, end)
);
"illegal number: " + toString(b, start, end)
);
} else {
result = -digit;
}
}
while (i < end) {
// Accumulating negatively avoids surprises near MAX_VALUE
digit = Character.digit((char)b[i++], radix);
digit = Character.digit((char) b[i++], radix);
if (digit < 0) {
throw new NumberFormatException("illegal number");
}
@ -120,56 +120,48 @@ public class ASCIIUtility {
* array into a String. The range extends from <code>start</code>
* till, but not including <code>end</code>.
*
* @param b bytes to convert to integer.
* @param b bytes to convert to integer.
* @param start start of the range.
* @param end end of the range (not including).
*
* @param end end of the range (not including).
* @return integer.
*
*/
public static String toString(byte[] b, int start, int end) {
int size = end - start;
char[] theChars = new char[size];
for (int i = 0, j = start; i < size; )
theChars[i++] = (char)(b[j++]&0xff);
theChars[i++] = (char) (b[j++] & 0xff);
return new String(theChars);
}
/**
* Encodes specified String into a sequence of bytes using the platform's
* default charset, storing the result into a new byte array.
*
* @param s string to encode into byte array.
*
* @return byte array.
*
*/
/**
* Encodes specified String into a sequence of bytes using the platform's
* default charset, storing the result into a new byte array.
*
* @param s string to encode into byte array.
* @return byte array.
*/
public static byte[] getBytes(String s) {
char [] chars= s.toCharArray();
char[] chars = s.toCharArray();
int size = chars.length;
byte[] bytes = new byte[size];
for (int i = 0; i < size;)
for (int i = 0; i < size; )
bytes[i] = (byte) chars[i++];
return bytes;
}
/**
* Converts input stream to array.
*
* @param is stream to convert to array.
*
* @return byte array.
*
* @throws IOException if an I/O error occurs.
* Converts input stream to array.
*
* @deprecated
* this is an expensive operation that require an additional
* buffer reallocation just to get the array of an exact size.
* Unless you absolutely need the exact size array, don't use this.
* Use {@link ByteOutputStream} and {@link ByteOutputStream#write(InputStream)}.
* @param is stream to convert to array.
* @return byte array.
* @throws IOException if an I/O error occurs.
* @deprecated this is an expensive operation that require an additional
* buffer reallocation just to get the array of an exact size.
* Unless you absolutely need the exact size array, don't use this.
* Use {@link ByteOutputStream} and {@link ByteOutputStream#write(InputStream)}.
*/
@Deprecated
public static byte[] getBytes(InputStream is) throws IOException {

@ -1,5 +1,5 @@
/*
* Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1997, 2017, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -63,6 +63,7 @@ public class QDecoderStream extends QPDecoderStream {
* stream is reached.
* @exception IOException if an I/O error occurs.
*/
@Override
public int read() throws IOException {
int c = in.read();

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

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

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

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

@ -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.
*
* 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() {
return AccessController.doPrivileged(new PrivilegedAction<ClassLoader>() {
@Override
public ClassLoader run() {
ClassLoader cl = null;
try {

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