-
Enhancement
-
Resolution: Not an Issue
-
P4
-
None
-
8
-
x86_64
-
linux
FULL PRODUCT VERSION :
java version "1.8.0"
Java(TM) SE Runtime Environment (build 1.8.0-b132)
Java HotSpot(TM) 64-Bit Server VM (build 25.0-b70, mixed mode)
ADDITIONAL OS VERSION INFORMATION :
Linux ivostmaina 3.13.6-gentoo #1 SMP Thu Mar 20 02:22:16 CET 2014 x86_64 AMD FX(tm)-8350 Eight-Core Processor AuthenticAMD GNU/Linux
A DESCRIPTION OF THE PROBLEM :
The name for the method java.lang.reflect.Parameter::getParameterizedType() is completely confusing or even wrong. It does not necessarily return a ParameterizedType instance. It may also return a simple Class or a TypeVariable. Why is not called getGenericType()?
Take a look at the source code:
public Type getParameterizedType() {
Type tmp = parameterTypeCache;
if (null == tmp) {
tmp = executable.getGenericParameterTypes()[index];
parameterTypeCache = tmp;
}
return tmp;
}
getParameterizedType() simply calls getGenericParameterTypes() with the right index on the underlying executable. So in fact it have got NOTHING todo with ParameterizedType. So calling it "getGenericType" is the right name.
Since the Parameter Interface is introduced with Java 1.8, there is no problem to rename this method. There is no backward compatibility that have to be granted.
REPRODUCIBILITY :
This bug can be reproduced always.
SUPPORT :
YES
java version "1.8.0"
Java(TM) SE Runtime Environment (build 1.8.0-b132)
Java HotSpot(TM) 64-Bit Server VM (build 25.0-b70, mixed mode)
ADDITIONAL OS VERSION INFORMATION :
Linux ivostmaina 3.13.6-gentoo #1 SMP Thu Mar 20 02:22:16 CET 2014 x86_64 AMD FX(tm)-8350 Eight-Core Processor AuthenticAMD GNU/Linux
A DESCRIPTION OF THE PROBLEM :
The name for the method java.lang.reflect.Parameter::getParameterizedType() is completely confusing or even wrong. It does not necessarily return a ParameterizedType instance. It may also return a simple Class or a TypeVariable. Why is not called getGenericType()?
Take a look at the source code:
public Type getParameterizedType() {
Type tmp = parameterTypeCache;
if (null == tmp) {
tmp = executable.getGenericParameterTypes()[index];
parameterTypeCache = tmp;
}
return tmp;
}
getParameterizedType() simply calls getGenericParameterTypes() with the right index on the underlying executable. So in fact it have got NOTHING todo with ParameterizedType. So calling it "getGenericType" is the right name.
Since the Parameter Interface is introduced with Java 1.8, there is no problem to rename this method. There is no backward compatibility that have to be granted.
REPRODUCIBILITY :
This bug can be reproduced always.
SUPPORT :
YES
- relates to
-
JDK-8004729 Add java.lang.reflect.Parameter and related changes for parameter reflection
- Closed