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

NullPointerException optimized away in null.equals(null)

XMLWordPrintable



      Name: laC46010 Date: 08/06/98



      VM (versions 1.1.6-1.2FCS-D) with Symantec jit (Versions
      3.00.053-3.00.063)
      throws no NullPointerException when invoking equals() method with object

      reference which is pointed to null.
      This bug appears only with jit enabled on win32 port. It is possibly
      connected with for() statement optimization. Without for() all works
      fine.

      An example and VM diagnostics follow:
      -----------------------------------------------------------------
      novo35% cat clss14702.java
      public class clss14702 {
          static int ML = 1;
          public static void main(String argv[]) {
              clss14702 test = null;
              for (int i = 0; i < ML; i++)
                  try {
                      if ( test.equals(null) ) {
                          System.out.println("Error! NullPointerException
      should be thrown.");
                      }
                      System.out.println("Error! No exception.");
                      System.exit(2);
                  } catch (Exception e) {
                      if ( ! NullPointerException.class.isInstance(e) ) {
                          System.out.println("Error! Exception: " + e);
                          System.exit(2);
                      }
                  }
             System.out.println("Passed");
          }
      }

      > C:\ld14\java\dest\jdk1.2fcsD\win32\bin\java -version
      java version "1.2fcs"
      Classic VM (build JDK-1.2fcs-D, native threads)
      > C:\ld14\java\dest\jdk1.2fcsD\win32\bin\javac clss14702.java

      > C:\ld14\java\dest\jdk1.2fcsD\win32\bin\java -verify clss14702
      Error! NullPointerException should be thrown.
      Error! No exception.
      > echo %errorlevel%
      2
      -------------------------------------------------------

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

            dviswanasunw Deepa Viswanathan (Inactive)
            leosunw Leo Leo (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: