JDK-6182618 : void bar1(Class x) does not compile
  • Type: Bug
  • Component: tools
  • Sub-Component: javac
  • Affected Version: 5.0
  • Priority: P4
  • Status: Closed
  • Resolution: Duplicate
  • OS: windows_2000
  • CPU: x86
  • Submitted: 2004-10-21
  • Updated: 2010-04-02
  • Resolved: 2004-10-21
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
Other
5.0Resolved
Related Reports
Duplicate :  
Description
FULL PRODUCT VERSION :
java version "1.5.0"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0-b64)
Java HotSpot(TM) Client VM (build 1.5.0-b64, mixed mode, sharing)

ADDITIONAL OS VERSION INFORMATION :
Microsoft Windows 2000
5.00.2195
Service Pack 4

A DESCRIPTION OF THE PROBLEM :
Super does not seem able to accept a named parameter type... method bar4() below does not compile.

public class Foo<T> {
        // These are all OK
        void bar1(Class<? extends T> x) {}
        <X extends T> void bar2(Class<X> x) {}
        void bar3(Class<? super T> x) {}

        // but this one causes javac to complain... why?
        <X super T> void bar4(Class<X> x) {}

        public static void main(String[] args) {
                Foo<Number> f = new Foo<Number>();
                f.bar1(Integer.class);
                f.bar2(Double.class);
                f.bar3(Object.class);
        }
}

STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Try to compile code snippet above, see error.

EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
expected it to compile, and for <X super T> to work similarly to <X extends T>
ACTUAL -
won't compile


ERROR MESSAGES/STACK TRACES THAT OCCUR :
Foo.java:8: > expected
        <X super T> void bar4(Class<X> x) {}
           ^
Foo.java:12: illegal start of type
                f.bar1(Integer.class);
                               ^

etc.

REPRODUCIBILITY :
This bug can be reproduced always.

---------- BEGIN SOURCE ----------
public class Foo<T> {
        // These are all OK
        void bar1(Class<? extends T> x) {}
        <X extends T> void bar2(Class<X> x) {}
        void bar3(Class<? super T> x) {}

        // but this one causes javac to complain... why?
        <X super T> void bar4(Class<X> x) {}

        public static void main(String[] args) {
                Foo<Number> f = new Foo<Number>();
                f.bar1(Integer.class);
                f.bar2(Double.class);
                f.bar3(Object.class);
        }
}
---------- END SOURCE ----------
###@###.### 10/21/04 17:04 GMT