Parameter reflection: parameters with "" as their name

Alex Buckley alex.buckley at oracle.com
Thu Jan 24 12:35:49 PST 2013


// See new recipients of this mail.

// No re-posting of content between lists with different licenses, please.

On 1/24/2013 11:33 AM, Eric McCorkle wrote:
> The current version of the spec for parameter reflection, found here:
>
> http://cr.openjdk.java.net/~abuckley/8misc.pdf
>
> states that if a parameter has no name, then the reflection API should
> synthesize a name of the form "argN", where N is the index of the
> parameter.  It also states that if a MethodParameters attribute has a
> name index of 0, then it indicates a parameter with no name.
>
> The question I have is, what if a MethodParameters attribute indicates a
> name of "" (meaning, the empty string)?  Does this count as a valid
> name, or should it be treated as a parameter with no name?

For simplicity, I would be OK with saying that the name of a method 
parameter is an "unqualified name" per JVMS 4.2.2. That bans . ; [ / and 
allows everything else. For compilers targeting the ClassFile format, 
this is a reasonable trade-off between freedom and convention.

I would also say that an unqualified name (regardless of its role as a 
field name, parameter name, etc) must consist of at least one ASCII 
character in addition to not containing certain characters. That is, I'm 
happy to declare "" out of bounds for MethodParameters to avoid 
confusion with a 0 index (which I think remains a useful escape hatch 
for compilers).

How does all that sound?

Alex



More information about the enhanced-metadata-spec-discuss mailing list