On 01/12/2026 16:12, Pavel Rappo wrote:
There have been reports (e.g. [^1]) that in some runtime images java
cannot run source files. Here's another scenario.

If a source file is run by the java command from a jlink-built runtime
image that doesn't include jdk.compiler, the output will read:

     ./java X.java
     Error: A JNI error has occurred, please check your installation
and try again
     Exception in thread "main" java.lang.InternalError: Module
jdk.compiler not in boot Layer
       at 
java.base/sun.launcher.LauncherHelper.loadModuleMainClass(LauncherHelper.java:807)
       at 
java.base/sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:757)

I accept that the inability to run a source file is not exactly
unexpected in such circumstances. However, the usage output for the
java command suggests that this capability is __integral__:

     Usage: java [java options...] <application> [application arguments...]

     Where <application> is one of:
       <mainclass>                to execute the main method of a
compiled main class
       -jar <jarfile>.jar         to execute the main class of a JAR archive
       -m <module>[/<mainclass>]  to execute the main class of a module
       <sourcefile>.java          to compile and execute a source-file program

Can you create a bug for this? And if you have cycles, can you see if changing ParseArguments (in java.c) to add --add-modules=jdk.compiler when the mode is LM_SOURCE (you'll see it adds ALL-DEFAULT already). That would at least give you an error that the jdk.compiler is not found. We can do better than that but try that first. Making part of the usage message conditional would require further work of course.

-Alan

Reply via email to