Debian Codegraph @

test/2012-structural-redefinition-failures-jni-id/src-art/Main.java

raw
1 /*
2 * Copyright (C) 2017 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 import art.*;
18
19 public class Main {
20 public static void Check(Class[] klasses) {
21 for (Class k : klasses) {
22 try {
23 boolean res = Redefinition.isStructurallyModifiable(k);
24 System.out.println("Is Structurally modifiable " + k + " " + res);
25 } catch (Exception e) {
26 System.out.println("Got exception " + e + " during check modifiablity of " + k);
27 e.printStackTrace(System.out);
28 }
29 }
30 }
31
32 public static class C1 {
33 public Object o;
34 public void foobar() {}
35 }
36 public static class C2 extends C1 {
37 public static Object o;
38 public static void foo() {}
39 }
40 public static class C3 extends C2 {
41 public Object j;
42 public void bar() {}
43 }
44
45 public static void doTest() throws Exception {
46 Class[] classes = new Class[] {
47 C1.class,
48 C2.class,
49 C3.class,
50 };
51 System.out.println("Checking classes");
52 Check(classes);
53 System.out.println("Setting C2 as having pointer-ids used and checking classes");
54 SetPointerIdsUsed(C2.class);
55 Check(classes);
56 }
57 public static native void SetPointerIdsUsed(Class<?> k);
58 public static void main(String[] args) throws Exception {
59 // Redefinition.setTestConfiguration(Redefinition.Config.COMMON_REDEFINE);
60 doTest();
61 }
62 }