blob: 22af9ad2b3f598aacd5f5338656c0cc8e0eb708e [file] [log] [blame]
Mikaƫl Peltier61633d42017-10-13 16:51:06 +02001// 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.
4package varhandle;
5
6import java.lang.invoke.MethodHandle;
7import java.lang.invoke.MethodHandles;
8import java.lang.invoke.MethodType;
9import java.lang.invoke.VarHandle;
10
11public 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}