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

javac crashes when a variable is not declared

XMLWordPrintable

    • b32
    • 7
    • x86
    • linux

      FULL PRODUCT VERSION :
      java version "1.7.0-ea"
      Java(TM) SE Runtime Environment (build 1.7.0-ea-b32)
      Java HotSpot(TM) 64-Bit Server VM (build 14.0-b01, mixed mode)


      ADDITIONAL OS VERSION INFORMATION :
      Ubuntu 8.04 :
      Linux erevan 2.6.24-20-generic #1 SMP Mon Jul 28 13:06:07 UTC 2008 x86_64 GNU/Linux

      EXTRA RELEVANT SYSTEM CONFIGURATION :
      Processor is a Core 2 Duo T7100.
      The shell used is zsh.


      A DESCRIPTION OF THE PROBLEM :
      The compiler crashes with the joind error message, when compiling the joined class file.
      I compile with "javac Bug.java".
      Actually, the source is not a _compilable_ java source, that's precisely the point :
      the compiler crashes because of the variable "a" is not declared (or a least it
      seems to be the reason).

      There is no real impact, since the error message is almost printed : hence it's possible
      to work. But it's not very "user friendly", and the compiler won't print any other error
      message.


      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Just compile the program with javac in a terminal.

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      The compiler should have printed, like the javac found in JDK6 :

      [erevan:beaver] ~% javac Bug.java
        Bug.java:4: cannot find symbol
      symbol : variable a
      location: class Bug
      a = 1;
      ^
      1 error
      zsh: exit 1 javac Bug.java
      [erevan:beaver] ~%

      ACTUAL -
      See error message.

      ERROR MESSAGES/STACK TRACES THAT OCCUR :
      [erevan:beaver] ~% javac Bug.java
        Bug.java:4: cannot find symbol
      symbol : variable a
      location: class Bug
      a = 1;
      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.StringIndexOutOfBoundsException: String index out of range: 8
      at java.lang.String.charAt(String.java:694)
      at com.sun.tools.javac.util.Log.printErrLine(Log.java:251)
      at com.sun.tools.javac.util.Log.writeDiagnostic(Log.java:343)
      at com.sun.tools.javac.util.Log.report(Log.java:315)
      at com.sun.tools.javac.util.AbstractLog.error(AbstractLog.java:86)
      at com.sun.tools.javac.comp.Resolve$ResolveError.report(Resolve.java:1667)
      at com.sun.tools.javac.comp.Resolve.access(Resolve.java:1093)
      at com.sun.tools.javac.comp.Resolve.access(Resolve.java:1113)
      at com.sun.tools.javac.comp.Resolve.resolveIdent(Resolve.java:1176)
      at com.sun.tools.javac.comp.Attr.visitIdent(Attr.java:1755)
      at com.sun.tools.javac.tree.JCTree$JCIdent.accept(JCTree.java:1679)
      at com.sun.tools.javac.comp.Attr.attribTree(Attr.java:372)
      at com.sun.tools.javac.comp.Attr.visitAssign(Attr.java:1594)
      at com.sun.tools.javac.tree.JCTree$JCAssign.accept(JCTree.java:1440)
      at com.sun.tools.javac.comp.Attr.attribTree(Attr.java:372)
      at com.sun.tools.javac.comp.Attr.attribExpr(Attr.java:396)
      at com.sun.tools.javac.comp.Attr.visitExec(Attr.java:1066)
      at com.sun.tools.javac.tree.JCTree$JCExpressionStatement.accept(JCTree.java:1142)
      at com.sun.tools.javac.comp.Attr.attribTree(Attr.java:372)
      at com.sun.tools.javac.comp.Attr.attribStat(Attr.java:409)
      at com.sun.tools.javac.comp.Attr.attribStats(Attr.java:425)
      at com.sun.tools.javac.comp.Attr.visitBlock(Attr.java:764)
      at com.sun.tools.javac.tree.JCTree$JCBlock.accept(JCTree.java:765)
      at com.sun.tools.javac.comp.Attr.attribTree(Attr.java:372)
      at com.sun.tools.javac.comp.Attr.attribStat(Attr.java:409)
      at com.sun.tools.javac.comp.Attr.visitMethodDef(Attr.java:683)
      at com.sun.tools.javac.tree.JCTree$JCMethodDecl.accept(JCTree.java:653)
      at com.sun.tools.javac.comp.Attr.attribTree(Attr.java:372)
      at com.sun.tools.javac.comp.Attr.attribStat(Attr.java:409)
      at com.sun.tools.javac.comp.Attr.attribClassBody(Attr.java:2745)
      at com.sun.tools.javac.comp.Attr.attribClass(Attr.java:2671)
      at com.sun.tools.javac.comp.Attr.attribClass(Attr.java:2607)
      at com.sun.tools.javac.main.JavaCompiler.attribute(JavaCompiler.java:1057)
      at com.sun.tools.javac.main.JavaCompiler.compile2(JavaCompiler.java:786)
      at com.sun.tools.javac.main.JavaCompiler.compile(JavaCompiler.java:751)
      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)
      zsh: exit 4 javac Bug.java
      [erevan:beaver] ~%


      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      public class Bug {
      public static void main(String[] args) {
      a = 1;
      }
      }
      ---------- END SOURCE ----------

      Release Regression From : 7
      The above release value was the last known release where this
      bug was not reproducible. Since then there has been a regression.

            mcimadamore Maurizio Cimadamore
            ndcosta Nelson Dcosta (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: