FULL PRODUCT VERSION :
javac 1.6.0_07 ... and other generics-aware javac versions (but not Eclipse)
ADDITIONAL OS VERSION INFORMATION :
Windows Vista Pro (32-bit)
A DESCRIPTION OF THE PROBLEM :
The following code should compile with no errors and generate class files smoothly.
class A<T> {}
class B<T> extends A<C<T>> {}
class C<T> extends B<T> {}
Javac instead emits
1 error found:
File: (no associated file) [line: (no source location)]
Error: Compile exception: java.lang.NullPointerException
and generates class files for classes A and B only.
Problem seems to be related to the fact that C<T> extends B<T>, yet C<T> is also used inside the supertype of B<T> (should be allowed, but possibly confuses javac).
More generally, javac seems to not realize that generic types (eg, B<T>) are, correctly, allowed (by the generics spec) to extend generic types (eg, A<C<T>>) that are instantiated with generic types that happen to be their *subtypes* (eg, C<T>).
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Type the following three lines of code in your favorite text editor
class A<T> {}
class B<T> extends A<C<T>> {}
class C<T> extends B<T> {}
... and compile using a (5.0+, generics-aware) javac.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
No error. 3 class files for 3 classes.
ACTUAL -
1 error found:
File: (no associated file) [line: (no source location)]
Error: Compile exception: java.lang.NullPointerException
2 class files, for classes A and B.
ERROR MESSAGES/STACK TRACES THAT OCCUR :
1 error found:
File: (no associated file) [line: (no source location)]
Error: Compile exception: java.lang.NullPointerException
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
class A<T> {}
class B<T> extends A<C<T>> {}
class C<T> extends B<T> {}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
None known.
javac 1.6.0_07 ... and other generics-aware javac versions (but not Eclipse)
ADDITIONAL OS VERSION INFORMATION :
Windows Vista Pro (32-bit)
A DESCRIPTION OF THE PROBLEM :
The following code should compile with no errors and generate class files smoothly.
class A<T> {}
class B<T> extends A<C<T>> {}
class C<T> extends B<T> {}
Javac instead emits
1 error found:
File: (no associated file) [line: (no source location)]
Error: Compile exception: java.lang.NullPointerException
and generates class files for classes A and B only.
Problem seems to be related to the fact that C<T> extends B<T>, yet C<T> is also used inside the supertype of B<T> (should be allowed, but possibly confuses javac).
More generally, javac seems to not realize that generic types (eg, B<T>) are, correctly, allowed (by the generics spec) to extend generic types (eg, A<C<T>>) that are instantiated with generic types that happen to be their *subtypes* (eg, C<T>).
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Type the following three lines of code in your favorite text editor
class A<T> {}
class B<T> extends A<C<T>> {}
class C<T> extends B<T> {}
... and compile using a (5.0+, generics-aware) javac.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
No error. 3 class files for 3 classes.
ACTUAL -
1 error found:
File: (no associated file) [line: (no source location)]
Error: Compile exception: java.lang.NullPointerException
2 class files, for classes A and B.
ERROR MESSAGES/STACK TRACES THAT OCCUR :
1 error found:
File: (no associated file) [line: (no source location)]
Error: Compile exception: java.lang.NullPointerException
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
class A<T> {}
class B<T> extends A<C<T>> {}
class C<T> extends B<T> {}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
None known.
- duplicates
-
JDK-6292765 java.lang.NullPointerException at Check.checkCompatibleConcretes
-
- Closed
-