ADDITIONAL SYSTEM INFORMATION :
Tested on Windows 10 but suspect it's OS independent.
openjdk 20.0.2 2023-07-18
OpenJDK Runtime Environment (build 20.0.2+9-78)
OpenJDK 64-Bit Server VM (build 20.0.2+9-78, mixed mode, sharing)
OpenJFX 20.0.2 (don't believe JavaFX version is important)
A DESCRIPTION OF THE PROBLEM :
When using the "JEP 330: Launch Single-File Source-Code Programs" feature and the following is true:
* The main class extends 'javafx.application.Application'
* A 'public static void main(String[])' method is present that calls 'javafx.application.Application.launch(Class,String...)'
* The call to 'javafx.application.Application.launch(Class,String...)' throws an exception
Then the exception thrown by 'launch' will be hidden behind an 'IllegalArgumentException' thrown by the 'jdk.compiler' module. This is said 'IllegalArgumentException':
Exception in thread "main" java.lang.IllegalArgumentException: 0 > -2
at java.base/java.util.Arrays.copyOfRange(Arrays.java:3782)
at java.base/java.util.Arrays.copyOfRange(Arrays.java:3742)
at jdk.compiler/com.sun.tools.javac.launcher.Main.execute(Main.java:447)
at jdk.compiler/com.sun.tools.javac.launcher.Main.run(Main.java:205)
at jdk.compiler/com.sun.tools.javac.launcher.Main.main(Main.java:132)
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
1. Have JavaFX available on the module-path
2. Execute 'java Main.java' or 'java -p <path-to-fx> --add-modules javafx.graphics Main.java'
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
The stack trace of the exception thrown by `javafx.application.Application.launch` is printed to the console. From the minimal example provided, something like the following is expected (using JavaFX 20.0.2):
Exception in Application start method
java.lang.RuntimeException: Exception in Application start method
at javafx.graphics@20.0.2/com.sun.javafx.application.LauncherImpl.launchApplication1(LauncherImpl.java:893)
at javafx.graphics@20.0.2/com.sun.javafx.application.LauncherImpl.lambda$launchApplication$2(LauncherImpl.java:195)
at java.base/java.lang.Thread.run(Thread.java:1623)
Caused by: java.lang.RuntimeException: demo
at Main.start(Main.java:8)
at javafx.graphics@20.0.2/com.sun.javafx.application.LauncherImpl.lambda$launchApplication1$9(LauncherImpl.java:839)
at javafx.graphics@20.0.2/com.sun.javafx.application.PlatformImpl.lambda$runAndWait$12(PlatformImpl.java:483)
at javafx.graphics@20.0.2/com.sun.javafx.application.PlatformImpl.lambda$runLater$10(PlatformImpl.java:456)
at java.base/java.security.AccessController.doPrivileged(AccessController.java:400)
at javafx.graphics@20.0.2/com.sun.javafx.application.PlatformImpl.lambda$runLater$11(PlatformImpl.java:455)
at javafx.graphics@20.0.2/com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:95)
at javafx.graphics@20.0.2/com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
at javafx.graphics@20.0.2/com.sun.glass.ui.win.WinApplication.lambda$runLoop$3(WinApplication.java:185)
... 1 more
ACTUAL -
The following is printed instead:
Exception in Application start method
Exception in thread "main" java.lang.IllegalArgumentException: 0 > -2
at java.base/java.util.Arrays.copyOfRange(Arrays.java:3782)
at java.base/java.util.Arrays.copyOfRange(Arrays.java:3742)
at jdk.compiler/com.sun.tools.javac.launcher.Main.execute(Main.java:447)
at jdk.compiler/com.sun.tools.javac.launcher.Main.run(Main.java:205)
at jdk.compiler/com.sun.tools.javac.launcher.Main.main(Main.java:132)
---------- BEGIN SOURCE ----------
import javafx.application.Application;
import javafx.stage.Stage;
public class Main extends Application {
@Override
public void start(Stage primaryStage) {
throw new RuntimeException("demo");
}
public static void main(String[] args) {
Application.launch(Main.class, args);
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
Wrap the call to 'Application.launch' in a try-catch
import javafx.application.Application;
import javafx.stage.Stage;
public class Main extends Application {
@Override
public void start(Stage primaryStage) {
throw new RuntimeException("demo");
}
public static void main(String[] args) {
try {
Application.launch(Main.class, args);
} catch (Throwable t) {
t.printStackTrace();
}
}
}
FREQUENCY : always
Tested on Windows 10 but suspect it's OS independent.
openjdk 20.0.2 2023-07-18
OpenJDK Runtime Environment (build 20.0.2+9-78)
OpenJDK 64-Bit Server VM (build 20.0.2+9-78, mixed mode, sharing)
OpenJFX 20.0.2 (don't believe JavaFX version is important)
A DESCRIPTION OF THE PROBLEM :
When using the "JEP 330: Launch Single-File Source-Code Programs" feature and the following is true:
* The main class extends 'javafx.application.Application'
* A 'public static void main(String[])' method is present that calls 'javafx.application.Application.launch(Class,String...)'
* The call to 'javafx.application.Application.launch(Class,String...)' throws an exception
Then the exception thrown by 'launch' will be hidden behind an 'IllegalArgumentException' thrown by the 'jdk.compiler' module. This is said 'IllegalArgumentException':
Exception in thread "main" java.lang.IllegalArgumentException: 0 > -2
at java.base/java.util.Arrays.copyOfRange(Arrays.java:3782)
at java.base/java.util.Arrays.copyOfRange(Arrays.java:3742)
at jdk.compiler/com.sun.tools.javac.launcher.Main.execute(Main.java:447)
at jdk.compiler/com.sun.tools.javac.launcher.Main.run(Main.java:205)
at jdk.compiler/com.sun.tools.javac.launcher.Main.main(Main.java:132)
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
1. Have JavaFX available on the module-path
2. Execute 'java Main.java' or 'java -p <path-to-fx> --add-modules javafx.graphics Main.java'
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
The stack trace of the exception thrown by `javafx.application.Application.launch` is printed to the console. From the minimal example provided, something like the following is expected (using JavaFX 20.0.2):
Exception in Application start method
java.lang.RuntimeException: Exception in Application start method
at javafx.graphics@20.0.2/com.sun.javafx.application.LauncherImpl.launchApplication1(LauncherImpl.java:893)
at javafx.graphics@20.0.2/com.sun.javafx.application.LauncherImpl.lambda$launchApplication$2(LauncherImpl.java:195)
at java.base/java.lang.Thread.run(Thread.java:1623)
Caused by: java.lang.RuntimeException: demo
at Main.start(Main.java:8)
at javafx.graphics@20.0.2/com.sun.javafx.application.LauncherImpl.lambda$launchApplication1$9(LauncherImpl.java:839)
at javafx.graphics@20.0.2/com.sun.javafx.application.PlatformImpl.lambda$runAndWait$12(PlatformImpl.java:483)
at javafx.graphics@20.0.2/com.sun.javafx.application.PlatformImpl.lambda$runLater$10(PlatformImpl.java:456)
at java.base/java.security.AccessController.doPrivileged(AccessController.java:400)
at javafx.graphics@20.0.2/com.sun.javafx.application.PlatformImpl.lambda$runLater$11(PlatformImpl.java:455)
at javafx.graphics@20.0.2/com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:95)
at javafx.graphics@20.0.2/com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
at javafx.graphics@20.0.2/com.sun.glass.ui.win.WinApplication.lambda$runLoop$3(WinApplication.java:185)
... 1 more
ACTUAL -
The following is printed instead:
Exception in Application start method
Exception in thread "main" java.lang.IllegalArgumentException: 0 > -2
at java.base/java.util.Arrays.copyOfRange(Arrays.java:3782)
at java.base/java.util.Arrays.copyOfRange(Arrays.java:3742)
at jdk.compiler/com.sun.tools.javac.launcher.Main.execute(Main.java:447)
at jdk.compiler/com.sun.tools.javac.launcher.Main.run(Main.java:205)
at jdk.compiler/com.sun.tools.javac.launcher.Main.main(Main.java:132)
---------- BEGIN SOURCE ----------
import javafx.application.Application;
import javafx.stage.Stage;
public class Main extends Application {
@Override
public void start(Stage primaryStage) {
throw new RuntimeException("demo");
}
public static void main(String[] args) {
Application.launch(Main.class, args);
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
Wrap the call to 'Application.launch' in a try-catch
import javafx.application.Application;
import javafx.stage.Stage;
public class Main extends Application {
@Override
public void start(Stage primaryStage) {
throw new RuntimeException("demo");
}
public static void main(String[] args) {
try {
Application.launch(Main.class, args);
} catch (Throwable t) {
t.printStackTrace();
}
}
}
FREQUENCY : always