This new way of running tests is developer-centric. It assumes that you have built a jdk locally and want to test it. Running common test targets is simple, and more complex ad-hoc combination of tests is possible. The user interface is forgiving, and clearly report errors it cannot resolve.
+
Some example command-lines:
+
$ make run-test-tier1
+$ make run-test-jdk_lang JTREG="JOBS=8"
+$ make run-test TEST=jdk_lang
+$ make run-test-only TEST="gtest:LogTagSet gtest:LogTagSetDescriptions" GTEST="REPEAT=-1"
+$ make run-test TEST="hotspot/test:hotspot_gc" JTREG="JOBS=1;TIMEOUT=8;VM_OTIONS=-XshowSettings -Xlog:gc+ref=debug"
+$ make run-test TEST="jtreg:hotspot/test:hotspot_gc hotspot/test/native_sanity/JniVersion.java"
+
Test selection
+
All functionality is available using the run-test make target. In this use case, the test or tests to be executed is controlled using the TEST variable. To speed up subsequent test runs with no source code changes, run-test-only can be used instead, which do not depend on the source and test image build.
+
For some common top-level tests, direct make targets have been generated. This includes all JTreg test groups, the hotspot gtest, and custom tests (if present). This means that make run-test-tier1 is equivalent to make run-test TEST="tier1", but the latter is more tab-completion friendly. For more complex test runs, the run-test TEST="x" solution needs to be used.
+
The test specifications given in TEST is parsed into fully qualified test descriptors, which clearly and unambigously show which tests will be run. As an example, :tier1 will expand to jtreg:jdk/test:tier1 jtreg:langtools/test:tier1 jtreg:nashorn/test:tier1 jtreg:jaxp/test:tier1. You can always submit a list of fully qualified test descriptors in the TEST variable if you want to shortcut the parser.
+
JTreg
+
JTreg test groups can be specified either without a test root, e.g. :tier1 (or tier1, the initial colon is optional), or with, e.g. hotspot/test:tier1, jdk/test:jdk_util.
+
When specified without a test root, all matching groups from all tests roots will be added. Otherwise, only the group from the specified test root will be added.
+
Individual JTreg tests or directories containing JTreg tests can also be specified, like hotspot/test/native_sanity/JniVersion.java or hotspot/test/native_sanity. You can also specify an absolute path, to point to a JTreg test outside the source tree.
+
As long as the test groups or test paths can be uniquely resolved, you do not need to enter the jtreg: prefix. If this is not possible, or if you want to use a fully qualified test descriptor, add jtreg:, e.g. jtreg:hotspot/test/native_sanity.
+
Gtest
+
Since the Hotspot Gtest suite is so quick, the default is to run all tests. This is specified by just gtest, or as a fully qualified test descriptor gtest:all.
+
If you want, you can single out an individual test or a group of tests, for instance gtest:LogDecorations or gtest:LogDecorations.level_test_vm. This can be particularly useful if you want to run a shaky test repeatedly.
+
Test results and summary
+
At the end of the test run, a summary of all tests run will be presented. This will have a consistent look, regardless of what test suites were used. This is a sample summary:
Tests where the number of TOTAL tests does not equal the number of PASSed tests will be considered a test failure. These are marked with the >> ... << marker for easy identification.
+
The classification of non-passed tests differs a bit between test suites. In the summary, ERROR is used as a catch-all for tests that neither passed nor are classified as failed by the framework. This might indicate test framework error, timeout or other problems.
+
In case of test failures, make run-test will exit with a non-zero exit value.
+
All tests have their result stored in build/$BUILD/test-result/$TEST_ID, where TEST_ID is a path-safe conversion from the fully qualified test descriptor, e.g. for jtreg:jdk/test:tier1 the TEST_ID is jtreg_jdk_test_tier1. This path is also printed in the log at the end of the test run.
+
Additional work data is stored in build/$BUILD/test-support/$TEST_ID. For some frameworks, this directory might contain information that is useful in determining the cause of a failed test.
+
Test suite control
+
It is possible to control various aspects of the test suites using make control variables.
+
These variables use a keyword=value approach to allow multiple values to be set. So, for instance, JTREG="JOBS=1;TIMEOUT=8" will set the JTreg concurrency level to 1 and the timeout factor to 8. This is equivalent to setting JTREG_JOBS=1 JTREG_TIMEOUT=8, but using the keyword format means that the JTREG variable is parsed and verified for correctness, so JTREG="TMIEOUT=8" would give an error, while JTREG_TMIEOUT=8 would just pass unnoticed.
+
To separate multiple keyword=value pairs, use ; (semicolon). Since the shell normally eats ;, the recommended usage is to write the assignment inside qoutes, e.g. JTREG="...;...". This will also make sure spaces are preserved, as in JTREG="VM_OTIONS=-XshowSettings -Xlog:gc+ref=debug".
+
(Other ways are possible, e.g. using backslash: JTREG=JOBS=1\;TIMEOUT=8. Also, as a special technique, the string %20 will be replaced with space for certain options, e.g. JTREG=VM_OTIONS=-XshowSettings%20-Xlog:gc+ref=debug. This can be useful if you have layers of scripts and have trouble getting proper quoting of command line arguments through.)
+
As far as possible, the names of the keywords have been standardized between test suites.
+
JTreg keywords
+
JOBS
+
The test concurrency (-concurrency).
+
Defaults to TEST_JOBS (if set by --with-test-jobs=), otherwise it defaults to JOBS, except for Hotspot, where the default is number of CPU cores/2, but never more than 12.
+
TIMEOUT
+
The timeout factor (-timeoutFactor).
+
Defaults to 4.
+
TEST_MODE
+
The test mode (-agentvm, -samevm or -othervm).
+
Defaults to -agentvm.
+
ASSERT
+
Enable asserts (-ea -esa, or none).
+
Set to true or false. If true, adds -ea -esa. Defaults to true, except for hotspot.
+
VERBOSE
+
The verbosity level (-verbose).
+
Defaults to fail,error,summary.
+
RETAIN
+
What test data to retain (-retain).
+
Defaults to fail,error.
+
MAX_MEM
+
Limit memory consumption (-Xmx and -vmoption:-Xmx, or none).
+
Limit memory consumption for JTreg test framework and VM under test. Set to 0 to disable the limits.
+
Defaults to 512m, except for hotspot, where it defaults to 0 (no limit).
+
OPTIONS
+
Additional options to the JTreg test framework.
+
Use JTREG="OPTIONS=--help all" to see all available JTreg options.
+
JAVA_OPTIONS
+
Additional Java options to JTreg (-javaoption).
+
VM_OPTIONS
+
Additional VM options to JTreg (-vmoption).
+
Gtest keywords
+
REPEAT
+
The number of times to repeat the tests (--gtest_repeat).
+
Default is 1. Set to -1 to repeat indefinitely. This can be especially useful combined with OPTIONS=--gtest_break_on_failure to reproduce an intermittent problem.
+
OPTIONS
+
Additional options to the Gtest test framework.
+
Use GTEST="OPTIONS=--help" to see all available Gtest options.
+
+
diff --git a/common/doc/testing.md b/common/doc/testing.md
new file mode 100644
index 00000000000..46f32f911e3
--- /dev/null
+++ b/common/doc/testing.md
@@ -0,0 +1,207 @@
+% Testing OpenJDK
+
+## Using the run-test framework
+
+This new way of running tests is developer-centric. It assumes that you have
+built a jdk locally and want to test it. Running common test targets is simple,
+and more complex ad-hoc combination of tests is possible. The user interface is
+forgiving, and clearly report errors it cannot resolve.
+
+Some example command-lines:
+
+ $ make run-test-tier1
+ $ make run-test-jdk_lang JTREG="JOBS=8"
+ $ make run-test TEST=jdk_lang
+ $ make run-test-only TEST="gtest:LogTagSet gtest:LogTagSetDescriptions" GTEST="REPEAT=-1"
+ $ make run-test TEST="hotspot/test:hotspot_gc" JTREG="JOBS=1;TIMEOUT=8;VM_OTIONS=-XshowSettings -Xlog:gc+ref=debug"
+ $ make run-test TEST="jtreg:hotspot/test:hotspot_gc hotspot/test/native_sanity/JniVersion.java"
+
+## Test selection
+
+All functionality is available using the run-test make target. In this use
+case, the test or tests to be executed is controlled using the `TEST` variable.
+To speed up subsequent test runs with no source code changes, run-test-only can
+be used instead, which do not depend on the source and test image build.
+
+For some common top-level tests, direct make targets have been generated. This
+includes all JTreg test groups, the hotspot gtest, and custom tests (if
+present). This means that `make run-test-tier1` is equivalent to `make run-test
+TEST="tier1"`, but the latter is more tab-completion friendly. For more complex
+test runs, the `run-test TEST="x"` solution needs to be used.
+
+The test specifications given in `TEST` is parsed into fully qualified test
+descriptors, which clearly and unambigously show which tests will be run. As an
+example, `:tier1` will expand to `jtreg:jdk/test:tier1
+jtreg:langtools/test:tier1 jtreg:nashorn/test:tier1 jtreg:jaxp/test:tier1`. You
+can always submit a list of fully qualified test descriptors in the `TEST`
+variable if you want to shortcut the parser.
+
+### JTreg
+
+JTreg test groups can be specified either without a test root, e.g. `:tier1`
+(or `tier1`, the initial colon is optional), or with, e.g.
+`hotspot/test:tier1`, `jdk/test:jdk_util`.
+
+When specified without a test root, all matching groups from all tests roots
+will be added. Otherwise, only the group from the specified test root will be
+added.
+
+Individual JTreg tests or directories containing JTreg tests can also be
+specified, like `hotspot/test/native_sanity/JniVersion.java` or
+`hotspot/test/native_sanity`. You can also specify an absolute path, to point
+to a JTreg test outside the source tree.
+
+As long as the test groups or test paths can be uniquely resolved, you do not
+need to enter the `jtreg:` prefix. If this is not possible, or if you want to
+use a fully qualified test descriptor, add `jtreg:`, e.g.
+`jtreg:hotspot/test/native_sanity`.
+
+### Gtest
+
+Since the Hotspot Gtest suite is so quick, the default is to run all tests.
+This is specified by just `gtest`, or as a fully qualified test descriptor
+`gtest:all`.
+
+If you want, you can single out an individual test or a group of tests, for
+instance `gtest:LogDecorations` or `gtest:LogDecorations.level_test_vm`. This
+can be particularly useful if you want to run a shaky test repeatedly.
+
+## Test results and summary
+
+At the end of the test run, a summary of all tests run will be presented. This
+will have a consistent look, regardless of what test suites were used. This is
+a sample summary:
+
+ ==============================
+ Test summary
+ ==============================
+ TEST TOTAL PASS FAIL ERROR
+ >> jtreg:jdk/test:tier1 1867 1865 2 0 <<
+ jtreg:langtools/test:tier1 4711 4711 0 0
+ jtreg:nashorn/test:tier1 133 133 0 0
+ ==============================
+ TEST FAILURE
+
+Tests where the number of TOTAL tests does not equal the number of PASSed tests
+will be considered a test failure. These are marked with the `>> ... <<` marker
+for easy identification.
+
+The classification of non-passed tests differs a bit between test suites. In
+the summary, ERROR is used as a catch-all for tests that neither passed nor are
+classified as failed by the framework. This might indicate test framework
+error, timeout or other problems.
+
+In case of test failures, `make run-test` will exit with a non-zero exit value.
+
+All tests have their result stored in `build/$BUILD/test-result/$TEST_ID`,
+where TEST_ID is a path-safe conversion from the fully qualified test
+descriptor, e.g. for `jtreg:jdk/test:tier1` the TEST_ID is
+`jtreg_jdk_test_tier1`. This path is also printed in the log at the end of the
+test run.
+
+Additional work data is stored in `build/$BUILD/test-support/$TEST_ID`. For
+some frameworks, this directory might contain information that is useful in
+determining the cause of a failed test.
+
+## Test suite control
+
+It is possible to control various aspects of the test suites using make control
+variables.
+
+These variables use a keyword=value approach to allow multiple values to be
+set. So, for instance, `JTREG="JOBS=1;TIMEOUT=8"` will set the JTreg
+concurrency level to 1 and the timeout factor to 8. This is equivalent to
+setting `JTREG_JOBS=1 JTREG_TIMEOUT=8`, but using the keyword format means that
+the `JTREG` variable is parsed and verified for correctness, so
+`JTREG="TMIEOUT=8"` would give an error, while `JTREG_TMIEOUT=8` would just
+pass unnoticed.
+
+To separate multiple keyword=value pairs, use `;` (semicolon). Since the shell
+normally eats `;`, the recommended usage is to write the assignment inside
+qoutes, e.g. `JTREG="...;..."`. This will also make sure spaces are preserved,
+as in `JTREG="VM_OTIONS=-XshowSettings -Xlog:gc+ref=debug"`.
+
+(Other ways are possible, e.g. using backslash: `JTREG=JOBS=1\;TIMEOUT=8`.
+Also, as a special technique, the string `%20` will be replaced with space for
+certain options, e.g. `JTREG=VM_OTIONS=-XshowSettings%20-Xlog:gc+ref=debug`.
+This can be useful if you have layers of scripts and have trouble getting
+proper quoting of command line arguments through.)
+
+As far as possible, the names of the keywords have been standardized between
+test suites.
+
+### JTreg keywords
+
+#### JOBS
+The test concurrency (`-concurrency`).
+
+Defaults to TEST_JOBS (if set by `--with-test-jobs=`), otherwise it defaults to
+JOBS, except for Hotspot, where the default is *number of CPU cores/2*, but
+never more than 12.
+
+#### TIMEOUT
+The timeout factor (`-timeoutFactor`).
+
+Defaults to 4.
+
+#### TEST_MODE
+The test mode (`-agentvm`, `-samevm` or `-othervm`).
+
+Defaults to `-agentvm`.
+
+#### ASSERT
+Enable asserts (`-ea -esa`, or none).
+
+Set to `true` or `false`. If true, adds `-ea -esa`. Defaults to true, except
+for hotspot.
+
+#### VERBOSE
+The verbosity level (`-verbose`).
+
+Defaults to `fail,error,summary`.
+
+#### RETAIN
+What test data to retain (`-retain`).
+
+Defaults to `fail,error`.
+
+#### MAX_MEM
+Limit memory consumption (`-Xmx` and `-vmoption:-Xmx`, or none).
+
+Limit memory consumption for JTreg test framework and VM under test. Set to 0
+to disable the limits.
+
+Defaults to 512m, except for hotspot, where it defaults to 0 (no limit).
+
+#### OPTIONS
+Additional options to the JTreg test framework.
+
+Use `JTREG="OPTIONS=--help all"` to see all available JTreg options.
+
+#### JAVA_OPTIONS
+Additional Java options to JTreg (`-javaoption`).
+
+#### VM_OPTIONS
+Additional VM options to JTreg (`-vmoption`).
+
+### Gtest keywords
+
+#### REPEAT
+The number of times to repeat the tests (`--gtest_repeat`).
+
+Default is 1. Set to -1 to repeat indefinitely. This can be especially useful
+combined with `OPTIONS=--gtest_break_on_failure` to reproduce an intermittent
+problem.
+
+#### OPTIONS
+Additional options to the Gtest test framework.
+
+Use `GTEST="OPTIONS=--help"` to see all available Gtest options.
+
+---
+# Override some definitions in http://openjdk.java.net/page.css that are
+# unsuitable for this document.
+header-includes:
+ - ''
+ - ''
+---
diff --git a/corba/.hgtags b/corba/.hgtags
index 1063f0df0c3..edc96406447 100644
--- a/corba/.hgtags
+++ b/corba/.hgtags
@@ -408,3 +408,4 @@ c7688f2fa07936b089ca0e9a0a0eff68ff37a542 jdk-9+160
18ffcf99a3b4a10457853d94190e825bdf07e39b jdk-9+162
493011dee80e51c2a2b064d049183c047df36d80 jdk-9+163
965bbae3072702f7c0d95c240523b65e6bb19261 jdk-9+164
+a510b2201154abdd12ede42788086b5283bfb9a6 jdk-9+165
diff --git a/hotspot/.hgtags b/hotspot/.hgtags
index 476e6f4636b..b139e14de05 100644
--- a/hotspot/.hgtags
+++ b/hotspot/.hgtags
@@ -568,3 +568,4 @@ b2d0a906afd73dcf27f572217eb1be0f196ec16c jdk-9+157
b01c519b715ef6f785d0631adee0a6537cf6c12e jdk-9+162
983fe207555724d98f4876991e1cbafbcf2733e8 jdk-9+163
0af429be8bbaeaaf0cb838e9af28c953dda6a9c8 jdk-9+164
+c92c6416ca03b1464d5ed99cf6201e52b5ba0a70 jdk-9+165
diff --git a/hotspot/src/cpu/x86/vm/assembler_x86.cpp b/hotspot/src/cpu/x86/vm/assembler_x86.cpp
index c819ffe9462..3c6d7b5cdd6 100644
--- a/hotspot/src/cpu/x86/vm/assembler_x86.cpp
+++ b/hotspot/src/cpu/x86/vm/assembler_x86.cpp
@@ -917,7 +917,7 @@ address Assembler::locate_operand(address inst, WhichOperand which) {
break;
case 0x62: // EVEX_4bytes
- assert((UseAVX > 0), "shouldn't have EVEX prefix");
+ assert(VM_Version::supports_evex(), "shouldn't have EVEX prefix");
assert(ip == inst+1, "no prefixes allowed");
// no EVEX collisions, all instructions that have 0x62 opcodes
// have EVEX versions and are subopcodes of 0x66
diff --git a/hotspot/src/cpu/x86/vm/nativeInst_x86.cpp b/hotspot/src/cpu/x86/vm/nativeInst_x86.cpp
index cb8c08f4652..fc7fcba2fc7 100644
--- a/hotspot/src/cpu/x86/vm/nativeInst_x86.cpp
+++ b/hotspot/src/cpu/x86/vm/nativeInst_x86.cpp
@@ -365,6 +365,10 @@ int NativeMovRegMem::instruction_start() const {
NOT_LP64(assert((0xC0 & ubyte_at(1)) == 0xC0, "shouldn't have LDS and LES instructions"));
return 3;
}
+ if (instr_0 == instruction_EVEX_prefix_4bytes) {
+ assert(VM_Version::supports_evex(), "shouldn't have EVEX prefix");
+ return 4;
+ }
// First check to see if we have a (prefixed or not) xor
if (instr_0 >= instruction_prefix_wide_lo && // 0x40
diff --git a/hotspot/src/cpu/x86/vm/nativeInst_x86.hpp b/hotspot/src/cpu/x86/vm/nativeInst_x86.hpp
index 7db3ccb9d3c..ef87c17807c 100644
--- a/hotspot/src/cpu/x86/vm/nativeInst_x86.hpp
+++ b/hotspot/src/cpu/x86/vm/nativeInst_x86.hpp
@@ -356,6 +356,7 @@ class NativeMovRegMem: public NativeInstruction {
instruction_VEX_prefix_2bytes = Assembler::VEX_2bytes,
instruction_VEX_prefix_3bytes = Assembler::VEX_3bytes,
+ instruction_EVEX_prefix_4bytes = Assembler::EVEX_4bytes,
instruction_size = 4,
instruction_offset = 0,
diff --git a/hotspot/src/jdk.internal.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotConstantReflectionProvider.java b/hotspot/src/jdk.internal.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotConstantReflectionProvider.java
index e74027f2dd1..1256cf02584 100644
--- a/hotspot/src/jdk.internal.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotConstantReflectionProvider.java
+++ b/hotspot/src/jdk.internal.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotConstantReflectionProvider.java
@@ -179,11 +179,14 @@ public class HotSpotConstantReflectionProvider implements ConstantReflectionProv
if (hotspotField.isStatic()) {
HotSpotResolvedJavaType holder = (HotSpotResolvedJavaType) hotspotField.getDeclaringClass();
if (holder.isInitialized()) {
- return memoryAccess.readUnsafeConstant(hotspotField.getJavaKind(), HotSpotObjectConstantImpl.forObject(holder.mirror()), hotspotField.offset());
+ return memoryAccess.readFieldValue(hotspotField, holder.mirror());
}
} else {
- if (receiver.isNonNull() && hotspotField.isInObject(((HotSpotObjectConstantImpl) receiver).object())) {
- return memoryAccess.readUnsafeConstant(hotspotField.getJavaKind(), receiver, hotspotField.offset());
+ if (receiver.isNonNull()) {
+ Object object = ((HotSpotObjectConstantImpl) receiver).object();
+ if (hotspotField.isInObject(object)) {
+ return memoryAccess.readFieldValue(hotspotField, object);
+ }
}
}
return null;
diff --git a/hotspot/src/jdk.internal.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotMemoryAccessProvider.java b/hotspot/src/jdk.internal.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotMemoryAccessProvider.java
index a4d68b56f19..15250e2c7d1 100644
--- a/hotspot/src/jdk.internal.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotMemoryAccessProvider.java
+++ b/hotspot/src/jdk.internal.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotMemoryAccessProvider.java
@@ -31,6 +31,10 @@ import jdk.vm.ci.meta.MemoryAccessProvider;
*/
public interface HotSpotMemoryAccessProvider extends MemoryAccessProvider {
+ /**
+ * @throws IllegalArgumentException if the address computed from {@code base} and
+ * {@code displacement} does not denote a location holding a narrow oop
+ */
JavaConstant readNarrowOopConstant(Constant base, long displacement);
Constant readKlassPointerConstant(Constant base, long displacement);
diff --git a/hotspot/src/jdk.internal.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotMemoryAccessProviderImpl.java b/hotspot/src/jdk.internal.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotMemoryAccessProviderImpl.java
index be8e3a32067..9f262aa71ae 100644
--- a/hotspot/src/jdk.internal.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotMemoryAccessProviderImpl.java
+++ b/hotspot/src/jdk.internal.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotMemoryAccessProviderImpl.java
@@ -22,13 +22,21 @@
*/
package jdk.vm.ci.hotspot;
+import static jdk.vm.ci.hotspot.HotSpotJVMCIRuntimeProvider.getArrayBaseOffset;
+import static jdk.vm.ci.hotspot.HotSpotJVMCIRuntimeProvider.getArrayIndexScale;
import static jdk.vm.ci.hotspot.UnsafeAccess.UNSAFE;
+import java.lang.reflect.Array;
+
+import jdk.vm.ci.common.JVMCIError;
import jdk.vm.ci.meta.Constant;
import jdk.vm.ci.meta.JavaConstant;
import jdk.vm.ci.meta.JavaKind;
import jdk.vm.ci.meta.MemoryAccessProvider;
+import jdk.vm.ci.meta.MetaAccessProvider;
import jdk.vm.ci.meta.PrimitiveConstant;
+import jdk.vm.ci.meta.ResolvedJavaField;
+import jdk.vm.ci.meta.ResolvedJavaType;
/**
* HotSpot implementation of {@link MemoryAccessProvider}.
@@ -41,12 +49,93 @@ class HotSpotMemoryAccessProviderImpl implements HotSpotMemoryAccessProvider {
this.runtime = runtime;
}
- private static Object asObject(Constant base) {
+ /**
+ * Gets the object boxed by {@code base} that is about to have a value of kind {@code kind} read
+ * from it at the offset {@code displacement}.
+ *
+ * @param base constant value containing the base address for a pending read
+ * @return {@code null} if {@code base} does not box an object otherwise the object boxed in
+ * {@code base}
+ */
+ private Object asObject(Constant base, JavaKind kind, long displacement) {
if (base instanceof HotSpotObjectConstantImpl) {
- return ((HotSpotObjectConstantImpl) base).object();
- } else {
- return null;
+ HotSpotObjectConstantImpl constant = (HotSpotObjectConstantImpl) base;
+ HotSpotResolvedObjectType type = constant.getType();
+ Object object = constant.object();
+ checkRead(kind, displacement, type, object);
+ return object;
}
+ return null;
+ }
+
+ /**
+ * Offset of injected {@code java.lang.Class::oop_size} field. No need to make {@code volatile}
+ * as initialization is idempotent.
+ */
+ private long oopSizeOffset;
+
+ private static int computeOopSizeOffset(HotSpotJVMCIRuntimeProvider runtime) {
+ MetaAccessProvider metaAccess = runtime.getHostJVMCIBackend().getMetaAccess();
+ ResolvedJavaType staticType = metaAccess.lookupJavaType(Class.class);
+ for (ResolvedJavaField f : staticType.getInstanceFields(false)) {
+ if (f.getName().equals("oop_size")) {
+ int offset = ((HotSpotResolvedJavaField) f).offset();
+ assert offset != 0 : "not expecting offset of java.lang.Class::oop_size to be 0";
+ return offset;
+ }
+ }
+ throw new JVMCIError("Could not find injected java.lang.Class::oop_size field");
+ }
+
+ private boolean checkRead(JavaKind kind, long displacement, HotSpotResolvedObjectType type, Object object) {
+ if (type.isArray()) {
+ ResolvedJavaType componentType = type.getComponentType();
+ JavaKind componentKind = componentType.getJavaKind();
+ final int headerSize = getArrayBaseOffset(componentKind);
+ int sizeOfElement = getArrayIndexScale(componentKind);
+ int length = Array.getLength(object);
+ long arrayEnd = headerSize + (sizeOfElement * length);
+ boolean aligned = ((displacement - headerSize) % sizeOfElement) == 0;
+ if (displacement < 0 || displacement > (arrayEnd - sizeOfElement) || (kind == JavaKind.Object && !aligned)) {
+ int index = (int) ((displacement - headerSize) / sizeOfElement);
+ throw new AssertionError("Unsafe array access: reading element of kind " + kind +
+ " at offset " + displacement + " (index ~ " + index + ") in " +
+ type.toJavaName() + " object of length " + length);
+ }
+ } else if (kind != JavaKind.Object) {
+ long size;
+ if (object instanceof Class) {
+ if (oopSizeOffset == 0) {
+ oopSizeOffset = computeOopSizeOffset(runtime);
+ }
+ int wordSize = runtime.getHostJVMCIBackend().getCodeCache().getTarget().wordSize;
+ size = UNSAFE.getInt(object, oopSizeOffset) * wordSize;
+ } else {
+ size = Math.abs(type.instanceSize());
+ }
+ int bytesToRead = kind.getByteCount();
+ if (displacement + bytesToRead > size || displacement < 0) {
+ throw new IllegalArgumentException("Unsafe access: reading " + bytesToRead + " bytes at offset " + displacement + " in " +
+ type.toJavaName() + " object of size " + size);
+ }
+ } else {
+ ResolvedJavaField field = type.findInstanceFieldWithOffset(displacement, JavaKind.Object);
+ if (field == null && object instanceof Class) {
+ // Read of a static field
+ MetaAccessProvider metaAccess = runtime.getHostJVMCIBackend().getMetaAccess();
+ HotSpotResolvedObjectTypeImpl staticFieldsHolder = (HotSpotResolvedObjectTypeImpl) metaAccess.lookupJavaType((Class>) object);
+ field = staticFieldsHolder.findStaticFieldWithOffset(displacement, JavaKind.Object);
+ }
+ if (field == null) {
+ throw new IllegalArgumentException("Unsafe object access: field not found for read of kind Object" +
+ " at offset " + displacement + " in " + type.toJavaName() + " object");
+ }
+ if (field.getJavaKind() != JavaKind.Object) {
+ throw new IllegalArgumentException("Unsafe object access: field " + field.format("%H.%n:%T") + " not of expected kind Object" +
+ " at offset " + displacement + " in " + type.toJavaName() + " object");
+ }
+ }
+ return true;
}
private boolean isValidObjectFieldDisplacement(Constant base, long displacement) {
@@ -77,8 +166,8 @@ class HotSpotMemoryAccessProviderImpl implements HotSpotMemoryAccessProvider {
throw new IllegalArgumentException(String.valueOf(base));
}
- private static long readRawValue(Constant baseConstant, long displacement, int bits) {
- Object base = asObject(baseConstant);
+ private long readRawValue(Constant baseConstant, long displacement, JavaKind kind, int bits) {
+ Object base = asObject(baseConstant, kind, displacement);
if (base != null) {
switch (bits) {
case Byte.SIZE:
@@ -123,9 +212,8 @@ class HotSpotMemoryAccessProviderImpl implements HotSpotMemoryAccessProvider {
private Object readRawObject(Constant baseConstant, long initialDisplacement, boolean compressed) {
long displacement = initialDisplacement;
-
Object ret;
- Object base = asObject(baseConstant);
+ Object base = asObject(baseConstant, JavaKind.Object, displacement);
if (base == null) {
assert !compressed;
displacement += asRawPointer(baseConstant);
@@ -138,34 +226,43 @@ class HotSpotMemoryAccessProviderImpl implements HotSpotMemoryAccessProvider {
return ret;
}
- /**
- * Reads a value of this kind using a base address and a displacement. No bounds checking or
- * type checking is performed. Returns {@code null} if the value is not available at this point.
- *
- * @param baseConstant the base address from which the value is read.
- * @param displacement the displacement within the object in bytes
- * @return the read value encapsulated in a {@link JavaConstant} object, or {@code null} if the
- * value cannot be read.
- * @throws IllegalArgumentException if {@code kind} is {@code null}, {@link JavaKind#Void}, not
- * {@link JavaKind#Object} or not {@linkplain JavaKind#isPrimitive() primitive} kind
- */
- JavaConstant readUnsafeConstant(JavaKind kind, JavaConstant baseConstant, long displacement) {
- if (kind == null) {
- throw new IllegalArgumentException("null JavaKind");
- }
- if (kind == JavaKind.Object) {
- Object o = readRawObject(baseConstant, displacement, runtime.getConfig().useCompressedOops);
+ JavaConstant readFieldValue(HotSpotResolvedJavaField field, Object obj) {
+ assert obj != null;
+ assert !field.isStatic() || obj instanceof Class;
+ long displacement = field.offset();
+ assert checkRead(field.getJavaKind(), displacement, (HotSpotResolvedObjectType) runtime.getHostJVMCIBackend().getMetaAccess().lookupJavaType(obj.getClass()), obj);
+ if (field.getJavaKind() == JavaKind.Object) {
+ Object o = UNSAFE.getObject(obj, displacement);
return HotSpotObjectConstantImpl.forObject(o);
} else {
- int bits = kind.getByteCount() * Byte.SIZE;
- return readPrimitiveConstant(kind, baseConstant, displacement, bits);
+ JavaKind kind = field.getJavaKind();
+ switch (kind) {
+ case Boolean:
+ return JavaConstant.forBoolean(UNSAFE.getBoolean(obj, displacement));
+ case Byte:
+ return JavaConstant.forByte(UNSAFE.getByte(obj, displacement));
+ case Char:
+ return JavaConstant.forChar(UNSAFE.getChar(obj, displacement));
+ case Short:
+ return JavaConstant.forShort(UNSAFE.getShort(obj, displacement));
+ case Int:
+ return JavaConstant.forInt(UNSAFE.getInt(obj, displacement));
+ case Long:
+ return JavaConstant.forLong(UNSAFE.getLong(obj, displacement));
+ case Float:
+ return JavaConstant.forFloat(UNSAFE.getFloat(obj, displacement));
+ case Double:
+ return JavaConstant.forDouble(UNSAFE.getDouble(obj, displacement));
+ default:
+ throw new IllegalArgumentException("Unsupported kind: " + kind);
+ }
}
}
@Override
public JavaConstant readPrimitiveConstant(JavaKind kind, Constant baseConstant, long initialDisplacement, int bits) {
try {
- long rawValue = readRawValue(baseConstant, initialDisplacement, bits);
+ long rawValue = readRawValue(baseConstant, initialDisplacement, kind, bits);
switch (kind) {
case Boolean:
return JavaConstant.forBoolean(rawValue != 0);
@@ -193,6 +290,10 @@ class HotSpotMemoryAccessProviderImpl implements HotSpotMemoryAccessProvider {
@Override
public JavaConstant readObjectConstant(Constant base, long displacement) {
+ if (base instanceof HotSpotObjectConstantImpl) {
+ Object o = readRawObject(base, displacement, runtime.getConfig().useCompressedOops);
+ return HotSpotObjectConstantImpl.forObject(o);
+ }
if (!isValidObjectFieldDisplacement(base, displacement)) {
return null;
}
diff --git a/hotspot/src/jdk.internal.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotResolvedObjectTypeImpl.java b/hotspot/src/jdk.internal.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotResolvedObjectTypeImpl.java
index 88974c3b415..8d969a45918 100644
--- a/hotspot/src/jdk.internal.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotResolvedObjectTypeImpl.java
+++ b/hotspot/src/jdk.internal.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotResolvedObjectTypeImpl.java
@@ -847,6 +847,15 @@ final class HotSpotResolvedObjectTypeImpl extends HotSpotResolvedJavaType implem
@Override
public ResolvedJavaField findInstanceFieldWithOffset(long offset, JavaKind expectedEntryKind) {
ResolvedJavaField[] declaredFields = getInstanceFields(true);
+ return findFieldWithOffset(offset, expectedEntryKind, declaredFields);
+ }
+
+ public ResolvedJavaField findStaticFieldWithOffset(long offset, JavaKind expectedEntryKind) {
+ ResolvedJavaField[] declaredFields = getStaticFields();
+ return findFieldWithOffset(offset, expectedEntryKind, declaredFields);
+ }
+
+ private static ResolvedJavaField findFieldWithOffset(long offset, JavaKind expectedEntryKind, ResolvedJavaField[] declaredFields) {
for (ResolvedJavaField field : declaredFields) {
HotSpotResolvedJavaField resolvedField = (HotSpotResolvedJavaField) field;
long resolvedFieldOffset = resolvedField.offset();
diff --git a/hotspot/src/jdk.internal.vm.ci/share/classes/jdk.vm.ci.meta/src/jdk/vm/ci/meta/MemoryAccessProvider.java b/hotspot/src/jdk.internal.vm.ci/share/classes/jdk.vm.ci.meta/src/jdk/vm/ci/meta/MemoryAccessProvider.java
index 81c5f395549..9eba9d0f8ac 100644
--- a/hotspot/src/jdk.internal.vm.ci/share/classes/jdk.vm.ci.meta/src/jdk/vm/ci/meta/MemoryAccessProvider.java
+++ b/hotspot/src/jdk.internal.vm.ci/share/classes/jdk.vm.ci.meta/src/jdk/vm/ci/meta/MemoryAccessProvider.java
@@ -35,9 +35,9 @@ public interface MemoryAccessProvider {
* @param displacement the displacement within the object in bytes
* @param bits the number of bits to read from memory
* @return the read value encapsulated in a {@link JavaConstant} object of {@link JavaKind} kind
- * @throws IllegalArgumentException if {@code kind} is {@link JavaKind#Void} or not
- * {@linkplain JavaKind#isPrimitive() primitive} kind or {@code bits} is not 8, 16,
- * 32 or 64
+ * @throws IllegalArgumentException if the read is out of bounds of the object or {@code kind}
+ * is {@link JavaKind#Void} or not {@linkplain JavaKind#isPrimitive() primitive}
+ * kind or {@code bits} is not 8, 16, 32 or 64
*/
JavaConstant readPrimitiveConstant(JavaKind kind, Constant base, long displacement, int bits) throws IllegalArgumentException;
@@ -46,9 +46,9 @@ public interface MemoryAccessProvider {
*
* @param base the base address from which the value is read
* @param displacement the displacement within the object in bytes
- * @return the read value encapsulated in a {@link Constant} object or {@code null} if the
- * address computed from {@code base} and {@code displacement} does not denote a
- * location holding an {@code Object} value
+ * @return the read value encapsulated in a {@link Constant} object
+ * @throws IllegalArgumentException if the address computed from {@code base} and
+ * {@code displacement} does not denote a location holding an {@code Object} value
*/
JavaConstant readObjectConstant(Constant base, long displacement);
}
diff --git a/hotspot/src/jdk.internal.vm.ci/share/classes/jdk.vm.ci.services/src/jdk/vm/ci/services/Services.java b/hotspot/src/jdk.internal.vm.ci/share/classes/jdk.vm.ci.services/src/jdk/vm/ci/services/Services.java
index dbeb7fbf6b0..851fd3060fe 100644
--- a/hotspot/src/jdk.internal.vm.ci/share/classes/jdk.vm.ci.services/src/jdk/vm/ci/services/Services.java
+++ b/hotspot/src/jdk.internal.vm.ci/share/classes/jdk.vm.ci.services/src/jdk/vm/ci/services/Services.java
@@ -28,6 +28,7 @@ import java.util.Formatter;
import java.util.Iterator;
import java.util.ServiceConfigurationError;
import java.util.ServiceLoader;
+import java.util.Set;
/**
* A mechanism for accessing service providers via JVMCI.
@@ -108,7 +109,7 @@ public final class Services {
Object jvmci = invoke(getModule, Services.class);
Object requestorModule = invoke(getModule, requestor);
if (jvmci != requestorModule) {
- String[] packages = invoke(getPackages, jvmci);
+ Set packages = invoke(getPackages, jvmci);
for (String pkg : packages) {
// Export all JVMCI packages dynamically instead
// of requiring a long list of --add-exports
diff --git a/hotspot/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.core.common/src/org/graalvm/compiler/core/common/util/ModuleAPI.java b/hotspot/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.core.common/src/org/graalvm/compiler/core/common/util/ModuleAPI.java
index 240fdc07fb6..8facd197165 100644
--- a/hotspot/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.core.common/src/org/graalvm/compiler/core/common/util/ModuleAPI.java
+++ b/hotspot/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.core.common/src/org/graalvm/compiler/core/common/util/ModuleAPI.java
@@ -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
@@ -58,22 +58,22 @@ public final class ModuleAPI {
public static final ModuleAPI addExports;
/**
- * {@code java.lang.reflect.Module.getResourceAsStream(String)}.
+ * {@code java.lang.Module.getResourceAsStream(String)}.
*/
public static final ModuleAPI getResourceAsStream;
/**
- * {@code java.lang.reflect.Module.canRead(Module)}.
+ * {@code java.lang.Module.canRead(Module)}.
*/
public static final ModuleAPI canRead;
/**
- * {@code java.lang.reflect.Module.isExported(String)}.
+ * {@code java.lang.Module.isExported(String)}.
*/
public static final ModuleAPI isExported;
/**
- * {@code java.lang.reflect.Module.isExported(String, Module)}.
+ * {@code java.lang.Module.isExported(String, Module)}.
*/
public static final ModuleAPI isExportedTo;
diff --git a/hotspot/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.hotspot/src/org/graalvm/compiler/hotspot/phases/aot/EliminateRedundantInitializationPhase.java b/hotspot/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.hotspot/src/org/graalvm/compiler/hotspot/phases/aot/EliminateRedundantInitializationPhase.java
index 46d8be12171..caa04c2c979 100644
--- a/hotspot/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.hotspot/src/org/graalvm/compiler/hotspot/phases/aot/EliminateRedundantInitializationPhase.java
+++ b/hotspot/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.hotspot/src/org/graalvm/compiler/hotspot/phases/aot/EliminateRedundantInitializationPhase.java
@@ -28,9 +28,6 @@ import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map.Entry;
-import jdk.vm.ci.hotspot.HotSpotMetaspaceConstant;
-import jdk.vm.ci.meta.JavaConstant;
-
import org.graalvm.compiler.graph.Node;
import org.graalvm.compiler.graph.iterators.NodeIterable;
import org.graalvm.compiler.hotspot.nodes.aot.InitializeKlassNode;
@@ -43,6 +40,9 @@ import org.graalvm.compiler.nodes.cfg.ControlFlowGraph;
import org.graalvm.compiler.phases.BasePhase;
import org.graalvm.compiler.phases.tiers.PhaseContext;
+import jdk.vm.ci.hotspot.HotSpotMetaspaceConstant;
+import jdk.vm.ci.meta.Constant;
+
public class EliminateRedundantInitializationPhase extends BasePhase {
/**
* Find blocks with class initializing nodes for the class identified the by the constant node.
@@ -202,7 +202,7 @@ public class EliminateRedundantInitializationPhase extends BasePhase redundantInits = new ArrayList<>();
for (ConstantNode node : getConstantNodes(graph)) {
- JavaConstant constant = node.asJavaConstant();
+ Constant constant = node.asConstant();
if (constant instanceof HotSpotMetaspaceConstant) {
redundantInits.addAll(processConstantNode(cfg, node));
}
diff --git a/hotspot/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.test/src/org/graalvm/compiler/test/ExportingClassLoader.java b/hotspot/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.test/src/org/graalvm/compiler/test/ExportingClassLoader.java
index e139b19c971..1c08964c696 100644
--- a/hotspot/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.test/src/org/graalvm/compiler/test/ExportingClassLoader.java
+++ b/hotspot/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.test/src/org/graalvm/compiler/test/ExportingClassLoader.java
@@ -29,14 +29,14 @@ package org.graalvm.compiler.test;
public class ExportingClassLoader extends ClassLoader {
public ExportingClassLoader() {
if (!GraalTest.Java8OrEarlier) {
- JLRModule.fromClass(getClass()).exportAllPackagesTo(JLRModule.getUnnamedModuleFor(this));
+ JLModule.fromClass(getClass()).exportAllPackagesTo(JLModule.getUnnamedModuleFor(this));
}
}
public ExportingClassLoader(ClassLoader parent) {
super(parent);
if (!GraalTest.Java8OrEarlier) {
- JLRModule.fromClass(getClass()).exportAllPackagesTo(JLRModule.getUnnamedModuleFor(this));
+ JLModule.fromClass(getClass()).exportAllPackagesTo(JLModule.getUnnamedModuleFor(this));
}
}
}
diff --git a/hotspot/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.test/src/org/graalvm/compiler/test/JLRModule.java b/hotspot/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.test/src/org/graalvm/compiler/test/JLModule.java
similarity index 80%
rename from hotspot/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.test/src/org/graalvm/compiler/test/JLRModule.java
rename to hotspot/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.test/src/org/graalvm/compiler/test/JLModule.java
index caa32231bd6..9fe1c139863 100644
--- a/hotspot/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.test/src/org/graalvm/compiler/test/JLRModule.java
+++ b/hotspot/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.test/src/org/graalvm/compiler/test/JLModule.java
@@ -23,22 +23,23 @@
package org.graalvm.compiler.test;
import java.lang.reflect.Method;
+import java.util.Set;
/**
- * Facade for the {@code java.lang.reflect.Module} class introduced in JDK9 that allows tests to be
+ * Facade for the {@code java.lang.Module} class introduced in JDK9 that allows tests to be
* developed against JDK8 but use module logic if deployed on JDK9.
*/
-public class JLRModule {
+public class JLModule {
static {
if (GraalTest.Java8OrEarlier) {
- throw new AssertionError("Use of " + JLRModule.class + " only allowed if " + GraalTest.class.getName() + ".JDK8OrEarlier is false");
+ throw new AssertionError("Use of " + JLModule.class + " only allowed if " + GraalTest.class.getName() + ".JDK8OrEarlier is false");
}
}
private final Object realModule;
- public JLRModule(Object module) {
+ public JLModule(Object module) {
this.realModule = module;
}
@@ -51,7 +52,7 @@ public class JLRModule {
private static final Method addExportsMethod;
static {
try {
- moduleClass = Class.forName("java.lang.reflect.Module");
+ moduleClass = Class.forName("java.lang.Module");
getModuleMethod = Class.class.getMethod("getModule");
getUnnamedModuleMethod = ClassLoader.class.getMethod("getUnnamedModule");
getPackagesMethod = moduleClass.getMethod("getPackages");
@@ -63,17 +64,17 @@ public class JLRModule {
}
}
- public static JLRModule fromClass(Class> cls) {
+ public static JLModule fromClass(Class> cls) {
try {
- return new JLRModule(getModuleMethod.invoke(cls));
+ return new JLModule(getModuleMethod.invoke(cls));
} catch (Exception e) {
throw new AssertionError(e);
}
}
- public static JLRModule getUnnamedModuleFor(ClassLoader cl) {
+ public static JLModule getUnnamedModuleFor(ClassLoader cl) {
try {
- return new JLRModule(getUnnamedModuleMethod.invoke(cl));
+ return new JLModule(getUnnamedModuleMethod.invoke(cl));
} catch (Exception e) {
throw new AssertionError(e);
}
@@ -82,7 +83,7 @@ public class JLRModule {
/**
* Exports all packages in this module to a given module.
*/
- public void exportAllPackagesTo(JLRModule module) {
+ public void exportAllPackagesTo(JLModule module) {
if (this != module) {
for (String pkg : getPackages()) {
// Export all JVMCI packages dynamically instead
@@ -95,9 +96,9 @@ public class JLRModule {
}
}
- public String[] getPackages() {
+ public Set getPackages() {
try {
- return (String[]) getPackagesMethod.invoke(realModule);
+ return (Set) getPackagesMethod.invoke(realModule);
} catch (Exception e) {
throw new AssertionError(e);
}
@@ -111,7 +112,7 @@ public class JLRModule {
}
}
- public boolean isExported(String pn, JLRModule other) {
+ public boolean isExported(String pn, JLModule other) {
try {
return (Boolean) isExported2Method.invoke(realModule, pn, other.realModule);
} catch (Exception e) {
@@ -119,7 +120,7 @@ public class JLRModule {
}
}
- public void addExports(String pn, JLRModule other) {
+ public void addExports(String pn, JLModule other) {
try {
addExportsMethod.invoke(realModule, pn, other.realModule);
} catch (Exception e) {
diff --git a/hotspot/src/share/vm/classfile/classFileParser.cpp b/hotspot/src/share/vm/classfile/classFileParser.cpp
index 8d5742c94da..db813adf834 100644
--- a/hotspot/src/share/vm/classfile/classFileParser.cpp
+++ b/hotspot/src/share/vm/classfile/classFileParser.cpp
@@ -5406,7 +5406,7 @@ void ClassFileParser::fill_instance_klass(InstanceKlass* ik, bool changed_by_loa
ModuleEntry* module_entry = ik->module();
assert(module_entry != NULL, "module_entry should always be set");
- // Obtain java.lang.reflect.Module
+ // Obtain java.lang.Module
Handle module_handle(THREAD, JNIHandles::resolve(module_entry->module()));
// Allocate mirror and initialize static fields
diff --git a/hotspot/src/share/vm/classfile/javaClasses.cpp b/hotspot/src/share/vm/classfile/javaClasses.cpp
index 62f27770365..22c1e6cc34e 100644
--- a/hotspot/src/share/vm/classfile/javaClasses.cpp
+++ b/hotspot/src/share/vm/classfile/javaClasses.cpp
@@ -773,13 +773,13 @@ void java_lang_Class::initialize_mirror_fields(KlassHandle k,
InstanceKlass::cast(k())->do_local_static_fields(&initialize_static_field, mirror, CHECK);
}
-// Set the java.lang.reflect.Module module field in the java_lang_Class mirror
+// Set the java.lang.Module module field in the java_lang_Class mirror
void java_lang_Class::set_mirror_module_field(KlassHandle k, Handle mirror, Handle module, TRAPS) {
if (module.is_null()) {
// During startup, the module may be NULL only if java.base has not been defined yet.
- // Put the class on the fixup_module_list to patch later when the java.lang.reflect.Module
+ // Put the class on the fixup_module_list to patch later when the java.lang.Module
// for java.base is known.
- assert(!Universe::is_module_initialized(), "Incorrect java.lang.reflect.Module pre module system initialization");
+ assert(!Universe::is_module_initialized(), "Incorrect java.lang.Module pre module system initialization");
bool javabase_was_defined = false;
{
@@ -810,7 +810,7 @@ void java_lang_Class::set_mirror_module_field(KlassHandle k, Handle mirror, Hand
assert(Universe::is_module_initialized() ||
(ModuleEntryTable::javabase_defined() &&
(module() == JNIHandles::resolve(ModuleEntryTable::javabase_moduleEntry()->module()))),
- "Incorrect java.lang.reflect.Module specification while creating mirror");
+ "Incorrect java.lang.Module specification while creating mirror");
set_module(mirror(), module());
}
}
@@ -2804,28 +2804,28 @@ void java_lang_reflect_Parameter::set_executable(oop param, oop value) {
}
-int java_lang_reflect_Module::loader_offset;
-int java_lang_reflect_Module::name_offset;
-int java_lang_reflect_Module::_module_entry_offset = -1;
+int java_lang_Module::loader_offset;
+int java_lang_Module::name_offset;
+int java_lang_Module::_module_entry_offset = -1;
-Handle java_lang_reflect_Module::create(Handle loader, Handle module_name, TRAPS) {
+Handle java_lang_Module::create(Handle loader, Handle module_name, TRAPS) {
assert(Universe::is_fully_initialized(), "Need to find another solution to the reflection problem");
- Symbol* name = vmSymbols::java_lang_reflect_Module();
+ Symbol* name = vmSymbols::java_lang_Module();
Klass* k = SystemDictionary::resolve_or_fail(name, true, CHECK_NH);
instanceKlassHandle klass (THREAD, k);
- Handle jlrmh = klass->allocate_instance_handle(CHECK_NH);
+ Handle jlmh = klass->allocate_instance_handle(CHECK_NH);
JavaValue result(T_VOID);
- JavaCalls::call_special(&result, jlrmh, KlassHandle(THREAD, klass()),
+ JavaCalls::call_special(&result, jlmh, KlassHandle(THREAD, klass()),
vmSymbols::object_initializer_name(),
- vmSymbols::java_lang_reflect_module_init_signature(),
+ vmSymbols::java_lang_module_init_signature(),
loader, module_name, CHECK_NH);
- return jlrmh;
+ return jlmh;
}
-void java_lang_reflect_Module::compute_offsets() {
- Klass* k = SystemDictionary::reflect_Module_klass();
+void java_lang_Module::compute_offsets() {
+ Klass* k = SystemDictionary::Module_klass();
if(NULL != k) {
compute_offset(loader_offset, k, vmSymbols::loader_name(), vmSymbols::classloader_signature());
compute_offset(name_offset, k, vmSymbols::name_name(), vmSymbols::string_signature());
@@ -2834,27 +2834,27 @@ void java_lang_reflect_Module::compute_offsets() {
}
-oop java_lang_reflect_Module::loader(oop module) {
+oop java_lang_Module::loader(oop module) {
assert(Universe::is_fully_initialized(), "Need to find another solution to the reflection problem");
return module->obj_field(loader_offset);
}
-void java_lang_reflect_Module::set_loader(oop module, oop value) {
+void java_lang_Module::set_loader(oop module, oop value) {
assert(Universe::is_fully_initialized(), "Need to find another solution to the reflection problem");
module->obj_field_put(loader_offset, value);
}
-oop java_lang_reflect_Module::name(oop module) {
+oop java_lang_Module::name(oop module) {
assert(Universe::is_fully_initialized(), "Need to find another solution to the reflection problem");
return module->obj_field(name_offset);
}
-void java_lang_reflect_Module::set_name(oop module, oop value) {
+void java_lang_Module::set_name(oop module, oop value) {
assert(Universe::is_fully_initialized(), "Need to find another solution to the reflection problem");
module->obj_field_put(name_offset, value);
}
-ModuleEntry* java_lang_reflect_Module::module_entry(oop module, TRAPS) {
+ModuleEntry* java_lang_Module::module_entry(oop module, TRAPS) {
assert(_module_entry_offset != -1, "Uninitialized module_entry_offset");
assert(module != NULL, "module can't be null");
assert(module->is_oop(), "module must be oop");
@@ -2863,7 +2863,7 @@ ModuleEntry* java_lang_reflect_Module::module_entry(oop module, TRAPS) {
if (module_entry == NULL) {
// If the inject field containing the ModuleEntry* is null then return the
// class loader's unnamed module.
- oop loader = java_lang_reflect_Module::loader(module);
+ oop loader = java_lang_Module::loader(module);
Handle h_loader = Handle(THREAD, loader);
ClassLoaderData* loader_cld = SystemDictionary::register_loader(h_loader, CHECK_NULL);
return loader_cld->modules()->unnamed_module();
@@ -2871,7 +2871,7 @@ ModuleEntry* java_lang_reflect_Module::module_entry(oop module, TRAPS) {
return module_entry;
}
-void java_lang_reflect_Module::set_module_entry(oop module, ModuleEntry* module_entry) {
+void java_lang_Module::set_module_entry(oop module, ModuleEntry* module_entry) {
assert(_module_entry_offset != -1, "Uninitialized module_entry_offset");
assert(module != NULL, "module can't be null");
assert(module->is_oop(), "module must be oop");
@@ -3877,7 +3877,7 @@ void JavaClasses::compute_offsets() {
reflect_ConstantPool::compute_offsets();
reflect_UnsafeStaticFieldAccessorImpl::compute_offsets();
java_lang_reflect_Parameter::compute_offsets();
- java_lang_reflect_Module::compute_offsets();
+ java_lang_Module::compute_offsets();
java_lang_StackFrameInfo::compute_offsets();
java_lang_LiveStackFrameInfo::compute_offsets();
diff --git a/hotspot/src/share/vm/classfile/javaClasses.hpp b/hotspot/src/share/vm/classfile/javaClasses.hpp
index fc934b89791..da5d4a67f2c 100644
--- a/hotspot/src/share/vm/classfile/javaClasses.hpp
+++ b/hotspot/src/share/vm/classfile/javaClasses.hpp
@@ -755,9 +755,9 @@ class java_lang_reflect_Parameter {
};
#define MODULE_INJECTED_FIELDS(macro) \
- macro(java_lang_reflect_Module, module_entry, intptr_signature, false)
+ macro(java_lang_Module, module_entry, intptr_signature, false)
-class java_lang_reflect_Module {
+class java_lang_Module {
private:
static int loader_offset;
static int name_offset;
diff --git a/hotspot/src/share/vm/classfile/javaClasses.inline.hpp b/hotspot/src/share/vm/classfile/javaClasses.inline.hpp
index b388bb157d3..a50113d1c61 100644
--- a/hotspot/src/share/vm/classfile/javaClasses.inline.hpp
+++ b/hotspot/src/share/vm/classfile/javaClasses.inline.hpp
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -162,8 +162,8 @@ inline bool java_lang_invoke_DirectMethodHandle::is_instance(oop obj) {
return obj != NULL && is_subclass(obj->klass());
}
-inline bool java_lang_reflect_Module::is_instance(oop obj) {
- return obj != NULL && obj->klass() == SystemDictionary::reflect_Module_klass();
+inline bool java_lang_Module::is_instance(oop obj) {
+ return obj != NULL && obj->klass() == SystemDictionary::Module_klass();
}
inline int Backtrace::merge_bci_and_version(int bci, int version) {
diff --git a/hotspot/src/share/vm/classfile/moduleEntry.cpp b/hotspot/src/share/vm/classfile/moduleEntry.cpp
index 42384cbacd2..2f07b10da3e 100644
--- a/hotspot/src/share/vm/classfile/moduleEntry.cpp
+++ b/hotspot/src/share/vm/classfile/moduleEntry.cpp
@@ -266,19 +266,19 @@ void ModuleEntryTable::create_unnamed_module(ClassLoaderData* loader_data) {
// Each ModuleEntryTable has exactly one unnamed module
if (loader_data->is_the_null_class_loader_data()) {
- // For the boot loader, the java.lang.reflect.Module for the unnamed module
+ // For the boot loader, the java.lang.Module for the unnamed module
// is not known until a call to JVM_SetBootLoaderUnnamedModule is made. At
// this point initially create the ModuleEntry for the unnamed module.
_unnamed_module = new_entry(0, Handle(NULL), NULL, NULL, NULL, loader_data);
} else {
- // For all other class loaders the java.lang.reflect.Module for their
+ // For all other class loaders the java.lang.Module for their
// corresponding unnamed module can be found in the java.lang.ClassLoader object.
oop module = java_lang_ClassLoader::unnamedModule(loader_data->class_loader());
_unnamed_module = new_entry(0, Handle(module), NULL, NULL, NULL, loader_data);
- // Store pointer to the ModuleEntry in the unnamed module's java.lang.reflect.Module
+ // Store pointer to the ModuleEntry in the unnamed module's java.lang.Module
// object.
- java_lang_reflect_Module::set_module_entry(module, _unnamed_module);
+ java_lang_Module::set_module_entry(module, _unnamed_module);
}
// Add to bucket 0, no name to hash on
@@ -388,27 +388,27 @@ void ModuleEntryTable::finalize_javabase(Handle module_handle, Symbol* version,
fatal("Unable to finalize module definition for " JAVA_BASE_NAME);
}
- // Set java.lang.reflect.Module, version and location for java.base
+ // Set java.lang.Module, version and location for java.base
ModuleEntry* jb_module = javabase_moduleEntry();
assert(jb_module != NULL, JAVA_BASE_NAME " ModuleEntry not defined");
jb_module->set_version(version);
jb_module->set_location(location);
// Once java.base's ModuleEntry _module field is set with the known
- // java.lang.reflect.Module, java.base is considered "defined" to the VM.
+ // java.lang.Module, java.base is considered "defined" to the VM.
jb_module->set_module(boot_loader_data->add_handle(module_handle));
- // Store pointer to the ModuleEntry for java.base in the java.lang.reflect.Module object.
- java_lang_reflect_Module::set_module_entry(module_handle(), jb_module);
+ // Store pointer to the ModuleEntry for java.base in the java.lang.Module object.
+ java_lang_Module::set_module_entry(module_handle(), jb_module);
}
-// Within java.lang.Class instances there is a java.lang.reflect.Module field
-// that must be set with the defining module. During startup, prior to java.base's
-// definition, classes needing their module field set are added to the fixup_module_list.
-// Their module field is set once java.base's java.lang.reflect.Module is known to the VM.
+// Within java.lang.Class instances there is a java.lang.Module field that must
+// be set with the defining module. During startup, prior to java.base's definition,
+// classes needing their module field set are added to the fixup_module_list.
+// Their module field is set once java.base's java.lang.Module is known to the VM.
void ModuleEntryTable::patch_javabase_entries(Handle module_handle) {
if (module_handle.is_null()) {
fatal("Unable to patch the module field of classes loaded prior to "
- JAVA_BASE_NAME "'s definition, invalid java.lang.reflect.Module");
+ JAVA_BASE_NAME "'s definition, invalid java.lang.Module");
}
// Do the fixups for the basic primitive types
diff --git a/hotspot/src/share/vm/classfile/moduleEntry.hpp b/hotspot/src/share/vm/classfile/moduleEntry.hpp
index ac35010b04c..c50441a1739 100644
--- a/hotspot/src/share/vm/classfile/moduleEntry.hpp
+++ b/hotspot/src/share/vm/classfile/moduleEntry.hpp
@@ -45,7 +45,7 @@ class ModuleClosure;
// A ModuleEntry describes a module that has been defined by a call to JVM_DefineModule.
// It contains:
// - Symbol* containing the module's name.
-// - pointer to the java.lang.reflect.Module for this module.
+// - pointer to the java.lang.Module for this module.
// - pointer to the java.security.ProtectionDomain shared by classes defined to this module.
// - ClassLoaderData*, class loader of this module.
// - a growable array containg other module entries that this module can read.
@@ -55,7 +55,7 @@ class ModuleClosure;
// data structure.
class ModuleEntry : public HashtableEntry {
private:
- jobject _module; // java.lang.reflect.Module
+ jobject _module; // java.lang.Module
jobject _pd; // java.security.ProtectionDomain, cached
// for shared classes from this module
ClassLoaderData* _loader_data;
diff --git a/hotspot/src/share/vm/classfile/modules.cpp b/hotspot/src/share/vm/classfile/modules.cpp
index 39ab9649516..39928498910 100644
--- a/hotspot/src/share/vm/classfile/modules.cpp
+++ b/hotspot/src/share/vm/classfile/modules.cpp
@@ -62,7 +62,7 @@ bool Modules::verify_package_name(const char* package_name) {
}
static char* get_module_name(oop module, TRAPS) {
- oop name_oop = java_lang_reflect_Module::name(module);
+ oop name_oop = java_lang_Module::name(module);
if (name_oop == NULL) {
THROW_MSG_NULL(vmSymbols::java_lang_NullPointerException(), "Null module name");
}
@@ -98,11 +98,11 @@ static PackageEntryTable* get_package_entry_table(Handle h_loader, TRAPS) {
static ModuleEntry* get_module_entry(jobject module, TRAPS) {
Handle module_h(THREAD, JNIHandles::resolve(module));
- if (!java_lang_reflect_Module::is_instance(module_h())) {
+ if (!java_lang_Module::is_instance(module_h())) {
THROW_MSG_NULL(vmSymbols::java_lang_IllegalArgumentException(),
- "module is not an instance of type java.lang.reflect.Module");
+ "module is not an instance of type java.lang.Module");
}
- return java_lang_reflect_Module::module_entry(module_h(), CHECK_NULL);
+ return java_lang_Module::module_entry(module_h(), CHECK_NULL);
}
static PackageEntry* get_package_entry(ModuleEntry* module_entry, const char* package_name, TRAPS) {
@@ -181,7 +181,7 @@ static void define_javabase_module(jobject module, jstring version,
}
// Validate java_base's loader is the boot loader.
- oop loader = java_lang_reflect_Module::loader(module_handle());
+ oop loader = java_lang_Module::loader(module_handle());
if (loader != NULL) {
THROW_MSG(vmSymbols::java_lang_IllegalArgumentException(),
"Class loader must be the boot class loader");
@@ -234,7 +234,7 @@ static void define_javabase_module(jobject module, jstring version,
// Only the thread that actually defined the base module will get here,
// so no locking is needed.
- // Patch any previously loaded class's module field with java.base's java.lang.reflect.Module.
+ // Patch any previously loaded class's module field with java.base's java.lang.Module.
ModuleEntryTable::patch_javabase_entries(module_handle);
log_debug(modules)("define_javabase_module(): Definition of module: "
@@ -284,9 +284,9 @@ void Modules::define_module(jobject module, jstring version,
}
Handle module_handle(THREAD, JNIHandles::resolve(module));
- if (!java_lang_reflect_Module::is_instance(module_handle())) {
+ if (!java_lang_Module::is_instance(module_handle())) {
THROW_MSG(vmSymbols::java_lang_IllegalArgumentException(),
- "module is not an instance of type java.lang.reflect.Module");
+ "module is not an instance of type java.lang.Module");
}
char* module_name = get_module_name(module_handle(), CHECK);
@@ -303,7 +303,7 @@ void Modules::define_module(jobject module, jstring version,
const char* module_version = get_module_version(version);
- oop loader = java_lang_reflect_Module::loader(module_handle());
+ oop loader = java_lang_Module::loader(module_handle());
// Make sure loader is not the jdk.internal.reflect.DelegatingClassLoader.
if (loader != java_lang_ClassLoader::non_reflection_class_loader(loader)) {
THROW_MSG(vmSymbols::java_lang_IllegalArgumentException(),
@@ -424,8 +424,8 @@ void Modules::define_module(jobject module, jstring version,
pkg_list->at(y)->decrement_refcount();
}
- // Store pointer to ModuleEntry record in java.lang.reflect.Module object.
- java_lang_reflect_Module::set_module_entry(module_handle(), module_entry);
+ // Store pointer to ModuleEntry record in java.lang.Module object.
+ java_lang_Module::set_module_entry(module_handle(), module_entry);
}
}
} // Release the lock
@@ -467,20 +467,20 @@ void Modules::set_bootloader_unnamed_module(jobject module, TRAPS) {
THROW_MSG(vmSymbols::java_lang_NullPointerException(), "Null module object");
}
Handle module_handle(THREAD, JNIHandles::resolve(module));
- if (!java_lang_reflect_Module::is_instance(module_handle())) {
+ if (!java_lang_Module::is_instance(module_handle())) {
THROW_MSG(vmSymbols::java_lang_IllegalArgumentException(),
- "module is not an instance of type java.lang.reflect.Module");
+ "module is not an instance of type java.lang.Module");
}
// Ensure that this is an unnamed module
- oop name = java_lang_reflect_Module::name(module_handle());
+ oop name = java_lang_Module::name(module_handle());
if (name != NULL) {
THROW_MSG(vmSymbols::java_lang_IllegalArgumentException(),
- "boot loader's unnamed module's java.lang.reflect.Module has a name");
+ "boot loader's unnamed module's java.lang.Module has a name");
}
// Validate java_base's loader is the boot loader.
- oop loader = java_lang_reflect_Module::loader(module_handle());
+ oop loader = java_lang_Module::loader(module_handle());
if (loader != NULL) {
THROW_MSG(vmSymbols::java_lang_IllegalArgumentException(),
"Class loader must be the boot class loader");
@@ -492,12 +492,12 @@ void Modules::set_bootloader_unnamed_module(jobject module, TRAPS) {
// Ensure the boot loader's PackageEntryTable has been created
ModuleEntryTable* module_table = get_module_entry_table(h_loader, CHECK);
- // Set java.lang.reflect.Module for the boot loader's unnamed module
+ // Set java.lang.Module for the boot loader's unnamed module
ModuleEntry* unnamed_module = module_table->unnamed_module();
assert(unnamed_module != NULL, "boot loader's unnamed ModuleEntry not defined");
unnamed_module->set_module(ClassLoaderData::the_null_class_loader_data()->add_handle(module_handle));
- // Store pointer to the ModuleEntry in the unnamed module's java.lang.reflect.Module object.
- java_lang_reflect_Module::set_module_entry(module_handle(), unnamed_module);
+ // Store pointer to the ModuleEntry in the unnamed module's java.lang.Module object.
+ java_lang_Module::set_module_entry(module_handle(), unnamed_module);
}
void Modules::add_module_exports(jobject from_module, const char* package_name, jobject to_module, TRAPS) {
@@ -627,13 +627,13 @@ jobject Modules::get_module(jclass clazz, TRAPS) {
oop module = java_lang_Class::module(mirror);
assert(module != NULL, "java.lang.Class module field not set");
- assert(java_lang_reflect_Module::is_instance(module), "module is not an instance of type java.lang.reflect.Module");
+ assert(java_lang_Module::is_instance(module), "module is not an instance of type java.lang.Module");
if (log_is_enabled(Debug, modules)) {
ResourceMark rm(THREAD);
outputStream* logst = Log(modules)::debug_stream();
Klass* klass = java_lang_Class::as_Klass(mirror);
- oop module_name = java_lang_reflect_Module::name(module);
+ oop module_name = java_lang_Module::name(module);
if (module_name != NULL) {
logst->print("get_module(): module ");
java_lang_String::print(module_name, tty);
diff --git a/hotspot/src/share/vm/classfile/modules.hpp b/hotspot/src/share/vm/classfile/modules.hpp
index 4f5e089a065..4dc752c95a4 100644
--- a/hotspot/src/share/vm/classfile/modules.hpp
+++ b/hotspot/src/share/vm/classfile/modules.hpp
@@ -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
@@ -55,12 +55,12 @@ public:
jstring location, const char* const* packages,
jsize num_packages, TRAPS);
- // Provides the java.lang.reflect.Module for the unnamed module defined
+ // Provides the java.lang.Module for the unnamed module defined
// to the boot loader.
//
// IllegalArgumentExceptions are thrown for the following :
// * Module has a name
- // * Module is not a subclass of java.lang.reflect.Module
+ // * Module is not a subclass of java.lang.Module
// * Module's class loader is not the boot loader
// NullPointerExceptions are thrown if module is null.
static void set_bootloader_unnamed_module(jobject module, TRAPS);
@@ -96,10 +96,10 @@ public:
// module does not exist.
static void add_reads_module(jobject from_module, jobject to_module, TRAPS);
- // Return the java.lang.reflect.Module object for this class object.
+ // Return the java.lang.Module object for this class object.
static jobject get_module(jclass clazz, TRAPS);
- // Return the java.lang.reflect.Module object for this class loader and package.
+ // Return the java.lang.Module object for this class loader and package.
// Returns NULL if the class loader has not loaded any classes in the package.
// The package should contain /'s, not .'s, as in java/lang, not java.lang.
// NullPointerException is thrown if package is null.
@@ -109,7 +109,7 @@ public:
static jobject get_named_module(Handle h_loader, const char* package, TRAPS);
// If package is defined by loader, return the
- // java.lang.reflect.Module object for the module in which the package is defined.
+ // java.lang.Module object for the module in which the package is defined.
// Returns NULL if package is invalid or not defined by loader.
static jobject get_module(Symbol* package_name, Handle h_loader, TRAPS);
diff --git a/hotspot/src/share/vm/classfile/systemDictionary.hpp b/hotspot/src/share/vm/classfile/systemDictionary.hpp
index 4cd5e40ffa8..f6ad7a4b347 100644
--- a/hotspot/src/share/vm/classfile/systemDictionary.hpp
+++ b/hotspot/src/share/vm/classfile/systemDictionary.hpp
@@ -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
@@ -133,9 +133,9 @@ class SymbolPropertyTable;
do_klass(Thread_klass, java_lang_Thread, Pre ) \
do_klass(ThreadGroup_klass, java_lang_ThreadGroup, Pre ) \
do_klass(Properties_klass, java_util_Properties, Pre ) \
+ do_klass(Module_klass, java_lang_Module, Pre ) \
do_klass(reflect_AccessibleObject_klass, java_lang_reflect_AccessibleObject, Pre ) \
do_klass(reflect_Field_klass, java_lang_reflect_Field, Pre ) \
- do_klass(reflect_Module_klass, java_lang_reflect_Module, Pre ) \
do_klass(reflect_Parameter_klass, java_lang_reflect_Parameter, Opt ) \
do_klass(reflect_Method_klass, java_lang_reflect_Method, Pre ) \
do_klass(reflect_Constructor_klass, java_lang_reflect_Constructor, Pre ) \
diff --git a/hotspot/src/share/vm/classfile/vmSymbols.hpp b/hotspot/src/share/vm/classfile/vmSymbols.hpp
index 1a9db44ddcd..633bb8fd98a 100644
--- a/hotspot/src/share/vm/classfile/vmSymbols.hpp
+++ b/hotspot/src/share/vm/classfile/vmSymbols.hpp
@@ -56,6 +56,7 @@
template(java_lang_Object, "java/lang/Object") \
template(java_lang_Class, "java/lang/Class") \
template(java_lang_Package, "java/lang/Package") \
+ template(java_lang_Module, "java/lang/Module") \
template(java_lang_String, "java/lang/String") \
template(java_lang_StringLatin1, "java/lang/StringLatin1") \
template(java_lang_StringUTF16, "java/lang/StringUTF16") \
@@ -90,7 +91,6 @@
template(java_lang_reflect_Method, "java/lang/reflect/Method") \
template(java_lang_reflect_Constructor, "java/lang/reflect/Constructor") \
template(java_lang_reflect_Field, "java/lang/reflect/Field") \
- template(java_lang_reflect_Module, "java/lang/reflect/Module") \
template(java_lang_reflect_Parameter, "java/lang/reflect/Parameter") \
template(java_lang_reflect_Array, "java/lang/reflect/Array") \
template(java_lang_StringBuffer, "java/lang/StringBuffer") \
@@ -136,7 +136,7 @@
template(initPhase1_name, "initPhase1") \
template(initPhase2_name, "initPhase2") \
template(initPhase3_name, "initPhase3") \
- template(java_lang_reflect_module_init_signature, "(Ljava/lang/ClassLoader;Ljava/lang/String;)V") \
+ template(java_lang_module_init_signature, "(Ljava/lang/ClassLoader;Ljava/lang/String;)V") \
\
/* class file format tags */ \
template(tag_source_file, "SourceFile") \
@@ -450,7 +450,7 @@
template(getModule_name, "getModule") \
template(input_stream_void_signature, "(Ljava/io/InputStream;)V") \
template(definePackage_name, "definePackage") \
- template(definePackage_signature, "(Ljava/lang/String;Ljava/lang/reflect/Module;)Ljava/lang/Package;") \
+ template(definePackage_signature, "(Ljava/lang/String;Ljava/lang/Module;)Ljava/lang/Package;") \
template(defineOrCheckPackage_name, "defineOrCheckPackage") \
template(defineOrCheckPackage_signature, "(Ljava/lang/String;Ljava/util/jar/Manifest;Ljava/net/URL;)Ljava/lang/Package;") \
template(fileToEncodedURL_name, "fileToEncodedURL") \
@@ -532,7 +532,7 @@
template(void_class_signature, "()Ljava/lang/Class;") \
template(void_class_array_signature, "()[Ljava/lang/Class;") \
template(void_string_signature, "()Ljava/lang/String;") \
- template(void_module_signature, "()Ljava/lang/reflect/Module;") \
+ template(void_module_signature, "()Ljava/lang/Module;") \
template(object_array_object_signature, "([Ljava/lang/Object;)Ljava/lang/Object;") \
template(object_object_array_object_signature, "(Ljava/lang/Object;[Ljava/lang/Object;)Ljava/lang/Object;")\
template(exception_void_signature, "(Ljava/lang/Exception;)V") \
@@ -552,7 +552,7 @@
template(reference_signature, "Ljava/lang/ref/Reference;") \
template(sun_misc_Cleaner_signature, "Lsun/misc/Cleaner;") \
template(executable_signature, "Ljava/lang/reflect/Executable;") \
- template(module_signature, "Ljava/lang/reflect/Module;") \
+ template(module_signature, "Ljava/lang/Module;") \
template(concurrenthashmap_signature, "Ljava/util/concurrent/ConcurrentHashMap;") \
template(String_StringBuilder_signature, "(Ljava/lang/String;)Ljava/lang/StringBuilder;") \
template(int_StringBuilder_signature, "(I)Ljava/lang/StringBuilder;") \
@@ -642,16 +642,16 @@
template(jdk_internal_module_Modules, "jdk/internal/module/Modules") \
template(jdk_internal_vm_VMSupport, "jdk/internal/vm/VMSupport") \
template(addReads_name, "addReads") \
- template(addReads_signature, "(Ljava/lang/reflect/Module;Ljava/lang/reflect/Module;)V") \
+ template(addReads_signature, "(Ljava/lang/Module;Ljava/lang/Module;)V") \
template(addExports_name, "addExports") \
template(addOpens_name, "addOpens") \
- template(addExports_signature, "(Ljava/lang/reflect/Module;Ljava/lang/String;Ljava/lang/reflect/Module;)V") \
+ template(addExports_signature, "(Ljava/lang/Module;Ljava/lang/String;Ljava/lang/Module;)V") \
template(addUses_name, "addUses") \
- template(addUses_signature, "(Ljava/lang/reflect/Module;Ljava/lang/Class;)V") \
+ template(addUses_signature, "(Ljava/lang/Module;Ljava/lang/Class;)V") \
template(addProvides_name, "addProvides") \
- template(addProvides_signature, "(Ljava/lang/reflect/Module;Ljava/lang/Class;Ljava/lang/Class;)V") \
+ template(addProvides_signature, "(Ljava/lang/Module;Ljava/lang/Class;Ljava/lang/Class;)V") \
template(transformedByAgent_name, "transformedByAgent") \
- template(transformedByAgent_signature, "(Ljava/lang/reflect/Module;)V") \
+ template(transformedByAgent_signature, "(Ljava/lang/Module;)V") \
template(appendToClassPathForInstrumentation_name, "appendToClassPathForInstrumentation") \
do_alias(appendToClassPathForInstrumentation_signature, string_void_signature) \
template(serializePropertiesToByteArray_name, "serializePropertiesToByteArray") \
diff --git a/hotspot/src/share/vm/gc/parallel/gcTaskThread.cpp b/hotspot/src/share/vm/gc/parallel/gcTaskThread.cpp
index 48eb3c4163d..e300f8c2309 100644
--- a/hotspot/src/share/vm/gc/parallel/gcTaskThread.cpp
+++ b/hotspot/src/share/vm/gc/parallel/gcTaskThread.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2002, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2002, 2017, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -54,8 +54,26 @@ GCTaskThread::~GCTaskThread() {
}
}
+void GCTaskThread::add_task_timestamp(const char* name, jlong t_entry, jlong t_exit) {
+ if (_time_stamp_index < GCTaskTimeStampEntries) {
+ GCTaskTimeStamp* time_stamp = time_stamp_at(_time_stamp_index);
+ time_stamp->set_name(name);
+ time_stamp->set_entry_time(t_entry);
+ time_stamp->set_exit_time(t_exit);
+ } else {
+ if (_time_stamp_index == GCTaskTimeStampEntries) {
+ log_warning(gc, task, time)("GC-thread %u: Too many timestamps, ignoring future ones. "
+ "Increase GCTaskTimeStampEntries to get more info.",
+ id());
+ }
+ // Let _time_stamp_index keep counting to give the user an idea about how many
+ // are needed.
+ }
+ _time_stamp_index++;
+}
+
GCTaskTimeStamp* GCTaskThread::time_stamp_at(uint index) {
- guarantee(index < GCTaskTimeStampEntries, "increase GCTaskTimeStampEntries");
+ assert(index < GCTaskTimeStampEntries, "Precondition");
if (_time_stamps == NULL) {
// We allocate the _time_stamps array lazily since logging can be enabled dynamically
GCTaskTimeStamp* time_stamps = NEW_C_HEAP_ARRAY(GCTaskTimeStamp, GCTaskTimeStampEntries, mtGC);
@@ -65,7 +83,6 @@ GCTaskTimeStamp* GCTaskThread::time_stamp_at(uint index) {
FREE_C_HEAP_ARRAY(GCTaskTimeStamp, time_stamps);
}
}
-
return &(_time_stamps[index]);
}
@@ -75,8 +92,11 @@ void GCTaskThread::print_task_time_stamps() {
// Since _time_stamps is now lazily allocated we need to check that it
// has in fact been allocated when calling this function.
if (_time_stamps != NULL) {
- log_debug(gc, task, time)("GC-Thread %u entries: %d", id(), _time_stamp_index);
- for(uint i=0; i<_time_stamp_index; i++) {
+ log_debug(gc, task, time)("GC-Thread %u entries: %d%s", id(),
+ _time_stamp_index,
+ _time_stamp_index >= GCTaskTimeStampEntries ? " (overflow)" : "");
+ const uint max_index = MIN2(_time_stamp_index, GCTaskTimeStampEntries);
+ for (uint i = 0; i < max_index; i++) {
GCTaskTimeStamp* time_stamp = time_stamp_at(i);
log_debug(gc, task, time)("\t[ %s " JLONG_FORMAT " " JLONG_FORMAT " ]",
time_stamp->name(),
@@ -144,16 +164,7 @@ void GCTaskThread::run() {
if (log_is_enabled(Debug, gc, task, time)) {
timer.update();
-
- GCTaskTimeStamp* time_stamp = time_stamp_at(_time_stamp_index);
-
- time_stamp->set_name(name);
- time_stamp->set_entry_time(entry_time);
- time_stamp->set_exit_time(timer.ticks());
-
- // Update the index after we have set up the entry correctly since
- // GCTaskThread::print_task_time_stamps() may read this value concurrently.
- _time_stamp_index++;
+ add_task_timestamp(name, entry_time, timer.ticks());
}
} else {
// idle tasks complete outside the normal accounting
diff --git a/hotspot/src/share/vm/gc/parallel/gcTaskThread.hpp b/hotspot/src/share/vm/gc/parallel/gcTaskThread.hpp
index 59e6286f26e..d4fbe4b96b7 100644
--- a/hotspot/src/share/vm/gc/parallel/gcTaskThread.hpp
+++ b/hotspot/src/share/vm/gc/parallel/gcTaskThread.hpp
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2002, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2002, 2017, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -45,6 +45,7 @@ private:
uint _time_stamp_index;
GCTaskTimeStamp* time_stamp_at(uint index);
+ void add_task_timestamp(const char* name, jlong t_entry, jlong t_exit);
bool _is_working; // True if participating in GC tasks
@@ -92,16 +93,16 @@ class GCTaskTimeStamp : public CHeapObj
private:
jlong _entry_time;
jlong _exit_time;
- char* _name;
+ const char* _name;
public:
jlong entry_time() { return _entry_time; }
jlong exit_time() { return _exit_time; }
- const char* name() const { return (const char*)_name; }
+ const char* name() const { return _name; }
void set_entry_time(jlong time) { _entry_time = time; }
void set_exit_time(jlong time) { _exit_time = time; }
- void set_name(char* name) { _name = name; }
+ void set_name(const char* name) { _name = name; }
};
#endif // SHARE_VM_GC_PARALLEL_GCTASKTHREAD_HPP
diff --git a/hotspot/src/share/vm/oops/constMethod.hpp b/hotspot/src/share/vm/oops/constMethod.hpp
index 45246ba209b..7453ecbf689 100644
--- a/hotspot/src/share/vm/oops/constMethod.hpp
+++ b/hotspot/src/share/vm/oops/constMethod.hpp
@@ -359,7 +359,9 @@ public:
}
// Sizing
- static int header_size() { return sizeof(ConstMethod)/wordSize; }
+ static int header_size() {
+ return align_size_up(sizeof(ConstMethod), wordSize) / wordSize;
+ }
// Size needed
static int size(int code_size, InlineTableSizes* sizes);
diff --git a/hotspot/src/share/vm/oops/constantPool.hpp b/hotspot/src/share/vm/oops/constantPool.hpp
index 38a71f525d2..86cfa192171 100644
--- a/hotspot/src/share/vm/oops/constantPool.hpp
+++ b/hotspot/src/share/vm/oops/constantPool.hpp
@@ -705,7 +705,9 @@ class ConstantPool : public Metadata {
}
// Sizing (in words)
- static int header_size() { return sizeof(ConstantPool)/wordSize; }
+ static int header_size() {
+ return align_size_up(sizeof(ConstantPool), wordSize) / wordSize;
+ }
static int size(int length) { return align_metadata_size(header_size() + length); }
int size() const { return size(length()); }
#if INCLUDE_SERVICES
diff --git a/hotspot/src/share/vm/oops/cpCache.hpp b/hotspot/src/share/vm/oops/cpCache.hpp
index e58d7c16ceb..e68c68a5098 100644
--- a/hotspot/src/share/vm/oops/cpCache.hpp
+++ b/hotspot/src/share/vm/oops/cpCache.hpp
@@ -359,7 +359,9 @@ class ConstantPoolCacheEntry VALUE_OBJ_CLASS_SPEC {
return (TosState)((_flags >> tos_state_shift) & tos_state_mask); }
// Code generation support
- static WordSize size() { return in_WordSize(sizeof(ConstantPoolCacheEntry) / wordSize); }
+ static WordSize size() {
+ return in_WordSize(align_size_up(sizeof(ConstantPoolCacheEntry), wordSize) / wordSize);
+ }
static ByteSize size_in_bytes() { return in_ByteSize(sizeof(ConstantPoolCacheEntry)); }
static ByteSize indices_offset() { return byte_offset_of(ConstantPoolCacheEntry, _indices); }
static ByteSize f1_offset() { return byte_offset_of(ConstantPoolCacheEntry, _f1); }
diff --git a/hotspot/src/share/vm/oops/klass.cpp b/hotspot/src/share/vm/oops/klass.cpp
index ebc59953842..d8ec1ba8875 100644
--- a/hotspot/src/share/vm/oops/klass.cpp
+++ b/hotspot/src/share/vm/oops/klass.cpp
@@ -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
@@ -532,7 +532,7 @@ void Klass::restore_unshareable_info(ClassLoaderData* loader_data, Handle protec
} else {
module_entry = ModuleEntryTable::javabase_moduleEntry();
}
- // Obtain java.lang.reflect.Module, if available
+ // Obtain java.lang.Module, if available
Handle module_handle(THREAD, ((module_entry != NULL) ? JNIHandles::resolve(module_entry->module()) : (oop)NULL));
java_lang_Class::create_mirror(this, loader, module_handle, protection_domain, CHECK);
}
diff --git a/hotspot/src/share/vm/oops/method.hpp b/hotspot/src/share/vm/oops/method.hpp
index ebd5f0feef2..6675410db81 100644
--- a/hotspot/src/share/vm/oops/method.hpp
+++ b/hotspot/src/share/vm/oops/method.hpp
@@ -671,7 +671,9 @@ class Method : public Metadata {
#endif
// sizing
- static int header_size() { return sizeof(Method)/wordSize; }
+ static int header_size() {
+ return align_size_up(sizeof(Method), wordSize) / wordSize;
+ }
static int size(bool is_native);
int size() const { return method_size(); }
#if INCLUDE_SERVICES
diff --git a/hotspot/src/share/vm/oops/methodCounters.hpp b/hotspot/src/share/vm/oops/methodCounters.hpp
index df96b638735..73c438b71ea 100644
--- a/hotspot/src/share/vm/oops/methodCounters.hpp
+++ b/hotspot/src/share/vm/oops/methodCounters.hpp
@@ -116,7 +116,9 @@ class MethodCounters: public MetaspaceObj {
AOT_ONLY(Method* method() const { return _method; })
- static int size() { return sizeof(MethodCounters) / wordSize; }
+ static int size() {
+ return align_size_up(sizeof(MethodCounters), wordSize) / wordSize;
+ }
bool is_klass() const { return false; }
diff --git a/hotspot/src/share/vm/prims/jvmti.xml b/hotspot/src/share/vm/prims/jvmti.xml
index d01db3240fc..e7d02cc6dd0 100644
--- a/hotspot/src/share/vm/prims/jvmti.xml
+++ b/hotspot/src/share/vm/prims/jvmti.xml
@@ -6516,7 +6516,7 @@ class C2 extends C1 implements I2 {
Get Named Module
- Return the java.lang.reflect.Module object for a named
+ Return the java.lang.Module object for a named
module defined to a class loader that contains a given package.
The module is returned via module_ptr.
@@ -6554,7 +6554,7 @@ class C2 extends C1 implements I2 {
- On return, points to a java.lang.reflect.Module object
+ On return, points to a java.lang.Module object
or points to NULL.
@@ -6599,6 +6599,10 @@ class C2 extends C1 implements I2 {
If is not a module object.
+
+ if the module cannot be modified.
+ See .
+
@@ -6633,7 +6637,7 @@ class C2 extends C1 implements I2 {
The module the package is exported to.
If the to_module is not a subclass of
- java.lang.reflect.Module this function returns
+ java.lang.Module this function returns
.
@@ -6649,6 +6653,10 @@ class C2 extends C1 implements I2 {
If the package
does not belong to the module.
+
+ if the module cannot be modified.
+ See .
+
@@ -6684,7 +6692,7 @@ class C2 extends C1 implements I2 {
The module with the package to open.
If the to_module is not a subclass of
- java.lang.reflect.Module this function returns
+ java.lang.Module this function returns
.
@@ -6700,6 +6708,10 @@ class C2 extends C1 implements I2 {
If the package
does not belong to the module.
+
+ if the module cannot be modified.
+ See .
+
@@ -6737,6 +6749,10 @@ class C2 extends C1 implements I2 {
If is not a class object.
+
+ if the module cannot be modified.
+ See .
+
@@ -6783,6 +6799,44 @@ class C2 extends C1 implements I2 {
If is not a class object.
+
+ if the module cannot be modified.
+ See .
+
+
+
+
+
+ Is Modifiable Module
+
+ Determines whether a module is modifiable.
+ If a module is modifiable then this module can be updated with
+ , ,
+ , ,
+ and . If a module is not modifiable
+ then the module can not be updated with these functions.
+
+ new
+
+
+
+
+
+
+ The module to query.
+
+
+
+
+
+ On return, points to the boolean result of this function.
+
+
+
+
+
+ If is not a module object.
+
@@ -7803,6 +7857,10 @@ class C2 extends C1 implements I2 {
A method in the new class version has different modifiers
than its counterpart in the old class version.
+
+ A module cannot be modified.
+ See .
+
@@ -11567,6 +11625,9 @@ myInit() {
The class cannot be modified.
+
+ The module cannot be modified.
+
The functionality is not available in this virtual machine.
@@ -14736,6 +14797,7 @@ typedef void (JNICALL *jvmtiEventVMInit)
- Add new functions:
- GetAllModules
- AddModuleReads, AddModuleExports, AddModuleOpens, AddModuleUses, AddModuleProvides
+ - IsModifiableModule
Clarified can_redefine_any_classes, can_retransform_any_classes and IsModifiableClass API to
disallow some implementation defined classes.
diff --git a/hotspot/src/share/vm/prims/jvmtiEnv.cpp b/hotspot/src/share/vm/prims/jvmtiEnv.cpp
index 57292a2c8bc..491eeddd1d5 100644
--- a/hotspot/src/share/vm/prims/jvmtiEnv.cpp
+++ b/hotspot/src/share/vm/prims/jvmtiEnv.cpp
@@ -235,12 +235,12 @@ JvmtiEnv::AddModuleReads(jobject module, jobject to_module) {
// check module
Handle h_module(THREAD, JNIHandles::resolve(module));
- if (!java_lang_reflect_Module::is_instance(h_module())) {
+ if (!java_lang_Module::is_instance(h_module())) {
return JVMTI_ERROR_INVALID_MODULE;
}
// check to_module
Handle h_to_module(THREAD, JNIHandles::resolve(to_module));
- if (!java_lang_reflect_Module::is_instance(h_to_module())) {
+ if (!java_lang_Module::is_instance(h_to_module())) {
return JVMTI_ERROR_INVALID_MODULE;
}
return JvmtiExport::add_module_reads(h_module, h_to_module, THREAD);
@@ -257,12 +257,12 @@ JvmtiEnv::AddModuleExports(jobject module, const char* pkg_name, jobject to_modu
// check module
Handle h_module(THREAD, JNIHandles::resolve(module));
- if (!java_lang_reflect_Module::is_instance(h_module())) {
+ if (!java_lang_Module::is_instance(h_module())) {
return JVMTI_ERROR_INVALID_MODULE;
}
// check to_module
Handle h_to_module(THREAD, JNIHandles::resolve(to_module));
- if (!java_lang_reflect_Module::is_instance(h_to_module())) {
+ if (!java_lang_Module::is_instance(h_to_module())) {
return JVMTI_ERROR_INVALID_MODULE;
}
return JvmtiExport::add_module_exports(h_module, h_pkg, h_to_module, THREAD);
@@ -279,12 +279,12 @@ JvmtiEnv::AddModuleOpens(jobject module, const char* pkg_name, jobject to_module
// check module
Handle h_module(THREAD, JNIHandles::resolve(module));
- if (!java_lang_reflect_Module::is_instance(h_module())) {
+ if (!java_lang_Module::is_instance(h_module())) {
return JVMTI_ERROR_INVALID_MODULE;
}
// check to_module
Handle h_to_module(THREAD, JNIHandles::resolve(to_module));
- if (!java_lang_reflect_Module::is_instance(h_to_module())) {
+ if (!java_lang_Module::is_instance(h_to_module())) {
return JVMTI_ERROR_INVALID_MODULE;
}
return JvmtiExport::add_module_opens(h_module, h_pkg, h_to_module, THREAD);
@@ -299,7 +299,7 @@ JvmtiEnv::AddModuleUses(jobject module, jclass service) {
// check module
Handle h_module(THREAD, JNIHandles::resolve(module));
- if (!java_lang_reflect_Module::is_instance(h_module())) {
+ if (!java_lang_Module::is_instance(h_module())) {
return JVMTI_ERROR_INVALID_MODULE;
}
// check service
@@ -321,7 +321,7 @@ JvmtiEnv::AddModuleProvides(jobject module, jclass service, jclass impl_class) {
// check module
Handle h_module(THREAD, JNIHandles::resolve(module));
- if (!java_lang_reflect_Module::is_instance(h_module())) {
+ if (!java_lang_Module::is_instance(h_module())) {
return JVMTI_ERROR_INVALID_MODULE;
}
// check service
@@ -339,6 +339,22 @@ JvmtiEnv::AddModuleProvides(jobject module, jclass service, jclass impl_class) {
return JvmtiExport::add_module_provides(h_module, h_service, h_impl_class, THREAD);
} /* end AddModuleProvides */
+// module - pre-checked for NULL
+// is_modifiable_class_ptr - pre-checked for NULL
+jvmtiError
+JvmtiEnv::IsModifiableModule(jobject module, jboolean* is_modifiable_module_ptr) {
+ JavaThread* THREAD = JavaThread::current();
+
+ // check module
+ Handle h_module(THREAD, JNIHandles::resolve(module));
+ if (!java_lang_Module::is_instance(h_module())) {
+ return JVMTI_ERROR_INVALID_MODULE;
+ }
+
+ *is_modifiable_module_ptr = JNI_TRUE;
+ return JVMTI_ERROR_NONE;
+} /* end IsModifiableModule */
+
//
// Class functions
diff --git a/hotspot/src/share/vm/runtime/globals.hpp b/hotspot/src/share/vm/runtime/globals.hpp
index e6b24b4c749..13c2f242c6c 100644
--- a/hotspot/src/share/vm/runtime/globals.hpp
+++ b/hotspot/src/share/vm/runtime/globals.hpp
@@ -1450,9 +1450,9 @@ public:
"Number of threads concurrent gc will use") \
constraint(ConcGCThreadsConstraintFunc,AfterErgo) \
\
- product(uintx, GCTaskTimeStampEntries, 200, \
+ product(uint, GCTaskTimeStampEntries, 200, \
"Number of time stamp entries per gc worker thread") \
- range(1, max_uintx) \
+ range(1, max_jint) \
\
product(bool, AlwaysTenure, false, \
"Always tenure objects in eden (ParallelGC only)") \
diff --git a/hotspot/src/share/vm/runtime/reflection.cpp b/hotspot/src/share/vm/runtime/reflection.cpp
index fb4b2ee63cc..68b895c5f05 100644
--- a/hotspot/src/share/vm/runtime/reflection.cpp
+++ b/hotspot/src/share/vm/runtime/reflection.cpp
@@ -594,9 +594,9 @@ char* Reflection::verify_class_access_msg(const Klass* current_class,
current_class_name, module_from_name, new_class_name,
module_to_name, module_from_name, module_to_name);
} else {
- jobject jlrm = module_to->module();
- assert(jlrm != NULL, "Null jlrm in module_to ModuleEntry");
- intptr_t identity_hash = JNIHandles::resolve(jlrm)->identity_hash();
+ jobject jlm = module_to->module();
+ assert(jlm != NULL, "Null jlm in module_to ModuleEntry");
+ intptr_t identity_hash = JNIHandles::resolve(jlm)->identity_hash();
size_t len = 160 + strlen(current_class_name) + 2*strlen(module_from_name) +
strlen(new_class_name) + 2*sizeof(uintx);
msg = NEW_RESOURCE_ARRAY(char, len);
@@ -621,9 +621,9 @@ char* Reflection::verify_class_access_msg(const Klass* current_class,
current_class_name, module_from_name, new_class_name,
module_to_name, module_to_name, package_name, module_from_name);
} else {
- jobject jlrm = module_from->module();
- assert(jlrm != NULL, "Null jlrm in module_from ModuleEntry");
- intptr_t identity_hash = JNIHandles::resolve(jlrm)->identity_hash();
+ jobject jlm = module_from->module();
+ assert(jlm != NULL, "Null jlm in module_from ModuleEntry");
+ intptr_t identity_hash = JNIHandles::resolve(jlm)->identity_hash();
size_t len = 170 + strlen(current_class_name) + strlen(new_class_name) +
2*strlen(module_to_name) + strlen(package_name) + 2*sizeof(uintx);
msg = NEW_RESOURCE_ARRAY(char, len);
diff --git a/hotspot/src/share/vm/runtime/thread.cpp b/hotspot/src/share/vm/runtime/thread.cpp
index b4fe087a960..c5bf44f76ec 100644
--- a/hotspot/src/share/vm/runtime/thread.cpp
+++ b/hotspot/src/share/vm/runtime/thread.cpp
@@ -3465,7 +3465,7 @@ void Threads::initialize_java_lang_classes(JavaThread* main_thread, TRAPS) {
java_lang_Thread::RUNNABLE);
// The VM creates objects of this class.
- initialize_class(vmSymbols::java_lang_reflect_Module(), CHECK);
+ initialize_class(vmSymbols::java_lang_Module(), CHECK);
// The VM preresolves methods to these classes. Make sure that they get initialized
initialize_class(vmSymbols::java_lang_reflect_Method(), CHECK);
diff --git a/hotspot/test/TEST.ROOT b/hotspot/test/TEST.ROOT
index 54b61ac1406..0bb7896cc79 100644
--- a/hotspot/test/TEST.ROOT
+++ b/hotspot/test/TEST.ROOT
@@ -50,8 +50,8 @@ requires.properties= \
vm.cpu.features \
vm.debug
-# Tests using jtreg 4.2 b04 features
-requiredVersion=4.2 b04
+# Tests using jtreg 4.2 b07 features
+requiredVersion=4.2 b07
# Path to libraries in the topmost test directory. This is needed so @library
# does not need ../../ notation to reach them
diff --git a/hotspot/test/compiler/c2/cr7200264/TestDriver.java b/hotspot/test/compiler/c2/cr7200264/TestDriver.java
index 558592ba693..bc8a987ffb2 100644
--- a/hotspot/test/compiler/c2/cr7200264/TestDriver.java
+++ b/hotspot/test/compiler/c2/cr7200264/TestDriver.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2016, 2017, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -26,7 +26,6 @@ package compiler.c2.cr7200264;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
-import java.util.regex.Pattern;
import jdk.test.lib.Asserts;
import jdk.test.lib.process.OutputAnalyzer;
@@ -45,7 +44,7 @@ public class TestDriver {
}
private List executeApplication() throws Throwable {
- OutputAnalyzer outputAnalyzer = ProcessTools.executeTestJvmAllArgs(
+ OutputAnalyzer outputAnalyzer = ProcessTools.executeTestJvm(
"-Xbatch",
"-XX:-TieredCompilation",
"-XX:+PrintCompilation",
diff --git a/hotspot/test/compiler/compilercontrol/share/scenario/Executor.java b/hotspot/test/compiler/compilercontrol/share/scenario/Executor.java
index fbd3f13259b..19ebd612e7c 100644
--- a/hotspot/test/compiler/compilercontrol/share/scenario/Executor.java
+++ b/hotspot/test/compiler/compilercontrol/share/scenario/Executor.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -25,6 +25,7 @@ package compiler.compilercontrol.share.scenario;
import compiler.compilercontrol.share.actions.BaseAction;
import jdk.test.lib.Asserts;
+import jdk.test.lib.management.InputArguments;
import jdk.test.lib.process.OutputAnalyzer;
import jdk.test.lib.process.ProcessTools;
import jdk.test.lib.dcmd.CommandExecutor;
@@ -38,6 +39,7 @@ import java.lang.reflect.Executable;
import java.net.ServerSocket;
import java.net.Socket;
import java.util.ArrayList;
+import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Map;
@@ -97,9 +99,13 @@ public class Executor {
// Start separate thread to connect with test VM
new Thread(() -> connectTestVM(serverSocket)).start();
}
- // Start test VM
- output = ProcessTools.executeTestJvmAllArgs(
- vmOptions.toArray(new String[vmOptions.size()]));
+ // Start a test VM using vm flags from @run and from vm options
+ String[] vmInputArgs = InputArguments.getVmInputArgs();
+ String[] cmds = Arrays.copyOf(vmInputArgs,
+ vmInputArgs.length + vmOptions.size());
+ System.arraycopy(vmOptions.toArray(), 0, cmds, vmInputArgs.length,
+ vmOptions.size());
+ output = ProcessTools.executeTestJvm(cmds);
} catch (Throwable thr) {
throw new Error("Execution failed: " + thr.getMessage(), thr);
}
diff --git a/hotspot/test/compiler/jvmci/common/CTVMUtilities.java b/hotspot/test/compiler/jvmci/common/CTVMUtilities.java
index 7ba6d00debf..7f32d95855d 100644
--- a/hotspot/test/compiler/jvmci/common/CTVMUtilities.java
+++ b/hotspot/test/compiler/jvmci/common/CTVMUtilities.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -41,7 +41,6 @@ import java.lang.reflect.Executable;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
-import java.lang.reflect.Module;
import java.lang.reflect.Parameter;
import java.util.HashMap;
import java.util.Map;
diff --git a/hotspot/test/compiler/jvmci/compilerToVM/DebugOutputTest.java b/hotspot/test/compiler/jvmci/compilerToVM/DebugOutputTest.java
index a66a448b5b1..f07c570fa16 100644
--- a/hotspot/test/compiler/jvmci/compilerToVM/DebugOutputTest.java
+++ b/hotspot/test/compiler/jvmci/compilerToVM/DebugOutputTest.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -30,11 +30,9 @@
* @modules java.base/jdk.internal.misc
* @modules jdk.internal.vm.ci/jdk.vm.ci.hotspot
* @build jdk.internal.vm.ci/jdk.vm.ci.hotspot.CompilerToVMHelper
- * @run main/othervm compiler.jvmci.compilerToVM.DebugOutputTest
+ * @run driver compiler.jvmci.compilerToVM.DebugOutputTest
*/
- // as soon as CODETOOLS-7901589 fixed, '@run main/othervm' should be replaced w/ '@run driver'
-
package compiler.jvmci.compilerToVM;
import jdk.test.lib.process.OutputAnalyzer;
@@ -42,8 +40,11 @@ import jdk.test.lib.process.ProcessTools;
import jdk.vm.ci.hotspot.CompilerToVMHelper;
import java.util.Arrays;
+import java.nio.file.Path;
+import java.nio.file.Paths;
public class DebugOutputTest {
+ private static final String VM_CI_MODULE = "jdk.internal.vm.ci";
public static void main(String[] args) {
new DebugOutputTest().test();
}
@@ -53,10 +54,18 @@ public class DebugOutputTest {
System.out.println(testCase);
OutputAnalyzer oa;
try {
- oa = ProcessTools.executeTestJvmAllArgs(
+ Path patch = Paths.get(System.getProperty("test.patch.path"));
+ Path jvmciPath = patch.resolve(VM_CI_MODULE).toAbsolutePath();
+ if (!jvmciPath.toFile().exists()) {
+ throw new Error("TESTBUG: patch for " + VM_CI_MODULE + " : "
+ + jvmciPath.toString() + " does not exist");
+ }
+ oa = ProcessTools.executeTestJvm(
"-XX:+UnlockExperimentalVMOptions",
"-XX:+EnableJVMCI",
- "-Xbootclasspath/a:.",
+ "--add-exports", "java.base/jdk.internal.misc=ALL-UNNAMED",
+ "--add-exports", "jdk.internal.vm.ci/jdk.vm.ci.hotspot=ALL-UNNAMED",
+ "--patch-module", VM_CI_MODULE + "=" + jvmciPath.toString(),
DebugOutputTest.Worker.class.getName(),
testCase.name());
} catch (Throwable e) {
diff --git a/hotspot/test/compiler/jvmci/jdk.vm.ci.hotspot.test/src/jdk/vm/ci/hotspot/test/MemoryAccessProviderData.java b/hotspot/test/compiler/jvmci/jdk.vm.ci.hotspot.test/src/jdk/vm/ci/hotspot/test/MemoryAccessProviderData.java
index fcbc721caa8..1122bd7eb5d 100644
--- a/hotspot/test/compiler/jvmci/jdk.vm.ci.hotspot.test/src/jdk/vm/ci/hotspot/test/MemoryAccessProviderData.java
+++ b/hotspot/test/compiler/jvmci/jdk.vm.ci.hotspot.test/src/jdk/vm/ci/hotspot/test/MemoryAccessProviderData.java
@@ -27,6 +27,7 @@ import java.lang.reflect.Field;
import org.testng.annotations.DataProvider;
+import sun.hotspot.WhiteBox;
import jdk.internal.misc.Unsafe;
import jdk.vm.ci.hotspot.HotSpotConstantReflectionProvider;
import jdk.vm.ci.hotspot.HotSpotJVMCIRuntimeProvider;
@@ -36,6 +37,10 @@ import jdk.vm.ci.meta.Constant;
import jdk.vm.ci.meta.JavaConstant;
import jdk.vm.ci.meta.JavaKind;
import jdk.vm.ci.runtime.JVMCI;
+import java.util.List;
+import java.util.ArrayList;
+import java.util.Map;
+import java.util.HashMap;
public class MemoryAccessProviderData {
private static final Unsafe UNSAFE = Unsafe.getUnsafe();
@@ -43,6 +48,18 @@ public class MemoryAccessProviderData {
private static final TestClass TEST_OBJECT = new TestClass();
private static final JavaConstant TEST_CONSTANT = CONSTANT_REFLECTION.forObject(TEST_OBJECT);
private static final JavaConstant TEST_CLASS_CONSTANT = CONSTANT_REFLECTION.forObject(TestClass.class);
+ private static KindData[] PRIMITIVE_KIND_DATA = {
+ new KindData(JavaKind.Boolean, TEST_OBJECT),
+ new KindData(JavaKind.Byte, TEST_OBJECT),
+ new KindData(JavaKind.Char, TEST_OBJECT),
+ new KindData(JavaKind.Short, TEST_OBJECT),
+ new KindData(JavaKind.Int, TEST_OBJECT),
+ new KindData(JavaKind.Float, TEST_OBJECT),
+ new KindData(JavaKind.Long, TEST_OBJECT),
+ new KindData(JavaKind.Double, TEST_OBJECT)
+ };
+ private static final WhiteBox WHITE_BOX = WhiteBox.getWhiteBox();
+
@DataProvider(name = "positiveObject")
public static Object[][] getPositiveObjectJavaKind() {
@@ -54,51 +71,40 @@ public class MemoryAccessProviderData {
@DataProvider(name = "positivePrimitive")
public static Object[][] getPositivePrimitiveJavaKinds() {
- Field booleanField;
- Field byteField;
- Field shortField;
- Field intField;
- Field longField;
- Field floatField;
- Field doubleField;
- Field charField;
- try {
- booleanField = MemoryAccessProviderData.TestClass.class.getDeclaredField("booleanField");
- byteField = MemoryAccessProviderData.TestClass.class.getDeclaredField("byteField");
- shortField = MemoryAccessProviderData.TestClass.class.getDeclaredField("shortField");
- intField = MemoryAccessProviderData.TestClass.class.getDeclaredField("intField");
- longField = MemoryAccessProviderData.TestClass.class.getDeclaredField("longField");
- floatField = MemoryAccessProviderData.TestClass.class.getDeclaredField("floatField");
- doubleField = MemoryAccessProviderData.TestClass.class.getDeclaredField("doubleField");
- charField = MemoryAccessProviderData.TestClass.class.getDeclaredField("charField");
- } catch (NoSuchFieldException e) {
- throw new Error("TESTBUG: can't find test field " + e, e);
+ List