On Tue, 22 Apr 2025 08:34:36 GMT, Alan Bateman <al...@openjdk.org> wrote:
>> Jan Lahoda has updated the pull request incrementally with one additional >> commit since the last revision: >> >> Add clause about handling of malformed/unmappable bytes. > > src/java.base/share/classes/jdk/internal/misc/MethodFinder.java line 89: > >> 87: if (mainMethod == null) { >> 88: //if not public method, try to lookup a non-public one >> 89: mainMethod = JLA.findMethod(cls, false, "main", >> String[].class); > > Is there a reason why the first findMethod can't use publicOnly=false? My reason was that when `publicOnly=false`, there's more classloading happening (unsurprisingly, as also the non-public methods must be resolved). Which may lead to a change of behavior if the traditional `public static main(String[])` exists. IIRC there is a test relying on this behavior, but I don't have the name offhand. Will put it here when I have it. For example: $ cat Main.java public class Main { public static void main(String... args) { System.err.println("Hello!"); } private Missing get() { return null; } } $ cat Missing.java public class Missing { } $ jdk-24/bin/javac Main.java Missing.java; rm Missing.class $ jdk-24/bin/java -classpath . Main Hello! $ jdk-without-publicOnly=true/bin/java -classpath . Main Error: Unable to initialize main class Main Caused by: java.lang.NoClassDefFoundError: Missing ------------- PR Review Comment: https://git.openjdk.org/jdk/pull/24438#discussion_r2053808119