bug in spec or compiler?
843793Sep 18 2002 — edited Oct 1 2002Hello!
I have some problems with the jsr14 specification and the compiler implementation. I am not a native english speaker, but I think I can understand the specification correctly.
In the spec8.pdf document "Adding Generics to the Java Programming Language - Participant Draft Specification" on page 16 example 20: this should not compile but it does compile with jsr14 prototype 1.2 (javac 1.4.0_01)! Why? Anyone tried this?
In the same spec page 14: 6.1: "the erasure of a type variable is [...] if the bound consists of interface tyes only, the interface among the erasures of all interface types which has the least canonical name, using lexicographic ordering."
This sounds crazy, and the compiler does it different. It always uses the first parameter (following extends)! You can see this using "javap -c" on the bytecode. So, what�s right?
In the spec, page 3: "if a type parameter X has more than one bound, then it is a compiletime error to reference a member of an object whose declared type is X, unless that member is an accessible member of class java.lang.object"
Well, why is this an error? It compiles without any errors!
And another point: in the spec are examples of type variables with the "A implements I" syntax, which is not allowed. The compiler uses "extends" only. The example code is even on the same page (Page 3). Oh, oh!
Maybe I am wrong in some parts, and you can help me. (I cant believe, that I found three bugs in five hours) Any comments?