1 /* /nodynamiccopyright/ */
   2 
   3 import java.lang.invoke.*;
   4 import java.lang.constant.*;
   5 import static java.lang.invoke.Intrinsics.*;
   6 import static java.lang.constant.DirectMethodHandleDesc.Kind.SETTER;
   7 
   8 public class FindSetterTest extends ConstantFoldingTest {
   9     String strField = "instance field";
  10 
  11     public static void main(String[] args) throws Throwable {
  12         new FindSetterTest().run();
  13     }
  14 
  15     void run() throws Throwable {
  16         test1(this);
  17     }
  18 
  19     @InstructionInfo(bytecodePosition=0, values={"CONSTANT_MethodHandle_info", "REF_putField"})
  20     void test1(FindSetterTest f) throws Throwable {
  21         final MethodHandle mhSetter = ldc(MethodHandleDesc.ofField(SETTER, ClassDesc.ofDescriptor("LFindSetterTest;"), "strField", ConstantDescs.CR_String));
  22         mhSetter.invoke(f, "new instance field value");
  23         check(f.strField.equals("new instance field value"));
  24     }
  25 }