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

Incorrect exceptions while invocation static run

XMLWordPrintable

    • generic
    • generic



      Name: akC45999 Date: 12/16/98



      According contract of the "java.lang.Thread" class method run() must be nonstatic.
       
      Nonstatic methods are called by invokevirtual instruction. And JVM
      specification reads (instruction "invokevirtual", section "Linking
      Exceptions"):
      ...
      Otherwise, if the resolved method is a class (static) method, the
      invokevirtual instruction throws an IncompatibleClassChangeError.

      Therefore, if method run() described as static the exception
      IncompatibleClassChangeError must be thrown.

      But different JDK versions give different results.
      See sources and logs below.

      The test couldn't be written in java. Javac does not allow
      statment "public static void run()" in class which extends java.lang.Thread.

      =========================================================================
      sources:
      //------------ run_test.jasm ---------------
      public class run_static_test
      extends java/lang/Thread
      {
      public Method "<init>":"()V"
      stack 1 locals 1
      {
      aload_0;
      invokespecial Method java/lang/Thread."<init>":"()V";
      return;
      }

      public static Method run:"()V"
      // ^^^^^^ - incorrect
      stack 2 locals 1
      {
      getstatic Field java/lang/System.out:"Ljava/io/PrintStream;";
      ldc String "--run--";
      invokevirtual Method java/io/PrintStream.println:"(Ljava/lang/String;)V";
      return;
      }

      }// end Class run_static_test

      public class run_test
      {
      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;)V";
      return;
      }

      public static Method run:"([Ljava/lang/String;Ljava/io/PrintStream;)V"
      stack 2 locals 3
      {
      new class run_static_test;
      dup;
      invokespecial Method run_static_test."<init>":"()V";
      astore_2;
      aload_2;
      invokevirtual Method java/lang/Thread.start:"()V";
      return;
      }

      } // end Class run_test

      //end--------- run_test.jasm ---------------


      # -------part of script to run test:
      ....
      echo -------------------------------
      $VAR_VERSION/java -fullversion
      $VAR_VERSION/java -verify run_test
      ....


      =======================================================================
      logs:

      x86 (SunOS 5.5.1 Generic i86pc i386)
      -------------------------------
      java full version "JDK1.1.2G"
      java.lang.NoClassDefFoundError
      -------------------------------
      java full version "JDK1.1.6N"
      java.lang.NoClassDefFoundError
      -------------------------------
      java full version "JDK-1.2beta4-K"
      java.lang.IncompatibleClassChangeError: run_static_test: method run()V did not used to be static
      -------------------------------
      java full version "JDK-1.2fcs-M"
      java.lang.NullPointerException
      -------------------------------
      java full version "JDK-1.2fcs-O"
      java.lang.NullPointerException
      -------------------------------
      java full version "JDK-1.2fcs-P"
      java.lang.NullPointerException
      -------------------------------
      java full version "JDK-1.2fcs-R"
      java.lang.IncompatibleClassChangeError: run_static_test: method run()V did not used to be static
      -------------------------------
      java full version "JDK-1.2-U"
      java.lang.IncompatibleClassChangeError: run_static_test: method run()V did not used to be static
      -------------------------------
      java full version "JDK-1.2-V"
      java.lang.NullPointerException
      -------------------------------
      java full version "JDK-1.2.2-A"
      java.lang.IncompatibleClassChangeError: run_static_test: method run()V did not used to be static


      solaris: (SunOS 5.5.1 Generic_103640-12 sun4m sparc SUNW,SPARCstation-10)
      -------------------------------
      java full version "JDK1.1.1E"
      java.lang.NullPointerException
      -------------------------------
      java full version "JDK1.1.2G"
      java.lang.NullPointerException
      -------------------------------
      java full version "JDK1.1.3F"
      java.lang.NullPointerException
      -------------------------------
      java full version "JDK1.1.4G"
      java.lang.NullPointerException
      -------------------------------
      java full version "JDK1.1.5K"
      java.lang.NullPointerException
      -------------------------------
      java full version "JDK1.1.6N"
      java.lang.NullPointerException
      -------------------------------
      java full version "JDK1.1.7M"
      java.lang.NullPointerException
      -------------------------------
      java full version "JDK-1.2beta4-K"
      java.lang.IncompatibleClassChangeError: run_static_test: method run()V did not used to be static
      -------------------------------
      java full version "JDK-1.2fcs-M"
      java.lang.NullPointerException
      -------------------------------
      java full version "JDK-1.2fcs-O"
      java.lang.IncompatibleClassChangeError: run_static_test: method run()V did not used to be static
      -------------------------------
      java full version "JDK-1.2fcs-P"
      java.lang.IncompatibleClassChangeError: run_static_test: method run()V did not used to be static
      -------------------------------
      java full version "JDK-1.2fcs-R"
      java.lang.NullPointerException
      -------------------------------
      java full version "JDK-1.2-U"
      java.lang.NullPointerException
      -------------------------------
      java full version "JDK-1.2-V"
      java.lang.NullPointerException
      -------------------------------
      java full version "JDK-1.2.2-A
      java.lang.NullPointerException


      win32 (windows'95 P-100)
      -------------------------------
      java full version "JDK1.1.2G"
      Unable to initialize threads: cannot find class java/lang/Thread
      -------------------------------
      java full version "JDK1.1.3F"
      Unable to initialize threads: cannot find class java/lang/Thread
      -------------------------------
      java full version "JDK1.1.4J"
      java.lang.NoClassDefFoundError
      -------------------------------
      java full version "JDK1.1.5K"
      java.lang.NoClassDefFoundError
      -------------------------------
      java full version "JDK1.1.6N"
      java.lang.NoClassDefFoundError
      -------------------------------
      java full version "JDK1.1.7M"
      java.lang.NoClassDefFoundError
      -------------------------------
      JAVA.EXE full version "JDK-1.2beta4-K"
      java.lang.IncompatibleClassChangeError: run_static_test: method run()V did not used to be static
      -------------------------------
      JAVA.EXE full version "JDK-1.2fcs-M"
      java.lang.IncompatibleClassChangeError: run_static_test: method run()V did not used to be static
      -------------------------------
      JAVA.EXE full version "JDK-1.2fcs-O"
      java.lang.NullPointerException
      -------------------------------
      JAVA.EXE full version "JDK-1.2fcs-P"
      java.lang.IncompatibleClassChangeError: run_static_test: method run()V did not used to be static
      -------------------------------
      JAVA.EXE full version "JDK-1.2fcs-R"
      java.lang.NullPointerException
      -------------------------------
      JAVA.EXE full version "JDK-1.2-U"
      java.lang.NullPointerException
      -------------------------------
      JAVA.EXE full version "JDK-1.2fcs-V"
      java.lang.IncompatibleClassChangeError: run_static_test: method run()V did not used to be static
      -------------------------------
      java full version "JDK-1.2.2-A
      java.lang.IncompatibleClassChangeError: run_static_test: method run()V did not used to be static

      --------------------------------------------------------------------------
      ======================================================================

            collins Gary Collins (Inactive)
            rfqsunw Rfq Rfq (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: