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

Christian Stein cstein at openjdk.org
Thu Nov 13 16:01:22 UTC 2025


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);
}

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

Commit messages:
 - 8371470: Java Launcher does not fail when running compact java-file with private no-arg constructor

Changes: https://git.openjdk.org/jdk/pull/28291/files
  Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=28291&range=00
  Issue: https://bugs.openjdk.org/browse/JDK-8371470
  Stats: 37 lines in 3 files changed: 34 ins; 1 del; 2 mod
  Patch: https://git.openjdk.org/jdk/pull/28291.diff
  Fetch: git fetch https://git.openjdk.org/jdk.git pull/28291/head:pull/28291

PR: https://git.openjdk.org/jdk/pull/28291


More information about the compiler-dev mailing list