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

Maurizio Cimadamore maurizio.cimadamore at oracle.com
Wed Feb 21 18:05:37 UTC 2018


Looks good - I'm mildly worried that attributing things inside a class 
w/o supertype might lead to issues - but as we chatted offline, that 
doesn't seem to be the case, so I'm approving.

Cheers
Maurizio


On 09/02/18 09:31, Jan Lahoda wrote:
> Hi,
>
> For certain classes -XDfind=lambda will crash javac (please see the 
> bug for details):
> ---
> public class AnonymousInAnonymous {
>     static void s(I1 i) {}
>     static {
>         s(
>             new I1() {
>                 public I2 get() {
>                     return new I2() {
>                     };
>                 }
>             });
>     }
>     public static interface I1 {
>         public static class I2 { }
>         public I2 get();
>     }
> }
> ---
>
> 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. 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. One of the changes to do that also removes 
> follow up errors that appear to be unnecessary (an error has already 
> been reported to the anonymous class' "clazz", so unnecessary to 
> report errors that relate to the anonymous class' constructor).
>
> Bug: https://bugs.openjdk.java.net/browse/JDK-8197439
> Webrev: http://cr.openjdk.java.net/~jlahoda/8197439/webrev.00/
>
> How does this look?
>
> Thanks,
>     Jan



More information about the compiler-dev mailing list