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

The compiler generates non-erased code when translating enhanced for loops

    Details

    • Type: Bug
    • Status: Closed
    • Priority: P2
    • Resolution: Duplicate
    • Affects Version/s: 7
    • Fix Version/s: 7
    • Component/s: tools
    • Subcomponent:
    • CPU:
      x86
    • OS:
      linux

      Description

      An AssertionError occurs while compiling the following code using "javac -target 1.5 Main.java":
      --------------------------------------------------------------------------
      import java.util.List;

      public class Main {

          public static void main(String[] args) {
              try {
              } finally {
                  List<List<?>> l = null;
                  for (List<?> textRegion : l) {
                  }
              }
          }

      }
      --------------------------------------------------------------------------

      Please note that "-target 1.5" is required on JDK6 and JDK7, can be omitted on JDK5.

      I can reproduce on:
      $ java -version
      java version "1.5.0_12"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_12-b04)
      Java HotSpot(TM) Server VM (build 1.5.0_12-b04, mixed mode)

      $ java -version
      java version "1.7.0-ea"
      Java(TM) SE Runtime Environment (build 1.7.0-ea-b22)
      Java HotSpot(TM) Server VM (build 11.0-b08, mixed mode)

      $ java -version
      java version "1.6.0_10-ea"
      Java(TM) SE Runtime Environment (build 1.6.0_10-ea-b12)
      Java HotSpot(TM) Server VM (build 11.0-b11, mixed mode)

      Stack trace (from 1.7.0-ea-b22):
      An exception has occurred in the compiler (1.7.0-ea). 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:1587)
              at com.sun.tools.javac.tree.JCTree$JCWildcard.accept(JCTree.java:1896)
              at com.sun.tools.javac.tree.TreeScanner.scan(TreeScanner.java:49)
              at com.sun.tools.javac.jvm.Gen$1ComplexityScanner.scan(Gen.java:1517)
              at com.sun.tools.javac.tree.TreeScanner.scan(TreeScanner.java:57)
              at com.sun.tools.javac.tree.TreeScanner.visitTypeApply(TreeScanner.java:268)
              at com.sun.tools.javac.tree.JCTree$JCTypeApply.accept(JCTree.java:1840)
              at com.sun.tools.javac.tree.TreeScanner.scan(TreeScanner.java:49)
              at com.sun.tools.javac.jvm.Gen$1ComplexityScanner.scan(Gen.java:1517)
              at com.sun.tools.javac.tree.TreeScanner.visitVarDef(TreeScanner.java:94)
              at com.sun.tools.javac.tree.JCTree$JCVariableDecl.accept(JCTree.java:709)
              at com.sun.tools.javac.tree.TreeScanner.scan(TreeScanner.java:49)
              at com.sun.tools.javac.jvm.Gen$1ComplexityScanner.scan(Gen.java:1517)
              at com.sun.tools.javac.tree.TreeScanner.scan(TreeScanner.java:57)
              at com.sun.tools.javac.tree.TreeScanner.visitBlock(TreeScanner.java:102)
              at com.sun.tools.javac.tree.JCTree$JCBlock.accept(JCTree.java:765)
              at com.sun.tools.javac.tree.TreeScanner.scan(TreeScanner.java:49)
              at com.sun.tools.javac.jvm.Gen$1ComplexityScanner.scan(Gen.java:1517)
              at com.sun.tools.javac.tree.TreeScanner.visitForLoop(TreeScanner.java:119)
              at com.sun.tools.javac.jvm.Gen$1ComplexityScanner.visitForLoop(Gen.java:1525)
              at com.sun.tools.javac.tree.JCTree$JCForLoop.accept(JCTree.java:856)
              at com.sun.tools.javac.tree.TreeScanner.scan(TreeScanner.java:49)
              at com.sun.tools.javac.jvm.Gen$1ComplexityScanner.scan(Gen.java:1517)
              at com.sun.tools.javac.tree.TreeScanner.scan(TreeScanner.java:57)
              at com.sun.tools.javac.tree.TreeScanner.visitBlock(TreeScanner.java:102)
              at com.sun.tools.javac.tree.JCTree$JCBlock.accept(JCTree.java:765)
              at com.sun.tools.javac.jvm.Gen.estimateCodeComplexity(Gen.java:1591)
              at com.sun.tools.javac.jvm.Gen.visitTry(Gen.java:1311)
              at com.sun.tools.javac.tree.JCTree$JCTry.accept(JCTree.java:1023)
              at com.sun.tools.javac.jvm.Gen.genDef(Gen.java:679)
              at com.sun.tools.javac.jvm.Gen.genStat(Gen.java:714)
              at com.sun.tools.javac.jvm.Gen.genStat(Gen.java:700)
              at com.sun.tools.javac.jvm.Gen.genStats(Gen.java:751)
              at com.sun.tools.javac.jvm.Gen.visitBlock(Gen.java:1027)
              at com.sun.tools.javac.tree.JCTree$JCBlock.accept(JCTree.java:765)
              at com.sun.tools.javac.jvm.Gen.genDef(Gen.java:679)
              at com.sun.tools.javac.jvm.Gen.genStat(Gen.java:714)
              at com.sun.tools.javac.jvm.Gen.genMethod(Gen.java:907)
              at com.sun.tools.javac.jvm.Gen.visitMethodDef(Gen.java:880)
              at com.sun.tools.javac.tree.JCTree$JCMethodDecl.accept(JCTree.java:653)
              at com.sun.tools.javac.jvm.Gen.genDef(Gen.java:679)
              at com.sun.tools.javac.jvm.Gen.genClass(Gen.java:2219)
              at com.sun.tools.javac.main.JavaCompiler.genCode(JavaCompiler.java:631)
              at com.sun.tools.javac.main.JavaCompiler.generate(JavaCompiler.java:1303)
              at com.sun.tools.javac.main.JavaCompiler.generate(JavaCompiler.java:1273)
              at com.sun.tools.javac.main.JavaCompiler.compile2(JavaCompiler.java:779)
              at com.sun.tools.javac.main.JavaCompiler.compile(JavaCompiler.java:744)
              at com.sun.tools.javac.main.Main.compile(Main.java:386)
              at com.sun.tools.javac.main.Main.compile(Main.java:312)
              at com.sun.tools.javac.main.Main.compile(Main.java:303)
              at com.sun.tools.javac.Main.compile(Main.java:82)
              at com.sun.tools.javac.Main.main(Main.java:67)

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                mcimadamore Maurizio Cimadamore
                Reporter:
                jlahoda Jan Lahoda
              • Votes:
                0 Vote for this issue
                Watchers:
                1 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:
                  Imported:
                  Indexed: