1 /* 2 * Copyright (C) 2020 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 package art; 18 19 import java.lang.invoke.*; 20 import java.lang.ref.*; 21 import java.lang.reflect.*; 22 import java.util.*; 23 24 public class Test1981_Varhandles implements Test1981.VarHandler { Test1981_Varhandles()25 public Test1981_Varhandles() {} 26 doVarHandleTests()27 public boolean doVarHandleTests() { 28 return true; 29 } 30 findStaticVarHandle(MethodHandles.Lookup l, Class c, String n, Class t)31 public Object findStaticVarHandle(MethodHandles.Lookup l, Class c, String n, Class t) 32 throws Throwable { 33 return l.findStaticVarHandle(c, n, t); 34 } 35 get(Object vh)36 public Object get(Object vh) throws Throwable { 37 return ((VarHandle) vh).get(); 38 } 39 set(Object vh, Object v)40 public void set(Object vh, Object v) throws Throwable { 41 ((VarHandle) vh).set(v); 42 } instanceofVarHandle(Object v)43 public boolean instanceofVarHandle(Object v) { 44 return v instanceof VarHandle; 45 } getVarTypeName(Object v)46 public Object getVarTypeName(Object v) { 47 return ((VarHandle)v).varType().getName(); 48 } 49 } 50