RFR : JDK-8197439, , Crash with -XDfind=lambda for anonymous class in anonymous class.

Jan Lahoda jan.lahoda at oracle.com
Tue Feb 20 14:11:34 UTC 2018


On 20.2.2018 10:29, Srikanth wrote:
>
>
> On Friday 09 February 2018 03:01 PM, Jan Lahoda wrote:
>> Hi,
>>
>> For certain classes -XDfind=lambda will crash javac (please see the
>> bug for details):
>>
> [...]
>
>> ---
>>
>> The reason is that:
>> - -XDfind=lambda will try to replace "new I1() {...}" with a lambda
>> and attribute that
>> -but this will make I2 unresolvable
>> -so Attr.visitNewClass will not (currently) attribute the inside of
>> the "new I2() {}".
>> -so Attr.PostAttrAnalyzer will try to fill in Symbols and Types, but
>> "Attr.PostAttrAnalyzer.dummyMethodType" will dereference
>> MethodTree.restype, which is null for constructors (in this case an
>> automatically generated constructor).
>>
>> A part of the proposed fix is to enhance
>> PostAttrAnalyzer.dummyMethodType to handle constructors.
>
> This part looks good.
>
>> But attributing the body of an unresolvable anonymous class does not
>> seem difficult, and would help API clients like JShell, so the
>> proposed fix is doing that as well.
>
> Not being a regular user of jshell, I am not able to form an assessment
> as to how important this is - my lay person's opinion is that it is not,
> but I will defer to your judgment. But the relevant changes in Attr look
> reasonable.

I think it is nicer for the users of the API to have the anonymous 
classes attributed, even if it may not be very important.

>
> AnonymousInAnonymous.java:
>
> (1) FWIW, it may be a better idea to capture the diagnostic issued by
> XDfind=lambda and prepare a golden file ??

Oops, yes, done.

> (2) @module directive unnecessary here ?

Not really sure, removed.

Updated webrev:
http://cr.openjdk.java.net/~jlahoda/8197439/webrev.01/

Thanks for the comments so far!

Jan

>
> Overall, I am fine with this patch,
>
> Sorry for the delayed response,
> Thanks!
> Srikanth
>
>
>


More information about the compiler-dev mailing list