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

generics: compiler rejects mutually recursive type variable bounds

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: P4 P4
    • None
    • 5.0
    • specification
    • x86
    • windows_xp



      Name: rmT116609 Date: 07/31/2003


      FULL PRODUCT VERSION :
      java version "1.4.2"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2-b28)
      Java HotSpot(TM) Client VM (build 1.4.2-b28, mixed mode)

      FULL OS VERSION :
      Windows XP

      EXTRA RELEVANT SYSTEM CONFIGURATION :
      generics prototype compiler 2.2-ea

      A DESCRIPTION OF THE PROBLEM :
      The prototype compiler rejects mutually recursive type variable bounds although the specification allows them.


      package generics;

      public class TypeVariablesInBounds {

      public static <T extends S & Comparable<S>, S extends T>
      T max(T arg1, S arg2) {
      return (arg1.compareTo(arg2)>0)?arg1:arg2;
      }

      }


      error message:

      TypeVariablesInBounds.java:5: illegal forward reference
      public static <T extends S & Comparable<S>, S extends T>
                                         ^


      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      compile source

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      error-free compilation
      ACTUAL -
      compile-time error messages

      ERROR MESSAGES/STACK TRACES THAT OCCUR :
      TypeVariablesInBounds.java:5: illegal forward reference
      public static <T extends S & Comparable<S>, S extends T>
                                         ^


      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      package generics;

      public class TypeVariablesInBounds {

      public static <T extends S & Comparable<S>, S extends T>
      T max(T arg1, S arg2) {
      return (arg1.compareTo(arg2)>0)?arg1:arg2;
      }

      }
      ---------- END SOURCE ----------
      (Incident Review ID: 193242)
      ======================================================================

            gbrachasunw Gilad Bracha (Inactive)
            rmandalasunw Ranjith Mandala (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: