57 unsigned int _nonstatic_oop_map_count;
58 unsigned int _max_nonstatic_oop_maps;
59
60 OopMapBlocksBuilder(unsigned int max_blocks);
61 OopMapBlock* last_oop_map() const;
62 void initialize_inherited_blocks(OopMapBlock* blocks, unsigned int nof_blocks);
63 void add(int offset, int count);
64 void copy(OopMapBlock* dst);
65 void compact();
66 void print_on(outputStream* st) const;
67 void print_value_on(outputStream* st) const;
68 };
69
70 // Values needed for oopmap and InstanceKlass creation
71 class FieldLayoutInfo : public ResourceObj {
72 public:
73 OopMapBlocksBuilder* oop_map_blocks;
74 int _instance_size;
75 int _nonstatic_field_size;
76 int _static_field_size;
77 bool _has_nonstatic_fields;
78 };
79
80 // Parser for for .class files
81 //
82 // The bytes describing the class file structure is read from a Stream object
83
84 class ClassFileParser {
85 friend class FieldLayoutBuilder;
86 friend class FieldLayout;
87
88 class ClassAnnotationCollector;
89 class FieldAnnotationCollector;
90
91 public:
92 // The ClassFileParser has an associated "publicity" level
93 // It is used to control which subsystems (if any)
94 // will observe the parsing (logging, events, tracing).
95 // Default level is "BROADCAST", which is equivalent to
96 // a "public" parsing attempt.
97 //
112 const ClassFileStream* _stream; // Actual input stream
113 Symbol* _class_name;
114 mutable ClassLoaderData* _loader_data;
115 const bool _is_hidden;
116 const bool _can_access_vm_annotations;
117 int _orig_cp_size;
118 unsigned int _static_oop_count;
119
120 // Metadata created before the instance klass is created. Must be deallocated
121 // if not transferred to the InstanceKlass upon successful class loading
122 // in which case these pointers have been set to null.
123 const InstanceKlass* _super_klass;
124 ConstantPool* _cp;
125 Array<u1>* _fieldinfo_stream;
126 Array<FieldStatus>* _fields_status;
127 Array<Method*>* _methods;
128 Array<u2>* _inner_classes;
129 Array<u2>* _nest_members;
130 u2 _nest_host;
131 Array<u2>* _permitted_subclasses;
132 Array<RecordComponent*>* _record_components;
133 Array<InstanceKlass*>* _local_interfaces;
134 Array<InstanceKlass*>* _transitive_interfaces;
135 Annotations* _combined_annotations;
136 AnnotationArray* _class_annotations;
137 AnnotationArray* _class_type_annotations;
138 Array<AnnotationArray*>* _fields_annotations;
139 Array<AnnotationArray*>* _fields_type_annotations;
140 InstanceKlass* _klass; // InstanceKlass* once created.
141 InstanceKlass* _klass_to_deallocate; // an InstanceKlass* to be destroyed
142
143 ClassAnnotationCollector* _parsed_annotations;
144 FieldLayoutInfo* _field_info;
145 GrowableArray<FieldInfo>* _temp_field_info;
146 const intArray* _method_ordering;
147 GrowableArray<Method*>* _all_mirandas;
148
149 enum { fixed_buffer_size = 128 };
150 u_char _linenumbertable_buffer[fixed_buffer_size];
151
152 // Size of Java vtable (in words)
153 int _vtable_size;
154 int _itable_size;
155
156 int _num_miranda_methods;
157
158 Handle _protection_domain;
159 AccessFlags _access_flags;
160
161 // for tracing and notifications
162 Publicity _pub_level;
163
164 // Used to keep track of whether a constant pool item 19 or 20 is found. These
165 // correspond to CONSTANT_Module and CONSTANT_Package tags and are not allowed
166 // in regular class files. For class file version >= 53, a CFE cannot be thrown
167 // immediately when these are seen because a NCDFE must be thrown if the class's
168 // access_flags have ACC_MODULE set. But, the access_flags haven't been looked
169 // at yet. So, the bad constant pool item is cached here. A value of zero
170 // means that no constant pool item 19 or 20 was found.
171 short _bad_constant_seen;
172
173 // class attributes parsed before the instance klass is created:
174 bool _synthetic_flag;
175 int _sde_length;
176 const char* _sde_buffer;
177 u2 _sourcefile_index;
178 u2 _generic_signature_index;
179
180 u2 _major_version;
181 u2 _minor_version;
182 u2 _this_class_index;
183 u2 _super_class_index;
184 u2 _itfs_len;
185 u2 _java_fields_count;
186
187 bool _need_verify;
188 bool _relax_verify;
189
190 bool _has_nonstatic_concrete_methods;
191 bool _declares_nonstatic_concrete_methods;
192 bool _has_localvariable_table;
193 bool _has_final_method;
194 bool _has_contended_fields;
195
196 // precomputed flags
197 bool _has_finalizer;
198 bool _has_empty_finalizer;
199 int _max_bootstrap_specifier_index; // detects BSS values
200
201 void parse_stream(const ClassFileStream* const stream, TRAPS);
202
203 void mangle_hidden_class_name(InstanceKlass* const ik);
204
205 void post_process_parsed_stream(const ClassFileStream* const stream,
206 ConstantPool* cp,
207 TRAPS);
208
209 void fill_instance_klass(InstanceKlass* ik, bool cf_changed_in_CFLH,
210 const ClassInstanceInfo& cl_inst_info, TRAPS);
211
212 void set_klass(InstanceKlass* instance);
213
214 void set_class_bad_constant_seen(short bad_constant);
215 short class_bad_constant_seen() { return _bad_constant_seen; }
241 bool* has_nonstatic_concrete_methods,
242 TRAPS);
243
244 const InstanceKlass* parse_super_class(ConstantPool* const cp,
245 const int super_class_index,
246 const bool need_verify,
247 TRAPS);
248
249 // Field parsing
250 void parse_field_attributes(const ClassFileStream* const cfs,
251 u2 attributes_count,
252 bool is_static,
253 u2 signature_index,
254 u2* const constantvalue_index_addr,
255 bool* const is_synthetic_addr,
256 u2* const generic_signature_index_addr,
257 FieldAnnotationCollector* parsed_annotations,
258 TRAPS);
259
260 void parse_fields(const ClassFileStream* const cfs,
261 bool is_interface,
262 ConstantPool* cp,
263 const int cp_size,
264 u2* const java_fields_count_ptr,
265 TRAPS);
266
267 // Method parsing
268 Method* parse_method(const ClassFileStream* const cfs,
269 bool is_interface,
270 const ConstantPool* cp,
271 bool* const has_localvariable_table,
272 TRAPS);
273
274 void parse_methods(const ClassFileStream* const cfs,
275 bool is_interface,
276 bool* const has_localvariable_table,
277 bool* const has_final_method,
278 bool* const declares_nonstatic_concrete_methods,
279 TRAPS);
280
281 const unsafe_u2* parse_exception_table(const ClassFileStream* const stream,
282 u4 code_length,
283 u4 exception_table_length,
284 TRAPS);
285
286 void parse_linenumber_table(u4 code_attribute_length,
287 u4 code_length,
288 CompressedLineNumberWriteStream**const write_stream,
289 TRAPS);
290
291 const unsafe_u2* parse_localvariable_table(const ClassFileStream* const cfs,
292 u4 code_length,
293 u2 max_locals,
294 u4 code_attribute_length,
295 u2* const localvariable_table_length,
310
311 // Check for circularity in InnerClasses attribute.
312 bool check_inner_classes_circularity(const ConstantPool* cp, int length, TRAPS);
313
314 u2 parse_classfile_inner_classes_attribute(const ClassFileStream* const cfs,
315 const ConstantPool* cp,
316 const u1* const inner_classes_attribute_start,
317 bool parsed_enclosingmethod_attribute,
318 u2 enclosing_method_class_index,
319 u2 enclosing_method_method_index,
320 TRAPS);
321
322 u2 parse_classfile_nest_members_attribute(const ClassFileStream* const cfs,
323 const u1* const nest_members_attribute_start,
324 TRAPS);
325
326 u2 parse_classfile_permitted_subclasses_attribute(const ClassFileStream* const cfs,
327 const u1* const permitted_subclasses_attribute_start,
328 TRAPS);
329
330 u4 parse_classfile_record_attribute(const ClassFileStream* const cfs,
331 const ConstantPool* cp,
332 const u1* const record_attribute_start,
333 TRAPS);
334
335 void parse_classfile_attributes(const ClassFileStream* const cfs,
336 ConstantPool* cp,
337 ClassAnnotationCollector* parsed_annotations,
338 TRAPS);
339
340 void parse_classfile_synthetic_attribute();
341 void parse_classfile_signature_attribute(const ClassFileStream* const cfs, TRAPS);
342 void parse_classfile_bootstrap_methods_attribute(const ClassFileStream* const cfs,
343 ConstantPool* cp,
344 u4 attribute_length,
345 TRAPS);
346
347 // Annotations handling
348 AnnotationArray* allocate_annotations(const u1* const anno,
349 int anno_length,
398 const char *name,
399 TRAPS) const {
400 if (!b) { classfile_parse_error(msg, index, name, THREAD); return; }
401 }
402
403 void throwIllegalSignature(const char* type,
404 const Symbol* name,
405 const Symbol* sig,
406 TRAPS) const;
407
408 void verify_constantvalue(const ConstantPool* const cp,
409 int constantvalue_index,
410 int signature_index,
411 TRAPS) const;
412
413 void verify_legal_utf8(const unsigned char* buffer, int length, TRAPS) const;
414 void verify_legal_class_name(const Symbol* name, TRAPS) const;
415 void verify_legal_field_name(const Symbol* name, TRAPS) const;
416 void verify_legal_method_name(const Symbol* name, TRAPS) const;
417
418 void verify_legal_field_signature(const Symbol* fieldname,
419 const Symbol* signature,
420 TRAPS) const;
421 int verify_legal_method_signature(const Symbol* methodname,
422 const Symbol* signature,
423 TRAPS) const;
424 void verify_legal_name_with_signature(const Symbol* name,
425 const Symbol* signature,
426 TRAPS) const;
427
428 void verify_class_version(u2 major, u2 minor, Symbol* class_name, TRAPS);
429
430 void verify_legal_class_modifiers(jint flags, TRAPS) const;
431 void verify_legal_field_modifiers(jint flags, bool is_interface, TRAPS) const;
432 void verify_legal_method_modifiers(jint flags,
433 bool is_interface,
434 const Symbol* name,
435 TRAPS) const;
436
437 void check_super_class_access(const InstanceKlass* this_klass,
438 TRAPS);
439
440 void check_super_interface_access(const InstanceKlass* this_klass,
441 TRAPS);
442
443 const char* skip_over_field_signature(const char* signature,
444 bool void_ok,
445 unsigned int length,
446 TRAPS) const;
447
448 // Wrapper for constantTag.is_klass_[or_]reference.
449 // In older versions of the VM, Klass*s cannot sneak into early phases of
450 // constant pool construction, but in later versions they can.
451 // %%% Let's phase out the old is_klass_reference.
452 bool valid_klass_reference_at(int index) const {
453 return _cp->is_within_bounds(index) &&
465 u2* const localvariable_table_length,
466 const unsafe_u2** const localvariable_table_start,
467 int lvtt_cnt,
468 u2* const localvariable_type_table_length,
469 const unsafe_u2** const localvariable_type_table_start,
470 TRAPS);
471
472 void copy_method_annotations(ConstMethod* cm,
473 const u1* runtime_visible_annotations,
474 int runtime_visible_annotations_length,
475 const u1* runtime_visible_parameter_annotations,
476 int runtime_visible_parameter_annotations_length,
477 const u1* runtime_visible_type_annotations,
478 int runtime_visible_type_annotations_length,
479 const u1* annotation_default,
480 int annotation_default_length,
481 TRAPS);
482
483 void update_class_name(Symbol* new_name);
484
485 public:
486 ClassFileParser(ClassFileStream* stream,
487 Symbol* name,
488 ClassLoaderData* loader_data,
489 const ClassLoadInfo* cl_info,
490 Publicity pub_level,
491 TRAPS);
492
493 ~ClassFileParser();
494
495 InstanceKlass* create_instance_klass(bool cf_changed_in_CFLH, const ClassInstanceInfo& cl_inst_info, TRAPS);
496
497 const ClassFileStream* clone_stream() const;
498
499 void set_klass_to_deallocate(InstanceKlass* klass);
500
501 int static_field_size() const;
502 int total_oop_map_count() const;
503 jint layout_size() const;
504
505 int vtable_size() const { return _vtable_size; }
506 int itable_size() const { return _itable_size; }
507
508 u2 this_class_index() const { return _this_class_index; }
509
510 bool is_hidden() const { return _is_hidden; }
511 bool is_interface() const { return _access_flags.is_interface(); }
512 bool is_abstract() const { return _access_flags.is_abstract(); }
513
514 ClassLoaderData* loader_data() const { return _loader_data; }
515 const Symbol* class_name() const { return _class_name; }
516 const InstanceKlass* super_klass() const { return _super_klass; }
517
518 ReferenceType super_reference_type() const;
519 bool is_instance_ref_klass() const;
520 bool is_java_lang_ref_Reference_subclass() const;
521
522 AccessFlags access_flags() const { return _access_flags; }
523
524 bool is_internal() const { return INTERNAL == _pub_level; }
525
526 static bool verify_unqualified_name(const char* name, unsigned int length, int type);
527
528 #ifdef ASSERT
529 static bool is_internal_format(Symbol* class_name);
530 #endif
531
532 };
533
534 #endif // SHARE_CLASSFILE_CLASSFILEPARSER_HPP
|
57 unsigned int _nonstatic_oop_map_count;
58 unsigned int _max_nonstatic_oop_maps;
59
60 OopMapBlocksBuilder(unsigned int max_blocks);
61 OopMapBlock* last_oop_map() const;
62 void initialize_inherited_blocks(OopMapBlock* blocks, unsigned int nof_blocks);
63 void add(int offset, int count);
64 void copy(OopMapBlock* dst);
65 void compact();
66 void print_on(outputStream* st) const;
67 void print_value_on(outputStream* st) const;
68 };
69
70 // Values needed for oopmap and InstanceKlass creation
71 class FieldLayoutInfo : public ResourceObj {
72 public:
73 OopMapBlocksBuilder* oop_map_blocks;
74 int _instance_size;
75 int _nonstatic_field_size;
76 int _static_field_size;
77 int _payload_alignment;
78 int _first_field_offset;
79 int _payload_size_in_bytes;
80 int _non_atomic_size_in_bytes;
81 int _non_atomic_alignment;
82 int _atomic_layout_size_in_bytes;
83 int _nullable_layout_size_in_bytes;
84 int _null_marker_offset;
85 int _default_value_offset;
86 int _null_reset_value_offset;
87 bool _has_nonstatic_fields;
88 bool _is_naturally_atomic;
89 bool _must_be_atomic;
90 bool _has_inline_fields;
91 bool _is_empty_inline_klass;
92 };
93
94 // Parser for for .class files
95 //
96 // The bytes describing the class file structure is read from a Stream object
97
98 class ClassFileParser {
99 friend class FieldLayoutBuilder;
100 friend class FieldLayout;
101
102 class ClassAnnotationCollector;
103 class FieldAnnotationCollector;
104
105 public:
106 // The ClassFileParser has an associated "publicity" level
107 // It is used to control which subsystems (if any)
108 // will observe the parsing (logging, events, tracing).
109 // Default level is "BROADCAST", which is equivalent to
110 // a "public" parsing attempt.
111 //
126 const ClassFileStream* _stream; // Actual input stream
127 Symbol* _class_name;
128 mutable ClassLoaderData* _loader_data;
129 const bool _is_hidden;
130 const bool _can_access_vm_annotations;
131 int _orig_cp_size;
132 unsigned int _static_oop_count;
133
134 // Metadata created before the instance klass is created. Must be deallocated
135 // if not transferred to the InstanceKlass upon successful class loading
136 // in which case these pointers have been set to null.
137 const InstanceKlass* _super_klass;
138 ConstantPool* _cp;
139 Array<u1>* _fieldinfo_stream;
140 Array<FieldStatus>* _fields_status;
141 Array<Method*>* _methods;
142 Array<u2>* _inner_classes;
143 Array<u2>* _nest_members;
144 u2 _nest_host;
145 Array<u2>* _permitted_subclasses;
146 Array<u2>* _loadable_descriptors;
147 Array<RecordComponent*>* _record_components;
148 Array<InstanceKlass*>* _local_interfaces;
149 GrowableArray<u2>* _local_interface_indexes;
150 Array<InstanceKlass*>* _transitive_interfaces;
151 Annotations* _combined_annotations;
152 AnnotationArray* _class_annotations;
153 AnnotationArray* _class_type_annotations;
154 Array<AnnotationArray*>* _fields_annotations;
155 Array<AnnotationArray*>* _fields_type_annotations;
156 InstanceKlass* _klass; // InstanceKlass* once created.
157 InstanceKlass* _klass_to_deallocate; // an InstanceKlass* to be destroyed
158
159 ClassAnnotationCollector* _parsed_annotations;
160 FieldLayoutInfo* _layout_info;
161 Array<InlineLayoutInfo>* _inline_layout_info_array;
162 GrowableArray<FieldInfo>* _temp_field_info;
163 const intArray* _method_ordering;
164 GrowableArray<Method*>* _all_mirandas;
165
166 enum { fixed_buffer_size = 128 };
167 u_char _linenumbertable_buffer[fixed_buffer_size];
168
169 // Size of Java vtable (in words)
170 int _vtable_size;
171 int _itable_size;
172
173 int _num_miranda_methods;
174
175
176 Handle _protection_domain;
177 AccessFlags _access_flags;
178
179 // for tracing and notifications
180 Publicity _pub_level;
181
182 // Used to keep track of whether a constant pool item 19 or 20 is found. These
183 // correspond to CONSTANT_Module and CONSTANT_Package tags and are not allowed
184 // in regular class files. For class file version >= 53, a CFE cannot be thrown
185 // immediately when these are seen because a NCDFE must be thrown if the class's
186 // access_flags have ACC_MODULE set. But, the access_flags haven't been looked
187 // at yet. So, the bad constant pool item is cached here. A value of zero
188 // means that no constant pool item 19 or 20 was found.
189 short _bad_constant_seen;
190
191 // class attributes parsed before the instance klass is created:
192 bool _synthetic_flag;
193 int _sde_length;
194 const char* _sde_buffer;
195 u2 _sourcefile_index;
196 u2 _generic_signature_index;
197
198 u2 _major_version;
199 u2 _minor_version;
200 u2 _this_class_index;
201 u2 _super_class_index;
202 u2 _itfs_len;
203 u2 _java_fields_count;
204
205 bool _need_verify;
206 bool _relax_verify;
207
208 bool _has_nonstatic_concrete_methods;
209 bool _declares_nonstatic_concrete_methods;
210 bool _has_localvariable_table;
211 bool _has_final_method;
212 bool _has_contended_fields;
213
214 bool _has_inline_type_fields;
215 bool _has_null_marker_offsets;
216 bool _is_naturally_atomic;
217 bool _must_be_atomic;
218 bool _is_implicitly_constructible;
219 bool _has_loosely_consistent_annotation;
220 bool _has_implicitly_constructible_annotation;
221
222 // precomputed flags
223 bool _has_finalizer;
224 bool _has_empty_finalizer;
225 int _max_bootstrap_specifier_index; // detects BSS values
226
227 void parse_stream(const ClassFileStream* const stream, TRAPS);
228
229 void mangle_hidden_class_name(InstanceKlass* const ik);
230
231 void post_process_parsed_stream(const ClassFileStream* const stream,
232 ConstantPool* cp,
233 TRAPS);
234
235 void fill_instance_klass(InstanceKlass* ik, bool cf_changed_in_CFLH,
236 const ClassInstanceInfo& cl_inst_info, TRAPS);
237
238 void set_klass(InstanceKlass* instance);
239
240 void set_class_bad_constant_seen(short bad_constant);
241 short class_bad_constant_seen() { return _bad_constant_seen; }
267 bool* has_nonstatic_concrete_methods,
268 TRAPS);
269
270 const InstanceKlass* parse_super_class(ConstantPool* const cp,
271 const int super_class_index,
272 const bool need_verify,
273 TRAPS);
274
275 // Field parsing
276 void parse_field_attributes(const ClassFileStream* const cfs,
277 u2 attributes_count,
278 bool is_static,
279 u2 signature_index,
280 u2* const constantvalue_index_addr,
281 bool* const is_synthetic_addr,
282 u2* const generic_signature_index_addr,
283 FieldAnnotationCollector* parsed_annotations,
284 TRAPS);
285
286 void parse_fields(const ClassFileStream* const cfs,
287 AccessFlags class_access_flags,
288 ConstantPool* cp,
289 const int cp_size,
290 u2* const java_fields_count_ptr,
291 TRAPS);
292
293 // Method parsing
294 Method* parse_method(const ClassFileStream* const cfs,
295 bool is_interface,
296 bool is_value_class,
297 bool is_abstract_class,
298 const ConstantPool* cp,
299 bool* const has_localvariable_table,
300 TRAPS);
301
302 void parse_methods(const ClassFileStream* const cfs,
303 bool is_interface,
304 bool is_value_class,
305 bool is_abstract_class,
306 bool* const has_localvariable_table,
307 bool* const has_final_method,
308 bool* const declares_nonstatic_concrete_methods,
309 TRAPS);
310
311 const unsafe_u2* parse_exception_table(const ClassFileStream* const stream,
312 u4 code_length,
313 u4 exception_table_length,
314 TRAPS);
315
316 void parse_linenumber_table(u4 code_attribute_length,
317 u4 code_length,
318 CompressedLineNumberWriteStream**const write_stream,
319 TRAPS);
320
321 const unsafe_u2* parse_localvariable_table(const ClassFileStream* const cfs,
322 u4 code_length,
323 u2 max_locals,
324 u4 code_attribute_length,
325 u2* const localvariable_table_length,
340
341 // Check for circularity in InnerClasses attribute.
342 bool check_inner_classes_circularity(const ConstantPool* cp, int length, TRAPS);
343
344 u2 parse_classfile_inner_classes_attribute(const ClassFileStream* const cfs,
345 const ConstantPool* cp,
346 const u1* const inner_classes_attribute_start,
347 bool parsed_enclosingmethod_attribute,
348 u2 enclosing_method_class_index,
349 u2 enclosing_method_method_index,
350 TRAPS);
351
352 u2 parse_classfile_nest_members_attribute(const ClassFileStream* const cfs,
353 const u1* const nest_members_attribute_start,
354 TRAPS);
355
356 u2 parse_classfile_permitted_subclasses_attribute(const ClassFileStream* const cfs,
357 const u1* const permitted_subclasses_attribute_start,
358 TRAPS);
359
360 u2 parse_classfile_loadable_descriptors_attribute(const ClassFileStream* const cfs,
361 const u1* const loadable_descriptors_attribute_start,
362 TRAPS);
363
364 u4 parse_classfile_record_attribute(const ClassFileStream* const cfs,
365 const ConstantPool* cp,
366 const u1* const record_attribute_start,
367 TRAPS);
368
369 void parse_classfile_attributes(const ClassFileStream* const cfs,
370 ConstantPool* cp,
371 ClassAnnotationCollector* parsed_annotations,
372 TRAPS);
373
374 void parse_classfile_synthetic_attribute();
375 void parse_classfile_signature_attribute(const ClassFileStream* const cfs, TRAPS);
376 void parse_classfile_bootstrap_methods_attribute(const ClassFileStream* const cfs,
377 ConstantPool* cp,
378 u4 attribute_length,
379 TRAPS);
380
381 // Annotations handling
382 AnnotationArray* allocate_annotations(const u1* const anno,
383 int anno_length,
432 const char *name,
433 TRAPS) const {
434 if (!b) { classfile_parse_error(msg, index, name, THREAD); return; }
435 }
436
437 void throwIllegalSignature(const char* type,
438 const Symbol* name,
439 const Symbol* sig,
440 TRAPS) const;
441
442 void verify_constantvalue(const ConstantPool* const cp,
443 int constantvalue_index,
444 int signature_index,
445 TRAPS) const;
446
447 void verify_legal_utf8(const unsigned char* buffer, int length, TRAPS) const;
448 void verify_legal_class_name(const Symbol* name, TRAPS) const;
449 void verify_legal_field_name(const Symbol* name, TRAPS) const;
450 void verify_legal_method_name(const Symbol* name, TRAPS) const;
451
452 bool legal_field_signature(const Symbol* signature, TRAPS) const;
453
454 void verify_legal_field_signature(const Symbol* fieldname,
455 const Symbol* signature,
456 TRAPS) const;
457 int verify_legal_method_signature(const Symbol* methodname,
458 const Symbol* signature,
459 TRAPS) const;
460 void verify_legal_name_with_signature(const Symbol* name,
461 const Symbol* signature,
462 TRAPS) const;
463
464 void verify_class_version(u2 major, u2 minor, Symbol* class_name, TRAPS);
465
466 void verify_legal_class_modifiers(jint flags, const char* name, bool is_Object, TRAPS) const;
467 void verify_legal_field_modifiers(jint flags,
468 AccessFlags class_access_flags,
469 TRAPS) const;
470 void verify_legal_method_modifiers(jint flags,
471 AccessFlags class_access_flags,
472 const Symbol* name,
473 TRAPS) const;
474
475 void check_super_class_access(const InstanceKlass* this_klass,
476 TRAPS);
477
478 void check_super_interface_access(const InstanceKlass* this_klass,
479 TRAPS);
480
481 const char* skip_over_field_signature(const char* signature,
482 bool void_ok,
483 unsigned int length,
484 TRAPS) const;
485
486 // Wrapper for constantTag.is_klass_[or_]reference.
487 // In older versions of the VM, Klass*s cannot sneak into early phases of
488 // constant pool construction, but in later versions they can.
489 // %%% Let's phase out the old is_klass_reference.
490 bool valid_klass_reference_at(int index) const {
491 return _cp->is_within_bounds(index) &&
503 u2* const localvariable_table_length,
504 const unsafe_u2** const localvariable_table_start,
505 int lvtt_cnt,
506 u2* const localvariable_type_table_length,
507 const unsafe_u2** const localvariable_type_table_start,
508 TRAPS);
509
510 void copy_method_annotations(ConstMethod* cm,
511 const u1* runtime_visible_annotations,
512 int runtime_visible_annotations_length,
513 const u1* runtime_visible_parameter_annotations,
514 int runtime_visible_parameter_annotations_length,
515 const u1* runtime_visible_type_annotations,
516 int runtime_visible_type_annotations_length,
517 const u1* annotation_default,
518 int annotation_default_length,
519 TRAPS);
520
521 void update_class_name(Symbol* new_name);
522
523 // Check if the class file supports inline types
524 bool supports_inline_types() const;
525
526 public:
527 ClassFileParser(ClassFileStream* stream,
528 Symbol* name,
529 ClassLoaderData* loader_data,
530 const ClassLoadInfo* cl_info,
531 Publicity pub_level,
532 TRAPS);
533
534 ~ClassFileParser();
535
536 InstanceKlass* create_instance_klass(bool cf_changed_in_CFLH, const ClassInstanceInfo& cl_inst_info, TRAPS);
537
538 const ClassFileStream* clone_stream() const;
539
540 void set_klass_to_deallocate(InstanceKlass* klass);
541
542 int static_field_size() const;
543 int total_oop_map_count() const;
544 jint layout_size() const;
545
546 int vtable_size() const { return _vtable_size; }
547 int itable_size() const { return _itable_size; }
548
549 u2 this_class_index() const { return _this_class_index; }
550
551 bool is_hidden() const { return _is_hidden; }
552 bool is_interface() const { return _access_flags.is_interface(); }
553 // Being an inline type means being a concrete value class
554 bool is_inline_type() const { return !_access_flags.is_identity_class() && !_access_flags.is_interface() && !_access_flags.is_abstract(); }
555 bool is_abstract_class() const { return _access_flags.is_abstract(); }
556 bool is_identity_class() const { return _access_flags.is_identity_class(); }
557 bool has_inline_fields() const { return _has_inline_type_fields; }
558
559 u2 java_fields_count() const { return _java_fields_count; }
560 bool is_abstract() const { return _access_flags.is_abstract(); }
561
562 ClassLoaderData* loader_data() const { return _loader_data; }
563 const Symbol* class_name() const { return _class_name; }
564 const InstanceKlass* super_klass() const { return _super_klass; }
565
566 ReferenceType super_reference_type() const;
567 bool is_instance_ref_klass() const;
568 bool is_java_lang_ref_Reference_subclass() const;
569
570 AccessFlags access_flags() const { return _access_flags; }
571
572 bool is_internal() const { return INTERNAL == _pub_level; }
573
574 bool is_class_in_loadable_descriptors_attribute(Symbol *klass);
575
576 static bool verify_unqualified_name(const char* name, unsigned int length, int type);
577
578 #ifdef ASSERT
579 static bool is_internal_format(Symbol* class_name);
580 #endif
581
582 };
583
584 #endif // SHARE_CLASSFILE_CLASSFILEPARSER_HPP
|