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

javac accepts division by zero constant expressions in case expressions.

    Details

    • Subcomponent:
    • CPU:
      x86, sparc
    • OS:
      solaris_2.5.1, windows_95

      Description



      Name: ngC57085 Date: 07/03/98



      Compiler version "1.2beta4" (build JDK-1.2beta4-K, green threads, sunwjit)

      Java compiler crashes while trying to compile next test.
      This test also crashes all 1.2beta4 compiler versions,
      but bug is absent in 12.beta3.
      An example and compiler diagnostics follow:
      -------------------------------------------------------
      public class B {

         public static void main(String argv[]) {
            switch( 0 ){
             case 0/0:
            }
         }
      }

      > uname -a
      SunOS novo35 5.5.1 Generic_103640-12 sun4m sparc SUNW,SPARCstation-20
      > javac B.java
      java.lang.ClassCastException: sun.tools.tree.DivideExpression
              at sun.tools.tree.SwitchStatement.code(Compiled Code)
              at sun.tools.javac.SourceMember.code(Compiled Code)
              at sun.tools.javac.SourceMember.code(Compiled Code)
              at sun.tools.javac.SourceClass.compileClass(Compiled Code)
              at sun.tools.javac.SourceClass.compile(Compiled Code)
              at sun.tools.javac.Main.compile(Compiled Code)
              at sun.tools.javac.Main.main(Compiled Code)
      error: An exception has occurred in the compiler; please file a bug report (http://java.sun.com/cgi-bin/bugreport.cgi).
      1 error
      >
      -------------------------------------------------------

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

      Name: krT82822 Date: 08/04/99


      8/4/99 kevin.ryan@eng -- bugs 4154563 and 4230296 apply.

      //dummy.java
      package droopy;
      public class dummy {
              private class subdummy {
                      void test()
                      {
                              m_x = 3;
                      }
              }
              final int y = 270;
              static final int doo = Dippy.dad;
              static final int dum = Dippy.did;
              int m_x;
              Dippy m_dippy;
              public void main(String argv[])
      {
                      final int a = y;
                      m_x = a;
      for (int i=0; i<10; i++)
      {
      switch(i)
      {
      case 2:
      case 4:
      m_x++;
      break;
      case 6:
      m_x--;
      break;
                                      case dum:
                                              break;
      default:
      break;
      }
      }
      }
      }
      //Dippy.java
      package droopy;
      import droopy.dummy;
      public class Dippy
      {
              dummy m_dummy;
              public static final int did=dummy.doo;
              public static final int dad = 7;
      }
      //go.bat (make it)
      \jdk1.2.1\bin\javac Dippy.java dummy.java
      //result:
      java.lang.ClassCastException
              at sun.tools.tree.SwitchStatement.code(Compiled Code)
              at sun.tools.tree.ForStatement.code(ForStatement.java:156)
              at sun.tools.tree.CompoundStatement.code(Compiled Code)
              at sun.tools.javac.SourceMember.code(Compiled Code)
              at sun.tools.javac.SourceMember.code(Compiled Code)
              at sun.tools.javac.SourceClass.compileClass(Compiled Code)
              at sun.tools.javac.SourceClass.compile(Compiled Code)
              at sun.tools.javac.Main.compile(Compiled Code)
              at sun.tools.javac.Main.main(Main.java:733)
      error: An exception has occurred in the compiler; please file a bug report (http
      ://java.sun.com/cgi-bin/bugreport.cgi).
      1 error
      (Review ID: 93472)
      ======================================================================

        Attachments

          Activity

            People

            • Assignee:
              wmaddoxsunw William Maddox (Inactive)
              Reporter:
              duke J. Duke (Inactive)
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:
                Imported:
                Indexed: