Generation of synthesized parameters

Eric McCorkle eric.mccorkle at
Wed Jan 30 11:57:14 PST 2013

On 01/29/13 20:14, Alex Buckley wrote:
> I have been looking into the JLS treatment of the constructs mentioned
> below, with an eye to clarifying matters in JLS8.
> I think a construct emitted by javac should be marked as synthesized if
> it corresponds to a construct declared implicitly in source code.
> Constructs declared implicitly in source code are:
> - default constructors (8.8.9)
> - the initial parameters of constructors for non-private inner member
> classes and anonymous classes (13.1,
> - the values and valueOf methods of enums (8.9.2)
> - certain public fields of enums (8.9.2)
> - certain public methods of interfaces (9.2)
> So for the purpose of this thread, only the second item need be marked
> synthesized.

This gives rise to two questions:

1) Based on inspecting the javac source, it seems that
Runtime*ParameterAnnotations won't include an entry for the synthesized

My reasoning is this:  writeParameterAttrs iterates through
MethodSymbol.params in order to write out the attributes, and
MethodSymbol.params does not seem to include this parameter.
(Incidentally, I used that writeParameterAttrs as an example for writing
out MethodParameters attributes, which is probably why MethodParameters
right now don't contain these parameters either).

Testing this shows that this is indeed the case.

However, the current spec indicates that there should be a
correspondence between MethodParameters (which should have the
synthesized parameter), and Runtime*ParameterAnnotations (which, unless
I'm wrong, won't), and the i'th type descriptor in the enclosing method.

This tells me one of the spec or javac needs to be updated.

2) Does this mean that the remaining parameters should be marked
SYNTHETIC?  Or should they be left alone?

a) Follow-up: is it objectionable to have javac set the
SYNTHESIZED/SYNTHETIC modifier flag when it creates synthesized or
synthetic parameters?  It doesn't seem to do this now, otherwise the
SYNTHETIC parameters would get reported correctly.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: eric_mccorkle.vcf
Type: text/x-vcard
Size: 314 bytes
Desc: not available
Url : 

More information about the compiler-dev mailing list