JDK-8039917 : Wrong name for java.lang.reflect.Parameter::getParameterizedType() method
  • Type: Enhancement
  • Component: core-libs
  • Sub-Component: java.lang:reflect
  • Affected Version: 8
  • Priority: P4
  • Status: Closed
  • Resolution: Not an Issue
  • OS: linux
  • CPU: x86_64
  • Submitted: 2014-04-06
  • Updated: 2014-04-23
  • Resolved: 2014-04-23
Related Reports
Relates :  
Description
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


Comments
To be consistent with the design of core reflection, which predates generics being included in the platform, a method like getParameterizedType is needed in addition a plain getType method which just return in effect the erased type (by returning a class object). The term "parameterized type" is more correct than "generic type" used previously for java.lang.Class and elsewhere. Closing as not an issue.
23-04-2014

I don't think we should or can change method names since JDK 8 is GA.
10-04-2014