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