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

David Holmes david.holmes at oracle.com
Wed Mar 17 01:09:28 UTC 2021


On 16/03/2021 2:59 pm, David Holmes wrote:
> On 16/03/2021 11:58 am, Sergey Bylokhov wrote:
>> On Sun, 14 Mar 2021 23:34:55 GMT, Henry Jen <henryjen at openjdk.org> wrote:
>>
>>> This patch ensure launcher won't crash JVM for the new static Methods 
>>> from local/anonymous class on MacOS.
>>>
>>> As @dholmes-ora pointed out in the analysis, this is a MacOS specific 
>>> bug when the launcher trying to grab class name to be displayed as 
>>> the Application name on the menu.
>>>
>>> The fix is to not setting name, test shows that GUI java application 
>>> shows 'bin' as the application name. It's possible for us to set the 
>>> name to something more friendly, for example, "Java", but I am not 
>>> sure that should be launcher's responsibility to choose such a 
>>> default name. It seems to me the consumer of the JAVA_MAIN_CLASS_%d 
>>> environment variable should be responsible to pick such name in case 
>>> the environment variable is not set.
>>
>> This bug is similar to 
>> https://bugs.openjdk.java.net/browse/JDK-8076264, and the fix looks fine.
> 
> Both issues involve a problem trying to use the canonical name, but I'd 
> consider both fixes deficient when an alternative name could be used. 

Except I overlooked that this is an anonymous class so no simple name 
either. I agree with Henry's later proposal - fix the crash simply then 
outlaw the usecase later.

Cheers,
David

> But this isn't my code so ...
> 
> David
> 
>> -------------
>>
>> PR: https://git.openjdk.java.net/jdk/pull/2999
>>


More information about the hotspot-runtime-dev mailing list