JDK-7085024 : internal error; cannot instantiate Foo
  • Type: Bug
  • Component: tools
  • Sub-Component: javac
  • Affected Version: 7
  • Priority: P4
  • Status: Closed
  • Resolution: Fixed
  • OS: linux
  • CPU: x86
  • Submitted: 2011-08-30
  • Updated: 2013-07-18
  • Resolved: 2012-02-24
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 JDK 8
7u4Fixed 8 b06Fixed
Description
FULL PRODUCT VERSION :
>/data/tora/java-versions/jdk1.7.0/bin/java -version
java version "1.7.0"
Java(TM) SE Runtime Environment (build 1.7.0-b147)
Java HotSpot(TM) 64-Bit Server VM (build 21.0-b17, mixed mode)

ADDITIONAL OS VERSION INFORMATION :
>uname -a
Linux agile.doc.ic.ac.uk 2.6.38.2 #3 SMP Wed Mar 30 14:19:08 BST 2011 x86_64 GNU/Linux


A DESCRIPTION OF THE PROBLEM :
A cast of null to an unknown symbol (BitSet in Bar below is not imported) can cause the compiler to reach an internal error during generics resolution of the file Foo.

STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
>cat Foo.java
import java.util.Comparator;
public class Foo {
    public Foo (Comparator<Object> list, boolean ret) {
    }
}

>cat Bar.java
public class Bar {
    public static void main(String[] args) {
        final Foo f = new Foo(null, (BitSet) null );
    }
}

> javac Foo.java Bar.java

EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Not an internal error.
ACTUAL -
>/data/tora/java-versions/jdk1.7.0/bin/javac Foo.java Bar.java
Bar.java:3: error: cannot find symbol
        final Foo f = new Foo(null, (BitSet) null );
                                     ^
  symbol:   class BitSet
  location: class Bar
Bar.java:3: error: internal error; cannot instantiate Foo(Comparator<Object>,boolean) at Foo to ()
        final Foo f = new Foo(null, (BitSet) null );
                      ^
2 errors


REPRODUCIBILITY :
This bug can be reproduced always.

Comments
SUGGESTED FIX A webrev of this fix is available at the following URL: http://hg.openjdk.java.net/jdk8/tl/langtools/rev/b86277584776
31-08-2011

EVALUATION Types.isConvertible doesn't handle erroneous types on the LHS of a conversion test - this should always yield true, as for Types.isAssignable, and Types.isSubtype.
31-08-2011