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

Alex Buckley alex.buckley at oracle.com
Tue Feb 12 17:50:07 PST 2013


On 2/12/2013 9:42 AM, Eric McCorkle wrote:
> On 02/12/13 11:56, Maurizio Cimadamore wrote:
>> On 12/02/13 16:44, Eric McCorkle wrote:
>>> Actually, it is necessary.  There are specific cases where a parameter
>>> must be marked MANDATED, and it is marked SYNTHETIC in all others.
>>>
>>> Most notably, only the outer this in a *non-private* inner member class
>>> constructor gets marked MANDATED.  If there's an outer this for a static
>>> or a private inner class constructor, it gets marked SYNTHETIC.
>> Well, for a static inner class the method won't be called - but for a
>> private inner it would (I must admit that I don't understand fully the
>> rationale as to why private constructors are omitted from the mandated
>> thing).
>
> The choice seems somewhat arbitrary, but I have to do what the spec says...

Per the new discussion in JLS 8.8.9 which appears in 8misc.pdf, it is 
possible for a _non-private_ inner member class to be instantiated by 
code in a totally different compilation unit, _compiled by a different 
compiler than compiled the inner member class_. Hence the mandated 
parameter which allows all compilers to reify the immediately enclosing 
instance. But a _private_ inner member class can only be instantiated 
within the same compilation unit, so it's the compiler's choice how to 
reify the immediately enclosing instance in that case, and I believe 
javac has always used ACC_SYNTHETIC for that class's default ctor.

Alex



More information about the compiler-dev mailing list