Re: Clarification Parameter.getName(…)
Alex Buckley
alex.buckley at oracle.com
Thu Jun 6 14:25:05 PDT 2013
On 6/5/2013 4:28 AM, Oliver Gierke wrote:
> the Parameter class introduced in Java 8 seems to return "arg0" for a
> call to getName(), even if the parameter name is not available in the
> bytecode. This makes it impossible to discover parameter names not
> being present in the bytecode and potentially taking further action
> in case names cannot be resolved. Does it make sense to return an
> Optional<String> to indicate this case?
While the MethodParameters attribute can express a parameter with
literally no name, the Core Reflection API follows the precedent of the
Language Model API in SE 6 whereby every parameter is deemed to have a
name. There is no facility for discovering whether the parameter name
was synthesized by the API. Why would it be useful? I'm not sure what
"resolution" of parameter names even means.
As an aside, the Core Reflection API has historically not depended on
the broader Java SE API, such as java.util. The Language Model API has
no such constraint, and uses java.util widely.
> Will parameter names be available for interface methods as well?
> Currently they cannot be resolved.
Are you saying that interface methods do not have a MethodParameters
attribute generated when -parameters is used at compile time?
Alex
More information about the jdk8-dev
mailing list