Skip to content

Commit 5debbd8

Browse files
pejovicatkrodriguez
authored andcommitted
[GR-42727] Switch SVM gates from JDK 19 to JDK 20.
PullRequest: graal/13455
2 parents 43f805d + 9d57126 commit 5debbd8

File tree

12 files changed

+140
-7
lines changed

12 files changed

+140
-7
lines changed

substratevm/ci/ci.jsonnet

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,6 @@
5353
// JDKs
5454
local jdk_name_to_dict = {
5555
"jdk17"+: common.labsjdk17,
56-
"jdk19"+: common.labsjdk19,
5756
"jdk20"+: common.labsjdk20,
5857
},
5958

@@ -80,6 +79,7 @@
8079

8180
local all_jobs = {
8281
"windows:aarch64"+: exclude,
82+
"*:*:jdk19"+: exclude,
8383
},
8484
local no_jobs = all_jobs {
8585
"*"+: exclude,
@@ -112,7 +112,7 @@
112112
"linux:amd64:jdk20": gate + t("30:00"),
113113
}),
114114
"basics": mxgate("build,helloworld,native_unittests,truffle_unittests,debuginfotest,hellomodule") + maven + jsonschema + platform_spec(no_jobs) + platform_spec({
115-
"linux:amd64:jdk19": gate + gdb("10.2") + t("55:00"),
115+
"linux:amd64:jdk20": gate + gdb("10.2") + t("55:00"),
116116
"windows:amd64:jdk17": gate + t("1:30:00"),
117117
}) + variants({
118118
"optlevel:quickbuild": {
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
/*
2+
* Copyright (c) 2022, 2022, 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.jdk;
26+
27+
import java.util.function.BooleanSupplier;
28+
29+
import org.graalvm.compiler.serviceprovider.JavaVersionUtil;
30+
31+
public class JDK19OrEarlier implements BooleanSupplier {
32+
@Override
33+
public boolean getAsBoolean() {
34+
return JavaVersionUtil.JAVA_SPEC <= 19;
35+
}
36+
}
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
/*
2+
* Copyright (c) 2022, 2022, 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.jdk;
26+
27+
import java.util.function.BooleanSupplier;
28+
29+
import org.graalvm.compiler.serviceprovider.JavaVersionUtil;
30+
31+
public class JDK20OrLater implements BooleanSupplier {
32+
@Override
33+
public boolean getAsBoolean() {
34+
return JavaVersionUtil.JAVA_SPEC >= 20;
35+
}
36+
}

substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jfr/JfrRecorderThread.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
package com.oracle.svm.core.jfr;
2626

2727
import org.graalvm.compiler.core.common.SuppressFBWarnings;
28+
import org.graalvm.compiler.serviceprovider.JavaVersionUtil;
2829
import org.graalvm.nativeimage.Platform;
2930
import org.graalvm.nativeimage.Platforms;
3031
import org.graalvm.word.UnsignedWord;
@@ -135,8 +136,11 @@ private void persistBuffers(JfrChunkWriter chunkWriter) {
135136
if (isFullEnough(buffer)) {
136137
boolean shouldNotify = persistBuffer(chunkWriter, buffer);
137138
if (shouldNotify) {
138-
synchronized (Target_jdk_jfr_internal_JVM.FILE_DELTA_CHANGE) {
139-
Target_jdk_jfr_internal_JVM.FILE_DELTA_CHANGE.notifyAll();
139+
Object chunkRotationMonitor = JavaVersionUtil.JAVA_SPEC >= 20
140+
? Target_jdk_jfr_internal_JVM.CHUNK_ROTATION_MONITOR
141+
: Target_jdk_jfr_internal_JVM.FILE_DELTA_CHANGE;
142+
synchronized (chunkRotationMonitor) {
143+
chunkRotationMonitor.notifyAll();
140144
}
141145
}
142146
}

substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jfr/Target_jdk_jfr_internal_JVM.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,9 @@
3737
import com.oracle.svm.core.jdk.JDK11OrEarlier;
3838
import com.oracle.svm.core.jdk.JDK17OrEarlier;
3939
import com.oracle.svm.core.jdk.JDK17OrLater;
40+
import com.oracle.svm.core.jdk.JDK19OrEarlier;
4041
import com.oracle.svm.core.jdk.JDK19OrLater;
42+
import com.oracle.svm.core.jdk.JDK20OrLater;
4143
import com.oracle.svm.core.jfr.traceid.JfrTraceId;
4244
import com.oracle.svm.core.util.VMError;
4345

@@ -49,7 +51,11 @@
4951
@TargetClass(value = jdk.jfr.internal.JVM.class, onlyWith = HasJfrSupport.class)
5052
public final class Target_jdk_jfr_internal_JVM {
5153
// Checkstyle: stop
52-
@Alias static Object FILE_DELTA_CHANGE;
54+
@Alias @TargetElement(onlyWith = JDK20OrLater.class) //
55+
static Object CHUNK_ROTATION_MONITOR;
56+
57+
@Alias @TargetElement(onlyWith = JDK19OrEarlier.class) //
58+
static Object FILE_DELTA_CHANGE;
5359
// Checkstyle: resume
5460

5561
@Alias @RecomputeFieldValue(kind = RecomputeFieldValue.Kind.Reset) //

substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/reflect/target/Target_java_lang_reflect_Executable.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,19 @@
3838
import com.oracle.svm.core.annotate.RecomputeFieldValue.Kind;
3939
import com.oracle.svm.core.annotate.Substitute;
4040
import com.oracle.svm.core.annotate.TargetClass;
41+
import com.oracle.svm.core.annotate.TargetElement;
42+
import com.oracle.svm.core.jdk.JDK19OrEarlier;
43+
import com.oracle.svm.core.jdk.JDK20OrLater;
4144
import com.oracle.svm.core.reflect.ReflectionMetadataDecoder;
4245

4346
@TargetClass(value = Executable.class)
4447
public final class Target_java_lang_reflect_Executable {
4548

49+
@TargetElement(onlyWith = JDK20OrLater.class)//
50+
@Alias @RecomputeFieldValue(kind = Kind.Reset)//
51+
Target_java_lang_reflect_Executable_ParameterData parameterData;
52+
53+
@TargetElement(onlyWith = JDK19OrEarlier.class)//
4654
@Alias @RecomputeFieldValue(kind = Kind.Reset)//
4755
Parameter[] parameters;
4856

@@ -72,3 +80,7 @@ public Object transform(Object receiver, Object originalValue) {
7280
}
7381
}
7482
}
83+
84+
@TargetClass(value = Executable.class, innerClass = "ParameterData", onlyWith = JDK20OrLater.class)
85+
final class Target_java_lang_reflect_Executable_ParameterData {
86+
}

substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/reflect/target/Target_jdk_internal_reflect_AccessorGenerator.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@
2828

2929
import com.oracle.svm.core.annotate.Substitute;
3030
import com.oracle.svm.core.annotate.TargetClass;
31+
import com.oracle.svm.core.annotate.TargetElement;
32+
import com.oracle.svm.core.jdk.JDK19OrEarlier;
33+
import com.oracle.svm.core.jdk.JDK20OrLater;
3134
import com.oracle.svm.core.reflect.serialize.SerializationRegistry;
3235

3336
@TargetClass(className = "jdk.internal.reflect.AccessorGenerator")
@@ -37,8 +40,18 @@ public final class Target_jdk_internal_reflect_AccessorGenerator {
3740
@TargetClass(className = "jdk.internal.reflect.MethodAccessorGenerator")
3841
final class Target_jdk_internal_reflect_MethodAccessorGenerator {
3942

43+
@Substitute
44+
@TargetElement(onlyWith = JDK20OrLater.class)
45+
public Target_jdk_internal_reflect_SerializationConstructorAccessorImpl generateSerializationConstructor(Class<?> declaringClass,
46+
@SuppressWarnings("unused") Class<?>[] parameterTypes,
47+
@SuppressWarnings("unused") int modifiers,
48+
Class<?> targetConstructorClass) {
49+
return generateSerializationConstructor(declaringClass, parameterTypes, null, modifiers, targetConstructorClass);
50+
}
51+
4052
@SuppressWarnings("static-method")
4153
@Substitute
54+
@TargetElement(onlyWith = JDK19OrEarlier.class)
4255
public Target_jdk_internal_reflect_SerializationConstructorAccessorImpl generateSerializationConstructor(Class<?> declaringClass,
4356
@SuppressWarnings("unused") Class<?>[] parameterTypes,
4457
@SuppressWarnings("unused") Class<?>[] checkedExceptions,

substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/thread/ContinuationsFeature.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ public class ContinuationsFeature implements InternalFeature {
4646
@Override
4747
public void afterRegistration(AfterRegistrationAccess access) {
4848
boolean supportLoom = false;
49-
if (JavaVersionUtil.JAVA_SPEC == 19) {
49+
if (JavaVersionUtil.JAVA_SPEC >= 19) {
5050
boolean haveLoom = false;
5151
try {
5252
haveLoom = (Boolean) Class.forName("jdk.internal.misc.PreviewFeatures")

substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/thread/Target_java_lang_Thread.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@
5454
import com.oracle.svm.core.jdk.JDK11OrEarlier;
5555
import com.oracle.svm.core.jdk.JDK17OrEarlier;
5656
import com.oracle.svm.core.jdk.JDK17OrLater;
57+
import com.oracle.svm.core.jdk.JDK19OrEarlier;
5758
import com.oracle.svm.core.jdk.JDK19OrLater;
5859
import com.oracle.svm.core.jdk.LoomJDK;
5960
import com.oracle.svm.core.jdk.NotLoomJDK;
@@ -483,18 +484,21 @@ void interrupt0() {
483484
}
484485

485486
@Substitute
487+
@TargetElement(onlyWith = JDK19OrEarlier.class)
486488
@SuppressWarnings({"static-method"})
487489
private void stop0(Object o) {
488490
throw VMError.unsupportedFeature("The deprecated method Thread.stop is not supported");
489491
}
490492

491493
@Substitute
494+
@TargetElement(onlyWith = JDK19OrEarlier.class)
492495
@SuppressWarnings({"static-method"})
493496
private void suspend0() {
494497
throw VMError.unsupportedFeature("The deprecated method Thread.suspend is not supported");
495498
}
496499

497500
@Substitute
501+
@TargetElement(onlyWith = JDK19OrEarlier.class)
498502
@SuppressWarnings({"static-method"})
499503
private void resume0() {
500504
throw VMError.unsupportedFeature("The deprecated method Thread.resume is not supported");

substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/thread/Target_java_lang_VirtualThread.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@
3838
import com.oracle.svm.core.annotate.RecomputeFieldValue;
3939
import com.oracle.svm.core.annotate.Substitute;
4040
import com.oracle.svm.core.annotate.TargetClass;
41+
import com.oracle.svm.core.annotate.TargetElement;
42+
import com.oracle.svm.core.jdk.JDK20OrLater;
4143
import com.oracle.svm.core.jdk.LoomJDK;
4244
import com.oracle.svm.core.monitor.MonitorSupport;
4345
import com.oracle.svm.core.util.VMError;
@@ -66,6 +68,18 @@ public final class Target_java_lang_VirtualThread {
6668
private static void registerNatives() {
6769
}
6870

71+
@Substitute
72+
@TargetElement(onlyWith = JDK20OrLater.class)
73+
@SuppressWarnings({"static-method", "unused"})
74+
private void notifyJvmtiHideFrames(boolean hide) {
75+
/*
76+
* Unfortunately, resetting the `notifyJvmtiEvents` field is not enough to completely remove
77+
* calls to this method due to the way it's used from the `switchToVirtualThread` method, so
78+
* unlike the other `notifyJvmti*` methods, we need a substitution to prevent linker errors.
79+
*/
80+
throw VMError.shouldNotReachHere();
81+
}
82+
6983
@Alias Executor scheduler;
7084

7185
@Alias volatile Thread carrierThread;

substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/image/CCLinkerInvocation.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
import java.util.stream.Stream;
3939

4040
import org.graalvm.compiler.options.Option;
41+
import org.graalvm.compiler.serviceprovider.JavaVersionUtil;
4142
import org.graalvm.nativeimage.ImageSingletons;
4243
import org.graalvm.nativeimage.Platform;
4344

@@ -510,6 +511,10 @@ public List<String> getCommand() {
510511
cmd.add("secur32.lib");
511512
cmd.add("iphlpapi.lib");
512513
cmd.add("userenv.lib");
514+
if (JavaVersionUtil.JAVA_SPEC >= 20) {
515+
/* JDK-8295231 removed implicit linking via pragma directives in source files. */
516+
cmd.add("mswsock.lib");
517+
}
513518

514519
if (SubstrateOptions.EnableWildcardExpansion.getValue() && imageKind == AbstractImage.NativeImageKind.EXECUTABLE) {
515520
/*

substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/jdk/JNIRegistrationJavaNet.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,10 @@ private static void registerNetworkInterfaceInit(DuringAnalysisAccess a) {
211211
RuntimeJNIAccess.register(constructor(a, "java.net.NetworkInterface"));
212212
RuntimeJNIAccess.register(fields(a, "java.net.NetworkInterface", "name", "displayName", "index", "addrs", "bindings", "childs"));
213213
if (isPosix()) {
214-
RuntimeJNIAccess.register(fields(a, "java.net.NetworkInterface", "virtual", "parent", "defaultIndex"));
214+
RuntimeJNIAccess.register(fields(a, "java.net.NetworkInterface", "virtual", "parent"));
215+
if (JavaVersionUtil.JAVA_SPEC < 20) {
216+
RuntimeJNIAccess.register(fields(a, "java.net.NetworkInterface", "defaultIndex"));
217+
}
215218
}
216219

217220
RuntimeJNIAccess.register(constructor(a, "java.net.InterfaceAddress"));

0 commit comments

Comments
 (0)