Generation of synthesized parameters

Joe Darcy joe.darcy at oracle.com
Tue Jan 29 14:21:45 PST 2013


On 1/29/2013 2:06 PM, Peter Jensen wrote:
> On 01/29/13 12:14, Joe Darcy wrote:
>> Hello,
>>
>> On 1/29/2013 11:40 AM, Eric McCorkle wrote:
>>> In order to facilitate writing tests for the MethodParameters feature,
>>> I'd like to get a complete list of all the cases when javac can 
>>> generate
>>> synthesized parameters.
>>>
>>> Here is a list I've put together from email discussions and comments 
>>> in JBS:
>>>
>>> 1) outer "this" parameters
>>
>> Arguably, some outer this parameters would be *synthesized* with 
>> others would be *synthetic*.
>>
>> Inner classes that are also member classes, (see diagram in "Nested, 
>> Inner, Member, and Top-Level Classes," 
>> https://blogs.oracle.com/darcy/entry/nested_inner_member_and_top), 
>> are potentially callable from outside of the enclosing class and are 
>> required to have an outer this parameter as the first parameter so 
>> that code from different compilers can call each other.  The other 
>> this parameter in this case is *synthesized* as it is mandated or 
>> implied by the JLS.
>>
>> On the other hand, named inner classes defined inside a method or 
>> constructor as well as anonymous classes only need to obey a 
>> compiler-internal contract and any extra parameters in this case are 
>> *synthetic*.  (Not all anonymous classes have an outer; an anonymous 
>> class created inside a static initializer block does not.)
>>
>>
>>> 2) extra values passed to constructor for enum values
>>
>> Such parameters are *synthetic*, they are a javac implementation 
>> artifact not mandated or implied by the JLS.
>>
>>> 3) hidden values passed to constructors of inner classes for final
>>> variables
>>
>> You'll can check the JLS regarding whether these are synthesized or 
>> synthetic, but I would assume they are synthetic.
>>
>>> 4) JLS mandated public no-arg constructors added by the compiler to
>>> classes with no declared constructor: synthesized
>>
>> This is not a parameter, but another language structure.
>>
>> HTH,
>>
>> -Joe
>>
>>> 5) The two parameters pre-ended to enum constructors by javac
>>>
>>>
>>> Does this capture everything, or does it miss something?
>>>
>>> Ideally, I would like to put together a complete list of all cases that
>>> should generate synthesized parameters.  (If one already exists, then
>>> that's great).
>>>
>>> Thanks,
>>> Eric
>>
> Argument pf synthetic enum valueOf() method. Synthetic or synthesized ?
>

The valueOf method itself is *synthesized* as the JLS mandates is 
creation, but I do not think the individual parameters of the method 
should be marked as such.

-Joe




More information about the compiler-dev mailing list