annotate graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/jvmci/HotSpotVMConfigVerifier.java @ 21539:d3002f7bd223

renamed com.oracle.graal.service.processor to com.oracle.jvmci.runtime.processor (JBS:GRAAL-53)
author Doug Simon <doug.simon@oracle.com>
date Mon, 25 May 2015 17:34:32 +0200
parents c1e2fdb5fea3
children abfdac702f14
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
18652
dfacef5b7958 remove uses of Unsafe in HotSpotVMConfig methods that may be executed on a deserialized HotSpotVMConfig object
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
1 /*
dfacef5b7958 remove uses of Unsafe in HotSpotVMConfig methods that may be executed on a deserialized HotSpotVMConfig object
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
2 * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
dfacef5b7958 remove uses of Unsafe in HotSpotVMConfig methods that may be executed on a deserialized HotSpotVMConfig object
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
dfacef5b7958 remove uses of Unsafe in HotSpotVMConfig methods that may be executed on a deserialized HotSpotVMConfig object
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
4 *
dfacef5b7958 remove uses of Unsafe in HotSpotVMConfig methods that may be executed on a deserialized HotSpotVMConfig object
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
5 * This code is free software; you can redistribute it and/or modify it
dfacef5b7958 remove uses of Unsafe in HotSpotVMConfig methods that may be executed on a deserialized HotSpotVMConfig object
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
6 * under the terms of the GNU General Public License version 2 only, as
dfacef5b7958 remove uses of Unsafe in HotSpotVMConfig methods that may be executed on a deserialized HotSpotVMConfig object
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
7 * published by the Free Software Foundation.
dfacef5b7958 remove uses of Unsafe in HotSpotVMConfig methods that may be executed on a deserialized HotSpotVMConfig object
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
8 *
dfacef5b7958 remove uses of Unsafe in HotSpotVMConfig methods that may be executed on a deserialized HotSpotVMConfig object
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
9 * This code is distributed in the hope that it will be useful, but WITHOUT
dfacef5b7958 remove uses of Unsafe in HotSpotVMConfig methods that may be executed on a deserialized HotSpotVMConfig object
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
dfacef5b7958 remove uses of Unsafe in HotSpotVMConfig methods that may be executed on a deserialized HotSpotVMConfig object
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
dfacef5b7958 remove uses of Unsafe in HotSpotVMConfig methods that may be executed on a deserialized HotSpotVMConfig object
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
12 * version 2 for more details (a copy is included in the LICENSE file that
dfacef5b7958 remove uses of Unsafe in HotSpotVMConfig methods that may be executed on a deserialized HotSpotVMConfig object
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
13 * accompanied this code).
dfacef5b7958 remove uses of Unsafe in HotSpotVMConfig methods that may be executed on a deserialized HotSpotVMConfig object
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
14 *
dfacef5b7958 remove uses of Unsafe in HotSpotVMConfig methods that may be executed on a deserialized HotSpotVMConfig object
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
15 * You should have received a copy of the GNU General Public License version
dfacef5b7958 remove uses of Unsafe in HotSpotVMConfig methods that may be executed on a deserialized HotSpotVMConfig object
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
16 * 2 along with this work; if not, write to the Free Software Foundation,
dfacef5b7958 remove uses of Unsafe in HotSpotVMConfig methods that may be executed on a deserialized HotSpotVMConfig object
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
dfacef5b7958 remove uses of Unsafe in HotSpotVMConfig methods that may be executed on a deserialized HotSpotVMConfig object
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
18 *
dfacef5b7958 remove uses of Unsafe in HotSpotVMConfig methods that may be executed on a deserialized HotSpotVMConfig object
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
dfacef5b7958 remove uses of Unsafe in HotSpotVMConfig methods that may be executed on a deserialized HotSpotVMConfig object
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
20 * or visit www.oracle.com if you need additional information or have any
dfacef5b7958 remove uses of Unsafe in HotSpotVMConfig methods that may be executed on a deserialized HotSpotVMConfig object
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
21 * questions.
dfacef5b7958 remove uses of Unsafe in HotSpotVMConfig methods that may be executed on a deserialized HotSpotVMConfig object
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
22 */
21538
c1e2fdb5fea3 removed more dependencies from JVMCI classes to non-JVMCI classes (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents: 18656
diff changeset
23 package com.oracle.graal.hotspot.jvmci;
18652
dfacef5b7958 remove uses of Unsafe in HotSpotVMConfig methods that may be executed on a deserialized HotSpotVMConfig object
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
24
dfacef5b7958 remove uses of Unsafe in HotSpotVMConfig methods that may be executed on a deserialized HotSpotVMConfig object
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
25 import static java.lang.String.*;
dfacef5b7958 remove uses of Unsafe in HotSpotVMConfig methods that may be executed on a deserialized HotSpotVMConfig object
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
26
dfacef5b7958 remove uses of Unsafe in HotSpotVMConfig methods that may be executed on a deserialized HotSpotVMConfig object
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
27 import java.io.*;
dfacef5b7958 remove uses of Unsafe in HotSpotVMConfig methods that may be executed on a deserialized HotSpotVMConfig object
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
28 import java.lang.reflect.*;
dfacef5b7958 remove uses of Unsafe in HotSpotVMConfig methods that may be executed on a deserialized HotSpotVMConfig object
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
29 import java.util.*;
dfacef5b7958 remove uses of Unsafe in HotSpotVMConfig methods that may be executed on a deserialized HotSpotVMConfig object
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
30
dfacef5b7958 remove uses of Unsafe in HotSpotVMConfig methods that may be executed on a deserialized HotSpotVMConfig object
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
31 import jdk.internal.org.objectweb.asm.*;
dfacef5b7958 remove uses of Unsafe in HotSpotVMConfig methods that may be executed on a deserialized HotSpotVMConfig object
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
32 import jdk.internal.org.objectweb.asm.Type;
dfacef5b7958 remove uses of Unsafe in HotSpotVMConfig methods that may be executed on a deserialized HotSpotVMConfig object
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
33 import sun.misc.*;
dfacef5b7958 remove uses of Unsafe in HotSpotVMConfig methods that may be executed on a deserialized HotSpotVMConfig object
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
34
dfacef5b7958 remove uses of Unsafe in HotSpotVMConfig methods that may be executed on a deserialized HotSpotVMConfig object
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
35 /**
dfacef5b7958 remove uses of Unsafe in HotSpotVMConfig methods that may be executed on a deserialized HotSpotVMConfig object
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
36 * A {@link ClassVisitor} that verifies {@link HotSpotVMConfig} does not access {@link Unsafe} from
dfacef5b7958 remove uses of Unsafe in HotSpotVMConfig methods that may be executed on a deserialized HotSpotVMConfig object
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
37 * any of its non-static, non-constructor methods. This ensures that a deserialized
dfacef5b7958 remove uses of Unsafe in HotSpotVMConfig methods that may be executed on a deserialized HotSpotVMConfig object
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
38 * {@link HotSpotVMConfig} object does not perform any unsafe reads on addresses that are only valid
dfacef5b7958 remove uses of Unsafe in HotSpotVMConfig methods that may be executed on a deserialized HotSpotVMConfig object
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
39 * in the context in which the object was serialized. Note that this does not catch cases where a
dfacef5b7958 remove uses of Unsafe in HotSpotVMConfig methods that may be executed on a deserialized HotSpotVMConfig object
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
40 * client uses an address stored in a {@link HotSpotVMConfig} field.
dfacef5b7958 remove uses of Unsafe in HotSpotVMConfig methods that may be executed on a deserialized HotSpotVMConfig object
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
41 */
dfacef5b7958 remove uses of Unsafe in HotSpotVMConfig methods that may be executed on a deserialized HotSpotVMConfig object
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
42 final class HotSpotVMConfigVerifier extends ClassVisitor {
dfacef5b7958 remove uses of Unsafe in HotSpotVMConfig methods that may be executed on a deserialized HotSpotVMConfig object
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
43
dfacef5b7958 remove uses of Unsafe in HotSpotVMConfig methods that may be executed on a deserialized HotSpotVMConfig object
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
44 public static boolean check() {
dfacef5b7958 remove uses of Unsafe in HotSpotVMConfig methods that may be executed on a deserialized HotSpotVMConfig object
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
45 Class<?> cls = HotSpotVMConfig.class;
dfacef5b7958 remove uses of Unsafe in HotSpotVMConfig methods that may be executed on a deserialized HotSpotVMConfig object
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
46 String classFilePath = "/" + cls.getName().replace('.', '/') + ".class";
dfacef5b7958 remove uses of Unsafe in HotSpotVMConfig methods that may be executed on a deserialized HotSpotVMConfig object
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
47 try {
dfacef5b7958 remove uses of Unsafe in HotSpotVMConfig methods that may be executed on a deserialized HotSpotVMConfig object
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
48 InputStream classfile = cls.getResourceAsStream(classFilePath);
dfacef5b7958 remove uses of Unsafe in HotSpotVMConfig methods that may be executed on a deserialized HotSpotVMConfig object
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
49 ClassReader cr = new ClassReader(Objects.requireNonNull(classfile, "Could not find class file for " + cls.getName()));
dfacef5b7958 remove uses of Unsafe in HotSpotVMConfig methods that may be executed on a deserialized HotSpotVMConfig object
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
50 ClassVisitor cv = new HotSpotVMConfigVerifier();
dfacef5b7958 remove uses of Unsafe in HotSpotVMConfig methods that may be executed on a deserialized HotSpotVMConfig object
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
51 cr.accept(cv, 0);
dfacef5b7958 remove uses of Unsafe in HotSpotVMConfig methods that may be executed on a deserialized HotSpotVMConfig object
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
52 return true;
dfacef5b7958 remove uses of Unsafe in HotSpotVMConfig methods that may be executed on a deserialized HotSpotVMConfig object
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
53 } catch (IOException e) {
21538
c1e2fdb5fea3 removed more dependencies from JVMCI classes to non-JVMCI classes (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents: 18656
diff changeset
54 throw new InternalError(e);
18652
dfacef5b7958 remove uses of Unsafe in HotSpotVMConfig methods that may be executed on a deserialized HotSpotVMConfig object
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
55 }
dfacef5b7958 remove uses of Unsafe in HotSpotVMConfig methods that may be executed on a deserialized HotSpotVMConfig object
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
56 }
dfacef5b7958 remove uses of Unsafe in HotSpotVMConfig methods that may be executed on a deserialized HotSpotVMConfig object
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
57
dfacef5b7958 remove uses of Unsafe in HotSpotVMConfig methods that may be executed on a deserialized HotSpotVMConfig object
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
58 /**
dfacef5b7958 remove uses of Unsafe in HotSpotVMConfig methods that may be executed on a deserialized HotSpotVMConfig object
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
59 * Source file context for error reporting.
dfacef5b7958 remove uses of Unsafe in HotSpotVMConfig methods that may be executed on a deserialized HotSpotVMConfig object
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
60 */
dfacef5b7958 remove uses of Unsafe in HotSpotVMConfig methods that may be executed on a deserialized HotSpotVMConfig object
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
61 String sourceFile = null;
dfacef5b7958 remove uses of Unsafe in HotSpotVMConfig methods that may be executed on a deserialized HotSpotVMConfig object
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
62
dfacef5b7958 remove uses of Unsafe in HotSpotVMConfig methods that may be executed on a deserialized HotSpotVMConfig object
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
63 /**
dfacef5b7958 remove uses of Unsafe in HotSpotVMConfig methods that may be executed on a deserialized HotSpotVMConfig object
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
64 * Line number for error reporting.
dfacef5b7958 remove uses of Unsafe in HotSpotVMConfig methods that may be executed on a deserialized HotSpotVMConfig object
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
65 */
dfacef5b7958 remove uses of Unsafe in HotSpotVMConfig methods that may be executed on a deserialized HotSpotVMConfig object
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
66 int lineNo = -1;
dfacef5b7958 remove uses of Unsafe in HotSpotVMConfig methods that may be executed on a deserialized HotSpotVMConfig object
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
67
dfacef5b7958 remove uses of Unsafe in HotSpotVMConfig methods that may be executed on a deserialized HotSpotVMConfig object
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
68 private static Class<?> resolve(String name) {
dfacef5b7958 remove uses of Unsafe in HotSpotVMConfig methods that may be executed on a deserialized HotSpotVMConfig object
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
69 try {
dfacef5b7958 remove uses of Unsafe in HotSpotVMConfig methods that may be executed on a deserialized HotSpotVMConfig object
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
70 return Class.forName(name.replace('/', '.'));
dfacef5b7958 remove uses of Unsafe in HotSpotVMConfig methods that may be executed on a deserialized HotSpotVMConfig object
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
71 } catch (ClassNotFoundException e) {
dfacef5b7958 remove uses of Unsafe in HotSpotVMConfig methods that may be executed on a deserialized HotSpotVMConfig object
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
72 throw new InternalError(e);
dfacef5b7958 remove uses of Unsafe in HotSpotVMConfig methods that may be executed on a deserialized HotSpotVMConfig object
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
73 }
dfacef5b7958 remove uses of Unsafe in HotSpotVMConfig methods that may be executed on a deserialized HotSpotVMConfig object
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
74 }
dfacef5b7958 remove uses of Unsafe in HotSpotVMConfig methods that may be executed on a deserialized HotSpotVMConfig object
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
75
dfacef5b7958 remove uses of Unsafe in HotSpotVMConfig methods that may be executed on a deserialized HotSpotVMConfig object
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
76 HotSpotVMConfigVerifier() {
dfacef5b7958 remove uses of Unsafe in HotSpotVMConfig methods that may be executed on a deserialized HotSpotVMConfig object
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
77 super(Opcodes.ASM5);
dfacef5b7958 remove uses of Unsafe in HotSpotVMConfig methods that may be executed on a deserialized HotSpotVMConfig object
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
78 }
dfacef5b7958 remove uses of Unsafe in HotSpotVMConfig methods that may be executed on a deserialized HotSpotVMConfig object
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
79
dfacef5b7958 remove uses of Unsafe in HotSpotVMConfig methods that may be executed on a deserialized HotSpotVMConfig object
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
80 @Override
dfacef5b7958 remove uses of Unsafe in HotSpotVMConfig methods that may be executed on a deserialized HotSpotVMConfig object
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
81 public void visitSource(String source, String debug) {
dfacef5b7958 remove uses of Unsafe in HotSpotVMConfig methods that may be executed on a deserialized HotSpotVMConfig object
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
82 this.sourceFile = source;
dfacef5b7958 remove uses of Unsafe in HotSpotVMConfig methods that may be executed on a deserialized HotSpotVMConfig object
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
83 }
dfacef5b7958 remove uses of Unsafe in HotSpotVMConfig methods that may be executed on a deserialized HotSpotVMConfig object
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
84
18656
de362aafce05 fixed findbugs issue
Doug Simon <doug.simon@oracle.com>
parents: 18652
diff changeset
85 void verify(boolean condition, String message) {
18652
dfacef5b7958 remove uses of Unsafe in HotSpotVMConfig methods that may be executed on a deserialized HotSpotVMConfig object
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
86 if (!condition) {
18656
de362aafce05 fixed findbugs issue
Doug Simon <doug.simon@oracle.com>
parents: 18652
diff changeset
87 error(message);
18652
dfacef5b7958 remove uses of Unsafe in HotSpotVMConfig methods that may be executed on a deserialized HotSpotVMConfig object
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
88 }
dfacef5b7958 remove uses of Unsafe in HotSpotVMConfig methods that may be executed on a deserialized HotSpotVMConfig object
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
89 }
dfacef5b7958 remove uses of Unsafe in HotSpotVMConfig methods that may be executed on a deserialized HotSpotVMConfig object
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
90
18656
de362aafce05 fixed findbugs issue
Doug Simon <doug.simon@oracle.com>
parents: 18652
diff changeset
91 void error(String message) {
de362aafce05 fixed findbugs issue
Doug Simon <doug.simon@oracle.com>
parents: 18652
diff changeset
92 String errorMessage = format("%s:%d: %s is not allowed in the context of compilation replay. The unsafe access should be moved into the %s constructor and the result cached in a field",
de362aafce05 fixed findbugs issue
Doug Simon <doug.simon@oracle.com>
parents: 18652
diff changeset
93 sourceFile, lineNo, message, HotSpotVMConfig.class.getSimpleName());
18652
dfacef5b7958 remove uses of Unsafe in HotSpotVMConfig methods that may be executed on a deserialized HotSpotVMConfig object
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
94 throw new InternalError(errorMessage);
dfacef5b7958 remove uses of Unsafe in HotSpotVMConfig methods that may be executed on a deserialized HotSpotVMConfig object
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
95
dfacef5b7958 remove uses of Unsafe in HotSpotVMConfig methods that may be executed on a deserialized HotSpotVMConfig object
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
96 }
dfacef5b7958 remove uses of Unsafe in HotSpotVMConfig methods that may be executed on a deserialized HotSpotVMConfig object
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
97
dfacef5b7958 remove uses of Unsafe in HotSpotVMConfig methods that may be executed on a deserialized HotSpotVMConfig object
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
98 @Override
dfacef5b7958 remove uses of Unsafe in HotSpotVMConfig methods that may be executed on a deserialized HotSpotVMConfig object
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
99 public MethodVisitor visitMethod(int access, String name, String d, String signature, String[] exceptions) {
dfacef5b7958 remove uses of Unsafe in HotSpotVMConfig methods that may be executed on a deserialized HotSpotVMConfig object
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
100 if (!Modifier.isStatic(access) && Modifier.isPublic(access) && !name.equals("<init>")) {
dfacef5b7958 remove uses of Unsafe in HotSpotVMConfig methods that may be executed on a deserialized HotSpotVMConfig object
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
101 return new MethodVisitor(Opcodes.ASM5) {
dfacef5b7958 remove uses of Unsafe in HotSpotVMConfig methods that may be executed on a deserialized HotSpotVMConfig object
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
102
dfacef5b7958 remove uses of Unsafe in HotSpotVMConfig methods that may be executed on a deserialized HotSpotVMConfig object
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
103 @Override
dfacef5b7958 remove uses of Unsafe in HotSpotVMConfig methods that may be executed on a deserialized HotSpotVMConfig object
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
104 public void visitLineNumber(int line, Label start) {
dfacef5b7958 remove uses of Unsafe in HotSpotVMConfig methods that may be executed on a deserialized HotSpotVMConfig object
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
105 lineNo = line;
dfacef5b7958 remove uses of Unsafe in HotSpotVMConfig methods that may be executed on a deserialized HotSpotVMConfig object
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
106 }
dfacef5b7958 remove uses of Unsafe in HotSpotVMConfig methods that may be executed on a deserialized HotSpotVMConfig object
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
107
dfacef5b7958 remove uses of Unsafe in HotSpotVMConfig methods that may be executed on a deserialized HotSpotVMConfig object
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
108 private Executable resolveMethod(String owner, String methodName, String methodDesc) {
dfacef5b7958 remove uses of Unsafe in HotSpotVMConfig methods that may be executed on a deserialized HotSpotVMConfig object
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
109 Class<?> declaringClass = resolve(owner);
dfacef5b7958 remove uses of Unsafe in HotSpotVMConfig methods that may be executed on a deserialized HotSpotVMConfig object
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
110 while (declaringClass != null) {
dfacef5b7958 remove uses of Unsafe in HotSpotVMConfig methods that may be executed on a deserialized HotSpotVMConfig object
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
111 if (methodName.equals("<init>")) {
dfacef5b7958 remove uses of Unsafe in HotSpotVMConfig methods that may be executed on a deserialized HotSpotVMConfig object
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
112 for (Constructor<?> c : declaringClass.getDeclaredConstructors()) {
dfacef5b7958 remove uses of Unsafe in HotSpotVMConfig methods that may be executed on a deserialized HotSpotVMConfig object
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
113 if (methodDesc.equals(Type.getConstructorDescriptor(c))) {
dfacef5b7958 remove uses of Unsafe in HotSpotVMConfig methods that may be executed on a deserialized HotSpotVMConfig object
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
114 return c;
dfacef5b7958 remove uses of Unsafe in HotSpotVMConfig methods that may be executed on a deserialized HotSpotVMConfig object
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
115 }
dfacef5b7958 remove uses of Unsafe in HotSpotVMConfig methods that may be executed on a deserialized HotSpotVMConfig object
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
116 }
dfacef5b7958 remove uses of Unsafe in HotSpotVMConfig methods that may be executed on a deserialized HotSpotVMConfig object
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
117 } else {
dfacef5b7958 remove uses of Unsafe in HotSpotVMConfig methods that may be executed on a deserialized HotSpotVMConfig object
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
118 Type[] argumentTypes = Type.getArgumentTypes(methodDesc);
dfacef5b7958 remove uses of Unsafe in HotSpotVMConfig methods that may be executed on a deserialized HotSpotVMConfig object
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
119 for (Method m : declaringClass.getDeclaredMethods()) {
dfacef5b7958 remove uses of Unsafe in HotSpotVMConfig methods that may be executed on a deserialized HotSpotVMConfig object
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
120 if (m.getName().equals(methodName)) {
dfacef5b7958 remove uses of Unsafe in HotSpotVMConfig methods that may be executed on a deserialized HotSpotVMConfig object
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
121 if (Arrays.equals(argumentTypes, Type.getArgumentTypes(m))) {
dfacef5b7958 remove uses of Unsafe in HotSpotVMConfig methods that may be executed on a deserialized HotSpotVMConfig object
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
122 if (Type.getReturnType(methodDesc).equals(Type.getReturnType(m))) {
dfacef5b7958 remove uses of Unsafe in HotSpotVMConfig methods that may be executed on a deserialized HotSpotVMConfig object
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
123 return m;
dfacef5b7958 remove uses of Unsafe in HotSpotVMConfig methods that may be executed on a deserialized HotSpotVMConfig object
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
124 }
dfacef5b7958 remove uses of Unsafe in HotSpotVMConfig methods that may be executed on a deserialized HotSpotVMConfig object
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
125 }
dfacef5b7958 remove uses of Unsafe in HotSpotVMConfig methods that may be executed on a deserialized HotSpotVMConfig object
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
126 }
dfacef5b7958 remove uses of Unsafe in HotSpotVMConfig methods that may be executed on a deserialized HotSpotVMConfig object
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
127 }
dfacef5b7958 remove uses of Unsafe in HotSpotVMConfig methods that may be executed on a deserialized HotSpotVMConfig object
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
128 }
dfacef5b7958 remove uses of Unsafe in HotSpotVMConfig methods that may be executed on a deserialized HotSpotVMConfig object
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
129 declaringClass = declaringClass.getSuperclass();
dfacef5b7958 remove uses of Unsafe in HotSpotVMConfig methods that may be executed on a deserialized HotSpotVMConfig object
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
130 }
dfacef5b7958 remove uses of Unsafe in HotSpotVMConfig methods that may be executed on a deserialized HotSpotVMConfig object
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
131 throw new NoSuchMethodError(owner + "." + methodName + methodDesc);
dfacef5b7958 remove uses of Unsafe in HotSpotVMConfig methods that may be executed on a deserialized HotSpotVMConfig object
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
132 }
dfacef5b7958 remove uses of Unsafe in HotSpotVMConfig methods that may be executed on a deserialized HotSpotVMConfig object
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
133
dfacef5b7958 remove uses of Unsafe in HotSpotVMConfig methods that may be executed on a deserialized HotSpotVMConfig object
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
134 /**
dfacef5b7958 remove uses of Unsafe in HotSpotVMConfig methods that may be executed on a deserialized HotSpotVMConfig object
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
135 * Checks whether a given method is allowed to be called.
dfacef5b7958 remove uses of Unsafe in HotSpotVMConfig methods that may be executed on a deserialized HotSpotVMConfig object
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
136 */
dfacef5b7958 remove uses of Unsafe in HotSpotVMConfig methods that may be executed on a deserialized HotSpotVMConfig object
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
137 private boolean checkInvokeTarget(Executable method) {
dfacef5b7958 remove uses of Unsafe in HotSpotVMConfig methods that may be executed on a deserialized HotSpotVMConfig object
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
138 if (method.getDeclaringClass().equals(Unsafe.class)) {
dfacef5b7958 remove uses of Unsafe in HotSpotVMConfig methods that may be executed on a deserialized HotSpotVMConfig object
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
139 return false;
dfacef5b7958 remove uses of Unsafe in HotSpotVMConfig methods that may be executed on a deserialized HotSpotVMConfig object
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
140 }
dfacef5b7958 remove uses of Unsafe in HotSpotVMConfig methods that may be executed on a deserialized HotSpotVMConfig object
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
141 return true;
dfacef5b7958 remove uses of Unsafe in HotSpotVMConfig methods that may be executed on a deserialized HotSpotVMConfig object
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
142 }
dfacef5b7958 remove uses of Unsafe in HotSpotVMConfig methods that may be executed on a deserialized HotSpotVMConfig object
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
143
dfacef5b7958 remove uses of Unsafe in HotSpotVMConfig methods that may be executed on a deserialized HotSpotVMConfig object
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
144 @Override
dfacef5b7958 remove uses of Unsafe in HotSpotVMConfig methods that may be executed on a deserialized HotSpotVMConfig object
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
145 public void visitMethodInsn(int opcode, String owner, String methodName, String methodDesc, boolean itf) {
dfacef5b7958 remove uses of Unsafe in HotSpotVMConfig methods that may be executed on a deserialized HotSpotVMConfig object
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
146 Executable callee = resolveMethod(owner, methodName, methodDesc);
18656
de362aafce05 fixed findbugs issue
Doug Simon <doug.simon@oracle.com>
parents: 18652
diff changeset
147 verify(checkInvokeTarget(callee), "invocation of " + callee);
18652
dfacef5b7958 remove uses of Unsafe in HotSpotVMConfig methods that may be executed on a deserialized HotSpotVMConfig object
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
148 }
dfacef5b7958 remove uses of Unsafe in HotSpotVMConfig methods that may be executed on a deserialized HotSpotVMConfig object
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
149 };
dfacef5b7958 remove uses of Unsafe in HotSpotVMConfig methods that may be executed on a deserialized HotSpotVMConfig object
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
150 } else {
dfacef5b7958 remove uses of Unsafe in HotSpotVMConfig methods that may be executed on a deserialized HotSpotVMConfig object
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
151 return null;
dfacef5b7958 remove uses of Unsafe in HotSpotVMConfig methods that may be executed on a deserialized HotSpotVMConfig object
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
152 }
dfacef5b7958 remove uses of Unsafe in HotSpotVMConfig methods that may be executed on a deserialized HotSpotVMConfig object
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
153 }
dfacef5b7958 remove uses of Unsafe in HotSpotVMConfig methods that may be executed on a deserialized HotSpotVMConfig object
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
154 }