Review request: update javac to properly output mandated parameters in MethodParameters attributes

Alex Buckley alex.buckley at oracle.com
Thu Feb 7 14:41:03 PST 2013


On 2/7/2013 2:17 PM, Maurizio Cimadamore wrote:
>>> *) (effectively) final variables passed in to inner classes (javac only
>>> does that for reference-types as others are just constants that can be
>>> produced on the stack at will)
>>
>> Right. The JLS does not say that those ctor parameters are implicitly
>> declared. javac should mark them with ACC_SYNTHETIC.
> So that we are clear - javac is already marking all this stuff I'm
> saying as ACC_SYNTHETIC. But Eric's code is implicitly tagging it as
> ACC_MANDATED too, which is where I think the problem lies.

I had not thought of a class file construct being marked as both. I 
should disallow that in the JVMS; however, enforcement would be the 
responsibility of core reflection. I have a feeling that 
Parameter.isSynthetic() is never really going to throw an exception just 
because ACC_MANDATED is set. Similarly for isMandated() and 
ACC_SYNTHETIC. So, I will not disallow it in the JVMS. If you can't 
trust a Java compiler, who can you trust?

>>> *) I believe javac's generated enum constructor has an additional
>>> parameter accepting the ordinal
>
> enum Test {
>      FOO { },
>      BAR { };
> }
>
> javap -p Test
>
> Compiled from "Test.java"
> class Test extends java.lang.Enum<Test> {
>    public static final Test FOO;
>    public static final Test BAR;
>    public static Test[] values();
>    public static Test valueOf(java.lang.String);
>    Test(java.lang.String, *int*, Test$1);
>    static {};
> }
>
> And also,
>
> enum Test {
>      Test() { }
> }
>
> that generates:
>
> Compiled from "Test.java"
> class Test extends java.lang.Enum<Test> {
>    public static final Test Test;
>    public static Test[] values();
>    public static Test valueOf(java.lang.String);
>    Test(java.lang.String, *int*, Test$1);
>    static {};
> }

Thanks for this. Since the compiler processing the expression "Test.FOO" 
could be different to the compiler which emitted Test.class, there must 
be a standard way for the Test.FOO compiler to indicate which Test 
constant ought to be instantiated. I will consult with Eclipse ASAP. I 
expect both the String and int parameters will end up as implicitly 
declared.

Alex



More information about the compiler-dev mailing list