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

NullPointerException is not thrown by invokespecial applied to null

XMLWordPrintable



      Name: laC46010 Date: 10/09/97



      JDK1.1.4 with JIT v. 57 fails to pass the following JCK-114a test cases:

      vm/instr/invokespecial/invokespecial021/invokespecial02101/invokespecial02101.html

      because it doesn't throw "java.lang.NullPointerException" as required by JVM spec
      (p. 263) when "invokespecial" is used with "null" object pointer.

      Modified version of "invokespecial02101" test below produces 98 as result
      instead of expected 95 that proves that method "proc2" has been indeed executed.
      This is a serious bug.

      ------------------------------------
      // Ident: @(#)invokespecial02101.jasm 1.1 96/12/25
      // Copyright 12/25/96 Sun Microsystems, Inc. All Rights Reserved
      package javasoft/sqe/tests/vm/invokespecial/invokespecial021/invokespecial02101;

      public class invokespecial02101
      extends java/lang/Object
      {
      // Compiled from invokespecial02101.java
      // Compiler version 3.45;

      private Field v1:"I";
      static Field v2:"I";
      private Field v3:"I";
      private Field v4:"I";
      private Field v5:"I";
      static Field ret_flag:"I";
      static Field iv:"Ljavasoft/sqe/tests/vm/invokespecial/invokespecial021/invokespecial02101/invokespecial02101;";

      private Method proc2:"(III)V"
      stack 2 locals 5
      {
      iconst_3;
      putstatic Field ret_flag:"I";
      L18: return;
      }

      public static Method proc1:"()V"
      stack 6 locals 4
      {
      iconst_1;
      istore_1;
      iconst_2;
      istore_2;
      iconst_3;
      istore_3;
      /*
      new class invokespecial02101;
      dup;

      invokespecial Method <init>:"()V";

      putstatic Field iv:"Ljavasoft/sqe/tests/vm/invokespecial/invokespecial021/invokespecial02101/invokespecial02101;";
      */
      getstatic Field iv:"Ljavasoft/sqe/tests/vm/invokespecial/invokespecial021/invokespecial02101/invokespecial02101;";
      iload_1;
      iload_2;
      iload_3;
      try t1;
      invokespecial Method proc2:"(III)V"; //"Otherwise, if <i>objectref</i> is <code>null</code>, the <i>invokespecial</i> instruction throws a <code>NullPointerException</code>."
      endtry t1;
      // iconst_2;
      // putstatic Field ret_flag:"I";
      return;
      catch t1 java/lang/NullPointerException;
      iconst_0;
      putstatic Field ret_flag:"I";
      return;
      }

      public static Method main:"([Ljava/lang/String;)V"
      stack 2 locals 1
      {
      aload_0;
      getstatic Field java/lang/System.out:"Ljava/io/PrintStream;";
      invokestatic Method run:"([Ljava/lang/String;Ljava/io/PrintStream;)I";
      bipush 95/*STATUS_TEMP*/;
      iadd;
      invokestatic Method java/lang/System.exit:"(I)V";
      return;
      }

      public static Method run:"([Ljava/lang/String;Ljava/io/PrintStream;)I"
      stack 1 locals 2
      {
      invokestatic Method proc1:"()V";
      getstatic Field ret_flag:"I";
      ireturn;
      }

      public Method <init>:"()V"
      stack 2 locals 1
      {
      aload_0;

      /// invokenonvirtual Method java/lang/Object.<init>:"()V";
      invokespecial Method java/lang/Object.<init>:"()V";

      aload_0;
      iconst_5;
      putfield Field v1:"I";
      aload_0;
      iconst_3;
      putfield Field v3:"I";
      aload_0;
      iconst_2;
      putfield Field v4:"I";
      aload_0;
      iconst_1;
      putfield Field v5:"I";
      return;
      }

      static Method <clinit>:"()V"
      stack 1 locals 0
      {
      iconst_4;
      putstatic Field v2:"I";
      return;
      }

      } // end Class invokespecial02101
      ---------------------------------------------------------


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

            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: