author | jwilhelm |
Sat, 19 Mar 2016 01:23:46 +0100 | |
changeset 37155 | f00f299cb386 |
parent 34666 | 1c7168ea0034 |
child 36508 | 5f9eee6b383b |
permissions | -rw-r--r-- |
1 | 1 |
/* |
29081
c61eb4914428
8072911: Remove includes of oop.inline.hpp from .hpp files
stefank
parents:
28027
diff
changeset
|
2 |
* Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved. |
1 | 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 |
* |
|
5547
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
3821
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
3821
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
3821
diff
changeset
|
21 |
* questions. |
1 | 22 |
* |
23 |
*/ |
|
24 |
||
7397 | 25 |
#ifndef SHARE_VM_CLASSFILE_CLASSFILEPARSER_HPP |
26 |
#define SHARE_VM_CLASSFILE_CLASSFILEPARSER_HPP |
|
27 |
||
34666 | 28 |
#include "memory/referenceType.hpp" |
29 |
#include "runtime/handles.inline.hpp" |
|
29201
fee2bbb2ec1d
8073389: Remove the include of resourceArea.hpp from classFileParser.hpp
stefank
parents:
29081
diff
changeset
|
30 |
#include "oops/constantPool.hpp" |
7397 | 31 |
#include "oops/typeArrayOop.hpp" |
32 |
#include "utilities/accessFlags.hpp" |
|
33 |
||
34666 | 34 |
class Annotations; |
35 |
template <typename T> |
|
36 |
class Array; |
|
37 |
class ClassFileStream; |
|
38 |
class ClassLoaderData; |
|
29201
fee2bbb2ec1d
8073389: Remove the include of resourceArea.hpp from classFileParser.hpp
stefank
parents:
29081
diff
changeset
|
39 |
class CompressedLineNumberWriteStream; |
34666 | 40 |
class ConstMethod; |
29201
fee2bbb2ec1d
8073389: Remove the include of resourceArea.hpp from classFileParser.hpp
stefank
parents:
29081
diff
changeset
|
41 |
class FieldInfo; |
34666 | 42 |
template <typename T> |
43 |
class GrowableArray; |
|
44 |
class InstanceKlass; |
|
45 |
class intArray; |
|
46 |
class Symbol; |
|
47 |
class TempNewSymbol; |
|
10546 | 48 |
|
1 | 49 |
// Parser for for .class files |
50 |
// |
|
51 |
// The bytes describing the class file structure is read from a Stream object |
|
52 |
||
53 |
class ClassFileParser VALUE_OBJ_CLASS_SPEC { |
|
34666 | 54 |
|
55 |
class ClassAnnotationCollector; |
|
56 |
class FieldAllocationCount; |
|
57 |
class FieldAnnotationCollector; |
|
58 |
class FieldLayoutInfo; |
|
59 |
||
60 |
public: |
|
61 |
// The ClassFileParser has an associated "publicity" level |
|
62 |
// It is used to control which subsystems (if any) |
|
63 |
// will observe the parsing (logging, events, tracing). |
|
64 |
// Default level is "BROADCAST", which is equivalent to |
|
65 |
// a "public" parsing attempt. |
|
66 |
// |
|
67 |
// "INTERNAL" level should be entirely private to the |
|
68 |
// caller - this allows for internal reuse of ClassFileParser |
|
69 |
// |
|
70 |
enum Publicity { |
|
71 |
INTERNAL, |
|
72 |
BROADCAST, |
|
73 |
NOF_PUBLICITY_LEVELS |
|
74 |
}; |
|
75 |
||
1 | 76 |
private: |
34666 | 77 |
const ClassFileStream* _stream; // Actual input stream |
78 |
const Symbol* _requested_name; |
|
79 |
Symbol* _class_name; |
|
80 |
mutable ClassLoaderData* _loader_data; |
|
81 |
const Klass* _host_klass; |
|
82 |
GrowableArray<Handle>* _cp_patches; // overrides for CP entries |
|
83 |
TempNewSymbol* _parsed_name; |
|
84 |
||
85 |
// Metadata created before the instance klass is created. Must be deallocated |
|
86 |
// if not transferred to the InstanceKlass upon successful class loading |
|
87 |
// in which case these pointers have been set to NULL. |
|
88 |
const InstanceKlass* _super_klass; |
|
89 |
ConstantPool* _cp; |
|
90 |
Array<u2>* _fields; |
|
91 |
Array<Method*>* _methods; |
|
92 |
Array<u2>* _inner_classes; |
|
93 |
Array<Klass*>* _local_interfaces; |
|
94 |
Array<Klass*>* _transitive_interfaces; |
|
95 |
Annotations* _combined_annotations; |
|
96 |
AnnotationArray* _annotations; |
|
97 |
AnnotationArray* _type_annotations; |
|
98 |
Array<AnnotationArray*>* _fields_annotations; |
|
99 |
Array<AnnotationArray*>* _fields_type_annotations; |
|
100 |
InstanceKlass* _klass; // InstanceKlass* once created. |
|
101 |
InstanceKlass* _klass_to_deallocate; // an InstanceKlass* to be destroyed |
|
102 |
||
103 |
ClassAnnotationCollector* _parsed_annotations; |
|
104 |
FieldAllocationCount* _fac; |
|
105 |
FieldLayoutInfo* _field_info; |
|
106 |
const intArray* _method_ordering; |
|
107 |
GrowableArray<Method*>* _all_mirandas; |
|
108 |
||
109 |
enum { fixed_buffer_size = 128 }; |
|
110 |
u_char _linenumbertable_buffer[fixed_buffer_size]; |
|
111 |
||
112 |
// Size of Java vtable (in words) |
|
113 |
int _vtable_size; |
|
114 |
int _itable_size; |
|
115 |
||
116 |
int _num_miranda_methods; |
|
117 |
||
118 |
ReferenceType _rt; |
|
119 |
Handle _protection_domain; |
|
120 |
AccessFlags _access_flags; |
|
121 |
||
122 |
// for tracing and notifications |
|
123 |
Publicity _pub_level; |
|
124 |
||
125 |
// class attributes parsed before the instance klass is created: |
|
126 |
bool _synthetic_flag; |
|
127 |
int _sde_length; |
|
128 |
const char* _sde_buffer; |
|
129 |
u2 _sourcefile_index; |
|
130 |
u2 _generic_signature_index; |
|
131 |
||
132 |
u2 _major_version; |
|
133 |
u2 _minor_version; |
|
134 |
u2 _this_class_index; |
|
135 |
u2 _super_class_index; |
|
136 |
u2 _itfs_len; |
|
137 |
u2 _java_fields_count; |
|
138 |
||
1 | 139 |
bool _need_verify; |
140 |
bool _relax_verify; |
|
34666 | 141 |
|
142 |
bool _has_default_methods; |
|
143 |
bool _declares_default_methods; |
|
144 |
bool _has_final_method; |
|
1 | 145 |
|
13291
9de3b1387cb8
6711908: JVM needs direct access to some annotations
jrose
parents:
12267
diff
changeset
|
146 |
// precomputed flags |
1 | 147 |
bool _has_finalizer; |
148 |
bool _has_empty_finalizer; |
|
149 |
bool _has_vanilla_constructor; |
|
13291
9de3b1387cb8
6711908: JVM needs direct access to some annotations
jrose
parents:
12267
diff
changeset
|
150 |
int _max_bootstrap_specifier_index; // detects BSS values |
1 | 151 |
|
34666 | 152 |
void parse_stream(const ClassFileStream* const stream, TRAPS); |
15935
50da9e5eb858
8003419: NPG: Clean up metadata created during class loading if failure
coleenp
parents:
15601
diff
changeset
|
153 |
|
34666 | 154 |
void post_process_parsed_stream(const ClassFileStream* const stream, |
155 |
ConstantPool* cp, |
|
156 |
TRAPS); |
|
157 |
||
158 |
void fill_instance_klass(InstanceKlass* ik, TRAPS); |
|
159 |
void set_klass(InstanceKlass* instance); |
|
13291
9de3b1387cb8
6711908: JVM needs direct access to some annotations
jrose
parents:
12267
diff
changeset
|
160 |
|
19326
14cb6cf26a96
8021948: Change InstanceKlass::_source_file_name and _generic_signature from Symbol* to constant pool indexes.
jiangli
parents:
17073
diff
changeset
|
161 |
void set_class_synthetic_flag(bool x) { _synthetic_flag = x; } |
14cb6cf26a96
8021948: Change InstanceKlass::_source_file_name and _generic_signature from Symbol* to constant pool indexes.
jiangli
parents:
17073
diff
changeset
|
162 |
void set_class_sourcefile_index(u2 x) { _sourcefile_index = x; } |
14cb6cf26a96
8021948: Change InstanceKlass::_source_file_name and _generic_signature from Symbol* to constant pool indexes.
jiangli
parents:
17073
diff
changeset
|
163 |
void set_class_generic_signature_index(u2 x) { _generic_signature_index = x; } |
34666 | 164 |
void set_class_sde_buffer(const char* x, int len) { _sde_buffer = x; _sde_length = len; } |
15935
50da9e5eb858
8003419: NPG: Clean up metadata created during class loading if failure
coleenp
parents:
15601
diff
changeset
|
165 |
|
28027
c63d0bb0101c
8065634: Crash in InstanceKlass::clean_method_data when _method is NULL
stefank
parents:
27402
diff
changeset
|
166 |
void create_combined_annotations(TRAPS); |
34666 | 167 |
void apply_parsed_class_attributes(InstanceKlass* k); // update k |
168 |
void apply_parsed_class_metadata(InstanceKlass* k, int fields_count, TRAPS); |
|
169 |
void clear_class_metadata(); |
|
1 | 170 |
|
171 |
// Constant pool parsing |
|
34666 | 172 |
void parse_constant_pool_entries(const ClassFileStream* const stream, |
173 |
ConstantPool* cp, |
|
174 |
const int length, |
|
175 |
TRAPS); |
|
1 | 176 |
|
34666 | 177 |
void parse_constant_pool(const ClassFileStream* const cfs, |
178 |
ConstantPool* const cp, |
|
179 |
const int length, |
|
180 |
TRAPS); |
|
1 | 181 |
|
182 |
// Interface parsing |
|
34666 | 183 |
void parse_interfaces(const ClassFileStream* const stream, |
184 |
const int itfs_len, |
|
185 |
ConstantPool* const cp, |
|
186 |
bool* has_default_methods, |
|
187 |
TRAPS); |
|
1 | 188 |
|
34666 | 189 |
const InstanceKlass* parse_super_class(ConstantPool* const cp, |
190 |
const int super_class_index, |
|
191 |
const bool need_verify, |
|
192 |
TRAPS); |
|
193 |
||
1 | 194 |
// Field parsing |
34666 | 195 |
void parse_field_attributes(const ClassFileStream* const cfs, |
196 |
u2 attributes_count, |
|
197 |
bool is_static, |
|
198 |
u2 signature_index, |
|
199 |
u2* const constantvalue_index_addr, |
|
200 |
bool* const is_synthetic_addr, |
|
201 |
u2* const generic_signature_index_addr, |
|
13291
9de3b1387cb8
6711908: JVM needs direct access to some annotations
jrose
parents:
12267
diff
changeset
|
202 |
FieldAnnotationCollector* parsed_annotations, |
9de3b1387cb8
6711908: JVM needs direct access to some annotations
jrose
parents:
12267
diff
changeset
|
203 |
TRAPS); |
1 | 204 |
|
34666 | 205 |
void parse_fields(const ClassFileStream* const cfs, |
206 |
bool is_interface, |
|
207 |
FieldAllocationCount* const fac, |
|
208 |
ConstantPool* cp, |
|
209 |
const int cp_size, |
|
210 |
u2* const java_fields_count_ptr, |
|
211 |
TRAPS); |
|
15193
8e6b5694267f
8003985: Support @Contended Annotation - JEP 142
jwilhelm
parents:
15097
diff
changeset
|
212 |
|
1 | 213 |
// Method parsing |
34666 | 214 |
Method* parse_method(const ClassFileStream* const cfs, |
215 |
bool is_interface, |
|
216 |
const ConstantPool* cp, |
|
217 |
AccessFlags* const promoted_flags, |
|
218 |
TRAPS); |
|
219 |
||
220 |
void parse_methods(const ClassFileStream* const cfs, |
|
221 |
bool is_interface, |
|
222 |
AccessFlags* const promoted_flags, |
|
223 |
bool* const has_final_method, |
|
224 |
bool* const declares_default_methods, |
|
225 |
TRAPS); |
|
226 |
||
227 |
const u2* parse_exception_table(const ClassFileStream* const stream, |
|
228 |
u4 code_length, |
|
229 |
u4 exception_table_length, |
|
230 |
TRAPS); |
|
15935
50da9e5eb858
8003419: NPG: Clean up metadata created during class loading if failure
coleenp
parents:
15601
diff
changeset
|
231 |
|
34666 | 232 |
void parse_linenumber_table(u4 code_attribute_length, |
233 |
u4 code_length, |
|
234 |
CompressedLineNumberWriteStream**const write_stream, |
|
235 |
TRAPS); |
|
236 |
||
237 |
const u2* parse_localvariable_table(const ClassFileStream* const cfs, |
|
238 |
u4 code_length, |
|
239 |
u2 max_locals, |
|
240 |
u4 code_attribute_length, |
|
241 |
u2* const localvariable_table_length, |
|
242 |
bool isLVTT, |
|
243 |
TRAPS); |
|
244 |
||
245 |
const u2* parse_checked_exceptions(const ClassFileStream* const cfs, |
|
246 |
u2* const checked_exceptions_length, |
|
247 |
u4 method_attribute_length, |
|
248 |
TRAPS); |
|
249 |
||
250 |
void parse_type_array(u2 array_length, |
|
251 |
u4 code_length, |
|
252 |
u4* const u1_index, |
|
253 |
u4* const u2_index, |
|
254 |
u1* const u1_array, |
|
255 |
u2* const u2_array, |
|
256 |
TRAPS); |
|
1 | 257 |
|
258 |
// Classfile attribute parsing |
|
34666 | 259 |
u2 parse_generic_signature_attribute(const ClassFileStream* const cfs, TRAPS); |
260 |
void parse_classfile_sourcefile_attribute(const ClassFileStream* const cfs, TRAPS); |
|
261 |
void parse_classfile_source_debug_extension_attribute(const ClassFileStream* const cfs, |
|
262 |
int length, |
|
263 |
TRAPS); |
|
264 |
||
265 |
u2 parse_classfile_inner_classes_attribute(const ClassFileStream* const cfs, |
|
266 |
const u1* const inner_classes_attribute_start, |
|
12231
6a9cfc59a18a
7109878: The instanceKlass EnclosingMethhod attribute fields can be folded into the _inner_class field.
jiangli
parents:
11412
diff
changeset
|
267 |
bool parsed_enclosingmethod_attribute, |
6a9cfc59a18a
7109878: The instanceKlass EnclosingMethhod attribute fields can be folded into the _inner_class field.
jiangli
parents:
11412
diff
changeset
|
268 |
u2 enclosing_method_class_index, |
6a9cfc59a18a
7109878: The instanceKlass EnclosingMethhod attribute fields can be folded into the _inner_class field.
jiangli
parents:
11412
diff
changeset
|
269 |
u2 enclosing_method_method_index, |
13291
9de3b1387cb8
6711908: JVM needs direct access to some annotations
jrose
parents:
12267
diff
changeset
|
270 |
TRAPS); |
34666 | 271 |
|
272 |
void parse_classfile_attributes(const ClassFileStream* const cfs, |
|
273 |
ConstantPool* cp, |
|
274 |
ClassAnnotationCollector* parsed_annotations, |
|
13291
9de3b1387cb8
6711908: JVM needs direct access to some annotations
jrose
parents:
12267
diff
changeset
|
275 |
TRAPS); |
34666 | 276 |
|
15935
50da9e5eb858
8003419: NPG: Clean up metadata created during class loading if failure
coleenp
parents:
15601
diff
changeset
|
277 |
void parse_classfile_synthetic_attribute(TRAPS); |
34666 | 278 |
void parse_classfile_signature_attribute(const ClassFileStream* const cfs, TRAPS); |
279 |
void parse_classfile_bootstrap_methods_attribute(const ClassFileStream* const cfs, |
|
280 |
ConstantPool* cp, |
|
281 |
u4 attribute_length, |
|
282 |
TRAPS); |
|
1 | 283 |
|
284 |
// Annotations handling |
|
34666 | 285 |
AnnotationArray* assemble_annotations(const u1* const runtime_visible_annotations, |
13952
e3cf184080bc
8000213: NPG: Should have renamed arrayKlass and typeArrayKlass
coleenp
parents:
13728
diff
changeset
|
286 |
int runtime_visible_annotations_length, |
34666 | 287 |
const u1* const runtime_invisible_annotations, |
288 |
int runtime_invisible_annotations_length, |
|
289 |
TRAPS); |
|
1 | 290 |
|
34666 | 291 |
void set_precomputed_flags(InstanceKlass* k); |
1 | 292 |
|
293 |
// Format checker methods |
|
34666 | 294 |
void classfile_parse_error(const char* msg, TRAPS) const; |
295 |
void classfile_parse_error(const char* msg, int index, TRAPS) const; |
|
296 |
void classfile_parse_error(const char* msg, const char *name, TRAPS) const; |
|
297 |
void classfile_parse_error(const char* msg, |
|
298 |
int index, |
|
299 |
const char *name, |
|
300 |
TRAPS) const; |
|
301 |
||
302 |
inline void guarantee_property(bool b, const char* msg, TRAPS) const { |
|
1 | 303 |
if (!b) { classfile_parse_error(msg, CHECK); } |
304 |
} |
|
305 |
||
34666 | 306 |
void report_assert_property_failure(const char* msg, TRAPS) const PRODUCT_RETURN; |
307 |
void report_assert_property_failure(const char* msg, int index, TRAPS) const PRODUCT_RETURN; |
|
29201
fee2bbb2ec1d
8073389: Remove the include of resourceArea.hpp from classFileParser.hpp
stefank
parents:
29081
diff
changeset
|
308 |
|
34666 | 309 |
inline void assert_property(bool b, const char* msg, TRAPS) const { |
1 | 310 |
#ifdef ASSERT |
17073
99baa410e207
8012695: Assertion message displays %u and %s text instead of actual values
hseigel
parents:
16692
diff
changeset
|
311 |
if (!b) { |
29201
fee2bbb2ec1d
8073389: Remove the include of resourceArea.hpp from classFileParser.hpp
stefank
parents:
29081
diff
changeset
|
312 |
report_assert_property_failure(msg, THREAD); |
17073
99baa410e207
8012695: Assertion message displays %u and %s text instead of actual values
hseigel
parents:
16692
diff
changeset
|
313 |
} |
99baa410e207
8012695: Assertion message displays %u and %s text instead of actual values
hseigel
parents:
16692
diff
changeset
|
314 |
#endif |
99baa410e207
8012695: Assertion message displays %u and %s text instead of actual values
hseigel
parents:
16692
diff
changeset
|
315 |
} |
99baa410e207
8012695: Assertion message displays %u and %s text instead of actual values
hseigel
parents:
16692
diff
changeset
|
316 |
|
34666 | 317 |
inline void assert_property(bool b, const char* msg, int index, TRAPS) const { |
17073
99baa410e207
8012695: Assertion message displays %u and %s text instead of actual values
hseigel
parents:
16692
diff
changeset
|
318 |
#ifdef ASSERT |
99baa410e207
8012695: Assertion message displays %u and %s text instead of actual values
hseigel
parents:
16692
diff
changeset
|
319 |
if (!b) { |
29201
fee2bbb2ec1d
8073389: Remove the include of resourceArea.hpp from classFileParser.hpp
stefank
parents:
29081
diff
changeset
|
320 |
report_assert_property_failure(msg, index, THREAD); |
17073
99baa410e207
8012695: Assertion message displays %u and %s text instead of actual values
hseigel
parents:
16692
diff
changeset
|
321 |
} |
1 | 322 |
#endif |
323 |
} |
|
324 |
||
34666 | 325 |
inline void check_property(bool property, |
326 |
const char* msg, |
|
327 |
int index, |
|
328 |
TRAPS) const { |
|
1 | 329 |
if (_need_verify) { |
330 |
guarantee_property(property, msg, index, CHECK); |
|
331 |
} else { |
|
17073
99baa410e207
8012695: Assertion message displays %u and %s text instead of actual values
hseigel
parents:
16692
diff
changeset
|
332 |
assert_property(property, msg, index, CHECK); |
1 | 333 |
} |
334 |
} |
|
335 |
||
34666 | 336 |
inline void check_property(bool property, const char* msg, TRAPS) const { |
1 | 337 |
if (_need_verify) { |
338 |
guarantee_property(property, msg, CHECK); |
|
339 |
} else { |
|
340 |
assert_property(property, msg, CHECK); |
|
341 |
} |
|
342 |
} |
|
343 |
||
34666 | 344 |
inline void guarantee_property(bool b, |
345 |
const char* msg, |
|
346 |
int index, |
|
347 |
TRAPS) const { |
|
1 | 348 |
if (!b) { classfile_parse_error(msg, index, CHECK); } |
349 |
} |
|
34666 | 350 |
|
351 |
inline void guarantee_property(bool b, |
|
352 |
const char* msg, |
|
353 |
const char *name, |
|
354 |
TRAPS) const { |
|
1 | 355 |
if (!b) { classfile_parse_error(msg, name, CHECK); } |
356 |
} |
|
34666 | 357 |
|
358 |
inline void guarantee_property(bool b, |
|
359 |
const char* msg, |
|
360 |
int index, |
|
361 |
const char *name, |
|
362 |
TRAPS) const { |
|
1 | 363 |
if (!b) { classfile_parse_error(msg, index, name, CHECK); } |
364 |
} |
|
365 |
||
34666 | 366 |
void throwIllegalSignature(const char* type, |
367 |
const Symbol* name, |
|
368 |
const Symbol* sig, |
|
369 |
TRAPS) const; |
|
5709
3b5307e27c1d
6930553: classfile format checker allows invalid method descriptor in CONSTANT_NameAndType_info in some cases
kamg
parents:
3821
diff
changeset
|
370 |
|
34666 | 371 |
void verify_constantvalue(const ConstantPool* const cp, |
372 |
int constantvalue_index, |
|
373 |
int signature_index, |
|
374 |
TRAPS) const; |
|
375 |
||
376 |
void verify_legal_utf8(const unsigned char* buffer, int length, TRAPS) const; |
|
377 |
void verify_legal_class_name(const Symbol* name, TRAPS) const; |
|
378 |
void verify_legal_field_name(const Symbol* name, TRAPS) const; |
|
379 |
void verify_legal_method_name(const Symbol* name, TRAPS) const; |
|
1 | 380 |
|
34666 | 381 |
void verify_legal_field_signature(const Symbol* fieldname, |
382 |
const Symbol* signature, |
|
383 |
TRAPS) const; |
|
384 |
int verify_legal_method_signature(const Symbol* methodname, |
|
385 |
const Symbol* signature, |
|
386 |
TRAPS) const; |
|
1 | 387 |
|
34666 | 388 |
void verify_legal_class_modifiers(jint flags, TRAPS) const; |
389 |
void verify_legal_field_modifiers(jint flags, bool is_interface, TRAPS) const; |
|
390 |
void verify_legal_method_modifiers(jint flags, |
|
391 |
bool is_interface, |
|
392 |
const Symbol* name, |
|
393 |
TRAPS) const; |
|
394 |
||
395 |
const char* skip_over_field_signature(const char* signature, |
|
396 |
bool void_ok, |
|
397 |
unsigned int length, |
|
398 |
TRAPS) const; |
|
399 |
||
400 |
bool has_cp_patch_at(int index) const { |
|
1550
be2fc37a817f
6653858: dynamic languages need to be able to load anonymous classes
jrose
parents:
1
diff
changeset
|
401 |
assert(index >= 0, "oob"); |
be2fc37a817f
6653858: dynamic languages need to be able to load anonymous classes
jrose
parents:
1
diff
changeset
|
402 |
return (_cp_patches != NULL |
be2fc37a817f
6653858: dynamic languages need to be able to load anonymous classes
jrose
parents:
1
diff
changeset
|
403 |
&& index < _cp_patches->length() |
be2fc37a817f
6653858: dynamic languages need to be able to load anonymous classes
jrose
parents:
1
diff
changeset
|
404 |
&& _cp_patches->adr_at(index)->not_null()); |
be2fc37a817f
6653858: dynamic languages need to be able to load anonymous classes
jrose
parents:
1
diff
changeset
|
405 |
} |
34666 | 406 |
|
407 |
Handle cp_patch_at(int index) const { |
|
1550
be2fc37a817f
6653858: dynamic languages need to be able to load anonymous classes
jrose
parents:
1
diff
changeset
|
408 |
assert(has_cp_patch_at(index), "oob"); |
be2fc37a817f
6653858: dynamic languages need to be able to load anonymous classes
jrose
parents:
1
diff
changeset
|
409 |
return _cp_patches->at(index); |
be2fc37a817f
6653858: dynamic languages need to be able to load anonymous classes
jrose
parents:
1
diff
changeset
|
410 |
} |
34666 | 411 |
|
1550
be2fc37a817f
6653858: dynamic languages need to be able to load anonymous classes
jrose
parents:
1
diff
changeset
|
412 |
Handle clear_cp_patch_at(int index) { |
be2fc37a817f
6653858: dynamic languages need to be able to load anonymous classes
jrose
parents:
1
diff
changeset
|
413 |
Handle patch = cp_patch_at(index); |
be2fc37a817f
6653858: dynamic languages need to be able to load anonymous classes
jrose
parents:
1
diff
changeset
|
414 |
_cp_patches->at_put(index, Handle()); |
be2fc37a817f
6653858: dynamic languages need to be able to load anonymous classes
jrose
parents:
1
diff
changeset
|
415 |
assert(!has_cp_patch_at(index), ""); |
be2fc37a817f
6653858: dynamic languages need to be able to load anonymous classes
jrose
parents:
1
diff
changeset
|
416 |
return patch; |
be2fc37a817f
6653858: dynamic languages need to be able to load anonymous classes
jrose
parents:
1
diff
changeset
|
417 |
} |
34666 | 418 |
|
419 |
void patch_constant_pool(ConstantPool* cp, |
|
420 |
int index, |
|
421 |
Handle patch, |
|
422 |
TRAPS); |
|
1550
be2fc37a817f
6653858: dynamic languages need to be able to load anonymous classes
jrose
parents:
1
diff
changeset
|
423 |
|
be2fc37a817f
6653858: dynamic languages need to be able to load anonymous classes
jrose
parents:
1
diff
changeset
|
424 |
// Wrapper for constantTag.is_klass_[or_]reference. |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
425 |
// In older versions of the VM, Klass*s cannot sneak into early phases of |
1550
be2fc37a817f
6653858: dynamic languages need to be able to load anonymous classes
jrose
parents:
1
diff
changeset
|
426 |
// constant pool construction, but in later versions they can. |
be2fc37a817f
6653858: dynamic languages need to be able to load anonymous classes
jrose
parents:
1
diff
changeset
|
427 |
// %%% Let's phase out the old is_klass_reference. |
34666 | 428 |
bool valid_klass_reference_at(int index) const { |
429 |
return _cp->is_within_bounds(index) && |
|
430 |
_cp->tag_at(index).is_klass_or_reference(); |
|
15935
50da9e5eb858
8003419: NPG: Clean up metadata created during class loading if failure
coleenp
parents:
15601
diff
changeset
|
431 |
} |
50da9e5eb858
8003419: NPG: Clean up metadata created during class loading if failure
coleenp
parents:
15601
diff
changeset
|
432 |
|
50da9e5eb858
8003419: NPG: Clean up metadata created during class loading if failure
coleenp
parents:
15601
diff
changeset
|
433 |
// Checks that the cpool index is in range and is a utf8 |
34666 | 434 |
bool valid_symbol_at(int cpool_index) const { |
435 |
return _cp->is_within_bounds(cpool_index) && |
|
436 |
_cp->tag_at(cpool_index).is_utf8(); |
|
1550
be2fc37a817f
6653858: dynamic languages need to be able to load anonymous classes
jrose
parents:
1
diff
changeset
|
437 |
} |
be2fc37a817f
6653858: dynamic languages need to be able to load anonymous classes
jrose
parents:
1
diff
changeset
|
438 |
|
34666 | 439 |
void copy_localvariable_table(const ConstMethod* cm, |
440 |
int lvt_cnt, |
|
441 |
u2* const localvariable_table_length, |
|
442 |
const u2**const localvariable_table_start, |
|
15601 | 443 |
int lvtt_cnt, |
34666 | 444 |
u2* const localvariable_type_table_length, |
445 |
const u2** const localvariable_type_table_start, |
|
15601 | 446 |
TRAPS); |
447 |
||
15935
50da9e5eb858
8003419: NPG: Clean up metadata created during class loading if failure
coleenp
parents:
15601
diff
changeset
|
448 |
void copy_method_annotations(ConstMethod* cm, |
34666 | 449 |
const u1* runtime_visible_annotations, |
15601 | 450 |
int runtime_visible_annotations_length, |
34666 | 451 |
const u1* runtime_invisible_annotations, |
15601 | 452 |
int runtime_invisible_annotations_length, |
34666 | 453 |
const u1* runtime_visible_parameter_annotations, |
15601 | 454 |
int runtime_visible_parameter_annotations_length, |
34666 | 455 |
const u1* runtime_invisible_parameter_annotations, |
15601 | 456 |
int runtime_invisible_parameter_annotations_length, |
34666 | 457 |
const u1* runtime_visible_type_annotations, |
15601 | 458 |
int runtime_visible_type_annotations_length, |
34666 | 459 |
const u1* runtime_invisible_type_annotations, |
15601 | 460 |
int runtime_invisible_type_annotations_length, |
34666 | 461 |
const u1* annotation_default, |
15601 | 462 |
int annotation_default_length, |
463 |
TRAPS); |
|
464 |
||
15935
50da9e5eb858
8003419: NPG: Clean up metadata created during class loading if failure
coleenp
parents:
15601
diff
changeset
|
465 |
// lays out fields in class and returns the total oopmap count |
34666 | 466 |
void layout_fields(ConstantPool* cp, |
467 |
const FieldAllocationCount* fac, |
|
468 |
const ClassAnnotationCollector* parsed_annotations, |
|
469 |
FieldLayoutInfo* info, |
|
470 |
TRAPS); |
|
15935
50da9e5eb858
8003419: NPG: Clean up metadata created during class loading if failure
coleenp
parents:
15601
diff
changeset
|
471 |
|
1 | 472 |
public: |
34666 | 473 |
ClassFileParser(ClassFileStream* stream, |
474 |
Symbol* name, |
|
475 |
ClassLoaderData* loader_data, |
|
476 |
Handle protection_domain, |
|
477 |
TempNewSymbol* parsed_name, |
|
478 |
const Klass* host_klass, |
|
479 |
GrowableArray<Handle>* cp_patches, |
|
480 |
Publicity pub_level, |
|
481 |
TRAPS); |
|
482 |
||
15935
50da9e5eb858
8003419: NPG: Clean up metadata created during class loading if failure
coleenp
parents:
15601
diff
changeset
|
483 |
~ClassFileParser(); |
1 | 484 |
|
34666 | 485 |
InstanceKlass* create_instance_klass(TRAPS); |
486 |
||
487 |
const ClassFileStream* clone_stream() const; |
|
488 |
||
489 |
void set_klass_to_deallocate(InstanceKlass* klass); |
|
490 |
||
491 |
int static_field_size() const; |
|
492 |
int total_oop_map_count() const; |
|
493 |
jint layout_size() const; |
|
494 |
||
495 |
int vtable_size() const { return _vtable_size; } |
|
496 |
int itable_size() const { return _itable_size; } |
|
1 | 497 |
|
34666 | 498 |
u2 this_class_index() const { return _this_class_index; } |
499 |
u2 super_class_index() const { return _super_class_index; } |
|
500 |
||
501 |
bool is_anonymous() const { return _host_klass != NULL; } |
|
502 |
bool is_interface() const { return _access_flags.is_interface(); } |
|
503 |
||
504 |
const Klass* host_klass() const { return _host_klass; } |
|
505 |
const GrowableArray<Handle>* cp_patches() const { return _cp_patches; } |
|
506 |
ClassLoaderData* loader_data() const { return _loader_data; } |
|
507 |
const Symbol* class_name() const { return _class_name; } |
|
508 |
const Klass* super_klass() const { return _super_klass; } |
|
509 |
||
510 |
ReferenceType reference_type() const { return _rt; } |
|
511 |
AccessFlags access_flags() const { return _access_flags; } |
|
512 |
||
513 |
bool is_internal() const { return INTERNAL == _pub_level; } |
|
514 |
||
1 | 515 |
}; |
7397 | 516 |
|
517 |
#endif // SHARE_VM_CLASSFILE_CLASSFILEPARSER_HPP |