RFR: 8371470: Java Launcher does not fail when running compact java-file with private no-arg constructor [v2]

Ana Maria Mihalceanu duke at openjdk.org
Fri Nov 14 07:02:06 UTC 2025


On Thu, 13 Nov 2025 16:20:38 GMT, Christian Stein <cstein at openjdk.org> wrote:

>> Please review this change to synchronize the behaviour in `java`'s source launch mode to fail when a non-arg constructor with `private` access modifier is defined - like it does in class launch mode.
>> 
>> Find the prior-art check performed in class launch mode at [LauncherHelper.java#L958-L961](https://github.com/openjdk/jdk/blob/8102f436f5586253302cd8cef49bfe2b4af41693/src/java.base/share/classes/sun/launcher/LauncherHelper.java#L958-L961):
>> 
>> 
>> Constructor<?> constructor = mainClass.getDeclaredConstructor();
>> if (Modifier.isPrivate(constructor.getModifiers())) {
>>     abort(null, "java.launcher.cls.error6", className);
>> }
>
> Christian Stein has updated the pull request incrementally with one additional commit since the last revision:
> 
>   Remove unused method

Thank you for solving this issue, Christian 🙏 . While not directly related to the core issue of this bug, could you also please check my comment?

src/jdk.compiler/share/classes/com/sun/tools/javac/resources/launcher.properties line 125:

> 123: # 0: string
> 124: launcher.err.cant.find.constructor=\
> 125:     can''t find no argument constructor in class: {0}

This is a nitpick, but I noticed the double `'` in the message above. 

Suggestion:

    can't find no argument constructor in class: {0}

-------------

PR Review: https://git.openjdk.org/jdk/pull/28291#pullrequestreview-3463106346
PR Review Comment: https://git.openjdk.org/jdk/pull/28291#discussion_r2526025421


More information about the compiler-dev mailing list