JDK-7034019 : ClassCastException in javac with conjunction types
  • Type: Bug
  • Component: tools
  • Sub-Component: javac
  • Affected Version: 7
  • Priority: P2
  • Status: Closed
  • Resolution: Fixed
  • OS: windows_7
  • CPU: x86
  • Submitted: 2011-04-05
  • Updated: 2012-03-20
  • Resolved: 2011-05-17
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 7
7 b140Fixed
Related Reports
Relates :  
Relates :  
Relates :  
Relates :  
Description
FULL PRODUCT VERSION :


A DESCRIPTION OF THE PROBLEM :
interface A
{
    abstract <T> void foo();
}

interface B
{
    abstract void foo();
}

class C<T extends A & B>
{
    void bar(T x)
    {
        x.foo();
    }
}

javac throws the following exception:
java.lang.ClassCastException: com.sun.tools.javac.code.Type$MethodType cannot be cast to com.sun.tools.javac.code.Type$ForAll


REPRODUCIBILITY :
This bug can be reproduced always.
Bugs 4851398 and 4881362 reported crash using similar conjunction types but those could not be reproduce.
This crashes same way with jdk5,6,7.

Comments
SUGGESTED FIX A webrev of this fix is available at the following URL: http://hg.openjdk.java.net/jdk7/tl/langtools/rev/bfbc197b560f
13-04-2011

EVALUATION Resolve.mostSpecific contains an inlined version of the return type substitutability check that doesn't cope well with all cases.
07-04-2011