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

Java compiler (javac) crashes on ternary operator type mismatch

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: P3
    • Resolution: Duplicate
    • Affects Version/s: 5.0
    • Fix Version/s: None
    • Component/s: tools
    • Labels:
    • Subcomponent:
    • CPU:
      x86
    • OS:
      windows_xp

      Description

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


      ADDITIONAL OS VERSION INFORMATION :
      Microsoft Windows XP professional edition SP2

      EXTRA RELEVANT SYSTEM CONFIGURATION :
      Not relevant.

      A DESCRIPTION OF THE PROBLEM :
      When compiling the hereafter example, javac crashes with the given stack trace.
      The program exhibits an erroneous assignement. Still javac should not crash.


      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Pase the Code snippet in the file SomeClass.java
      Then compile it:

      javac SomeClass.java

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      Should report the ternary operator type mismatch.


      ACTUAL -
      > javac SomeClass.java
      An exception has occurred in the compiler (1.5.0_05). 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.


      ERROR MESSAGES/STACK TRACES THAT OCCUR :

      java.lang.NullPointerException
              at com.sun.tools.javac.code.Types.lub(Types.java:2564)
              at com.sun.tools.javac.code.Types.lub(Types.java:2578)
              at com.sun.tools.javac.code.Types.lub(Types.java:2578)
              at com.sun.tools.javac.code.Types.lub(Types.java:2554)
              at com.sun.tools.javac.comp.Attr.condType1(Attr.java:885)
              at com.sun.tools.javac.comp.Attr.condType(Attr.java:808)
              at com.sun.tools.javac.comp.Attr.visitConditional(Attr.java:789)
              at com.sun.tools.javac.tree.Tree$Conditional.accept(Tree.java:699)
              at com.sun.tools.javac.comp.Attr.attribTree(Attr.java:280)
              at com.sun.tools.javac.comp.Attr.attribExpr(Attr.java:295)
              at com.sun.tools.javac.comp.Attr.visitAssign(Attr.java:1426)
              at com.sun.tools.javac.tree.Tree$Assign.accept(Tree.java:881)
              at com.sun.tools.javac.comp.Attr.attribTree(Attr.java:280)
              at com.sun.tools.javac.comp.Attr.attribExpr(Attr.java:302)
              at com.sun.tools.javac.comp.Attr.visitExec(Attr.java:897)
              at com.sun.tools.javac.tree.Tree$Exec.accept(Tree.java:728)
              at com.sun.tools.javac.comp.Attr.attribTree(Attr.java:280)
              at com.sun.tools.javac.comp.Attr.attribStat(Attr.java:315)
              at com.sun.tools.javac.comp.Attr.attribStats(Attr.java:331)
              at com.sun.tools.javac.comp.Attr.visitBlock(Attr.java:599)
              at com.sun.tools.javac.tree.Tree$Block.accept(Tree.java:535)
              at com.sun.tools.javac.comp.Attr.attribTree(Attr.java:280)
              at com.sun.tools.javac.comp.Attr.attribStat(Attr.java:315)
              at com.sun.tools.javac.comp.Attr.visitMethodDef(Attr.java:532)
              at com.sun.tools.javac.tree.Tree$MethodDef.accept(Tree.java:478)
              at com.sun.tools.javac.comp.Attr.attribTree(Attr.java:280)
              at com.sun.tools.javac.comp.Attr.attribStat(Attr.java:315)
              at com.sun.tools.javac.comp.Attr.attribClassBody(Attr.java:2473)
              at com.sun.tools.javac.comp.Attr.attribClass(Attr.java:2406)
              at com.sun.tools.javac.comp.Attr.attribClass(Attr.java:2355)
              at com.sun.tools.javac.main.JavaCompiler.compile(JavaCompiler.java:444)
              at com.sun.tools.javac.main.Main.compile(Main.java:592)
              at com.sun.tools.javac.main.Main.compile(Main.java:544)
              at com.sun.tools.javac.Main.compile(Main.java:67)
              at com.sun.tools.javac.Main.main(Main.java:52)


      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------

      public final class SomeClass {

          private double[][] _d;

          public void foo() {
              _d=_d==null ? new double[0] : _d;
          }

      }

      ---------- END SOURCE ----------

      CUSTOMER SUBMITTED WORKAROUND :
      The source code is not correct so no need for workaround.

      Release Regression From : 1.4.2
      The above release value was the last known release where this
      bug was known to work. Since then there has been a regression.

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              ahe Peter Ahe
              Reporter:
              gmanwanisunw Girish Manwani (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved:
                Imported:
                Indexed: