Records (preview): Why aren't accessor methods generated as final?

Brian Goetz brian.goetz at oracle.com
Fri Apr 24 21:41:58 UTC 2020


> FYI, this is called an "explicit declaration" in the JEP: 
> https://openjdk.java.net/jeps/359#Explicitly-declaring-members-of-a-record 
> - it's not really related to final, because the explicit declaration 
> happens in the same class, not a different one.

Also, we struggled with this terminology; this could be "explicit 
declaration", or it could be "override" (as if the default 
implementation came from some magical invisible superclass, which maybe 
could even be accessed with "super.m()").  In the end, we concluded that 
the language spec wanted to treat it separately from overriding, but 
that asking users to keep track of two separate terms, with two separate 
annotations for "hey, this is deliberately providing a new 
implementation of an existing thing" -- seemed like needless 
specificity, and so you can use @Override on them.  Because everyone 
will know what that means!

So it doesn't bother me that people call it "overide", even though the 
spec has a fussier name for it.


More information about the amber-dev mailing list