-
Bug
-
Resolution: Fixed
-
P4
-
None
-
b02
-
generic
-
generic
Below code throws exception when run with -XDfind=lambda at compile time.
public class AnalyzerNotCopyingTest {
public static void main(String... args) {
new AnalyzerNotCopyingTest().run();
}
private void run() {
Base b = new Base() {
public void run() {
test(this);
}
};
b.run();
}
private static void test(AnalyzerNotCopyingTest t) {
throw new AssertionError("Should not be invoked!");
}
private static void test(Base b) {
//ok to invoke
}
public static interface Base {
public abstract void run();
}
}
javac -XDfind=lambda AnalyzerNotCopyingTest.java
java AnalyzerNotCopyingTest
Exception in thread "main" java.lang.NoSuchFieldError: this
at AnalyzerNotCopyingTest$1.run(AnalyzerNotCopyingTest.java:16)
at AnalyzerNotCopyingTest.run(AnalyzerNotCopyingTest.java:19)
at AnalyzerNotCopyingTest.main(AnalyzerNotCopyingTest.java:10)
This happens mainly because the lambda analyzer reattributes the live AST for "test(this)" .
public class AnalyzerNotCopyingTest {
public static void main(String... args) {
new AnalyzerNotCopyingTest().run();
}
private void run() {
Base b = new Base() {
public void run() {
test(this);
}
};
b.run();
}
private static void test(AnalyzerNotCopyingTest t) {
throw new AssertionError("Should not be invoked!");
}
private static void test(Base b) {
//ok to invoke
}
public static interface Base {
public abstract void run();
}
}
javac -XDfind=lambda AnalyzerNotCopyingTest.java
java AnalyzerNotCopyingTest
Exception in thread "main" java.lang.NoSuchFieldError: this
at AnalyzerNotCopyingTest$1.run(AnalyzerNotCopyingTest.java:16)
at AnalyzerNotCopyingTest.run(AnalyzerNotCopyingTest.java:19)
at AnalyzerNotCopyingTest.main(AnalyzerNotCopyingTest.java:10)
This happens mainly because the lambda analyzer reattributes the live AST for "test(this)" .
- relates to
-
JDK-8198504 Revisit Analyzer class and related test infrastructure to better handle reattribution of live AST kind of issue
- Closed