United StatesChange Country, Oracle Worldwide Web Sites Communities I am a... I want to...
JDK-6682380 : Foreach loop with generics inside finally block crashes javac with -target 1.5

Details
Type:
Bug
Submit Date:
2008-03-31
Status:
Closed
Updated Date:
2011-05-18
Project Name:
JDK
Resolved Date:
2011-05-17
Component:
tools
OS:
linux,solaris_10
Sub-Component:
javac
CPU:
x86,sparc
Priority:
P2
Resolution:
Fixed
Affected Versions:
5.0u4,7
Fixed Versions:

Related Reports
Backport:
Backport:
Backport:
Duplicate:
Relates:

Sub Tasks

Description
Can't compile the code provided below with JDK 1.5 and with "-target 1.5" in case of Java 6.

Output error for Java 6 (similar for JDK 1.5 without options):

% javac -target 1.5 Crash.java
An exception has occurred in the compiler (1.6.0). Please file a bug at the Java Developer Connection (http://java.sun.com/webapps/bugreport)  after checking the Bug Parade for duplicates. Include your program and the following diagnostic in your report.  Thank you.
java.lang.AssertionError: com.sun.tools.javac.jvm.Gen$1ComplexityScanner
        at com.sun.tools.javac.jvm.Gen$1ComplexityScanner.visitWildcard(Gen.java:1538)
        at com.sun.tools.javac.tree.JCTree$JCWildcard.accept(JCTree.java:1746)
        at com.sun.tools.javac.tree.TreeScanner.scan(TreeScanner.java:35)
        at com.sun.tools.javac.jvm.Gen$1ComplexityScanner.scan(Gen.java:1468)
        at com.sun.tools.javac.tree.TreeScanner.scan(TreeScanner.java:43)
        at com.sun.tools.javac.tree.TreeScanner.visitTypeApply(TreeScanner.java:254)
        at com.sun.tools.javac.tree.JCTree$JCTypeApply.accept(JCTree.java:1697)
        at com.sun.tools.javac.tree.TreeScanner.scan(TreeScanner.java:35)
        at com.sun.tools.javac.jvm.Gen$1ComplexityScanner.scan(Gen.java:1468)
        at com.sun.tools.javac.tree.TreeScanner.visitVarDef(TreeScanner.java:80)        at com.sun.tools.javac.tree.JCTree$JCVariableDecl.accept(JCTree.java:691)
        at com.sun.tools.javac.tree.TreeScanner.scan(TreeScanner.java:35)
        at com.sun.tools.javac.jvm.Gen$1ComplexityScanner.scan(Gen.java:1468)
        at com.sun.tools.javac.tree.TreeScanner.scan(TreeScanner.java:43)
        at com.sun.tools.javac.tree.TreeScanner.visitBlock(TreeScanner.java:88)
        at com.sun.tools.javac.tree.JCTree$JCBlock.accept(JCTree.java:739)
        at com.sun.tools.javac.tree.TreeScanner.scan(TreeScanner.java:35)
        at com.sun.tools.javac.jvm.Gen$1ComplexityScanner.scan(Gen.java:1468)
        at com.sun.tools.javac.tree.TreeScanner.visitForLoop(TreeScanner.java:105)
        at com.sun.tools.javac.jvm.Gen$1ComplexityScanner.visitForLoop(Gen.java:1476)
        at com.sun.tools.javac.tree.JCTree$JCForLoop.accept(JCTree.java:818)
        at com.sun.tools.javac.tree.TreeScanner.scan(TreeScanner.java:35)
        at com.sun.tools.javac.jvm.Gen$1ComplexityScanner.scan(Gen.java:1468)
        at com.sun.tools.javac.tree.TreeScanner.scan(TreeScanner.java:43)
        at com.sun.tools.javac.tree.TreeScanner.visitBlock(TreeScanner.java:88)
        at com.sun.tools.javac.tree.JCTree$JCBlock.accept(JCTree.java:739)
        at com.sun.tools.javac.jvm.Gen.estimateCodeComplexity(Gen.java:1542)
        at com.sun.tools.javac.jvm.Gen.visitTry(Gen.java:1268)
        at com.sun.tools.javac.tree.JCTree$JCTry.accept(JCTree.java:967)
        at com.sun.tools.javac.jvm.Gen.genDef(Gen.java:660)
        at com.sun.tools.javac.jvm.Gen.genStat(Gen.java:695)
        at com.sun.tools.javac.jvm.Gen.genStat(Gen.java:681)
        at com.sun.tools.javac.jvm.Gen.genStats(Gen.java:732)
        at com.sun.tools.javac.jvm.Gen.visitBlock(Gen.java:985)
        at com.sun.tools.javac.tree.JCTree$JCBlock.accept(JCTree.java:739)
        at com.sun.tools.javac.jvm.Gen.genDef(Gen.java:660)
        at com.sun.tools.javac.jvm.Gen.genStat(Gen.java:695)
        at com.sun.tools.javac.jvm.Gen.genMethod(Gen.java:918)
        at com.sun.tools.javac.jvm.Gen.visitMethodDef(Gen.java:854)
        at com.sun.tools.javac.tree.JCTree$JCMethodDecl.accept(JCTree.java:639)
        at com.sun.tools.javac.jvm.Gen.genDef(Gen.java:660)
        at com.sun.tools.javac.jvm.Gen.genClass(Gen.java:2163)
        at com.sun.tools.javac.main.JavaCompiler.genCode(JavaCompiler.java:617)
        at com.sun.tools.javac.main.JavaCompiler.generate(JavaCompiler.java:1289)
        at com.sun.tools.javac.main.JavaCompiler.generate(JavaCompiler.java:1259)
        at com.sun.tools.javac.main.JavaCompiler.compile2(JavaCompiler.java:765)        at com.sun.tools.javac.main.JavaCompiler.compile(JavaCompiler.java:730)
        at com.sun.tools.javac.main.Main.compile(Main.java:353)
        at com.sun.tools.javac.main.Main.compile(Main.java:279)
        at com.sun.tools.javac.main.Main.compile(Main.java:270)
        at com.sun.tools.javac.Main.compile(Main.java:69)
        at com.sun.tools.javac.Main.main(Main.java:54)

The code:

-------------------------
public class Crash {

        public static void main(String[] argv){
                TreeSet<Father> sons = new TreeSet<Father>();

                try{
                }
                catch(Throwable t){
                }
                finally{
                        for(Father<?> son : sons)
                        {
                                son.clear();
                        }
                }
        }
}

abstract class Father<T extends Father>
{
        public void clear(){

        }
}

class Son extends Father<Son>
{
}
---------------------------------------------

                                    

Comments
EVALUATION

For the evaluation of this bug, please refer to the related CR 6679509
                                     
2008-04-15
EVALUATION

Bug confirmed in 1.6.0_05, using -target 5.

----------------------------------
jjg@gzillapc:/w/jjg/work/6682380-crash$ /opt/jdk/jdk1.6.0_05/bin/javac Crash.java
jjg@gzillapc:/w/jjg/work/6682380-crash$ /opt/jdk/jdk1.6.0_05/bin/javac -target 5 Crash.java
An exception has occurred in the compiler (1.6.0_05). Please file a bug at the Java Developer Connection (http://java.sun.com/webapps/bugreport)  after checking the Bug Parade for duplicates. Include your program and the following diagnostic in your report.  Thank you.
java.lang.AssertionError: com.sun.tools.javac.jvm.Gen$1ComplexityScanner
        at com.sun.tools.javac.jvm.Gen$1ComplexityScanner.visitWildcard(Gen.java:1573)
        at com.sun.tools.javac.tree.JCTree$JCWildcard.accept(JCTree.java:1746)
-----------------------------------
                                     
2008-03-31



Hardware and Software, Engineered to Work Together