test/hotspot/jtreg/vmTestbase/vm/runtime/defmeth/BasicTest.java
changeset 50735 2f2af62dfac7
parent 50243 4fac3c99487d
equal deleted inserted replaced
50734:0828a0f6676b 50735:2f2af62dfac7
    79         Class expectedClass;
    79         Class expectedClass;
    80         if (factory.getExecutionMode().equals("REFLECTION")) {
    80         if (factory.getExecutionMode().equals("REFLECTION")) {
    81             expectedClass = IllegalArgumentException.class;
    81             expectedClass = IllegalArgumentException.class;
    82         } else if (factory.getExecutionMode().equals("INVOKE_WITH_ARGS")) {
    82         } else if (factory.getExecutionMode().equals("INVOKE_WITH_ARGS")) {
    83             // Notes from JDK-8029926 which details reasons behind CCE.
    83             // Notes from JDK-8029926 which details reasons behind CCE.
    84         // The code below demonstrates the use of a MethodHandle
    84             // The code below demonstrates the use of a MethodHandle
    85             // of kind REF_invokeInterface pointing to method I.m.
    85             // of kind REF_invokeInterface pointing to method I.m.
    86             // Because 'invoke' is called, this MethodHandle is effectively
    86             // Because 'invoke' is called, this MethodHandle is effectively
    87             // wrapped in the type adaptations necessary to accept a C
    87             // wrapped in the type adaptations necessary to accept a C
    88             // as the first argument. ***Before we even get to the point
    88             // as the first argument. ***Before we even get to the point
    89             // of the invokeinterface call to I.m***, the adaptation
    89             // of the invokeinterface call to I.m***, the adaptation
   155 
   155 
   156         .run();
   156         .run();
   157     }
   157     }
   158 
   158 
   159     /*
   159     /*
   160      * Default method override w/ non-public concrete method
   160      * Default method override attempt w/ non-public concrete method.
   161      *
   161      * Private methods never override any other method.
   162      * interface I { void m() default {} }
   162      *
   163      * class C implements I {
   163      * interface I { int m() default { returns 1; } }
   164      *   [private/package-private/protected]
   164      * class C/D/E implements I {
   165      *   void m() {}
   165      *   [private/protected/package-private]
       
   166      *   int m() { returns 2;}
   166      * }
   167      * }
   167      *
   168      *
   168      */
   169      */
   169     @KnownFailure(modes = {INVOKE_EXACT, INVOKE_GENERIC, INVOKE_WITH_ARGS, INDY}) // NPE, instead of IAE
       
   170     public void testNonPublicOverride() {
   170     public void testNonPublicOverride() {
   171         TestBuilder b = factory.getBuilder();
   171         TestBuilder b = factory.getBuilder();
   172 
   172 
   173         Interface I = b.intf("I")
   173         Interface I = b.intf("I")
   174                 .defaultMethod("m","()V").emptyBody().build()
   174                 .defaultMethod("m", "()I").returns(1).build()
   175             .build();
   175             .build();
   176 
   176 
   177         ConcreteClass C = b.clazz("C").implement(I)
   177         ConcreteClass C = b.clazz("C").implement(I)
   178                 .concreteMethod("m", "()V").private_().emptyBody().build()
   178             .concreteMethod("m", "()I").private_().returns(2).build()
   179             .build();
   179             .build();
   180 
   180 
   181         ConcreteClass D = b.clazz("D").implement(I)
   181         ConcreteClass D = b.clazz("D").implement(I)
   182                 .concreteMethod("m", "()V").protected_().emptyBody().build()
   182                 .concreteMethod("m", "()I").protected_().returns(2).build()
   183             .build();
   183             .build();
   184 
   184 
   185          ConcreteClass E = b.clazz("E").implement(I)
   185          ConcreteClass E = b.clazz("E").implement(I)
   186                 .concreteMethod("m", "()V").package_private().emptyBody().build()
   186                 .concreteMethod("m", "()I").package_private().returns(2).build()
   187             .build();
   187             .build();
   188 
   188 
   189         b.test().callSite(I, C, "m", "()V").throws_(IllegalAccessError.class).done()
   189          b.test().callSite(I, C, "m", "()I").returns(1).done()
   190          .test().callSite(I, D, "m", "()V").throws_(IllegalAccessError.class).done()
   190           .test().callSite(I, D, "m", "()I").throws_(IllegalAccessError.class).done()
   191          .test().callSite(I, E, "m", "()V").throws_(IllegalAccessError.class).done()
   191           .test().callSite(I, E, "m", "()I").throws_(IllegalAccessError.class).done()
   192 
   192 
   193         .run();
   193         .run();
   194     }
   194     }
   195 
   195 
   196 
   196