Skip to content

Commit

Permalink
Remove JDK11OrEarlier substitutions
Browse files Browse the repository at this point in the history
  • Loading branch information
Christian Wimmer committed Apr 2, 2023
1 parent bea56bf commit c8d7ce0
Show file tree
Hide file tree
Showing 25 changed files with 20 additions and 654 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,6 @@
import com.oracle.svm.core.annotate.RecomputeFieldValue;
import com.oracle.svm.core.annotate.Substitute;
import com.oracle.svm.core.annotate.TargetClass;
import com.oracle.svm.core.annotate.TargetElement;
import com.oracle.svm.core.jdk.JDK11OrEarlier;
import com.oracle.svm.core.jdk.JDK17OrLater;
import com.oracle.svm.core.thread.VMThreads;

import jdk.internal.misc.InnocuousThread;
Expand Down Expand Up @@ -88,47 +85,15 @@ final class Target_jdk_internal_ref_CleanerImpl {
@Alias @RecomputeFieldValue(kind = RecomputeFieldValue.Kind.NewInstance, declClassName = "jdk.internal.ref.CleanerImpl$PhantomCleanableRef")//
Target_jdk_internal_ref_PhantomCleanable phantomCleanableList;

@Alias @RecomputeFieldValue(kind = RecomputeFieldValue.Kind.NewInstance, declClassName = "jdk.internal.ref.CleanerImpl$WeakCleanableRef")//
@TargetElement(onlyWith = JDK11OrEarlier.class) //
Target_jdk_internal_ref_WeakCleanable weakCleanableList;

@Alias @RecomputeFieldValue(kind = RecomputeFieldValue.Kind.NewInstance, declClassName = "jdk.internal.ref.CleanerImpl$SoftCleanableRef")//
@TargetElement(onlyWith = JDK11OrEarlier.class) //
Target_jdk_internal_ref_SoftCleanable softCleanableList;

@Alias @RecomputeFieldValue(kind = RecomputeFieldValue.Kind.NewInstance, declClassName = "java.lang.ref.ReferenceQueue")//
public ReferenceQueue<Object> queue;

/** @see #run() */
@Substitute
@TargetElement(name = "run", onlyWith = JDK11OrEarlier.class)
public void runJDK11() {
Thread t = Thread.currentThread();
InnocuousThread mlThread = (t instanceof InnocuousThread) ? (InnocuousThread) t : null;
while (!phantomCleanableList.isListEmpty() || !weakCleanableList.isListEmpty() || !softCleanableList.isListEmpty()) {
if (mlThread != null) {
mlThread.eraseThreadLocals();
}
try {
Cleaner.Cleanable ref = (Cleaner.Cleanable) queue.remove(60 * 1000L);
if (ref != null) {
ref.clean();
}
} catch (Throwable e) {
if (VMThreads.isTearingDown()) {
return;
}
}
}
}

/**
* This loop executes in a daemon thread and waits until there are no more cleanables (including
* the {@code Cleaner} itself), ignoring {@link InterruptedException}. This blocks VM tear-down,
* so we add a check if the VM is tearing down here.
*/
@Substitute
@TargetElement(onlyWith = JDK17OrLater.class)
public void run() {
Thread t = Thread.currentThread();
InnocuousThread mlThread = (t instanceof InnocuousThread) ? (InnocuousThread) t : null;
Expand Down Expand Up @@ -173,17 +138,3 @@ public Object transform(Object receiver, Object originalValue) {
return receiver;
}
}

// Removed by JDK-8251861
@TargetClass(className = "jdk.internal.ref.WeakCleanable", onlyWith = JDK11OrEarlier.class)
final class Target_jdk_internal_ref_WeakCleanable {
@Alias
native boolean isListEmpty();
}

// Removed by JDK-8251861
@TargetClass(className = "jdk.internal.ref.SoftCleanable", onlyWith = JDK11OrEarlier.class)
final class Target_jdk_internal_ref_SoftCleanable {
@Alias
native boolean isListEmpty();
}
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,6 @@
import com.oracle.svm.core.config.ConfigurationValues;
import com.oracle.svm.core.config.ObjectLayout;
import com.oracle.svm.core.heap.UnknownObjectField;
import com.oracle.svm.core.jdk.JDK11OrEarlier;
import com.oracle.svm.core.jdk.JDK17OrLater;
import com.oracle.svm.core.jdk.JDK19OrLater;
import com.oracle.svm.core.jdk.Resources;
Expand Down Expand Up @@ -363,10 +362,6 @@ public void setModule(Module module) {
@Substitute @InjectAccessors(CachedConstructorAccessors.class) //
private Constructor<?> cachedConstructor;

@Substitute @InjectAccessors(NewInstanceCallerCacheAccessors.class) //
@TargetElement(onlyWith = JDK11OrEarlier.class) //
private Class<?> newInstanceCallerCache;

@UnknownObjectField(types = DynamicHubMetadata.class, canBeNull = true) private DynamicHubMetadata hubMetadata;

@UnknownObjectField(types = ReflectionMetadata.class, canBeNull = true) private ReflectionMetadata reflectionMetadata;
Expand Down Expand Up @@ -1821,18 +1816,6 @@ private static void setCachedConstructor(DynamicHub that, Constructor<?> value)
}
}

private static class NewInstanceCallerCacheAccessors {
@SuppressWarnings("unused")
private static Class<?> getNewInstanceCallerCache(DynamicHub that) {
return that.companion.getNewInstanceCallerCache();
}

@SuppressWarnings("unused")
private static void setNewInstanceCallerCache(DynamicHub that, Class<?> value) {
that.companion.setNewInstanceCallerCache(value);
}
}

private static final class DynamicHubMetadata {
final int enclosingMethodInfoIndex;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@

import org.graalvm.compiler.serviceprovider.JavaVersionUtil;

@Deprecated(since = "23.1.0", forRemoval = true)
public class JDK11OrEarlier implements BooleanSupplier {
@Override
public boolean getAsBoolean() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,12 +86,6 @@
@SuppressWarnings("static-method")
final class Target_java_lang_Object {

@Substitute
@TargetElement(name = "registerNatives", onlyWith = JDK11OrEarlier.class)
private static void registerNativesSubst() {
/* We reimplemented all native methods, so nothing to do. */
}

@Substitute
@TargetElement(name = "getClass")
private Object getClassSubst() {
Expand Down

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
import static com.oracle.svm.core.annotate.RecomputeFieldValue.Kind.AtomicFieldUpdaterOffset;
import static com.oracle.svm.core.annotate.RecomputeFieldValue.Kind.Reset;

import java.lang.ref.ReferenceQueue;
import java.lang.ref.WeakReference;
import java.lang.reflect.Field;
import java.lang.reflect.Modifier;
Expand All @@ -40,7 +39,6 @@
import java.util.concurrent.atomic.AtomicIntegerFieldUpdater;
import java.util.concurrent.atomic.AtomicLongFieldUpdater;
import java.util.concurrent.atomic.AtomicReferenceFieldUpdater;
import java.util.concurrent.locks.ReentrantLock;
import java.util.function.Consumer;

import org.graalvm.nativeimage.ImageSingletons;
Expand All @@ -54,7 +52,6 @@
import com.oracle.svm.core.annotate.Delete;
import com.oracle.svm.core.annotate.InjectAccessors;
import com.oracle.svm.core.annotate.RecomputeFieldValue;
import com.oracle.svm.core.annotate.RecomputeFieldValue.Kind;
import com.oracle.svm.core.annotate.Substitute;
import com.oracle.svm.core.annotate.TargetClass;
import com.oracle.svm.core.annotate.TargetElement;
Expand Down Expand Up @@ -389,31 +386,6 @@ private static synchronized ForkJoinPool initializeCommonPool() {
}
}

@TargetClass(value = java.util.concurrent.ForkJoinTask.class, onlyWith = JDK11OrEarlier.class)
@SuppressWarnings("static-method")
final class Target_java_util_concurrent_ForkJoinTask_JDK11OrEarlier {
@Alias @RecomputeFieldValue(kind = Kind.FromAlias) //
private static Target_java_util_concurrent_ForkJoinTask_ExceptionNode[] exceptionTable;
@Alias @RecomputeFieldValue(kind = Kind.FromAlias) //
private static ReentrantLock exceptionTableLock;
@Alias @RecomputeFieldValue(kind = Kind.FromAlias) //
private static ReferenceQueue<Object> exceptionTableRefQueue;

static {
exceptionTableLock = new ReentrantLock();
exceptionTableRefQueue = new ReferenceQueue<>();
/*
* JDK 8 has a static final field EXCEPTION_MAP_CAPACITY with value 32, later versions just
* use 32 hardcoded. To be JDK version independent, we duplicate the hardcoded value.
*/
exceptionTable = new Target_java_util_concurrent_ForkJoinTask_ExceptionNode[32];
}
}

@TargetClass(value = java.util.concurrent.ForkJoinTask.class, innerClass = "ExceptionNode", onlyWith = JDK11OrEarlier.class)
final class Target_java_util_concurrent_ForkJoinTask_ExceptionNode {
}

/** Dummy class to have a class with the file's name. */
public final class RecomputedFields {
}
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@
import com.oracle.svm.core.SubstrateUtil;
import com.oracle.svm.core.annotate.Alias;
import com.oracle.svm.core.annotate.Delete;
import com.oracle.svm.core.annotate.InjectAccessors;
import com.oracle.svm.core.annotate.RecomputeFieldValue;
import com.oracle.svm.core.annotate.Substitute;
import com.oracle.svm.core.annotate.TargetClass;
Expand All @@ -66,7 +65,6 @@
import com.oracle.svm.core.util.VMError;
import com.oracle.svm.util.ReflectionUtil;

import jdk.internal.reflect.Reflection;
import sun.security.jca.ProviderList;
import sun.security.util.SecurityConstants;

Expand All @@ -79,35 +77,6 @@
@SuppressWarnings({"unused"})
final class Target_java_security_AccessController {

@Substitute
@TargetElement(onlyWith = JDK11OrEarlier.class)
public static <T> T doPrivileged(PrivilegedAction<T> action) throws Throwable {
return executePrivileged(action, null, Reflection.getCallerClass());
}

@Substitute
@TargetElement(onlyWith = JDK11OrEarlier.class)
public static <T> T doPrivileged(PrivilegedAction<T> action, AccessControlContext context) throws Throwable {
Class<?> caller = Reflection.getCallerClass();
AccessControlContext acc = checkContext(context, caller);
return executePrivileged(action, acc, caller);
}

@Substitute
@TargetElement(onlyWith = JDK11OrEarlier.class)
public static <T> T doPrivileged(PrivilegedExceptionAction<T> action) throws Throwable {
Class<?> caller = Reflection.getCallerClass();
return executePrivileged(action, null, caller);
}

@Substitute
@TargetElement(onlyWith = JDK11OrEarlier.class)
static <T> T doPrivileged(PrivilegedExceptionAction<T> action, AccessControlContext context) throws Throwable {
Class<?> caller = Reflection.getCallerClass();
AccessControlContext acc = checkContext(context, caller);
return executePrivileged(action, acc, caller);
}

@Substitute
@SuppressWarnings("deprecation")
static AccessControlContext getStackAccessControlContext() {
Expand Down Expand Up @@ -321,17 +290,6 @@ static boolean isTrustedCryptoProvider(Provider provider) {
@SuppressWarnings({"unused"})
final class Target_javax_crypto_JceSecurity {

/*
* Lazily recompute the RANDOM field at runtime. We cannot push the entire static initialization
* of JceSecurity to run time because we want the JceSecurity.verificationResults initialized at
* image build time.
*
* This is only used in {@link KeyAgreement}, it's safe to remove.
*/
@Alias @TargetElement(onlyWith = JDK11OrEarlier.class) //
@InjectAccessors(JceSecurityAccessor.class) //
static SecureRandom RANDOM;

/*
* The JceSecurity.verificationResults cache is initialized by the SecurityServicesFeature at
* build time, for all registered providers. The cache is used by JceSecurity.canUseProvider()
Expand Down Expand Up @@ -634,22 +592,6 @@ final class Target_sun_security_jca_ProviderConfig_ProviderLoader {
static Target_sun_security_jca_ProviderConfig_ProviderLoader INSTANCE;
}

/**
* This only applies to JDK8 and JDK11. Experimental FIPS mode in the SunJSSE Provider was removed
* in JDK-8217835. Going forward it is recommended to configure FIPS 140 compliant cryptography
* providers by using the usual JCA providers configuration mechanism.
*/
@SuppressWarnings("unused")
@TargetClass(value = sun.security.ssl.SunJSSE.class, onlyWith = JDK11OrEarlier.class)
final class Target_sun_security_ssl_SunJSSE {

@Substitute
private Target_sun_security_ssl_SunJSSE(java.security.Provider cryptoProvider, String providerName) {
throw VMError.unsupportedFeature("Experimental FIPS mode in the SunJSSE Provider is deprecated (JDK-8217835)." +
" To register a FIPS provider use the supported java.security.Security.addProvider() API.");
}
}

@TargetClass(className = "sun.security.jca.Providers")
final class Target_sun_security_jca_Providers {
@Alias//
Expand Down
Loading

0 comments on commit c8d7ce0

Please sign in to comment.