-
Bug
-
Resolution: Duplicate
-
P3
-
5.0
Name: jl125535 Date: 06/22/2004
FULL PRODUCT VERSION :
java version "1.5.0-beta2"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0-beta2-b51)
Java HotSpot(TM) Client VM (build 1.5.0-beta2-b51, mixed mode, sharing)
ADDITIONAL OS VERSION INFORMATION :
Linux 2.4.7-10 #1 Thu Sep 6 17:27:27 EDT 2001 i686 unknown
and
Microsoft Windows XP [Version 5.1.2600]
A DESCRIPTION OF THE PROBLEM :
In a parameterised class, a test "this instanceof" against a non-parameterised subclass gives a compile-time error.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
javac -source 1.5 Test.java
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Clean compile.
ACTUAL -
Error message.
ERROR MESSAGES/STACK TRACES THAT OCCUR :
Test.java:3: inconvertible types
found : Test<T>
required: Test.Special
boolean DEBUG = this instanceof Special;
^
1 error
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
public class Test<T>
{
boolean DEBUG = this instanceof Special;
public static class Special extends Test<String>
{
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
Cast to a non-generified version. E.g. [code]public class Test<T>
{
boolean DEBUG = ((Test)this) instanceof Special;
public static class Special extends Test<String>
{
}
}[/code]
(Incident Review ID: 280878)
======================================================================
FULL PRODUCT VERSION :
java version "1.5.0-beta2"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0-beta2-b51)
Java HotSpot(TM) Client VM (build 1.5.0-beta2-b51, mixed mode, sharing)
ADDITIONAL OS VERSION INFORMATION :
Linux 2.4.7-10 #1 Thu Sep 6 17:27:27 EDT 2001 i686 unknown
and
Microsoft Windows XP [Version 5.1.2600]
A DESCRIPTION OF THE PROBLEM :
In a parameterised class, a test "this instanceof" against a non-parameterised subclass gives a compile-time error.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
javac -source 1.5 Test.java
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Clean compile.
ACTUAL -
Error message.
ERROR MESSAGES/STACK TRACES THAT OCCUR :
Test.java:3: inconvertible types
found : Test<T>
required: Test.Special
boolean DEBUG = this instanceof Special;
^
1 error
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
public class Test<T>
{
boolean DEBUG = this instanceof Special;
public static class Special extends Test<String>
{
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
Cast to a non-generified version. E.g. [code]public class Test<T>
{
boolean DEBUG = ((Test)this) instanceof Special;
public static class Special extends Test<String>
{
}
}[/code]
(Incident Review ID: 280878)
======================================================================
- duplicates
-
JDK-4916620 legal cast is rejected
- Closed