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

interface method implemented as private causes IllegalAccessError at link time

    Details

    • Subcomponent:
    • Resolved In Build:
      1.2fcs
    • CPU:
      sparc
    • OS:
      solaris_2.5.1, solaris_2.6
    • Verification:
      Verified

      Description



      Name: szC45993 Date: 05/08/98



      In the following test, class invokeinterface02004a implements
      an interface method as private.

      When resolving a reference to such class with "new" instruction
      IllegalAccessError is thrown, even if no other access
      to this class is intended, as if such class was illegal itself.

      No place in the spec prescribes that such class as invokeinterface02004a
      is illegal, so resolving a reference to such class must pass
      without exceptions.

      However, for example, jvm must detect illegal (nonpublic) method
      implementation as *RUNTIME EXCEPTION* IllegalAccessError under the
      execution of the invokeinterface instruction for such implementation.

      SOURCE:


      --------------------- invokeinterface02501.jasm
      // Ident: %Z%%M% %I% %E%
      // Copyright %G% Sun Microsystems, Inc. All Rights Reserved

      package javasoft/sqe/tests/vm/invokeinterface/invokeinterface020/invokeinterface02004;

      public interface invokeinterface02004i {

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

      } // end invokeinterface02004i

      public class invokeinterface02004a implements invokeinterface02004i {

      //#############################################################################
      private /*public*/ Method f1:"(IF)I"
      //#############################################################################
      stack 1 locals 3
      {
      iconst_2;
      ireturn;
      }

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

      public Method p:"()V"
      stack 3 locals 1
      {
      new class invokeinterface02004a;
      dup;
      invokenonvirtual Method invokeinterface02004a.<init>:"()V";
      iconst_1;
      fconst_1;
      //#############################################################################
      // invokeinterface InterfaceMethod invokeinterface02004i.f1:"(IF)I", 3;
      //#############################################################################
      return;
      }

      } // end Class invokeinterface02004a

      public class invokeinterface02004 {

      public static Method run:"([Ljava/lang/String;Ljava/io/PrintStream;)I"
      stack 6 locals 4
      {
      try t1;
      new class invokeinterface02004a;
      dup;
      invokenonvirtual Method invokeinterface02004a.<init>:"()V";
      invokevirtual Method invokeinterface02004a.p:"()V";
      iconst_2; // no exception - test failed
      ireturn;
      endtry t1;
      catch t1 java/lang/IllegalAccessError;
      iconst_0; // passed
      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 invokeinterface02004
      ======================================================================

      Hook 5(hook5): test

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

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                never Tom Rodriguez
                Reporter:
                zsssunw Zss Zss (Inactive)
              • Votes:
                0 Vote for this issue
                Watchers:
                0 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:
                  Imported:
                  Indexed: