RFR: 8362237: IllegalArgumentException in the launcher when exception without stack trace is thrown

ExE Boss duke at openjdk.org
Tue Jul 15 21:48:41 UTC 2025


On Tue, 15 Jul 2025 12:20:43 GMT, Christian Stein <cstein at openjdk.org> wrote:

> Please review this change introducing a range check before pruning
> stacktrace elements in source launch mode. An additional `null`-check
> was also added to this change set.

src/jdk.compiler/share/classes/com/sun/tools/javac/launcher/SourceLauncher.java line 266:

> 264:             Throwable cause = exception.getCause();
> 265:             if (cause == null) throw exception;
> 266:             StackTraceElement[] elements = cause.getStackTrace();

Note that `Throwable​::getStackTrace()` is not `final`, so it can be made to return `null` by overriding.
Suggestion:

            StackTraceElement[] elements = cause.getStackTrace();
            if (elements == null) throw exception;

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

PR Review Comment: https://git.openjdk.org/jdk/pull/26315#discussion_r2208772126


More information about the compiler-dev mailing list