Parameter reflection: parameters with "" as their name
eric.mccorkle at oracle.com
Thu Jan 24 19:55:51 UTC 2013
On 01/24/13 14:40, Jonathan Gibbons wrote:
> On 01/24/2013 11:33 AM, Eric McCorkle wrote:
>> The current version of the spec for parameter reflection, found here:
>> 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?
>> It is probably also worth thinking about invalid parameter names, for
>> example "10", "_", "+", " ", other whitespace characters, and so on.
> What about name clashes, such as if I choose to name my args "arg3,
> arg2, arg1, arg0"
> Are valid parameter names JVMS identifiers or JLS identifiers?
It bears mention that Java may not be the only language using this
feature. Lisp (clojure) comes to mind, where names frequently have "-"
in them. There might also be languages out there where "0" is a valid
Also, one could imagine a language with nameless parameters in the style
of C++, or _ in the style of SML. But I really can't see a compelling
case why "" would be distinct from being unnamed.
More information about the core-libs-dev