JDK-6682380 : Foreach loop with generics inside finally block crashes javac with -target 1.5
  • Type: Bug
  • Component: tools
  • Sub-Component: javac
  • Affected Version: 5.0u4,7
  • Priority: P2
  • Status: Closed
  • Resolution: Fixed
  • OS: linux,solaris_10
  • CPU: x86,sparc
  • Submitted: 2008-03-31
  • Updated: 2011-05-18
  • 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.
Other Other JDK 6 JDK 7
5.0u15-revFixed 5.0u17Fixed 6u30Fixed 7 b27Fixed
Related Reports
Duplicate :  
Relates :  
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
15-04-2008

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) -----------------------------------
31-03-2008