java.lang.reflect.Parameter comments

Kasper Nielsen kasperni at
Thu Sep 19 12:05:31 UTC 2013

Sorry for the late reply,

On 8/25/2013 7:03 AM, Kasper Nielsen wrote:
>> Hi,
>> just 2 short questions/commons on java.lang.reflect.Parameter
>> 1)
>> I was wondering if there is any reason for java.lang.reflect.Parameter not
>> to expose the index field?
> "Not sure what you mean by the "index field", but if you mean the
> name_index item in the MethodParameters attribute, then it is possible to
> know whether it's zero by calling Parameter#isNamePresent."
I'm talking about the "index field" as in
java.lang.reflect.Parameter.index, the field that indicates which parameter
you "are" if you call parameter.getDeclaringExecutable().getParameters().
I have a couple of places where I have to include the index when passing a
parameter around. Instead of just being able to call parameter.getIndex().
A simple getter should do

public int getIndex() {
   return index;

> "Yes and no. First, the historic use of getGenericXXX in java.lang.reflect
> is wrong (it should be getParameterizedXXX) but it can't be changed now.
> The Language Model API in javax.lang.model.** is much better with
> terminology. Second, when we add methods to existing java.lang.reflect
> types, we hold our noses and use "Generic" for consistency, e.g., the new
> AnnotatedArrayType interface for type annotations has a method
> getAnnotatedGenericComponentTy**pe that is consistent with the
> getGenericComponentType method in GenericArrayType. Third, when we add new
> types to java.lang.reflect, we use the correct terminology, hence Parameter#
> **getParameterizedType."
> Thanks for explanation.

- Kasper

More information about the core-libs-dev mailing list