< prev index next >

src/hotspot/share/oops/instanceKlass.hpp

Print this page
rev 58565 : 8238358: Implementation of JEP 371: Hidden Classes
Reviewed-by: duke
Contributed-by: mandy.chung@oracle.com, lois.foltan@oracle.com, david.holmes@oracle.com, harold.seigel@oracle.com, serguei.spitsyn@oracle.com, alex.buckley@oracle.com, jamsheed.c.m@oracle.com


 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.


 452   int java_fields_count() const           { return (int)_java_fields_count; }
 453 
 454   Array<u2>* fields() const            { return _fields; }
 455   void set_fields(Array<u2>* f, u2 java_fields_count) {
 456     guarantee(_fields == NULL || f == NULL, "Just checking");
 457     _fields = f;
 458     _java_fields_count = java_fields_count;
 459   }
 460 
 461   // inner classes
 462   Array<u2>* inner_classes() const       { return _inner_classes; }
 463   void set_inner_classes(Array<u2>* f)   { _inner_classes = f; }
 464 
 465   // nest members
 466   Array<u2>* nest_members() const     { return _nest_members; }
 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 
 473   // record components
 474   Array<RecordComponent*>* record_components() const { return _record_components; }
 475   void set_record_components(Array<RecordComponent*>* record_components) {
 476     _record_components = record_components;
 477   }
 478   bool is_record() const { return _record_components != NULL; }
 479 
 480 private:
 481   // Called to verify that k is a member of this nest - does not look at k's nest-host
 482   bool has_nest_member(InstanceKlass* k, TRAPS) const;
 483 
 484 public:
 485   // Returns nest-host class, resolving and validating it if needed
 486   // Returns NULL if an exception occurs during loading, or validation fails
 487   InstanceKlass* nest_host(Symbol* validationException, TRAPS);




 488   // Check if this klass is a nestmate of k - resolves this nest-host and k's
 489   bool has_nestmate_access_to(InstanceKlass* k, TRAPS);
 490 
 491   enum InnerClassAttributeOffset {
 492     // From http://mirror.eng/products/jdk/1.1/docs/guide/innerclasses/spec/innerclasses.doc10.html#18814
 493     inner_class_inner_class_info_offset = 0,
 494     inner_class_outer_class_info_offset = 1,
 495     inner_class_inner_name_offset = 2,
 496     inner_class_access_flags_offset = 3,
 497     inner_class_next_offset = 4
 498   };
 499 
 500   enum EnclosingMethodAttributeOffset {
 501     enclosing_method_class_index_offset = 0,
 502     enclosing_method_method_index_offset = 1,
 503     enclosing_method_attribute_size = 2
 504   };
 505 
 506   // method override check
 507   bool is_override(const methodHandle& super_method, Handle targetclassloader, Symbol* targetclassname, TRAPS);


 795 
 796   bool has_been_redefined() const {
 797     return (_misc_flags & _misc_has_been_redefined) != 0;
 798   }
 799   void set_has_been_redefined() {
 800     _misc_flags |= _misc_has_been_redefined;
 801   }
 802 
 803   bool has_passed_fingerprint_check() const {
 804     return (_misc_flags & _misc_has_passed_fingerprint_check) != 0;
 805   }
 806   void set_has_passed_fingerprint_check(bool b) {
 807     if (b) {
 808       _misc_flags |= _misc_has_passed_fingerprint_check;
 809     } else {
 810       _misc_flags &= ~_misc_has_passed_fingerprint_check;
 811     }
 812   }
 813   bool supers_have_passed_fingerprint_checks();
 814 
 815   static bool should_store_fingerprint(bool is_unsafe_anonymous);
 816   bool should_store_fingerprint() const { return should_store_fingerprint(is_unsafe_anonymous()); }
 817   bool has_stored_fingerprint() const;
 818   uint64_t get_stored_fingerprint() const;
 819   void store_fingerprint(uint64_t fingerprint);
 820 
 821   bool is_scratch_class() const {
 822     return (_misc_flags & _misc_is_scratch_class) != 0;
 823   }
 824 
 825   void set_is_scratch_class() {
 826     _misc_flags |= _misc_is_scratch_class;
 827   }
 828 
 829   bool has_resolved_methods() const {
 830     return (_misc_flags & _misc_has_resolved_methods) != 0;
 831   }
 832 
 833   void set_has_resolved_methods() {
 834     _misc_flags |= _misc_has_resolved_methods;
 835   }
 836 private:




 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   // The contents of the Record attribute.
 206   Array<RecordComponent*>* _record_components;
 207 
 208   // the source debug extension for this klass, NULL if not specified.
 209   // Specified as UTF-8 string without terminating zero byte in the classfile,
 210   // it is stored in the instanceklass as a NULL-terminated UTF-8 string
 211   const char*     _source_debug_extension;
 212   // Array name derived from this class which needs unreferencing
 213   // if this class is unloaded.
 214   Symbol*         _array_name;
 215 
 216   // Number of heapOopSize words used by non-static fields in this klass
 217   // (including inherited fields but after header_size()).
 218   int             _nonstatic_field_size;
 219   int             _static_field_size;    // number words used by static fields (oop and non-oop) in this klass
 220   // Constant pool index to the utf8 entry of the Generic signature,
 221   // or 0 if none.


 455   int java_fields_count() const           { return (int)_java_fields_count; }
 456 
 457   Array<u2>* fields() const            { return _fields; }
 458   void set_fields(Array<u2>* f, u2 java_fields_count) {
 459     guarantee(_fields == NULL || f == NULL, "Just checking");
 460     _fields = f;
 461     _java_fields_count = java_fields_count;
 462   }
 463 
 464   // inner classes
 465   Array<u2>* inner_classes() const       { return _inner_classes; }
 466   void set_inner_classes(Array<u2>* f)   { _inner_classes = f; }
 467 
 468   // nest members
 469   Array<u2>* nest_members() const     { return _nest_members; }
 470   void set_nest_members(Array<u2>* m) { _nest_members = m; }
 471 
 472   // nest-host index
 473   jushort nest_host_index() const { return _nest_host_index; }
 474   void set_nest_host_index(u2 i)  { _nest_host_index = i; }
 475   // dynamic nest member support
 476   void set_nest_host(InstanceKlass* host, TRAPS);
 477 
 478   // record components
 479   Array<RecordComponent*>* record_components() const { return _record_components; }
 480   void set_record_components(Array<RecordComponent*>* record_components) {
 481     _record_components = record_components;
 482   }
 483   bool is_record() const { return _record_components != NULL; }
 484 
 485 private:
 486   // Called to verify that k is a member of this nest - does not look at k's nest-host
 487   bool has_nest_member(InstanceKlass* k, TRAPS) const;
 488 
 489 public:
 490   // Used to construct informative IllegalAccessError messages at a higher level,
 491   // if there was an issue resolving or validating the nest host.
 492   // Returns NULL if there was no error.
 493   const char* nest_host_error(TRAPS);
 494   // Returns nest-host class, resolving and validating it if needed.
 495   // Returns NULL if resolution is not possible from the calling context.
 496   InstanceKlass* nest_host(TRAPS);
 497   // Check if this klass is a nestmate of k - resolves this nest-host and k's
 498   bool has_nestmate_access_to(InstanceKlass* k, TRAPS);
 499 
 500   enum InnerClassAttributeOffset {
 501     // From http://mirror.eng/products/jdk/1.1/docs/guide/innerclasses/spec/innerclasses.doc10.html#18814
 502     inner_class_inner_class_info_offset = 0,
 503     inner_class_outer_class_info_offset = 1,
 504     inner_class_inner_name_offset = 2,
 505     inner_class_access_flags_offset = 3,
 506     inner_class_next_offset = 4
 507   };
 508 
 509   enum EnclosingMethodAttributeOffset {
 510     enclosing_method_class_index_offset = 0,
 511     enclosing_method_method_index_offset = 1,
 512     enclosing_method_attribute_size = 2
 513   };
 514 
 515   // method override check
 516   bool is_override(const methodHandle& super_method, Handle targetclassloader, Symbol* targetclassname, TRAPS);


 804 
 805   bool has_been_redefined() const {
 806     return (_misc_flags & _misc_has_been_redefined) != 0;
 807   }
 808   void set_has_been_redefined() {
 809     _misc_flags |= _misc_has_been_redefined;
 810   }
 811 
 812   bool has_passed_fingerprint_check() const {
 813     return (_misc_flags & _misc_has_passed_fingerprint_check) != 0;
 814   }
 815   void set_has_passed_fingerprint_check(bool b) {
 816     if (b) {
 817       _misc_flags |= _misc_has_passed_fingerprint_check;
 818     } else {
 819       _misc_flags &= ~_misc_has_passed_fingerprint_check;
 820     }
 821   }
 822   bool supers_have_passed_fingerprint_checks();
 823 
 824   static bool should_store_fingerprint(bool is_hidden_or_anonymous);
 825   bool should_store_fingerprint() const { return should_store_fingerprint(is_hidden() || is_unsafe_anonymous()); }
 826   bool has_stored_fingerprint() const;
 827   uint64_t get_stored_fingerprint() const;
 828   void store_fingerprint(uint64_t fingerprint);
 829 
 830   bool is_scratch_class() const {
 831     return (_misc_flags & _misc_is_scratch_class) != 0;
 832   }
 833 
 834   void set_is_scratch_class() {
 835     _misc_flags |= _misc_is_scratch_class;
 836   }
 837 
 838   bool has_resolved_methods() const {
 839     return (_misc_flags & _misc_has_resolved_methods) != 0;
 840   }
 841 
 842   void set_has_resolved_methods() {
 843     _misc_flags |= _misc_has_resolved_methods;
 844   }
 845 private:


< prev index next >