mirror of
https://github.com/openjdk/jdk.git
synced 2025-09-18 18:14:38 +02:00
Merge
This commit is contained in:
commit
735f943ea6
488 changed files with 14493 additions and 8732 deletions
|
@ -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="gtest:LogTagSet gtest:LogTagSetDescriptions"
|
|||
$ make run-test TEST="hotspot/test:hotspot_gc" JTREG="JOBS=1;TIMEOUT=8;VM_OTIONS=-XshowSettings -Xlog:gc+ref=debug"
|
||||
$ make run-test TEST="jtreg:hotspot/test:hotspot_gc hotspot/test/native_sanity/JniVersion.java"
|
||||
$ 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=<path to jtreg home></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="tier1"</code>, but the latter is more tab-completion friendly. For more complex test runs, the <code>run-test TEST="x"</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="tier1"</code>, but the latter is more tab-completion friendly. For more complex test runs, the <code>run-test TEST="x"</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>>> ... <<</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="JOBS=1;TIMEOUT=8"</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="TMIEOUT=8"</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="JOBS=1;TIMEOUT=8"</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="TMIEOUT=8"</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="...;..."</code>. This will also make sure spaces are preserved, as in <code>JTREG="VM_OTIONS=-XshowSettings -Xlog:gc+ref=debug"</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="OPTIONS=--help all"</code> to see all available JTreg options.</p>
|
||||
<p>Additional options to the JTReg test framework.</p>
|
||||
<p>Use <code>JTREG="OPTIONS=--help all"</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
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
|
|
53
hotspot/test/compiler/c1/MultiplyByMaxInt.java
Normal file
53
hotspot/test/compiler/c1/MultiplyByMaxInt.java
Normal file
|
@ -0,0 +1,53 @@
|
|||
/*
|
||||
* Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
/*
|
||||
* @test
|
||||
* @bug 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 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) {
|
||||
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
|
||||
*/
|
||||
|
|
|
@ -0,0 +1,57 @@
|
|||
/*
|
||||
* Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package MyPackage;
|
||||
|
||||
/**
|
||||
* @test
|
||||
* @summary Verifies the JVMTI IsModifiableModule API
|
||||
* @modules jdk.jdi
|
||||
* @compile IsModifiableModuleTest.java
|
||||
* @run main/othervm/native -agentlib:IsModifiableModuleTest MyPackage.IsModifiableModuleTest
|
||||
*/
|
||||
|
||||
import java.io.PrintStream;
|
||||
|
||||
public class IsModifiableModuleTest {
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
native static int check();
|
||||
|
||||
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 @@ df64bd4757d0d130d62a22b8143ba31d3a16ac18 jdk-10+10
|
|||
a5506b425f1bf91530d8417b57360e5d89328c0c jdk-9+173
|
||||
42f18c931bd4fae5c206ccf6d8e591e4c4e69d31 jdk-9+174
|
||||
5f504872a75b71f2fb19299f0d1e3395cf32eaa0 jdk-10+12
|
||||
e6c4f6ef717d104dba880e2dae538690c993b46f jdk-9+175
|
||||
4540d6376f3ef22305cca546f85f9b2ce9a210c4 jdk-10+13
|
||||
|
|
|
@ -1 +1,2 @@
|
|||
project=jdk10
|
||||
bugids=dup
|
||||
|
|
|
@ -49,7 +49,4 @@ TOOL_ADD_PACKAGES_ATTRIBUTE := $(BUILD_JAVA) $(JAVA_FLAGS_SMALL) \
|
|||
--add-exports java.base/jdk.internal.module=ALL-UNNAMED \
|
||||
build.tools.jigsaw.AddPackagesAttribute
|
||||
|
||||
TOOL_GEN_DOCS_BUNDLE_PAGE := $(BUILD_JAVA) -esa -ea -cp $(TOOLS_CLASSES_DIR) \
|
||||
build.tools.docs.GenDocsBundlePage
|
||||
|
||||
endif # _MODULE_TOOLS_GMK
|
||||
|
|
|
@ -278,7 +278,6 @@ SUNWprivate_1.1 {
|
|||
Java_java_lang_Module_addExports0;
|
||||
Java_java_lang_Module_addExportsToAll0;
|
||||
Java_java_lang_Module_addExportsToAllUnnamed0;
|
||||
Java_java_lang_Module_addPackage0;
|
||||
|
||||
Java_jdk_internal_loader_BootLoader_getSystemPackageLocation;
|
||||
Java_jdk_internal_loader_BootLoader_getSystemPackageNames;
|
||||
|
|
|
@ -1,247 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package build.tools.docs;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.BufferedWriter;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.PrintWriter;
|
||||
import java.lang.module.ModuleDescriptor;
|
||||
import java.lang.module.ModuleFinder;
|
||||
import java.lang.module.ModuleReference;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
import java.util.Arrays;
|
||||
import java.util.Comparator;
|
||||
import java.util.HashMap;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.Properties;
|
||||
import java.util.Set;
|
||||
import java.util.function.Predicate;
|
||||
import java.util.stream.Stream;
|
||||
import static java.util.stream.Collectors.*;
|
||||
|
||||
/**
|
||||
* Build tool to generate the docs bundle index page.
|
||||
*/
|
||||
public class GenDocsBundlePage {
|
||||
private static String DOCS_BUNDLE_PAGE = "docs-bundle-page.html";
|
||||
private static String MODULE_GROUPS_PROPS = "docs-module-groups.properties";
|
||||
|
||||
private static String USAGE =
|
||||
"GenDocsBundlePage --output <file path> --title <title>" +
|
||||
" [--template <template>]";
|
||||
|
||||
public static void main(String... args) throws IOException {
|
||||
String title = null;
|
||||
Path outputfile = null;
|
||||
Path template = null;
|
||||
for (int i=0; i < args.length; i++) {
|
||||
String option = args[i];
|
||||
if (option.equals("--output")) {
|
||||
outputfile = Paths.get(getArgument(args, option, ++i));
|
||||
} else if (option.equals("--title")) {
|
||||
title = getArgument(args, option, ++i);
|
||||
} else if (option.equals("--template")) {
|
||||
template = Paths.get(getArgument(args, option, ++i));
|
||||
} else if (option.startsWith("-")) {
|
||||
throw new IllegalArgumentException("Invalid option: " + option);
|
||||
}
|
||||
}
|
||||
|
||||
if (outputfile == null) {
|
||||
System.err.println("ERROR: must specify --output option");
|
||||
System.exit(1);
|
||||
}
|
||||
if (title == null) {
|
||||
System.err.println("ERROR: must specify --title option");
|
||||
System.exit(1);
|
||||
}
|
||||
|
||||
try (InputStream is = readTemplate(template);
|
||||
BufferedReader reader = new BufferedReader(new InputStreamReader(is)))
|
||||
{
|
||||
new GenDocsBundlePage(title, outputfile).run(reader);
|
||||
}
|
||||
}
|
||||
|
||||
private static String getArgument(String[] args, String option, int index) {
|
||||
if (index < args.length) {
|
||||
return args[index];
|
||||
}
|
||||
throw new IllegalArgumentException("Argument must be specified for " + option);
|
||||
}
|
||||
|
||||
private static InputStream readTemplate(Path template) throws IOException {
|
||||
if (template != null) {
|
||||
return Files.newInputStream(template);
|
||||
} else {
|
||||
return GenDocsBundlePage.class.getResourceAsStream(DOCS_BUNDLE_PAGE);
|
||||
}
|
||||
}
|
||||
|
||||
private static final String HEADER_TITLE = "@HEADER_TITLE@";
|
||||
|
||||
|
||||
final Path outputfile;
|
||||
final String title;
|
||||
final Map<String, Set<ModuleDescriptor>> moduleGroups = new HashMap<>();
|
||||
GenDocsBundlePage(String title, Path outputfile) throws IOException
|
||||
{
|
||||
this.outputfile = outputfile;
|
||||
this.title = title;
|
||||
|
||||
// read module groups
|
||||
ModuleFinder finder = ModuleFinder.ofSystem();
|
||||
try (InputStream in = GenDocsBundlePage.class.getResourceAsStream(MODULE_GROUPS_PROPS)) {
|
||||
Properties props = new Properties();
|
||||
props.load(in);
|
||||
for (String key: props.stringPropertyNames()) {
|
||||
Set<ModuleDescriptor> mods =
|
||||
Stream.of(props.getProperty(key).split("\\s+"))
|
||||
.map(String::trim)
|
||||
.flatMap(mn -> finder.find(mn).stream())
|
||||
.map(ModuleReference::descriptor)
|
||||
.collect(toSet());
|
||||
|
||||
String name = "@" + key.toUpperCase(Locale.ENGLISH) + "@";
|
||||
moduleGroups.put(name, mods);
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
void run(BufferedReader reader) throws IOException {
|
||||
if (Files.notExists(outputfile.getParent())) {
|
||||
Files.createDirectories(outputfile.getParent());
|
||||
}
|
||||
try (BufferedWriter bw = Files.newBufferedWriter(outputfile, StandardCharsets.UTF_8);
|
||||
PrintWriter writer = new PrintWriter(bw)) {
|
||||
reader.lines().map(this::genOutputLine)
|
||||
.forEach(writer::println);
|
||||
}
|
||||
}
|
||||
|
||||
String genOutputLine(String line) {
|
||||
if (line.contains(HEADER_TITLE)) {
|
||||
line = line.replace(HEADER_TITLE, title);
|
||||
}
|
||||
int i = line.indexOf('@');
|
||||
int j = line.indexOf('@', i+1);
|
||||
if (i >= 0 && i < j) {
|
||||
String name = line.substring(i, j+1);
|
||||
if (moduleGroups.containsKey(name)) {
|
||||
line = line.replace(name, formatModuleGroup(name));
|
||||
}
|
||||
}
|
||||
return line;
|
||||
}
|
||||
|
||||
String toHRef(ModuleDescriptor md) {
|
||||
String mn = md.name();
|
||||
String formattedName;
|
||||
if (hasExportedAPIs(md)) {
|
||||
// has exported APIs
|
||||
formattedName = mn;
|
||||
} else if (!md.provides().isEmpty()) {
|
||||
// a provider
|
||||
formattedName = "<i>" + mn + "</i>";
|
||||
} else {
|
||||
// a tool
|
||||
formattedName = "<i>" + mn + "</i>";
|
||||
}
|
||||
return String.format("<a href=\"api/%s-summary.html\">%s</a>",
|
||||
mn, formattedName);
|
||||
}
|
||||
|
||||
String formatModuleGroup(String groupName) {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
// organize in Java SE, JDK, JavaFX, JCP groups
|
||||
Set<ModuleDescriptor> modules = moduleGroups.get(groupName);
|
||||
Arrays.stream(ModuleGroup.values())
|
||||
.forEach(g -> {
|
||||
Set<ModuleDescriptor> mods = modules.stream()
|
||||
.filter(md -> g.predicate.test(md.name()))
|
||||
.collect(toSet());
|
||||
if (!mods.isEmpty()) {
|
||||
sb.append("<div class=" + g.cssClass + ">\n");
|
||||
// modules with exported API
|
||||
mods.stream()
|
||||
.filter(this::hasExportedAPIs)
|
||||
.sorted(Comparator.comparing(ModuleDescriptor::name))
|
||||
.map(this::toHRef)
|
||||
.forEach(m -> sb.append(m).append("\n"));
|
||||
|
||||
// tools and providers
|
||||
mods.stream()
|
||||
.filter(md -> !hasExportedAPIs(md))
|
||||
.sorted(Comparator.comparing(ModuleDescriptor::name))
|
||||
.map(this::toHRef)
|
||||
.forEach(m -> sb.append(m).append("\n"));
|
||||
sb.append("</div>");
|
||||
}
|
||||
});
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
private boolean hasExportedAPIs(ModuleDescriptor md) {
|
||||
if (md.exports().stream().anyMatch(e -> !e.isQualified())) {
|
||||
return true;
|
||||
}
|
||||
// this should check if any indirect exports
|
||||
// checking requires transitive would be sufficient for JDK modules
|
||||
if (md.requires().stream()
|
||||
.map(ModuleDescriptor.Requires::modifiers)
|
||||
.anyMatch(mods -> mods.contains(ModuleDescriptor.Requires.Modifier.TRANSITIVE))) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private static final Set<String> NON_JAVA_SE_MODULES =
|
||||
Set.of("java.jnlp", "java.smartcardio");
|
||||
|
||||
/**
|
||||
* CSS class names are defined in docs-bundle-page.html
|
||||
*/
|
||||
enum ModuleGroup {
|
||||
JAVA_SE("javase", mn -> mn.startsWith("java.") && !NON_JAVA_SE_MODULES.contains(mn)),
|
||||
JDK("jdk", mn -> mn.startsWith("jdk.")),
|
||||
JAVAFX("javafx", mn -> mn.startsWith("javafx.")),
|
||||
NON_JAVA_SE("jcp", NON_JAVA_SE_MODULES::contains);
|
||||
|
||||
final String cssClass;
|
||||
final Predicate<String> predicate;
|
||||
ModuleGroup(String cssClass, Predicate<String> predicate) {
|
||||
this.cssClass = cssClass;
|
||||
this.predicate = predicate;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,171 +0,0 @@
|
|||
<!--
|
||||
Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
|
||||
DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
|
||||
This code is free software; you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License version 2 only, as
|
||||
published by the Free Software Foundation. Oracle designates this
|
||||
particular file as subject to the "Classpath" exception as provided
|
||||
by Oracle in the LICENSE file that accompanied this code.
|
||||
|
||||
This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
version 2 for more details (a copy is included in the LICENSE file that
|
||||
accompanied this code).
|
||||
|
||||
You should have received a copy of the GNU General Public License version
|
||||
2 along with this work; if not, write to the Free Software Foundation,
|
||||
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
|
||||
Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
or visit www.oracle.com if you need additional information or have any
|
||||
questions.
|
||||
-->
|
||||
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<title>@HEADER_TITLE@</title>
|
||||
|
||||
<meta http-equiv="content-type" content="text/html;" charset="utf-8">
|
||||
<link rel="stylesheet" href="resources/jdk-default.css" type="text/css" />
|
||||
<style type="text/css">
|
||||
|
||||
table a { text-decoration: none }
|
||||
table { border: none }
|
||||
th, td { border: 2px solid white; }
|
||||
thead th { background-color: #DDD }
|
||||
tbody th { background-color: #EEE }
|
||||
|
||||
table div.javase, ul.key span.javase { background-color: #C6E7F3 }
|
||||
table div.jdk, ul.key span.jdk { background-color: #ECE1C5 }
|
||||
table div.javafx, ul.key span.javafx { background-color: #ECEDCC }
|
||||
table div.jcp, ul.key span.jcp { background-color: #E9E9E9 }
|
||||
td div { padding: 3px 5px; color: blue }
|
||||
table tbody td div a { padding: 0 .5em; margin: 0: 1em; }
|
||||
table tbody td div a:link { color: black }
|
||||
table tbody td div a:visited { color: black }
|
||||
table tbody td div a[href]:hover { color: black; text-decoration: underline }
|
||||
td { padding: 0 }
|
||||
table tbody td div a { padding: 0 .5em; margin: 0: 1em }
|
||||
|
||||
.key { font-size: smaller; }
|
||||
ul.key li { display:inline-block; padding: 0 1em }
|
||||
ul.key span {
|
||||
border: 1px solid black;
|
||||
font-family: DejaVu Sans Mono, monospace;
|
||||
}
|
||||
ul.key span:before { content: " " }
|
||||
ul.key span:after { content: " " }
|
||||
|
||||
caption {
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
tr:nth-child(even), tr:nth-child(even) th[scope=row] {
|
||||
background-color: #EEE;
|
||||
}
|
||||
tr:nth-child(odd), tr:nth-child(odd) th[scope=row] {
|
||||
background-color: #EEE;
|
||||
}
|
||||
|
||||
</style>
|
||||
</head>
|
||||
|
||||
<h1>@HEADER_TITLE@</h1>
|
||||
|
||||
<ul>
|
||||
<li><a href="api/index.html">JDK API Specification</a></li>
|
||||
<li><a href="https://docs.oracle.com/javase/specs/">
|
||||
Java Language and Virtual Machine Specifications</a></li>
|
||||
<li><a href="https://www.oracle.com/pls/topic/lookup?ctx=javase9&id=tools_reference_overview">
|
||||
Tools Reference</a></li>
|
||||
</ul>
|
||||
|
||||
|
||||
<table>
|
||||
<caption style="display:none">JDK Modules</caption>
|
||||
<thead>
|
||||
<tr>
|
||||
<th scope="col">Group</th>
|
||||
<th scope="col">Modules</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<th scope="row">Foundation</th>
|
||||
<td>@JAVA_BASE@</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row">Integration</th>
|
||||
<td>@INTEGRATION_MODULES@</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row">User Interface</th>
|
||||
<td>@UI_MODULES@</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row">Compilation</th>
|
||||
<td>@COMPILER_MODULES@</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row">Scripting</th>
|
||||
<td>@SCRIPTING_MODULES@</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row">Security</th>
|
||||
<td>@SECURITY_MODULES@</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row">Management</th>
|
||||
<td>@MANAGEMENT_MODULES@</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row">Instrumentation</th>
|
||||
<td>@INSTRUMENT_MODULES@</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row">Serviceability</th>
|
||||
<td>@SVC_MODULES@</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row">Packaging</th>
|
||||
<td>@PACKAGING_MODULES@</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row">Incubator</th>
|
||||
<td>@INCUBATOR_MODULES@</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row">Non-Java SE</th>
|
||||
<td>@OTHER_MODULES@</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row">Java EE</th>
|
||||
<td>@JAVA_EE_MODULES@</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row">Aggregator</th>
|
||||
<td>@AGGREGATOR_MODULES@</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<p class="key">Key:
|
||||
<ul class="key">
|
||||
<li><span class="javase"> </span> Java SE
|
||||
<li><span class="jdk"> </span> JDK
|
||||
<li><span class="javafx"> </span> JavaFX
|
||||
<li><span class="jcp"> </span> Non-Java SE
|
||||
<li><i>italic</i> No Exported API (e.g. a tool or provider)</li>
|
||||
</ul>
|
||||
|
||||
<p>
|
||||
<hr>
|
||||
<a href="legal/cpyr.html">Copyright</a> © 1993, 2017, Oracle and/or its affiliates. All rights reserved.</p>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
||||
|
|
@ -1,114 +0,0 @@
|
|||
# Module Grouping for the docs bundle page
|
||||
#
|
||||
|
||||
java_base=\
|
||||
java.base
|
||||
|
||||
java_ee_modules=\
|
||||
java.activation \
|
||||
java.corba \
|
||||
java.transaction \
|
||||
java.xml.bind \
|
||||
java.xml.ws \
|
||||
java.xml.ws.annotation \
|
||||
jdk.xml.bind \
|
||||
jdk.xml.ws
|
||||
|
||||
aggregator_modules=\
|
||||
java.se \
|
||||
java.se.ee
|
||||
|
||||
security_modules=\
|
||||
java.security.jgss \
|
||||
java.security.sasl \
|
||||
java.xml.crypto \
|
||||
jdk.security.auth \
|
||||
jdk.security.jgss \
|
||||
jdk.crypto.cryptoki \
|
||||
jdk.crypto.ec \
|
||||
jdk.crypto.mscapi \
|
||||
jdk.crypto.ucrypto \
|
||||
jdk.policytool
|
||||
|
||||
instrument_modules=\
|
||||
java.instrument
|
||||
|
||||
management_modules=\
|
||||
java.management \
|
||||
java.management.rmi \
|
||||
jdk.management \
|
||||
jdk.management.agent \
|
||||
jdk.management.cmm \
|
||||
jdk.management.jfr \
|
||||
jdk.management.resource \
|
||||
jdk.snmp \
|
||||
jdk.jconsole
|
||||
|
||||
integration_modules=\
|
||||
java.logging \
|
||||
java.naming \
|
||||
java.prefs \
|
||||
java.rmi \
|
||||
java.sql \
|
||||
java.sql.rowset \
|
||||
java.xml \
|
||||
jdk.charsets \
|
||||
jdk.localedata \
|
||||
jdk.net \
|
||||
jdk.sctp \
|
||||
jdk.jsobject \
|
||||
jdk.httpserver \
|
||||
jdk.naming.dns \
|
||||
jdk.naming.rmi \
|
||||
jdk.xml.dom \
|
||||
jdk.zipfs
|
||||
|
||||
ui_modules=\
|
||||
java.datatransfer \
|
||||
java.desktop \
|
||||
javafx.base \
|
||||
javafx.controls \
|
||||
javafx.fxml \
|
||||
javafx.graphics \
|
||||
javafx.media \
|
||||
javafx.swing \
|
||||
javafx.web \
|
||||
jdk.accessibility
|
||||
|
||||
svc_modules=\
|
||||
jdk.jfr \
|
||||
jdk.attach \
|
||||
jdk.jcmd \
|
||||
jdk.jdi \
|
||||
jdk.jdwp.agent \
|
||||
jdk.jstatd \
|
||||
jdk.hotspot.agent
|
||||
|
||||
packaging_modules=\
|
||||
jdk.jartool \
|
||||
jdk.jlink \
|
||||
jdk.pack \
|
||||
jdk.packager.services
|
||||
|
||||
compiler_modules=\
|
||||
java.compiler \
|
||||
jdk.compiler \
|
||||
jdk.javadoc \
|
||||
jdk.jdeps \
|
||||
jdk.editpad \
|
||||
jdk.jshell \
|
||||
jdk.rmic
|
||||
|
||||
scripting_modules=\
|
||||
java.scripting \
|
||||
jdk.dynalink \
|
||||
jdk.scripting.nashorn \
|
||||
jdk.scripting.nashorn.shell
|
||||
|
||||
other_modules=\
|
||||
java.jnlp \
|
||||
java.smartcardio
|
||||
|
||||
incubator_modules=\
|
||||
jdk.incubator.httpclient
|
||||
|
File diff suppressed because it is too large
Load diff
|
@ -916,23 +916,28 @@ public class File
|
|||
* Returns the time that the file denoted by this abstract pathname was
|
||||
* last modified.
|
||||
*
|
||||
* @apiNote
|
||||
* While the unit of time of the return value is milliseconds, the
|
||||
* granularity of the value depends on the underlying file system and may
|
||||
* be larger. For example, some file systems use time stamps in units of
|
||||
* seconds.
|
||||
*
|
||||
* <p> Where it is required to distinguish an I/O exception from the case
|
||||
* where {@code 0L} is returned, or where several attributes of the
|
||||
* same file are required at the same time, or where the time of last
|
||||
* access or the creation time are required, then the {@link
|
||||
* java.nio.file.Files#readAttributes(Path,Class,LinkOption[])
|
||||
* Files.readAttributes} method may be used.
|
||||
*
|
||||
* @apiNote
|
||||
* While the unit of time of the return value is milliseconds,
|
||||
* the granularity of the value depends on the underlying
|
||||
* file system and may be larger. For example, some
|
||||
* file systems use time stamps in units of seconds.
|
||||
* Files.readAttributes} method may be used. If however only the
|
||||
* time of last modification is required, then the
|
||||
* {@link java.nio.file.Files#getLastModifiedTime(Path,LinkOption[])
|
||||
* Files.getLastModifiedTime} method may be used instead.
|
||||
*
|
||||
* @return A <code>long</code> value representing the time the file was
|
||||
* last modified, measured in milliseconds since the epoch
|
||||
* (00:00:00 GMT, January 1, 1970), or <code>0L</code> if the
|
||||
* file does not exist or if an I/O error occurs
|
||||
* file does not exist or if an I/O error occurs. The value may
|
||||
* be negative indicating the number of milliseconds before the
|
||||
* epoch
|
||||
*
|
||||
* @throws SecurityException
|
||||
* If a security manager exists and its {@link
|
||||
|
|
|
@ -50,6 +50,7 @@ import java.net.URL;
|
|||
import java.security.AccessController;
|
||||
import java.security.PrivilegedAction;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
|
@ -2066,25 +2067,6 @@ public final class Class<T> implements java.io.Serializable,
|
|||
return getReflectionFactory().copyMethod(method);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a {@code Method} object that reflects the specified public
|
||||
* member method of the class or interface represented by this
|
||||
* {@code Class} object.
|
||||
*
|
||||
* @param name the name of the method
|
||||
* @param parameterTypes the list of parameters
|
||||
* @return the {@code Method} object that matches the specified
|
||||
* {@code name} and {@code parameterTypes}; {@code null}
|
||||
* if the method is not found or the name is
|
||||
* "<init>"or "<clinit>".
|
||||
*/
|
||||
Method getMethodOrNull(String name, Class<?>... parameterTypes) {
|
||||
Objects.requireNonNull(name);
|
||||
Method method = getMethod0(name, parameterTypes);
|
||||
return method == null ? null : getReflectionFactory().copyMethod(method);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns a {@code Constructor} object that reflects the specified
|
||||
* public constructor of the class represented by this {@code Class}
|
||||
|
@ -2225,7 +2207,6 @@ public final class Class<T> implements java.io.Serializable,
|
|||
|
||||
|
||||
/**
|
||||
*
|
||||
* Returns an array containing {@code Method} objects reflecting all the
|
||||
* declared methods of the class or interface represented by this {@code
|
||||
* Class} object, including public, protected, default (package)
|
||||
|
@ -2453,6 +2434,30 @@ public final class Class<T> implements java.io.Serializable,
|
|||
return getReflectionFactory().copyMethod(method);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the list of {@code Method} objects for the declared public
|
||||
* methods of this class or interface that have the specified method name
|
||||
* and parameter types.
|
||||
*
|
||||
* @param name the name of the method
|
||||
* @param parameterTypes the parameter array
|
||||
* @return the list of {@code Method} objects for the public methods of
|
||||
* this class matching the specified name and parameters
|
||||
*/
|
||||
List<Method> getDeclaredPublicMethods(String name, Class<?>... parameterTypes) {
|
||||
Method[] methods = privateGetDeclaredMethods(/* publicOnly */ true);
|
||||
ReflectionFactory factory = getReflectionFactory();
|
||||
List<Method> result = new ArrayList<>();
|
||||
for (Method method : methods) {
|
||||
if (method.getName().equals(name)
|
||||
&& Arrays.equals(
|
||||
factory.getExecutableSharedParameterTypes(method),
|
||||
parameterTypes)) {
|
||||
result.add(factory.copyMethod(method));
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a {@code Constructor} object that reflects the specified
|
||||
|
|
|
@ -93,12 +93,20 @@ import sun.security.util.SecurityConstants;
|
|||
* <p> Class loaders may typically be used by security managers to indicate
|
||||
* security domains.
|
||||
*
|
||||
* <p> In addition to loading classes, a class loader is also responsible for
|
||||
* locating resources. A resource is some data (a "{@code .class}" file,
|
||||
* configuration data, or an image for example) that is identified with an
|
||||
* abstract '/'-separated path name. Resources are typically packaged with an
|
||||
* application or library so that they can be located by code in the
|
||||
* application or library. In some cases, the resources are included so that
|
||||
* they can be located by other libraries.
|
||||
*
|
||||
* <p> The {@code ClassLoader} class uses a delegation model to search for
|
||||
* classes and resources. Each instance of {@code ClassLoader} has an
|
||||
* associated parent class loader. When requested to find a class or
|
||||
* resource, a {@code ClassLoader} instance will delegate the search for the
|
||||
* class or resource to its parent class loader before attempting to find the
|
||||
* class or resource itself.
|
||||
* associated parent class loader. When requested to find a class or
|
||||
* resource, a {@code ClassLoader} instance will usually delegate the search
|
||||
* for the class or resource to its parent class loader before attempting to
|
||||
* find the class or resource itself.
|
||||
*
|
||||
* <p> Class loaders that support concurrent loading of classes are known as
|
||||
* <em>{@linkplain #isRegisteredAsParallelCapable() parallel capable}</em> class
|
||||
|
@ -129,11 +137,13 @@ import sun.security.util.SecurityConstants;
|
|||
* classes and JDK-specific run-time classes that are defined by the
|
||||
* platform class loader or its ancestors.
|
||||
* <p> To allow for upgrading/overriding of modules defined to the platform
|
||||
* class loader, and where classes in the upgraded version link to
|
||||
* classes in modules defined to the application class loader, the
|
||||
* platform class loader may delegate to the application class loader.
|
||||
* In other words, classes in named modules defined to the application
|
||||
* class loader may be visible to the platform class loader. </li>
|
||||
* class loader, and where upgraded modules read modules defined to class
|
||||
* loaders other than the platform class loader and its ancestors, then
|
||||
* the platform class loader may have to delegate to other class loaders,
|
||||
* the application class loader for example.
|
||||
* In other words, classes in named modules defined to class loaders
|
||||
* other than the platform class loader and its ancestors may be visible
|
||||
* to the platform class loader. </li>
|
||||
* <li><p>{@linkplain #getSystemClassLoader() System class loader}.
|
||||
* It is also known as <em>application class loader</em> and is distinct
|
||||
* from the platform class loader.
|
||||
|
@ -498,7 +508,7 @@ public abstract class ClassLoader {
|
|||
*
|
||||
* <li><p> Invoke the {@link #loadClass(String) loadClass} method
|
||||
* on the parent class loader. If the parent is {@code null} the class
|
||||
* loader built-in to the virtual machine is used, instead. </p></li>
|
||||
* loader built into the virtual machine is used, instead. </p></li>
|
||||
*
|
||||
* <li><p> Invoke the {@link #findClass(String)} method to find the
|
||||
* class. </p></li>
|
||||
|
@ -681,8 +691,9 @@ public abstract class ClassLoader {
|
|||
* This method should be overridden by class loader implementations that
|
||||
* follow the delegation model for loading classes, and will be invoked by
|
||||
* the {@link #loadClass loadClass} method after checking the
|
||||
* parent class loader for the requested class. The default implementation
|
||||
* throws a {@code ClassNotFoundException}.
|
||||
* parent class loader for the requested class.
|
||||
*
|
||||
* @implSpec The default implementation throws {@code ClassNotFoundException}.
|
||||
*
|
||||
* @param name
|
||||
* The <a href="#name">binary name</a> of the class
|
||||
|
@ -1127,8 +1138,9 @@ public abstract class ClassLoader {
|
|||
putIfAbsent(pname, (certs == null? nocerts:certs));
|
||||
}
|
||||
if (pcerts != null && !compareCerts(pcerts, certs)) {
|
||||
throw new SecurityException("class \""+ name +
|
||||
"\"'s signer information does not match signer information of other classes in the same package");
|
||||
throw new SecurityException("class \"" + name
|
||||
+ "\"'s signer information does not match signer information"
|
||||
+ " of other classes in the same package");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1329,12 +1341,7 @@ public abstract class ClassLoader {
|
|||
* that is independent of the location of the code.
|
||||
*
|
||||
* <p> The name of a resource is a '{@code /}'-separated path name that
|
||||
* identifies the resource.
|
||||
*
|
||||
* <p> This method will first search the parent class loader for the
|
||||
* resource; if the parent is {@code null} the path of the class loader
|
||||
* built-in to the virtual machine is searched. That failing, this method
|
||||
* will invoke {@link #findResource(String)} to find the resource. </p>
|
||||
* identifies the resource. </p>
|
||||
*
|
||||
* <p> Resources in named modules are subject to the encapsulation rules
|
||||
* specified by {@link Module#getResourceAsStream Module.getResourceAsStream}.
|
||||
|
@ -1344,6 +1351,11 @@ public abstract class ClassLoader {
|
|||
* opened} unconditionally (even if the caller of this method is in the
|
||||
* same module as the resource). </p>
|
||||
*
|
||||
* @implSpec The default implementation will first search the parent class
|
||||
* loader for the resource; if the parent is {@code null} the path of the
|
||||
* class loader built into the virtual machine is searched. If not found,
|
||||
* this method will invoke {@link #findResource(String)} to find the resource.
|
||||
*
|
||||
* @apiNote Where several modules are defined to the same class loader,
|
||||
* and where more than one module contains a resource with the given name,
|
||||
* then the ordering that modules are searched is not specified and may be
|
||||
|
@ -1387,10 +1399,7 @@ public abstract class ClassLoader {
|
|||
* that is independent of the location of the code.
|
||||
*
|
||||
* <p> The name of a resource is a {@code /}-separated path name that
|
||||
* identifies the resource.
|
||||
*
|
||||
* <p> The delegation order for searching is described in the documentation
|
||||
* for {@link #getResource(String)}. </p>
|
||||
* identifies the resource. </p>
|
||||
*
|
||||
* <p> Resources in named modules are subject to the encapsulation rules
|
||||
* specified by {@link Module#getResourceAsStream Module.getResourceAsStream}.
|
||||
|
@ -1398,7 +1407,15 @@ public abstract class ClassLoader {
|
|||
* name ending with "{@code .class}", this method will only find resources in
|
||||
* packages of named modules when the package is {@link Module#isOpen(String)
|
||||
* opened} unconditionally (even if the caller of this method is in the
|
||||
* same module as the resource).</p>
|
||||
* same module as the resource). </p>
|
||||
*
|
||||
* @implSpec The default implementation will first search the parent class
|
||||
* loader for the resource; if the parent is {@code null} the path of the
|
||||
* class loader built into the virtual machine is searched. It then
|
||||
* invokes {@link #findResources(String)} to find the resources with the
|
||||
* name in this class loader. It returns an enumeration whose elements
|
||||
* are the URLs found by searching the parent class loader followed by
|
||||
* the elements found with {@code findResources}.
|
||||
*
|
||||
* @apiNote Where several modules are defined to the same class loader,
|
||||
* and where more than one module contains a resource with the given name,
|
||||
|
@ -1424,8 +1441,6 @@ public abstract class ClassLoader {
|
|||
* If I/O errors occur
|
||||
* @throws NullPointerException If {@code name} is {@code null}
|
||||
*
|
||||
* @see #findResources(String)
|
||||
*
|
||||
* @since 1.2
|
||||
* @revised 9
|
||||
* @spec JPMS
|
||||
|
@ -1453,9 +1468,6 @@ public abstract class ClassLoader {
|
|||
* <p> The name of a resource is a {@code /}-separated path name that
|
||||
* identifies the resource.
|
||||
*
|
||||
* <p> The search order is described in the documentation for {@link
|
||||
* #getResource(String)}.
|
||||
*
|
||||
* <p> The resources will be located when the returned stream is evaluated.
|
||||
* If the evaluation results in an {@code IOException} then the I/O
|
||||
* exception is wrapped in an {@link UncheckedIOException} that is then
|
||||
|
@ -1469,6 +1481,10 @@ public abstract class ClassLoader {
|
|||
* opened} unconditionally (even if the caller of this method is in the
|
||||
* same module as the resource). </p>
|
||||
*
|
||||
* @implSpec The default implementation invokes {@link #getResources(String)
|
||||
* getResources} to find all the resources with the given name and returns
|
||||
* a stream with the elements in the enumeration as the source.
|
||||
*
|
||||
* @apiNote When overriding this method it is recommended that an
|
||||
* implementation ensures that any delegation is consistent with the {@link
|
||||
* #getResource(java.lang.String) getResource(String)} method. This should
|
||||
|
@ -1486,8 +1502,6 @@ public abstract class ClassLoader {
|
|||
*
|
||||
* @throws NullPointerException If {@code name} is {@code null}
|
||||
*
|
||||
* @see #findResources(String)
|
||||
*
|
||||
* @since 9
|
||||
*/
|
||||
public Stream<URL> resources(String name) {
|
||||
|
@ -1506,7 +1520,7 @@ public abstract class ClassLoader {
|
|||
|
||||
/**
|
||||
* Finds the resource with the given name. Class loader implementations
|
||||
* should override this method to specify where to find resources.
|
||||
* should override this method.
|
||||
*
|
||||
* <p> For resources in named modules then the method must implement the
|
||||
* rules for encapsulation specified in the {@code Module} {@link
|
||||
|
@ -1515,6 +1529,8 @@ public abstract class ClassLoader {
|
|||
* modules unless the package is {@link Module#isOpen(String) opened}
|
||||
* unconditionally. </p>
|
||||
*
|
||||
* @implSpec The default implementation returns {@code null}.
|
||||
*
|
||||
* @param name
|
||||
* The resource name
|
||||
*
|
||||
|
@ -1535,8 +1551,7 @@ public abstract class ClassLoader {
|
|||
/**
|
||||
* Returns an enumeration of {@link java.net.URL URL} objects
|
||||
* representing all the resources with the given name. Class loader
|
||||
* implementations should override this method to specify where to load
|
||||
* resources from.
|
||||
* implementations should override this method.
|
||||
*
|
||||
* <p> For resources in named modules then the method must implement the
|
||||
* rules for encapsulation specified in the {@code Module} {@link
|
||||
|
@ -1545,6 +1560,9 @@ public abstract class ClassLoader {
|
|||
* modules unless the package is {@link Module#isOpen(String) opened}
|
||||
* unconditionally. </p>
|
||||
*
|
||||
* @implSpec The default implementation returns an enumeration that
|
||||
* contains no elements.
|
||||
*
|
||||
* @param name
|
||||
* The resource name
|
||||
*
|
||||
|
@ -1899,7 +1917,8 @@ public abstract class ClassLoader {
|
|||
// the system class loader is the built-in app class loader during startup
|
||||
return getBuiltinAppClassLoader();
|
||||
case 3:
|
||||
throw new InternalError("getSystemClassLoader should only be called after VM booted");
|
||||
String msg = "getSystemClassLoader should only be called after VM booted";
|
||||
throw new InternalError(msg);
|
||||
case 4:
|
||||
// system fully initialized
|
||||
assert VM.isBooted() && scl != null;
|
||||
|
@ -2146,7 +2165,7 @@ public abstract class ClassLoader {
|
|||
* @revised 9
|
||||
* @spec JPMS
|
||||
*
|
||||
* @see <a href="../../../technotes/guides/jar/jar.html#sealing">
|
||||
* @see <a href="{@docRoot}/../specs/jar/jar.html#sealing">
|
||||
* The JAR File Specification: Package Sealing</a>
|
||||
*/
|
||||
protected Package definePackage(String name, String specTitle,
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 1998, 2016, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1998, 2017, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
|
@ -116,6 +116,10 @@ class FdLibm {
|
|||
private static final double F = 0x1.9b6db6db6db6ep0; // 45/28 ~= 1.60714285714285720630e+00
|
||||
private static final double G = 0x1.6db6db6db6db7p-2; // 5/14 ~= 3.57142857142857150787e-01
|
||||
|
||||
private Cbrt() {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
public static strictfp double compute(double x) {
|
||||
double t = 0.0;
|
||||
double sign;
|
||||
|
@ -195,6 +199,10 @@ class FdLibm {
|
|||
public static final double TWO_MINUS_600 = 0x1.0p-600;
|
||||
public static final double TWO_PLUS_600 = 0x1.0p+600;
|
||||
|
||||
private Hypot() {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
public static strictfp double compute(double x, double y) {
|
||||
double a = Math.abs(x);
|
||||
double b = Math.abs(y);
|
||||
|
@ -331,6 +339,10 @@ class FdLibm {
|
|||
* representable.
|
||||
*/
|
||||
public static class Pow {
|
||||
private Pow() {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
public static strictfp double compute(final double x, final double y) {
|
||||
double z;
|
||||
double r, s, t, u, v, w;
|
||||
|
@ -664,6 +676,10 @@ class FdLibm {
|
|||
private static final double P4 = -0x1.bbd41c5d26bf1p-20; // -1.65339022054652515390e-06
|
||||
private static final double P5 = 0x1.6376972bea4d0p-25; // 4.13813679705723846039e-08
|
||||
|
||||
private Exp() {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
// should be able to forgo strictfp due to controlled over/underflow
|
||||
public static strictfp double compute(double x) {
|
||||
double y;
|
||||
|
|
|
@ -63,8 +63,8 @@ public class LayerInstantiationException extends RuntimeException {
|
|||
}
|
||||
|
||||
/**
|
||||
* Constructs a {@code FindException} with the given detail message
|
||||
* and cause.
|
||||
* Constructs a {@code LayerInstantiationException} with the given detail
|
||||
* message and cause.
|
||||
*
|
||||
* @param msg
|
||||
* The detail message; can be {@code null}
|
||||
|
@ -74,6 +74,5 @@ public class LayerInstantiationException extends RuntimeException {
|
|||
public LayerInstantiationException(String msg, Throwable cause) {
|
||||
super(msg, cause);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -43,6 +43,7 @@ import java.security.PrivilegedAction;
|
|||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
|
@ -55,8 +56,10 @@ import java.util.stream.Stream;
|
|||
|
||||
import jdk.internal.loader.BuiltinClassLoader;
|
||||
import jdk.internal.loader.BootLoader;
|
||||
import jdk.internal.loader.ClassLoaders;
|
||||
import jdk.internal.misc.JavaLangAccess;
|
||||
import jdk.internal.misc.SharedSecrets;
|
||||
import jdk.internal.module.IllegalAccessLogger;
|
||||
import jdk.internal.module.ModuleLoaderMap;
|
||||
import jdk.internal.module.ServicesCatalog;
|
||||
import jdk.internal.module.Resources;
|
||||
|
@ -162,7 +165,6 @@ public final class Module implements AnnotatedElement {
|
|||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Returns {@code true} if this module is a named module.
|
||||
*
|
||||
|
@ -249,12 +251,10 @@ public final class Module implements AnnotatedElement {
|
|||
|
||||
// special Module to mean "all unnamed modules"
|
||||
private static final Module ALL_UNNAMED_MODULE = new Module(null);
|
||||
private static final Set<Module> ALL_UNNAMED_MODULE_SET = Set.of(ALL_UNNAMED_MODULE);
|
||||
|
||||
// special Module to mean "everyone"
|
||||
private static final Module EVERYONE_MODULE = new Module(null);
|
||||
|
||||
// set contains EVERYONE_MODULE, used when a package is opened or
|
||||
// exported unconditionally
|
||||
private static final Set<Module> EVERYONE_SET = Set.of(EVERYONE_MODULE);
|
||||
|
||||
|
||||
|
@ -534,12 +534,12 @@ public final class Module implements AnnotatedElement {
|
|||
return true;
|
||||
|
||||
// all packages are exported/open to self
|
||||
if (other == this && containsPackage(pn))
|
||||
if (other == this && descriptor.packages().contains(pn))
|
||||
return true;
|
||||
|
||||
// all packages in open and automatic modules are open
|
||||
if (descriptor.isOpen() || descriptor.isAutomatic())
|
||||
return containsPackage(pn);
|
||||
return descriptor.packages().contains(pn);
|
||||
|
||||
// exported/opened via module declaration/descriptor
|
||||
if (isStaticallyExportedOrOpen(pn, other, open))
|
||||
|
@ -555,42 +555,48 @@ public final class Module implements AnnotatedElement {
|
|||
|
||||
/**
|
||||
* Returns {@code true} if this module exports or opens a package to
|
||||
* the given module via its module declaration.
|
||||
* the given module via its module declaration or CLI options.
|
||||
*/
|
||||
private boolean isStaticallyExportedOrOpen(String pn, Module other, boolean open) {
|
||||
// package is open to everyone or <other>
|
||||
// test if package is open to everyone or <other>
|
||||
Map<String, Set<Module>> openPackages = this.openPackages;
|
||||
if (openPackages != null) {
|
||||
Set<Module> targets = openPackages.get(pn);
|
||||
if (targets != null) {
|
||||
if (targets.contains(EVERYONE_MODULE))
|
||||
return true;
|
||||
if (other != EVERYONE_MODULE && targets.contains(other))
|
||||
return true;
|
||||
}
|
||||
if (openPackages != null && allows(openPackages.get(pn), other)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!open) {
|
||||
// package is exported to everyone or <other>
|
||||
// test package is exported to everyone or <other>
|
||||
Map<String, Set<Module>> exportedPackages = this.exportedPackages;
|
||||
if (exportedPackages != null) {
|
||||
Set<Module> targets = exportedPackages.get(pn);
|
||||
if (targets != null) {
|
||||
if (targets.contains(EVERYONE_MODULE))
|
||||
return true;
|
||||
if (other != EVERYONE_MODULE && targets.contains(other))
|
||||
return true;
|
||||
}
|
||||
if (exportedPackages != null && allows(exportedPackages.get(pn), other)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns {@code true} if targets is non-null and contains EVERYONE_MODULE
|
||||
* or the given module. Also returns true if the given module is an unnamed
|
||||
* module and targets contains ALL_UNNAMED_MODULE.
|
||||
*/
|
||||
private boolean allows(Set<Module> targets, Module module) {
|
||||
if (targets != null) {
|
||||
if (targets.contains(EVERYONE_MODULE))
|
||||
return true;
|
||||
if (module != EVERYONE_MODULE) {
|
||||
if (targets.contains(module))
|
||||
return true;
|
||||
if (!module.isNamed() && targets.contains(ALL_UNNAMED_MODULE))
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns {@code true} if this module reflectively exports or opens given
|
||||
* package package to the given module.
|
||||
* Returns {@code true} if this module reflectively exports or opens the
|
||||
* given package to the given module.
|
||||
*/
|
||||
private boolean isReflectivelyExportedOrOpen(String pn, Module other, boolean open) {
|
||||
// exported or open to all modules
|
||||
|
@ -632,6 +638,22 @@ public final class Module implements AnnotatedElement {
|
|||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns {@code true} if this module reflectively exports the
|
||||
* given package to the given module.
|
||||
*/
|
||||
boolean isReflectivelyExported(String pn, Module other) {
|
||||
return isReflectivelyExportedOrOpen(pn, other, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns {@code true} if this module reflectively opens the
|
||||
* given package to the given module.
|
||||
*/
|
||||
boolean isReflectivelyOpened(String pn, Module other) {
|
||||
return isReflectivelyExportedOrOpen(pn, other, true);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* If the caller's module is this module then update this module to export
|
||||
|
@ -800,7 +822,7 @@ public final class Module implements AnnotatedElement {
|
|||
}
|
||||
|
||||
/**
|
||||
* Updates this module to export a package to all unnamed modules.
|
||||
* Updates this module to open a package to all unnamed modules.
|
||||
*
|
||||
* @apiNote Used by the --add-opens command line option.
|
||||
*/
|
||||
|
@ -808,7 +830,6 @@ public final class Module implements AnnotatedElement {
|
|||
implAddExportsOrOpens(pn, Module.ALL_UNNAMED_MODULE, true, true);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Updates a module to export or open a module to another module.
|
||||
*
|
||||
|
@ -825,12 +846,31 @@ public final class Module implements AnnotatedElement {
|
|||
if (!isNamed() || descriptor.isOpen() || descriptor.isAutomatic())
|
||||
return;
|
||||
|
||||
// nothing to do if already exported/open to other
|
||||
if (implIsExportedOrOpen(pn, other, open))
|
||||
return;
|
||||
// check if the package is already exported/open to other
|
||||
if (implIsExportedOrOpen(pn, other, open)) {
|
||||
|
||||
// if the package is exported/open for illegal access then we need
|
||||
// to record that it has also been exported/opened reflectively so
|
||||
// that the IllegalAccessLogger doesn't emit a warning.
|
||||
boolean needToAdd = false;
|
||||
if (!other.isNamed()) {
|
||||
IllegalAccessLogger l = IllegalAccessLogger.illegalAccessLogger();
|
||||
if (l != null) {
|
||||
if (open) {
|
||||
needToAdd = l.isOpenForIllegalAccess(this, pn);
|
||||
} else {
|
||||
needToAdd = l.isExportedForIllegalAccess(this, pn);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!needToAdd) {
|
||||
// nothing to do
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// can only export a package in the module
|
||||
if (!containsPackage(pn)) {
|
||||
if (!descriptor.packages().contains(pn)) {
|
||||
throw new IllegalArgumentException("package " + pn
|
||||
+ " not in contents");
|
||||
}
|
||||
|
@ -850,7 +890,6 @@ public final class Module implements AnnotatedElement {
|
|||
Map<String, Boolean> map = reflectivelyExports
|
||||
.computeIfAbsent(this, other,
|
||||
(m1, m2) -> new ConcurrentHashMap<>());
|
||||
|
||||
if (open) {
|
||||
map.put(pn, Boolean.TRUE); // may need to promote from FALSE to TRUE
|
||||
} else {
|
||||
|
@ -858,6 +897,38 @@ public final class Module implements AnnotatedElement {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates a module to open all packages returned by the given iterator to
|
||||
* all unnamed modules.
|
||||
*
|
||||
* @apiNote Used during startup to open packages for illegal access.
|
||||
*/
|
||||
void implAddOpensToAllUnnamed(Iterator<String> iterator) {
|
||||
if (jdk.internal.misc.VM.isModuleSystemInited()) {
|
||||
throw new IllegalStateException("Module system already initialized");
|
||||
}
|
||||
|
||||
// replace this module's openPackages map with a new map that opens
|
||||
// the packages to all unnamed modules.
|
||||
Map<String, Set<Module>> openPackages = this.openPackages;
|
||||
if (openPackages == null) {
|
||||
openPackages = new HashMap<>();
|
||||
} else {
|
||||
openPackages = new HashMap<>(openPackages);
|
||||
}
|
||||
while (iterator.hasNext()) {
|
||||
String pn = iterator.next();
|
||||
Set<Module> prev = openPackages.putIfAbsent(pn, ALL_UNNAMED_MODULE_SET);
|
||||
if (prev != null) {
|
||||
prev.add(ALL_UNNAMED_MODULE);
|
||||
}
|
||||
|
||||
// update VM to export the package
|
||||
addExportsToAllUnnamed0(this, pn);
|
||||
}
|
||||
this.openPackages = openPackages;
|
||||
}
|
||||
|
||||
|
||||
// -- services --
|
||||
|
||||
|
@ -947,19 +1018,6 @@ public final class Module implements AnnotatedElement {
|
|||
|
||||
// -- packages --
|
||||
|
||||
// Additional packages that are added to the module at run-time.
|
||||
private volatile Map<String, Boolean> extraPackages;
|
||||
|
||||
private boolean containsPackage(String pn) {
|
||||
if (descriptor.packages().contains(pn))
|
||||
return true;
|
||||
Map<String, Boolean> extraPackages = this.extraPackages;
|
||||
if (extraPackages != null && extraPackages.containsKey(pn))
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns the set of package names for the packages in this module.
|
||||
*
|
||||
|
@ -974,89 +1032,19 @@ public final class Module implements AnnotatedElement {
|
|||
*/
|
||||
public Set<String> getPackages() {
|
||||
if (isNamed()) {
|
||||
|
||||
Set<String> packages = descriptor.packages();
|
||||
Map<String, Boolean> extraPackages = this.extraPackages;
|
||||
if (extraPackages == null) {
|
||||
return packages;
|
||||
} else {
|
||||
return Stream.concat(packages.stream(),
|
||||
extraPackages.keySet().stream())
|
||||
.collect(Collectors.toSet());
|
||||
}
|
||||
|
||||
return descriptor.packages();
|
||||
} else {
|
||||
// unnamed module
|
||||
Stream<Package> packages;
|
||||
if (loader == null) {
|
||||
packages = BootLoader.packages();
|
||||
} else {
|
||||
packages = SharedSecrets.getJavaLangAccess().packages(loader);
|
||||
packages = loader.packages();
|
||||
}
|
||||
return packages.map(Package::getName).collect(Collectors.toSet());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a package to this module without notifying the VM.
|
||||
*
|
||||
* @apiNote This method is VM white-box testing.
|
||||
*/
|
||||
void implAddPackageNoSync(String pn) {
|
||||
implAddPackage(pn.replace('/', '.'), false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a package to this module.
|
||||
*
|
||||
* If {@code syncVM} is {@code true} then the VM is notified. This method is
|
||||
* a no-op if this is an unnamed module or the module already contains the
|
||||
* package.
|
||||
*
|
||||
* @throws IllegalArgumentException if the package name is not legal
|
||||
* @throws IllegalStateException if the package is defined to another module
|
||||
*/
|
||||
private void implAddPackage(String pn, boolean syncVM) {
|
||||
// no-op if unnamed module
|
||||
if (!isNamed())
|
||||
return;
|
||||
|
||||
// no-op if module contains the package
|
||||
if (containsPackage(pn))
|
||||
return;
|
||||
|
||||
// check package name is legal for named modules
|
||||
if (pn.isEmpty())
|
||||
throw new IllegalArgumentException("Cannot add <unnamed> package");
|
||||
for (int i=0; i<pn.length(); i++) {
|
||||
char c = pn.charAt(i);
|
||||
if (c == '/' || c == ';' || c == '[') {
|
||||
throw new IllegalArgumentException("Illegal character: " + c);
|
||||
}
|
||||
}
|
||||
|
||||
// create extraPackages if needed
|
||||
Map<String, Boolean> extraPackages = this.extraPackages;
|
||||
if (extraPackages == null) {
|
||||
synchronized (this) {
|
||||
extraPackages = this.extraPackages;
|
||||
if (extraPackages == null)
|
||||
this.extraPackages = extraPackages = new ConcurrentHashMap<>();
|
||||
}
|
||||
}
|
||||
|
||||
// update VM first in case it fails. This is a no-op if another thread
|
||||
// beats us to add the package first
|
||||
if (syncVM) {
|
||||
// throws IllegalStateException if defined to another module
|
||||
addPackage0(this, pn);
|
||||
if (descriptor.isOpen() || descriptor.isAutomatic()) {
|
||||
addExportsToAll0(this, pn);
|
||||
}
|
||||
}
|
||||
extraPackages.putIfAbsent(pn, Boolean.TRUE);
|
||||
}
|
||||
|
||||
|
||||
// -- creating Module objects --
|
||||
|
||||
|
@ -1075,18 +1063,22 @@ public final class Module implements AnnotatedElement {
|
|||
Map<String, Module> nameToModule = new HashMap<>();
|
||||
Map<String, ClassLoader> moduleToLoader = new HashMap<>();
|
||||
|
||||
boolean isBootLayer = (ModuleLayer.boot() == null);
|
||||
Set<ClassLoader> loaders = new HashSet<>();
|
||||
boolean hasPlatformModules = false;
|
||||
|
||||
// map each module to a class loader
|
||||
for (ResolvedModule resolvedModule : cf.modules()) {
|
||||
String name = resolvedModule.name();
|
||||
ClassLoader loader = clf.apply(name);
|
||||
if (loader != null) {
|
||||
moduleToLoader.put(name, loader);
|
||||
moduleToLoader.put(name, loader);
|
||||
if (loader == null || loader == ClassLoaders.platformClassLoader()) {
|
||||
if (!(clf instanceof ModuleLoaderMap.Mapper)) {
|
||||
throw new IllegalArgumentException("loader can't be 'null'"
|
||||
+ " or the platform class loader");
|
||||
}
|
||||
hasPlatformModules = true;
|
||||
} else {
|
||||
loaders.add(loader);
|
||||
} else if (!(clf instanceof ModuleLoaderMap.Mapper)) {
|
||||
throw new IllegalArgumentException("loader can't be 'null'");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1098,7 +1090,7 @@ public final class Module implements AnnotatedElement {
|
|||
URI uri = mref.location().orElse(null);
|
||||
ClassLoader loader = moduleToLoader.get(resolvedModule.name());
|
||||
Module m;
|
||||
if (loader == null && isBootLayer && name.equals("java.base")) {
|
||||
if (loader == null && name.equals("java.base")) {
|
||||
// java.base is already defined to the VM
|
||||
m = Object.class.getModule();
|
||||
} else {
|
||||
|
@ -1157,8 +1149,12 @@ public final class Module implements AnnotatedElement {
|
|||
initExportsAndOpens(m, nameToSource, nameToModule, layer.parents());
|
||||
}
|
||||
|
||||
// register the modules in the boot layer
|
||||
if (isBootLayer) {
|
||||
// if there are modules defined to the boot or platform class loaders
|
||||
// then register the modules in the class loader's services catalog
|
||||
if (hasPlatformModules) {
|
||||
ClassLoader pcl = ClassLoaders.platformClassLoader();
|
||||
ServicesCatalog bootCatalog = BootLoader.getServicesCatalog();
|
||||
ServicesCatalog pclCatalog = ServicesCatalog.getServicesCatalog(pcl);
|
||||
for (ResolvedModule resolvedModule : cf.modules()) {
|
||||
ModuleReference mref = resolvedModule.reference();
|
||||
ModuleDescriptor descriptor = mref.descriptor();
|
||||
|
@ -1166,13 +1162,11 @@ public final class Module implements AnnotatedElement {
|
|||
String name = descriptor.name();
|
||||
Module m = nameToModule.get(name);
|
||||
ClassLoader loader = moduleToLoader.get(name);
|
||||
ServicesCatalog catalog;
|
||||
if (loader == null) {
|
||||
catalog = BootLoader.getServicesCatalog();
|
||||
} else {
|
||||
catalog = ServicesCatalog.getServicesCatalog(loader);
|
||||
bootCatalog.register(m);
|
||||
} else if (loader == pcl) {
|
||||
pclCatalog.register(m);
|
||||
}
|
||||
catalog.register(m);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1587,7 +1581,4 @@ public final class Module implements AnnotatedElement {
|
|||
|
||||
// JVM_AddModuleExportsToAllUnnamed
|
||||
private static native void addExportsToAllUnnamed0(Module from, String pn);
|
||||
|
||||
// JVM_AddModulePackage
|
||||
private static native void addPackage0(Module m, String pn);
|
||||
}
|
||||
|
|
|
@ -244,6 +244,32 @@ public final class ModuleLayer {
|
|||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates module {@code source} in the layer to export a package to
|
||||
* module {@code target}. This method is a no-op if {@code source}
|
||||
* already exports the package to at least {@code target}.
|
||||
*
|
||||
* @param source
|
||||
* The source module
|
||||
* @param pn
|
||||
* The package name
|
||||
* @param target
|
||||
* The target module
|
||||
*
|
||||
* @return This controller
|
||||
*
|
||||
* @throws IllegalArgumentException
|
||||
* If {@code source} is not in the module layer or the package
|
||||
* is not in the source module
|
||||
*
|
||||
* @see Module#addExports
|
||||
*/
|
||||
public Controller addExports(Module source, String pn, Module target) {
|
||||
ensureInLayer(source);
|
||||
source.implAddExports(pn, target);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates module {@code source} in the layer to open a package to
|
||||
* module {@code target}. This method is a no-op if {@code source}
|
||||
|
@ -254,7 +280,7 @@ public final class ModuleLayer {
|
|||
* @param pn
|
||||
* The package name
|
||||
* @param target
|
||||
* The target module to read
|
||||
* The target module
|
||||
*
|
||||
* @return This controller
|
||||
*
|
||||
|
@ -397,7 +423,7 @@ public final class ModuleLayer {
|
|||
* class loader and defines all modules to that class loader.
|
||||
*
|
||||
* <p> The class loader created by this method implements <em>direct
|
||||
* delegation</em> when loading types from modules. When its {@link
|
||||
* delegation</em> when loading classes from modules. If the {@link
|
||||
* ClassLoader#loadClass(String, boolean) loadClass} method is invoked to
|
||||
* load a class then it uses the package name of the class to map it to a
|
||||
* module. This may be a module in this layer and hence defined to the same
|
||||
|
@ -408,6 +434,12 @@ public final class ModuleLayer {
|
|||
* When {@code loadClass} is invoked to load classes that do not map to a
|
||||
* module then it delegates to the parent class loader. </p>
|
||||
*
|
||||
* <p> The class loader created by this method locates resources
|
||||
* ({@link ClassLoader#getResource(String) getResource}, {@link
|
||||
* ClassLoader#getResources(String) getResources}, and other resource
|
||||
* methods) in all modules in the layer before searching the parent class
|
||||
* loader. </p>
|
||||
*
|
||||
* <p> Attempting to create a layer with all modules defined to the same
|
||||
* class loader can fail for the following reasons:
|
||||
*
|
||||
|
@ -417,8 +449,8 @@ public final class ModuleLayer {
|
|||
* configuration have the same package. </p></li>
|
||||
*
|
||||
* <li><p> <em>Split delegation</em>: The resulting class loader would
|
||||
* need to delegate to more than one class loader in order to load types
|
||||
* in a specific package. </p></li>
|
||||
* need to delegate to more than one class loader in order to load
|
||||
* classes in a specific package. </p></li>
|
||||
*
|
||||
* </ul>
|
||||
*
|
||||
|
@ -481,7 +513,7 @@ public final class ModuleLayer {
|
|||
* class loader.
|
||||
*
|
||||
* <p> The class loaders created by this method implement <em>direct
|
||||
* delegation</em> when loading types from modules. When {@link
|
||||
* delegation</em> when loading classes from modules. If the {@link
|
||||
* ClassLoader#loadClass(String, boolean) loadClass} method is invoked to
|
||||
* load a class then it uses the package name of the class to map it to a
|
||||
* module. The package may be in the module defined to the class loader.
|
||||
|
@ -489,9 +521,15 @@ public final class ModuleLayer {
|
|||
* module defined to the class loader. It may be in a package exported by a
|
||||
* module in a parent layer. The class loader delegates to the class loader
|
||||
* of the module, throwing {@code ClassNotFoundException} if not found by
|
||||
* that class loader.
|
||||
* When {@code loadClass} is invoked to load classes that do not map to a
|
||||
* module then it delegates to the parent class loader. </p>
|
||||
* that class loader. When {@code loadClass} is invoked to load a class
|
||||
* that does not map to a module then it delegates to the parent class
|
||||
* loader. </p>
|
||||
*
|
||||
* <p> The class loaders created by this method locate resources
|
||||
* ({@link ClassLoader#getResource(String) getResource}, {@link
|
||||
* ClassLoader#getResources(String) getResources}, and other resource
|
||||
* methods) in the module defined to the class loader before searching
|
||||
* the parent class loader. </p>
|
||||
*
|
||||
* <p> If there is a security manager then the class loaders created by
|
||||
* this method will load classes and resources with privileges that are
|
||||
|
@ -576,10 +614,9 @@ public final class ModuleLayer {
|
|||
* <p> In addition, a layer cannot be created if the configuration contains
|
||||
* a module named "{@code java.base}", a configuration contains a module
|
||||
* with a package named "{@code java}" or a package name starting with
|
||||
* "{@code java.}" and the module is mapped to a class loader other than
|
||||
* the {@link ClassLoader#getPlatformClassLoader() platform class loader},
|
||||
* or the function to map a module name to a class loader returns
|
||||
* {@code null}. </p>
|
||||
* "{@code java.}", or the function to map a module name to a class loader
|
||||
* returns {@code null} or the {@linkplain ClassLoader#getPlatformClassLoader()
|
||||
* platform class loader}. </p>
|
||||
*
|
||||
* <p> If the function to map a module name to class loader throws an error
|
||||
* or runtime exception then it is propagated to the caller of this method.
|
||||
|
|
|
@ -109,7 +109,7 @@ import jdk.internal.reflect.Reflection;
|
|||
* and have no specification and implementation versioning information.
|
||||
*
|
||||
* @jvms 5.3 Run-time package
|
||||
* @see <a href="../../../technotes/guides/jar/jar.html#sealing">
|
||||
* @see <a href="{@docRoot}/../specs/jar/jar.html#sealing">
|
||||
* The JAR File Specification: Package Sealing</a>
|
||||
* @see ClassLoader#definePackage(String, String, String, String, String, String, String, URL)
|
||||
*
|
||||
|
|
|
@ -194,18 +194,15 @@ import sun.security.util.SecurityConstants;
|
|||
* of system administrators who might need to perform multiple
|
||||
* tasks that require all (or numerous) permissions.
|
||||
* <p>
|
||||
* See <a href ="../../../technotes/guides/security/permissions.html">
|
||||
* Permissions in the JDK</a> for permission-related information.
|
||||
* See {@extLink security_guide_permissions
|
||||
* Permissions in the Java Development Kit (JDK)}
|
||||
* for permission-related information.
|
||||
* This document includes, for example, a table listing the various SecurityManager
|
||||
* <code>check</code> methods and the permission(s) the default
|
||||
* implementation of each such method requires.
|
||||
* It also contains a table of all the version 1.2 methods
|
||||
* that require permissions, and for each such method tells
|
||||
* which permission it requires.
|
||||
* <p>
|
||||
* For more information about <code>SecurityManager</code> changes made in
|
||||
* the JDK and advice regarding porting of 1.1-style security managers,
|
||||
* see the <a href="../../../technotes/guides/security/index.html">security documentation</a>.
|
||||
*
|
||||
* @author Arthur van Hoff
|
||||
* @author Roland Schemers
|
||||
|
@ -1496,7 +1493,10 @@ class SecurityManager {
|
|||
* Throws a {@code SecurityException} if the calling thread is not allowed
|
||||
* to access the specified package.
|
||||
* <p>
|
||||
* This method is called by the {@code loadClass} method of class loaders.
|
||||
* During class loading, this method may be called by the {@code loadClass}
|
||||
* method of class loaders and by the Java Virtual Machine to ensure that
|
||||
* the caller is allowed to access the package of the class that is
|
||||
* being loaded.
|
||||
* <p>
|
||||
* This method checks if the specified package starts with or equals
|
||||
* any of the packages in the {@code package.access} Security Property.
|
||||
|
|
|
@ -47,6 +47,8 @@ import java.security.AccessController;
|
|||
import java.security.PrivilegedAction;
|
||||
import java.nio.channels.Channel;
|
||||
import java.nio.channels.spi.SelectorProvider;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.Properties;
|
||||
|
@ -2069,8 +2071,8 @@ public final class System {
|
|||
private static void setJavaLangAccess() {
|
||||
// Allow privileged classes outside of java.lang
|
||||
SharedSecrets.setJavaLangAccess(new JavaLangAccess() {
|
||||
public Method getMethodOrNull(Class<?> klass, String name, Class<?>... parameterTypes) {
|
||||
return klass.getMethodOrNull(name, parameterTypes);
|
||||
public List<Method> getDeclaredPublicMethods(Class<?> klass, String name, Class<?>... parameterTypes) {
|
||||
return klass.getDeclaredPublicMethods(name, parameterTypes);
|
||||
}
|
||||
public jdk.internal.reflect.ConstantPool getConstantPool(Class<?> klass) {
|
||||
return klass.getConstantPool();
|
||||
|
@ -2094,7 +2096,7 @@ public final class System {
|
|||
return Class.getExecutableTypeAnnotationBytes(executable);
|
||||
}
|
||||
public <E extends Enum<E>>
|
||||
E[] getEnumConstantsShared(Class<E> klass) {
|
||||
E[] getEnumConstantsShared(Class<E> klass) {
|
||||
return klass.getEnumConstantsShared();
|
||||
}
|
||||
public void blockedOn(Thread t, Interruptible b) {
|
||||
|
@ -2122,9 +2124,6 @@ public final class System {
|
|||
public Class<?> findBootstrapClassOrNull(ClassLoader cl, String name) {
|
||||
return cl.findBootstrapClassOrNull(name);
|
||||
}
|
||||
public Stream<Package> packages(ClassLoader cl) {
|
||||
return cl.packages();
|
||||
}
|
||||
public Package definePackage(ClassLoader cl, String name, Module module) {
|
||||
return cl.definePackage(name, module);
|
||||
}
|
||||
|
@ -2163,9 +2162,18 @@ public final class System {
|
|||
public void addOpensToAllUnnamed(Module m, String pn) {
|
||||
m.implAddOpensToAllUnnamed(pn);
|
||||
}
|
||||
public void addOpensToAllUnnamed(Module m, Iterator<String> packages) {
|
||||
m.implAddOpensToAllUnnamed(packages);
|
||||
}
|
||||
public void addUses(Module m, Class<?> service) {
|
||||
m.implAddUses(service);
|
||||
}
|
||||
public boolean isReflectivelyExported(Module m, String pn, Module other) {
|
||||
return m.isReflectivelyExported(pn, other);
|
||||
}
|
||||
public boolean isReflectivelyOpened(Module m, String pn, Module other) {
|
||||
return m.isReflectivelyOpened(pn, other);
|
||||
}
|
||||
public ServicesCatalog getServicesCatalog(ModuleLayer layer) {
|
||||
return layer.getServicesCatalog();
|
||||
}
|
||||
|
|
|
@ -212,7 +212,7 @@ public class MethodHandles {
|
|||
if (!callerModule.isNamed() && targetModule.isNamed()) {
|
||||
IllegalAccessLogger logger = IllegalAccessLogger.illegalAccessLogger();
|
||||
if (logger != null) {
|
||||
logger.logIfOpenedByBackdoor(lookup, targetClass);
|
||||
logger.logIfOpenedForIllegalAccess(lookup, targetClass);
|
||||
}
|
||||
}
|
||||
return new Lookup(targetClass);
|
||||
|
|
|
@ -110,6 +110,20 @@ import static java.lang.invoke.MethodHandleStatics.newInternalError;
|
|||
* boolean r = avh.compareAndSet(sa, 10, "expected", "new");
|
||||
* }</pre>
|
||||
*
|
||||
* <p>Access modes control atomicity and consistency properties.
|
||||
* <em>Plain</em> read ({@code get}) and write ({@code set})
|
||||
* accesses are guaranteed to be bitwise atomic only for references
|
||||
* and for primitive values of at most 32 bits, and impose no observable
|
||||
* ordering constraints with respect to threads other than the
|
||||
* executing thread. <em>Opaque</em> operations are bitwise atomic and
|
||||
* coherently ordered with respect to accesses to the same variable.
|
||||
* In addition to obeying Opaque properties, <em>Acquire</em> mode
|
||||
* reads and their subsequent accesses are ordered after matching
|
||||
* <em>Release</em> mode writes and their previous accesses. In
|
||||
* addition to obeying Acquire and Release properties, all
|
||||
* <em>Volatile</em> operations are totally ordered with respect to
|
||||
* each other.
|
||||
*
|
||||
* <p>Access modes are grouped into the following categories:
|
||||
* <ul>
|
||||
* <li>read access modes that get the value of a variable under specified
|
||||
|
|
|
@ -43,11 +43,10 @@ import java.util.stream.Stream;
|
|||
|
||||
/**
|
||||
* A configuration that is the result of <a href="package-summary.html#resolution">
|
||||
* resolution</a> or resolution with <a href="package-summary.html#servicebinding">
|
||||
* service binding</a>.
|
||||
* resolution</a> or resolution with <a href="#service-binding">service binding</a>.
|
||||
*
|
||||
* <p> A configuration encapsulates the <em>readability graph</em> that is the
|
||||
* output of resolution. A readability graph is a directed graph where the nodes
|
||||
* output of resolution. A readability graph is a directed graph whose vertices
|
||||
* are of type {@link ResolvedModule} and the edges represent the readability
|
||||
* amongst the modules. {@code Configuration} defines the {@link #modules()
|
||||
* modules()} method to get the set of resolved modules in the graph. {@code
|
||||
|
@ -176,8 +175,8 @@ public final class Configuration {
|
|||
* If resolution fails for any of the observability-related reasons
|
||||
* specified by the static {@code resolve} method
|
||||
* @throws ResolutionException
|
||||
* If any of the post-resolution consistency checks specified by
|
||||
* the static {@code resolve} method fail
|
||||
* If resolution fails any of the consistency checks specified by
|
||||
* the static {@code resolve} method
|
||||
* @throws SecurityException
|
||||
* If locating a module is denied by the security manager
|
||||
*/
|
||||
|
@ -219,8 +218,8 @@ public final class Configuration {
|
|||
* If resolution fails for any of the observability-related reasons
|
||||
* specified by the static {@code resolve} method
|
||||
* @throws ResolutionException
|
||||
* If any of the post-resolution consistency checks specified by
|
||||
* the static {@code resolve} method fail
|
||||
* If resolution fails any of the consistency checks specified by
|
||||
* the static {@code resolve} method
|
||||
* @throws SecurityException
|
||||
* If locating a module is denied by the security manager
|
||||
*/
|
||||
|
@ -234,7 +233,7 @@ public final class Configuration {
|
|||
|
||||
/**
|
||||
* Resolves a collection of root modules, with service binding, and with
|
||||
* the empty configuration as its parent. The post resolution checks
|
||||
* the empty configuration as its parent. The consistency checks
|
||||
* are optionally run.
|
||||
*
|
||||
* This method is used to create the configuration for the boot layer.
|
||||
|
@ -264,10 +263,9 @@ public final class Configuration {
|
|||
* or dependences that are located in a parent configuration are resolved
|
||||
* no further and are not included in the resulting configuration. </p>
|
||||
*
|
||||
* <p> When all modules have been resolved then the resulting dependency
|
||||
* graph is checked to ensure that it does not contain cycles. A
|
||||
* readability graph is constructed, and in conjunction with the module
|
||||
* exports and service use, checked for consistency. </p>
|
||||
* <p> When all modules have been enumerated then a readability graph
|
||||
* is computed, and in conjunction with the module exports and service use,
|
||||
* checked for consistency. </p>
|
||||
*
|
||||
* <p> Resolution may fail with {@code FindException} for the following
|
||||
* <em>observability-related</em> reasons: </p>
|
||||
|
@ -284,8 +282,8 @@ public final class Configuration {
|
|||
*
|
||||
* </ul>
|
||||
*
|
||||
* <p> Post-resolution consistency checks may fail with {@code
|
||||
* ResolutionException} for the following reasons: </p>
|
||||
* <p> Resolution may fail with {@code ResolutionException} if any of the
|
||||
* following consistency checks fail: </p>
|
||||
*
|
||||
* <ul>
|
||||
*
|
||||
|
@ -329,9 +327,11 @@ public final class Configuration {
|
|||
* root modules
|
||||
*
|
||||
* @throws FindException
|
||||
* If resolution fails for an observability-related reason
|
||||
* If resolution fails for any of observability-related reasons
|
||||
* specified above
|
||||
* @throws ResolutionException
|
||||
* If a post-resolution consistency checks fails
|
||||
* If resolution fails for any of the consistency checks specified
|
||||
* above
|
||||
* @throws IllegalArgumentException
|
||||
* If the list of parents is empty, or the list has two or more
|
||||
* parents with modules for different target operating systems,
|
||||
|
@ -368,11 +368,11 @@ public final class Configuration {
|
|||
* resolve} except that the graph of resolved modules is augmented
|
||||
* with modules induced by the service-use dependence relation. </p>
|
||||
*
|
||||
* <p> More specifically, the root modules are resolved as if by calling
|
||||
* {@code resolve}. The resolved modules, and all modules in the
|
||||
* parent configurations, with {@link ModuleDescriptor#uses() service
|
||||
* dependences} are then examined. All modules found by the given module
|
||||
* finders that {@link ModuleDescriptor#provides() provide} an
|
||||
* <p id="service-binding"> More specifically, the root modules are
|
||||
* resolved as if by calling {@code resolve}. The resolved modules, and
|
||||
* all modules in the parent configurations, with {@link ModuleDescriptor#uses()
|
||||
* service dependences} are then examined. All modules found by the given
|
||||
* module finders that {@link ModuleDescriptor#provides() provide} an
|
||||
* implementation of one or more of the service types are added to the
|
||||
* module graph and then resolved as if by calling the {@code
|
||||
* resolve} method. Adding modules to the module graph may introduce new
|
||||
|
@ -402,8 +402,8 @@ public final class Configuration {
|
|||
* If resolution fails for any of the observability-related reasons
|
||||
* specified by the static {@code resolve} method
|
||||
* @throws ResolutionException
|
||||
* If any of the post-resolution consistency checks specified by
|
||||
* the static {@code resolve} method fail
|
||||
* If resolution fails any of the consistency checks specified by
|
||||
* the static {@code resolve} method
|
||||
* @throws IllegalArgumentException
|
||||
* If the list of parents is empty, or the list has two or more
|
||||
* parents with modules for different target operating systems,
|
||||
|
|
|
@ -48,7 +48,7 @@ import jdk.internal.module.SystemModuleFinder;
|
|||
/**
|
||||
* A finder of modules. A {@code ModuleFinder} is used to find modules during
|
||||
* <a href="package-summary.html#resolution">resolution</a> or
|
||||
* <a href="package-summary.html#servicebinding">service binding</a>.
|
||||
* <a href="Configuration.html#service-binding">service binding</a>.
|
||||
*
|
||||
* <p> A {@code ModuleFinder} can only find one module with a given name. A
|
||||
* {@code ModuleFinder} that finds modules in a sequence of directories, for
|
||||
|
@ -239,30 +239,35 @@ public interface ModuleFinder {
|
|||
*
|
||||
* <ul>
|
||||
*
|
||||
* <li><p> The module {@link ModuleDescriptor#name() name}, and {@link
|
||||
* ModuleDescriptor#version() version} if applicable, is derived from
|
||||
* the file name of the JAR file as follows: </p>
|
||||
* <li><p> If the JAR file has the attribute "{@code Automatic-Module-Name}"
|
||||
* in its main manifest then its value is the {@linkplain
|
||||
* ModuleDescriptor#name() module name}. The module name is otherwise
|
||||
* derived from the name of the JAR file. </p></li>
|
||||
*
|
||||
* <li><p> The {@link ModuleDescriptor#version() version}, and the
|
||||
* module name when the attribute "{@code Automatic-Module-Name}" is not
|
||||
* present, are derived from the file name of the JAR file as follows: </p>
|
||||
*
|
||||
* <ul>
|
||||
*
|
||||
* <li><p> The {@code .jar} suffix is removed. </p></li>
|
||||
* <li><p> The "{@code .jar}" suffix is removed. </p></li>
|
||||
*
|
||||
* <li><p> If the name matches the regular expression {@code
|
||||
* "-(\\d+(\\.|$))"} then the module name will be derived from the
|
||||
* subsequence preceding the hyphen of the first occurrence. The
|
||||
* subsequence after the hyphen is parsed as a {@link
|
||||
* ModuleDescriptor.Version} and ignored if it cannot be parsed as
|
||||
* a {@code Version}. </p></li>
|
||||
* ModuleDescriptor.Version Version} and ignored if it cannot be
|
||||
* parsed as a {@code Version}. </p></li>
|
||||
*
|
||||
* <li><p> All non-alphanumeric characters ({@code [^A-Za-z0-9]})
|
||||
* in the module name are replaced with a dot ({@code "."}), all
|
||||
* repeating dots are replaced with one dot, and all leading and
|
||||
* trailing dots are removed. </p></li>
|
||||
*
|
||||
* <li><p> As an example, a JAR file named {@code foo-bar.jar} will
|
||||
* derive a module name {@code foo.bar} and no version. A JAR file
|
||||
* named {@code foo-bar-1.2.3-SNAPSHOT.jar} will derive a module
|
||||
* name {@code foo.bar} and {@code 1.2.3-SNAPSHOT} as the version.
|
||||
* <li><p> As an example, a JAR file named "{@code foo-bar.jar}" will
|
||||
* derive a module name "{@code foo.bar}" and no version. A JAR file
|
||||
* named "{@code foo-bar-1.2.3-SNAPSHOT.jar}" will derive a module
|
||||
* name "{@code foo.bar}" and "{@code 1.2.3-SNAPSHOT}" as the version.
|
||||
* </p></li>
|
||||
*
|
||||
* </ul></li>
|
||||
|
@ -295,11 +300,12 @@ public interface ModuleFinder {
|
|||
* <p> If a {@code ModuleDescriptor} cannot be created (by means of the
|
||||
* {@link ModuleDescriptor.Builder ModuleDescriptor.Builder} API) for an
|
||||
* automatic module then {@code FindException} is thrown. This can arise
|
||||
* when a legal module name cannot be derived from the file name of the JAR
|
||||
* file, where the JAR file contains a {@code .class} in the top-level
|
||||
* directory of the JAR file, where an entry in a service configuration
|
||||
* file is not a legal class name or its package name is not in the set of
|
||||
* packages derived for the module. </p>
|
||||
* when the value of the "{@code Automatic-Module-Name}" attribute is not a
|
||||
* legal module name, a legal module name cannot be derived from the file
|
||||
* name of the JAR file, where the JAR file contains a {@code .class} in
|
||||
* the top-level directory of the JAR file, where an entry in a service
|
||||
* configuration file is not a legal class name or its package name is not
|
||||
* in the set of packages derived for the module. </p>
|
||||
*
|
||||
* <p> In addition to JAR files, an implementation may also support modules
|
||||
* that are packaged in other implementation specific module formats. If
|
||||
|
|
|
@ -27,118 +27,185 @@
|
|||
* Classes to support module descriptors and creating configurations of modules
|
||||
* by means of resolution and service binding.
|
||||
*
|
||||
* <h2><a id="resolution">Resolution</a></h2>
|
||||
*
|
||||
* <p> Resolution is the process of computing the transitive closure of a set
|
||||
* of root modules over a set of observable modules by resolving the
|
||||
* dependences expressed by {@link
|
||||
* java.lang.module.ModuleDescriptor.Requires requires} clauses.
|
||||
* The <em>dependence graph</em> is augmented with edges that take account of
|
||||
* implicitly declared dependences ({@code requires transitive}) to create a
|
||||
* <em>readability graph</em>. The result of resolution is a {@link
|
||||
* java.lang.module.Configuration Configuration} that encapsulates the
|
||||
* readability graph. </p>
|
||||
*
|
||||
* <p> As an example, suppose we have the following observable modules: </p>
|
||||
* <pre> {@code
|
||||
* module m1 { requires m2; }
|
||||
* module m2 { requires transitive m3; }
|
||||
* module m3 { }
|
||||
* module m4 { }
|
||||
* } </pre>
|
||||
*
|
||||
* <p> If the module {@code m1} is resolved then the resulting configuration
|
||||
* contains three modules ({@code m1}, {@code m2}, {@code m3}). The edges in
|
||||
* its readability graph are: </p>
|
||||
* <pre> {@code
|
||||
* m1 --> m2 (meaning m1 reads m2)
|
||||
* m1 --> m3
|
||||
* m2 --> m3
|
||||
* } </pre>
|
||||
*
|
||||
* <p> Resolution is an additive process. When computing the transitive closure
|
||||
* then the dependence relation may include dependences on modules in {@link
|
||||
* java.lang.module.Configuration#parents() parent} configurations. The result
|
||||
* is a <em>relative configuration</em> that is relative to one or more parent
|
||||
* configurations and where the readability graph may have edges from modules
|
||||
* in the configuration to modules in parent configurations. </p>
|
||||
*
|
||||
* <p> As an example, suppose we have the following observable modules: </p>
|
||||
* <pre> {@code
|
||||
* module m1 { requires m2; requires java.xml; }
|
||||
* module m2 { }
|
||||
* } </pre>
|
||||
*
|
||||
* <p> If module {@code m1} is resolved with the configuration for the {@link
|
||||
* java.lang.ModuleLayer#boot() boot} layer as the parent then the resulting
|
||||
* configuration contains two modules ({@code m1}, {@code m2}). The edges in
|
||||
* its readability graph are:
|
||||
* <pre> {@code
|
||||
* m1 --> m2
|
||||
* m1 --> java.xml
|
||||
* } </pre>
|
||||
* where module {@code java.xml} is in the parent configuration. For
|
||||
* simplicity, this example omits the implicitly declared dependence on the
|
||||
* {@code java.base} module.
|
||||
*
|
||||
* <p> Requires clauses that are "{@code requires static}" express an optional
|
||||
* dependence (except at compile-time). If a module declares that it
|
||||
* "{@code requires static M}" then resolution does not search the observable
|
||||
* modules for "{@code M}". However, if "{@code M}" is resolved (because resolution
|
||||
* resolves a module that requires "{@code M}" without the {@link
|
||||
* java.lang.module.ModuleDescriptor.Requires.Modifier#STATIC static} modifier)
|
||||
* then the readability graph will contain read edges for each module that
|
||||
* "{@code requires static M}". </p>
|
||||
*
|
||||
* <p> {@link java.lang.module.ModuleDescriptor#isAutomatic() Automatic} modules
|
||||
* receive special treatment during resolution. Each automatic module is resolved
|
||||
* as if it "{@code requires transitive}" all observable automatic modules and
|
||||
* all automatic modules in the parent configurations. Each automatic module is
|
||||
* resolved so that it reads all other modules in the resulting configuration and
|
||||
* all modules in parent configurations. </p>
|
||||
*
|
||||
* <h2><a id="servicebinding">Service binding</a></h2>
|
||||
*
|
||||
* <p> Service binding is the process of augmenting a graph of resolved modules
|
||||
* from the set of observable modules induced by the service-use dependence
|
||||
* ({@code uses} and {@code provides} clauses). Any module that was not
|
||||
* previously in the graph requires resolution to compute its transitive
|
||||
* closure. Service binding is an iterative process in that adding a module
|
||||
* that satisfies some service-use dependence may introduce new service-use
|
||||
* dependences. </p>
|
||||
*
|
||||
* <p> Suppose we have the following observable modules: </p>
|
||||
* <pre> {@code
|
||||
* module m1 { exports p; uses p.S; }
|
||||
* module m2 { requires m1; provides p.S with p2.S2; }
|
||||
* module m3 { requires m1; requires m4; provides p.S with p3.S3; }
|
||||
* module m4 { }
|
||||
* } </pre>
|
||||
*
|
||||
* <p> If the module {@code m1} is resolved then the resulting graph of modules
|
||||
* has one module ({@code m1}). If the graph is augmented with modules induced
|
||||
* by the service-use dependence relation then the configuration will contain
|
||||
* four modules ({@code m1}, {@code m2}, {@code m3}, {@code m4}). The edges in
|
||||
* its readability graph are: </p>
|
||||
* <pre> {@code
|
||||
* m2 --> m1
|
||||
* m3 --> m1
|
||||
* m3 --> m4
|
||||
* } </pre>
|
||||
* <p> The edges in the conceptual service-use graph are: </p>
|
||||
* <pre> {@code
|
||||
* m1 --> m2 (meaning m1 uses a service that is provided by m2)
|
||||
* m1 --> m3
|
||||
* } </pre>
|
||||
*
|
||||
* <h2>General Exceptions</h2>
|
||||
*
|
||||
* <p> Unless otherwise noted, passing a {@code null} argument to a constructor
|
||||
* or method of any class or interface in this package will cause a {@link
|
||||
* java.lang.NullPointerException NullPointerException} to be thrown. Additionally,
|
||||
* invoking a method with an array or collection containing a {@code null} element
|
||||
* will cause a {@code NullPointerException}, unless otherwise specified. </p>
|
||||
*
|
||||
*
|
||||
* <h1><a id="resolution">Resolution</a></h1>
|
||||
*
|
||||
* <p> Resolution is the process of computing how modules depend on each other.
|
||||
* The process occurs at compile time and run time. </p>
|
||||
*
|
||||
* <p> Resolution is a two-step process. The first step recursively enumerates
|
||||
* the 'requires' directives of a set of root modules. If all the enumerated
|
||||
* modules are observable, then the second step computes their readability graph.
|
||||
* The readability graph embodies how modules depend on each other, which in
|
||||
* turn controls access across module boundaries. </p>
|
||||
*
|
||||
* <h2> Step 1: Recursive enumeration </h2>
|
||||
*
|
||||
* <p> Recursive enumeration takes a set of module names, looks up each of their
|
||||
* module declarations, and for each module declaration, recursively enumerates:
|
||||
*
|
||||
* <ul>
|
||||
* <li> <p> the module names given by the 'requires' directives with the
|
||||
* 'transitive' modifier, and </p></li>
|
||||
* <li> <p> at the discretion of the host system, the module names given by
|
||||
* the 'requires' directives without the 'transitive' modifier. </p></li>
|
||||
* </ul>
|
||||
*
|
||||
* <p> Module declarations are looked up in a set of observable modules. The set
|
||||
* of observable modules is determined in an implementation specific manner. The
|
||||
* set of observable modules may include modules with explicit declarations
|
||||
* (that is, with a {@code module-info.java} source file or {@code module-info.class}
|
||||
* file) and modules with implicit declarations (that is,
|
||||
* <a href="ModuleFinder.html#automatic-modules">automatic modules</a>).
|
||||
* Because an automatic module has no explicit module declaration, it has no
|
||||
* 'requires' directives of its own, although its name may be given by a
|
||||
* 'requires' directive of an explicit module declaration. </p>
|
||||
|
||||
* <p> The set of root modules, whose names are the initial input to this
|
||||
* algorithm, is determined in an implementation specific manner. The set of
|
||||
* root modules may include automatic modules. </p>
|
||||
*
|
||||
* <p> If at least one automatic module is enumerated by this algorithm, then
|
||||
* every observable automatic module must be enumerated, regardless of whether
|
||||
* any of their names are given by 'requires' directives of explicit module
|
||||
* declarations. </p>
|
||||
*
|
||||
* <p> If any of the following conditions occur, then resolution fails:
|
||||
* <ul>
|
||||
* <li><p> Any root module is not observable. </p></li>
|
||||
* <li><p> Any module whose name is given by a 'requires' directive with the
|
||||
* 'transitive' modifier is not observable. </p></li>
|
||||
* <li><p> At the discretion of the host system, any module whose name is given
|
||||
* by a 'requires' directive without the 'transitive' modifier is not
|
||||
* observable. </p></li>
|
||||
* <li><p> The algorithm in this step enumerates the same module name twice. This
|
||||
* indicates a cycle in the 'requires' directives, disregarding any 'transitive'
|
||||
* modifiers. </p></li>
|
||||
* </ul>
|
||||
*
|
||||
* <p> Otherwise, resolution proceeds to step 2. </p>
|
||||
*
|
||||
* <h2> Step 2: Computing the readability graph </h2>
|
||||
*
|
||||
* <p> A 'requires' directive (irrespective of 'transitive') expresses that
|
||||
* one module depends on some other module. The effect of the 'transitive'
|
||||
* modifier is to cause additional modules to also depend on the other module.
|
||||
* If module M 'requires transitive N', then not only does M depend on N, but
|
||||
* any module that depends on M also depends on N. This allows M to be
|
||||
* refactored so that some or all of its content can be moved to a new module N
|
||||
* without breaking modules that have a 'requires M' directive. </p>
|
||||
*
|
||||
* <p> Module dependencies are represented by the readability graph. The
|
||||
* readability graph is a directed graph whose vertices are the modules
|
||||
* enumerated in step 1 and whose edges represent readability between pairs of
|
||||
* modules. The edges are specified as follows:
|
||||
*
|
||||
* <p> First, readability is determined by the 'requires' directives of the
|
||||
* enumerated modules, disregarding any 'transitive' modifiers:
|
||||
*
|
||||
* <ul>
|
||||
* <li><p> For each enumerated module A that 'requires' B: A "reads" B. </p></li>
|
||||
* <li><p> For each enumerated module X that is automatic: X "reads" every
|
||||
* other enumerated module (it is "as if" an automatic module has 'requires'
|
||||
* directives for every other enumerated module). </p></li>
|
||||
* </ul>
|
||||
*
|
||||
* <p> Second, readability is augmented to account for 'transitive' modifiers:
|
||||
* <ul>
|
||||
* <li> <p> For each enumerated module A that "reads" B: </p>
|
||||
* <ul>
|
||||
* <li><p> If B 'requires transitive' C, then A "reads" C as well as B. This
|
||||
* augmentation is recursive: since A "reads" C, if C 'requires transitive'
|
||||
* D, then A "reads" D as well as C and B. </p></li>
|
||||
* <li><p> If B is an automatic module, then A "reads" every other enumerated
|
||||
* automatic module. (It is "as if" an automatic module has 'requires transitive'
|
||||
* directives for every other enumerated automatic module).</p> </li>
|
||||
* </ul>
|
||||
* </li>
|
||||
* </ul>
|
||||
*
|
||||
* <p> Finally, every module "reads" itself. </p>
|
||||
*
|
||||
* <p> If any of the following conditions occur in the readability graph, then
|
||||
* resolution fails:
|
||||
* <ul>
|
||||
* <li><p> A module "reads" two or more modules with the same name. This includes
|
||||
* the case where a module "reads" another with the same name as itself. </p></li>
|
||||
* <li><p> Two or more modules export a package with the same name to a module
|
||||
* that "reads" both. This includes the case where a module M containing package
|
||||
* p "reads" another module that exports p to M. </p></li>
|
||||
* <li><p> A module M declares that it 'uses p.S' or 'provides p.S with ...' but
|
||||
* package p is neither in module M nor exported to M by any module that M
|
||||
* "reads". </p></li>
|
||||
* </ul>
|
||||
* <p> Otherwise, resolution succeeds, and the result of resolution is the
|
||||
* readability graph.
|
||||
*
|
||||
* <h2> Root modules </h2>
|
||||
*
|
||||
* <p> The set of root modules at compile-time is usually the set of modules
|
||||
* being compiled. At run-time, the set of root modules is usually the
|
||||
* application module specified to the 'java' launcher. When compiling code in
|
||||
* the unnamed module, or at run-time when the main application class is loaded
|
||||
* from the class path, then the default set of root modules is implementation
|
||||
* specific (In the JDK implementation it is the module "java.se", if observable,
|
||||
* and every observable module that exports an API). </p>
|
||||
*
|
||||
* <h2> Observable modules </h2>
|
||||
*
|
||||
* <p> The set of observable modules at both compile-time and run-time is
|
||||
* determined by searching several different paths, and also by searching
|
||||
* the compiled modules built in to the environment. The search order is as
|
||||
* follows: </p>
|
||||
*
|
||||
* <ol>
|
||||
* <li><p> At compile time only, the compilation module path. This path
|
||||
* contains module definitions in source form. </p></li>
|
||||
*
|
||||
* <li><p> The upgrade module path. This path contains compiled definitions of
|
||||
* modules that will be observed in preference to the compiled definitions of
|
||||
* any <i>upgradeable modules</i> that are present in (3) and (4). See the Java
|
||||
* SE Platform for the designation of which standard modules are upgradeable.
|
||||
* </p></li>
|
||||
*
|
||||
* <li><p> The system modules, which are the compiled definitions built in to
|
||||
* the environment. </p></li>
|
||||
*
|
||||
* <li><p> The application module path. This path contains compiled definitions
|
||||
* of library and application modules. </p></li>
|
||||
*
|
||||
* </ol>
|
||||
*
|
||||
* <h2> 'requires' directives with 'static' modifier </h2>
|
||||
*
|
||||
* <p> 'requires' directives that have the 'static' modifier express an optional
|
||||
* dependence at run time. If a module declares that it 'requires static M' then
|
||||
* resolution does not search the observable modules for M to satisfy the dependency.
|
||||
* However, if M is recursively enumerated at step 1 then all modules that are
|
||||
* enumerated and `requires static M` will read M. </p>
|
||||
*
|
||||
* <h2> Completeness </h2>
|
||||
*
|
||||
* <p> Resolution may be partial at compile-time in that the complete transitive
|
||||
* closure may not be required to compile a set of modules. Minimally, the
|
||||
* readability graph that is constructed and validated at compile-time includes
|
||||
* the modules being compiled, their direct dependences, and all implicitly
|
||||
* declared dependences (requires transitive). </p>
|
||||
*
|
||||
* <p> At run-time, resolution is an additive process. The recursive enumeration
|
||||
* at step 1 may be relative to previous resolutions so that a root module,
|
||||
* or a module named in a 'requires' directive, is not enumerated when it was
|
||||
* enumerated by a previous (or parent) resolution. The readability graph that
|
||||
* is the result of resolution may therefore have a vertex for a module enumerated
|
||||
* in step 1 but with an edge to represent that the module reads a module that
|
||||
* was enumerated by previous (or parent) resolution. </p>
|
||||
*
|
||||
* @since 9
|
||||
* @spec JPMS
|
||||
*/
|
||||
|
|
|
@ -304,7 +304,7 @@ public class AccessibleObject implements AnnotatedElement {
|
|||
if (isClassPublic && declaringModule.isExported(pn, callerModule)) {
|
||||
// member is public
|
||||
if (Modifier.isPublic(modifiers)) {
|
||||
logIfExportedByBackdoor(caller, declaringClass);
|
||||
logIfExportedForIllegalAccess(caller, declaringClass);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -312,14 +312,14 @@ public class AccessibleObject implements AnnotatedElement {
|
|||
if (Modifier.isProtected(modifiers)
|
||||
&& Modifier.isStatic(modifiers)
|
||||
&& isSubclassOf(caller, declaringClass)) {
|
||||
logIfExportedByBackdoor(caller, declaringClass);
|
||||
logIfExportedForIllegalAccess(caller, declaringClass);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
// package is open to caller
|
||||
if (declaringModule.isOpen(pn, callerModule)) {
|
||||
logIfOpenedByBackdoor(caller, declaringClass);
|
||||
logIfOpenedForIllegalAccess(caller, declaringClass);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -353,26 +353,26 @@ public class AccessibleObject implements AnnotatedElement {
|
|||
return false;
|
||||
}
|
||||
|
||||
private void logIfOpenedByBackdoor(Class<?> caller, Class<?> declaringClass) {
|
||||
private void logIfOpenedForIllegalAccess(Class<?> caller, Class<?> declaringClass) {
|
||||
Module callerModule = caller.getModule();
|
||||
Module targetModule = declaringClass.getModule();
|
||||
// callerModule is null during early startup
|
||||
if (callerModule != null && !callerModule.isNamed() && targetModule.isNamed()) {
|
||||
IllegalAccessLogger logger = IllegalAccessLogger.illegalAccessLogger();
|
||||
if (logger != null) {
|
||||
logger.logIfOpenedByBackdoor(caller, declaringClass, this::toShortString);
|
||||
logger.logIfOpenedForIllegalAccess(caller, declaringClass, this::toShortString);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void logIfExportedByBackdoor(Class<?> caller, Class<?> declaringClass) {
|
||||
private void logIfExportedForIllegalAccess(Class<?> caller, Class<?> declaringClass) {
|
||||
Module callerModule = caller.getModule();
|
||||
Module targetModule = declaringClass.getModule();
|
||||
// callerModule is null during early startup
|
||||
if (callerModule != null && !callerModule.isNamed() && targetModule.isNamed()) {
|
||||
IllegalAccessLogger logger = IllegalAccessLogger.illegalAccessLogger();
|
||||
if (logger != null) {
|
||||
logger.logIfExportedByBackdoor(caller, declaringClass, this::toShortString);
|
||||
logger.logIfExportedForIllegalAccess(caller, declaringClass, this::toShortString);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -634,7 +634,7 @@ public class AccessibleObject implements AnnotatedElement {
|
|||
}
|
||||
|
||||
// access okay
|
||||
logIfExportedByBackdoor(caller, memberClass);
|
||||
logIfExportedForIllegalAccess(caller, memberClass);
|
||||
|
||||
// Success: Update the cache.
|
||||
Object cache = (targetClass != null
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2003, 2008, 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
|
||||
|
@ -36,4 +36,21 @@ package java.lang.reflect;
|
|||
*/
|
||||
public class MalformedParameterizedTypeException extends RuntimeException {
|
||||
private static final long serialVersionUID = -5696557788586220964L;
|
||||
|
||||
/**
|
||||
* Constructs a {@code MalformedParameterizedTypeException} with
|
||||
* no detail message.
|
||||
*/
|
||||
public MalformedParameterizedTypeException() {
|
||||
super();
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a {@code MalformedParameterizedTypeException} with
|
||||
* the given detail message.
|
||||
* @param message the detail message; may be {@code null}
|
||||
*/
|
||||
public MalformedParameterizedTypeException(String message) {
|
||||
super(message);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
|
@ -195,12 +195,10 @@ public abstract class Charset$Coder$ {
|
|||
if (max$ItypesPerOtype$ <= 0.0f)
|
||||
throw new IllegalArgumentException("Non-positive "
|
||||
+ "max$ItypesPerOtype$");
|
||||
if (!Charset.atBugLevel("1.4")) {
|
||||
if (average$ItypesPerOtype$ > max$ItypesPerOtype$)
|
||||
throw new IllegalArgumentException("average$ItypesPerOtype$"
|
||||
+ " exceeds "
|
||||
+ "max$ItypesPerOtype$");
|
||||
}
|
||||
if (average$ItypesPerOtype$ > max$ItypesPerOtype$)
|
||||
throw new IllegalArgumentException("average$ItypesPerOtype$"
|
||||
+ " exceeds "
|
||||
+ "max$ItypesPerOtype$");
|
||||
this.replacement = replacement;
|
||||
this.average$ItypesPerOtype$ = average$ItypesPerOtype$;
|
||||
this.max$ItypesPerOtype$ = max$ItypesPerOtype$;
|
||||
|
|
|
@ -281,19 +281,6 @@ public abstract class Charset
|
|||
|
||||
/* -- Static methods -- */
|
||||
|
||||
private static volatile String bugLevel;
|
||||
|
||||
static boolean atBugLevel(String bl) { // package-private
|
||||
String level = bugLevel;
|
||||
if (level == null) {
|
||||
if (!VM.isBooted())
|
||||
return false;
|
||||
bugLevel = level = GetPropertyAction
|
||||
.privilegedGetProperty("sun.nio.cs.bugLevel", "");
|
||||
}
|
||||
return level.equals(bl);
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks that the given string is a legal charset name. </p>
|
||||
*
|
||||
|
@ -305,7 +292,7 @@ public abstract class Charset
|
|||
*/
|
||||
private static void checkName(String s) {
|
||||
int n = s.length();
|
||||
if (n == 0 && !atBugLevel("1.4")) {
|
||||
if (n == 0) {
|
||||
throw new IllegalCharsetNameException(s);
|
||||
}
|
||||
for (int i = 0; i < n; i++) {
|
||||
|
|
|
@ -64,8 +64,7 @@ import java.util.Objects;
|
|||
* AlgorithmParameterGenerator (via a call to an {@code init} method),
|
||||
* each provider must supply (and document) a default initialization.
|
||||
* See the Keysize Restriction sections of the
|
||||
* <a href="{@docRoot}/../technotes/guides/security/SunProviders.html">
|
||||
* JDK Providers</a>
|
||||
* {@extLink security_guide_jdk_providers JDK Providers}
|
||||
* document for information on the AlgorithmParameterGenerator defaults
|
||||
* used by JDK providers.
|
||||
* However, note that defaults may vary across different providers.
|
||||
|
|
|
@ -40,8 +40,7 @@ import java.security.spec.AlgorithmParameterSpec;
|
|||
* AlgorithmParameterGenerator (via a call to an {@code engineInit}
|
||||
* method), each provider must supply (and document) a default initialization.
|
||||
* See the Keysize Restriction sections of the
|
||||
* <a href="{@docRoot}/../technotes/guides/security/SunProviders.html">
|
||||
* JDK Providers</a>
|
||||
* {@extLink security_guide_jdk_providers JDK Providers}
|
||||
* document for information on the AlgorithmParameterGenerator defaults
|
||||
* used by JDK providers.
|
||||
* However, note that defaults may vary across different providers.
|
||||
|
|
|
@ -114,10 +114,10 @@ public interface Key extends java.io.Serializable {
|
|||
/**
|
||||
* Returns the standard algorithm name for this key. For
|
||||
* example, "DSA" would indicate that this key is a DSA key.
|
||||
* See Appendix A in the <a href=
|
||||
* "../../../technotes/guides/security/crypto/CryptoSpec.html#AppA">
|
||||
* Java Cryptography Architecture API Specification & Reference </a>
|
||||
* for information about standard algorithm names.
|
||||
* See the <a href=
|
||||
* "{@docRoot}/../specs/security/standard-names.html">
|
||||
* Java Security Standard Algorithm Names</a> document
|
||||
* for more information.
|
||||
*
|
||||
* @return the name of the algorithm associated with this key.
|
||||
*/
|
||||
|
|
|
@ -96,8 +96,7 @@ import sun.security.util.Debug;
|
|||
* (via a call to an {@code initialize} method), each provider must
|
||||
* supply (and document) a default initialization.
|
||||
* See the Keysize Restriction sections of the
|
||||
* <a href="{@docRoot}/../technotes/guides/security/SunProviders.html">
|
||||
* JDK Providers</a>
|
||||
* {@extLink security_guide_jdk_providers JDK Providers}
|
||||
* document for information on the KeyPairGenerator defaults used by
|
||||
* JDK providers.
|
||||
* However, note that defaults may vary across different providers.
|
||||
|
|
|
@ -40,8 +40,7 @@ import java.security.spec.AlgorithmParameterSpec;
|
|||
* (via a call to an {@code initialize} method), each provider must
|
||||
* supply (and document) a default initialization.
|
||||
* See the Keysize Restriction sections of the
|
||||
* <a href="{@docRoot}/../technotes/guides/security/SunProviders.html">
|
||||
* JDK Providers</a>
|
||||
* {@extLink security_guide_jdk_providers JDK Providers}
|
||||
* document for information on the KeyPairGenerator defaults used by
|
||||
* JDK providers.
|
||||
* However, note that defaults may vary across different providers.
|
||||
|
|
|
@ -94,9 +94,9 @@ import java.util.function.Function;
|
|||
* The JDK implementation supports static registration of the security
|
||||
* providers via the {@code conf/security/java.security} file in the Java
|
||||
* installation directory. These providers are automatically installed by
|
||||
* the JDK runtime, see <a href =
|
||||
* "../../../technotes/guides/security/crypto/CryptoSpec.html#Provider">The Provider Class</a>
|
||||
* in the "Java Cryptography Architecture API Specification & Reference"
|
||||
* the JDK runtime, see {@extLink security_guide_jca_provider
|
||||
* The Provider Class}
|
||||
* in the Java Cryptography Architecture (JCA) Reference Guide
|
||||
* for information about how a particular type of provider, the cryptographic
|
||||
* service provider, works and is installed.
|
||||
*
|
||||
|
@ -1310,8 +1310,8 @@ public abstract class Provider extends Properties {
|
|||
* it is replaced by the new service.
|
||||
* This method also places information about this service
|
||||
* in the provider's Hashtable values in the format described in the
|
||||
* <a href="../../../technotes/guides/security/crypto/CryptoSpec.html">
|
||||
* Java Cryptography Architecture API Specification & Reference </a>.
|
||||
* {@extLink security_guide_jca
|
||||
* Java Cryptography Architecture (JCA) Reference Guide}.
|
||||
*
|
||||
* <p>Also, if there is a security manager, its
|
||||
* {@code checkSecurityAccess} method is called with the string
|
||||
|
@ -1593,8 +1593,8 @@ public abstract class Provider extends Properties {
|
|||
* suitable services and instantiates them. The valid arguments to those
|
||||
* methods depend on the type of service. For the service types defined
|
||||
* within Java SE, see the
|
||||
* <a href="../../../technotes/guides/security/crypto/CryptoSpec.html">
|
||||
* Java Cryptography Architecture API Specification & Reference </a>
|
||||
* {@extLink security_guide_jca
|
||||
* Java Cryptography Architecture (JCA) Reference Guide}
|
||||
* for the valid values.
|
||||
* Note that components outside of Java SE can define additional types of
|
||||
* services and their behavior.
|
||||
|
@ -1769,9 +1769,8 @@ public abstract class Provider extends Properties {
|
|||
* instantiation in a different way.
|
||||
* For details and the values of constructorParameter that are
|
||||
* valid for the various types of services see the
|
||||
* <a href="../../../technotes/guides/security/crypto/CryptoSpec.html">
|
||||
* Java Cryptography Architecture API Specification &
|
||||
* Reference</a>.
|
||||
* {@extLink security_guide_jca
|
||||
* Java Cryptography Architecture (JCA) Reference Guide}.
|
||||
*
|
||||
* @param constructorParameter the value to pass to the constructor,
|
||||
* or null if this type of service does not use a constructorParameter.
|
||||
|
@ -1878,9 +1877,8 @@ public abstract class Provider extends Properties {
|
|||
*
|
||||
* <p>For details and the values of parameter that are valid for the
|
||||
* various types of services see the top of this class and the
|
||||
* <a href="../../../technotes/guides/security/crypto/CryptoSpec.html">
|
||||
* Java Cryptography Architecture API Specification &
|
||||
* Reference</a>.
|
||||
* {@extLink security_guide_jca
|
||||
* Java Cryptography Architecture (JCA) Reference Guide}.
|
||||
* Security providers can override it to implement their own test.
|
||||
*
|
||||
* @param parameter the parameter to test
|
||||
|
|
|
@ -1041,8 +1041,8 @@ public final class Security {
|
|||
* an empty Set if there is no provider that supports the
|
||||
* specified service or if serviceName is null. For a complete list
|
||||
* of Java cryptographic services, please see the
|
||||
* <a href="../../../technotes/guides/security/crypto/CryptoSpec.html">Java
|
||||
* Cryptography Architecture API Specification & Reference</a>.
|
||||
* {@extLink security_guide_jca
|
||||
* Java Cryptography Architecture (JCA) Reference Guide}.
|
||||
* Note: the returned set is immutable.
|
||||
*
|
||||
* @param serviceName the name of the Java cryptographic
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 1998, 2006, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1998, 2017, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
|
@ -52,9 +52,9 @@ public abstract class CRL {
|
|||
* Creates a CRL of the specified type.
|
||||
*
|
||||
* @param type the standard name of the CRL type.
|
||||
* See Appendix A in the <a href=
|
||||
* "../../../../technotes/guides/security/crypto/CryptoSpec.html#AppA">
|
||||
* Java Cryptography Architecture API Specification & Reference </a>
|
||||
* See the <a href=
|
||||
* "{@docRoot}/../specs/security/standard-names.html">
|
||||
* Java Security Standard Algorithm Names</a> document
|
||||
* for information about standard CRL types.
|
||||
*/
|
||||
protected CRL(String type) {
|
||||
|
|
|
@ -32,15 +32,14 @@
|
|||
* <h2>Package Specification</h2>
|
||||
*
|
||||
* <ul>
|
||||
* <li><a href="{@docRoot}/../technotes/guides/security/crypto/CryptoSpec.html">
|
||||
* <b>Java™
|
||||
* Cryptography Architecture (JCA) Reference Guide</b></a>
|
||||
* <li>{@extLink security_guide_jca
|
||||
* Java Cryptography Architecture (JCA) Reference Guide}
|
||||
* <li>RFC 5280: Internet X.509 Public Key Infrastructure Certificate and
|
||||
* Certificate Revocation List (CRL) Profile
|
||||
* <li>RFC 2560: X.509 Internet Public Key Infrastructure Online Certificate
|
||||
* Status Protocol - OCSP
|
||||
* <li><a href="{@docRoot}/../specs/security/standard-names.html">
|
||||
* <b>Java™ Security Standard Algorithm Names Specification
|
||||
* <b>Java Security Standard Algorithm Names Specification
|
||||
* </b></a></li>
|
||||
* </ul>
|
||||
*
|
||||
|
@ -50,12 +49,7 @@
|
|||
* <ul>
|
||||
* <li><a href="http://www.ietf.org/rfc/rfc5280.txt">
|
||||
* http://www.ietf.org/rfc/rfc5280.txt</a>
|
||||
* <li><a href=
|
||||
* "{@docRoot}/../technotes/guides/security/certpath/CertPathProgGuide.html">
|
||||
* <b>Java™
|
||||
* PKI Programmer's Guide</b></a>
|
||||
* <li><a href="{@docRoot}/../technotes/guides/security/cert3.html">
|
||||
* <b>X.509 Certificates and Certificate Revocation Lists (CRLs)</b></a>
|
||||
* <li> {@extLink security_guide_pki Java PKI Programmer's Guide}
|
||||
* </ul>
|
||||
*
|
||||
* @since 1.2
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 1998, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1998, 2017, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
|
@ -42,11 +42,10 @@
|
|||
* {@code Key} classes for hardware devices, please refer
|
||||
* to these cryptographic provider developer guides:
|
||||
* <ul>
|
||||
* <li><a href=
|
||||
* "{@docRoot}/../technotes/guides/security/crypto/HowToImplAProvider.html">
|
||||
* <b>How to Implement a Provider for the
|
||||
* Java™ Cryptography Architecture
|
||||
* </b></a></li>
|
||||
* <li>
|
||||
* {@extLink security_guide_impl_provider
|
||||
* How to Implement a Provider in the Java Cryptography Architecture}
|
||||
* </li>
|
||||
* </ul>
|
||||
*
|
||||
* <h2>Package Specification</h2>
|
||||
|
@ -61,12 +60,8 @@
|
|||
*
|
||||
* For further documentation, please see:
|
||||
* <ul>
|
||||
* <li>
|
||||
* <a href=
|
||||
* "{@docRoot}/../technotes/guides/security/crypto/CryptoSpec.html">
|
||||
* <b>Java™
|
||||
* Cryptography Architecture API Specification and Reference
|
||||
* </b></a></li>
|
||||
* <li> {extLink security_guide_jca
|
||||
* Java Cryptography Architecture Reference Guide}</li>
|
||||
* </ul>
|
||||
*
|
||||
* @since 1.1
|
||||
|
|
|
@ -46,63 +46,36 @@
|
|||
* <h2>Package Specification</h2>
|
||||
*
|
||||
* <ul>
|
||||
* <li><a href="{@docRoot}/../technotes/guides/security/crypto/CryptoSpec.html">
|
||||
* <b>Java™
|
||||
* Cryptography Architecture (JCA) Reference Guide</b></a></li>
|
||||
* <li> {@extLink security_guide_jca
|
||||
* Java Cryptography Architecture (JCA) Reference Guide}</li>
|
||||
*
|
||||
* <li>PKCS #8: Private-Key Information Syntax Standard, Version 1.2,
|
||||
* November 1993</li>
|
||||
*
|
||||
* <li><a href="{@docRoot}/../specs/security/standard-names.html">
|
||||
* <b>Java™ Security Standard Algorithm Names Specification
|
||||
* </b></a></li>
|
||||
* Java Security Standard Algorithm Names Specification
|
||||
* </a></li>
|
||||
* </ul>
|
||||
*
|
||||
* <h2>Related Documentation</h2>
|
||||
*
|
||||
* For further documentation, please see:
|
||||
* <ul>
|
||||
* <li><a href=
|
||||
* "{@docRoot}/../technotes/guides/security/spec/security-spec.doc.html">
|
||||
* <b>Java™
|
||||
* SE Platform Security Architecture</b></a></li>
|
||||
* <li> {@extLink security_guide_overview
|
||||
* Java Security Overview} </li>
|
||||
*
|
||||
* <li><a href=
|
||||
* "{@docRoot}/../technotes/guides/security/crypto/HowToImplAProvider.html">
|
||||
* <b>How to Implement a Provider in the
|
||||
* Java™ Cryptography Architecture
|
||||
* </b></a></li>
|
||||
* <li> {@extLink security_guide_impl_provider
|
||||
* How to Implement a Provider in the Java Cryptography Architecture}</li>
|
||||
*
|
||||
* <li><a href=
|
||||
* "{@docRoot}/../technotes/guides/security/PolicyFiles.html"><b>
|
||||
* Default Policy Implementation and Policy File Syntax
|
||||
* </b></a></li>
|
||||
* <li> {@extLink security_guide_default_policy
|
||||
* Default Policy Implementation and Policy File Syntax}</li>
|
||||
*
|
||||
* <li><a href=
|
||||
* "{@docRoot}/../technotes/guides/security/permissions.html"><b>
|
||||
* Permissions in the
|
||||
* Java™ SE Development Kit (JDK)
|
||||
* </b></a></li>
|
||||
* <li> {@extLink security_guide_permissions
|
||||
* Permissions in the Java Development Kit (JDK)}</li>
|
||||
*
|
||||
* <li><a href=
|
||||
* "{@docRoot}/../technotes/guides/security/SecurityToolsSummary.html"><b>
|
||||
* Summary of Tools for
|
||||
* Java™ Platform Security
|
||||
* </b></a></li>
|
||||
*
|
||||
* <li><b>keytool</b>
|
||||
* (<a href="{@docRoot}/../technotes/tools/unix/keytool.html">
|
||||
* for Solaris/Linux</a>)
|
||||
* (<a href="{@docRoot}/../technotes/tools/windows/keytool.html">
|
||||
* for Windows</a>)
|
||||
* </li>
|
||||
*
|
||||
* <li><b>jarsigner</b>
|
||||
* (<a href="{@docRoot}/../technotes/tools/unix/jarsigner.html">
|
||||
* for Solaris/Linux</a>)
|
||||
* (<a href="{@docRoot}/../technotes/tools/windows/jarsigner.html">
|
||||
* for Windows</a>)
|
||||
* </li>
|
||||
* <li> {@extLink security_guide_tools
|
||||
* Summary of Tools for Java Platform Security}
|
||||
* (for example {@code keytool} and {@code jarsigner}),</li>
|
||||
*
|
||||
* </ul>
|
||||
*
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 1998, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1998, 2017, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
|
@ -54,18 +54,10 @@
|
|||
* For documentation that includes information about algorithm parameter
|
||||
* and key specifications, please see:
|
||||
* <ul>
|
||||
* <li>
|
||||
* <a href=
|
||||
* "{@docRoot}/../technotes/guides/security/crypto/CryptoSpec.html">
|
||||
* <b>Java™
|
||||
* Cryptography Architecture API Specification and Reference
|
||||
* </b></a></li>
|
||||
* <li>
|
||||
* <a href=
|
||||
* "{@docRoot}/../technotes/guides/security/crypto/HowToImplAProvider.html">
|
||||
* <b>How to Implement a Provider for the
|
||||
* Java™ Cryptography Architecture
|
||||
* </b></a></li>
|
||||
* <li> {@extLink security_guide_jca
|
||||
* Java Cryptography Architecture (JCA) Reference Guide}</li>
|
||||
* <li> {@extLink security_guide_impl_provider
|
||||
* How to Implement a Provider in the Java Cryptography Architecture}</li>
|
||||
* </ul>
|
||||
*
|
||||
* @since 1.2
|
||||
|
|
|
@ -72,24 +72,24 @@ package java.util;
|
|||
* </tr>
|
||||
* <tr>
|
||||
* <td><b>Insert</b></td>
|
||||
* <td>{@link Deque#addFirst addFirst(e)}</td>
|
||||
* <td>{@link Deque#offerFirst offerFirst(e)}</td>
|
||||
* <td>{@link Deque#addLast addLast(e)}</td>
|
||||
* <td>{@link Deque#offerLast offerLast(e)}</td>
|
||||
* <td>{@link #addFirst(Object) addFirst(e)}</td>
|
||||
* <td>{@link #offerFirst(Object) offerFirst(e)}</td>
|
||||
* <td>{@link #addLast(Object) addLast(e)}</td>
|
||||
* <td>{@link #offerLast(Object) offerLast(e)}</td>
|
||||
* </tr>
|
||||
* <tr>
|
||||
* <td><b>Remove</b></td>
|
||||
* <td>{@link Deque#removeFirst removeFirst()}</td>
|
||||
* <td>{@link Deque#pollFirst pollFirst()}</td>
|
||||
* <td>{@link Deque#removeLast removeLast()}</td>
|
||||
* <td>{@link Deque#pollLast pollLast()}</td>
|
||||
* <td>{@link #removeFirst() removeFirst()}</td>
|
||||
* <td>{@link #pollFirst() pollFirst()}</td>
|
||||
* <td>{@link #removeLast() removeLast()}</td>
|
||||
* <td>{@link #pollLast() pollLast()}</td>
|
||||
* </tr>
|
||||
* <tr>
|
||||
* <td><b>Examine</b></td>
|
||||
* <td>{@link Deque#getFirst getFirst()}</td>
|
||||
* <td>{@link Deque#peekFirst peekFirst()}</td>
|
||||
* <td>{@link Deque#getLast getLast()}</td>
|
||||
* <td>{@link Deque#peekLast peekLast()}</td>
|
||||
* <td>{@link #getFirst() getFirst()}</td>
|
||||
* <td>{@link #peekFirst() peekFirst()}</td>
|
||||
* <td>{@link #getLast() getLast()}</td>
|
||||
* <td>{@link #peekLast() peekLast()}</td>
|
||||
* </tr>
|
||||
* </table>
|
||||
*
|
||||
|
@ -106,28 +106,28 @@ package java.util;
|
|||
* <td style="text-align:center"> <b>Equivalent {@code Deque} Method</b></td>
|
||||
* </tr>
|
||||
* <tr>
|
||||
* <td>{@link java.util.Queue#add add(e)}</td>
|
||||
* <td>{@link #addLast addLast(e)}</td>
|
||||
* <td>{@link #add(Object) add(e)}</td>
|
||||
* <td>{@link #addLast(Object) addLast(e)}</td>
|
||||
* </tr>
|
||||
* <tr>
|
||||
* <td>{@link java.util.Queue#offer offer(e)}</td>
|
||||
* <td>{@link #offerLast offerLast(e)}</td>
|
||||
* <td>{@link #offer(Object) offer(e)}</td>
|
||||
* <td>{@link #offerLast(Object) offerLast(e)}</td>
|
||||
* </tr>
|
||||
* <tr>
|
||||
* <td>{@link java.util.Queue#remove remove()}</td>
|
||||
* <td>{@link #removeFirst removeFirst()}</td>
|
||||
* <td>{@link #remove() remove()}</td>
|
||||
* <td>{@link #removeFirst() removeFirst()}</td>
|
||||
* </tr>
|
||||
* <tr>
|
||||
* <td>{@link java.util.Queue#poll poll()}</td>
|
||||
* <td>{@link #pollFirst pollFirst()}</td>
|
||||
* <td>{@link #poll() poll()}</td>
|
||||
* <td>{@link #pollFirst() pollFirst()}</td>
|
||||
* </tr>
|
||||
* <tr>
|
||||
* <td>{@link java.util.Queue#element element()}</td>
|
||||
* <td>{@link #getFirst getFirst()}</td>
|
||||
* <td>{@link #element() element()}</td>
|
||||
* <td>{@link #getFirst() getFirst()}</td>
|
||||
* </tr>
|
||||
* <tr>
|
||||
* <td>{@link java.util.Queue#peek peek()}</td>
|
||||
* <td>{@link #peek peekFirst()}</td>
|
||||
* <td>{@link #peek() peek()}</td>
|
||||
* <td>{@link #peekFirst() peekFirst()}</td>
|
||||
* </tr>
|
||||
* </table>
|
||||
*
|
||||
|
@ -144,16 +144,16 @@ package java.util;
|
|||
* <td style="text-align:center"> <b>Equivalent {@code Deque} Method</b></td>
|
||||
* </tr>
|
||||
* <tr>
|
||||
* <td>{@link #push push(e)}</td>
|
||||
* <td>{@link #addFirst addFirst(e)}</td>
|
||||
* <td>{@link #push(Object) push(e)}</td>
|
||||
* <td>{@link #addFirst(Object) addFirst(e)}</td>
|
||||
* </tr>
|
||||
* <tr>
|
||||
* <td>{@link #pop pop()}</td>
|
||||
* <td>{@link #removeFirst removeFirst()}</td>
|
||||
* <td>{@link #pop() pop()}</td>
|
||||
* <td>{@link #removeFirst() removeFirst()}</td>
|
||||
* </tr>
|
||||
* <tr>
|
||||
* <td>{@link #peek peek()}</td>
|
||||
* <td>{@link #peekFirst peekFirst()}</td>
|
||||
* <td>{@link #peek() peek()}</td>
|
||||
* <td>{@link #peekFirst() peekFirst()}</td>
|
||||
* </tr>
|
||||
* </table>
|
||||
*
|
||||
|
@ -430,8 +430,8 @@ public interface Deque<E> extends Queue<E> {
|
|||
/**
|
||||
* Retrieves and removes the head of the queue represented by this deque
|
||||
* (in other words, the first element of this deque).
|
||||
* This method differs from {@link #poll poll} only in that it throws an
|
||||
* exception if this deque is empty.
|
||||
* This method differs from {@link #poll() poll()} only in that it
|
||||
* throws an exception if this deque is empty.
|
||||
*
|
||||
* <p>This method is equivalent to {@link #removeFirst()}.
|
||||
*
|
||||
|
@ -477,6 +477,31 @@ public interface Deque<E> extends Queue<E> {
|
|||
*/
|
||||
E peek();
|
||||
|
||||
/**
|
||||
* Adds all of the elements in the specified collection at the end
|
||||
* of this deque, as if by calling {@link #addLast} on each one,
|
||||
* in the order that they are returned by the collection's iterator.
|
||||
*
|
||||
* <p>When using a capacity-restricted deque, it is generally preferable
|
||||
* to call {@link #offer(Object) offer} separately on each element.
|
||||
*
|
||||
* <p>An exception encountered while trying to add an element may result
|
||||
* in only some of the elements having been successfully added when
|
||||
* the associated exception is thrown.
|
||||
*
|
||||
* @param c the elements to be inserted into this deque
|
||||
* @return {@code true} if this deque changed as a result of the call
|
||||
* @throws IllegalStateException if not all the elements can be added at
|
||||
* this time due to insertion restrictions
|
||||
* @throws ClassCastException if the class of an element of the specified
|
||||
* collection prevents it from being added to this deque
|
||||
* @throws NullPointerException if the specified collection contains a
|
||||
* null element and this deque does not permit null elements,
|
||||
* or if the specified collection is null
|
||||
* @throws IllegalArgumentException if some property of an element of the
|
||||
* specified collection prevents it from being added to this deque
|
||||
*/
|
||||
boolean addAll(Collection<? extends E> c);
|
||||
|
||||
// *** Stack methods ***
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2005, 2006, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2005, 2017, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
|
@ -27,33 +27,12 @@ package java.util;
|
|||
|
||||
|
||||
/**
|
||||
* Error thrown when something goes wrong while loading a service provider.
|
||||
*
|
||||
* <p> This error will be thrown in the following situations:
|
||||
*
|
||||
* <ul>
|
||||
*
|
||||
* <li> The format of a provider-configuration file violates the <a
|
||||
* href="ServiceLoader.html#format">specification</a>; </li>
|
||||
*
|
||||
* <li> An {@link java.io.IOException IOException} occurs while reading a
|
||||
* provider-configuration file; </li>
|
||||
*
|
||||
* <li> A concrete provider class named in a provider-configuration file
|
||||
* cannot be found; </li>
|
||||
*
|
||||
* <li> A concrete provider class is not a subclass of the service class;
|
||||
* </li>
|
||||
*
|
||||
* <li> A concrete provider class cannot be instantiated; or
|
||||
*
|
||||
* <li> Some other kind of error occurs. </li>
|
||||
*
|
||||
* </ul>
|
||||
*
|
||||
* Error thrown when something goes wrong while locating, loading, or
|
||||
* instantiating a service provider.
|
||||
*
|
||||
* @author Mark Reinhold
|
||||
* @since 1.6
|
||||
* @see ServiceLoader
|
||||
*/
|
||||
|
||||
public class ServiceConfigurationError
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -249,7 +249,8 @@ public class AtomicInteger extends Number implements java.io.Serializable {
|
|||
}
|
||||
|
||||
/**
|
||||
* Atomically updates the current value with the results of
|
||||
* Atomically updates (with memory effects as specified by {@link
|
||||
* VarHandle#compareAndSet}) the current value with the results of
|
||||
* applying the given function, returning the previous value. The
|
||||
* function should be side-effect-free, since it may be re-applied
|
||||
* when attempted updates fail due to contention among threads.
|
||||
|
@ -270,7 +271,8 @@ public class AtomicInteger extends Number implements java.io.Serializable {
|
|||
}
|
||||
|
||||
/**
|
||||
* Atomically updates the current value with the results of
|
||||
* Atomically updates (with memory effects as specified by {@link
|
||||
* VarHandle#compareAndSet}) the current value with the results of
|
||||
* applying the given function, returning the updated value. The
|
||||
* function should be side-effect-free, since it may be re-applied
|
||||
* when attempted updates fail due to contention among threads.
|
||||
|
@ -291,13 +293,14 @@ public class AtomicInteger extends Number implements java.io.Serializable {
|
|||
}
|
||||
|
||||
/**
|
||||
* Atomically updates the current value with the results of
|
||||
* Atomically updates (with memory effects as specified by {@link
|
||||
* VarHandle#compareAndSet}) the current value with the results of
|
||||
* applying the given function to the current and given values,
|
||||
* returning the previous value. The function should be
|
||||
* side-effect-free, since it may be re-applied when attempted
|
||||
* updates fail due to contention among threads. The function
|
||||
* is applied with the current value as its first argument,
|
||||
* and the given update as the second argument.
|
||||
* updates fail due to contention among threads. The function is
|
||||
* applied with the current value as its first argument, and the
|
||||
* given update as the second argument.
|
||||
*
|
||||
* @param x the update value
|
||||
* @param accumulatorFunction a side-effect-free function of two arguments
|
||||
|
@ -317,13 +320,14 @@ public class AtomicInteger extends Number implements java.io.Serializable {
|
|||
}
|
||||
|
||||
/**
|
||||
* Atomically updates the current value with the results of
|
||||
* Atomically updates (with memory effects as specified by {@link
|
||||
* VarHandle#compareAndSet}) the current value with the results of
|
||||
* applying the given function to the current and given values,
|
||||
* returning the updated value. The function should be
|
||||
* side-effect-free, since it may be re-applied when attempted
|
||||
* updates fail due to contention among threads. The function
|
||||
* is applied with the current value as its first argument,
|
||||
* and the given update as the second argument.
|
||||
* updates fail due to contention among threads. The function is
|
||||
* applied with the current value as its first argument, and the
|
||||
* given update as the second argument.
|
||||
*
|
||||
* @param x the update value
|
||||
* @param accumulatorFunction a side-effect-free function of two arguments
|
||||
|
|
|
@ -260,10 +260,12 @@ public class AtomicIntegerArray implements java.io.Serializable {
|
|||
}
|
||||
|
||||
/**
|
||||
* Atomically updates the element at index {@code i} with the results
|
||||
* of applying the given function, returning the previous value. The
|
||||
* function should be side-effect-free, since it may be re-applied
|
||||
* when attempted updates fail due to contention among threads.
|
||||
* Atomically updates (with memory effects as specified by {@link
|
||||
* VarHandle#compareAndSet}) the element at index {@code i} with
|
||||
* the results of applying the given function, returning the
|
||||
* previous value. The function should be side-effect-free, since
|
||||
* it may be re-applied when attempted updates fail due to
|
||||
* contention among threads.
|
||||
*
|
||||
* @param i the index
|
||||
* @param updateFunction a side-effect-free function
|
||||
|
@ -282,10 +284,12 @@ public class AtomicIntegerArray implements java.io.Serializable {
|
|||
}
|
||||
|
||||
/**
|
||||
* Atomically updates the element at index {@code i} with the results
|
||||
* of applying the given function, returning the updated value. The
|
||||
* function should be side-effect-free, since it may be re-applied
|
||||
* when attempted updates fail due to contention among threads.
|
||||
* Atomically updates (with memory effects as specified by {@link
|
||||
* VarHandle#compareAndSet}) the element at index {@code i} with
|
||||
* the results of applying the given function, returning the
|
||||
* updated value. The function should be side-effect-free, since it
|
||||
* may be re-applied when attempted updates fail due to contention
|
||||
* among threads.
|
||||
*
|
||||
* @param i the index
|
||||
* @param updateFunction a side-effect-free function
|
||||
|
@ -304,10 +308,11 @@ public class AtomicIntegerArray implements java.io.Serializable {
|
|||
}
|
||||
|
||||
/**
|
||||
* Atomically updates the element at index {@code i} with the
|
||||
* results of applying the given function to the current and given
|
||||
* values, returning the previous value. The function should be
|
||||
* side-effect-free, since it may be re-applied when attempted
|
||||
* Atomically updates (with memory effects as specified by {@link
|
||||
* VarHandle#compareAndSet}) the element at index {@code i} with
|
||||
* the results of applying the given function to the current and
|
||||
* given values, returning the previous value. The function should
|
||||
* be side-effect-free, since it may be re-applied when attempted
|
||||
* updates fail due to contention among threads. The function is
|
||||
* applied with the current value of the element at index {@code i}
|
||||
* as its first argument, and the given update as the second
|
||||
|
@ -332,10 +337,11 @@ public class AtomicIntegerArray implements java.io.Serializable {
|
|||
}
|
||||
|
||||
/**
|
||||
* Atomically updates the element at index {@code i} with the
|
||||
* results of applying the given function to the current and given
|
||||
* values, returning the updated value. The function should be
|
||||
* side-effect-free, since it may be re-applied when attempted
|
||||
* Atomically updates (with memory effects as specified by {@link
|
||||
* VarHandle#compareAndSet}) the element at index {@code i} with
|
||||
* the results of applying the given function to the current and
|
||||
* given values, returning the updated value. The function should
|
||||
* be side-effect-free, since it may be re-applied when attempted
|
||||
* updates fail due to contention among threads. The function is
|
||||
* applied with the current value of the element at index {@code i}
|
||||
* as its first argument, and the given update as the second
|
||||
|
|
|
@ -46,6 +46,7 @@ import java.util.function.IntUnaryOperator;
|
|||
import jdk.internal.misc.Unsafe;
|
||||
import jdk.internal.reflect.CallerSensitive;
|
||||
import jdk.internal.reflect.Reflection;
|
||||
import java.lang.invoke.VarHandle;
|
||||
|
||||
/**
|
||||
* A reflection-based utility that enables atomic updates to
|
||||
|
@ -275,10 +276,12 @@ public abstract class AtomicIntegerFieldUpdater<T> {
|
|||
}
|
||||
|
||||
/**
|
||||
* Atomically updates the field of the given object managed by this updater
|
||||
* with the results of applying the given function, returning the previous
|
||||
* value. The function should be side-effect-free, since it may be
|
||||
* re-applied when attempted updates fail due to contention among threads.
|
||||
* Atomically updates (with memory effects as specified by {@link
|
||||
* VarHandle#compareAndSet}) the field of the given object managed
|
||||
* by this updater with the results of applying the given
|
||||
* function, returning the previous value. The function should be
|
||||
* side-effect-free, since it may be re-applied when attempted
|
||||
* updates fail due to contention among threads.
|
||||
*
|
||||
* @param obj An object whose field to get and set
|
||||
* @param updateFunction a side-effect-free function
|
||||
|
@ -295,10 +298,12 @@ public abstract class AtomicIntegerFieldUpdater<T> {
|
|||
}
|
||||
|
||||
/**
|
||||
* Atomically updates the field of the given object managed by this updater
|
||||
* with the results of applying the given function, returning the updated
|
||||
* value. The function should be side-effect-free, since it may be
|
||||
* re-applied when attempted updates fail due to contention among threads.
|
||||
* Atomically updates (with memory effects as specified by {@link
|
||||
* VarHandle#compareAndSet}) the field of the given object managed
|
||||
* by this updater with the results of applying the given
|
||||
* function, returning the updated value. The function should be
|
||||
* side-effect-free, since it may be re-applied when attempted
|
||||
* updates fail due to contention among threads.
|
||||
*
|
||||
* @param obj An object whose field to get and set
|
||||
* @param updateFunction a side-effect-free function
|
||||
|
@ -315,13 +320,14 @@ public abstract class AtomicIntegerFieldUpdater<T> {
|
|||
}
|
||||
|
||||
/**
|
||||
* Atomically updates the field of the given object managed by this
|
||||
* updater with the results of applying the given function to the
|
||||
* current and given values, returning the previous value. The
|
||||
* function should be side-effect-free, since it may be re-applied
|
||||
* when attempted updates fail due to contention among threads. The
|
||||
* function is applied with the current value as its first argument,
|
||||
* and the given update as the second argument.
|
||||
* Atomically updates (with memory effects as specified by {@link
|
||||
* VarHandle#compareAndSet}) the field of the given object managed
|
||||
* by this updater with the results of applying the given function
|
||||
* to the current and given values, returning the previous value.
|
||||
* The function should be side-effect-free, since it may be
|
||||
* re-applied when attempted updates fail due to contention among
|
||||
* threads. The function is applied with the current value as its
|
||||
* first argument, and the given update as the second argument.
|
||||
*
|
||||
* @param obj An object whose field to get and set
|
||||
* @param x the update value
|
||||
|
@ -340,13 +346,14 @@ public abstract class AtomicIntegerFieldUpdater<T> {
|
|||
}
|
||||
|
||||
/**
|
||||
* Atomically updates the field of the given object managed by this
|
||||
* updater with the results of applying the given function to the
|
||||
* current and given values, returning the updated value. The
|
||||
* function should be side-effect-free, since it may be re-applied
|
||||
* when attempted updates fail due to contention among threads. The
|
||||
* function is applied with the current value as its first argument,
|
||||
* and the given update as the second argument.
|
||||
* Atomically updates (with memory effects as specified by {@link
|
||||
* VarHandle#compareAndSet}) the field of the given object managed
|
||||
* by this updater with the results of applying the given function
|
||||
* to the current and given values, returning the updated value.
|
||||
* The function should be side-effect-free, since it may be
|
||||
* re-applied when attempted updates fail due to contention among
|
||||
* threads. The function is applied with the current value as its
|
||||
* first argument, and the given update as the second argument.
|
||||
*
|
||||
* @param obj An object whose field to get and set
|
||||
* @param x the update value
|
||||
|
|
|
@ -118,8 +118,7 @@ public class AtomicLong extends Number implements java.io.Serializable {
|
|||
* @param newValue the new value
|
||||
*/
|
||||
public final void set(long newValue) {
|
||||
// Use putLongVolatile instead of ordinary volatile store when
|
||||
// using compareAndSetLong, for sake of some 32bit systems.
|
||||
// See JDK-8180620: Clarify VarHandle mixed-access subtleties
|
||||
U.putLongVolatile(this, VALUE, newValue);
|
||||
}
|
||||
|
||||
|
@ -265,7 +264,8 @@ public class AtomicLong extends Number implements java.io.Serializable {
|
|||
}
|
||||
|
||||
/**
|
||||
* Atomically updates the current value with the results of
|
||||
* Atomically updates (with memory effects as specified by {@link
|
||||
* VarHandle#compareAndSet}) the current value with the results of
|
||||
* applying the given function, returning the previous value. The
|
||||
* function should be side-effect-free, since it may be re-applied
|
||||
* when attempted updates fail due to contention among threads.
|
||||
|
@ -286,7 +286,8 @@ public class AtomicLong extends Number implements java.io.Serializable {
|
|||
}
|
||||
|
||||
/**
|
||||
* Atomically updates the current value with the results of
|
||||
* Atomically updates (with memory effects as specified by {@link
|
||||
* VarHandle#compareAndSet}) the current value with the results of
|
||||
* applying the given function, returning the updated value. The
|
||||
* function should be side-effect-free, since it may be re-applied
|
||||
* when attempted updates fail due to contention among threads.
|
||||
|
@ -307,13 +308,14 @@ public class AtomicLong extends Number implements java.io.Serializable {
|
|||
}
|
||||
|
||||
/**
|
||||
* Atomically updates the current value with the results of
|
||||
* Atomically updates (with memory effects as specified by {@link
|
||||
* VarHandle#compareAndSet}) the current value with the results of
|
||||
* applying the given function to the current and given values,
|
||||
* returning the previous value. The function should be
|
||||
* side-effect-free, since it may be re-applied when attempted
|
||||
* updates fail due to contention among threads. The function
|
||||
* is applied with the current value as its first argument,
|
||||
* and the given update as the second argument.
|
||||
* updates fail due to contention among threads. The function is
|
||||
* applied with the current value as its first argument, and the
|
||||
* given update as the second argument.
|
||||
*
|
||||
* @param x the update value
|
||||
* @param accumulatorFunction a side-effect-free function of two arguments
|
||||
|
@ -333,13 +335,14 @@ public class AtomicLong extends Number implements java.io.Serializable {
|
|||
}
|
||||
|
||||
/**
|
||||
* Atomically updates the current value with the results of
|
||||
* Atomically updates (with memory effects as specified by {@link
|
||||
* VarHandle#compareAndSet}) the current value with the results of
|
||||
* applying the given function to the current and given values,
|
||||
* returning the updated value. The function should be
|
||||
* side-effect-free, since it may be re-applied when attempted
|
||||
* updates fail due to contention among threads. The function
|
||||
* is applied with the current value as its first argument,
|
||||
* and the given update as the second argument.
|
||||
* updates fail due to contention among threads. The function is
|
||||
* applied with the current value as its first argument, and the
|
||||
* given update as the second argument.
|
||||
*
|
||||
* @param x the update value
|
||||
* @param accumulatorFunction a side-effect-free function of two arguments
|
||||
|
|
|
@ -260,10 +260,12 @@ public class AtomicLongArray implements java.io.Serializable {
|
|||
}
|
||||
|
||||
/**
|
||||
* Atomically updates the element at index {@code i} with the results
|
||||
* of applying the given function, returning the previous value. The
|
||||
* function should be side-effect-free, since it may be re-applied
|
||||
* when attempted updates fail due to contention among threads.
|
||||
* Atomically updates (with memory effects as specified by {@link
|
||||
* VarHandle#compareAndSet}) the element at index {@code i} with
|
||||
* the results of applying the given function, returning the
|
||||
* previous value. The function should be side-effect-free, since
|
||||
* it may be re-applied when attempted updates fail due to
|
||||
* contention among threads.
|
||||
*
|
||||
* @param i the index
|
||||
* @param updateFunction a side-effect-free function
|
||||
|
@ -282,10 +284,12 @@ public class AtomicLongArray implements java.io.Serializable {
|
|||
}
|
||||
|
||||
/**
|
||||
* Atomically updates the element at index {@code i} with the results
|
||||
* of applying the given function, returning the updated value. The
|
||||
* function should be side-effect-free, since it may be re-applied
|
||||
* when attempted updates fail due to contention among threads.
|
||||
* Atomically updates (with memory effects as specified by {@link
|
||||
* VarHandle#compareAndSet}) the element at index {@code i} with
|
||||
* the results of applying the given function, returning the
|
||||
* updated value. The function should be side-effect-free, since it
|
||||
* may be re-applied when attempted updates fail due to contention
|
||||
* among threads.
|
||||
*
|
||||
* @param i the index
|
||||
* @param updateFunction a side-effect-free function
|
||||
|
@ -304,10 +308,11 @@ public class AtomicLongArray implements java.io.Serializable {
|
|||
}
|
||||
|
||||
/**
|
||||
* Atomically updates the element at index {@code i} with the
|
||||
* results of applying the given function to the current and given
|
||||
* values, returning the previous value. The function should be
|
||||
* side-effect-free, since it may be re-applied when attempted
|
||||
* Atomically updates (with memory effects as specified by {@link
|
||||
* VarHandle#compareAndSet}) the element at index {@code i} with
|
||||
* the results of applying the given function to the current and
|
||||
* given values, returning the previous value. The function should
|
||||
* be side-effect-free, since it may be re-applied when attempted
|
||||
* updates fail due to contention among threads. The function is
|
||||
* applied with the current value of the element at index {@code i}
|
||||
* as its first argument, and the given update as the second
|
||||
|
@ -332,10 +337,11 @@ public class AtomicLongArray implements java.io.Serializable {
|
|||
}
|
||||
|
||||
/**
|
||||
* Atomically updates the element at index {@code i} with the
|
||||
* results of applying the given function to the current and given
|
||||
* values, returning the updated value. The function should be
|
||||
* side-effect-free, since it may be re-applied when attempted
|
||||
* Atomically updates (with memory effects as specified by {@link
|
||||
* VarHandle#compareAndSet}) the element at index {@code i} with
|
||||
* the results of applying the given function to the current and
|
||||
* given values, returning the updated value. The function should
|
||||
* be side-effect-free, since it may be re-applied when attempted
|
||||
* updates fail due to contention among threads. The function is
|
||||
* applied with the current value of the element at index {@code i}
|
||||
* as its first argument, and the given update as the second
|
||||
|
|
|
@ -46,6 +46,7 @@ import java.util.function.LongUnaryOperator;
|
|||
import jdk.internal.misc.Unsafe;
|
||||
import jdk.internal.reflect.CallerSensitive;
|
||||
import jdk.internal.reflect.Reflection;
|
||||
import java.lang.invoke.VarHandle;
|
||||
|
||||
/**
|
||||
* A reflection-based utility that enables atomic updates to
|
||||
|
@ -278,10 +279,12 @@ public abstract class AtomicLongFieldUpdater<T> {
|
|||
}
|
||||
|
||||
/**
|
||||
* Atomically updates the field of the given object managed by this updater
|
||||
* with the results of applying the given function, returning the previous
|
||||
* value. The function should be side-effect-free, since it may be
|
||||
* re-applied when attempted updates fail due to contention among threads.
|
||||
* Atomically updates (with memory effects as specified by {@link
|
||||
* VarHandle#compareAndSet}) the field of the given object managed
|
||||
* by this updater with the results of applying the given
|
||||
* function, returning the previous value. The function should be
|
||||
* side-effect-free, since it may be re-applied when attempted
|
||||
* updates fail due to contention among threads.
|
||||
*
|
||||
* @param obj An object whose field to get and set
|
||||
* @param updateFunction a side-effect-free function
|
||||
|
@ -298,10 +301,12 @@ public abstract class AtomicLongFieldUpdater<T> {
|
|||
}
|
||||
|
||||
/**
|
||||
* Atomically updates the field of the given object managed by this updater
|
||||
* with the results of applying the given function, returning the updated
|
||||
* value. The function should be side-effect-free, since it may be
|
||||
* re-applied when attempted updates fail due to contention among threads.
|
||||
* Atomically updates (with memory effects as specified by {@link
|
||||
* VarHandle#compareAndSet}) the field of the given object managed
|
||||
* by this updater with the results of applying the given
|
||||
* function, returning the updated value. The function should be
|
||||
* side-effect-free, since it may be re-applied when attempted
|
||||
* updates fail due to contention among threads.
|
||||
*
|
||||
* @param obj An object whose field to get and set
|
||||
* @param updateFunction a side-effect-free function
|
||||
|
@ -318,13 +323,14 @@ public abstract class AtomicLongFieldUpdater<T> {
|
|||
}
|
||||
|
||||
/**
|
||||
* Atomically updates the field of the given object managed by this
|
||||
* updater with the results of applying the given function to the
|
||||
* current and given values, returning the previous value. The
|
||||
* function should be side-effect-free, since it may be re-applied
|
||||
* when attempted updates fail due to contention among threads. The
|
||||
* function is applied with the current value as its first argument,
|
||||
* and the given update as the second argument.
|
||||
* Atomically updates (with memory effects as specified by {@link
|
||||
* VarHandle#compareAndSet}) the field of the given object managed
|
||||
* by this updater with the results of applying the given function
|
||||
* to the current and given values, returning the previous value.
|
||||
* The function should be side-effect-free, since it may be
|
||||
* re-applied when attempted updates fail due to contention among
|
||||
* threads. The function is applied with the current value as its
|
||||
* first argument, and the given update as the second argument.
|
||||
*
|
||||
* @param obj An object whose field to get and set
|
||||
* @param x the update value
|
||||
|
@ -343,13 +349,14 @@ public abstract class AtomicLongFieldUpdater<T> {
|
|||
}
|
||||
|
||||
/**
|
||||
* Atomically updates the field of the given object managed by this
|
||||
* updater with the results of applying the given function to the
|
||||
* current and given values, returning the updated value. The
|
||||
* function should be side-effect-free, since it may be re-applied
|
||||
* when attempted updates fail due to contention among threads. The
|
||||
* function is applied with the current value as its first argument,
|
||||
* and the given update as the second argument.
|
||||
* Atomically updates (with memory effects as specified by {@link
|
||||
* VarHandle#compareAndSet}) the field of the given object managed
|
||||
* by this updater with the results of applying the given function
|
||||
* to the current and given values, returning the updated value.
|
||||
* The function should be side-effect-free, since it may be
|
||||
* re-applied when attempted updates fail due to contention among
|
||||
* threads. The function is applied with the current value as its
|
||||
* first argument, and the given update as the second argument.
|
||||
*
|
||||
* @param obj An object whose field to get and set
|
||||
* @param x the update value
|
||||
|
|
|
@ -170,7 +170,8 @@ public class AtomicReference<V> implements java.io.Serializable {
|
|||
}
|
||||
|
||||
/**
|
||||
* Atomically updates the current value with the results of
|
||||
* Atomically updates (with memory effects as specified by {@link
|
||||
* VarHandle#compareAndSet}) the current value with the results of
|
||||
* applying the given function, returning the previous value. The
|
||||
* function should be side-effect-free, since it may be re-applied
|
||||
* when attempted updates fail due to contention among threads.
|
||||
|
@ -191,7 +192,8 @@ public class AtomicReference<V> implements java.io.Serializable {
|
|||
}
|
||||
|
||||
/**
|
||||
* Atomically updates the current value with the results of
|
||||
* Atomically updates (with memory effects as specified by {@link
|
||||
* VarHandle#compareAndSet}) the current value with the results of
|
||||
* applying the given function, returning the updated value. The
|
||||
* function should be side-effect-free, since it may be re-applied
|
||||
* when attempted updates fail due to contention among threads.
|
||||
|
@ -212,13 +214,14 @@ public class AtomicReference<V> implements java.io.Serializable {
|
|||
}
|
||||
|
||||
/**
|
||||
* Atomically updates the current value with the results of
|
||||
* Atomically updates (with memory effects as specified by {@link
|
||||
* VarHandle#compareAndSet}) the current value with the results of
|
||||
* applying the given function to the current and given values,
|
||||
* returning the previous value. The function should be
|
||||
* side-effect-free, since it may be re-applied when attempted
|
||||
* updates fail due to contention among threads. The function
|
||||
* is applied with the current value as its first argument,
|
||||
* and the given update as the second argument.
|
||||
* updates fail due to contention among threads. The function is
|
||||
* applied with the current value as its first argument, and the
|
||||
* given update as the second argument.
|
||||
*
|
||||
* @param x the update value
|
||||
* @param accumulatorFunction a side-effect-free function of two arguments
|
||||
|
@ -238,13 +241,14 @@ public class AtomicReference<V> implements java.io.Serializable {
|
|||
}
|
||||
|
||||
/**
|
||||
* Atomically updates the current value with the results of
|
||||
* Atomically updates (with memory effects as specified by {@link
|
||||
* VarHandle#compareAndSet}) the current value with the results of
|
||||
* applying the given function to the current and given values,
|
||||
* returning the updated value. The function should be
|
||||
* side-effect-free, since it may be re-applied when attempted
|
||||
* updates fail due to contention among threads. The function
|
||||
* is applied with the current value as its first argument,
|
||||
* and the given update as the second argument.
|
||||
* updates fail due to contention among threads. The function is
|
||||
* applied with the current value as its first argument, and the
|
||||
* given update as the second argument.
|
||||
*
|
||||
* @param x the update value
|
||||
* @param accumulatorFunction a side-effect-free function of two arguments
|
||||
|
|
|
@ -190,10 +190,12 @@ public class AtomicReferenceArray<E> implements java.io.Serializable {
|
|||
}
|
||||
|
||||
/**
|
||||
* Atomically updates the element at index {@code i} with the results
|
||||
* of applying the given function, returning the previous value. The
|
||||
* function should be side-effect-free, since it may be re-applied
|
||||
* when attempted updates fail due to contention among threads.
|
||||
* Atomically updates (with memory effects as specified by {@link
|
||||
* VarHandle#compareAndSet}) the element at index {@code i} with
|
||||
* the results of applying the given function, returning the
|
||||
* previous value. The function should be side-effect-free, since
|
||||
* it may be re-applied when attempted updates fail due to
|
||||
* contention among threads.
|
||||
*
|
||||
* @param i the index
|
||||
* @param updateFunction a side-effect-free function
|
||||
|
@ -212,10 +214,12 @@ public class AtomicReferenceArray<E> implements java.io.Serializable {
|
|||
}
|
||||
|
||||
/**
|
||||
* Atomically updates the element at index {@code i} with the results
|
||||
* of applying the given function, returning the updated value. The
|
||||
* function should be side-effect-free, since it may be re-applied
|
||||
* when attempted updates fail due to contention among threads.
|
||||
* Atomically updates (with memory effects as specified by {@link
|
||||
* VarHandle#compareAndSet}) the element at index {@code i} with
|
||||
* the results of applying the given function, returning the
|
||||
* updated value. The function should be side-effect-free, since it
|
||||
* may be re-applied when attempted updates fail due to contention
|
||||
* among threads.
|
||||
*
|
||||
* @param i the index
|
||||
* @param updateFunction a side-effect-free function
|
||||
|
@ -234,10 +238,11 @@ public class AtomicReferenceArray<E> implements java.io.Serializable {
|
|||
}
|
||||
|
||||
/**
|
||||
* Atomically updates the element at index {@code i} with the
|
||||
* results of applying the given function to the current and given
|
||||
* values, returning the previous value. The function should be
|
||||
* side-effect-free, since it may be re-applied when attempted
|
||||
* Atomically updates (with memory effects as specified by {@link
|
||||
* VarHandle#compareAndSet}) the element at index {@code i} with
|
||||
* the results of applying the given function to the current and
|
||||
* given values, returning the previous value. The function should
|
||||
* be side-effect-free, since it may be re-applied when attempted
|
||||
* updates fail due to contention among threads. The function is
|
||||
* applied with the current value of the element at index {@code i}
|
||||
* as its first argument, and the given update as the second
|
||||
|
@ -262,10 +267,11 @@ public class AtomicReferenceArray<E> implements java.io.Serializable {
|
|||
}
|
||||
|
||||
/**
|
||||
* Atomically updates the element at index {@code i} with the
|
||||
* results of applying the given function to the current and given
|
||||
* values, returning the updated value. The function should be
|
||||
* side-effect-free, since it may be re-applied when attempted
|
||||
* Atomically updates (with memory effects as specified by {@link
|
||||
* VarHandle#compareAndSet}) the element at index {@code i} with
|
||||
* the results of applying the given function to the current and
|
||||
* given values, returning the updated value. The function should
|
||||
* be side-effect-free, since it may be re-applied when attempted
|
||||
* updates fail due to contention among threads. The function is
|
||||
* applied with the current value of the element at index {@code i}
|
||||
* as its first argument, and the given update as the second
|
||||
|
|
|
@ -46,6 +46,7 @@ import java.util.function.UnaryOperator;
|
|||
import jdk.internal.misc.Unsafe;
|
||||
import jdk.internal.reflect.CallerSensitive;
|
||||
import jdk.internal.reflect.Reflection;
|
||||
import java.lang.invoke.VarHandle;
|
||||
|
||||
/**
|
||||
* A reflection-based utility that enables atomic updates to
|
||||
|
@ -199,10 +200,12 @@ public abstract class AtomicReferenceFieldUpdater<T,V> {
|
|||
}
|
||||
|
||||
/**
|
||||
* Atomically updates the field of the given object managed by this updater
|
||||
* with the results of applying the given function, returning the previous
|
||||
* value. The function should be side-effect-free, since it may be
|
||||
* re-applied when attempted updates fail due to contention among threads.
|
||||
* Atomically updates (with memory effects as specified by {@link
|
||||
* VarHandle#compareAndSet}) the field of the given object managed
|
||||
* by this updater with the results of applying the given
|
||||
* function, returning the previous value. The function should be
|
||||
* side-effect-free, since it may be re-applied when attempted
|
||||
* updates fail due to contention among threads.
|
||||
*
|
||||
* @param obj An object whose field to get and set
|
||||
* @param updateFunction a side-effect-free function
|
||||
|
@ -219,10 +222,12 @@ public abstract class AtomicReferenceFieldUpdater<T,V> {
|
|||
}
|
||||
|
||||
/**
|
||||
* Atomically updates the field of the given object managed by this updater
|
||||
* with the results of applying the given function, returning the updated
|
||||
* value. The function should be side-effect-free, since it may be
|
||||
* re-applied when attempted updates fail due to contention among threads.
|
||||
* Atomically updates (with memory effects as specified by {@link
|
||||
* VarHandle#compareAndSet}) the field of the given object managed
|
||||
* by this updater with the results of applying the given
|
||||
* function, returning the updated value. The function should be
|
||||
* side-effect-free, since it may be re-applied when attempted
|
||||
* updates fail due to contention among threads.
|
||||
*
|
||||
* @param obj An object whose field to get and set
|
||||
* @param updateFunction a side-effect-free function
|
||||
|
@ -239,13 +244,14 @@ public abstract class AtomicReferenceFieldUpdater<T,V> {
|
|||
}
|
||||
|
||||
/**
|
||||
* Atomically updates the field of the given object managed by this
|
||||
* updater with the results of applying the given function to the
|
||||
* current and given values, returning the previous value. The
|
||||
* function should be side-effect-free, since it may be re-applied
|
||||
* when attempted updates fail due to contention among threads. The
|
||||
* function is applied with the current value as its first argument,
|
||||
* and the given update as the second argument.
|
||||
* Atomically updates (with memory effects as specified by {@link
|
||||
* VarHandle#compareAndSet}) the field of the given object managed
|
||||
* by this updater with the results of applying the given function
|
||||
* to the current and given values, returning the previous value.
|
||||
* The function should be side-effect-free, since it may be
|
||||
* re-applied when attempted updates fail due to contention among
|
||||
* threads. The function is applied with the current value as its
|
||||
* first argument, and the given update as the second argument.
|
||||
*
|
||||
* @param obj An object whose field to get and set
|
||||
* @param x the update value
|
||||
|
@ -264,13 +270,14 @@ public abstract class AtomicReferenceFieldUpdater<T,V> {
|
|||
}
|
||||
|
||||
/**
|
||||
* Atomically updates the field of the given object managed by this
|
||||
* updater with the results of applying the given function to the
|
||||
* current and given values, returning the updated value. The
|
||||
* function should be side-effect-free, since it may be re-applied
|
||||
* when attempted updates fail due to contention among threads. The
|
||||
* function is applied with the current value as its first argument,
|
||||
* and the given update as the second argument.
|
||||
* Atomically updates (with memory effects as specified by {@link
|
||||
* VarHandle#compareAndSet}) the field of the given object managed
|
||||
* by this updater with the results of applying the given function
|
||||
* to the current and given values, returning the updated value.
|
||||
* The function should be side-effect-free, since it may be
|
||||
* re-applied when attempted updates fail due to contention among
|
||||
* threads. The function is applied with the current value as its
|
||||
* first argument, and the given update as the second argument.
|
||||
*
|
||||
* @param obj An object whose field to get and set
|
||||
* @param x the update value
|
||||
|
|
|
@ -0,0 +1,399 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
||||
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||
|
||||
<!--
|
||||
Copyright (c) 1998, 2017, Oracle and/or its affiliates. All rights reserved.
|
||||
DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
|
||||
This code is free software; you can redistribute it and/or modify it
|
||||
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.
|
||||
-->
|
||||
|
||||
<html lang="en-US" xmlns="http://www.w3.org/1999/xhtml" xml:lang=
|
||||
"en-US">
|
||||
<head>
|
||||
<title>Java Collections API Design FAQ</title>
|
||||
</head>
|
||||
<body>
|
||||
<h2>Java Collections API Design FAQ</h2>
|
||||
<!-- Body text begins here -->
|
||||
<hr />
|
||||
This document answers frequently asked questions concerning the
|
||||
design of the Java collections framework. It is derived from the
|
||||
large volume of traffic on the collections-comments alias. It
|
||||
serves as a design rationale for the collections framework.
|
||||
<h3>Core Interfaces - General Questions</h3>
|
||||
<ol>
|
||||
<li><a href="#a1"><b>Why don't you support immutability directly in
|
||||
the core collection interfaces so that you can do away with
|
||||
<em>optional operations</em> (and
|
||||
UnsupportedOperationException)?</b></a></li>
|
||||
<li><a href="#a2"><b>Won't programmers have to surround any code
|
||||
that calls optional operations with a try-catch clause in case they
|
||||
throw an UnsupportedOperationException?</b></a></li>
|
||||
<li><a href="#a3"><b>Why isn't there a core interface for "bags"
|
||||
(AKA multisets)?</b></a></li>
|
||||
<li><a href="#a28"><b>Why didn't you use "Beans-style names" for
|
||||
consistency?</b></a></li>
|
||||
</ol>
|
||||
<h3>Collection Interface</h3>
|
||||
<ol>
|
||||
<li><a href="#a5"><b>Why doesn't Collection extend Cloneable and
|
||||
Serializable?</b></a></li>
|
||||
<li><a href="#a6"><b>Why don't you provide an "apply" method in
|
||||
Collection to apply a given method ("upcall") to all the elements
|
||||
of the Collection?</b></a></li>
|
||||
<li><a href="#a7"><b>Why didn't you provide a "Predicate" interface,
|
||||
and related methods (e.g., a method to find the first element in
|
||||
the Collection satisfying the predicate)?</b></a></li>
|
||||
<li><a href="#a8"><b>Why don't you provide a form of the addAll
|
||||
method that takes an Enumeration (or an Iterator)?</b></a></li>
|
||||
<li><a href="#a9"><b>Why don't the concrete implementations in the
|
||||
JDK have Enumeration (or Iterator) constructors?</b></a></li>
|
||||
<li><a href="#a10"><b>Why don't you provide an Iterator.add
|
||||
method?</b></a></li>
|
||||
</ol>
|
||||
<h3>List Interface</h3>
|
||||
<ol>
|
||||
<li><a href="#a11"><b>Why don't you rename the List interface to
|
||||
Sequence; doesn't "list" generally suggest "linked list"? Also,
|
||||
doesn't it conflict with java.awt.List?</b></a></li>
|
||||
<li><a href="#a12"><b>Why don't you rename List's set method to
|
||||
replace, to avoid confusion with Set.</b></a></li>
|
||||
</ol>
|
||||
<h3>Map Interface</h3>
|
||||
<ol>
|
||||
<li><a href="#a14"><b>Why doesn't Map extend
|
||||
Collection?</b></a></li>
|
||||
</ol>
|
||||
<h3>Iterator Interface</h3>
|
||||
<ol>
|
||||
<li><a href="#a18"><b>Why doesn't Iterator extend
|
||||
Enumeration?</b></a></li>
|
||||
<li><a href="#a19"><b>Why don't you provide an Iterator.peek method
|
||||
that allows you to look at the next element in an iteration without
|
||||
advancing the iterator?</b></a></li>
|
||||
</ol>
|
||||
<h3>Miscellaneous</h3>
|
||||
<ol>
|
||||
<li><a href="#a23"><b>Why did you write a new collections framework
|
||||
instead of adopting JGL (a preexisting collections package from
|
||||
ObjectSpace, Inc.) into the JDK?</b></a></li>
|
||||
<li><a href="#a26"><b>Why don't you eliminate all of the methods and
|
||||
classes that return "views" (Collections backed by other
|
||||
collection-like objects). This would greatly reduce
|
||||
aliasing.</b></a></li>
|
||||
<li><a href="#a27"><b>Why don't you provide for "observable"
|
||||
collections that send out Events when they're
|
||||
modified?</b></a></li>
|
||||
</ol>
|
||||
<hr size="3" noshade="noshade" />
|
||||
<h3>Core Interfaces - General Questions</h3>
|
||||
<ol>
|
||||
<li><a name="a1" id="a1"><b>Why don't you support immutability
|
||||
directly in the core collection interfaces so that you can do away
|
||||
with <em>optional operations</em> (and
|
||||
UnsupportedOperationException)?</b></a>
|
||||
<p>This is the most controversial design decision in the whole API.
|
||||
Clearly, static (compile time) type checking is highly desirable,
|
||||
and is the norm in Java. We would have supported it if we believed
|
||||
it were feasible. Unfortunately, attempts to achieve this goal
|
||||
cause an explosion in the size of the interface hierarchy, and do
|
||||
not succeed in eliminating the need for runtime exceptions (though
|
||||
they reduce it substantially).</p>
|
||||
<p>Doug Lea, who wrote a popular Java collections package that did
|
||||
reflect mutability distinctions in its interface hierarchy, no
|
||||
longer believes it is a viable approach, based on user experience
|
||||
with his collections package. In his words (from personal
|
||||
correspondence) "Much as it pains me to say it, strong static
|
||||
typing does not work for collection interfaces in Java."</p>
|
||||
<p>To illustrate the problem in gory detail, suppose you want to
|
||||
add the notion of modifiability to the Hierarchy. You need four new
|
||||
interfaces: ModifiableCollection, ModifiableSet, ModifiableList,
|
||||
and ModifiableMap. What was previously a simple hierarchy is now a
|
||||
messy heterarchy. Also, you need a new Iterator interface for use
|
||||
with unmodifiable Collections, that does not contain the remove
|
||||
operation. Now can you do away with UnsupportedOperationException?
|
||||
Unfortunately not.</p>
|
||||
<p>Consider arrays. They implement most of the List operations, but
|
||||
not remove and add. They are "fixed-size" Lists. If you want to
|
||||
capture this notion in the hierarchy, you have to add two new
|
||||
interfaces: VariableSizeList and VariableSizeMap. You don't have to
|
||||
add VariableSizeCollection and VariableSizeSet, because they'd be
|
||||
identical to ModifiableCollection and ModifiableSet, but you might
|
||||
choose to add them anyway for consistency's sake. Also, you need a
|
||||
new variety of ListIterator that doesn't support the add and remove
|
||||
operations, to go along with unmodifiable List. Now we're up to ten
|
||||
or twelve interfaces, plus two new Iterator interfaces, instead of
|
||||
our original four. Are we done? No.</p>
|
||||
<p>Consider logs (such as error logs, audit logs and journals for
|
||||
recoverable data objects). They are natural append-only sequences,
|
||||
that support all of the List operations except for remove and set
|
||||
(replace). They require a new core interface, and a new
|
||||
iterator.</p>
|
||||
<p>And what about immutable Collections, as opposed to unmodifiable
|
||||
ones? (i.e., Collections that cannot be changed by the client AND
|
||||
will never change for any other reason). Many argue that this is
|
||||
the most important distinction of all, because it allows multiple
|
||||
threads to access a collection concurrently without the need for
|
||||
synchronization. Adding this support to the type hierarchy requires
|
||||
four more interfaces.</p>
|
||||
<p>Now we're up to twenty or so interfaces and five iterators, and
|
||||
it's almost certain that there are still collections arising in
|
||||
practice that don't fit cleanly into any of the interfaces. For
|
||||
example, the <em>collection-views</em> returned by Map are natural
|
||||
delete-only collections. Also, there are collections that will
|
||||
reject certain elements on the basis of their value, so we still
|
||||
haven't done away with runtime exceptions.</p>
|
||||
<p>When all was said and done, we felt that it was a sound
|
||||
engineering compromise to sidestep the whole issue by providing a
|
||||
very small set of core interfaces that can throw a runtime
|
||||
exception.</p>
|
||||
</li>
|
||||
<li><a name="a2" id="a2"><b>Won't programmers have to surround any
|
||||
code that calls optional operations with a try-catch clause in case
|
||||
they throw an UnsupportedOperationException?</b></a>
|
||||
<p>It was never our intention that programs should catch these
|
||||
exceptions: that's why they're unchecked (runtime) exceptions. They
|
||||
should only arise as a result of programming errors, in which case,
|
||||
your program will halt due to the uncaught exception.</p>
|
||||
</li>
|
||||
<li><a name="a3" id="a3"><b>Why isn't there a core interface for
|
||||
"bags" (AKA multisets)?</b></a>
|
||||
<p>The Collection interface provides this functionality. We are not
|
||||
providing any public implementations of this interface, as we think
|
||||
that it wouldn't be used frequently enough to "pull its weight." We
|
||||
occasionally return such Collections, which are implemented easily
|
||||
atop AbstractCollection (for example, the Collection returned by
|
||||
Map.values).</p>
|
||||
</li>
|
||||
<li><a name="a28" id="a28"><b>Why didn't you use "Beans-style
|
||||
names" for consistency?</b></a>
|
||||
<p>While the names of the new collections methods do not adhere to
|
||||
the "Beans naming conventions", we believe that they are
|
||||
reasonable, consistent and appropriate to their purpose. It should
|
||||
be remembered that the Beans naming conventions do not apply to the
|
||||
JDK as a whole; the AWT did adopt these conventions, but that
|
||||
decision was somewhat controversial. We suspect that the
|
||||
collections APIs will be used quite pervasively, often with
|
||||
multiple method calls on a single line of code, so it is important
|
||||
that the names be short. Consider, for example, the Iterator
|
||||
methods. Currently, a loop over a collection looks like this:</p>
|
||||
<pre>
|
||||
for (Iterator i = c.iterator(); i.hasNext(); )
|
||||
System.out.println(i.next());
|
||||
</pre>
|
||||
Everything fits neatly on one line, even if the Collection name is
|
||||
a long expression. If we named the methods "getIterator",
|
||||
"hasNextElement" and "getNextElement", this would no longer be the
|
||||
case. Thus, we adopted the "traditional" JDK style rather than the
|
||||
Beans style.</li>
|
||||
</ol>
|
||||
<hr />
|
||||
<h3>Collection Interface</h3>
|
||||
<ol>
|
||||
<li><a name="a5" id="a5"><b>Why doesn't Collection extend Cloneable
|
||||
and Serializable?</b></a>
|
||||
<p>Many Collection implementations (including all of the ones
|
||||
provided by the JDK) will have a public clone method, but it would
|
||||
be mistake to require it of all Collections. For example, what does
|
||||
it mean to clone a Collection that's backed by a terabyte SQL
|
||||
database? Should the method call cause the company to requisition a
|
||||
new disk farm? Similar arguments hold for serializable.</p>
|
||||
<p>If the client doesn't know the actual type of a Collection, it's
|
||||
much more flexible and less error prone to have the client decide
|
||||
what type of Collection is desired, create an empty Collection of
|
||||
this type, and use the addAll method to copy the elements of the
|
||||
original collection into the new one.</p>
|
||||
</li>
|
||||
<li><a name="a6" id="a6"><b>Why don't you provide an "apply" method
|
||||
in Collection to apply a given method ("upcall") to all the
|
||||
elements of the Collection?</b></a>
|
||||
<p>This is what is referred to as an "Internal Iterator" in the
|
||||
"Design Patterns" book (Gamma et al.). We considered providing it,
|
||||
but decided not to as it seems somewhat redundant to support
|
||||
internal and external iterators, and Java already has a precedent
|
||||
for external iterators (with Enumerations). The "throw weight" of
|
||||
this functionality is increased by the fact that it requires a
|
||||
public interface to describe upcalls.</p>
|
||||
</li>
|
||||
<li><a name="a7" id="a7"><b>Why didn't you provide a "Predicate"
|
||||
interface, and related methods (e.g., a method to find the first
|
||||
element in the Collection satisfying the predicate)?</b></a>
|
||||
<p>It's easy to implement this functionality atop Iterators, and
|
||||
the resulting code may actually look cleaner as the user can inline
|
||||
the predicate. Thus, it's not clear whether this facility pulls its
|
||||
weight. It could be added to the Collections class at a later date
|
||||
(implemented atop Iterator), if it's deemed useful.</p>
|
||||
</li>
|
||||
<li><a name="a8" id="a8"><b>Why don't you provide a form of the
|
||||
addAll method that takes an Enumeration (or an Iterator)?</b></a>
|
||||
<p>Because we don't believe in using Enumerations (or Iterators) as
|
||||
"poor man's collections." This was occasionally done in prior
|
||||
releases, but now that we have the Collection interface, it is the
|
||||
preferred way to pass around abstract collections of objects.</p>
|
||||
</li>
|
||||
<li><a name="a9" id="a9"><b>Why don't the concrete implementations
|
||||
in the JDK have Enumeration (or Iterator) constructors?</b></a>
|
||||
<p>Again, this is an instance of an Enumeration serving as a "poor
|
||||
man's collection" and we're trying to discourage that. Note
|
||||
however, that we strongly suggest that all concrete implementations
|
||||
should have constructors that take a Collection (and create a new
|
||||
Collection with the same elements).</p>
|
||||
</li>
|
||||
<li><a name="a10" id="a10"><b>Why don't you provide an Iterator.add
|
||||
method?</b></a>
|
||||
<p>The semantics are unclear, given that the contract for Iterator
|
||||
makes no guarantees about the order of iteration. Note, however,
|
||||
that ListIterator does provide an add operation, as it does
|
||||
guarantee the order of the iteration.</p>
|
||||
</li>
|
||||
</ol>
|
||||
<hr />
|
||||
<h3>List Interface</h3>
|
||||
<ol>
|
||||
<li><a name="a11" id="a11"><b>Why don't you rename the List
|
||||
interface to Sequence; doesn't "list" generally suggest "linked
|
||||
list"? Also, doesn't it conflict with java.awt.List?</b></a>
|
||||
<p>People were evenly divided as to whether List suggests linked
|
||||
lists. Given the implementation naming convention,
|
||||
<<em>Implementation</em>><<em>Interface</em>>, there
|
||||
was a strong desire to keep the core interface names short. Also,
|
||||
several existing names (AbstractSequentialList, LinkedList) would
|
||||
have been decidedly worse if we changed List to Sequence. The
|
||||
naming conflict can be dealt with by the following incantation:</p>
|
||||
<pre>
|
||||
import java.util.*;
|
||||
import java.awt.*;
|
||||
import java.util.List; // Dictates interpretation of "List"
|
||||
</pre></li>
|
||||
<li><a name="a12" id="a12"><b>Why don't you rename List's set
|
||||
method to replace, to avoid confusion with Set.</b></a>
|
||||
<p>It was decided that the "set/get" naming convention was strongly
|
||||
enough enshrined in the language that we'd stick with it.</p>
|
||||
</li>
|
||||
</ol>
|
||||
<hr />
|
||||
<h3>Map Interface</h3>
|
||||
<ol>
|
||||
<li><a name="a14" id="a14"><b>Why doesn't Map extend
|
||||
Collection?</b></a>
|
||||
<p>This was by design. We feel that mappings are not collections
|
||||
and collections are not mappings. Thus, it makes little sense for
|
||||
Map to extend the Collection interface (or vice versa).</p>
|
||||
<p>If a Map is a Collection, what are the elements? The only
|
||||
reasonable answer is "Key-value pairs", but this provides a very
|
||||
limited (and not particularly useful) Map abstraction. You can't
|
||||
ask what value a given key maps to, nor can you delete the entry
|
||||
for a given key without knowing what value it maps to.</p>
|
||||
<p>Collection could be made to extend Map, but this raises the
|
||||
question: what are the keys? There's no really satisfactory answer,
|
||||
and forcing one leads to an unnatural interface.</p>
|
||||
<p>Maps can be <em>viewed</em> as Collections (of keys, values, or
|
||||
pairs), and this fact is reflected in the three "Collection view
|
||||
operations" on Maps (keySet, entrySet, and values). While it is, in
|
||||
principle, possible to view a List as a Map mapping indices to
|
||||
elements, this has the nasty property that deleting an element from
|
||||
the List changes the Key associated with every element before the
|
||||
deleted element. That's why we don't have a map view operation on
|
||||
Lists.</p>
|
||||
</li>
|
||||
</ol>
|
||||
<hr />
|
||||
<h3>Iterator Interface</h3>
|
||||
<ol>
|
||||
<li><a name="a18" id="a18"><b>Why doesn't Iterator extend
|
||||
Enumeration?</b></a>
|
||||
<p>We view the method names for Enumeration as unfortunate. They're
|
||||
very long, and very frequently used. Given that we were adding a
|
||||
method and creating a whole new framework, we felt that it would be
|
||||
foolish not to take advantage of the opportunity to improve the
|
||||
names. Of course we could support the new and old names in
|
||||
Iterator, but it doesn't seem worthwhile.</p>
|
||||
</li>
|
||||
<li><a name="a19" id="a19"><b>Why don't you provide an
|
||||
Iterator.peek method that allows you to look at the next element in
|
||||
an iteration without advancing the iterator?</b></a>
|
||||
<p>It can be implemented atop the current Iterators (a similar
|
||||
pattern to java.io.PushbackInputStream). We believe that its use
|
||||
would be rare enough that it isn't worth including in the interface
|
||||
that everyone has to implement.</p>
|
||||
</li>
|
||||
</ol>
|
||||
<hr />
|
||||
<h3>Miscellaneous</h3>
|
||||
<ol>
|
||||
<li><a name="a23" id="a23"><b>Why did you write a new collections
|
||||
framework instead of adopting JGL (a preexisting collections
|
||||
package from ObjectSpace, Inc.) into the JDK?</b></a>
|
||||
<p>If you examine the goals for our Collections framework (in the
|
||||
Overview), you'll see that we are not really "playing in the same
|
||||
space" as JGL. Quoting from the "Design Goals" Section of the Java
|
||||
Collections Overview: "Our main design goal was to produce an API
|
||||
that was reasonably small, both in size, and (more importantly) in
|
||||
'conceptual weight.'"</p>
|
||||
<p>JGL consists of approximately 130 classes and interfaces; its
|
||||
main goal was consistency with the C++ Standard Template Library
|
||||
(STL). This was <em>not</em> one of our goals. Java has
|
||||
traditionally stayed away from C++'s more complex features (e.g.,
|
||||
multiple inheritance, operator overloading). Our entire framework,
|
||||
including all infrastructure, contains approximately 25 classes and
|
||||
interfaces.</p>
|
||||
<p>While this may cause some discomfort for some C++ programmers,
|
||||
we feel that it will be good for Java in the long run. As the Java
|
||||
libraries mature, they inevitably grow, but we are trying as hard
|
||||
as we can to keep them small and manageable, so that Java continues
|
||||
to be an easy, fun language to learn and to use.</p>
|
||||
</li>
|
||||
<li><a name="a26" id="a26"><b>Why don't you eliminate all of the
|
||||
methods and classes that return "views" (Collections backed by
|
||||
other collection-like objects). This would greatly reduce
|
||||
aliasing.</b></a>
|
||||
<p>Given that we provide core collection interfaces behind which
|
||||
programmers can "hide" their own implementations, there will be
|
||||
aliased collections whether the JDK provides them or not.
|
||||
Eliminating all views from the JDK would greatly increase the cost
|
||||
of common operations like making a Collection out of an array, and
|
||||
would do away with many useful facilities (like synchronizing
|
||||
wrappers). One view that we see as being particularly useful is
|
||||
<a href=
|
||||
"../List.html#subList-int-int-">List.subList</a>.
|
||||
The existence of this method means that people who write methods
|
||||
taking List on input do not have to write secondary forms taking an
|
||||
offset and a length (as they do for arrays).</p>
|
||||
</li>
|
||||
<li><a name="a27" id="a27"><b>Why don't you provide for
|
||||
"observable" collections that send out Events when they're
|
||||
modified?</b></a>
|
||||
<p>Primarily, resource constraints. If we're going to commit to
|
||||
such an API, it has to be something that works for everyone, that
|
||||
we can live with for the long haul. We may provide such a facility
|
||||
some day. In the meantime, it's not difficult to implement such a
|
||||
facility on top of the public APIs.</p>
|
||||
</li>
|
||||
</ol>
|
||||
<hr />
|
||||
<p style="font-size:smaller">
|
||||
Copyright © 1998, 2017, Oracle and/or its affiliates. 500 Oracle Parkway<br />
|
||||
Redwood Shores, CA 94065 USA. All rights reserved.</p>
|
||||
<!-- Body text ends here -->
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,80 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
||||
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||
|
||||
<!--
|
||||
Copyright (c) 1998, 2017, Oracle and/or its affiliates. All rights reserved.
|
||||
DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
|
||||
This code is free software; you can redistribute it and/or modify it
|
||||
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.
|
||||
-->
|
||||
|
||||
<html lang="en-US" xmlns="http://www.w3.org/1999/xhtml" xml:lang=
|
||||
"en-US">
|
||||
<head>
|
||||
<meta name="generator" content="HTML Tidy, see www.w3.org" />
|
||||
<title>The Collections Framework</title>
|
||||
|
||||
<style type="text/css">
|
||||
/*<![CDATA[*/
|
||||
|
||||
ul li, ul ul li {font-weight: normal;}
|
||||
pre {margin-left: 42pt;}
|
||||
a {font-weight: bold;}
|
||||
|
||||
/*]]>*/
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<h1>The Collections Framework</h1>
|
||||
<!-- Body text begins here -->
|
||||
<p>The collections framework is a unified architecture for
|
||||
representing and manipulating collections, enabling them to be
|
||||
manipulated independently of the details of their representation.
|
||||
It reduces programming effort while increasing performance. It
|
||||
enables interoperability among unrelated APIs, reduces effort in
|
||||
designing and learning new APIs, and fosters software reuse. The
|
||||
framework is based on more than a dozen collection interfaces. It
|
||||
includes implementations of these interfaces and algorithms to
|
||||
manipulate them.</p>
|
||||
<p>The documents in this section are non-normative portions of
|
||||
the Java™ Platform, Standard Edition API Specification.</p>
|
||||
<ul>
|
||||
<li><b><a href="coll-overview.html">Overview</a></b> - An overview of
|
||||
the collections framework.</li>
|
||||
</ul>
|
||||
<ul>
|
||||
<li><b><a href="coll-reference.html">Annotated API Outline</a></b> - An
|
||||
annotated outline of the classes and interfaces comprising the
|
||||
collections framework, with links into the API Specification.</li>
|
||||
</ul>
|
||||
<ul>
|
||||
<li><b><a href="coll-designfaq.html">Design FAQ</a></b> - Answers to
|
||||
frequently asked questions (FAQ) about the design of the
|
||||
collections framework.</li>
|
||||
</ul>
|
||||
<hr />
|
||||
<p style="font-size:smaller">
|
||||
Copyright © 1998, 2017, Oracle and/or its affiliates. 500 Oracle Parkway<br />
|
||||
Redwood Shores, CA 94065 USA. All rights reserved.</p>
|
||||
<!-- Body text ends here -->
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,359 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
||||
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||
|
||||
<!--
|
||||
Copyright (c) 1998, 2017, Oracle and/or its affiliates. All rights reserved.
|
||||
DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
|
||||
This code is free software; you can redistribute it and/or modify it
|
||||
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.
|
||||
-->
|
||||
|
||||
<html lang="en-US" xmlns="http://www.w3.org/1999/xhtml" xml:lang=
|
||||
"en-US">
|
||||
<head>
|
||||
<title>Collections Framework Overview</title>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Collections Framework Overview</h1>
|
||||
<!-- Body text begins here -->
|
||||
<h2>Introduction</h2>
|
||||
The Java platform includes a <i>collections framework</i>. A
|
||||
<i>collection</i> is an object that represents a group of objects
|
||||
(such as the classic <a href="../ArrayList.html">ArrayList</a> class).
|
||||
A collections framework is a unified architecture for representing
|
||||
and manipulating collections, enabling collections to be
|
||||
manipulated independently of implementation details.
|
||||
<p>The primary advantages of a collections framework are that
|
||||
it:</p>
|
||||
<ul>
|
||||
<li><strong>Reduces programming effort</strong> by providing data
|
||||
structures and algorithms so you don't have to write them
|
||||
yourself.</li>
|
||||
<li><strong>Increases performance</strong> by providing
|
||||
high-performance implementations of data structures and algorithms.
|
||||
Because the various implementations of each interface are
|
||||
interchangeable, programs can be tuned by switching
|
||||
implementations.</li>
|
||||
<li><strong>Provides interoperability between unrelated
|
||||
APIs</strong> by establishing a common language to pass collections
|
||||
back and forth.</li>
|
||||
<li><strong>Reduces the effort required to learn APIs</strong> by
|
||||
requiring you to learn multiple ad hoc collection APIs.</li>
|
||||
<li><strong>Reduces the effort required to design and implement
|
||||
APIs</strong> by not requiring you to produce ad hoc collections
|
||||
APIs.</li>
|
||||
<li><strong>Fosters software reuse</strong> by providing a standard
|
||||
interface for collections and algorithms with which to manipulate
|
||||
them.</li>
|
||||
</ul>
|
||||
<p>The collections framework consists of:</p>
|
||||
<ul>
|
||||
<li><strong>Collection interfaces</strong>. Represent different
|
||||
types of collections, such as sets, lists, and maps. These
|
||||
interfaces form the basis of the framework.</li>
|
||||
<li><strong>General-purpose implementations</strong>. Primary
|
||||
implementations of the collection interfaces.</li>
|
||||
<li><strong>Legacy implementations</strong>. The collection classes
|
||||
from earlier releases, <tt>Vector</tt> and <tt>Hashtable</tt>, were
|
||||
retrofitted to implement the collection interfaces.</li>
|
||||
<li><strong>Special-purpose implementations</strong>.
|
||||
Implementations designed for use in special situations. These
|
||||
implementations display nonstandard performance characteristics,
|
||||
usage restrictions, or behavior.</li>
|
||||
<li><strong>Concurrent implementations</strong>. Implementations
|
||||
designed for highly concurrent use.</li>
|
||||
<li><strong>Wrapper implementations</strong>. Add functionality,
|
||||
such as synchronization, to other implementations.</li>
|
||||
<li><strong>Convenience implementations</strong>. High-performance
|
||||
"mini-implementations" of the collection interfaces.</li>
|
||||
<li><strong>Abstract implementations</strong>. Partial
|
||||
implementations of the collection interfaces to facilitate custom
|
||||
implementations.</li>
|
||||
<li><strong>Algorithms</strong>. Static methods that perform useful
|
||||
functions on collections, such as sorting a list.</li>
|
||||
<li><strong>Infrastructure</strong>. Interfaces that provide
|
||||
essential support for the collection interfaces.</li>
|
||||
<li><strong>Array Utilities</strong>. Utility functions for arrays
|
||||
of primitive types and reference objects. Not, strictly speaking, a
|
||||
part of the collections framework, this feature was added to the
|
||||
Java platform at the same time as the collections framework and
|
||||
relies on some of the same infrastructure.</li>
|
||||
</ul>
|
||||
<hr />
|
||||
<h2>Collection Interfaces</h2>
|
||||
<p>The <i>collection interfaces</i> are divided into two groups.
|
||||
The most basic interface, <tt><a href=
|
||||
"../Collection.html">java.util.Collection</a></tt>,
|
||||
has the following descendants:</p>
|
||||
<ul>
|
||||
<li><tt><a href=
|
||||
"../Set.html">java.util.Set</a></tt></li>
|
||||
<li><tt><a href=
|
||||
"../SortedSet.html">java.util.SortedSet</a></tt></li>
|
||||
<li><tt><a href=
|
||||
"../NavigableSet.html">java.util.NavigableSet</a></tt></li>
|
||||
<li><tt><a href=
|
||||
"../Queue.html">java.util.Queue</a></tt></li>
|
||||
<li><tt><a href=
|
||||
"../concurrent/BlockingQueue.html">java.util.concurrent.BlockingQueue</a></tt></li>
|
||||
<li><tt><a href=
|
||||
"../concurrent/TransferQueue.html">java.util.concurrent.TransferQueue</a></tt></li>
|
||||
<li><tt><a href=
|
||||
"../Deque.html">java.util.Deque</a></tt></li>
|
||||
<li><tt><a href=
|
||||
"../concurrent/BlockingDeque.html">java.util.concurrent.BlockingDeque</a></tt></li>
|
||||
</ul>
|
||||
<p>The other collection interfaces are based on <tt><a href=
|
||||
"../Map.html">java.util.Map</a></tt> and are
|
||||
not true collections. However, these interfaces contain
|
||||
<i>collection-view</i> operations, which enable them to be
|
||||
manipulated as collections. <tt>Map</tt> has the following
|
||||
offspring:</p>
|
||||
<ul>
|
||||
<li><tt><a href=
|
||||
"../SortedMap.html">java.util.SortedMap</a></tt></li>
|
||||
<li><tt><a href=
|
||||
"../NavigableMap.html">java.util.NavigableMap</a></tt></li>
|
||||
<li><tt><a href=
|
||||
"../concurrent/ConcurrentMap.html">java.util.concurrent.ConcurrentMap</a></tt></li>
|
||||
<li><tt><a href=
|
||||
"../concurrent/ConcurrentNavigableMap.html">java.util.concurrent.ConcurrentNavigableMap</a></tt></li>
|
||||
</ul>
|
||||
<p>Many of the modification methods in the collection interfaces
|
||||
are labeled <i>optional</i>. Implementations are permitted to not
|
||||
perform one or more of these operations, throwing a runtime
|
||||
exception (<tt>UnsupportedOperationException</tt>) if they are
|
||||
attempted. The documentation for each implementation must specify
|
||||
which optional operations are supported. Several terms are
|
||||
introduced to aid in this specification:</p>
|
||||
<ul>
|
||||
<li>Collections that do not support modification operations (such
|
||||
as <tt>add</tt>, <tt>remove</tt> and <tt>clear</tt>) are referred
|
||||
to as <i>unmodifiable</i>. Collections that are not unmodifiable
|
||||
are <i>modifiable.</i></li>
|
||||
<li>Collections that additionally guarantee that no change in the
|
||||
<tt>Collection</tt> object will be visible are referred to as
|
||||
<i>immutable</i>. Collections that are not immutable are
|
||||
<i>mutable</i>.</li>
|
||||
<li>Lists that guarantee that their size remains constant even
|
||||
though the elements can change are referred to as
|
||||
<i>fixed-size</i>. Lists that are not fixed-size are referred to as
|
||||
<i>variable-size</i>.</li>
|
||||
<li>Lists that support fast (generally constant time) indexed
|
||||
element access are known as <i>random access</i> lists. Lists that
|
||||
do not support fast indexed element access are known as
|
||||
<i>sequential access</i> lists. The <tt><a href=
|
||||
"../RandomAccess.html">RandomAccess</a></tt>
|
||||
marker interface enables lists to advertise the fact that they
|
||||
support random access. This enables generic algorithms to change
|
||||
their behavior to provide good performance when applied to either
|
||||
random or sequential access lists.</li>
|
||||
</ul>
|
||||
<p>Some implementations restrict what elements (or in the case of
|
||||
<tt>Maps</tt>, keys and values) can be stored. Possible
|
||||
restrictions include requiring elements to:</p>
|
||||
<ul>
|
||||
<li>Be of a particular type.</li>
|
||||
<li>Be not null.</li>
|
||||
<li>Obey some arbitrary predicate.</li>
|
||||
</ul>
|
||||
<p>Attempting to add an element that violates an implementation's
|
||||
restrictions results in a runtime exception, typically a
|
||||
<tt>ClassCastException</tt>, an <tt>IllegalArgumentException</tt>,
|
||||
or a <tt>NullPointerException</tt>. Attempting to remove or test
|
||||
for the presence of an element that violates an implementation's
|
||||
restrictions can result in an exception. Some restricted
|
||||
collections permit this usage.</p>
|
||||
<hr />
|
||||
<h2>Collection Implementations</h2>
|
||||
<p>Classes that implement the collection interfaces typically have
|
||||
names in the form of
|
||||
<<em>Implementation-style</em>><<em>Interface</em>>.
|
||||
The general purpose implementations are summarized in the following
|
||||
table:</p>
|
||||
<table border="2" summary=
|
||||
"general purpose implementations and interfaces" align="center">
|
||||
<thead>
|
||||
<tr>
|
||||
<th id="interfaces">Interface</th>
|
||||
<th id="hashtable">Hash Table</th>
|
||||
<th id="resizablearray">Resizable Array</th>
|
||||
<th id="balancedtree">Balanced Tree</th>
|
||||
<th id="linkedlist">Linked List</th>
|
||||
<th id="hashtableandlinkedlist">Hash Table + Linked List</th>
|
||||
</tr>
|
||||
<tr>
|
||||
<td headers="interfaces"><code>Set</code></td>
|
||||
<td headers="hashtable"><a href=
|
||||
"../HashSet.html"><tt>HashSet</tt></a></td>
|
||||
<td headers="resizablearray"> </td>
|
||||
<td headers="balancedtree"><a href=
|
||||
"../TreeSet.html"><tt>TreeSet</tt></a></td>
|
||||
<td headers="linkedlist"> </td>
|
||||
<td headers="hashtableandlinkedlist"><a href=
|
||||
"../LinkedHashSet.html"><tt>LinkedHashSet</tt></a></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td headers="interfaces"><code>List</code></td>
|
||||
<td headers="hashtable"> </td>
|
||||
<td headers="resizablearray"><a href=
|
||||
"../ArrayList.html"><tt>ArrayList</tt></a></td>
|
||||
<td headers="balancedtree"> </td>
|
||||
<td headers="linkedlist"><a href=
|
||||
"../LinkedList.html"><tt>LinkedList</tt></a></td>
|
||||
<td headers="hashtableandlinkedlist"> </td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td headers="interfaces"><code>Deque</code></td>
|
||||
<td headers="hashtable"> </td>
|
||||
<td headers="resizablearray"><a href=
|
||||
"../ArrayDeque.html"><tt>ArrayDeque</tt></a></td>
|
||||
<td headers="balancedtree"> </td>
|
||||
<td headers="linkedlist"><a href=
|
||||
"../LinkedList.html"><tt>LinkedList</tt></a></td>
|
||||
<td headers="hashtableandlinkedlist"> </td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td headers="interfaces"><code>Map</code></td>
|
||||
<td headers="hashtable"><a href=
|
||||
"../HashMap.html"><tt>HashMap</tt></a></td>
|
||||
<td headers="resizablearray"> </td>
|
||||
<td headers="balancedtree"><a href=
|
||||
"../TreeMap.html"><tt>TreeMap</tt></a></td>
|
||||
<td headers="linkedlist"> </td>
|
||||
<td headers="hashtableandlinkedlist"><a href=
|
||||
"../LinkedHashMap.html"><tt>LinkedHashMap</tt></a></td>
|
||||
</tr>
|
||||
</thead>
|
||||
</table>
|
||||
<p>The general-purpose implementations support all of the
|
||||
<i>optional operations</i> in the collection interfaces and have no
|
||||
restrictions on the elements they may contain. They are
|
||||
unsynchronized, but the <tt>Collections</tt> class contains static
|
||||
factories called <a href=
|
||||
"../Collections.html#synchronizedCollection-java.util.Collection-">
|
||||
<em>synchronization wrappers</em></a> that can be used to add
|
||||
synchronization to many unsynchronized collections. All of the new
|
||||
implementations have <i>fail-fast iterators</i>, which detect
|
||||
invalid concurrent modification, and fail quickly and cleanly
|
||||
(rather than behaving erratically).</p>
|
||||
<p>The <tt>AbstractCollection</tt>, <tt>AbstractSet</tt>,
|
||||
<tt>AbstractList</tt>, <tt>AbstractSequentialList</tt> and
|
||||
<tt>AbstractMap</tt> classes provide basic implementations of the
|
||||
core collection interfaces, to minimize the effort required to
|
||||
implement them. The API documentation for these classes describes
|
||||
precisely how each method is implemented so the implementer knows
|
||||
which methods must be overridden, given the performance of the
|
||||
basic operations of a specific implementation.</p>
|
||||
<hr />
|
||||
<h2>Concurrent Collections</h2>
|
||||
<p>Applications that use collections from more than one thread must
|
||||
be carefully programmed. In general, this is known as <i>concurrent
|
||||
programming</i>. The Java platform includes extensive support for
|
||||
concurrent programming. See <a href=
|
||||
"../concurrent/package-summary.html">Java Concurrency
|
||||
Utilities</a> for details.</p>
|
||||
<p>Collections are so frequently used that various concurrent
|
||||
friendly interfaces and implementations of collections are included
|
||||
in the APIs. These types go beyond the synchronization wrappers
|
||||
discussed previously to provide features that are frequently needed
|
||||
in concurrent programming.</p>
|
||||
<p>These concurrent-aware interfaces are available:</p>
|
||||
<ul>
|
||||
<li><tt><a href=
|
||||
"../concurrent/BlockingQueue.html">BlockingQueue</a></tt></li>
|
||||
<li><tt><a href=
|
||||
"../concurrent/TransferQueue.html">TransferQueue</a></tt></li>
|
||||
<li><tt><a href=
|
||||
"../concurrent/BlockingDeque.html">BlockingDeque</a></tt></li>
|
||||
<li><tt><a href=
|
||||
"../concurrent/ConcurrentMap.html">ConcurrentMap</a></tt></li>
|
||||
<li><tt><a href=
|
||||
"../concurrent/ConcurrentNavigableMap.html">ConcurrentNavigableMap</a></tt></li>
|
||||
</ul>
|
||||
<p>The following concurrent-aware implementation classes are
|
||||
available. See the API documentation for the correct usage of these
|
||||
implementations.</p>
|
||||
<ul>
|
||||
<li><tt><a href=
|
||||
"../concurrent/LinkedBlockingQueue.html">LinkedBlockingQueue</a></tt></li>
|
||||
<li><tt><a href=
|
||||
"../concurrent/ArrayBlockingQueue.html">ArrayBlockingQueue</a></tt></li>
|
||||
<li><tt><a href=
|
||||
"../concurrent/PriorityBlockingQueue.html">PriorityBlockingQueue</a></tt></li>
|
||||
<li><tt><a href=
|
||||
"../concurrent/DelayQueue.html">DelayQueue</a></tt></li>
|
||||
<li><tt><a href=
|
||||
"../concurrent/SynchronousQueue.html">SynchronousQueue</a></tt></li>
|
||||
<li><a href=
|
||||
"../concurrent/LinkedBlockingDeque.html"><tt>LinkedBlockingDeque</tt></a></li>
|
||||
<li><a href=
|
||||
"../concurrent/LinkedTransferQueue.html"><tt>LinkedTransferQueue</tt></a></li>
|
||||
<li><tt><a href=
|
||||
"../concurrent/CopyOnWriteArrayList.html">CopyOnWriteArrayList</a></tt></li>
|
||||
<li><tt><a href=
|
||||
"../concurrent/CopyOnWriteArraySet.html">CopyOnWriteArraySet</a></tt></li>
|
||||
<li><tt><a href=
|
||||
"../concurrent/ConcurrentSkipListSet.html">ConcurrentSkipListSet</a></tt></li>
|
||||
<li><tt><a href=
|
||||
"../concurrent/ConcurrentHashMap.html">ConcurrentHashMap</a></tt></li>
|
||||
<li><tt><a href=
|
||||
"../concurrent/ConcurrentSkipListMap.html">ConcurrentSkipListMap</a></tt></li>
|
||||
</ul>
|
||||
<hr />
|
||||
<h2>Design Goals</h2>
|
||||
<p>The main design goal was to produce an API that was small in
|
||||
size and, more importantly, in "conceptual weight." It
|
||||
was critical that the new functionality not seem too different to
|
||||
current Java programmers; it had to augment current facilities,
|
||||
rather than replace them. At the same time, the new API had to be
|
||||
powerful enough to provide all the advantages described
|
||||
previously.</p>
|
||||
<p>To keep the number of core interfaces small, the interfaces do
|
||||
not attempt to capture such subtle distinctions as mutability,
|
||||
modifiability, and resizability. Instead, certain calls in the core
|
||||
interfaces are <i>optional</i>, enabling implementations to throw
|
||||
an <tt>UnsupportedOperationException</tt> to indicate that they do
|
||||
not support a specified optional operation. Collection implementers
|
||||
must clearly document which optional operations are supported by an
|
||||
implementation.</p>
|
||||
<p>To keep the number of methods in each core interface small, an
|
||||
interface contains a method only if either:</p>
|
||||
<ul>
|
||||
<li>It is a truly <i>fundamental operation</i>: a basic operations
|
||||
in terms of which others could be reasonably defined,</li>
|
||||
<li>There is a compelling performance reason why an important
|
||||
implementation would want to override it.</li>
|
||||
</ul>
|
||||
<p>It was critical that all reasonable representations of
|
||||
collections interoperate well. This included arrays, which cannot
|
||||
be made to implement the <tt>Collection</tt> interface directly
|
||||
without changing the language. Thus, the framework includes methods
|
||||
to enable collections to be moved into arrays, arrays to be viewed
|
||||
as collections, and maps to be viewed as collections.</p>
|
||||
<hr />
|
||||
<p style="font-size:smaller">
|
||||
Copyright © 1998, 2017, Oracle and/or its affiliates. 500 Oracle Parkway<br />
|
||||
Redwood Shores, CA 94065 USA. All rights reserved.</p>
|
||||
<!-- Body text ends here -->
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,564 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
||||
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||
|
||||
<!--
|
||||
Copyright (c) 1998, 2017, Oracle and/or its affiliates. All rights reserved.
|
||||
DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
|
||||
This code is free software; you can redistribute it and/or modify it
|
||||
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.
|
||||
-->
|
||||
|
||||
<html lang="en-US" xmlns="http://www.w3.org/1999/xhtml" xml:lang=
|
||||
"en-US">
|
||||
<head>
|
||||
<title>Outline of the Collections Framework</title>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Outline of the Collections Framework</h1>
|
||||
<!-- Body text begins here -->
|
||||
The collections framework consists of:
|
||||
<ul>
|
||||
<li><strong>Collection interfaces</strong> - The primary means by
|
||||
which collections are manipulated.
|
||||
<ul>
|
||||
<li><a href=
|
||||
"../Collection.html"><strong>Collection</strong></a>
|
||||
- A group of objects. No assumptions are made about the order of
|
||||
the collection (if any) or whether it can contain duplicate
|
||||
elements.</li>
|
||||
<li><a href=
|
||||
"../Set.html"><strong>Set</strong></a> - The
|
||||
familiar set abstraction. No duplicate elements permitted. May or
|
||||
may not be ordered. Extends the <tt>Collection</tt> interface.</li>
|
||||
<li><a href=
|
||||
"../List.html"><strong>List</strong></a> -
|
||||
Ordered collection, also known as a <i>sequence</i>. Duplicates are
|
||||
generally permitted. Allows positional access. Extends the
|
||||
<tt>Collection</tt> interface.</li>
|
||||
<li><a href=
|
||||
"../Queue.html"><strong>Queue</strong></a> - A
|
||||
collection designed for holding elements before processing. Besides
|
||||
basic <tt>Collection</tt> operations, queues provide additional
|
||||
insertion, extraction, and inspection operations.</li>
|
||||
<li><a href=
|
||||
"../Deque.html"><strong>Deque</strong></a> - A
|
||||
<em>double ended queue</em>, supporting element insertion and
|
||||
removal at both ends. Extends the <tt>Queue</tt> interface.</li>
|
||||
<li><a href=
|
||||
"../Map.html"><strong>Map</strong></a> - A
|
||||
mapping from keys to values. Each key can map to one value.</li>
|
||||
<li><a href=
|
||||
"../SortedSet.html"><strong>SortedSet</strong></a>
|
||||
- A set whose elements are automatically sorted, either in their
|
||||
<i>natural ordering</i> (see the <a href=
|
||||
"../../lang/Comparable.html"><tt>Comparable</tt></a>
|
||||
interface) or by a <a href=
|
||||
"../Comparator.html"><tt>Comparator</tt></a>
|
||||
object provided when a <tt>SortedSet</tt> instance is created.
|
||||
Extends the <tt>Set</tt> interface.</li>
|
||||
<li><a href=
|
||||
"../SortedMap.html"><strong>SortedMap</strong></a>
|
||||
- A map whose mappings are automatically sorted by key, either
|
||||
using the <i>natural ordering</i> of the keys or by a comparator
|
||||
provided when a <tt>SortedMap</tt> instance is created. Extends the
|
||||
<tt>Map</tt> interface.</li>
|
||||
<li><a href=
|
||||
"../NavigableSet.html"><strong>NavigableSet</strong></a>
|
||||
- A <tt>SortedSet</tt> extended with navigation methods reporting
|
||||
closest matches for given search targets. A <tt>NavigableSet</tt>
|
||||
may be accessed and traversed in either ascending or descending
|
||||
order.</li>
|
||||
<li><a href=
|
||||
"../NavigableMap.html"><strong>NavigableMap</strong></a>
|
||||
- A <tt>SortedMap</tt> extended with navigation methods returning
|
||||
the closest matches for given search targets. A
|
||||
<tt>NavigableMap</tt> can be accessed and traversed in either
|
||||
ascending or descending key order.</li>
|
||||
<li><a href=
|
||||
"../concurrent/BlockingQueue.html"><strong>BlockingQueue</strong></a>
|
||||
- A <tt>Queue</tt> with operations that wait for the queue to
|
||||
become nonempty when retrieving an element and that wait for space
|
||||
to become available in the queue when storing an element. (This
|
||||
interface is part of the <tt><a href=
|
||||
"../concurrent/package-summary.html">java.util.concurrent</a></tt>
|
||||
package.)</li>
|
||||
<li><a href=
|
||||
"../concurrent/TransferQueue.html"><strong>TransferQueue</strong></a>
|
||||
- A <tt>BlockingQueue</tt> in which producers can wait for
|
||||
consumers to receive elements. (This interface is part of the
|
||||
<tt><a href=
|
||||
"../concurrent/package-summary.html">java.util.concurrent</a></tt>
|
||||
package.)</li>
|
||||
<li><a href=
|
||||
"../concurrent/BlockingDeque.html"><strong>BlockingDeque</strong></a>
|
||||
- A <tt>Deque</tt> with operations that wait for the deque to
|
||||
become nonempty when retrieving an element and wait for space to
|
||||
become available in the deque when storing an element. Extends both
|
||||
the <tt>Deque</tt> and <tt>BlockingQueue</tt> interfaces. (This
|
||||
interface is part of the <tt><a href=
|
||||
"../concurrent/package-summary.html">java.util.concurrent</a></tt>
|
||||
package.)</li>
|
||||
<li><a href=
|
||||
"../concurrent/ConcurrentMap.html"><strong>ConcurrentMap</strong></a>
|
||||
- A <tt>Map</tt> with atomic <tt>putIfAbsent</tt>, <tt>remove</tt>,
|
||||
and <tt>replace</tt> methods. (This interface is part of the
|
||||
<tt>java.util.concurrent</tt> package.)</li>
|
||||
<li><a href=
|
||||
"../concurrent/ConcurrentNavigableMap.html"><strong>
|
||||
ConcurrentNavigableMap</strong></a> - A <tt>ConcurrentMap</tt> that
|
||||
is also a <tt>NavigableMap</tt>.</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li><strong>General-purpose implementations</strong> - The primary
|
||||
implementations of the collection interfaces.
|
||||
<ul>
|
||||
<li><strong><a href=
|
||||
"../HashSet.html">HashSet</a></strong> - Hash
|
||||
table implementation of the <tt>Set</tt> interface. The best
|
||||
all-around implementation of the <tt>Set</tt> interface.</li>
|
||||
<li><a href=
|
||||
"../TreeSet.html"><strong>TreeSet</strong></a>
|
||||
- Red-black tree implementation of the <tt>NavigableSet</tt>
|
||||
interface.</li>
|
||||
<li><strong><a href=
|
||||
"../LinkedHashSet.html">LinkedHashSet</a></strong>
|
||||
- Hash table and linked list implementation of the <tt>Set</tt>
|
||||
interface. An insertion-ordered <tt>Set</tt> implementation that
|
||||
runs nearly as fast as <tt>HashSet</tt>.</li>
|
||||
<li><strong><a href=
|
||||
"../ArrayList.html">ArrayList</a></strong> -
|
||||
Resizable array implementation of the <tt>List</tt> interface (an
|
||||
unsynchronized <tt>Vector</tt>). The best all-around implementation
|
||||
of the <tt>List</tt> interface.</li>
|
||||
<li><strong><a href=
|
||||
"../ArrayDeque.html">ArrayDeque</a></strong> -
|
||||
Efficient, resizable array implementation of the <tt>Deque</tt>
|
||||
interface.</li>
|
||||
<li><a href=
|
||||
"../LinkedList.html"><strong>LinkedList</strong></a>
|
||||
- Doubly-linked list implementation of the <tt>List</tt> interface.
|
||||
Provides better performance than the <tt>ArrayList</tt>
|
||||
implementation if elements are frequently inserted or deleted
|
||||
within the list. Also implements the <tt>Deque</tt> interface. When
|
||||
accessed through the <tt>Queue</tt> interface, <tt>LinkedList</tt>
|
||||
acts as a FIFO queue.</li>
|
||||
<li><strong><a href=
|
||||
"../PriorityQueue.html">PriorityQueue</a></strong>
|
||||
- Heap implementation of an unbounded priority queue.</li>
|
||||
<li><strong><a href=
|
||||
"../HashMap.html">HashMap</a></strong> - Hash
|
||||
table implementation of the <tt>Map</tt> interface (an
|
||||
unsynchronized <tt>Hashtable</tt> that supports <tt>null</tt> keys
|
||||
and values). The best all-around implementation of the <tt>Map</tt>
|
||||
interface.</li>
|
||||
<li><a href=
|
||||
"../TreeMap.html"><strong>TreeMap</strong></a>
|
||||
Red-black tree implementation of the <tt>NavigableMap</tt>
|
||||
interface.</li>
|
||||
<li><strong><a href=
|
||||
"../LinkedHashMap.html">LinkedHashMap</a></strong>
|
||||
- Hash table and linked list implementation of the <tt>Map</tt>
|
||||
interface. An insertion-ordered <tt>Map</tt> implementation that
|
||||
runs nearly as fast as <tt>HashMap</tt>. Also useful for building
|
||||
caches (see <a href=
|
||||
"../LinkedHashMap.html#removeEldestEntry-java.util.Map.Entry-">
|
||||
removeEldestEntry(Map.Entry)</a> ).</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li><strong>Wrapper implementations</strong> -
|
||||
Functionality-enhancing implementations for use with other
|
||||
implementations. Accessed solely through static factory methods.
|
||||
<ul>
|
||||
<li><a href=
|
||||
"../Collections.html#unmodifiableCollection-java.util.Collection-">
|
||||
<strong>Collections.unmodifiable<i>Interface</i></strong></a> -
|
||||
Returns an unmodifiable view of a specified collection that throws
|
||||
an <tt>UnsupportedOperationException</tt> if the user attempts to
|
||||
modify it.</li>
|
||||
<li><a name="synchWrappers" href=
|
||||
"../Collections.html#synchronizedCollection-java.util.Collection-"
|
||||
id=
|
||||
"synchWrappers"><strong>Collections.synchronized<i>Interface</i></strong></a>
|
||||
- Returns a synchronized collection that is backed by the specified
|
||||
(typically unsynchronized) collection. As long as all accesses to
|
||||
the backing collection are through the returned collection, thread
|
||||
safety is guaranteed.</li>
|
||||
<li><a href=
|
||||
"../Collections.html#checkedCollection-java.util.Collection-java.lang.Class-">
|
||||
<strong>Collections.checked<i>Interface</i></strong></a> - Returns
|
||||
a dynamically type-safe view of the specified collection, which
|
||||
throws a <tt>ClassCastException</tt> if a client attempts to add an
|
||||
element of the wrong type. The generics mechanism in the language
|
||||
provides compile-time (static) type checking, but it is possible to
|
||||
bypass this mechanism. Dynamically type-safe views eliminate this
|
||||
possibility.</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li><strong>Adapter implementations</strong> - Implementations that
|
||||
adapt one collections interface to another:
|
||||
<ul>
|
||||
<li><strong><a href=
|
||||
"../Collections.html#newSetFromMap-java.util.Map-">
|
||||
newSetFromMap(Map)</a></strong> - Creates a general-purpose
|
||||
<tt>Set</tt> implementation from a general-purpose <tt>Map</tt>
|
||||
implementation.</li>
|
||||
<li><strong><a href=
|
||||
"../Collections.html#asLifoQueue-java.util.Deque-">
|
||||
asLifoQueue(Deque)</a></strong> - Returns a view of a
|
||||
<tt>Deque</tt> as a Last In First Out (LIFO) <tt>Queue</tt>.</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li><strong>Convenience implementations</strong> - High-performance
|
||||
"mini-implementations" of the collection interfaces.
|
||||
<ul>
|
||||
<li><a href=
|
||||
"../Arrays.html#asList-T...-"><strong>Arrays.asList</strong></a>
|
||||
- Enables an array to be viewed as a list.</li>
|
||||
<li><strong><a href=
|
||||
"../Collections.html#emptySet--">emptySet</a>,
|
||||
<a href=
|
||||
"../Collections.html#emptyList--">emptyList</a>
|
||||
and <a href=
|
||||
"../Collections.html#emptyMap--">emptyMap</a></strong>
|
||||
- Return an immutable empty set, list, or map.</li>
|
||||
<li><strong><a href=
|
||||
"../Collections.html#singleton-java.lang.Object-">
|
||||
singleton</a>, <a href=
|
||||
"../Collections.html#singletonList-java.lang.Object-">
|
||||
singletonList</a>, and <a href=
|
||||
"../Collections.html#singletonMap-K-V-">singletonMap</a></strong>
|
||||
- Return an immutable singleton set, list, or map, containing only
|
||||
the specified object (or key-value mapping).</li>
|
||||
<li><a href=
|
||||
"../Collections.html#nCopies-int-T-"><strong>
|
||||
nCopies</strong></a> - Returns an immutable list consisting of n
|
||||
copies of a specified object.</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li><strong>Legacy implementations</strong> - Older collection
|
||||
classes were retrofitted to implement the collection interfaces.
|
||||
<ul>
|
||||
<li><a href=
|
||||
"../Vector.html"><strong>Vector</strong></a> -
|
||||
Synchronized resizable array implementation of the <tt>List</tt>
|
||||
interface with additional legacy methods.</li>
|
||||
<li><a href=
|
||||
"../Hashtable.html"><strong>Hashtable</strong></a>
|
||||
- Synchronized hash table implementation of the <tt>Map</tt>
|
||||
interface that does not allow <tt>null</tt> keys or values, plus
|
||||
additional legacy methods.</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li><strong>Special-purpose implementations</strong>
|
||||
<ul>
|
||||
<li><strong><a href=
|
||||
"../WeakHashMap.html">WeakHashMap</a></strong>
|
||||
- An implementation of the <tt>Map</tt> interface that stores only
|
||||
<a href="../../lang/ref/WeakReference.html"><i>weak
|
||||
references</i></a> to its keys. Storing only weak references
|
||||
enables key-value pairs to be garbage collected when the key is no
|
||||
longer referenced outside of the <tt>WeakHashMap</tt>. This class
|
||||
is the easiest way to use the power of weak references. It is
|
||||
useful for implementing registry-like data structures, where the
|
||||
utility of an entry vanishes when its key is no longer reachable by
|
||||
any thread.</li>
|
||||
<li><strong><a href=
|
||||
"../IdentityHashMap.html">IdentityHashMap</a></strong>
|
||||
- Identity-based <tt>Map</tt> implementation based on a hash table.
|
||||
This class is useful for topology-preserving object graph
|
||||
transformations (such as serialization or deep copying). To perform
|
||||
these transformations, you must maintain an identity-based "node
|
||||
table" that keeps track of which objects have already been seen.
|
||||
Identity-based maps are also used to maintain
|
||||
object-to-meta-information mappings in dynamic debuggers and
|
||||
similar systems. Finally, identity-based maps are useful in
|
||||
preventing "spoof attacks" resulting from intentionally perverse
|
||||
equals methods. (<tt>IdentityHashMap</tt> never invokes the equals
|
||||
method on its keys.) An added benefit of this implementation is
|
||||
that it is fast.</li>
|
||||
<li><strong><a href=
|
||||
"../concurrent/CopyOnWriteArrayList.html">CopyOnWriteArrayList</a></strong>
|
||||
- A <tt>List</tt> implementation backed by an copy-on-write array.
|
||||
All mutative operations (such as <tt>add</tt>, <tt>set</tt>, and
|
||||
<tt>remove</tt>) are implemented by making a new copy of the array.
|
||||
No synchronization is necessary, even during iteration, and
|
||||
iterators are guaranteed never to throw
|
||||
<tt>ConcurrentModificationException</tt>. This implementation is
|
||||
well-suited to maintaining event-handler lists (where change is
|
||||
infrequent, and traversal is frequent and potentially
|
||||
time-consuming).</li>
|
||||
<li><strong><a href=
|
||||
"../concurrent/CopyOnWriteArraySet.html">CopyOnWriteArraySet</a></strong>
|
||||
- A <tt>Set</tt> implementation backed by a copy-on-write array.
|
||||
This implementation is similar to <tt>CopyOnWriteArrayList</tt>.
|
||||
Unlike most <tt>Set</tt> implementations, the <tt>add</tt>,
|
||||
<tt>remove</tt>, and <tt>contains</tt> methods require time
|
||||
proportional to the size of the set. This implementation is well
|
||||
suited to maintaining event-handler lists that must prevent
|
||||
duplicates.</li>
|
||||
<li><strong><a href=
|
||||
"../EnumSet.html">EnumSet</a></strong> - A
|
||||
high-performance <tt>Set</tt> implementation backed by a bit
|
||||
vector. All elements of each <tt>EnumSet</tt> instance must be
|
||||
elements of a single enum type.</li>
|
||||
<li><strong><a href=
|
||||
"../EnumMap.html">EnumMap</a></strong> - A
|
||||
high-performance <tt>Map</tt> implementation backed by an array.
|
||||
All keys in each <tt>EnumMap</tt> instance must be elements of a
|
||||
single enum type.</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li><strong>Concurrent implementations</strong> - These
|
||||
implementations are part of <tt>java.util.concurrent</tt>.
|
||||
<ul>
|
||||
<li><strong><a href=
|
||||
"../concurrent/ConcurrentLinkedQueue.html">ConcurrentLinkedQueue</a></strong>
|
||||
- An unbounded first in, first out (FIFO) queue based on linked
|
||||
nodes.</li>
|
||||
<li><a href=
|
||||
"../concurrent/LinkedBlockingQueue.html"><strong>
|
||||
LinkedBlockingQueue</strong></a> - An optionally bounded FIFO
|
||||
blocking queue backed by linked nodes.</li>
|
||||
<li><a href=
|
||||
"../concurrent/ArrayBlockingQueue.html"><strong>
|
||||
ArrayBlockingQueue</strong></a> - A bounded FIFO blocking queue
|
||||
backed by an array.</li>
|
||||
<li><a href=
|
||||
"../concurrent/PriorityBlockingQueue.html"><strong>
|
||||
PriorityBlockingQueue</strong></a> - An unbounded blocking priority
|
||||
queue backed by a priority heap.</li>
|
||||
<li><a href=
|
||||
"../concurrent/DelayQueue.html"><strong>DelayQueue</strong></a>
|
||||
- A time-based scheduling queue backed by a priority heap.</li>
|
||||
<li><a href=
|
||||
"../concurrent/SynchronousQueue.html"><strong>SynchronousQueue</strong></a>
|
||||
- A simple rendezvous mechanism that uses the
|
||||
<tt>BlockingQueue</tt> interface.</li>
|
||||
<li><a href=
|
||||
"../concurrent/LinkedBlockingDeque.html"><strong>
|
||||
LinkedBlockingDeque</strong></a> - An optionally bounded FIFO
|
||||
blocking deque backed by linked nodes.</li>
|
||||
<li><a href=
|
||||
"../concurrent/LinkedTransferQueue.html"><strong>
|
||||
LinkedTransferQueue</strong></a> - An unbounded
|
||||
<tt>TransferQueue</tt> backed by linked nodes.</li>
|
||||
<li><a href=
|
||||
"../concurrent/ConcurrentHashMap.html"><strong>ConcurrentHashMap</strong></a>
|
||||
- A highly concurrent, high-performance <tt>ConcurrentMap</tt>
|
||||
implementation based on a hash table. This implementation never
|
||||
blocks when performing retrievals and enables the client to select
|
||||
the concurrency level for updates. It is intended as a drop-in
|
||||
replacement for <tt><a href=
|
||||
"../Hashtable.html">Hashtable</a></tt>. In
|
||||
addition to implementing <tt>ConcurrentMap</tt>, it supports all of
|
||||
the legacy methods of <tt>Hashtable</tt>.</li>
|
||||
<li><a href=
|
||||
"../concurrent/ConcurrentSkipListSet.html"><strong>
|
||||
ConcurrentSkipListSet</strong></a> - Skips list implementation of
|
||||
the <tt>NavigableSet</tt> interface.</li>
|
||||
<li><a href=
|
||||
"../concurrent/ConcurrentSkipListMap.html"><strong>
|
||||
ConcurrentSkipListMap</strong></a> - Skips list implementation of
|
||||
the <tt>ConcurrentNavigableMap</tt> interface.</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li><strong>Abstract implementations</strong> - Skeletal
|
||||
implementations of the collection interfaces to facilitate custom
|
||||
implementations.
|
||||
<ul>
|
||||
<li><a href=
|
||||
"../AbstractCollection.html"><strong>AbstractCollection</strong></a>
|
||||
- Skeletal <tt>Collection</tt> implementation that is neither a set
|
||||
nor a list (such as a "bag" or multiset).</li>
|
||||
<li><a href=
|
||||
"../AbstractSet.html"><strong>AbstractSet</strong></a>
|
||||
- Skeletal <tt>Set</tt> implementation.</li>
|
||||
<li><a href=
|
||||
"../AbstractList.html"><strong>AbstractList</strong></a>
|
||||
- Skeletal <tt>List</tt> implementation backed by a random access
|
||||
data store (such as an array).</li>
|
||||
<li><a href=
|
||||
"../AbstractSequentialList.html"><strong>AbstractSequentialList</strong></a>
|
||||
- Skeletal <tt>List</tt> implementation backed by a sequential
|
||||
access data store (such as a linked list).</li>
|
||||
<li><a href=
|
||||
"../AbstractQueue.html"><strong>AbstractQueue</strong></a>
|
||||
- Skeletal <tt>Queue</tt> implementation.</li>
|
||||
<li><a href=
|
||||
"../AbstractMap.html"><strong>AbstractMap</strong></a>
|
||||
- Skeletal <tt>Map</tt> implementation.</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li><strong>Algorithms</strong> - The <a href=
|
||||
"../Collections.html"><strong>Collections</strong></a>
|
||||
class contains these useful static methods.
|
||||
<ul>
|
||||
<li><strong><a href=
|
||||
"../Collections.html#sort-java.util.List-">sort(List)</a></strong>
|
||||
- Sorts a list using a merge sort algorithm, which provides average
|
||||
case performance comparable to a high quality quicksort, guaranteed
|
||||
O(n*log n) performance (unlike quicksort), and <em>stability</em>
|
||||
(unlike quicksort). A stable sort is one that does not reorder
|
||||
equal elements.</li>
|
||||
<li><strong><a href=
|
||||
"../Collections.html#binarySearch-java.util.List-T-">
|
||||
binarySearch(List, Object)</a></strong> - Searches for an element
|
||||
in an ordered list using the binary search algorithm.</li>
|
||||
<li><strong><a href=
|
||||
"../Collections.html#reverse-java.util.List-">reverse(List)</a></strong>
|
||||
- Reverses the order of the elements in a list.</li>
|
||||
<li><strong><a href=
|
||||
"../Collections.html#shuffle-java.util.List-">shuffle(List)</a></strong>
|
||||
- Randomly changes the order of the elements in a list.</li>
|
||||
<li><strong><a href=
|
||||
"../Collections.html#fill-java.util.List-T-">
|
||||
fill(List, Object)</a></strong> - Overwrites every element in a
|
||||
list with the specified value.</li>
|
||||
<li><strong><a href=
|
||||
"../Collections.html#copy-java.util.List-java.util.List-">
|
||||
copy(List dest, List src)</a></strong> - Copies the source list
|
||||
into the destination list.</li>
|
||||
<li><strong><a href=
|
||||
"../Collections.html#min-java.util.Collection-">
|
||||
min(Collection)</a></strong> - Returns the minimum element in a
|
||||
collection.</li>
|
||||
<li><strong><a href=
|
||||
"../Collections.html#max-java.util.Collection-">
|
||||
max(Collection)</a></strong> - Returns the maximum element in a
|
||||
collection.</li>
|
||||
<li><strong><a href=
|
||||
"../Collections.html#rotate-java.util.List-int-">
|
||||
rotate(List list, int distance)</a></strong> - Rotates all of the
|
||||
elements in the list by the specified distance.</li>
|
||||
<li><strong><a href=
|
||||
"../Collections.html#replaceAll-java.util.List-T-T-">
|
||||
replaceAll(List list, Object oldVal, Object newVal)</a></strong> -
|
||||
Replaces all occurrences of one specified value with another.</li>
|
||||
<li><strong><a href=
|
||||
"../Collections.html#indexOfSubList-java.util.List-java.util.List-">
|
||||
indexOfSubList(List source, List target)</a></strong> - Returns the
|
||||
index of the first sublist of source that is equal to target.</li>
|
||||
<li><strong><a href=
|
||||
"../Collections.html#lastIndexOfSubList-java.util.List-java.util.List-">
|
||||
lastIndexOfSubList(List source, List target)</a></strong> - Returns
|
||||
the index of the last sublist of source that is equal to
|
||||
target.</li>
|
||||
<li><strong><a href=
|
||||
"../Collections.html#swap-java.util.List-int-int-">
|
||||
swap(List, int, int)</a></strong> - Swaps the elements at the
|
||||
specified positions in the specified list.</li>
|
||||
<li><strong><a href=
|
||||
"../Collections.html#frequency-java.util.Collection-java.lang.Object-">
|
||||
frequency(Collection, Object)</a></strong> - Counts the number of
|
||||
times the specified element occurs in the specified
|
||||
collection.</li>
|
||||
<li><strong><a href=
|
||||
"../Collections.html#disjoint-java.util.Collection-java.util.Collection-">
|
||||
disjoint(Collection, Collection)</a></strong> - Determines whether
|
||||
two collections are disjoint, in other words, whether they contain
|
||||
no elements in common.</li>
|
||||
<li><strong><a href=
|
||||
"../Collections.html#addAll-java.util.Collection-T...-">
|
||||
addAll(Collection<? super T>, T...)</a></strong> - Adds all
|
||||
of the elements in the specified array to the specified
|
||||
collection.</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li><strong>Infrastructure</strong>
|
||||
<ul>
|
||||
<li><strong>Iterators</strong> - Similar to the familiar <a href=
|
||||
"../Enumeration.html">Enumeration</a>
|
||||
interface, but more powerful, and with improved method names.
|
||||
<ul>
|
||||
<li><a href=
|
||||
"../Iterator.html"><strong>Iterator</strong></a>
|
||||
- In addition to the functionality of the <tt>Enumeration</tt>
|
||||
interface, enables the user to remove elements from the backing
|
||||
collection with well-defined, useful semantics.</li>
|
||||
<li><a href=
|
||||
"../ListIterator.html"><strong>ListIterator</strong></a>
|
||||
- Iterator for use with lists. In addition to the functionality of
|
||||
the <tt>Iterator</tt> interface, supports bidirectional iteration,
|
||||
element replacement, element insertion, and index retrieval.</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li><strong>Ordering</strong>
|
||||
<ul>
|
||||
<li><a href=
|
||||
"../../lang/Comparable.html"><strong>Comparable</strong></a>
|
||||
- Imparts a <i>natural ordering</i> to classes that implement it.
|
||||
The natural ordering can be used to sort a list or maintain order
|
||||
in a sorted set or map. Many classes were retrofitted to implement
|
||||
this interface.</li>
|
||||
<li><a href=
|
||||
"../Comparator.html"><strong>Comparator</strong></a>
|
||||
- Represents an order relation, which can be used to sort a list or
|
||||
maintain order in a sorted set or map. Can override a type's
|
||||
natural ordering or order objects of a type that does not implement
|
||||
the <tt>Comparable</tt> interface.</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li><strong>Runtime exceptions</strong>
|
||||
<ul>
|
||||
<li><a href=
|
||||
"../../lang/UnsupportedOperationException.html"><strong>
|
||||
UnsupportedOperationException</strong></a> - Thrown by collections
|
||||
if an unsupported optional operation is called.</li>
|
||||
<li><a href=
|
||||
"../ConcurrentModificationException.html"><strong>
|
||||
ConcurrentModificationException</strong></a> - Thrown by iterators
|
||||
and list iterators if the backing collection is changed
|
||||
unexpectedly while the iteration is in progress. Also thrown by
|
||||
<i>sublist</i> views of lists if the backing list is changed
|
||||
unexpectedly.</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li><strong>Performance</strong>
|
||||
<ul>
|
||||
<li><strong><a href=
|
||||
"../RandomAccess.html">RandomAccess</a></strong>
|
||||
- Marker interface that lets <tt>List</tt> implementations indicate
|
||||
that they support fast (generally constant time) random access.
|
||||
This lets generic algorithms change their behavior to provide good
|
||||
performance when applied to either random or sequential access
|
||||
lists.</li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li><strong>Array Utilities</strong>
|
||||
<ul>
|
||||
<li><a href=
|
||||
"../Arrays.html"><strong>Arrays</strong></a> -
|
||||
Contains static methods to sort, search, compare, hash, copy,
|
||||
resize, convert to <tt>String</tt>, and fill arrays of primitives
|
||||
and objects.</li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
<hr />
|
||||
<p style="font-size:smaller">
|
||||
Copyright © 1998, 2017, Oracle and/or its affiliates. 500 Oracle Parkway<br />
|
||||
Redwood Shores, CA 94065 USA. All rights reserved.</p>
|
||||
<!-- Body text ends here -->
|
||||
</body>
|
||||
</html>
|
|
@ -44,7 +44,7 @@ import java.util.Comparator;
|
|||
* the ASCII characters in the set [0-9a-zA-Z_-], and cannot exceed 70
|
||||
* characters in length. Attribute values can contain any characters and
|
||||
* will be UTF8-encoded when written to the output stream. See the
|
||||
* <a href="../../../../technotes/guides/jar/jar.html">JAR File Specification</a>
|
||||
* <a href="{@docRoot}/../specs/jar/jar.html">JAR File Specification</a>
|
||||
* for more information about valid attribute names and values.
|
||||
*
|
||||
* <p>This map and its views have a predictable iteration order, namely the
|
||||
|
@ -443,7 +443,7 @@ public class Attributes implements Map<Object,Object>, Cloneable {
|
|||
* to the ASCII characters in the set [0-9a-zA-Z_-], and cannot exceed
|
||||
* 70 characters in length. Attribute values can contain any characters
|
||||
* and will be UTF8-encoded when written to the output stream. See the
|
||||
* <a href="../../../../technotes/guides/jar/jar.html">JAR File Specification</a>
|
||||
* <a href="{@docRoot}/../specs/jar/jar.html">JAR File Specification</a>
|
||||
* for more information about valid attribute names and values.
|
||||
*/
|
||||
public static class Name {
|
||||
|
@ -529,7 +529,7 @@ public class Attributes implements Map<Object,Object>, Cloneable {
|
|||
* {@code Name} object for {@code Manifest-Version}
|
||||
* manifest attribute. This attribute indicates the version number
|
||||
* of the manifest standard to which a JAR file's manifest conforms.
|
||||
* @see <a href="../../../../technotes/guides/jar/jar.html#JAR_Manifest">
|
||||
* @see <a href="{@docRoot}/../specs/jar/jar.html#JAR_Manifest">
|
||||
* Manifest and Signature Specification</a>
|
||||
*/
|
||||
public static final Name MANIFEST_VERSION = new Name("Manifest-Version");
|
||||
|
@ -537,7 +537,7 @@ public class Attributes implements Map<Object,Object>, Cloneable {
|
|||
/**
|
||||
* {@code Name} object for {@code Signature-Version}
|
||||
* manifest attribute used when signing JAR files.
|
||||
* @see <a href="../../../../technotes/guides/jar/jar.html#JAR_Manifest">
|
||||
* @see <a href="{@docRoot}/../specs/jar/jar.html#JAR_Manifest">
|
||||
* Manifest and Signature Specification</a>
|
||||
*/
|
||||
public static final Name SIGNATURE_VERSION = new Name("Signature-Version");
|
||||
|
@ -551,7 +551,7 @@ public class Attributes implements Map<Object,Object>, Cloneable {
|
|||
/**
|
||||
* {@code Name} object for {@code Class-Path}
|
||||
* manifest attribute.
|
||||
* @see <a href="../../../../technotes/guides/jar/jar.html#classpath">
|
||||
* @see <a href="{@docRoot}/../specs/jar/jar.html#classpath">
|
||||
* JAR file specification</a>
|
||||
*/
|
||||
public static final Name CLASS_PATH = new Name("Class-Path");
|
||||
|
@ -568,7 +568,7 @@ public class Attributes implements Map<Object,Object>, Cloneable {
|
|||
/**
|
||||
* {@code Name} object for {@code Sealed} manifest attribute
|
||||
* used for sealing.
|
||||
* @see <a href="../../../../technotes/guides/jar/jar.html#sealing">
|
||||
* @see <a href="{@docRoot}/../specs/jar/jar.html#sealing">
|
||||
* Package Sealing</a>
|
||||
*/
|
||||
public static final Name SEALED = new Name("Sealed");
|
||||
|
|
|
@ -39,7 +39,7 @@ import java.util.Iterator;
|
|||
* associated Attributes. There are main Manifest Attributes as well as
|
||||
* per-entry Attributes. For information on the Manifest format, please
|
||||
* see the
|
||||
* <a href="../../../../technotes/guides/jar/jar.html">
|
||||
* <a href="{@docRoot}/../specs/jar/jar.html">
|
||||
* Manifest format specification</a>.
|
||||
*
|
||||
* @author David Connelly
|
||||
|
|
|
@ -34,8 +34,7 @@ import sun.security.action.GetPropertyAction;
|
|||
|
||||
/**
|
||||
* Transforms a JAR file to or from a packed stream in Pack200 format.
|
||||
* Please refer to Network Transfer Format JSR 200 Specification at
|
||||
* <a href=http://jcp.org/aboutJava/communityprocess/review/jsr200/index.html>http://jcp.org/aboutJava/communityprocess/review/jsr200/index.html</a>
|
||||
* Please refer to <a href="{@docRoot}/../specs/pack-spec.html">Network Transfer Format JSR 200 Specification</a>
|
||||
* <p>
|
||||
* Typically the packer engine is used by application developers
|
||||
* to deploy or host JAR files on a website.
|
||||
|
|
|
@ -40,7 +40,7 @@
|
|||
* <a href="../zip/package-summary.html#package_description">java.util.zip
|
||||
* package description.</a> <p>
|
||||
* In JAR files, all file names must be encoded in the UTF-8 encoding.
|
||||
* <li><a href="../../../../technotes/guides/jar/jar.html">
|
||||
* <li><a href="{@docRoot}/../specs/jar/jar.html">
|
||||
* Manifest and Signature Specification</a> - The manifest format specification.
|
||||
* </ul>
|
||||
*
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue