annotate graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/jvmci/HotSpotVMConfigVerifier.java @ 21528:513f8d0ae27d

merge fixes
author Doug Simon <doug.simon@oracle.com>
date Fri, 22 May 2015 23:58:35 +0200
parents 1da7aef31a08
children
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 */
21526
1da7aef31a08 created com.oracle.graal.hotspot.jvmci package and moved classes destined for future JVMCI module into it (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 com.oracle.graal.compiler.common.*;
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
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 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
34 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
35 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
36
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 /**
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 * 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
39 * 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
40 * {@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
41 * 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
42 * 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
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 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
45
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 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
47 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
48 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
49 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
50 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
51 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
52 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
53 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
54 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
55 } catch (IOException 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
56 throw new GraalInternalError(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
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
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 * 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
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 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
64
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 * 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
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 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
69
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 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
71 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
72 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
73 } 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
74 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
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 }
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
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 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
79 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
80 }
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
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 @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
83 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
84 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
85 }
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
18656
de362aafce05 fixed findbugs issue
Doug Simon <doug.simon@oracle.com>
parents: 18652
diff changeset
87 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
88 if (!condition) {
18656
de362aafce05 fixed findbugs issue
Doug Simon <doug.simon@oracle.com>
parents: 18652
diff changeset
89 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
90 }
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
91 }
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
92
18656
de362aafce05 fixed findbugs issue
Doug Simon <doug.simon@oracle.com>
parents: 18652
diff changeset
93 void error(String message) {
de362aafce05 fixed findbugs issue
Doug Simon <doug.simon@oracle.com>
parents: 18652
diff changeset
94 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
95 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
96 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
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 }
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
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 @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
101 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
102 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
103 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
104
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 @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
106 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
107 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
108 }
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
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 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
111 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
112 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
113 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
114 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
115 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
116 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
117 }
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 }
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 } 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
120 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
121 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
122 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
123 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
124 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
125 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
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 }
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 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
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 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
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
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 * 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
138 */
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 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
140 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
141 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
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 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
144 }
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
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 @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
147 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
148 Executable callee = resolveMethod(owner, methodName, methodDesc);
18656
de362aafce05 fixed findbugs issue
Doug Simon <doug.simon@oracle.com>
parents: 18652
diff changeset
149 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
150 }
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 };
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 } 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
153 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
154 }
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
155 }
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
156 }