This commit is contained in:
J. Duke 2017-08-24 16:24:37 +02:00
commit 21a6c262c8
743 changed files with 18976 additions and 19418 deletions

View File

@ -1,3 +1,4 @@
94680c6d60ecd9ed3ffd1847706efde7eb947afc jdk-9+174
6dd7fda42bab7ecf648cafb0a4e9b4ca11b3094f jdk-9+173
dad6746278facbbea57dd462cb56fb743dc0a5f0 jdk-9+172
643b5f18c2656fe91b69fea85b07b98d5fad394d jdk-9+171
@ -428,3 +429,4 @@ c42dc7b58b4d4301ea676a76326fd9bbd403d595 jdk-10+8
aa5b01f5e5620438fd39efdb2e2f6365a2c7d898 jdk-10+9
b0f2b8ff25a2209b2c807785d75f20e5086bbfc2 jdk-10+10
036dbf8b381798e5d31065109714d04d97bf98a4 jdk-10+11
e6d70017f5b9adbb2ec82d826973d0251800a3c3 jdk-10+12

View File

@ -428,3 +428,7 @@ b94be69cbb1d2943b886bf2d458745756df146e4 jdk-10+9
2c25fc24103251f9711a1c280c31e1e41016d90f jdk-9+172
6b750cdb823a029a25ff2e560302cc2d28a86cb6 jdk-10+11
88d7fd969e7df0e07a53b201cfd29393ca33ede9 jdk-9+173
5466f409346e0446ee9a6daeb7f5d75c8fc76823 jdk-9+174
8d4ed1e06fe184c9cb08c5b708e7d6f5c066644f jdk-10+12
8f7227c6012b0051ea4e0bcee040c627bf699b88 jdk-9+175
d67a3f1f057f7e31e12f33ebe3667cb73d252268 jdk-10+13

View File

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

View File

@ -688,6 +688,7 @@ LIBFFI_LIBS
LIBFFI_CFLAGS
ALSA_LIBS
ALSA_CFLAGS
FREETYPE_LICENSE
FREETYPE_BUNDLE_LIB_PATH
FREETYPE_LIBS
FREETYPE_CFLAGS
@ -1200,6 +1201,7 @@ with_freetype_include
with_freetype_lib
with_freetype_src
enable_freetype_bundling
with_freetype_license
with_alsa
with_alsa_include
with_alsa_lib
@ -2153,6 +2155,7 @@ Optional Packages:
--with-freetype-src specify directory with freetype sources to
automatically build the library (experimental,
Windows-only)
--with-freetype-license if bundling freetype, also bundle this license file
--with-alsa specify prefix directory for the alsa package
(expecting the libraries under PATH/lib and the
headers under PATH/include)
@ -5186,7 +5189,7 @@ VS_SDK_PLATFORM_NAME_2013=
#CUSTOM_AUTOCONF_INCLUDE
# Do not change or remove the following line, it is needed for consistency checks:
DATE_WHEN_GENERATED=1494858828
DATE_WHEN_GENERATED=1496926402
###############################################################################
#
@ -57906,6 +57909,12 @@ if test "${enable_freetype_bundling+set}" = set; then :
fi
# Check whether --with-freetype-license was given.
if test "${with_freetype_license+set}" = set; then :
withval=$with_freetype_license;
fi
# Need to specify explicitly since it needs to be overridden on some versions of macosx
FREETYPE_BASE_NAME=freetype
FREETYPE_CFLAGS=
@ -63852,6 +63861,153 @@ $as_echo "$BUNDLE_FREETYPE" >&6; }
fi # end freetype needed
FREETYPE_LICENSE=""
if test "x$with_freetype_license" = "xyes"; then
as_fn_error $? "--with-freetype-license must have a value" "$LINENO" 5
elif test "x$with_freetype_license" != "x"; then
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for freetype license" >&5
$as_echo_n "checking for freetype license... " >&6; }
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $with_freetype_license" >&5
$as_echo "$with_freetype_license" >&6; }
FREETYPE_LICENSE="$with_freetype_license"
# Only process if variable expands to non-empty
if test "x$FREETYPE_LICENSE" != x; then
if test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.cygwin"; then
# Input might be given as Windows format, start by converting to
# unix format.
path="$FREETYPE_LICENSE"
new_path=`$CYGPATH -u "$path"`
# Cygwin tries to hide some aspects of the Windows file system, such that binaries are
# named .exe but called without that suffix. Therefore, "foo" and "foo.exe" are considered
# the same file, most of the time (as in "test -f"). But not when running cygpath -s, then
# "foo.exe" is OK but "foo" is an error.
#
# This test is therefore slightly more accurate than "test -f" to check for file precense.
# It is also a way to make sure we got the proper file name for the real test later on.
test_shortpath=`$CYGPATH -s -m "$new_path" 2> /dev/null`
if test "x$test_shortpath" = x; then
{ $as_echo "$as_me:${as_lineno-$LINENO}: The path of FREETYPE_LICENSE, which resolves as \"$path\", is invalid." >&5
$as_echo "$as_me: The path of FREETYPE_LICENSE, which resolves as \"$path\", is invalid." >&6;}
as_fn_error $? "Cannot locate the the path of FREETYPE_LICENSE" "$LINENO" 5
fi
# Call helper function which possibly converts this using DOS-style short mode.
# If so, the updated path is stored in $new_path.
input_path="$new_path"
# Check if we need to convert this using DOS-style short mode. If the path
# contains just simple characters, use it. Otherwise (spaces, weird characters),
# take no chances and rewrite it.
# Note: m4 eats our [], so we need to use [ and ] instead.
has_forbidden_chars=`$ECHO "$input_path" | $GREP [^-._/a-zA-Z0-9]`
if test "x$has_forbidden_chars" != x; then
# Now convert it to mixed DOS-style, short mode (no spaces, and / instead of \)
shortmode_path=`$CYGPATH -s -m -a "$input_path"`
path_after_shortmode=`$CYGPATH -u "$shortmode_path"`
if test "x$path_after_shortmode" != "x$input_to_shortpath"; then
# Going to short mode and back again did indeed matter. Since short mode is
# case insensitive, let's make it lowercase to improve readability.
shortmode_path=`$ECHO "$shortmode_path" | $TR 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'`
# Now convert it back to Unix-style (cygpath)
input_path=`$CYGPATH -u "$shortmode_path"`
new_path="$input_path"
fi
fi
test_cygdrive_prefix=`$ECHO $input_path | $GREP ^/cygdrive/`
if test "x$test_cygdrive_prefix" = x; then
# As a simple fix, exclude /usr/bin since it's not a real path.
if test "x`$ECHO $new_path | $GREP ^/usr/bin/`" = x; then
# The path is in a Cygwin special directory (e.g. /home). We need this converted to
# a path prefixed by /cygdrive for fixpath to work.
new_path="$CYGWIN_ROOT_PATH$input_path"
fi
fi
if test "x$path" != "x$new_path"; then
FREETYPE_LICENSE="$new_path"
{ $as_echo "$as_me:${as_lineno-$LINENO}: Rewriting FREETYPE_LICENSE to \"$new_path\"" >&5
$as_echo "$as_me: Rewriting FREETYPE_LICENSE to \"$new_path\"" >&6;}
fi
elif test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.msys"; then
path="$FREETYPE_LICENSE"
has_colon=`$ECHO $path | $GREP ^.:`
new_path="$path"
if test "x$has_colon" = x; then
# Not in mixed or Windows style, start by that.
new_path=`cmd //c echo $path`
fi
input_path="$new_path"
# Check if we need to convert this using DOS-style short mode. If the path
# contains just simple characters, use it. Otherwise (spaces, weird characters),
# take no chances and rewrite it.
# Note: m4 eats our [], so we need to use [ and ] instead.
has_forbidden_chars=`$ECHO "$input_path" | $GREP [^-_/:a-zA-Z0-9]`
if test "x$has_forbidden_chars" != x; then
# Now convert it to mixed DOS-style, short mode (no spaces, and / instead of \)
new_path=`cmd /c "for %A in (\"$input_path\") do @echo %~sA"|$TR \\\\\\\\ / | $TR 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'`
fi
windows_path="$new_path"
if test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.cygwin"; then
unix_path=`$CYGPATH -u "$windows_path"`
new_path="$unix_path"
elif test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.msys"; then
unix_path=`$ECHO "$windows_path" | $SED -e 's,^\\(.\\):,/\\1,g' -e 's,\\\\,/,g'`
new_path="$unix_path"
fi
if test "x$path" != "x$new_path"; then
FREETYPE_LICENSE="$new_path"
{ $as_echo "$as_me:${as_lineno-$LINENO}: Rewriting FREETYPE_LICENSE to \"$new_path\"" >&5
$as_echo "$as_me: Rewriting FREETYPE_LICENSE to \"$new_path\"" >&6;}
fi
# Save the first 10 bytes of this path to the storage, so fixpath can work.
all_fixpath_prefixes=("${all_fixpath_prefixes[@]}" "${new_path:0:10}")
else
# We're on a unix platform. Hooray! :)
path="$FREETYPE_LICENSE"
has_space=`$ECHO "$path" | $GREP " "`
if test "x$has_space" != x; then
{ $as_echo "$as_me:${as_lineno-$LINENO}: The path of FREETYPE_LICENSE, which resolves as \"$path\", is invalid." >&5
$as_echo "$as_me: The path of FREETYPE_LICENSE, which resolves as \"$path\", is invalid." >&6;}
as_fn_error $? "Spaces are not allowed in this path." "$LINENO" 5
fi
# Use eval to expand a potential ~
eval path="$path"
if test ! -f "$path" && test ! -d "$path"; then
as_fn_error $? "The path of FREETYPE_LICENSE, which resolves as \"$path\", is not found." "$LINENO" 5
fi
if test -d "$path"; then
FREETYPE_LICENSE="`cd "$path"; $THEPWDCMD -L`"
else
dir="`$DIRNAME "$path"`"
base="`$BASENAME "$path"`"
FREETYPE_LICENSE="`cd "$dir"; $THEPWDCMD -L`/$base"
fi
fi
fi
if test ! -f "$FREETYPE_LICENSE"; then
as_fn_error $? "$FREETYPE_LICENSE cannot be found" "$LINENO" 5
fi
fi

View File

@ -194,6 +194,8 @@ AC_DEFUN_ONCE([LIB_SETUP_FREETYPE],
[specify directory with freetype sources to automatically build the library (experimental, Windows-only)])])
AC_ARG_ENABLE(freetype-bundling, [AS_HELP_STRING([--disable-freetype-bundling],
[disable bundling of the freetype library with the build result @<:@enabled on Windows or when using --with-freetype, disabled otherwise@:>@])])
AC_ARG_WITH(freetype-license, [AS_HELP_STRING([--with-freetype-license],
[if bundling freetype, also bundle this license file])])
# Need to specify explicitly since it needs to be overridden on some versions of macosx
FREETYPE_BASE_NAME=freetype
@ -443,7 +445,21 @@ AC_DEFUN_ONCE([LIB_SETUP_FREETYPE],
fi # end freetype needed
FREETYPE_LICENSE=""
if test "x$with_freetype_license" = "xyes"; then
AC_MSG_ERROR([--with-freetype-license must have a value])
elif test "x$with_freetype_license" != "x"; then
AC_MSG_CHECKING([for freetype license])
AC_MSG_RESULT([$with_freetype_license])
FREETYPE_LICENSE="$with_freetype_license"
BASIC_FIXUP_PATH(FREETYPE_LICENSE)
if test ! -f "$FREETYPE_LICENSE"; then
AC_MSG_ERROR([$FREETYPE_LICENSE cannot be found])
fi
fi
AC_SUBST(FREETYPE_BUNDLE_LIB_PATH)
AC_SUBST(FREETYPE_CFLAGS)
AC_SUBST(FREETYPE_LIBS)
AC_SUBST(FREETYPE_LICENSE)
])

View File

@ -312,6 +312,7 @@ DEFAULT_MAKE_TARGET:=@DEFAULT_MAKE_TARGET@
FREETYPE_LIBS:=@FREETYPE_LIBS@
FREETYPE_CFLAGS:=@FREETYPE_CFLAGS@
FREETYPE_BUNDLE_LIB_PATH=@FREETYPE_BUNDLE_LIB_PATH@
FREETYPE_LICENSE=@FREETYPE_LICENSE@
CUPS_CFLAGS:=@CUPS_CFLAGS@
ALSA_LIBS:=@ALSA_LIBS@
ALSA_CFLAGS:=@ALSA_CFLAGS@

View File

@ -893,6 +893,16 @@ var getJibProfilesProfiles = function (input, common, data) {
}
});
// The windows ri profile needs to add the freetype license file
profilesRiFreetype = {
"windows-x86-ri": {
configure_args: "--with-freetype-license="
+ input.get("freetype", "install_path")
+ "/freetype-2.7.1-v120-x86/freetype.md"
}
};
profiles = concatObjects(profiles, profilesRiFreetype);
// Generate the missing platform attributes
profiles = generatePlatformAttributes(profiles);
profiles = generateDefaultMakeTargetsConfigureArg(common, profiles);

View File

@ -18,14 +18,16 @@
</header>
<nav id="TOC">
<ul>
<li><a href="#using-the-run-test-framework">Using the run-test framework</a></li>
<li><a href="#using-the-run-test-framework">Using the run-test framework</a><ul>
<li><a href="#configuration">Configuration</a></li>
</ul></li>
<li><a href="#test-selection">Test selection</a><ul>
<li><a href="#jtreg">JTreg</a></li>
<li><a href="#jtreg">JTReg</a></li>
<li><a href="#gtest">Gtest</a></li>
</ul></li>
<li><a href="#test-results-and-summary">Test results and summary</a></li>
<li><a href="#test-suite-control">Test suite control</a><ul>
<li><a href="#jtreg-keywords">JTreg keywords</a></li>
<li><a href="#jtreg-keywords">JTReg keywords</a></li>
<li><a href="#gtest-keywords">Gtest keywords</a></li>
</ul></li>
</ul>
@ -41,14 +43,17 @@ $ make run-test-only TEST=&quot;gtest:LogTagSet gtest:LogTagSetDescriptions&quot
$ make run-test TEST=&quot;hotspot/test:hotspot_gc&quot; JTREG=&quot;JOBS=1;TIMEOUT=8;VM_OTIONS=-XshowSettings -Xlog:gc+ref=debug&quot;
$ make run-test TEST=&quot;jtreg:hotspot/test:hotspot_gc hotspot/test/native_sanity/JniVersion.java&quot;
$ make exploded-run-test TEST=hotspot_tier1</code></pre>
<h3 id="configuration">Configuration</h3>
<p>To be able to run JTReg tests, <code>configure</code> needs to know where to find the JTReg test framework. If it is not picked up automatically by configure, use the <code>--with-jtreg=&lt;path to jtreg home&gt;</code> option to point to the JTReg framework. Note that this option should point to the JTReg home, i.e. the top directory, containing <code>lib/jtreg.jar</code> etc. (An alternative is to set the <code>JT_HOME</code> environment variable to point to the JTReg home before running <code>configure</code>.)</p>
<h2 id="test-selection">Test selection</h2>
<p>All functionality is available using the run-test make target. In this use case, the test or tests to be executed is controlled using the <code>TEST</code> variable. To speed up subsequent test runs with no source code changes, run-test-only can be used instead, which do not depend on the source and test image build.</p>
<p>For some common top-level tests, direct make targets have been generated. This includes all JTreg test groups, the hotspot gtest, and custom tests (if present). This means that <code>make run-test-tier1</code> is equivalent to <code>make run-test TEST=&quot;tier1&quot;</code>, but the latter is more tab-completion friendly. For more complex test runs, the <code>run-test TEST=&quot;x&quot;</code> solution needs to be used.</p>
<p>For some common top-level tests, direct make targets have been generated. This includes all JTReg test groups, the hotspot gtest, and custom tests (if present). This means that <code>make run-test-tier1</code> is equivalent to <code>make run-test TEST=&quot;tier1&quot;</code>, but the latter is more tab-completion friendly. For more complex test runs, the <code>run-test TEST=&quot;x&quot;</code> solution needs to be used.</p>
<p>The test specifications given in <code>TEST</code> is parsed into fully qualified test descriptors, which clearly and unambigously show which tests will be run. As an example, <code>:tier1</code> will expand to <code>jtreg:jdk/test:tier1 jtreg:langtools/test:tier1 jtreg:nashorn/test:tier1 jtreg:jaxp/test:tier1</code>. You can always submit a list of fully qualified test descriptors in the <code>TEST</code> variable if you want to shortcut the parser.</p>
<h3 id="jtreg">JTreg</h3>
<p>JTreg test groups can be specified either without a test root, e.g. <code>:tier1</code> (or <code>tier1</code>, the initial colon is optional), or with, e.g. <code>hotspot/test:tier1</code>, <code>jdk/test:jdk_util</code>.</p>
<h3 id="jtreg">JTReg</h3>
<p>JTReg test groups can be specified either without a test root, e.g. <code>:tier1</code> (or <code>tier1</code>, the initial colon is optional), or with, e.g. <code>hotspot/test:tier1</code>, <code>jdk/test:jdk_util</code>.</p>
<p>When specified without a test root, all matching groups from all tests roots will be added. Otherwise, only the group from the specified test root will be added.</p>
<p>Individual JTreg tests or directories containing JTreg tests can also be specified, like <code>hotspot/test/native_sanity/JniVersion.java</code> or <code>hotspot/test/native_sanity</code>. You can also specify an absolute path, to point to a JTreg test outside the source tree.</p>
<p>Individual JTReg tests or directories containing JTReg tests can also be specified, like <code>hotspot/test/native_sanity/JniVersion.java</code> or <code>hotspot/test/native_sanity</code>. You can also specify an absolute path, to point to a JTReg test outside the source tree.</p>
<p>As long as the test groups or test paths can be uniquely resolved, you do not need to enter the <code>jtreg:</code> prefix. If this is not possible, or if you want to use a fully qualified test descriptor, add <code>jtreg:</code>, e.g. <code>jtreg:hotspot/test/native_sanity</code>.</p>
<h3 id="gtest">Gtest</h3>
<p>Since the Hotspot Gtest suite is so quick, the default is to run all tests. This is specified by just <code>gtest</code>, or as a fully qualified test descriptor <code>gtest:all</code>.</p>
@ -67,15 +72,15 @@ TEST FAILURE</code></pre>
<p>Tests where the number of TOTAL tests does not equal the number of PASSed tests will be considered a test failure. These are marked with the <code>&gt;&gt; ... &lt;&lt;</code> marker for easy identification.</p>
<p>The classification of non-passed tests differs a bit between test suites. In the summary, ERROR is used as a catch-all for tests that neither passed nor are classified as failed by the framework. This might indicate test framework error, timeout or other problems.</p>
<p>In case of test failures, <code>make run-test</code> will exit with a non-zero exit value.</p>
<p>All tests have their result stored in <code>build/$BUILD/test-result/$TEST_ID</code>, where TEST_ID is a path-safe conversion from the fully qualified test descriptor, e.g. for <code>jtreg:jdk/test:tier1</code> the TEST_ID is <code>jtreg_jdk_test_tier1</code>. This path is also printed in the log at the end of the test run.</p>
<p>All tests have their result stored in <code>build/$BUILD/test-results/$TEST_ID</code>, where TEST_ID is a path-safe conversion from the fully qualified test descriptor, e.g. for <code>jtreg:jdk/test:tier1</code> the TEST_ID is <code>jtreg_jdk_test_tier1</code>. This path is also printed in the log at the end of the test run.</p>
<p>Additional work data is stored in <code>build/$BUILD/test-support/$TEST_ID</code>. For some frameworks, this directory might contain information that is useful in determining the cause of a failed test.</p>
<h2 id="test-suite-control">Test suite control</h2>
<p>It is possible to control various aspects of the test suites using make control variables.</p>
<p>These variables use a keyword=value approach to allow multiple values to be set. So, for instance, <code>JTREG=&quot;JOBS=1;TIMEOUT=8&quot;</code> will set the JTreg concurrency level to 1 and the timeout factor to 8. This is equivalent to setting <code>JTREG_JOBS=1 JTREG_TIMEOUT=8</code>, but using the keyword format means that the <code>JTREG</code> variable is parsed and verified for correctness, so <code>JTREG=&quot;TMIEOUT=8&quot;</code> would give an error, while <code>JTREG_TMIEOUT=8</code> would just pass unnoticed.</p>
<p>These variables use a keyword=value approach to allow multiple values to be set. So, for instance, <code>JTREG=&quot;JOBS=1;TIMEOUT=8&quot;</code> will set the JTReg concurrency level to 1 and the timeout factor to 8. This is equivalent to setting <code>JTREG_JOBS=1 JTREG_TIMEOUT=8</code>, but using the keyword format means that the <code>JTREG</code> variable is parsed and verified for correctness, so <code>JTREG=&quot;TMIEOUT=8&quot;</code> would give an error, while <code>JTREG_TMIEOUT=8</code> would just pass unnoticed.</p>
<p>To separate multiple keyword=value pairs, use <code>;</code> (semicolon). Since the shell normally eats <code>;</code>, the recommended usage is to write the assignment inside qoutes, e.g. <code>JTREG=&quot;...;...&quot;</code>. This will also make sure spaces are preserved, as in <code>JTREG=&quot;VM_OTIONS=-XshowSettings -Xlog:gc+ref=debug&quot;</code>.</p>
<p>(Other ways are possible, e.g. using backslash: <code>JTREG=JOBS=1\;TIMEOUT=8</code>. Also, as a special technique, the string <code>%20</code> will be replaced with space for certain options, e.g. <code>JTREG=VM_OTIONS=-XshowSettings%20-Xlog:gc+ref=debug</code>. This can be useful if you have layers of scripts and have trouble getting proper quoting of command line arguments through.)</p>
<p>As far as possible, the names of the keywords have been standardized between test suites.</p>
<h3 id="jtreg-keywords">JTreg keywords</h3>
<h3 id="jtreg-keywords">JTReg keywords</h3>
<h4 id="jobs">JOBS</h4>
<p>The test concurrency (<code>-concurrency</code>).</p>
<p>Defaults to TEST_JOBS (if set by <code>--with-test-jobs=</code>), otherwise it defaults to JOBS, except for Hotspot, where the default is <em>number of CPU cores/2</em>, but never more than 12.</p>
@ -96,15 +101,15 @@ TEST FAILURE</code></pre>
<p>Defaults to <code>fail,error</code>.</p>
<h4 id="max_mem">MAX_MEM</h4>
<p>Limit memory consumption (<code>-Xmx</code> and <code>-vmoption:-Xmx</code>, or none).</p>
<p>Limit memory consumption for JTreg test framework and VM under test. Set to 0 to disable the limits.</p>
<p>Limit memory consumption for JTReg test framework and VM under test. Set to 0 to disable the limits.</p>
<p>Defaults to 512m, except for hotspot, where it defaults to 0 (no limit).</p>
<h4 id="options">OPTIONS</h4>
<p>Additional options to the JTreg test framework.</p>
<p>Use <code>JTREG=&quot;OPTIONS=--help all&quot;</code> to see all available JTreg options.</p>
<p>Additional options to the JTReg test framework.</p>
<p>Use <code>JTREG=&quot;OPTIONS=--help all&quot;</code> to see all available JTReg options.</p>
<h4 id="java_options">JAVA_OPTIONS</h4>
<p>Additional Java options to JTreg (<code>-javaoption</code>).</p>
<p>Additional Java options to JTReg (<code>-javaoption</code>).</p>
<h4 id="vm_options">VM_OPTIONS</h4>
<p>Additional VM options to JTreg (<code>-vmoption</code>).</p>
<p>Additional VM options to JTReg (<code>-vmoption</code>).</p>
<h3 id="gtest-keywords">Gtest keywords</h3>
<h4 id="repeat">REPEAT</h4>
<p>The number of times to repeat the tests (<code>--gtest_repeat</code>).</p>

View File

@ -22,6 +22,15 @@ Some example command-lines:
$ make run-test TEST="jtreg:hotspot/test:hotspot_gc hotspot/test/native_sanity/JniVersion.java"
$ make 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

View File

@ -428,3 +428,7 @@ c62e5964cfcf144d8f72e9ba69757897785349a9 jdk-9+171
95ed14547ca9246baed34f90ef3ca13217538a8c jdk-9+172
8ef8a0f1c4dfea17e10125e1f885920538e63085 jdk-10+11
534ba4f8cfcf12accc5b9adb943103f2ff79fe16 jdk-9+173
3615768c12904e29bb2ec1b506cd4633cd8a9ced jdk-9+174
00ae6307d78bac49883ddc85d687aa88c49f3971 jdk-10+12
dc78a3dd6b3a4f11cdae8a3e3d160e6a78bc7838 jdk-9+175
564fced058bd2c8375e9104aa8f9494642cd7bdd jdk-10+13

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -588,3 +588,7 @@ c6cd3ec8d46b034e57c86399380ffcf7f25706e4 jdk-10+10
1ae9e84f68b359420d2d153ecfe5ee2903e33a2e jdk-9+172
7f14e550f1e8abea41c223e5fdad2261e99ba929 jdk-10+11
e64b1cb48d6e7703928a9d1da106fc27f8cb65fd jdk-9+173
944791f8160185bffa13fbb821fc09b6198f1f25 jdk-9+174
070aa7a2eb14c4645f7eb31384cba0a2ba72a4b5 jdk-10+12
8f04d457168b9f1f4a1b2c37f49e0513ca9d33a7 jdk-9+175
a9da03357f190807591177fe9846d6e68ad64fc0 jdk-10+13

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -234,8 +234,8 @@ void LIRGenerator::cmp_reg_mem(LIR_Condition condition, LIR_Opr reg, LIR_Opr bas
}
bool LIRGenerator::strength_reduce_multiply(LIR_Opr left, int c, LIR_Opr result, LIR_Opr tmp) {
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)) {

View File

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

View File

@ -26,6 +26,15 @@
/**
* Defines the implementation of the HotSpot Serviceability Agent.
*
* <p> This module includes the <em>{@index jhsdb jhsdb tool}</em> tool to
* attach to a running Java Virtual Machine (JVM) or launch a postmortem
* debugger to analyze the content of a core-dump from a crashed JVM.
*
* <dl style="font-family:'DejaVu Sans', Arial, Helvetica, sans serif">
* <dt class="simpleTagLabel">Tool Guides:</dt>
* <dd> {@extLink jhsdb_tool_reference jhsdb}</dd>
* </dl>
*
* @moduleGraph
* @since 9
*/

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -251,7 +251,13 @@ public class StandardGraphBuilderPlugins {
for (JavaKind kind : new JavaKind[]{JavaKind.Int, JavaKind.Long, JavaKind.Object}) {
Class<?> javaClass = kind == JavaKind.Object ? Object.class : kind.toJavaClass();
r.register5("compareAndSwap" + kind.name(), Receiver.class, Object.class, long.class, javaClass, javaClass, new InvocationPlugin() {
String casName;
if (Java8OrEarlier) {
casName = "compareAndSwap";
} else {
casName = "compareAndSet";
}
r.register5(casName + kind.name(), Receiver.class, Object.class, long.class, javaClass, javaClass, new InvocationPlugin() {
@Override
public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver unsafe, ValueNode object, ValueNode offset, ValueNode expected, ValueNode x) {
// Emits a null-check for the otherwise unused receiver

View File

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

View File

@ -313,7 +313,7 @@ class LIRGenerator: public InstructionVisitor, public BlockClosure {
// is_strictfp is only needed for mul and div (and only generates different code on i486)
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);

View File

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

View File

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

View File

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

View File

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

View File

@ -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()) {

View File

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

View File

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

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1997, 2017, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* 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
*/

View File

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

View File

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

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2003, 2016, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2003, 2017, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* 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;
}
}
{

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1997, 2017, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -1095,8 +1095,11 @@ inline intptr_t bitfield(intptr_t x, int start_bit_no, int field_length) {
#undef min
#endif
#define max(a,b) Do_not_use_max_use_MAX2_instead
#define min(a,b) Do_not_use_min_use_MIN2_instead
// The following defines serve the purpose of preventing use of accidentally
// included min max macros from compiling, while continuing to allow innocent
// min and max identifiers in the code to compile as intended.
#define max max
#define min min
// It is necessary to use templates here. Having normal overloaded
// functions does not work because it is necessary to provide both 32-

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

View File

@ -773,221 +773,221 @@ public class TestIntUnsafeCAS {
static void test_ci(int[] a) {
for (int i = 0; i < ARRLEN; i+=1) {
unsafe.compareAndSwapInt(a, byte_offset(i), -1, -123);
unsafe.compareAndSetInt(a, byte_offset(i), -1, -123);
}
}
static void test_vi(int[] a, int b, int old) {
for (int i = 0; i < ARRLEN; i+=1) {
unsafe.compareAndSwapInt(a, byte_offset(i), old, b);
unsafe.compareAndSetInt(a, byte_offset(i), old, b);
}
}
static void test_cp(int[] a, int[] b) {
for (int i = 0; i < ARRLEN; i+=1) {
unsafe.compareAndSwapInt(a, byte_offset(i), -123, b[i]);
unsafe.compareAndSetInt(a, byte_offset(i), -123, b[i]);
}
}
static void test_2ci(int[] a, int[] b) {
for (int i = 0; i < ARRLEN; i+=1) {
unsafe.compareAndSwapInt(a, byte_offset(i), 123, -123);
unsafe.compareAndSwapInt(b, byte_offset(i), 123, -103);
unsafe.compareAndSetInt(a, byte_offset(i), 123, -123);
unsafe.compareAndSetInt(b, byte_offset(i), 123, -103);
}
}
static void test_2vi(int[] a, int[] b, int c, int d) {
for (int i = 0; i < ARRLEN; i+=1) {
unsafe.compareAndSwapInt(a, byte_offset(i), -123, c);
unsafe.compareAndSwapInt(b, byte_offset(i), -103, d);
unsafe.compareAndSetInt(a, byte_offset(i), -123, c);
unsafe.compareAndSetInt(b, byte_offset(i), -103, d);
}
}
static void test_ci_neg(int[] a, int old) {
for (int i = ARRLEN-1; i >= 0; i-=1) {
unsafe.compareAndSwapInt(a, byte_offset(i), old, -123);
unsafe.compareAndSetInt(a, byte_offset(i), old, -123);
}
}
static void test_vi_neg(int[] a, int b, int old) {
for (int i = ARRLEN-1; i >= 0; i-=1) {
unsafe.compareAndSwapInt(a, byte_offset(i), old, b);
unsafe.compareAndSetInt(a, byte_offset(i), old, b);
}
}
static void test_cp_neg(int[] a, int[] b) {
for (int i = ARRLEN-1; i >= 0; i-=1) {
unsafe.compareAndSwapInt(a, byte_offset(i), -123, b[i]);
unsafe.compareAndSetInt(a, byte_offset(i), -123, b[i]);
}
}
static void test_2ci_neg(int[] a, int[] b) {
for (int i = ARRLEN-1; i >= 0; i-=1) {
unsafe.compareAndSwapInt(a, byte_offset(i), 123, -123);
unsafe.compareAndSwapInt(b, byte_offset(i), 123, -103);
unsafe.compareAndSetInt(a, byte_offset(i), 123, -123);
unsafe.compareAndSetInt(b, byte_offset(i), 123, -103);
}
}
static void test_2vi_neg(int[] a, int[] b, int c, int d) {
for (int i = ARRLEN-1; i >= 0; i-=1) {
unsafe.compareAndSwapInt(a, byte_offset(i), -123, c);
unsafe.compareAndSwapInt(b, byte_offset(i), -103, d);
unsafe.compareAndSetInt(a, byte_offset(i), -123, c);
unsafe.compareAndSetInt(b, byte_offset(i), -103, d);
}
}
static void test_ci_oppos(int[] a, int old) {
int limit = ARRLEN-1;
for (int i = 0; i < ARRLEN; i+=1) {
unsafe.compareAndSwapInt(a, byte_offset(limit-i), old, -123);
unsafe.compareAndSetInt(a, byte_offset(limit-i), old, -123);
}
}
static void test_vi_oppos(int[] a, int b, int old) {
int limit = ARRLEN-1;
for (int i = limit; i >= 0; i-=1) {
unsafe.compareAndSwapInt(a, byte_offset(limit-i), old, b);
unsafe.compareAndSetInt(a, byte_offset(limit-i), old, b);
}
}
static void test_cp_oppos(int[] a, int[] b) {
int limit = ARRLEN-1;
for (int i = 0; i < ARRLEN; i+=1) {
unsafe.compareAndSwapInt(a, byte_offset(i), -123, b[limit-i]);
unsafe.compareAndSetInt(a, byte_offset(i), -123, b[limit-i]);
}
}
static void test_2ci_oppos(int[] a, int[] b) {
int limit = ARRLEN-1;
for (int i = 0; i < ARRLEN; i+=1) {
unsafe.compareAndSwapInt(a, byte_offset(limit-i), 123, -123);
unsafe.compareAndSwapInt(b, byte_offset(i), 123, -103);
unsafe.compareAndSetInt(a, byte_offset(limit-i), 123, -123);
unsafe.compareAndSetInt(b, byte_offset(i), 123, -103);
}
}
static void test_2vi_oppos(int[] a, int[] b, int c, int d) {
int limit = ARRLEN-1;
for (int i = limit; i >= 0; i-=1) {
unsafe.compareAndSwapInt(a, byte_offset(i), -123, c);
unsafe.compareAndSwapInt(b, byte_offset(limit-i), -103, d);
unsafe.compareAndSetInt(a, byte_offset(i), -123, c);
unsafe.compareAndSetInt(b, byte_offset(limit-i), -103, d);
}
}
static void test_ci_off(int[] a, int old) {
for (int i = 0; i < ARRLEN-OFFSET; i+=1) {
unsafe.compareAndSwapInt(a, byte_offset(i+OFFSET), old, -123);
unsafe.compareAndSetInt(a, byte_offset(i+OFFSET), old, -123);
}
}
static void test_vi_off(int[] a, int b, int old) {
for (int i = 0; i < ARRLEN-OFFSET; i+=1) {
unsafe.compareAndSwapInt(a, byte_offset(i+OFFSET), old, b);
unsafe.compareAndSetInt(a, byte_offset(i+OFFSET), old, b);
}
}
static void test_cp_off(int[] a, int[] b) {
for (int i = 0; i < ARRLEN-OFFSET; i+=1) {
unsafe.compareAndSwapInt(a, byte_offset(i+OFFSET), -123, b[i+OFFSET]);
unsafe.compareAndSetInt(a, byte_offset(i+OFFSET), -123, b[i+OFFSET]);
}
}
static void test_2ci_off(int[] a, int[] b) {
for (int i = 0; i < ARRLEN-OFFSET; i+=1) {
unsafe.compareAndSwapInt(a, byte_offset(i+OFFSET), 123, -123);
unsafe.compareAndSwapInt(b, byte_offset(i+OFFSET), 123, -103);
unsafe.compareAndSetInt(a, byte_offset(i+OFFSET), 123, -123);
unsafe.compareAndSetInt(b, byte_offset(i+OFFSET), 123, -103);
}
}
static void test_2vi_off(int[] a, int[] b, int c, int d) {
for (int i = 0; i < ARRLEN-OFFSET; i+=1) {
unsafe.compareAndSwapInt(a, byte_offset(i+OFFSET), -123, c);
unsafe.compareAndSwapInt(b, byte_offset(i+OFFSET), -103, d);
unsafe.compareAndSetInt(a, byte_offset(i+OFFSET), -123, c);
unsafe.compareAndSetInt(b, byte_offset(i+OFFSET), -103, d);
}
}
static void test_ci_inv(int[] a, int k, int old) {
for (int i = 0; i < ARRLEN-k; i+=1) {
unsafe.compareAndSwapInt(a, byte_offset(i+k), old, -123);
unsafe.compareAndSetInt(a, byte_offset(i+k), old, -123);
}
}
static void test_vi_inv(int[] a, int b, int k, int old) {
for (int i = 0; i < ARRLEN-k; i+=1) {
unsafe.compareAndSwapInt(a, byte_offset(i+k), old, b);
unsafe.compareAndSetInt(a, byte_offset(i+k), old, b);
}
}
static void test_cp_inv(int[] a, int[] b, int k) {
for (int i = 0; i < ARRLEN-k; i+=1) {
unsafe.compareAndSwapInt(a, byte_offset(i+k), -123, b[i+k]);
unsafe.compareAndSetInt(a, byte_offset(i+k), -123, b[i+k]);
}
}
static void test_2ci_inv(int[] a, int[] b, int k) {
for (int i = 0; i < ARRLEN-k; i+=1) {
unsafe.compareAndSwapInt(a, byte_offset(i+k), 123, -123);
unsafe.compareAndSwapInt(b, byte_offset(i+k), 123, -103);
unsafe.compareAndSetInt(a, byte_offset(i+k), 123, -123);
unsafe.compareAndSetInt(b, byte_offset(i+k), 123, -103);
}
}
static void test_2vi_inv(int[] a, int[] b, int c, int d, int k) {
for (int i = 0; i < ARRLEN-k; i+=1) {
unsafe.compareAndSwapInt(a, byte_offset(i+k), -123, c);
unsafe.compareAndSwapInt(b, byte_offset(i+k), -103, d);
unsafe.compareAndSetInt(a, byte_offset(i+k), -123, c);
unsafe.compareAndSetInt(b, byte_offset(i+k), -103, d);
}
}
static void test_ci_scl(int[] a, int old) {
for (int i = 0; i*SCALE < ARRLEN; i+=1) {
unsafe.compareAndSwapInt(a, byte_offset(i*SCALE), old, -123);
unsafe.compareAndSetInt(a, byte_offset(i*SCALE), old, -123);
}
}
static void test_vi_scl(int[] a, int b, int old) {
for (int i = 0; i*SCALE < ARRLEN; i+=1) {
unsafe.compareAndSwapInt(a, byte_offset(i*SCALE), old, b);
unsafe.compareAndSetInt(a, byte_offset(i*SCALE), old, b);
}
}
static void test_cp_scl(int[] a, int[] b) {
for (int i = 0; i*SCALE < ARRLEN; i+=1) {
unsafe.compareAndSwapInt(a, byte_offset(i*SCALE), -123, b[i*SCALE]);
unsafe.compareAndSetInt(a, byte_offset(i*SCALE), -123, b[i*SCALE]);
}
}
static void test_2ci_scl(int[] a, int[] b) {
for (int i = 0; i*SCALE < ARRLEN; i+=1) {
unsafe.compareAndSwapInt(a, byte_offset(i*SCALE), 123, -123);
unsafe.compareAndSwapInt(b, byte_offset(i*SCALE), 123, -103);
unsafe.compareAndSetInt(a, byte_offset(i*SCALE), 123, -123);
unsafe.compareAndSetInt(b, byte_offset(i*SCALE), 123, -103);
}
}
static void test_2vi_scl(int[] a, int[] b, int c, int d) {
for (int i = 0; i*SCALE < ARRLEN; i+=1) {
unsafe.compareAndSwapInt(a, byte_offset(i*SCALE), -123, c);
unsafe.compareAndSwapInt(b, byte_offset(i*SCALE), -103, d);
unsafe.compareAndSetInt(a, byte_offset(i*SCALE), -123, c);
unsafe.compareAndSetInt(b, byte_offset(i*SCALE), -103, d);
}
}
static void test_cp_alndst(int[] a, int[] b) {
for (int i = 0; i < ARRLEN-ALIGN_OFF; i+=1) {
unsafe.compareAndSwapInt(a, byte_offset(i+ALIGN_OFF), -1, b[i]);
unsafe.compareAndSetInt(a, byte_offset(i+ALIGN_OFF), -1, b[i]);
}
}
static void test_cp_alnsrc(int[] a, int[] b) {
for (int i = 0; i < ARRLEN-ALIGN_OFF; i+=1) {
int old = unsafe.getIntVolatile(a, byte_offset(i));
unsafe.compareAndSwapInt(a, byte_offset(i), old, b[i+ALIGN_OFF]);
unsafe.compareAndSetInt(a, byte_offset(i), old, b[i+ALIGN_OFF]);
}
}
static void test_2ci_aln(int[] a, int[] b) {
for (int i = 0; i < ARRLEN-ALIGN_OFF; i+=1) {
unsafe.compareAndSwapInt(a, byte_offset(i+ALIGN_OFF), -1, -123);
unsafe.compareAndSetInt(a, byte_offset(i+ALIGN_OFF), -1, -123);
int old = unsafe.getIntVolatile(b, byte_offset(i));
unsafe.compareAndSwapInt(b, byte_offset(i), old, -103);
unsafe.compareAndSetInt(b, byte_offset(i), old, -103);
}
}
static void test_2vi_aln(int[] a, int[] b, int c, int d) {
for (int i = 0; i < ARRLEN-ALIGN_OFF; i+=1) {
int old = unsafe.getIntVolatile(a, byte_offset(i));
unsafe.compareAndSwapInt(a, byte_offset(i), old, c);
unsafe.compareAndSetInt(a, byte_offset(i), old, c);
old = unsafe.getIntVolatile(b, byte_offset(i+ALIGN_OFF));
unsafe.compareAndSwapInt(b, byte_offset(i+ALIGN_OFF), old, d);
unsafe.compareAndSetInt(b, byte_offset(i+ALIGN_OFF), old, d);
}
}
static void test_cp_unalndst(int[] a, int[] b) {
for (int i = 0; i < ARRLEN-UNALIGN_OFF; i+=1) {
unsafe.compareAndSwapInt(a, byte_offset(i+UNALIGN_OFF), -1, b[i]);
unsafe.compareAndSetInt(a, byte_offset(i+UNALIGN_OFF), -1, b[i]);
}
}
static void test_cp_unalnsrc(int[] a, int[] b) {
for (int i = 0; i < ARRLEN-UNALIGN_OFF; i+=1) {
int old = unsafe.getIntVolatile(a, byte_offset(i));
unsafe.compareAndSwapInt(a, byte_offset(i), old, b[i+UNALIGN_OFF]);
unsafe.compareAndSetInt(a, byte_offset(i), old, b[i+UNALIGN_OFF]);
}
}
static void test_2ci_unaln(int[] a, int[] b) {
for (int i = 0; i < ARRLEN-UNALIGN_OFF; i+=1) {
unsafe.compareAndSwapInt(a, byte_offset(i+UNALIGN_OFF), -1, -123);
unsafe.compareAndSetInt(a, byte_offset(i+UNALIGN_OFF), -1, -123);
int old = unsafe.getIntVolatile(b, byte_offset(i));
unsafe.compareAndSwapInt(b, byte_offset(i), old, -103);
unsafe.compareAndSetInt(b, byte_offset(i), old, -103);
}
}
static void test_2vi_unaln(int[] a, int[] b, int c, int d) {
for (int i = 0; i < ARRLEN-UNALIGN_OFF; i+=1) {
int old = unsafe.getIntVolatile(a, byte_offset(i));
unsafe.compareAndSwapInt(a, byte_offset(i), old, c);
unsafe.compareAndSetInt(a, byte_offset(i), old, c);
old = unsafe.getIntVolatile(b, byte_offset(i+UNALIGN_OFF));
unsafe.compareAndSwapInt(b, byte_offset(i+UNALIGN_OFF), old, d);
unsafe.compareAndSetInt(b, byte_offset(i+UNALIGN_OFF), old, d);
}
}

View File

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

View File

@ -64,7 +64,7 @@ public class UnsafeAccess {
static Object helperUnsafeLoadStore(Object o, boolean isObjArray) {
if (isObjArray) {
Object o1 = U.getObject(o, off);
U.compareAndSwapObject(o, off, o1, new Object());
U.compareAndSetObject(o, off, o1, new Object());
}
return o;
}

View File

@ -1,154 +0,0 @@
/*
* Copyright (c) 2016, 2017, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/*
* @test
* @modules java.base/jdk.internal.misc
* @library /test/lib ..
* @build sun.hotspot.WhiteBox
* @compile/module=java.base java/lang/ModuleHelper.java
* @run main ClassFileInstaller sun.hotspot.WhiteBox
* sun.hotspot.WhiteBox$WhiteBoxPermission
* @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI JVMAddModulePackage
*/
import static jdk.test.lib.Asserts.*;
import java.sql.Time;
public class JVMAddModulePackage {
public static void main(String args[]) throws Throwable {
MyClassLoader cl1 = new MyClassLoader();
MyClassLoader cl3 = new MyClassLoader();
Object module_one, module_two, module_three;
boolean result;
module_one = ModuleHelper.ModuleObject("module_one", cl1, new String[] { "mypackage" });
assertNotNull(module_one, "Module should not be null");
ModuleHelper.DefineModule(module_one, "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 { }
}

View File

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

View File

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

View File

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

View File

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

View File

@ -0,0 +1,215 @@
/*
* Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
#include <stdio.h>
#include <string.h>
#include "jvmti.h"
#ifdef __cplusplus
extern "C" {
#endif
#ifndef JNI_ENV_ARG
#ifdef __cplusplus
#define JNI_ENV_ARG(x, y) y
#define JNI_ENV_PTR(x) x
#else
#define JNI_ENV_ARG(x,y) x, y
#define JNI_ENV_PTR(x) (*x)
#endif
#endif
#define TranslateError(err) "JVMTI error"
#define PASSED 0
#define FAILED 2
static const char *EXC_CNAME = "java/lang/AssertionError";
static jvmtiEnv *jvmti = NULL;
static jint result = PASSED;
static jboolean printdump = JNI_FALSE;
static jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved);
JNIEXPORT
jint JNICALL Agent_OnLoad(JavaVM *jvm, char *options, void *reserved) {
return Agent_Initialize(jvm, options, reserved);
}
JNIEXPORT
jint JNICALL Agent_OnAttach(JavaVM *jvm, char *options, void *reserved) {
return Agent_Initialize(jvm, options, reserved);
}
JNIEXPORT
jint JNICALL JNI_OnLoad(JavaVM *jvm, void *reserved) {
return JNI_VERSION_1_8;
}
static
jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) {
jint res;
if (options != NULL && strcmp(options, "printdump") == 0) {
printdump = JNI_TRUE;
}
res = JNI_ENV_PTR(jvm)->GetEnv(JNI_ENV_ARG(jvm, (void **) &jvmti),
JVMTI_VERSION_9);
if (res != JNI_OK || jvmti == NULL) {
printf(" Error: wrong result of a valid call to GetEnv!\n");
return JNI_ERR;
}
return JNI_OK;
}
static
jclass find_class(JNIEnv *env, const char* cname) {
jclass cls = JNI_ENV_PTR(env)->FindClass(JNI_ENV_ARG(env, cname));
if (cls == NULL) {
printf("find_class: Error: FindClass(env, \"%s\") returned NULL\n", cname);
}
return cls;
}
static
jint throw_exc(JNIEnv *env, char *msg) {
jclass exc_class = find_class(env, EXC_CNAME);
if (exc_class == NULL) {
printf("throw_exc: Error in find_class(env, \"%s\")\n", EXC_CNAME);
return -1;
}
return JNI_ENV_PTR(env)->ThrowNew(JNI_ENV_ARG(env, exc_class), msg);
}
static jobject get_module_by_class_name(JNIEnv *env, const char* cname) {
jobject module = NULL;
jclass cls = find_class(env, cname);
printf(">>> getting module by class name: \"%s\"\n", cname);
if (cls == NULL) {
printf("get_module_by_class_name: Error in find_class(env, \"%s\")\n", cname);
return NULL;
}
module = JNI_ENV_PTR(env)->GetModule(JNI_ENV_ARG(env, cls));
if (module == NULL) {
printf("get_module_by_class_name: Error in GetModule for class \"%s\"\n", cname);
}
return module;
}
static
jint check_is_modifiable_error_codes(jobject module, jobject not_a_module) {
jvmtiError err = JVMTI_ERROR_NONE;
jboolean is_modifiable = JNI_FALSE;
printf(">>> passing a bad module argument to JVMTI IsModifiableModule\n");
err = (*jvmti)->IsModifiableModule(jvmti, not_a_module, &is_modifiable);
if (err != JVMTI_ERROR_INVALID_MODULE) {
printf(" Error #EC0: Did not get expected INVALID_MODULE error code from"
" IsModifiableModule: %s (%d)\n", TranslateError(err), err);
return FAILED;
}
printf(">>> passing NULL module argument to JVMTI IsModifiableModule\n");
err = (*jvmti)->IsModifiableModule(jvmti, NULL, &is_modifiable);
if (err != JVMTI_ERROR_NULL_POINTER) {
printf(" Error #EC1: Did not get expected NULL_POINTER error code from"
" IsModifiableModule: %s (%d)\n", TranslateError(err), err);
return FAILED;
}
printf(">>> passing NULL status pointer to JVMTI IsModifiableModule\n");
err = (*jvmti)->IsModifiableModule(jvmti, module, NULL);
if (err != JVMTI_ERROR_NULL_POINTER) {
printf(" Error #EC2: Did not get expected NULL_POINTER error code from"
" IsModifiableModule: %s (%d)\n", TranslateError(err), err);
return FAILED;
}
return PASSED;
}
static
jint check_is_modifiable(jobject module) {
jvmtiError err = JVMTI_ERROR_NONE;
jboolean is_modifiable = JNI_FALSE;
printf(">>> checking module %p is modifiable\n", module);
err = (*jvmti)->IsModifiableModule(jvmti, module, &is_modifiable);
if (err != JVMTI_ERROR_NONE) {
printf(" Error in IsModifiableModule for module %p: %s (%d)\n",
module, TranslateError(err), err);
return FAILED;
}
if (is_modifiable == JNI_FALSE) {
printf(" unexpected non-modifiable status for module: %p\n", module);
return FAILED;
}
return PASSED;
}
JNIEXPORT jint JNICALL
Java_MyPackage_IsModifiableModuleTest_check(JNIEnv *env, jclass cls) {
jobject module = NULL;
if (jvmti == NULL) {
throw_exc(env, "JVMTI client was not properly loaded!\n");
return FAILED;
}
printf("\n*** Testing IsModifiableModule ***\n\n");
if (check_is_modifiable_error_codes(module, cls) == FAILED) {
throw_exc(env, "check #MM0: failed to return expected error code from "
"a bad call to JVMTI IsModifiableModule");
return FAILED;
}
module = get_module_by_class_name(env, "java/lang/Class");
if (check_is_modifiable(module) == FAILED) {
throw_exc(env, "check #MM1: failed to return modifiable module status");
return FAILED;
}
module = get_module_by_class_name(env, "com/sun/jdi/VirtualMachine");
if (check_is_modifiable(module) == FAILED) {
throw_exc(env, "check #MM2: failed to return modifiable module status");
return FAILED;
}
module = get_module_by_class_name(env, "MyPackage/IsModifiableModuleTest");
if (check_is_modifiable(module) == FAILED) {
throw_exc(env, "check #MM3: failed to return modifiable module status");
return FAILED;
}
return PASSED;
}
#ifdef __cplusplus
}
#endif

View File

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

View File

@ -431,3 +431,5 @@ e705867d9989d00e4357f66f18b302c95e13b5e7 jdk-10+8
8c615099f3e3ca137325be34bf566b767d9e3c64 jdk-9+172
2d22d6732a73e615b9e13d6bc93bf026db3bc231 jdk-10+11
2bd967aa452c1e0e87a6173bef6fbb96ef1c521b jdk-9+173
c2296642010f1b215ac35da89e92c3ce44104e32 jdk-9+174
712a3a657654079514590d37a0f4894d43541d5c jdk-10+12

View File

@ -26,6 +26,8 @@
/**
* Defines the Java Architecture for XML Binding (JAXB) API.
*
* @uses javax.xml.bind.JAXBContextFactory
*
* @moduleGraph
* @since 9
*/

View File

@ -27,6 +27,12 @@
* Defines the Java API for XML-Based Web Services (JAX-WS), and
* the Web Services Metadata API.
*
* @uses javax.xml.soap.MessageFactory
* @uses javax.xml.soap.SAAJMetaFactory
* @uses javax.xml.soap.SOAPConnectionFactory
* @uses javax.xml.soap.SOAPFactory
* @uses javax.xml.ws.spi.Provider
*
* @moduleGraph
* @since 9
*/

View File

@ -23,6 +23,21 @@
* questions.
*/
/**
* Defines tools for JAXB classes and XML schema generation,
* including the <em>{@index schemagen schemagen tool}</em>
* and <em>{@index xjc xjc tool}</em> tools.
*
* <dl style="font-family:'DejaVu Sans', Arial, Helvetica, sans serif">
* <dt class="simpleTagLabel">Tool Guides:
* <dd>{@extLink schemagen_tool_reference schemagen},
* {@extLink xjc_tool_reference xjc}
* </dl>
*
* @moduleGraph
* @since 9
*/
@Deprecated(since="9", forRemoval=true)
module jdk.xml.bind {
requires java.activation;
requires java.compiler;

View File

@ -23,6 +23,21 @@
* questions.
*/
/**
* Defines tools for JAX-WS classes and WSDL generation,
* including the <em>{@index wsgen wsgen tool}</em>
* and <em>{@index wsimport wsimport tool}</em> tools.
*
* <dl style="font-family:'DejaVu Sans', Arial, Helvetica, sans serif">
* <dt class="simpleTagLabel">Tool Guides:
* <dd>{@extLink wsgen_tool_reference wsgen},
* {@extLink wsimport_tool_reference wsimport}
* </dl>
*
* @moduleGraph
* @since 9
*/
@Deprecated(since="9", forRemoval=true)
module jdk.xml.ws {
requires java.compiler;
requires java.logging;

View File

@ -428,3 +428,7 @@ df64bd4757d0d130d62a22b8143ba31d3a16ac18 jdk-10+10
0ff9ad7d067cd4fa14450cf208bf019175a0aaba jdk-9+172
7c54889c0ec649ee04643e5cace434623d0dc667 jdk-10+11
a5506b425f1bf91530d8417b57360e5d89328c0c jdk-9+173
42f18c931bd4fae5c206ccf6d8e591e4c4e69d31 jdk-9+174
5f504872a75b71f2fb19299f0d1e3395cf32eaa0 jdk-10+12
e6c4f6ef717d104dba880e2dae538690c993b46f jdk-9+175
4540d6376f3ef22305cca546f85f9b2ce9a210c4 jdk-10+13

View File

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

View File

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

View File

@ -77,6 +77,13 @@ ifneq ($(FREETYPE_BUNDLE_LIB_PATH), )
endif
TARGETS += $(FREETYPE_TARGET_LIB)
$(eval $(call SetupCopyFiles, COPY_FREETYPE_LICENSE, \
FILES := $(FREETYPE_LICENSE), \
DEST := $(LEGAL_DST_DIR), \
))
TARGETS += $(COPY_FREETYPE_LICENSE)
endif
################################################################################

View File

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

View File

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

View File

@ -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">&nbsp;</span>&nbsp; Java SE
<li><span class="jdk">&nbsp;</span>&nbsp; JDK
<li><span class="javafx">&nbsp;</span>&nbsp; JavaFX
<li><span class="jcp">&nbsp;</span>&nbsp; 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> &copy 1993, 2017, Oracle and/or its affiliates. All rights reserved.</p>
</body>
</html>

View File

@ -1,112 +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
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

View File

@ -58,7 +58,7 @@ public class ExtLink implements Taglet {
static final String URL = "https://www.oracle.com/pls/topic/lookup?ctx=javase9&amp;id=";
static final Pattern TAG_PATTERN = Pattern.compile("(\\s*)(?<name>\\w+)(\\s+)(?<desc>.*)");
static final Pattern TAG_PATTERN = Pattern.compile("(?s)(\\s*)(?<name>\\w+)(\\s+)(?<desc>.*)$");
/**
* Returns the set of locations in which the tag may be used.

View File

@ -42,12 +42,22 @@ include TestFilesCompilation.gmk
# Add more directories here when needed.
BUILD_JDK_JTREG_NATIVE_SRC := \
$(JDK_TOPDIR)/test/native_sanity \
$(JDK_TOPDIR)/test/java/lang/String/nativeEncoding \
#
BUILD_JDK_JTREG_OUTPUT_DIR := $(BUILD_OUTPUT)/support/test/jdk/jtreg/native
BUILD_JDK_JTREG_IMAGE_DIR := $(TEST_IMAGE_DIR)/jdk/jtreg
ifeq ($(OPENJDK_TARGET_OS), windows)
WIN_LIB_JAVA := $(SUPPORT_OUTPUTDIR)/native/java.base/libjava/java.lib
BUILD_JDK_JTREG_LIBRARIES_LIBS_libstringPlatformChars := $(WIN_LIB_JAVA)
else ifeq ($(OPENJDK_TARGET_OS), solaris)
BUILD_JDK_JTREG_LIBRARIES_LIBS_libstringPlatformChars := -ljava -lc
else
BUILD_JDK_JTREG_LIBRARIES_LIBS_libstringPlatformChars := -ljava
endif
$(eval $(call SetupTestFilesCompilation, BUILD_JDK_JTREG_LIBRARIES, \
TYPE := LIBRARY, \
SOURCE_DIRS := $(BUILD_JDK_JTREG_NATIVE_SRC), \

View File

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

View File

@ -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
* "&lt;init&gt;"or "&lt;clinit&gt;".
*/
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

View File

@ -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,9 +2165,7 @@ public abstract class ClassLoader {
* @revised 9
* @spec JPMS
*
* @see <a href="../../../technotes/guides/jar/jar.html#versioning">
* The JAR File Specification: Package Versioning</a>
* @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,

View File

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

View File

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

View File

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

View File

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

View File

@ -102,10 +102,14 @@ import jdk.internal.reflect.Reflection;
* with the {@link Package#getPackages Package.getPackages()} and
* {@link ClassLoader#getDefinedPackages} methods.
*
* @implNote
* The <a href="ClassLoader.html#builtinLoaders">builtin class loaders</a>
* do not explicitly define {@code Package} objects for packages in
* <em>named modules</em>. Instead those packages are automatically defined
* and have no specification and implementation versioning information.
*
* @jvms 5.3 Run-time package
* @see <a href="../../../technotes/guides/jar/jar.html#versioning">
* The JAR File Specification: Package Versioning</a>
* @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)
*

View File

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

View File

@ -27,6 +27,7 @@ package java.lang;
import java.io.ObjectStreamField;
import java.io.UnsupportedEncodingException;
import java.lang.annotation.Native;
import java.nio.charset.Charset;
import java.util.ArrayList;
import java.util.Arrays;
@ -3063,8 +3064,8 @@ public final class String
return COMPACT_STRINGS && coder == LATIN1;
}
static final byte LATIN1 = 0;
static final byte UTF16 = 1;
@Native static final byte LATIN1 = 0;
@Native static final byte UTF16 = 1;
/*
* StringIndexOutOfBoundsException if {@code index} is

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -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++) {

View File

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

View File

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

View File

@ -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 &amp; 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.
*/

View File

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

View File

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

View File

@ -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 &amp; 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 &amp; 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 &amp; 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 &amp;
* 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 &amp;
* 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

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