RFR : JDK-8197439,,Crash with -XDfind=lambda for anonymous class in anonymous class.
Jan Lahoda
jan.lahoda at oracle.com
Fri Feb 9 09:31:38 UTC 2018
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