Mikaƫl Peltier | 61633d4 | 2017-10-13 16:51:06 +0200 | [diff] [blame] | 1 | // Copyright (c) 2017, the R8 project authors. Please see the AUTHORS file |
| 2 | // for details. All rights reserved. Use of this source code is governed by a |
| 3 | // BSD-style license that can be found in the LICENSE file. |
| 4 | package varhandle; |
| 5 | |
| 6 | import java.lang.invoke.MethodHandle; |
| 7 | import java.lang.invoke.MethodHandles; |
| 8 | import java.lang.invoke.MethodType; |
| 9 | import java.lang.invoke.VarHandle; |
| 10 | |
| 11 | public class VarHandleTests { |
| 12 | |
| 13 | private static boolean staticField = true; |
| 14 | |
| 15 | public static void test1() throws NoSuchFieldException, IllegalAccessException { |
| 16 | VarHandle vb = MethodHandles.lookup() |
| 17 | .findStaticVarHandle(VarHandleTests.class, "staticField", boolean.class); |
| 18 | System.out.println((boolean) vb.get()); |
| 19 | } |
| 20 | |
| 21 | public static void main(String[] args) throws NoSuchFieldException, IllegalAccessException { |
| 22 | VarHandleTests.test1(); |
| 23 | } |
| 24 | } |