author | mikael |
Tue, 22 Dec 2015 20:47:40 -0800 | |
changeset 35023 | ee10ca0129b2 |
parent 31751 | ec251536a004 |
child 42822 | a84956e7ee4d |
permissions | -rw-r--r-- |
17284
7cae365bf8d5
8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff
changeset
|
1 |
/* |
7cae365bf8d5
8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff
changeset
|
2 |
* Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. |
7cae365bf8d5
8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
7cae365bf8d5
8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff
changeset
|
4 |
* |
7cae365bf8d5
8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
7cae365bf8d5
8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
7cae365bf8d5
8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. Oracle designates this |
7cae365bf8d5
8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff
changeset
|
8 |
* particular file as subject to the "Classpath" exception as provided |
7cae365bf8d5
8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff
changeset
|
9 |
* by Oracle in the LICENSE file that accompanied this code. |
7cae365bf8d5
8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff
changeset
|
10 |
* |
7cae365bf8d5
8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff
changeset
|
11 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
7cae365bf8d5
8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff
changeset
|
12 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
7cae365bf8d5
8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff
changeset
|
13 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
7cae365bf8d5
8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff
changeset
|
14 |
* version 2 for more details (a copy is included in the LICENSE file that |
7cae365bf8d5
8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff
changeset
|
15 |
* accompanied this code). |
7cae365bf8d5
8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff
changeset
|
16 |
* |
7cae365bf8d5
8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff
changeset
|
17 |
* You should have received a copy of the GNU General Public License version |
7cae365bf8d5
8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff
changeset
|
18 |
* 2 along with this work; if not, write to the Free Software Foundation, |
7cae365bf8d5
8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff
changeset
|
19 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
7cae365bf8d5
8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff
changeset
|
20 |
* |
7cae365bf8d5
8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff
changeset
|
21 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
7cae365bf8d5
8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff
changeset
|
22 |
* or visit www.oracle.com if you need additional information or have any |
7cae365bf8d5
8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff
changeset
|
23 |
* questions. |
7cae365bf8d5
8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff
changeset
|
24 |
*/ |
7cae365bf8d5
8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff
changeset
|
25 |
|
7cae365bf8d5
8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff
changeset
|
26 |
package com.sun.tools.classfile; |
7cae365bf8d5
8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff
changeset
|
27 |
|
7cae365bf8d5
8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff
changeset
|
28 |
import java.util.ArrayList; |
7cae365bf8d5
8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff
changeset
|
29 |
import java.util.HashSet; |
7cae365bf8d5
8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff
changeset
|
30 |
import java.util.List; |
7cae365bf8d5
8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff
changeset
|
31 |
import java.util.Objects; |
7cae365bf8d5
8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff
changeset
|
32 |
import java.util.Set; |
7cae365bf8d5
8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff
changeset
|
33 |
import com.sun.tools.classfile.Instruction.TypeKind; |
7cae365bf8d5
8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff
changeset
|
34 |
import static com.sun.tools.classfile.ConstantPool.*; |
7cae365bf8d5
8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff
changeset
|
35 |
|
7cae365bf8d5
8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff
changeset
|
36 |
/** |
7cae365bf8d5
8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff
changeset
|
37 |
* A utility class to find where in a ClassFile references |
7cae365bf8d5
8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff
changeset
|
38 |
* a {@link CONSTANT_Methodref_info method}, |
31751 | 39 |
* a {@link CONSTANT_InterfaceMethodref_info interface method}, |
17284
7cae365bf8d5
8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff
changeset
|
40 |
* or a {@link CONSTANT_Fieldref_info field}. |
7cae365bf8d5
8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff
changeset
|
41 |
*/ |
7cae365bf8d5
8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff
changeset
|
42 |
public final class ReferenceFinder { |
7cae365bf8d5
8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff
changeset
|
43 |
/** |
7cae365bf8d5
8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff
changeset
|
44 |
* Filter for ReferenceFinder of what constant pool entries for reference lookup. |
7cae365bf8d5
8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff
changeset
|
45 |
*/ |
7cae365bf8d5
8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff
changeset
|
46 |
public interface Filter { |
7cae365bf8d5
8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff
changeset
|
47 |
/** |
7cae365bf8d5
8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff
changeset
|
48 |
* Decides if the given CPRefInfo entry should be accepted or filtered. |
7cae365bf8d5
8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff
changeset
|
49 |
* |
7cae365bf8d5
8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff
changeset
|
50 |
* @param cpool ConstantPool of the ClassFile being parsed |
7cae365bf8d5
8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff
changeset
|
51 |
* @param cpref constant pool entry representing a reference to |
7cae365bf8d5
8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff
changeset
|
52 |
* a fields method, and interface method. |
7cae365bf8d5
8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff
changeset
|
53 |
* @return {@code true} if accepted; otherwise {@code false} |
7cae365bf8d5
8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff
changeset
|
54 |
*/ |
7cae365bf8d5
8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff
changeset
|
55 |
boolean accept(ConstantPool cpool, CPRefInfo cpref); |
7cae365bf8d5
8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff
changeset
|
56 |
} |
7cae365bf8d5
8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff
changeset
|
57 |
|
7cae365bf8d5
8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff
changeset
|
58 |
/** |
7cae365bf8d5
8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff
changeset
|
59 |
* Visitor of individual method of a ClassFile that references the |
7cae365bf8d5
8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff
changeset
|
60 |
* accepted field, method, or interface method references. |
7cae365bf8d5
8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff
changeset
|
61 |
*/ |
7cae365bf8d5
8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff
changeset
|
62 |
public interface Visitor { |
7cae365bf8d5
8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff
changeset
|
63 |
/** |
7cae365bf8d5
8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff
changeset
|
64 |
* Invoked for a method containing one or more accepted CPRefInfo entries |
7cae365bf8d5
8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff
changeset
|
65 |
* |
7cae365bf8d5
8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff
changeset
|
66 |
* @param cf ClassFile |
7cae365bf8d5
8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff
changeset
|
67 |
* @param method Method that does the references the accepted references |
7cae365bf8d5
8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff
changeset
|
68 |
* @param refs Accepted constant pool method/field reference |
7cae365bf8d5
8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff
changeset
|
69 |
*/ |
7cae365bf8d5
8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff
changeset
|
70 |
void visit(ClassFile cf, Method method, List<CPRefInfo> refConstantPool); |
7cae365bf8d5
8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff
changeset
|
71 |
} |
7cae365bf8d5
8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff
changeset
|
72 |
|
7cae365bf8d5
8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff
changeset
|
73 |
private final Filter filter; |
7cae365bf8d5
8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff
changeset
|
74 |
private final Visitor visitor; |
7cae365bf8d5
8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff
changeset
|
75 |
|
7cae365bf8d5
8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff
changeset
|
76 |
/** |
7cae365bf8d5
8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff
changeset
|
77 |
* Constructor. |
7cae365bf8d5
8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff
changeset
|
78 |
*/ |
7cae365bf8d5
8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff
changeset
|
79 |
public ReferenceFinder(Filter filter, Visitor visitor) { |
7cae365bf8d5
8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff
changeset
|
80 |
this.filter = Objects.requireNonNull(filter); |
7cae365bf8d5
8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff
changeset
|
81 |
this.visitor = Objects.requireNonNull(visitor); |
7cae365bf8d5
8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff
changeset
|
82 |
} |
7cae365bf8d5
8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff
changeset
|
83 |
|
7cae365bf8d5
8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff
changeset
|
84 |
/** |
7cae365bf8d5
8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff
changeset
|
85 |
* Parses a given ClassFile and invoke the visitor if there is any reference |
7cae365bf8d5
8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff
changeset
|
86 |
* to the constant pool entries referencing field, method, or |
7cae365bf8d5
8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff
changeset
|
87 |
* interface method that are accepted. This method will return |
7cae365bf8d5
8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff
changeset
|
88 |
* {@code true} if there is one or more accepted constant pool entries |
7cae365bf8d5
8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff
changeset
|
89 |
* to lookup; otherwise, it will return {@code false}. |
7cae365bf8d5
8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff
changeset
|
90 |
* |
7cae365bf8d5
8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff
changeset
|
91 |
* @param cf ClassFile |
7cae365bf8d5
8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff
changeset
|
92 |
* @return {@code true} if the given class file is processed to lookup |
7cae365bf8d5
8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff
changeset
|
93 |
* references |
7cae365bf8d5
8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff
changeset
|
94 |
* @throws ConstantPoolException if an error of the constant pool |
7cae365bf8d5
8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff
changeset
|
95 |
*/ |
7cae365bf8d5
8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff
changeset
|
96 |
public boolean parse(ClassFile cf) throws ConstantPoolException { |
22163 | 97 |
List<Integer> cprefs = new ArrayList<>(); |
17284
7cae365bf8d5
8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff
changeset
|
98 |
int index = 1; |
7cae365bf8d5
8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff
changeset
|
99 |
for (ConstantPool.CPInfo cpInfo : cf.constant_pool.entries()) { |
7cae365bf8d5
8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff
changeset
|
100 |
if (cpInfo.accept(cpVisitor, cf.constant_pool)) { |
7cae365bf8d5
8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff
changeset
|
101 |
cprefs.add(index); |
7cae365bf8d5
8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff
changeset
|
102 |
} |
7cae365bf8d5
8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff
changeset
|
103 |
index += cpInfo.size(); |
7cae365bf8d5
8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff
changeset
|
104 |
} |
7cae365bf8d5
8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff
changeset
|
105 |
|
7cae365bf8d5
8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff
changeset
|
106 |
if (cprefs.isEmpty()) { |
7cae365bf8d5
8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff
changeset
|
107 |
return false; |
7cae365bf8d5
8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff
changeset
|
108 |
} |
7cae365bf8d5
8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff
changeset
|
109 |
|
7cae365bf8d5
8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff
changeset
|
110 |
for (Method m : cf.methods) { |
22163 | 111 |
Set<Integer> ids = new HashSet<>(); |
17284
7cae365bf8d5
8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff
changeset
|
112 |
Code_attribute c_attr = (Code_attribute) m.attributes.get(Attribute.Code); |
7cae365bf8d5
8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff
changeset
|
113 |
if (c_attr != null) { |
7cae365bf8d5
8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff
changeset
|
114 |
for (Instruction instr : c_attr.getInstructions()) { |
7cae365bf8d5
8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff
changeset
|
115 |
int idx = instr.accept(codeVisitor, cprefs); |
7cae365bf8d5
8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff
changeset
|
116 |
if (idx > 0) { |
7cae365bf8d5
8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff
changeset
|
117 |
ids.add(idx); |
7cae365bf8d5
8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff
changeset
|
118 |
} |
7cae365bf8d5
8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff
changeset
|
119 |
} |
7cae365bf8d5
8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff
changeset
|
120 |
} |
7cae365bf8d5
8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff
changeset
|
121 |
if (ids.size() > 0) { |
22163 | 122 |
List<CPRefInfo> refInfos = new ArrayList<>(ids.size()); |
17284
7cae365bf8d5
8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff
changeset
|
123 |
for (int id : ids) { |
7cae365bf8d5
8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff
changeset
|
124 |
refInfos.add(CPRefInfo.class.cast(cf.constant_pool.get(id))); |
7cae365bf8d5
8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff
changeset
|
125 |
} |
7cae365bf8d5
8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff
changeset
|
126 |
visitor.visit(cf, m, refInfos); |
7cae365bf8d5
8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff
changeset
|
127 |
} |
7cae365bf8d5
8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff
changeset
|
128 |
} |
7cae365bf8d5
8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff
changeset
|
129 |
return true; |
7cae365bf8d5
8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff
changeset
|
130 |
} |
7cae365bf8d5
8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff
changeset
|
131 |
|
7cae365bf8d5
8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff
changeset
|
132 |
private ConstantPool.Visitor<Boolean,ConstantPool> cpVisitor = |
7cae365bf8d5
8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff
changeset
|
133 |
new ConstantPool.Visitor<Boolean,ConstantPool>() |
7cae365bf8d5
8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff
changeset
|
134 |
{ |
7cae365bf8d5
8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff
changeset
|
135 |
public Boolean visitClass(CONSTANT_Class_info info, ConstantPool cpool) { |
7cae365bf8d5
8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff
changeset
|
136 |
return false; |
7cae365bf8d5
8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff
changeset
|
137 |
} |
7cae365bf8d5
8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff
changeset
|
138 |
|
7cae365bf8d5
8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff
changeset
|
139 |
public Boolean visitInterfaceMethodref(CONSTANT_InterfaceMethodref_info info, ConstantPool cpool) { |
7cae365bf8d5
8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff
changeset
|
140 |
return filter.accept(cpool, info); |
7cae365bf8d5
8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff
changeset
|
141 |
} |
7cae365bf8d5
8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff
changeset
|
142 |
|
7cae365bf8d5
8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff
changeset
|
143 |
public Boolean visitMethodref(CONSTANT_Methodref_info info, ConstantPool cpool) { |
7cae365bf8d5
8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff
changeset
|
144 |
return filter.accept(cpool, info); |
7cae365bf8d5
8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff
changeset
|
145 |
} |
7cae365bf8d5
8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff
changeset
|
146 |
|
7cae365bf8d5
8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff
changeset
|
147 |
public Boolean visitFieldref(CONSTANT_Fieldref_info info, ConstantPool cpool) { |
7cae365bf8d5
8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff
changeset
|
148 |
return filter.accept(cpool, info); |
7cae365bf8d5
8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff
changeset
|
149 |
} |
7cae365bf8d5
8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff
changeset
|
150 |
|
7cae365bf8d5
8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff
changeset
|
151 |
public Boolean visitDouble(CONSTANT_Double_info info, ConstantPool cpool) { |
7cae365bf8d5
8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff
changeset
|
152 |
return false; |
7cae365bf8d5
8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff
changeset
|
153 |
} |
7cae365bf8d5
8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff
changeset
|
154 |
|
7cae365bf8d5
8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff
changeset
|
155 |
public Boolean visitFloat(CONSTANT_Float_info info, ConstantPool cpool) { |
7cae365bf8d5
8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff
changeset
|
156 |
return false; |
7cae365bf8d5
8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff
changeset
|
157 |
} |
7cae365bf8d5
8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff
changeset
|
158 |
|
7cae365bf8d5
8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff
changeset
|
159 |
public Boolean visitInteger(CONSTANT_Integer_info info, ConstantPool cpool) { |
7cae365bf8d5
8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff
changeset
|
160 |
return false; |
7cae365bf8d5
8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff
changeset
|
161 |
} |
7cae365bf8d5
8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff
changeset
|
162 |
|
7cae365bf8d5
8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff
changeset
|
163 |
public Boolean visitInvokeDynamic(CONSTANT_InvokeDynamic_info info, ConstantPool cpool) { |
7cae365bf8d5
8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff
changeset
|
164 |
return false; |
7cae365bf8d5
8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff
changeset
|
165 |
} |
7cae365bf8d5
8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff
changeset
|
166 |
|
7cae365bf8d5
8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff
changeset
|
167 |
public Boolean visitLong(CONSTANT_Long_info info, ConstantPool cpool) { |
7cae365bf8d5
8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff
changeset
|
168 |
return false; |
7cae365bf8d5
8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff
changeset
|
169 |
} |
7cae365bf8d5
8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff
changeset
|
170 |
|
7cae365bf8d5
8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff
changeset
|
171 |
public Boolean visitNameAndType(CONSTANT_NameAndType_info info, ConstantPool cpool) { |
7cae365bf8d5
8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff
changeset
|
172 |
return false; |
7cae365bf8d5
8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff
changeset
|
173 |
} |
7cae365bf8d5
8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff
changeset
|
174 |
|
7cae365bf8d5
8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff
changeset
|
175 |
public Boolean visitMethodHandle(CONSTANT_MethodHandle_info info, ConstantPool cpool) { |
7cae365bf8d5
8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff
changeset
|
176 |
return false; |
7cae365bf8d5
8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff
changeset
|
177 |
} |
7cae365bf8d5
8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff
changeset
|
178 |
|
7cae365bf8d5
8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff
changeset
|
179 |
public Boolean visitMethodType(CONSTANT_MethodType_info info, ConstantPool cpool) { |
7cae365bf8d5
8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff
changeset
|
180 |
return false; |
7cae365bf8d5
8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff
changeset
|
181 |
} |
7cae365bf8d5
8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff
changeset
|
182 |
|
7cae365bf8d5
8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff
changeset
|
183 |
public Boolean visitString(CONSTANT_String_info info, ConstantPool cpool) { |
7cae365bf8d5
8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff
changeset
|
184 |
return false; |
7cae365bf8d5
8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff
changeset
|
185 |
} |
7cae365bf8d5
8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff
changeset
|
186 |
|
7cae365bf8d5
8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff
changeset
|
187 |
public Boolean visitUtf8(CONSTANT_Utf8_info info, ConstantPool cpool) { |
7cae365bf8d5
8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff
changeset
|
188 |
return false; |
7cae365bf8d5
8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff
changeset
|
189 |
} |
7cae365bf8d5
8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff
changeset
|
190 |
}; |
7cae365bf8d5
8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff
changeset
|
191 |
|
7cae365bf8d5
8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff
changeset
|
192 |
private Instruction.KindVisitor<Integer, List<Integer>> codeVisitor = |
7cae365bf8d5
8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff
changeset
|
193 |
new Instruction.KindVisitor<Integer, List<Integer>>() |
7cae365bf8d5
8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff
changeset
|
194 |
{ |
7cae365bf8d5
8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff
changeset
|
195 |
public Integer visitNoOperands(Instruction instr, List<Integer> p) { |
7cae365bf8d5
8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff
changeset
|
196 |
return 0; |
7cae365bf8d5
8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff
changeset
|
197 |
} |
7cae365bf8d5
8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff
changeset
|
198 |
|
7cae365bf8d5
8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff
changeset
|
199 |
public Integer visitArrayType(Instruction instr, TypeKind kind, List<Integer> p) { |
7cae365bf8d5
8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff
changeset
|
200 |
return 0; |
7cae365bf8d5
8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff
changeset
|
201 |
} |
7cae365bf8d5
8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff
changeset
|
202 |
|
7cae365bf8d5
8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff
changeset
|
203 |
public Integer visitBranch(Instruction instr, int offset, List<Integer> p) { |
7cae365bf8d5
8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff
changeset
|
204 |
return 0; |
7cae365bf8d5
8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff
changeset
|
205 |
} |
7cae365bf8d5
8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff
changeset
|
206 |
|
7cae365bf8d5
8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff
changeset
|
207 |
public Integer visitConstantPoolRef(Instruction instr, int index, List<Integer> p) { |
7cae365bf8d5
8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff
changeset
|
208 |
return p.contains(index) ? index : 0; |
7cae365bf8d5
8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff
changeset
|
209 |
} |
7cae365bf8d5
8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff
changeset
|
210 |
|
7cae365bf8d5
8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff
changeset
|
211 |
public Integer visitConstantPoolRefAndValue(Instruction instr, int index, int value, List<Integer> p) { |
7cae365bf8d5
8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff
changeset
|
212 |
return p.contains(index) ? index : 0; |
7cae365bf8d5
8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff
changeset
|
213 |
} |
7cae365bf8d5
8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff
changeset
|
214 |
|
7cae365bf8d5
8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff
changeset
|
215 |
public Integer visitLocal(Instruction instr, int index, List<Integer> p) { |
7cae365bf8d5
8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff
changeset
|
216 |
return 0; |
7cae365bf8d5
8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff
changeset
|
217 |
} |
7cae365bf8d5
8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff
changeset
|
218 |
|
7cae365bf8d5
8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff
changeset
|
219 |
public Integer visitLocalAndValue(Instruction instr, int index, int value, List<Integer> p) { |
7cae365bf8d5
8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff
changeset
|
220 |
return 0; |
7cae365bf8d5
8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff
changeset
|
221 |
} |
7cae365bf8d5
8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff
changeset
|
222 |
|
7cae365bf8d5
8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff
changeset
|
223 |
public Integer visitLookupSwitch(Instruction instr, int default_, int npairs, int[] matches, int[] offsets, List<Integer> p) { |
7cae365bf8d5
8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff
changeset
|
224 |
return 0; |
7cae365bf8d5
8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff
changeset
|
225 |
} |
7cae365bf8d5
8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff
changeset
|
226 |
|
7cae365bf8d5
8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff
changeset
|
227 |
public Integer visitTableSwitch(Instruction instr, int default_, int low, int high, int[] offsets, List<Integer> p) { |
7cae365bf8d5
8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff
changeset
|
228 |
return 0; |
7cae365bf8d5
8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff
changeset
|
229 |
} |
7cae365bf8d5
8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff
changeset
|
230 |
|
7cae365bf8d5
8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff
changeset
|
231 |
public Integer visitValue(Instruction instr, int value, List<Integer> p) { |
7cae365bf8d5
8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff
changeset
|
232 |
return 0; |
7cae365bf8d5
8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff
changeset
|
233 |
} |
7cae365bf8d5
8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff
changeset
|
234 |
|
7cae365bf8d5
8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff
changeset
|
235 |
public Integer visitUnknown(Instruction instr, List<Integer> p) { |
7cae365bf8d5
8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff
changeset
|
236 |
return 0; |
7cae365bf8d5
8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff
changeset
|
237 |
} |
7cae365bf8d5
8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff
changeset
|
238 |
}; |
7cae365bf8d5
8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff
changeset
|
239 |
} |
7cae365bf8d5
8013531: Provide a utility class in com.sun.tools.classfile to find field/method references
mchung
parents:
diff
changeset
|
240 |