Relates :
|
|
Relates :
|
|
Relates :
|
|
Relates :
|
|
Relates :
|
|
Relates :
|
|
Relates :
|
The following is asserted about anonymous classes: "An anonymous class is always implicitly final (ยง8.1.1.2)." Longstanding behavior of javac, since 1.3, has been, for the most part, *not* to treat the classes as 'final'. To address this inconsistency, the specification should be changed to accurately reflect the reference implementation. Specifically, anonymous classes are almost never generated with the ACC_FINAL flag set. We can't change this longstanding behavior without impacting some serialization clients (this would be permissible, but is unnecessarily disruptive). And we can't faithfully implement Class.getModifers (which promises to provide the "Java language modifiers") without the class files encoding the language's modifiers. Some history: - JDK-4243945 observes a change that stopped setting ACC_FINAL in 1.3 - JDK-4777101 discussed changing the class files back to their 1.2 form, ultimately giving up due to compatibility concerns - JDK-6219964 and JDK-6520152 observed that finality is observable at compile time via a cast, leading to an awkward compromise in which anonymous classes are considered 'final' temporarily during type checking - JDK-8129576 once again observed the inconsistency between JLS 15.9.5 and 'Class.getModifiers' The change impacts the set of legal programs, in that it allows some casts that would be considered illegal under the current specification (see JDK-6219964). But, after searching for mentions of 'final' classes in JLS, I don't anticipate any other impact, meaning that this is a source-compatible fix.
|