Skip to content

Commit b0735cd

Browse files
committed
[GR-24572] JDK15 java.lang.invoke.MemberName is reachable.
PullRequest: graal/6600
2 parents 1ebe2de + 319c6d7 commit b0735cd

File tree

9 files changed

+146
-46
lines changed

9 files changed

+146
-46
lines changed

common.hocon

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ openjdk8 : { downloads : { JAVA_HOME : ${jdks.openjdk8} }}
3434
oraclejdk11 : { downloads : { JAVA_HOME : ${jdks.oraclejdk11} }}
3535
oraclejdk15 : { downloads : { JAVA_HOME : ${jdks.oraclejdk15} }}
3636
openjdk11 : { downloads : { JAVA_HOME : ${jdks.openjdk11} }}
37+
openjdk15 : { downloads : { JAVA_HOME : ${jdks.openjdk15} }}
3738

3839
labsjdk-ce-11 : { downloads : { JAVA_HOME : ${jdks.labsjdk-ce-11} }}
3940
labsjdk-ee-11 : { downloads : { JAVA_HOME : ${jdks.labsjdk-ee-11} }}

common.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,9 @@
66
"openjdk8": {"name": "openjdk", "version": "8u262+10-jvmci-20.2-b03", "platformspecific": true },
77
"oraclejdk8Debug": {"name": "oraclejdk", "version": "8u261+33-jvmci-20.2-b03-fastdebug", "platformspecific": true },
88
"oraclejdk11": {"name": "oraclejdk", "version": "11.0.6+8", "platformspecific": true },
9-
"oraclejdk15": {"name": "oraclejdk", "version": "15+27", "platformspecific": true },
9+
"oraclejdk15": {"name": "oraclejdk", "version": "15+30", "platformspecific": true },
1010
"openjdk11": {"name": "openjdk", "version": "11.0.3+7", "platformspecific": true },
11+
"openjdk15": {"name": "openjdk", "version": "15+30", "platformspecific": true },
1112
"labsjdk-ce-11": {"name": "labsjdk", "version": "ce-11.0.8+10-jvmci-20.2-b03", "platformspecific": true },
1213
"labsjdk-ee-11": {"name": "labsjdk", "version": "ee-11.0.8.0.2+1-jvmci-20.2-b03", "platformspecific": true }
1314
},

substratevm/mx.substratevm/suite.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,8 @@
227227
"requiresConcealed" : {
228228
"java.base" : [
229229
"jdk.internal.loader",
230+
"jdk.internal.misc",
231+
"sun.invoke.util",
230232
],
231233
},
232234
"javaCompliance": "15+",
Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
/*
2+
* Copyright (c) 2020, 2020, Oracle and/or its affiliates. All rights reserved.
3+
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4+
*
5+
* This code is free software; you can redistribute it and/or modify it
6+
* under the terms of the GNU General Public License version 2 only, as
7+
* published by the Free Software Foundation. Oracle designates this
8+
* particular file as subject to the "Classpath" exception as provided
9+
* by Oracle in the LICENSE file that accompanied this code.
10+
*
11+
* This code is distributed in the hope that it will be useful, but WITHOUT
12+
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13+
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14+
* version 2 for more details (a copy is included in the LICENSE file that
15+
* accompanied this code).
16+
*
17+
* You should have received a copy of the GNU General Public License version
18+
* 2 along with this work; if not, write to the Free Software Foundation,
19+
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20+
*
21+
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22+
* or visit www.oracle.com if you need additional information or have any
23+
* questions.
24+
*/
25+
package com.oracle.svm.core.jdk15;
26+
27+
import java.lang.invoke.MethodHandles;
28+
// Checkstyle: stop
29+
import sun.invoke.util.VerifyAccess;
30+
// Checkstyle: resume
31+
import jdk.internal.misc.Unsafe;
32+
33+
import com.oracle.svm.core.jdk.JDK15OrLater;
34+
import com.oracle.svm.core.jdk.JDK15OrEarlier;
35+
import com.oracle.svm.core.SubstrateUtil;
36+
import com.oracle.svm.core.annotate.Alias;
37+
import com.oracle.svm.core.annotate.Substitute;
38+
import com.oracle.svm.core.annotate.TargetClass;
39+
40+
@TargetClass(className = "java.lang.invoke.MethodHandles", innerClass = "Lookup", onlyWith = {JDK15OrLater.class, JDK15OrEarlier.class})
41+
final class Target_java_lang_invoke_MethodHandles_Lookup_JDK15 {
42+
43+
@Alias //
44+
private Class<?> lookupClass;
45+
46+
@Alias //
47+
private Class<?> prevLookupClass;
48+
49+
@Alias //
50+
private int allowedModes;
51+
52+
@Substitute
53+
public Class<?> lookupClass() {
54+
return lookupClass;
55+
}
56+
57+
/**
58+
* Eliminate the dependencies on MemberName.
59+
*/
60+
@Substitute
61+
public Class<?> ensureInitialized(Class<?> targetClass) throws IllegalAccessException {
62+
if (targetClass.isPrimitive()) {
63+
throw new IllegalArgumentException(targetClass + " is a primitive class");
64+
}
65+
if (targetClass.isArray()) {
66+
throw new IllegalArgumentException(targetClass + " is an array class");
67+
}
68+
if (!VerifyAccess.isClassAccessible(targetClass, lookupClass, prevLookupClass, allowedModes)) {
69+
// throw new MemberName(targetClass).makeAccessException("access violation", this);
70+
String message = "access violation: " + targetClass;
71+
if (this == SubstrateUtil.cast(MethodHandles.publicLookup(), Target_java_lang_invoke_MethodHandles_Lookup_JDK15.class)) {
72+
message += ", from public Lookup";
73+
} else {
74+
Module m = lookupClass().getModule();
75+
message += ", from " + lookupClass() + " (" + m + ")";
76+
if (prevLookupClass != null) {
77+
message += ", previous lookup " +
78+
prevLookupClass.getName() + " (" + prevLookupClass.getModule() + ")";
79+
}
80+
}
81+
throw new IllegalAccessException(message);
82+
}
83+
84+
// This call is a noop without the security manager
85+
// checkSecurityManager(targetClass, null);
86+
87+
// ensure class initialization
88+
Unsafe.getUnsafe().ensureClassInitialized(targetClass);
89+
return targetClass;
90+
}
91+
92+
}
93+
94+
public class Target_java_lang_invoke_MethodHandles_JDK15 {
95+
}

substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/aarch64/AArch64CPUFeatureAccess.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,11 @@ public static EnumSet<AArch64.CPUFeature> determineHostCPUFeatures() {
9898
features.add(AArch64.CPUFeature.A53MAC);
9999
}
100100
if (cpuFeatures.fDMBATOMICS()) {
101-
features.add(AArch64.CPUFeature.DMB_ATOMICS);
101+
try {
102+
features.add(AArch64.CPUFeature.valueOf("DMB_ATOMICS"));
103+
} catch (IllegalArgumentException e) {
104+
// This JVMCI CPU feature is not available in all JDKs (JDK-8243339)
105+
}
102106
}
103107

104108
return features;
Lines changed: 6 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -24,30 +24,13 @@
2424
*/
2525
package com.oracle.svm.core.jdk;
2626

27-
import com.oracle.svm.core.annotate.NeverInline;
28-
import com.oracle.svm.core.annotate.Substitute;
29-
import com.oracle.svm.core.annotate.TargetClass;
27+
import java.util.function.BooleanSupplier;
3028

31-
@TargetClass(className = "java.lang.StringConcatHelper", onlyWith = JDK11OrLater.class)
32-
final class Target_java_lang_StringConcatHelper {
29+
import org.graalvm.compiler.serviceprovider.JavaVersionUtil;
3330

34-
/**
35-
* The original implementation allocates the OutOfMemoryError in this method. This is OK with
36-
* JIT compilation, but bad for AOT compilation because there is no profiling information that
37-
* replaces the allocation with a deopt.
38-
*/
39-
@Substitute
40-
private static int checkOverflow(int len) {
41-
if (len < 0) {
42-
throw StringConcatHelperSupport.throwOutOfMemoryError();
43-
}
44-
return len;
45-
}
46-
}
47-
48-
class StringConcatHelperSupport {
49-
@NeverInline("slow path")
50-
static OutOfMemoryError throwOutOfMemoryError() {
51-
throw new OutOfMemoryError("Overflow: String length out of range");
31+
public class JDK15OrEarlier implements BooleanSupplier {
32+
@Override
33+
public boolean getAsBoolean() {
34+
return JavaVersionUtil.JAVA_SPEC <= 15;
5235
}
5336
}

substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/NativeImageGeneratorRunner.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -532,6 +532,9 @@ public static void main(String[] args) {
532532
ModuleSupport.exportAndOpenAllPackagesToUnnamed("jdk.internal.vm.compiler.management", true);
533533
ModuleSupport.exportAndOpenAllPackagesToUnnamed("com.oracle.graal.graal_enterprise", true);
534534
ModuleSupport.exportAndOpenPackageToUnnamed("java.base", "jdk.internal.loader", false);
535+
if (JavaVersionUtil.JAVA_SPEC >= 15) {
536+
ModuleSupport.exportAndOpenPackageToUnnamed("java.base", "jdk.internal.misc", false);
537+
}
535538
ModuleSupport.exportAndOpenPackageToUnnamed("java.base", "sun.text.spi", false);
536539
ModuleSupport.exportAndOpenPackageToUnnamed("java.base", "jdk.internal.org.objectweb.asm", false);
537540
NativeImageGeneratorRunner.main(args);

vm/ci_common/common.hocon

Lines changed: 29 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -250,6 +250,27 @@ full_vm_build_linux: ${svm-common-linux-amd64} ${sulong_linux} ${truffleruby_lin
250250
full_vm_build_linux_aarch64: ${svm-common-linux-aarch64} ${sulong_linux} ${custom_vm_linux}
251251
full_vm_build_darwin: ${svm-common-darwin} ${sulong_darwin} ${truffleruby_darwin} ${fastr_darwin} ${graalpython_darwin} ${custom_vm_darwin}
252252

253+
libgraal_compiler: ${svm-common-linux-amd64} ${custom_vm_linux} ${vm_linux} {
254+
run: [
255+
# enable asserts in the JVM building the image and enable asserts in the resulting native image
256+
[mx, --env, ${libgraal_env}, "--extra-image-builder-argument=-J-esa", "--extra-image-builder-argument=-J-ea", "--extra-image-builder-argument=-ea", build]
257+
[mx, --env, ${libgraal_env}, gate, --task, "LibGraal Compiler"]
258+
]
259+
timelimit: "1:00:00"
260+
targets: [gate]
261+
}
262+
263+
libgraal_truffle: ${svm-common-linux-amd64} ${custom_vm_linux} ${vm_linux} {
264+
run: [
265+
# enable asserts in the JVM building the image and enable asserts in the resulting native image
266+
[mx, --env, ${libgraal_env}, "--extra-image-builder-argument=-J-esa", "--extra-image-builder-argument=-J-ea", "--extra-image-builder-argument=-ea", build]
267+
[mx, --env, ${libgraal_env}, gate, --task, "LibGraal Truffle"]
268+
]
269+
logs: ${common_vm.logs} ["*/graal-compiler.log"]
270+
timelimit: "45:00"
271+
targets: [gate]
272+
}
273+
253274
builds += [
254275
#
255276
# Gates
@@ -260,27 +281,14 @@ builds += [
260281
]
261282
name: gate-vm-style-linux-amd64
262283
}
263-
${vm_java_8} ${svm-common-linux-amd64} ${custom_vm_linux} ${vm_linux} {
264-
run: [
265-
# enable asserts in the JVM building the image and enable asserts in the resulting native image
266-
[mx, --env, ${libgraal_env}, "--extra-image-builder-argument=-J-esa", "--extra-image-builder-argument=-J-ea", "--extra-image-builder-argument=-ea", build]
267-
[mx, --env, ${libgraal_env}, gate, --task, "LibGraal Compiler"]
268-
]
269-
timelimit: "1:00:00"
270-
targets: [gate]
271-
name: gate-vm-libgraal-compiler
272-
}
273-
${vm_java_8} ${svm-common-linux-amd64} ${custom_vm_linux} ${vm_linux} {
274-
run: [
275-
# enable asserts in the JVM building the image and enable asserts in the resulting native image
276-
[mx, --env, ${libgraal_env}, "--extra-image-builder-argument=-J-esa", "--extra-image-builder-argument=-J-ea", "--extra-image-builder-argument=-ea", build]
277-
[mx, --env, ${libgraal_env}, gate, --task, "LibGraal Truffle"]
278-
]
279-
logs: ${common_vm.logs} ["*/graal-compiler.log"]
280-
timelimit: "45:00"
281-
targets: [gate]
282-
name: gate-vm-libgraal-truffle
283-
}
284+
${libgraal_compiler} ${vm_java_8} { name: gate-vm-libgraal-compiler-8-linux-amd64 }
285+
# Blocked JDK-8249880
286+
# ${libgraal_compiler} ${vm_java_15} { name: gate-vm-libgraal-compiler-15-linux-amd64 }
287+
288+
${libgraal_truffle} ${vm_java_8} { name: gate-vm-libgraal-truffle-8-linux-amd64 }
289+
# Blocked JDK-8249880
290+
# ${libgraal_truffle} ${vm_java_15} { name: gate-vm-libgraal-truffle-15-linux-amd64 }
291+
284292
${vm_java_8} ${svm-common-linux-amd64} ${sulong_linux} ${custom_vm_linux} ${gate_vm_linux} {
285293
run: [
286294
[export, "SVM_SUITE="${svm_suite}]

vm/ci_includes/vm.hocon

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@ vm_java_8: ${openjdk8} {
44
vm_java_11: ${labsjdk-ce-11} {
55
environment: { BASE_JDK_VERSION: "11" }
66
}
7+
vm_java_15: ${openjdk15} {
8+
environment: { BASE_JDK_VERSION: "15" }
9+
}
710
svm_suite: /substratevm
811
vm_extra_suites: "truffleruby,graalpython,fastr,/wasm"
912
vm_extra_suites_aarch64: "/wasm,truffleruby"

0 commit comments

Comments
 (0)