Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8039917

Wrong name for java.lang.reflect.Parameter::getParameterizedType() method

XMLWordPrintable

    • Icon: Enhancement Enhancement
    • Resolution: Not an Issue
    • Icon: P4 P4
    • None
    • 8
    • core-libs

      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

            darcy Joe Darcy
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: