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

Unused type parameter triggering error in unrelated method

XMLWordPrintable

    • Icon: Enhancement Enhancement
    • Resolution: Duplicate
    • Icon: P4 P4
    • None
    • 6
    • tools
    • x86
    • windows_xp

      FULL PRODUCT VERSION :
      java version "1.6.0_10-ea"
      Java(TM) SE Runtime Environment (build 1.6.0_10-ea-b10)
      Java HotSpot(TM) Client VM (build 11.0-b09, mixed mode, sharing)

      ADDITIONAL OS VERSION INFORMATION :
      Windows XP [Version 5.1.2600]

      A DESCRIPTION OF THE PROBLEM :
      The introduction of a type parameter to a superclass can cause a compile-time error if that type parameter is not yet used. The compiler's complaint is about a seemingly unrelated over-ridden method.

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      See code below.

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      Compilable code.
      ACTUAL -
      Compile-time error.

      ERROR MESSAGES/STACK TRACES THAT OCCUR :
      Setter.java:10: name clash: setStuff(java.util.List<java.lang.String>) in SpecialSetter and setStuff(java.util.List<java.lang.String>) in Setter have the same erasure, yet neither overrides the other
      class SpecialSetter extends Setter {
      ^
      1 error

      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      // Does not compile (that's the point)

      import java.util.List;

      public class Setter<T> {
          public void setStuff(List<String> strings) {
          }
      }

      class SpecialSetter extends Setter {
          public void setStuff(List<String> strings) {
          }
      }
      ---------- END SOURCE ----------

      CUSTOMER SUBMITTED WORKAROUND :
      Force all subclasses to provide a value for the superclass's type parameter.

            mcimadamore Maurizio Cimadamore
            ryeung Roger Yeung (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: