Jinseong Jeon | d44a768 | 2017-08-08 11:53:05 -0700 | [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 naming001; |
| 5 | |
| 6 | import java.util.concurrent.atomic.AtomicIntegerFieldUpdater; |
| 7 | import java.util.concurrent.atomic.AtomicLongFieldUpdater; |
| 8 | import java.util.concurrent.atomic.AtomicReferenceFieldUpdater; |
| 9 | |
| 10 | public class Reflect { |
| 11 | void keep() throws ClassNotFoundException { |
| 12 | Class.forName("naming001.Reflect2"); |
| 13 | Class.forName("ClassThatDoesNotExists"); |
| 14 | } |
| 15 | |
| 16 | void keep2() throws NoSuchFieldException, SecurityException { |
| 17 | Reflect2.class.getField("fieldPublic"); |
| 18 | Reflect2.class.getField("fieldPrivate"); |
| 19 | } |
| 20 | |
| 21 | void keep3() throws NoSuchFieldException, SecurityException { |
| 22 | Reflect2.class.getDeclaredField("fieldPublic"); |
| 23 | Reflect2.class.getDeclaredField("fieldPrivate"); |
| 24 | } |
| 25 | |
| 26 | void keep4() throws SecurityException, NoSuchMethodException { |
| 27 | Reflect2.class.getMethod("m", new Class[] {naming001.Reflect2.A.class}); |
| 28 | Reflect2.class.getMethod("m", new Class[] {naming001.Reflect2.B.class}); |
| 29 | Reflect2.class.getMethod("methodThatDoesNotExist", |
| 30 | new Class[] {naming001.Reflect2.A.class}); |
| 31 | } |
| 32 | |
| 33 | void keep5() throws SecurityException, NoSuchMethodException { |
| 34 | Reflect2.class.getDeclaredMethod("m", new Class[] {naming001.Reflect2.A.class}); |
| 35 | Reflect2.class.getDeclaredMethod("m", new Class[] {naming001.Reflect2.B.class}); |
| 36 | } |
| 37 | |
| 38 | void keep6() throws SecurityException { |
| 39 | AtomicIntegerFieldUpdater.newUpdater(Reflect2.class, "fieldPublic"); |
| 40 | } |
| 41 | |
| 42 | void keep7() throws SecurityException { |
| 43 | AtomicLongFieldUpdater.newUpdater(Reflect2.class, "fieldLong"); |
| 44 | AtomicLongFieldUpdater.newUpdater(Reflect2.class, "fieldLong2"); |
| 45 | } |
| 46 | |
| 47 | void keep8() throws SecurityException { |
| 48 | AtomicReferenceFieldUpdater.newUpdater(Reflect2.class, Reflect2.A.class, "a"); |
| 49 | AtomicReferenceFieldUpdater.newUpdater(Reflect2.class, Reflect2.A.class, "b"); |
| 50 | AtomicReferenceFieldUpdater.newUpdater(Reflect2.class, Object.class, "c"); |
| 51 | } |
| 52 | } |
| 53 | |