author | zmajo |
Wed, 15 Jun 2016 14:27:58 +0200 | |
changeset 39421 | a9652c919db8 |
parent 33160 | c59f1676d27e |
permissions | -rw-r--r-- |
33160 | 1 |
/* |
2 |
* Copyright (c) 2009, 2014, Oracle and/or its affiliates. All rights reserved. |
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
|
4 |
* |
|
5 |
* This code is free software; you can redistribute it and/or modify it |
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
|
7 |
* published by the Free Software Foundation. |
|
8 |
* |
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
|
13 |
* accompanied this code). |
|
14 |
* |
|
15 |
* You should have received a copy of the GNU General Public License version |
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
|
18 |
* |
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
|
20 |
* or visit www.oracle.com if you need additional information or have any |
|
21 |
* questions. |
|
22 |
*/ |
|
23 |
package jdk.vm.ci.meta; |
|
24 |
||
25 |
/** |
|
26 |
* Represents the runtime representation of the constant pool that is used by the compiler when |
|
27 |
* parsing bytecode. Provides methods to look up a constant pool entry without performing |
|
28 |
* resolution. They are used during compilation. |
|
29 |
*/ |
|
30 |
public interface ConstantPool { |
|
31 |
||
32 |
/** |
|
33 |
* Returns the number of entries the constant pool. |
|
34 |
* |
|
35 |
* @return number of entries in the constant pool |
|
36 |
*/ |
|
37 |
int length(); |
|
38 |
||
39 |
/** |
|
40 |
* Ensures that the type referenced by the specified constant pool entry is loaded and |
|
41 |
* initialized. This can be used to compile time resolve a type. It works for field, method, or |
|
42 |
* type constant pool entries. |
|
43 |
* |
|
44 |
* @param cpi the index of the constant pool entry that references the type |
|
45 |
* @param opcode the opcode of the instruction that references the type |
|
46 |
*/ |
|
47 |
void loadReferencedType(int cpi, int opcode); |
|
48 |
||
49 |
/** |
|
50 |
* Looks up a reference to a field. If {@code opcode} is non-negative, then resolution checks |
|
39421
a9652c919db8
8157181: Compilers accept modification of final fields outside initializer methods
zmajo
parents:
33160
diff
changeset
|
51 |
* specific to the bytecode it denotes are performed if the field is already resolved. Checks |
a9652c919db8
8157181: Compilers accept modification of final fields outside initializer methods
zmajo
parents:
33160
diff
changeset
|
52 |
* for some bytecodes require the method that contains the bytecode to be specified. Should |
33160 | 53 |
* any of these checks fail, an unresolved field reference is returned. |
54 |
* |
|
55 |
* @param cpi the constant pool index |
|
56 |
* @param opcode the opcode of the instruction for which the lookup is being performed or |
|
57 |
* {@code -1} |
|
39421
a9652c919db8
8157181: Compilers accept modification of final fields outside initializer methods
zmajo
parents:
33160
diff
changeset
|
58 |
* @param method the method for which the lookup is being performed |
33160 | 59 |
* @return a reference to the field at {@code cpi} in this pool |
60 |
* @throws ClassFormatError if the entry at {@code cpi} is not a field |
|
61 |
*/ |
|
39421
a9652c919db8
8157181: Compilers accept modification of final fields outside initializer methods
zmajo
parents:
33160
diff
changeset
|
62 |
JavaField lookupField(int cpi, ResolvedJavaMethod method, int opcode); |
33160 | 63 |
|
64 |
/** |
|
65 |
* Looks up a reference to a method. If {@code opcode} is non-negative, then resolution checks |
|
66 |
* specific to the bytecode it denotes are performed if the method is already resolved. Should |
|
67 |
* any of these checks fail, an unresolved method reference is returned. |
|
68 |
* |
|
69 |
* @param cpi the constant pool index |
|
70 |
* @param opcode the opcode of the instruction for which the lookup is being performed or |
|
71 |
* {@code -1} |
|
72 |
* @return a reference to the method at {@code cpi} in this pool |
|
73 |
* @throws ClassFormatError if the entry at {@code cpi} is not a method |
|
74 |
*/ |
|
75 |
JavaMethod lookupMethod(int cpi, int opcode); |
|
76 |
||
77 |
/** |
|
78 |
* Looks up a reference to a type. If {@code opcode} is non-negative, then resolution checks |
|
79 |
* specific to the bytecode it denotes are performed if the type is already resolved. Should any |
|
80 |
* of these checks fail, an unresolved type reference is returned. |
|
81 |
* |
|
82 |
* @param cpi the constant pool index |
|
83 |
* @param opcode the opcode of the instruction for which the lookup is being performed or |
|
84 |
* {@code -1} |
|
85 |
* @return a reference to the compiler interface type |
|
86 |
*/ |
|
87 |
JavaType lookupType(int cpi, int opcode); |
|
88 |
||
89 |
/** |
|
90 |
* Looks up an Utf8 string. |
|
91 |
* |
|
92 |
* @param cpi the constant pool index |
|
93 |
* @return the Utf8 string at index {@code cpi} in this constant pool |
|
94 |
*/ |
|
95 |
String lookupUtf8(int cpi); |
|
96 |
||
97 |
/** |
|
98 |
* Looks up a method signature. |
|
99 |
* |
|
100 |
* @param cpi the constant pool index |
|
101 |
* @return the method signature at index {@code cpi} in this constant pool |
|
102 |
*/ |
|
103 |
Signature lookupSignature(int cpi); |
|
104 |
||
105 |
/** |
|
106 |
* Looks up a constant at the specified index. |
|
107 |
* |
|
108 |
* @param cpi the constant pool index |
|
109 |
* @return the {@code Constant} or {@code JavaType} instance representing the constant pool |
|
110 |
* entry |
|
111 |
*/ |
|
112 |
Object lookupConstant(int cpi); |
|
113 |
||
114 |
/** |
|
115 |
* Looks up the appendix at the specified index. |
|
116 |
* |
|
117 |
* @param cpi the constant pool index |
|
118 |
* @param opcode the opcode of the instruction for which the lookup is being performed or |
|
119 |
* {@code -1} |
|
120 |
* @return the appendix if it exists and is resolved or {@code null} |
|
121 |
*/ |
|
122 |
JavaConstant lookupAppendix(int cpi, int opcode); |
|
123 |
} |