Skip to content

Commit

Permalink
[JDK-8344133] Adapt JDK-8343981: Remove usage of security manager fro…
Browse files Browse the repository at this point in the history
…m Thread and related classes

PullRequest: graal/19311
  • Loading branch information
mur47x111 committed Nov 13, 2024
2 parents 0915cc6 + daefe02 commit 397ed73
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 5 deletions.
2 changes: 1 addition & 1 deletion common.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

"COMMENT.jdks": "When adding or removing JDKs keep in sync with JDKs in ci/common.jsonnet",
"jdks": {
"galahad-jdk": {"name": "jpg-jdk", "version": "24", "build_id": "jdk-24+24-2921", "platformspecific": true, "extrabundles": ["static-libs"]},
"galahad-jdk": {"name": "jpg-jdk", "version": "24", "build_id": "jdk-24+24-2950", "platformspecific": true, "extrabundles": ["static-libs"]},

"oraclejdk17": {"name": "jpg-jdk", "version": "17.0.7", "build_id": "jdk-17.0.7+8", "platformspecific": true, "extrabundles": ["static-libs"]},
"labsjdk-ce-17": {"name": "labsjdk", "version": "ce-17.0.7+4-jvmci-23.1-b02", "platformspecific": true },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,6 @@
import java.util.Map;
import java.util.Objects;

import com.oracle.svm.core.jdk.JDKUtils;
import jdk.graal.compiler.serviceprovider.JavaVersionUtil;
import org.graalvm.nativeimage.IsolateThread;
import org.graalvm.nativeimage.Platforms;
import org.graalvm.nativeimage.impl.InternalPlatform;
Expand All @@ -54,6 +52,7 @@

import jdk.graal.compiler.api.directives.GraalDirectives;
import jdk.graal.compiler.replacements.ReplacementsUtil;
import jdk.graal.compiler.serviceprovider.JavaVersionUtil;

@TargetClass(Thread.class)
@SuppressWarnings({"unused"})
Expand Down Expand Up @@ -117,7 +116,7 @@ public final class Target_java_lang_Thread {
*/
@Alias //
@RecomputeFieldValue(kind = RecomputeFieldValue.Kind.Reset) //
@TargetElement(onlyWith = JDK21OrEarlier.class)
@TargetElement(onlyWith = JDK21OrEarlier.class) //
public AccessControlContext inheritedAccessControlContext;

@Alias //
Expand Down Expand Up @@ -218,6 +217,7 @@ void setCurrentThread(Thread thread) {
@Substitute
@SuppressWarnings({"unused"})
@Platforms(InternalPlatform.NATIVE_ONLY.class)
@TargetElement(onlyWith = JDK21OrEarlier.class)
private Target_java_lang_Thread(
ThreadGroup g,
String name,
Expand All @@ -237,6 +237,27 @@ private Target_java_lang_Thread(
this.scopedValueBindings = NEW_THREAD_BINDINGS;
}

@Substitute
@Platforms(InternalPlatform.NATIVE_ONLY.class)
@TargetElement(onlyWith = JDKLatest.class)
private Target_java_lang_Thread(
ThreadGroup g,
String name,
int characteristics,
Runnable target,
long stackSize) {
/* Non-0 instance field initialization. */
this.interruptLock = new Object();
/* Injected Target_java_lang_Thread instance field initialization. */
this.threadData = new ThreadData();

String nameLocal = (name != null) ? name : genThreadName();
boolean inheritThreadLocals = (characteristics & NO_INHERIT_THREAD_LOCALS) == 0;
JavaThreads.initializeNewThread(this, g, target, nameLocal, stackSize, null, inheritThreadLocals);

this.scopedValueBindings = NEW_THREAD_BINDINGS;
}

@Substitute
static String genThreadName() {
int threadNum = JavaThreads.JavaThreadNumberSingleton.singleton().threadInitNumber.incrementAndGet();
Expand Down Expand Up @@ -543,7 +564,7 @@ boolean isTerminated() {
final class Target_java_lang_Thread_Constants {
// Checkstyle: stop
@SuppressWarnings("removal") //
@TargetElement(onlyWith = JDK21OrEarlier.class)
@TargetElement(onlyWith = JDK21OrEarlier.class) //
@Alias static AccessControlContext NO_PERMISSIONS_ACC;

@Alias static ThreadGroup VTHREAD_GROUP;
Expand Down

0 comments on commit 397ed73

Please sign in to comment.