1 /* /nodynamiccopyright/ */
   2 
   3 import java.lang.invoke.*;
   4 import java.lang.constant.*;
   5 import static java.lang.invoke.Intrinsics.*;
   6 
   7 public class FindVirtualTest02 extends ConstantFoldingTest {
   8     class Foo {
   9         String foo() {
  10             return "invoking method Foo.foo()";
  11         }
  12     }
  13 
  14     public static void main(String[] args) throws Throwable {
  15         new FindVirtualTest02().run();
  16     }
  17 
  18     void run() throws Throwable {
  19         Foo f = new Foo();
  20         test1(f);
  21     }
  22 
  23     @InstructionInfo(bytecodePosition=0, values={"CONSTANT_MethodHandle_info", "REF_invokeVirtual"})
  24     void test1(Foo f) throws Throwable {
  25         final MethodTypeDesc mt = MethodTypeDesc.ofDescriptor("()Ljava/lang/String;");
  26         MethodHandle mh2 = ldc(MethodHandleDesc.of(DirectMethodHandleDesc.Kind.VIRTUAL, ClassDesc.ofDescriptor("LFindVirtualTest02$Foo;"), "foo", mt));
  27         check(mh2.invoke(f).toString().equals("invoking method Foo.foo()"));
  28     }
  29 }