145 Annotations* _annotations; 146 // Package this class is defined in 147 PackageEntry* _package_entry; 148 // Array classes holding elements of this class. 149 Klass* volatile _array_klasses; 150 // Constant pool for this class. 151 ConstantPool* _constants; 152 // The InnerClasses attribute and EnclosingMethod attribute. The 153 // _inner_classes is an array of shorts. If the class has InnerClasses 154 // attribute, then the _inner_classes array begins with 4-tuples of shorts 155 // [inner_class_info_index, outer_class_info_index, 156 // inner_name_index, inner_class_access_flags] for the InnerClasses 157 // attribute. If the EnclosingMethod attribute exists, it occupies the 158 // last two shorts [class_index, method_index] of the array. If only 159 // the InnerClasses attribute exists, the _inner_classes array length is 160 // number_of_inner_classes * 4. If the class has both InnerClasses 161 // and EnclosingMethod attributes the _inner_classes array length is 162 // number_of_inner_classes * 4 + enclosing_method_attribute_size. 163 Array<jushort>* _inner_classes; 164 165 // the source debug extension for this klass, NULL if not specified. 166 // Specified as UTF-8 string without terminating zero byte in the classfile, 167 // it is stored in the instanceklass as a NULL-terminated UTF-8 string 168 const char* _source_debug_extension; 169 // Array name derived from this class which needs unreferencing 170 // if this class is unloaded. 171 Symbol* _array_name; 172 173 // Number of heapOopSize words used by non-static fields in this klass 174 // (including inherited fields but after header_size()). 175 int _nonstatic_field_size; 176 int _static_field_size; // number words used by static fields (oop and non-oop) in this klass 177 // Constant pool index to the utf8 entry of the Generic signature, 178 // or 0 if none. 179 u2 _generic_signature_index; 180 // Constant pool index to the utf8 entry for the name of source file 181 // containing this klass, 0 if not specified. 182 u2 _source_file_name_index; 183 u2 _static_oop_field_count;// number of static oop fields in this klass 184 u2 _java_fields_count; // The number of declared Java fields 411 public: 412 int field_offset (int index) const { return field(index)->offset(); } 413 int field_access_flags(int index) const { return field(index)->access_flags(); } 414 Symbol* field_name (int index) const { return field(index)->name(constants()); } 415 Symbol* field_signature (int index) const { return field(index)->signature(constants()); } 416 417 // Number of Java declared fields 418 int java_fields_count() const { return (int)_java_fields_count; } 419 420 Array<u2>* fields() const { return _fields; } 421 void set_fields(Array<u2>* f, u2 java_fields_count) { 422 guarantee(_fields == NULL || f == NULL, "Just checking"); 423 _fields = f; 424 _java_fields_count = java_fields_count; 425 } 426 427 // inner classes 428 Array<u2>* inner_classes() const { return _inner_classes; } 429 void set_inner_classes(Array<u2>* f) { _inner_classes = f; } 430 431 enum InnerClassAttributeOffset { 432 // From http://mirror.eng/products/jdk/1.1/docs/guide/innerclasses/spec/innerclasses.doc10.html#18814 433 inner_class_inner_class_info_offset = 0, 434 inner_class_outer_class_info_offset = 1, 435 inner_class_inner_name_offset = 2, 436 inner_class_access_flags_offset = 3, 437 inner_class_next_offset = 4 438 }; 439 440 enum EnclosingMethodAttributeOffset { 441 enclosing_method_class_index_offset = 0, 442 enclosing_method_method_index_offset = 1, 443 enclosing_method_attribute_size = 2 444 }; 445 446 // method override check 447 bool is_override(const methodHandle& super_method, Handle targetclassloader, Symbol* targetclassname, TRAPS); 448 449 // package 450 PackageEntry* package() const { return _package_entry; } 530 // find field according to JVM spec 5.4.3.2, returns the klass in which the field is defined 531 Klass* find_field(Symbol* name, Symbol* sig, fieldDescriptor* fd) const; 532 // find instance or static fields according to JVM spec 5.4.3.2, returns the klass in which the field is defined 533 Klass* find_field(Symbol* name, Symbol* sig, bool is_static, fieldDescriptor* fd) const; 534 535 // find a non-static or static field given its offset within the class. 536 bool contains_field_offset(int offset) { 537 return instanceOopDesc::contains_field_offset(offset, nonstatic_field_size()); 538 } 539 540 bool find_local_field_from_offset(int offset, bool is_static, fieldDescriptor* fd) const; 541 bool find_field_from_offset(int offset, bool is_static, fieldDescriptor* fd) const; 542 543 // find a local method (returns NULL if not found) 544 Method* find_method(const Symbol* name, const Symbol* signature) const; 545 static Method* find_method(const Array<Method*>* methods, 546 const Symbol* name, 547 const Symbol* signature); 548 549 // find a local method, but skip static methods 550 Method* find_instance_method(const Symbol* name, const Symbol* signature) const; 551 static Method* find_instance_method(const Array<Method*>* methods, 552 const Symbol* name, 553 const Symbol* signature); 554 555 // find a local method (returns NULL if not found) 556 Method* find_local_method(const Symbol* name, 557 const Symbol* signature, 558 OverpassLookupMode overpass_mode, 559 StaticLookupMode static_mode, 560 PrivateLookupMode private_mode) const; 561 562 // find a local method from given methods array (returns NULL if not found) 563 static Method* find_local_method(const Array<Method*>* methods, 564 const Symbol* name, 565 const Symbol* signature, 566 OverpassLookupMode overpass_mode, 567 StaticLookupMode static_mode, 568 PrivateLookupMode private_mode); 569 570 // find a local method index in methods or default_methods (returns -1 if not found) 571 static int find_method_index(const Array<Method*>* methods, 572 const Symbol* name, 573 const Symbol* signature, 574 OverpassLookupMode overpass_mode, 575 StaticLookupMode static_mode, 576 PrivateLookupMode private_mode); 577 578 // lookup operation (returns NULL if not found) 579 Method* uncached_lookup_method(const Symbol* name, 580 const Symbol* signature, 581 OverpassLookupMode overpass_mode) const; 582 583 // lookup a method in all the interfaces that this class implements 584 // (returns NULL if not found) 585 Method* lookup_method_in_all_interfaces(Symbol* name, Symbol* signature, DefaultsLookupMode defaults_mode) const; 586 587 // lookup a method in local defaults then in all interfaces 588 // (returns NULL if not found) 589 Method* lookup_method_in_ordered_interfaces(Symbol* name, Symbol* signature) const; 590 591 // Find method indices by name. If a method with the specified name is 592 // found the index to the first method is returned, and 'end' is filled in 593 // with the index of first non-name-matching method. If no method is found 594 // -1 is returned. 595 int find_method_by_name(const Symbol* name, int* end) const; 596 static int find_method_by_name(const Array<Method*>* methods, 597 const Symbol* name, int* end); 598 599 // constant pool 600 ConstantPool* constants() const { return _constants; } 601 void set_constants(ConstantPool* c) { _constants = c; } | 145 Annotations* _annotations; 146 // Package this class is defined in 147 PackageEntry* _package_entry; 148 // Array classes holding elements of this class. 149 Klass* volatile _array_klasses; 150 // Constant pool for this class. 151 ConstantPool* _constants; 152 // The InnerClasses attribute and EnclosingMethod attribute. The 153 // _inner_classes is an array of shorts. If the class has InnerClasses 154 // attribute, then the _inner_classes array begins with 4-tuples of shorts 155 // [inner_class_info_index, outer_class_info_index, 156 // inner_name_index, inner_class_access_flags] for the InnerClasses 157 // attribute. If the EnclosingMethod attribute exists, it occupies the 158 // last two shorts [class_index, method_index] of the array. If only 159 // the InnerClasses attribute exists, the _inner_classes array length is 160 // number_of_inner_classes * 4. If the class has both InnerClasses 161 // and EnclosingMethod attributes the _inner_classes array length is 162 // number_of_inner_classes * 4 + enclosing_method_attribute_size. 163 Array<jushort>* _inner_classes; 164 165 // The NestMembers attribute. An array of shorts, where each is a 166 // class info index for the class that is a nest member. This data 167 // has not been validated. 168 Array<jushort>* _nest_members; 169 170 // The NestHost attribute. The class info index for the class 171 // that is the nest-host of this class. This data has not been validated. 172 jushort _nest_host_index; 173 174 // Resolved nest-host klass: either true nest-host or self if we are not nested. 175 // By always being set it makes nest-member access checks simpler. 176 InstanceKlass* _nest_host; 177 178 // the source debug extension for this klass, NULL if not specified. 179 // Specified as UTF-8 string without terminating zero byte in the classfile, 180 // it is stored in the instanceklass as a NULL-terminated UTF-8 string 181 const char* _source_debug_extension; 182 // Array name derived from this class which needs unreferencing 183 // if this class is unloaded. 184 Symbol* _array_name; 185 186 // Number of heapOopSize words used by non-static fields in this klass 187 // (including inherited fields but after header_size()). 188 int _nonstatic_field_size; 189 int _static_field_size; // number words used by static fields (oop and non-oop) in this klass 190 // Constant pool index to the utf8 entry of the Generic signature, 191 // or 0 if none. 192 u2 _generic_signature_index; 193 // Constant pool index to the utf8 entry for the name of source file 194 // containing this klass, 0 if not specified. 195 u2 _source_file_name_index; 196 u2 _static_oop_field_count;// number of static oop fields in this klass 197 u2 _java_fields_count; // The number of declared Java fields 424 public: 425 int field_offset (int index) const { return field(index)->offset(); } 426 int field_access_flags(int index) const { return field(index)->access_flags(); } 427 Symbol* field_name (int index) const { return field(index)->name(constants()); } 428 Symbol* field_signature (int index) const { return field(index)->signature(constants()); } 429 430 // Number of Java declared fields 431 int java_fields_count() const { return (int)_java_fields_count; } 432 433 Array<u2>* fields() const { return _fields; } 434 void set_fields(Array<u2>* f, u2 java_fields_count) { 435 guarantee(_fields == NULL || f == NULL, "Just checking"); 436 _fields = f; 437 _java_fields_count = java_fields_count; 438 } 439 440 // inner classes 441 Array<u2>* inner_classes() const { return _inner_classes; } 442 void set_inner_classes(Array<u2>* f) { _inner_classes = f; } 443 444 // nest members 445 Array<u2>* nest_members() const { return _nest_members; } 446 void set_nest_members(Array<u2>* m) { _nest_members = m; } 447 448 // nest-host index 449 jushort nest_host_index() const { return _nest_host_index; } 450 void set_nest_host_index(u2 i) { _nest_host_index = i; } 451 452 // Returns nest-host class, resolving and validating it if needed 453 // Returns NULL if an exception occurs during loading, or validation fails 454 InstanceKlass* nest_host(Symbol* validationException, TRAPS); 455 InstanceKlass* raw_nest_host() { return _nest_host; } // debugging 456 457 // Called to verify that k is a member of this nest - does not look at k's nest-host 458 bool has_nest_member(InstanceKlass* k, TRAPS) const; 459 // Check if this klass is a nestmate of k - resolves this nest-host and k's 460 bool has_nestmate_access_to(InstanceKlass* k, TRAPS); 461 462 enum InnerClassAttributeOffset { 463 // From http://mirror.eng/products/jdk/1.1/docs/guide/innerclasses/spec/innerclasses.doc10.html#18814 464 inner_class_inner_class_info_offset = 0, 465 inner_class_outer_class_info_offset = 1, 466 inner_class_inner_name_offset = 2, 467 inner_class_access_flags_offset = 3, 468 inner_class_next_offset = 4 469 }; 470 471 enum EnclosingMethodAttributeOffset { 472 enclosing_method_class_index_offset = 0, 473 enclosing_method_method_index_offset = 1, 474 enclosing_method_attribute_size = 2 475 }; 476 477 // method override check 478 bool is_override(const methodHandle& super_method, Handle targetclassloader, Symbol* targetclassname, TRAPS); 479 480 // package 481 PackageEntry* package() const { return _package_entry; } 561 // find field according to JVM spec 5.4.3.2, returns the klass in which the field is defined 562 Klass* find_field(Symbol* name, Symbol* sig, fieldDescriptor* fd) const; 563 // find instance or static fields according to JVM spec 5.4.3.2, returns the klass in which the field is defined 564 Klass* find_field(Symbol* name, Symbol* sig, bool is_static, fieldDescriptor* fd) const; 565 566 // find a non-static or static field given its offset within the class. 567 bool contains_field_offset(int offset) { 568 return instanceOopDesc::contains_field_offset(offset, nonstatic_field_size()); 569 } 570 571 bool find_local_field_from_offset(int offset, bool is_static, fieldDescriptor* fd) const; 572 bool find_field_from_offset(int offset, bool is_static, fieldDescriptor* fd) const; 573 574 // find a local method (returns NULL if not found) 575 Method* find_method(const Symbol* name, const Symbol* signature) const; 576 static Method* find_method(const Array<Method*>* methods, 577 const Symbol* name, 578 const Symbol* signature); 579 580 // find a local method, but skip static methods 581 Method* find_instance_method(const Symbol* name, const Symbol* signature, 582 PrivateLookupMode private_mode = find_private) const; 583 static Method* find_instance_method(const Array<Method*>* methods, 584 const Symbol* name, 585 const Symbol* signature, 586 PrivateLookupMode private_mode = find_private); 587 588 // find a local method (returns NULL if not found) 589 Method* find_local_method(const Symbol* name, 590 const Symbol* signature, 591 OverpassLookupMode overpass_mode, 592 StaticLookupMode static_mode, 593 PrivateLookupMode private_mode) const; 594 595 // find a local method from given methods array (returns NULL if not found) 596 static Method* find_local_method(const Array<Method*>* methods, 597 const Symbol* name, 598 const Symbol* signature, 599 OverpassLookupMode overpass_mode, 600 StaticLookupMode static_mode, 601 PrivateLookupMode private_mode); 602 603 // find a local method index in methods or default_methods (returns -1 if not found) 604 static int find_method_index(const Array<Method*>* methods, 605 const Symbol* name, 606 const Symbol* signature, 607 OverpassLookupMode overpass_mode, 608 StaticLookupMode static_mode, 609 PrivateLookupMode private_mode); 610 611 // lookup operation (returns NULL if not found) 612 Method* uncached_lookup_method(const Symbol* name, 613 const Symbol* signature, 614 OverpassLookupMode overpass_mode, 615 PrivateLookupMode private_mode = find_private) const; 616 617 // lookup a method in all the interfaces that this class implements 618 // (returns NULL if not found) 619 Method* lookup_method_in_all_interfaces(Symbol* name, Symbol* signature, DefaultsLookupMode defaults_mode) const; 620 621 // lookup a method in local defaults then in all interfaces 622 // (returns NULL if not found) 623 Method* lookup_method_in_ordered_interfaces(Symbol* name, Symbol* signature) const; 624 625 // Find method indices by name. If a method with the specified name is 626 // found the index to the first method is returned, and 'end' is filled in 627 // with the index of first non-name-matching method. If no method is found 628 // -1 is returned. 629 int find_method_by_name(const Symbol* name, int* end) const; 630 static int find_method_by_name(const Array<Method*>* methods, 631 const Symbol* name, int* end); 632 633 // constant pool 634 ConstantPool* constants() const { return _constants; } 635 void set_constants(ConstantPool* c) { _constants = c; } |