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

no exceptions are thrown if method run of Thread described as static

    XMLWordPrintable

    Details

    • Subcomponent:
    • CPU:
      generic
    • OS:
      generic

      Description



      Name: ipC94532 Date: 10/07/99


      If method run() of java.lang.Thread described as static the exception
      IncompatibleClassChangeError must be thrown.
      But Java HotSpot (TM) Client VM does nothing.

      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.

      =========================================================================
      logs under SolarisOS (same under WinNT):

      novo50% java -version
      java version "1.3.0"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.3.0-H)
      Java HotSpot (TM) Client VM (build 1.3-H, interpreted mode)
      novo50% java -Xfuture run_test
      novo50%
      No errors, no exceptions, no logs.

      novo50% java -classic -version
      java version "1.3.0"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.3.0-H)
      Classic VM (build 1.3.0-H, green threads, nojit)
      novo50% java -classic -Xfuture run_test
      java.lang.IncompatibleClassChangeError: run_static_test: method run()V did not used to be static
      novo50%
      Correct behavior.

       
      =========================================================================
      The test couldn't be written in java. Javac does not allow
      statment "public static void run()" in class which extends java.lang.Thread.
      Source was taken from bug report #4197839.

      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

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

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

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              rschmidtsunw Rene Schmidt (Inactive)
              Reporter:
              duke J. Duke (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved:
                Imported:
                Indexed: