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

javac 1.5 compiler error, extended enums

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: P3 P3
    • None
    • 5.0
    • tools
    • sparc
    • solaris_8



      Name: gm110360 Date: 04/07/2004


      FULL PRODUCT VERSION :
      $ java -version
      java version "1.5.0-beta"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0-beta-b32c)
      Java HotSpot(TM) Client VM (build 1.5.0-beta-b32c, mixed mode)

      ADDITIONAL OS VERSION INFORMATION :
      SunOS xxx 5.8 Generic_108528-27 sun4u sparc SUNW,Ultra-5_10
      SunOS xxx 5.8 Generic_108528-27 sun4u sparc SUNW,Ultra-4
      Microsoft Windows 2000 [Version 5.00.2195]

      A DESCRIPTION OF THE PROBLEM :
      Compiling the following file fails with a compiler exception:

      $ less CompilerError.java

      final class Alphabet
      {
          private final String name;

          public Alphabet(final String name)
          {
              this.name = name;
          }

          public final String getName()
          {
              return name;
          }
      }

      public class CompilerError
      {
          public static void main(final String args[])
          {
              final Alphabet dna = new Alphabet("dna");

              enum Symbol
              {
                  a(dna), t(dna), g(dna), c(dna);

                  private final Alphabet alphabet;

                  Symbol(final Alphabet alphabet)
                  {
                      this.alphabet = alphabet;
                  }

                  public final Alphabet getAlphabet()
                  {
                      return alphabet;
                  }
              };

              for (Symbol s : Symbol.values())
              {
                  System.out.println("Symbol " + s);
              }
          }
      }

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      $ javac -source 1.5 -target 1.5 CompilerError.java

      ACTUAL -
      $ javac -source 1.5 -target 1.5 CompilerError.java
      An exception has occurred in the compiler (1.5.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.jvm.Code.emitop0(Code.java:471)
              at com.sun.tools.javac.jvm.Items$SelfItem.load(Items.java:347)
              at com.sun.tools.javac.jvm.Gen.visitIdent(Gen.java:2068)
              at com.sun.tools.javac.tree.Tree$Ident.accept(Tree.java:1006)
              at com.sun.tools.javac.jvm.Gen.genExpr(Gen.java:804)
              at com.sun.tools.javac.jvm.Gen.genArgs(Gen.java:822)
              at com.sun.tools.javac.jvm.Gen.visitNewClass(Gen.java:1692)
              at com.sun.tools.javac.tree.Tree$NewClass.accept(Tree.java:841)
              at com.sun.tools.javac.jvm.Gen.genExpr(Gen.java:804)
              at com.sun.tools.javac.jvm.Gen.visitAssign(Gen.java:1746)
              at com.sun.tools.javac.tree.Tree$Assign.accept(Tree.java:883)
              at com.sun.tools.javac.jvm.Gen.genExpr(Gen.java:804)
              at com.sun.tools.javac.jvm.Gen.visitExec(Gen.java:1599)
              at com.sun.tools.javac.tree.Tree$Exec.accept(Tree.java:734)
              at com.sun.tools.javac.jvm.Gen.genDef(Gen.java:651)
              at com.sun.tools.javac.jvm.Gen.genStat(Gen.java:686)
              at com.sun.tools.javac.jvm.Gen.genStat(Gen.java:672)
              at com.sun.tools.javac.jvm.Gen.genStats(Gen.java:723)
              at com.sun.tools.javac.jvm.Gen.visitBlock(Gen.java:970)
              at com.sun.tools.javac.tree.Tree$Block.accept(Tree.java:540)
              at com.sun.tools.javac.jvm.Gen.genDef(Gen.java:651)
              at com.sun.tools.javac.jvm.Gen.genStat(Gen.java:686)
              at com.sun.tools.javac.jvm.Gen.genMethod(Gen.java:908)
              at com.sun.tools.javac.jvm.Gen.visitMethodDef(Gen.java:844)
              at com.sun.tools.javac.tree.Tree$MethodDef.accept(Tree.java:482)
              at com.sun.tools.javac.jvm.Gen.genDef(Gen.java:651)
              at com.sun.tools.javac.jvm.Gen.genClass(Gen.java:2177)
              at com.sun.tools.javac.main.JavaCompiler.genCode(JavaCompiler.java:325)
              at com.sun.tools.javac.main.JavaCompiler.compile(JavaCompiler.java:467)
              at com.sun.tools.javac.main.Main.compile(Main.java:593)
              at com.sun.tools.javac.main.Main.compile(Main.java:545)
              at com.sun.tools.javac.Main.compile(Main.java:44)
              at com.sun.tools.javac.Main.main(Main.java:35)

      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      see description
      ---------- END SOURCE ----------
      (Incident Review ID: 246730)
      ======================================================================

            Unassigned Unassigned
            gmanwanisunw Girish Manwani (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: