Retrofitting classes as records in the JDK

Brian Goetz brian.goetz at oracle.com
Tue Feb 25 14:24:23 UTC 2020




> However, this brings up a question: can the visibility of an accessor 
> method be changed or the method removed? Looking at the specs I found 
> [1], it seems that the answer is no, but it's not that clear to me:

The method cannot be removed.  Under the current spec, it _must_ be 
public.  Under the spec current in revision, the rule will be relaxed 
that it has the same accessibility as the class, but can be made _more_ 
accessible, but not less.  It is part of the API; removing it / hiding 
it would violate this.

You can implement it to through UOE, but in that case, you should 
question whether you should be using records in the first place.


More information about the amber-dev mailing list