RFR: 8261785: Calling "main" method in anonymous nested class crashes the JVM

Alan Bateman alanb at openjdk.java.net
Tue Mar 16 15:36:08 UTC 2021


On Tue, 16 Mar 2021 07:43:54 GMT, Sergey Bylokhov <serb at openjdk.org> wrote:

>> This bug is similar to https://bugs.openjdk.java.net/browse/JDK-8076264, and the fix looks fine.
>
>> Maybe the AWT folk should decide what name should be displayed in this
>> case. The canonical name was chosen when all main classes had to have a
>> canonical name. So perhaps a simple name will suffice in the case where
>> there is no canonical name?
> 
> This is not the last attempt to set the name, the JAVA_MAIN_CLASS_ variable is used in the middle of the name selection, there are some others. And the "bin" is selected by some of the next step, I agree it is not a friendly name that could be improved.

Using an anonymous class for the main class looks strange and hard to believe anyone is relying on this.  I wonder if we should do more checking LauncherHelper.validateMainClass to reject cases like this.

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

PR: https://git.openjdk.java.net/jdk/pull/2999


More information about the hotspot-runtime-dev mailing list