Review request: update javac to properly output mandated parameters in MethodParameters attributes
Maurizio Cimadamore
maurizio.cimadamore at oracle.com
Thu Feb 7 14:17:16 PST 2013
On 07/02/13 22:06, Alex Buckley wrote:
> On 2/7/2013 12:29 PM, maurizio cimadamore wrote:
>> It would seem that the spec is not defining (on top of my head - there
>> are probably others):
>>
>> *) (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 believe javac's generated enum constructor has an additional
>> parameter accepting the ordinal
>
> We need to be clear what we're talking abut here. For an enum type,
> JLS 8.9.2 has always implicitly declared a default ctor _with no
> formal parameters_ - but that ctor is required to be private, so no
> other compiler can emit code which uses it. I think you're talking not
> about the default ctor, but about an explicitly-declared ctor to which
> javac adds a parameter. In this case, is code from another compiler
> expected to use the parameter to construct the enum instance
> correctly? If yes, then the ordinal parameter should be implicitly
> declared. Please let me know so I can update the JLS.
Here you are sir:
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 {};
}
Maurizio
>
>> In any case, the implementation problem remains: it doesn't distinguish
>> between impl-only parameters and 'implicitly declared' ones. It just
>> takes all parameters that do not have a correspondent in the source code
>> and put them in the same place.
>
> I hope Eric is out there somewhere :-)
>
> Alex
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.openjdk.java.net/pipermail/compiler-dev/attachments/20130207/e4ea5989/attachment.html
More information about the compiler-dev
mailing list