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

Incorrectly rejected class impl. of interface methods typed with wildcards

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Not an Issue
    • Icon: P4 P4
    • 5.0
    • 5.0
    • tools
    • x86
    • linux

      FULL PRODUCT VERSION :
      [On the linux box]
      java version "1.5.0-rc"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0-rc-b63)
      Java HotSpot(TM) Client VM (build 1.5.0-rc-b63, mixed mode, sharing)

      [On the windows box]
      java version "1.5.0-rc"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0-rc-b63)
      Java HotSpot(TM) Client VM (build 1.5.0-rc-b63, mixed mode, sharing)


      ADDITIONAL OS VERSION INFORMATION :
      Linux [machine name] 2.6.3-7mdk-i686-up-4GB #1 Wed Mar 17 15:17:23 CET 2004 i686 unknown unknown GNU/Linux

      Microsoft Windows 2000 [Version 5.00.2195]



      A DESCRIPTION OF THE PROBLEM :
      First the code:

      /////////////////////////////////////////////////////// Start here
      interface Interf<K1,K2,V> {
      public void meth(Interf<? extends K1, ? extends K2, ? extends V> t);
      }

      abstract class Clss<K1,K2,V> implements Interf<K1,K2,V> {
      public <SK1 extends K1, SK2 extends K2>
      void meth(Interf<SK1,SK2, ? extends V> that) {
      // ...
      }
      }
      /////////////////////////////////////////////////////// Ends here

      This is rejected by javac from the command-line.

      Using the wildcard in the interface seems to be the preferred style (e.g. in the generics tutorial, http://java.sun.com/j2se/1.5/pdf/generics-tutorial.pdf , bottom p.8 to top p.9) since the actual argument types do not appear elsewhere in the signature. However, a particular the implementation may find it necessary to name the type for use in the method body.

      FWIW, this code successfully compiled under Eclipse 3.1M2.


      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Just compiling it.

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      Compilation without error.
      ACTUAL -
      name clash: <SK1,SK2>meth(Interf<SK1,SK2,? extends V>) in Clss<K1,K2,V> and meth(Interf<? extends K1,? extends K2,? extends V>) in Interf<K1,K2,V> have the same erasure, yet neither overrides the other
      abstract class Clss<K1,K2,V> implements Interf<K1,K2,V> {
               ^



      ERROR MESSAGES/STACK TRACES THAT OCCUR :
      name clash: <SK1,SK2>meth(Interf<SK1,SK2,? extends V>) in Clss<K1,K2,V> and meth(Interf<? extends K1,? extends K2,? extends V>) in Interf<K1,K2,V> have the same erasure, yet neither overrides the other
      abstract class Clss<K1,K2,V> implements Interf<K1,K2,V> {
               ^



      REPRODUCIBILITY :
      This bug can be reproduced always.

      CUSTOMER SUBMITTED WORKAROUND :
      Don't use the wildcards in the interface; require the subclasses be named.
      ###@###.### 10/9/04 08:16 GMT
      ###@###.### 10/10/04 02:38 GMT

            Unassigned Unassigned
            gmanwanisunw Girish Manwani (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: