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

javac NPE on Object a[]; Object o = (a=null)[0];

XMLWordPrintable

    • b142
    • x86
    • linux_redhat_5.0
    • Verified

      FULL PRODUCT VERSION :
      java version "1.6.0_24"
      Java(TM) SE Runtime Environment (build 1.6.0_24-b07)
      Java HotSpot(TM) Server VM (build 19.1-b02, mixed mode)


      ADDITIONAL OS VERSION INFORMATION :
      Linux 2.6.18-238.5.1.el5 #1 SMP Mon Feb 21 05:53:18 EST 2011 i686 i686 i386 GNU/Linux

      A DESCRIPTION OF THE PROBLEM :
      I compiled the following program. Instead of compiling, javac aborted with the following stack dump.

      ===program===
      public class Boom {
          Object a[];
          Object o = (a = null)[0];
      }
      ===end===
      ===shell command and output===
      javac Boom.java
      An exception has occurred in the compiler (1.6.0_24). 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.NullPointerException
      at com.sun.tools.javac.code.Types.erasure(Types.java:1490)
      at com.sun.tools.javac.jvm.Code.emitop0(Code.java:455)
      at com.sun.tools.javac.jvm.Items$IndexedItem.load(Items.java:305)
      at com.sun.tools.javac.jvm.Gen.visitAssign(Gen.java:1752)
      at com.sun.tools.javac.tree.JCTree$JCAssign.accept(JCTree.java:1342)
      at com.sun.tools.javac.jvm.Gen.genExpr(Gen.java:818)
      at com.sun.tools.javac.jvm.Gen.visitExec(Gen.java:1605)
      at com.sun.tools.javac.tree.JCTree$JCExpressionStatement.accept(JCTree.java:1074)
      at com.sun.tools.javac.jvm.Gen.genDef(Gen.java:665)
      at com.sun.tools.javac.jvm.Gen.genStat(Gen.java:700)
      at com.sun.tools.javac.jvm.Gen.genStat(Gen.java:686)
      at com.sun.tools.javac.jvm.Gen.genStats(Gen.java:737)
      at com.sun.tools.javac.jvm.Gen.visitBlock(Gen.java:1013)
      at com.sun.tools.javac.tree.JCTree$JCBlock.accept(JCTree.java:739)
      at com.sun.tools.javac.jvm.Gen.genDef(Gen.java:665)
      at com.sun.tools.javac.jvm.Gen.genStat(Gen.java:700)
      at com.sun.tools.javac.jvm.Gen.genMethod(Gen.java:893)
      at com.sun.tools.javac.jvm.Gen.visitMethodDef(Gen.java:866)
      at com.sun.tools.javac.tree.JCTree$JCMethodDecl.accept(JCTree.java:639)
      at com.sun.tools.javac.jvm.Gen.genDef(Gen.java:665)
      at com.sun.tools.javac.jvm.Gen.genClass(Gen.java:2198)
      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)


      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      $ cat > Boom.java
      public class Boom {
          Object a[];
          Object o = (a = null)[0];
      }
      ^D

      $ javac Boom.java

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      Javac compiles my program.
      ACTUAL -
      Javac aborted with a stack dump.


      ERROR MESSAGES/STACK TRACES THAT OCCUR :
      An exception has occurred in the compiler (1.6.0_24). 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.NullPointerException
      at com.sun.tools.javac.code.Types.erasure(Types.java:1490)
      at com.sun.tools.javac.jvm.Code.emitop0(Code.java:455)
      at com.sun.tools.javac.jvm.Items$IndexedItem.load(Items.java:305)
      at com.sun.tools.javac.jvm.Gen.visitAssign(Gen.java:1752)
      at com.sun.tools.javac.tree.JCTree$JCAssign.accept(JCTree.java:1342)
      at com.sun.tools.javac.jvm.Gen.genExpr(Gen.java:818)
      at com.sun.tools.javac.jvm.Gen.visitExec(Gen.java:1605)
      at com.sun.tools.javac.tree.JCTree$JCExpressionStatement.accept(JCTree.java:1074)
      at com.sun.tools.javac.jvm.Gen.genDef(Gen.java:665)
      at com.sun.tools.javac.jvm.Gen.genStat(Gen.java:700)
      at com.sun.tools.javac.jvm.Gen.genStat(Gen.java:686)
      at com.sun.tools.javac.jvm.Gen.genStats(Gen.java:737)
      at com.sun.tools.javac.jvm.Gen.visitBlock(Gen.java:1013)
      at com.sun.tools.javac.tree.JCTree$JCBlock.accept(JCTree.java:739)
      at com.sun.tools.javac.jvm.Gen.genDef(Gen.java:665)
      at com.sun.tools.javac.jvm.Gen.genStat(Gen.java:700)
      at com.sun.tools.javac.jvm.Gen.genMethod(Gen.java:893)
      at com.sun.tools.javac.jvm.Gen.visitMethodDef(Gen.java:866)
      at com.sun.tools.javac.tree.JCTree$JCMethodDecl.accept(JCTree.java:639)
      at com.sun.tools.javac.jvm.Gen.genDef(Gen.java:665)
      at com.sun.tools.javac.jvm.Gen.genClass(Gen.java:2198)
      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)

      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      public class Boom {
          Object a[];
          Object o = (a = null)[0];
      }
      ---------- END SOURCE ----------

      CUSTOMER SUBMITTED WORKAROUND :
      Don't write such a silly program.

            mcimadamore Maurizio Cimadamore
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: