Skip to content

Commit

Permalink
Use own lookupMethod to avoid dependency on internal GraalVM API
Browse files Browse the repository at this point in the history
  • Loading branch information
zakkak committed Sep 2, 2022
1 parent b9ba708 commit df10660
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 2 deletions.
4 changes: 4 additions & 0 deletions core/deployment/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,10 @@
<version>${project.version}</version>
</path>
</annotationProcessorPaths>
<compilerArgs>
<arg>--add-exports</arg>
<arg>java.base/jdk.internal.module=ALL-UNNAMED</arg>
</compilerArgs>
</configuration>
</plugin>
</plugins>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
import io.quarkus.runtime.ResourceHelper;
import io.quarkus.runtime.graal.ResourcesFeature;
import io.quarkus.runtime.graal.WeakReflection;
import jdk.internal.module.Modules;

public class NativeImageFeatureStep {

Expand Down Expand Up @@ -82,7 +83,7 @@ public class NativeImageFeatureStep {
String.class);

private static final MethodDescriptor LOOKUP_METHOD = ofMethod(
"com.oracle.svm.util.ReflectionUtil",
NativeImageFeatureStep.class,
"lookupMethod", Method.class, Class.class, String.class, Class[].class);
private static final MethodDescriptor FOR_NAME = ofMethod(
Class.class, "forName", Class.class, String.class, boolean.class, ClassLoader.class);
Expand Down Expand Up @@ -688,4 +689,18 @@ private ReflectionInfo(boolean constructors, boolean methods, boolean fields, bo
}
}

private static Method lookupMethod(Class<?> declaringClass, String methodName, Class<?>... parameterTypes)
throws NoSuchMethodException {
Method result = declaringClass.getDeclaredMethod(methodName, parameterTypes);
Module declaringModule = declaringClass.getModule();
String packageName = declaringClass.getPackageName();

if (declaringModule.isOpen(packageName)) {
Modules.addOpensToAllUnnamed(declaringModule, packageName);
}

result.setAccessible(true);
return result;
}

}
1 change: 0 additions & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@
<properties>
<maven.compiler.target>11</maven.compiler.target>
<maven.compiler.source>11</maven.compiler.source>
<maven.compiler.release>11</maven.compiler.release>
<maven.compiler.parameters>true</maven.compiler.parameters>

<graalvmHome>${env.GRAALVM_HOME}</graalvmHome>
Expand Down

0 comments on commit df10660

Please sign in to comment.