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

Linker throws wrong exception.

XMLWordPrintable

    • sparc
    • solaris_2.4



      Name: akC45999 Date: 11/18/96


      The section "6.4 The Virtual machine instruction set" of The Java Virtual Machine,
      subsection invokeinterface/Linking Exceptions defines which exception is to be
      thrown in each case. For example, if accessed method is happens to not be public,
      IllegalAccessError should be thrown.

      However, in all such cases linker throws java.lang.UnknownError.

      See the sample test. It takes into account that the jdk11 now performs
      this check during linking.

      -------------------------------------------------------- invokeinterface02002.jasm

      public interface i {

      public abstract Method f1:"(IF)I";

      } // end class i


      public class clss implements i {

      protected /*private*/ Method f1:"(IF)I" // method should be public
      stack 1 locals 1
      {
      iconst_0;
      ireturn;
      }

      public static Method run:"()V"
      stack 4 locals 1
      {
      new class clss;
      dup;
      invokenonvirtual Method clss.<init>:"()V";
      iconst_1;
      fconst_1;
      invokeinterface InterfaceMethod i.f1:"(IF)I", 3;
      return;
      }

      public Method <init>:"()V"
      stack 1 locals 1
      {
      aload_0;
      invokenonvirtual Method java/lang/Object.<init>:"()V";
      return;
      }

      } // end class clss


      public class invokeinterface02002 {

      public static Method run:"([Ljava/lang/String;Ljava/io/PrintStream;)I"
      stack 6 locals 2
      {
      try t1;
      new class clss;
      dup;
      invokenonvirtual Method clss.<init>:"()V";
      iconst_1;
      fconst_1;
      invokeinterface InterfaceMethod i.f1:"(IF)I", 3;
      iconst_1; // no exception - test failed
      ireturn;
      endtry t1;
      catch t1 java/lang/IllegalAccessError;
      iconst_0; // passed
      ireturn;
      catch t1 java/lang/UnknownError;
      iconst_2; // failed
      ireturn;
      catch t1 #0; // all other exceptions
      iconst_3; // failed
      ireturn;
      }

      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;
      }

      } // end Class invokeinterface02002

      -----------------------------------------------------------------

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

            fyellinsunw Frank Yellin (Inactive)
            rfqsunw Rfq Rfq (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: