constant references in enums

Alex Buckley alex.buckley at
Wed Jan 27 23:12:37 UTC 2016

On 1/22/2016 2:38 PM, Alex Buckley wrote:
> As to readability of the spec, an enum constants like FOOE(FOOV) has
> always been specified by translation to a public static final field. JSR
> 201 said "Each such field is initialized to the enum constant that
> corresponds to it." I sharpened this very slightly in JLS8 to "The field
> has a variable initializer consisting of c [c is the enum constant]" but
> I recall not wanting to commit to "The field has a variable initializer
> consisting of 'new E(/c_arglist/)'." because compilers don't need to
> agree on the signature of an enum constructor. (See the related note in
> 8.9.2.)
> As such, your complaint that the JLS doesn't specify the class variable
> initializer for FOOE well enough to predict the meaning of FOOV is
> valid. A possible fix is to have 8.9.3 reiterate the useful info from
> 8.9.1: "An enum constant may be followed by arguments, which are passed
> to the constructor of the enum when the constant is created during class
> initialization as described later in this section."


More information about the compiler-dev mailing list