Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
import org.graalvm.nativeimage.Platform;
import org.graalvm.nativeimage.Platforms;

import com.oracle.svm.core.annotate.NeverInline;
import com.oracle.svm.core.graal.code.CGlobalDataInfo;
import com.oracle.svm.core.util.ImageHeapMap;

Expand All @@ -50,6 +51,7 @@ public class CGlobalDataNonConstantRegistry {
/**
* Invoked at runtime via com.oracle.svm.hosted.c.CGlobalDataFeature#getCGlobalDataInfoMethod.
*/
@NeverInline("CGlobalDataFeature expects that this call is not inlined")
public CGlobalDataInfo getCGlobalDataInfo(CGlobalDataImpl<?> cGlobalData) {
return cGlobalDataInfos.get(cGlobalData);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,10 @@ public final class Target_java_lang_Thread {
// Checkstyle: stop
@Alias //
static StackTraceElement[] EMPTY_STACK_TRACE;

@Alias //
@TargetElement(onlyWith = JDK19OrLater.class) //
static int NO_INHERIT_THREAD_LOCALS;
// Checkstyle: resume

/** This field is initialized when the thread actually starts executing. */
Expand Down Expand Up @@ -333,9 +337,11 @@ private Target_java_lang_Thread(
/* Injected Target_java_lang_Thread instance field initialization. */
this.threadData = new ThreadData();

// TODO: derive from characteristics bitset
boolean inheritThreadLocals = false;
/* Initialize the rest of the Thread object, ignoring `characteristics`. */
boolean inheritThreadLocals = (characteristics & NO_INHERIT_THREAD_LOCALS) == 0;
/*
* Initialize the rest of the Thread object, ignoring `characteristics` except for inherit
* thread locals.
*/
String nameLocal = (name != null) ? name : genThreadName();
JavaThreads.initializeNewThread(this, g, target, nameLocal, stackSize, acc, inheritThreadLocals);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,13 @@
import org.graalvm.compiler.nodes.java.InstanceOfNode;
import org.graalvm.compiler.nodes.java.LoadFieldNode;
import org.graalvm.compiler.replacements.nodes.MacroNode.MacroParams;
import org.graalvm.compiler.serviceprovider.JavaVersionUtil;
import org.graalvm.nativeimage.hosted.Feature;

import com.oracle.graal.pointsto.constraints.UnsupportedFeatureException;
import com.oracle.graal.pointsto.infrastructure.OriginalClassProvider;
import com.oracle.graal.pointsto.meta.HostedProviders;
import com.oracle.graal.pointsto.util.GraalAccess;
import com.oracle.svm.core.SubstrateAnnotationInvocationHandler;
import com.oracle.svm.core.annotate.AutomaticFeature;
import com.oracle.svm.core.graal.jdk.SubstrateObjectCloneWithExceptionNode;
Expand Down Expand Up @@ -585,12 +588,25 @@ public StructuredGraph buildGraph(DebugContext debug, ResolvedJavaMethod method,
state.initializeForMethodStart(null, true, providers.getGraphBuilderPlugins());
graph.start().setStateAfter(state.create(0, graph.start()));

String returnValue = "@" + annotationInterfaceType.toJavaName(true);
String returnValue;
if (JavaVersionUtil.JAVA_SPEC >= 19) {
/*
* In JDK 19, annotations use Class.getCanonicalName() instead of Class.getName().
* See JDK-8281462.
*/
returnValue = "@" + getJavaClass(annotationInterfaceType).getCanonicalName();
} else {
returnValue = "@" + annotationInterfaceType.toJavaName(true);
}
ValueNode returnConstant = kit.unique(ConstantNode.forConstant(SubstrateObjectConstant.forObject(returnValue), providers.getMetaAccess()));
kit.append(new ReturnNode(returnConstant));

return kit.finalizeGraph();
}

private static Class<?> getJavaClass(ResolvedJavaType type) {
return OriginalClassProvider.getJavaClass(GraalAccess.getOriginalSnippetReflection(), type);
}
}

/*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,16 @@
import java.security.Provider;
import java.security.Security;

import org.graalvm.compiler.serviceprovider.JavaVersionUtil;
import org.graalvm.nativeimage.hosted.Feature;
import org.graalvm.nativeimage.hosted.RuntimeClassInitialization;
import org.graalvm.nativeimage.hosted.RuntimeReflection;
import org.hamcrest.CoreMatchers;
import org.junit.Assert;
import org.junit.Test;

import com.oracle.svm.util.ModuleSupport;
import com.oracle.svm.util.ReflectionUtil;

import sun.security.jca.GetInstance;

/**
Expand All @@ -48,6 +50,8 @@ public void afterRegistration(AfterRegistrationAccess access) {
// register the providers
Security.addProvider(new NoOpProvider());
Security.addProvider(new NoOpProviderTwo());
// open sun.security.jca.GetInstance
ModuleSupport.accessModuleByClass(ModuleSupport.Access.EXPORT, JCACompliantNoOpService.class, ReflectionUtil.lookupClass(false, "sun.security.jca.GetInstance"));
}

@Override
Expand Down Expand Up @@ -81,15 +85,12 @@ public void testUnknownSecurityServices() throws Exception {

@Test
public void testAutomaticSecurityServiceRegistration() {
if (JavaVersionUtil.JAVA_SPEC < 19) {
// Does not work on JDK 19 for yet unknown reasons (GR-39827)
try {
JCACompliantNoOpService service = JCACompliantNoOpService.getInstance("no-op-algo-two");
Assert.assertNotNull("No service instance was created", service);
Assert.assertThat("Unexpected service implementtation class", service, CoreMatchers.instanceOf(JcaCompliantNoOpServiceImpl.class));
} catch (NoSuchAlgorithmException e) {
Assert.fail("Failed to fetch noop service with exception: " + e);
}
try {
JCACompliantNoOpService service = JCACompliantNoOpService.getInstance("no-op-algo-two");
Assert.assertNotNull("No service instance was created", service);
Assert.assertThat("Unexpected service implementation class", service, CoreMatchers.instanceOf(JcaCompliantNoOpServiceImpl.class));
} catch (NoSuchAlgorithmException e) {
Assert.fail("Failed to fetch noop service with exception: " + e);
}
}

Expand Down