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

javac throws NullPointerException for break to label outside of class

XMLWordPrintable

    • beta
    • sparc
    • solaris_7
    • Verified



      Name: ngR10089 Date: 01/24/2001



      The test below causes the compiler to throw NullPointerException.

      -----------------test.java------------------------
       public class test {
          public static void main(String argv[]) {
              final int i = 6;
          M: {
                  new test(){
                      {
                          if (i != 5) break M;
                      }
                  };
                  System.out.println("failed : " + i);
              }
              System.out.println("passed : " + i);
          }
      }
      ----------------------------------------------------

      > java -version
      java version "1.4.0-beta"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.0-beta-b48)
      Java HotSpot(TM) Client VM (build 1.4beta-B48, mixed mode)

      > javac test.java
      An exception has occurred in the compiler (1.4.0-beta). Please file a bug at the
      Java Developer Connection (http://java.sun.com/cgi-bin/bugreport.cgi) 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.v8.comp.Gen._case(Gen.java:916)
      at com.sun.tools.javac.v8.tree.Tree$Break.visit(Tree.java:727)
      at com.sun.tools.javac.v8.comp.Gen.genDef(Gen.java:398)
      at com.sun.tools.javac.v8.comp.Gen.genStat(Gen.java:415)
      at com.sun.tools.javac.v8.comp.Gen.genStats(Gen.java:424)
      at com.sun.tools.javac.v8.comp.Gen._case(Gen.java:530)
      at com.sun.tools.javac.v8.tree.Tree$Block.visit(Tree.java:502)
      at com.sun.tools.javac.v8.comp.Gen.genDef(Gen.java:398)
      at com.sun.tools.javac.v8.comp.Gen.genStat(Gen.java:415)
      at com.sun.tools.javac.v8.comp.Gen.genStats(Gen.java:424)
      at com.sun.tools.javac.v8.comp.Gen._case(Gen.java:530)
      at com.sun.tools.javac.v8.tree.Tree$Block.visit(Tree.java:502)
      at com.sun.tools.javac.v8.comp.Gen.genDef(Gen.java:398)
      at com.sun.tools.javac.v8.comp.Gen.genStat(Gen.java:415)
      at com.sun.tools.javac.v8.comp.Gen.genMethod(Gen.java:500)
      at com.sun.tools.javac.v8.comp.Gen._case(Gen.java:475)
      at com.sun.tools.javac.v8.tree.Tree$MethodDef.visit(Tree.java:451)
      at com.sun.tools.javac.v8.comp.Gen.genDef(Gen.java:398)
      at com.sun.tools.javac.v8.comp.Gen.genClass(Gen.java:1415)
      at com.sun.tools.javac.v8.JavaCompiler.genCode(JavaCompiler.java:310)
      at com.sun.tools.javac.v8.JavaCompiler.compile(JavaCompiler.java:415)
      at com.sun.tools.javac.v8.Main.compile(Main.java:301)
      at com.sun.tools.javac.Main.main(Main.java:15)
      >


      ======================================================================

            gafter Neal Gafter (Inactive)
            nvgsunw Nvg Nvg (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: