Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-6682380

Foreach loop with generics inside finally block crashes javac with -target 1.5

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P2 P2
    • 7
    • 5.0u4, 7
    • tools
    • b27
    • x86, sparc
    • linux, solaris_10
    • Not verified

        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>
        {
        }
        ---------------------------------------------

              mcimadamore Maurizio Cimadamore
              mbykov Misha Bykov (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

                Created:
                Updated:
                Resolved:
                Imported:
                Indexed: