Unnamed classes (was: Paving the on-ramp)

Brian Goetz brian.goetz at oracle.com
Thu Oct 20 17:04:03 UTC 2022


> Yeah, I’m getting there too after pulling on a string I liked more at first than I do now.  Thanks Dan.
>
> Next question:  If we are embracing accidental names, what are the rules for the name-precursors?  Can we extract an accidental name from any possible file name in any possible file system?  Or are there restrictions on the file names?  Since this is a pedagogical feature, I suppose we require the “.java” suffix always, despite the inevitable requests for shebang script support.

A class name must conform to various constraints, such as matching the 
"Identifier"production; the compiler should demand the same of the 
implicit name.

The compiler currently enforces matching of the class name to the file 
name (for public classes); we can enforce the same on the (implicit 
name, file name) pair.

These mean that if you want to add the `class Foo { .. }` wrapper, you 
won't run into accidental problems.  (I spy an embedding-projection 
pair; stay within the embeddable domain.)


More information about the amber-spec-observers mailing list