-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
IllegalArgumentException: Cannot create Method for class initializer #1320
Comments
Adding this patch seems to make no difference: diff --git a/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/cenum/CEnumCallWrapperSubstitutionProcessor.java b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/cenum/CEnumCallWrapperSubstitutionProcessor.java
index b39351e464f..777a139e53f 100644
--- a/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/cenum/CEnumCallWrapperSubstitutionProcessor.java
+++ b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/cenum/CEnumCallWrapperSubstitutionProcessor.java
@@ -51,8 +51,8 @@ public class CEnumCallWrapperSubstitutionProcessor extends SubstitutionProcessor
@Override
public ResolvedJavaMethod lookup(ResolvedJavaMethod method) {
- if (GuardedAnnotationAccess.isAnnotationPresent(method, CEnumLookup.class) ||
- GuardedAnnotationAccess.isAnnotationPresent(method, CEnumValue.class)) {
+ if (! method.getName().contains("<clinit>") && (GuardedAnnotationAccess.isAnnotationPresent(method, CEnumLookup.class) ||
+ GuardedAnnotationAccess.isAnnotationPresent(method, CEnumValue.class))) {
return callWrappers.computeIfAbsent(method, v -> new CEnumCallWrapperMethod(nativeLibraries, v));
} else {
return method; Whether or not it's correct, I don't know. Maybe we're registering some reflection class wrongly? |
I also tried this (which didn't work): diff --git a/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/cenum/CEnumCallWrapperSubstitutionProcessor.java b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/cenum/CEnumCallWrapperSubstitutionProcessor.java
index b39351e464f..7423644ef5c 100644
--- a/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/cenum/CEnumCallWrapperSubstitutionProcessor.java
+++ b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/cenum/CEnumCallWrapperSubstitutionProcessor.java
@@ -51,8 +51,8 @@ public class CEnumCallWrapperSubstitutionProcessor extends SubstitutionProcessor
@Override
public ResolvedJavaMethod lookup(ResolvedJavaMethod method) {
- if (GuardedAnnotationAccess.isAnnotationPresent(method, CEnumLookup.class) ||
- GuardedAnnotationAccess.isAnnotationPresent(method, CEnumValue.class)) {
+ if (! method.isClassInitializer() && (GuardedAnnotationAccess.isAnnotationPresent(method, CEnumLookup.class) ||
+ GuardedAnnotationAccess.isAnnotationPresent(method, CEnumValue.class))) {
return callWrappers.computeIfAbsent(method, v -> new CEnumCallWrapperMethod(nativeLibraries, v));
} else {
return method; I'll have to do some more debugging to see what it's trying to do. |
OK looks like there are two spots that need patching: diff --git a/substratevm/src/com.oracle.graal.pointsto/src/com/oracle/graal/pointsto/meta/AnalysisUniverse.java b/substratevm/src/com.oracle.graal.pointsto/src/com/oracle/graal/pointsto/meta/AnalysisUniverse.java
index 445fb7225a1..d0707e0867e 100644
--- a/substratevm/src/com.oracle.graal.pointsto/src/com/oracle/graal/pointsto/meta/AnalysisUniverse.java
+++ b/substratevm/src/com.oracle.graal.pointsto/src/com/oracle/graal/pointsto/meta/AnalysisUniverse.java
@@ -401,7 +401,7 @@ public class AnalysisUniverse implements Universe {
}
private AnalysisMethod createMethod(ResolvedJavaMethod method) {
- if (!platformSupported(method)) {
+ if (!method.isClassInitializer() && !platformSupported(method)) {
throw new UnsupportedFeatureException("Method " + method.format("%H.%n(%p)" + " is not available in this platform."));
}
if (sealed) {
diff --git a/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/cenum/CEnumCallWrapperSubstitutionProcessor.java b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/cenum/CEnumCallWrapperSubstitutionProcessor.java
index b39351e464f..eb3382c55b7 100644
--- a/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/cenum/CEnumCallWrapperSubstitutionProcessor.java
+++ b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/cenum/CEnumCallWrapperSubstitutionProcessor.java
@@ -51,8 +51,8 @@ public class CEnumCallWrapperSubstitutionProcessor extends SubstitutionProcessor
@Override
public ResolvedJavaMethod lookup(ResolvedJavaMethod method) {
- if (GuardedAnnotationAccess.isAnnotationPresent(method, CEnumLookup.class) ||
- GuardedAnnotationAccess.isAnnotationPresent(method, CEnumValue.class)) {
+ if (!method.isClassInitializer() && (GuardedAnnotationAccess.isAnnotationPresent(method, CEnumLookup.class) ||
+ GuardedAnnotationAccess.isAnnotationPresent(method, CEnumValue.class))) {
return callWrappers.computeIfAbsent(method, v -> new CEnumCallWrapperMethod(nativeLibraries, v));
} else {
return method; Maybe this is due to a JVMCI update or something? But with these two patches I don't get the error anymore. |
I'll make this into a PR though, maybe it's not wrong. |
Created #1321. |
Ping @cstancu - this is a problem for Quarkus; is there any chance the PR could make it in to a 19 release? |
@dmlloyd Can you share some more details about this class initializer: Is this a class initializer that has an annotation? I don't think that is even possible to do in regular Java code. And in manually crafted bytecode, why would you put an annotation on it when there is no way to ever access this annotation (since you cannot get a |
It is crafted bytecode, but it is not annotated as far as I can tell (tooling might be hiding something though; I'll have to dig into the raw bytes to be certain). My impression was that the exception occurs simply when asked to look for annotations on a class initializer though. The output of
Whether or not that makes a difference, I do not know. It didn't before today at any rate. |
The JVMCI code has the following check before going to the
For all class initializers that we have seen so far, that check was sufficient. |
The JVM specification doesn't seem to forbid it, and it has worked for many years against every major JVM, so I'd still be inclined to say it's a bug, though whether it's a JVMCI bug or a GraalVM bug I don't know. |
OK. We are going to fix this on the JVMCI level. |
Fix is merged: graalvm/graal-jvmci-8@2749403 Will be a bit though before we make the next release of a JVMCI JDK. The plan is also to backport to the 19 release branch. |
Great, thanks. |
@dmlloyd We are backporting this for the 19.0.1 update. Are there any other blockers on your side we should prioritize? |
Here's the error:
To dig into this I attached a debugger. It looks like we're getting to here (
com/oracle/graal/pointsto/meta/AnalysisType.java:964
):The
wrapped.getClassInitializer()
is returning a method whosetoString
isHotSpotMethod<HttpRequestParser$$generated.<clinit>()>
, which seems to make sense. Later in the stack the recursivelookup
s arrive atcom.oracle.svm.hosted.cenum.CEnumCallWrapperSubstitutionProcessor#lookup
which tries to find annotations on the method, but the method is<clinit>
so presumably that's not going to work out well.The text was updated successfully, but these errors were encountered: