Towards cleaner nesting

Brian Goetz brian.goetz at oracle.com
Thu Jan 9 16:03:31 UTC 2020



> FWIW, I think it's helpful for case analysis to flatten the list of things that can be nested/contain nested things as follows:
> - top-level/static classes
> - inner classes* (I always forget whether this includes local classes, but turns out it does)
> - interfaces
> - records
> - enums
> - annotation types
> - static methods/initializers
> - instance methods/local methods/constructors/instance initializers*
>
> The proposal is that each one of these can be nested in any of these.

Of course, some of these don't make sense, such as "constructors in 
field initializers", so it's not quite as simple as that, but yes, we 
should seek to bust the _gratuitous_ restrictions.

> Annotation types currently have some restrictions on methods that probably ought to be relaxed for uniformity?
Not sure "for uniformity" is a good enough reason; for example, we don't 
allow default methods in annotations, and I don't see this as being a 
"gratuitous" restriction.  But, since annotations are interfaces, then 
we should probably allow them in all the nested positions where we allow 
interfaces (and like interfaces, they should always be implicitly static.)




More information about the amber-spec-experts mailing list