I hope people don't mind me using this list for japitools discussion -
I think it's relevant to Claspath as the primary consumer of the
results...
Anyway, I found another evil case that javac accepts and I'm wondering
if any of the experts on the JLS can tell me whether this is
*supposed* to be acceptable...
class Outer<T> {
class Inner<U> {
}
class InnerTester extends Inner {
}
public InnerTester getIt() { return new InnerTester(); }
}
public class Tester2 {
public static Outer<String>.InnerTester getIt() {
return new Outer<String>().getIt();
}
// Fails to compile because Inner is "half-bound"
// But for some reason InnerTester is okay even though it results in
// Inner being equally half-bound.
//public static Outer<String>.Inner getIt2() {
// return new Outer<String>().getIt();
//}
public static void main(String[] args) {
System.out.println(getIt());
}
}
The bit that fails to compile is obvious - you can't have
Outer<String>.Inner because T is bound but U is not. However, I can't
understand why InnerTester is legal, because it's in exactly the same
boat - in fact, it's superclass *is* Outer<String>.Inner.
The rules as I understood them were that you could have a raw type,
with all generic parameters omitted, or a fully-qualified type with
all the parameters specified, but specifying some but not all was
illegal. This appears to be an exception to that rule?
It gets worse...
class Inner<U> {
class InnerInner<V> {}
}
class InnerTester extends Inner {
InnerInner<String> foo;
}
Now InnerInner has T bound, U unbound and V bound - there's a hole in
the *middle* of the list of parameters. Is this *really* supposed to
be legal?
Stuart.
--
http://sab39.dev.netreach.com/
_______________________________________________
Classpath mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/classpath