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
|
|
51 |
* specific to the bytecode it denotes are performed if the field is already resolved. Should
|
|
52 |
* any of these checks fail, an unresolved field reference is returned.
|
|
53 |
*
|
|
54 |
* @param cpi the constant pool index
|
|
55 |
* @param opcode the opcode of the instruction for which the lookup is being performed or
|
|
56 |
* {@code -1}
|
|
57 |
* @return a reference to the field at {@code cpi} in this pool
|
|
58 |
* @throws ClassFormatError if the entry at {@code cpi} is not a field
|
|
59 |
*/
|
|
60 |
JavaField lookupField(int cpi, int opcode);
|
|
61 |
|
|
62 |
/**
|
|
63 |
* Looks up a reference to a method. If {@code opcode} is non-negative, then resolution checks
|
|
64 |
* specific to the bytecode it denotes are performed if the method is already resolved. Should
|
|
65 |
* any of these checks fail, an unresolved method reference is returned.
|
|
66 |
*
|
|
67 |
* @param cpi the constant pool index
|
|
68 |
* @param opcode the opcode of the instruction for which the lookup is being performed or
|
|
69 |
* {@code -1}
|
|
70 |
* @return a reference to the method at {@code cpi} in this pool
|
|
71 |
* @throws ClassFormatError if the entry at {@code cpi} is not a method
|
|
72 |
*/
|
|
73 |
JavaMethod lookupMethod(int cpi, int opcode);
|
|
74 |
|
|
75 |
/**
|
|
76 |
* Looks up a reference to a type. If {@code opcode} is non-negative, then resolution checks
|
|
77 |
* specific to the bytecode it denotes are performed if the type is already resolved. Should any
|
|
78 |
* of these checks fail, an unresolved type reference is returned.
|
|
79 |
*
|
|
80 |
* @param cpi the constant pool index
|
|
81 |
* @param opcode the opcode of the instruction for which the lookup is being performed or
|
|
82 |
* {@code -1}
|
|
83 |
* @return a reference to the compiler interface type
|
|
84 |
*/
|
|
85 |
JavaType lookupType(int cpi, int opcode);
|
|
86 |
|
|
87 |
/**
|
|
88 |
* Looks up an Utf8 string.
|
|
89 |
*
|
|
90 |
* @param cpi the constant pool index
|
|
91 |
* @return the Utf8 string at index {@code cpi} in this constant pool
|
|
92 |
*/
|
|
93 |
String lookupUtf8(int cpi);
|
|
94 |
|
|
95 |
/**
|
|
96 |
* Looks up a method signature.
|
|
97 |
*
|
|
98 |
* @param cpi the constant pool index
|
|
99 |
* @return the method signature at index {@code cpi} in this constant pool
|
|
100 |
*/
|
|
101 |
Signature lookupSignature(int cpi);
|
|
102 |
|
|
103 |
/**
|
|
104 |
* Looks up a constant at the specified index.
|
|
105 |
*
|
|
106 |
* @param cpi the constant pool index
|
|
107 |
* @return the {@code Constant} or {@code JavaType} instance representing the constant pool
|
|
108 |
* entry
|
|
109 |
*/
|
|
110 |
Object lookupConstant(int cpi);
|
|
111 |
|
|
112 |
/**
|
|
113 |
* Looks up the appendix at the specified index.
|
|
114 |
*
|
|
115 |
* @param cpi the constant pool index
|
|
116 |
* @param opcode the opcode of the instruction for which the lookup is being performed or
|
|
117 |
* {@code -1}
|
|
118 |
* @return the appendix if it exists and is resolved or {@code null}
|
|
119 |
*/
|
|
120 |
JavaConstant lookupAppendix(int cpi, int opcode);
|
|
121 |
}
|