178 // attribute, then the _inner_classes array begins with 4-tuples of shorts
179 // [inner_class_info_index, outer_class_info_index,
180 // inner_name_index, inner_class_access_flags] for the InnerClasses
181 // attribute. If the EnclosingMethod attribute exists, it occupies the
182 // last two shorts [class_index, method_index] of the array. If only
183 // the InnerClasses attribute exists, the _inner_classes array length is
184 // number_of_inner_classes * 4. If the class has both InnerClasses
185 // and EnclosingMethod attributes the _inner_classes array length is
186 // number_of_inner_classes * 4 + enclosing_method_attribute_size.
187 Array<jushort>* _inner_classes;
188
189 // The NestMembers attribute. An array of shorts, where each is a
190 // class info index for the class that is a nest member. This data
191 // has not been validated.
192 Array<jushort>* _nest_members;
193
194 // The NestHost attribute. The class info index for the class
195 // that is the nest-host of this class. This data has not been validated.
196 jushort _nest_host_index;
197
198 // Resolved nest-host klass: either true nest-host or self if we are not nested.
199 // By always being set it makes nest-member access checks simpler.
200 InstanceKlass* _nest_host;
201
202 // The contents of the Record attribute.
203 Array<RecordComponent*>* _record_components;
204
205 // the source debug extension for this klass, NULL if not specified.
206 // Specified as UTF-8 string without terminating zero byte in the classfile,
207 // it is stored in the instanceklass as a NULL-terminated UTF-8 string
208 const char* _source_debug_extension;
209 // Array name derived from this class which needs unreferencing
210 // if this class is unloaded.
211 Symbol* _array_name;
212
213 // Number of heapOopSize words used by non-static fields in this klass
214 // (including inherited fields but after header_size()).
215 int _nonstatic_field_size;
216 int _static_field_size; // number words used by static fields (oop and non-oop) in this klass
217 // Constant pool index to the utf8 entry of the Generic signature,
218 // or 0 if none.
219 u2 _generic_signature_index;
220 // Constant pool index to the utf8 entry for the name of source file
221 // containing this klass, 0 if not specified.
467 void set_nest_members(Array<u2>* m) { _nest_members = m; }
468
469 // nest-host index
470 jushort nest_host_index() const { return _nest_host_index; }
471 void set_nest_host_index(u2 i) { _nest_host_index = i; }
472 // dynamic nest member support
473 void set_nest_host(InstanceKlass* host, TRAPS);
474
475 // record components
476 Array<RecordComponent*>* record_components() const { return _record_components; }
477 void set_record_components(Array<RecordComponent*>* record_components) {
478 _record_components = record_components;
479 }
480 bool is_record() const { return _record_components != NULL; }
481
482 private:
483 // Called to verify that k is a member of this nest - does not look at k's nest-host
484 bool has_nest_member(InstanceKlass* k, TRAPS) const;
485
486 public:
487 // Returns nest-host class, resolving and validating it if needed
488 // Returns NULL if an exception occurs during loading, or validation fails
489 InstanceKlass* nest_host(Symbol* validationException, TRAPS);
490 // Check if this klass is a nestmate of k - resolves this nest-host and k's
491 bool has_nestmate_access_to(InstanceKlass* k, TRAPS);
492 // Returns the runtime nest host. If static nest host is valid, set the nest host;
493 // otherwise this klass is the host of a nest; all errors are ignored
494 InstanceKlass* runtime_nest_host(TRAPS);
495
496 enum InnerClassAttributeOffset {
497 // From http://mirror.eng/products/jdk/1.1/docs/guide/innerclasses/spec/innerclasses.doc10.html#18814
498 inner_class_inner_class_info_offset = 0,
499 inner_class_outer_class_info_offset = 1,
500 inner_class_inner_name_offset = 2,
501 inner_class_access_flags_offset = 3,
502 inner_class_next_offset = 4
503 };
504
505 enum EnclosingMethodAttributeOffset {
506 enclosing_method_class_index_offset = 0,
507 enclosing_method_method_index_offset = 1,
508 enclosing_method_attribute_size = 2
509 };
510
511 // method override check
512 bool is_override(const methodHandle& super_method, Handle targetclassloader, Symbol* targetclassname, TRAPS);
513
514 // package
|
178 // attribute, then the _inner_classes array begins with 4-tuples of shorts
179 // [inner_class_info_index, outer_class_info_index,
180 // inner_name_index, inner_class_access_flags] for the InnerClasses
181 // attribute. If the EnclosingMethod attribute exists, it occupies the
182 // last two shorts [class_index, method_index] of the array. If only
183 // the InnerClasses attribute exists, the _inner_classes array length is
184 // number_of_inner_classes * 4. If the class has both InnerClasses
185 // and EnclosingMethod attributes the _inner_classes array length is
186 // number_of_inner_classes * 4 + enclosing_method_attribute_size.
187 Array<jushort>* _inner_classes;
188
189 // The NestMembers attribute. An array of shorts, where each is a
190 // class info index for the class that is a nest member. This data
191 // has not been validated.
192 Array<jushort>* _nest_members;
193
194 // The NestHost attribute. The class info index for the class
195 // that is the nest-host of this class. This data has not been validated.
196 jushort _nest_host_index;
197
198 // Resolved nest-host klass: either true nest-host or self if we are not
199 // nested, or an error occurred resolving or validating the nominated
200 // nest-host. Can also be set directly by JDK API's that establish nest
201 // relationships.
202 // By always being set it makes nest-member access checks simpler.
203 InstanceKlass* _nest_host;
204
205 // Used to record a reason for nest-host resolution/validation failures.
206 const char* _nest_host_res_error;
207
208 // The contents of the Record attribute.
209 Array<RecordComponent*>* _record_components;
210
211 // the source debug extension for this klass, NULL if not specified.
212 // Specified as UTF-8 string without terminating zero byte in the classfile,
213 // it is stored in the instanceklass as a NULL-terminated UTF-8 string
214 const char* _source_debug_extension;
215 // Array name derived from this class which needs unreferencing
216 // if this class is unloaded.
217 Symbol* _array_name;
218
219 // Number of heapOopSize words used by non-static fields in this klass
220 // (including inherited fields but after header_size()).
221 int _nonstatic_field_size;
222 int _static_field_size; // number words used by static fields (oop and non-oop) in this klass
223 // Constant pool index to the utf8 entry of the Generic signature,
224 // or 0 if none.
225 u2 _generic_signature_index;
226 // Constant pool index to the utf8 entry for the name of source file
227 // containing this klass, 0 if not specified.
473 void set_nest_members(Array<u2>* m) { _nest_members = m; }
474
475 // nest-host index
476 jushort nest_host_index() const { return _nest_host_index; }
477 void set_nest_host_index(u2 i) { _nest_host_index = i; }
478 // dynamic nest member support
479 void set_nest_host(InstanceKlass* host, TRAPS);
480
481 // record components
482 Array<RecordComponent*>* record_components() const { return _record_components; }
483 void set_record_components(Array<RecordComponent*>* record_components) {
484 _record_components = record_components;
485 }
486 bool is_record() const { return _record_components != NULL; }
487
488 private:
489 // Called to verify that k is a member of this nest - does not look at k's nest-host
490 bool has_nest_member(InstanceKlass* k, TRAPS) const;
491
492 public:
493 // Used to construct informative IllegalAccessError messages at a higher level.
494 // Returns NULL if there was no error.
495 const char* nest_host_resolution_error() { return _nest_host_res_error; }
496 // Returns nest-host class, resolving and validating it if needed.
497 // Returns NULL if resolution is not possible from the calling context.
498 InstanceKlass* nest_host(TRAPS);
499 // Check if this klass is a nestmate of k - resolves this nest-host and k's
500 bool has_nestmate_access_to(InstanceKlass* k, TRAPS);
501
502 enum InnerClassAttributeOffset {
503 // From http://mirror.eng/products/jdk/1.1/docs/guide/innerclasses/spec/innerclasses.doc10.html#18814
504 inner_class_inner_class_info_offset = 0,
505 inner_class_outer_class_info_offset = 1,
506 inner_class_inner_name_offset = 2,
507 inner_class_access_flags_offset = 3,
508 inner_class_next_offset = 4
509 };
510
511 enum EnclosingMethodAttributeOffset {
512 enclosing_method_class_index_offset = 0,
513 enclosing_method_method_index_offset = 1,
514 enclosing_method_attribute_size = 2
515 };
516
517 // method override check
518 bool is_override(const methodHandle& super_method, Handle targetclassloader, Symbol* targetclassname, TRAPS);
519
520 // package
|