Relates :
|
|
Relates :
|
|
Relates :
|
|
Relates :
|
Per JDK-8161009, an assertion in JLS that anonymous classes are 'final' is incorrect, due to inconsistency with longstanding behavior. Anonymous classes should not be considered 'final'. javac generally does not do so, but there are two bugs: - In an attempt to conform to the old JLS without fully doing so, JDK-6219964 and JDK-6520152 set the 'final' flag during checking, then unset it. Wanted behavior is to simply leave it unset. - The logic to unset ACC_FINAL during code gen accidentally leaves it set on 'access_flags' (but not 'inner_class_access_flags') for anonymous classes in static contexts. Example of the first bug: interface I {} Object o = new Object() { I i = (I) this; // expected: ok; actual: cast error }; Example of the second bug: class C { static Object o = new Object() {}; } javac C.java javap -verbose C\$1 final class C$1 <--- expected: not 'final' minor version: 0 major version: 52 flags: ACC_FINAL, ACC_SUPER <--- expected: not ACC_FINAL ... InnerClasses: static #2; //class C$1 <--- as expected: not 'final'
|