Skip to content

Commit

Permalink
svm: adopt "JDK-8315458 Implement JEP 463: Implicitly Declared Classe…
Browse files Browse the repository at this point in the history
…s and Instance Main Method (Second Preview)"
  • Loading branch information
zapster committed Dec 11, 2023
1 parent 892990c commit 55d9e08
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,6 @@
import java.util.Optional;
import java.util.StringJoiner;

import com.oracle.svm.core.jdk.JDK21OrEarlier;
import org.graalvm.nativeimage.AnnotationAccess;
import org.graalvm.nativeimage.ImageSingletons;
import org.graalvm.nativeimage.Platform;
Expand Down Expand Up @@ -101,6 +100,7 @@
import com.oracle.svm.core.config.ObjectLayout;
import com.oracle.svm.core.heap.UnknownObjectField;
import com.oracle.svm.core.heap.UnknownPrimitiveField;
import com.oracle.svm.core.jdk.JDK21OrEarlier;
import com.oracle.svm.core.jdk.JDK22OrLater;
import com.oracle.svm.core.jdk.Resources;
import com.oracle.svm.core.meta.SharedType;
Expand Down Expand Up @@ -1750,6 +1750,10 @@ private Class<?>[] getPermittedSubclasses0() {
@KeepOriginal
private native GenericsFactory getFactory();

@KeepOriginal
@TargetElement(onlyWith = JDK22OrLater.class)
native Method findMethod(boolean publicOnly, String name, Class<?>... parameterTypes);

@KeepOriginal
private native Method getMethod0(String methodName, Class<?>[] parameterTypes);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@
import com.oracle.svm.util.ReflectionUtil.ReflectionUtilError;

import jdk.graal.compiler.options.OptionValues;
import jdk.graal.compiler.serviceprovider.JavaVersionUtil;
import jdk.vm.ci.aarch64.AArch64;
import jdk.vm.ci.amd64.AMD64;
import jdk.vm.ci.code.Architecture;
Expand Down Expand Up @@ -472,7 +473,8 @@ private int buildImage(ImageClassLoader classLoader) {
*
* MainMethodFinder will perform all the necessary checks
*/
Class<?> mainMethodFinder = ReflectionUtil.lookupClass(false, "jdk.internal.misc.MainMethodFinder");
String mainMethodFinderClassName = JavaVersionUtil.JAVA_SPEC >= 22 ? "jdk.internal.misc.MethodFinder" : "jdk.internal.misc.MainMethodFinder";
Class<?> mainMethodFinder = ReflectionUtil.lookupClass(false, mainMethodFinderClassName);
Method findMainMethod = ReflectionUtil.lookupMethod(mainMethodFinder, "findMainMethod", Class.class);
javaMainMethod = (Method) findMainMethod.invoke(null, mainClass);
} catch (InvocationTargetException ex) {
Expand Down

0 comments on commit 55d9e08

Please sign in to comment.