United StatesChange Country, Oracle Worldwide Web Sites Communities I am a... I want to...
Bug ID: JDK-7085024 internal error; cannot instantiate Foo
JDK-7085024 : internal error; cannot instantiate Foo

Details
Type:
Bug
Submit Date:
2011-08-30
Status:
Closed
Updated Date:
2013-07-18
Project Name:
JDK
Resolved Date:
2012-02-24
Component:
tools
OS:
linux
Sub-Component:
javac
CPU:
x86
Priority:
P4
Resolution:
Fixed
Affected Versions:
7
Fixed Versions:

Related Reports
Backport:

Sub Tasks

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
                                     
2011-08-31
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.
                                     
2011-08-31



Hardware and Software, Engineered to Work Together