-
Bug
-
Resolution: Fixed
-
P3
-
6, 6u14
-
b40
-
generic, x86
-
generic, linux, windows_xp
-
Not verified
Issue | Fix Version | Assignee | Priority | Status | Resolution | Resolved In Build |
---|---|---|---|---|---|---|
JDK-2183396 | 6u18 | Sean Coffey | P3 | Resolved | Fixed | b03 |
JDK-2183395 | 6u17-rev | Sean Coffey | P3 | Resolved | Fixed | b05 |
JDK-2180427 | 6u16-rev | Sean Coffey | P3 | Closed | Fixed | b02 |
JDK-2192428 | OpenJDK6 | Jonathan Gibbons | P4 | Resolved | Fixed | b20 |
java version "1.6.0"
Java(TM) SE Runtime Environment (build 1.6.0-b105)
Java HotSpot(TM) Client VM (build 1.6.0-b105, mixed mode, sharing)
ADDITIONAL OS VERSION INFORMATION :
Linux lotp-laptop 2.6.20-15-generic #2 SMP Sun Apr 15 07:36:31 UTC 2007 i686 GNU
A DESCRIPTION OF THE PROBLEM :
In some cases javac outputs errors about inconvertible types. The circumstances in which this happens seem to be rather complicated. Trying to reduce the problem to a canonical form eradicates it.
Full discussion can be found at http://forum.java.sun.com/thread.jspa?threadID=5162196&tstart=0
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Try to compile the supplied source code example.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Should compile without errors
ACTUAL -
javac outputs the following errors:
javac Bug.java
Bug.java:27: inconvertible types
found : JETEvent<capture#608 of ?>
required: FSDEvent
if(event == null || ! (event instanceof FSDEvent)) { // <-- doesn't compile
^
Bug.java:30: inconvertible types
found : JETEvent<capture#870 of ?>
required: FSDEvent
FSDEvent fsdEvent = (FSDEvent)event;
^
2 errors
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
abstract class JETEvent<E extends Enum<E>> {}
class FSDEvent extends JETEvent<FSDEvent.SUBTYPE> {
public enum SUBTYPE {
TYPE_A,
TYPE_B
}
}
interface State<T extends Task> {
public Transition<T> getTransition(JETEvent<?> event);
}
class DefaultState<T extends Task> implements State<T> {
public Transition<T> getTransition(JETEvent<?> event) {
return null;
}
}
class FSDState extends DefaultState<FSDTask> {
@Override
public FSDTransition getTransition(JETEvent<?> event) {
if(event == null || ! (event instanceof FSDEvent)) { // <-- doesn't compile
return null;
}
FSDEvent fsdEvent = (FSDEvent)event; // <-- doesn't compile either
return null;
}
}
interface Task<T extends Task> {}
class FSDTask extends DefaultTask<FSDTask> {}
class DefaultTask<T extends DefaultTask> implements Task<T> {}
interface Transition<T extends Task> {}
class DefaultTransition<T extends Task> implements Transition<T> {}
class FSDTransition extends DefaultTransition<FSDTask> {}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
Casting to Object first solves the problem. The two problematic lines must be
if(event == null || ! ((Object)event instanceof FSDEvent)) { // <-- This compiles
FSDEvent fsdEvent = (FSDEvent)(Object)event; // <-- This now also compiles
for the compilation to work
Release Regression From : 5.0u11
The above release value was the last known release where this
bug was not reproducible. Since then there has been a regression.
Release Regression From : 5.0u11
The above release value was the last known release where this
bug was not reproducible. Since then there has been a regression.
- backported by
-
JDK-2183395 Incorrect inconvertible types error
- Resolved
-
JDK-2183396 Incorrect inconvertible types error
- Resolved
-
JDK-2192428 Incorrect inconvertible types error
- Resolved
-
JDK-2180427 Incorrect inconvertible types error
- Closed
- duplicates
-
JDK-6531814 Generics bug with Enum<?> instanceof
- Closed
-
JDK-6570761 Possible generics regression - inconvertible types
- Closed
-
JDK-6717191 Casting from generic class with wildcard to subclass fails to compile
- Closed
- relates to
-
JDK-6718388 4.9: Specify subtyping of intersection types
- Open
-
JDK-6575893 Restructure j2se workspace for langtools separation, simplier building
- Closed
-
JDK-7123100 javac fails with java.lang.StackOverflowError
- Closed