Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: 22b21f38b69fab7d0f5895788d7c95b83dc27f88 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
/*******************************************************************************
 * Copyright (c) 2000, 2020 IBM Corporation and others.
 *
 * This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License 2.0
 * which accompanies this distribution, and is available at
 * https://www.eclipse.org/legal/epl-2.0/
 *
 * SPDX-License-Identifier: EPL-2.0
 *
 * Contributors:
 *     IBM Corporation - initial API and implementation
 *******************************************************************************/
package org.eclipse.jdt.core.util;

/**
 * Description of a .class file. This class reifies the internal structure of a .class
 * file following the JVM specifications.
 * <p>
 * Note that several changes were introduced with J2SE 1.5.
 * Class file reader implementations should use support these
 * new class file attributes by returning objects implementing
 * the appropriate specialized attribute interfaces. Class
 * file reader clients can search for these new attributes
 * and downcast to the new interfaces as appropriate.
 * </p>
 *
 * This interface may be implemented by clients.
 *
 * @since 2.0
 */
public interface IClassFileReader {
	/**
	 * This value should be used to read completely each part of a .class file.
	 */
	int ALL 					= 0xFFFF;

	/**
	 * This value should be used to read only the constant pool entries of a .class file.
	 */
	int CONSTANT_POOL 			= 0x0001;

	/**
	 * This value should be used to read the constant pool entries and
	 * the method infos of a .class file.
	 */
	int METHOD_INFOS 			= 0x0002 + CONSTANT_POOL;

	/**
	 * This value should be used to read the constant pool entries and
	 * the field infos of a .class file.
	 */
	int FIELD_INFOS 			= 0x0004 + CONSTANT_POOL;

	/**
	 * This value should be used to read the constant pool entries and
	 * the super interface names of a .class file.
	 */
	int SUPER_INTERFACES 		= 0x0008 + CONSTANT_POOL;

	/**
	 * This value should be used to read the constant pool entries and
	 * the attributes of a .class file.
	 */
	int CLASSFILE_ATTRIBUTES 	= 0x0010 + CONSTANT_POOL;

	/**
	 * This value should be used to read the method bodies.
	 * It has to be used with METHOD_INFOS.
	 */
	int METHOD_BODIES 			= 0x0020;

	/**
	 * This value should be used to read the whole contents of the .class file except the
	 * method bodies.
	 */
	int ALL_BUT_METHOD_BODIES   = ALL & ~METHOD_BODIES;

	/**
	 * Answer back the access flags of the .class file.
	 *
	 * @return the access flags of the .class file
	 */
	int getAccessFlags();

	/**
	 * Answer back the array of field infos of the .class file,
	 * an empty array if none.
	 *
	 * @return the array of field infos of the .class file, an empty array if none
	 */
	IFieldInfo[] getFieldInfos();

	/**
	 * Answer back the names of interfaces implemented by this .class file,
	 * an empty array if none. The names are returned as described in the
	 * JVM specifications.
	 *
	 * @return the names of interfaces implemented by this .class file, an empty array if none
	 */
	char[][] getInterfaceNames();

	/**
	 * Answer back the indexes in the constant pool of interfaces implemented
	 * by this .class file, an empty array if none.
	 *
	 * @return the indexes in the constant pool of interfaces implemented
	 * by this .class file, an empty array if none
	 */
	int[] getInterfaceIndexes();

	/**
	 * Answer back the inner classes attribute of this .class file, null if none.
	 *
	 * @return the inner classes attribute of this .class file, null if none
	 */
	IInnerClassesAttribute getInnerClassesAttribute();

	/**
	 * Answer back the nest members attribute of this .class file, null if none.
	 *
	 * @return the nest members attribute of this .class file, null if none
	 * @since 3.16
	 */
	default INestMembersAttribute getNestMembersAttribute() {
		return null;
	}

	/**
	 * Answer back the record attribute of this .class file, null if none.
	 *
	 * @return the nest record of this .class file, null if none
	 * @since 3.22
	 */
	default IRecordAttribute getRecordAttribute() {
		return null;
	}

	/**
	 * Answer back the permitted subclasses attribute of this .class file, null if none.
	 *
	 * @return the permitted subclasses attribute of this .class file, null if none
	 * @since 3.23
	 */
	default IPermittedSubclassesAttribute getPermittedSubclassesAttribute() {
		return null;
	}

	/**
	 * Answer back the array of method infos of this .class file,
	 * an empty array if none.
	 *
	 * @return the array of method infos of this .class file,
	 * an empty array if none
	 */
	IMethodInfo[] getMethodInfos();

	/**
	 * Answer back the qualified name of the .class file.
	 * The name is returned as described in the JVM specifications.
	 *
	 * @return the qualified name of the .class file
	 */
	char[] getClassName();

	/**
	 * Answer back the index of the class name in the constant pool
	 * of the .class file.
	 *
	 * @return the index of the class name in the constant pool
	 */
	int getClassIndex();

	/**
	 * Answer back the qualified name of the superclass of this .class file.
	 * The name is returned as described in the JVM specifications. Answer null if
	 * getSuperclassIndex() is zero.
	 *
	 * @return the qualified name of the superclass of this .class file, null if getSuperclassIndex() is zero
	 */
	char[] getSuperclassName();

	/**
	 * Answer back the index of the superclass name in the constant pool
	 * of the .class file. Answer 0 if this .class file represents java.lang.Object.
	 *
	 * @return the index of the superclass name in the constant pool
	 * of the .class file, 0 if this .class file represents java.lang.Object.
	 */
	int getSuperclassIndex();

	/**
	 * Answer true if this .class file represents a class, false otherwise.
	 *
	 * @return true if this .class file represents a class, false otherwise
	 */
	boolean isClass();

	/**
	 * Answer true if this .class file represents an interface, false otherwise.
	 *
	 * @return true if this .class file represents an interface, false otherwise
	 */
	boolean isInterface();

	/**
	 * Answer the source file attribute, if it exists, null otherwise.
	 *
	 * @return the source file attribute, if it exists, null otherwise
	 */
	ISourceAttribute getSourceFileAttribute();

	/**
	 * Answer the constant pool of this .class file.
	 *
	 * @return the constant pool of this .class file
	 */
	IConstantPool getConstantPool();

	/**
	 * Answer the minor version of this .class file.
	 *
	 * @return the minor version of this .class file
	 */
	int getMinorVersion();

	/**
	 * Answer the major version of this .class file.
	 *
	 * @return the major version of this .class file
	 */
	int getMajorVersion();

	/**
	 * Answer back the attribute number of the .class file.
	 *
	 * @return the attribute number of the .class file
	 */
	int getAttributeCount();

	/**
	 * Answer back the collection of all attributes of the field info. It
	 * includes SyntheticAttribute, ConstantValueAttributes, etc. Answers an empty
	 * array if none.
	 *
	 * @return the collection of all attributes of the field info. It
	 * includes SyntheticAttribute, ConstantValueAttributes, etc. Answers an empty
	 * array if none
	 */
	IClassFileAttribute[] getAttributes();

	/**
	 * Answer back the magic number.
	 *
	 * @return the magic number
	 */
	int getMagic();

	/**
	 * Answer back the number of field infos.
	 *
	 * @return the number of field infos
	 */
	int getFieldsCount();

	/**
	 * Answer back the number of method infos.
	 *
	 * @return the number of method infos
	 */
	int getMethodsCount();
}

Back to the top