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

Consider special case for Class.getSuperclass() result type

XMLWordPrintable

    • Icon: Enhancement Enhancement
    • Resolution: Won't Fix
    • Icon: P5 P5
    • None
    • 6
    • tools
    • None
    • 5.0
    • 5.0
    • generic
    • generic

      The result type of getSuperclass is somewhat useless, consider this example:

      Integer i = 1;
      i.getClass().getSuperclass();

      The static type of the last is expression is (before capture conversion is applied):

      Class<? super X> where X extends Integer.

      This is equivalent to:

      Class<?>

      which means that all information is lost.

      The compiler knows that the restult type of i.getClass() is Class<? extends Integer> so the result type of i.getClass().getSuperclass() should be Class<? extends Number>.
      ###@###.### 10/29/04 23:54 GMT

            ahe Peter Ahe
            ahe Peter Ahe
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: