1503 BAD_ALLOCATION_TYPE, // 3
1504 STATIC_BYTE , // T_BOOLEAN = 4,
1505 STATIC_SHORT, // T_CHAR = 5,
1506 STATIC_WORD, // T_FLOAT = 6,
1507 STATIC_DOUBLE, // T_DOUBLE = 7,
1508 STATIC_BYTE, // T_BYTE = 8,
1509 STATIC_SHORT, // T_SHORT = 9,
1510 STATIC_WORD, // T_INT = 10,
1511 STATIC_DOUBLE, // T_LONG = 11,
1512 STATIC_OOP, // T_OBJECT = 12,
1513 STATIC_OOP, // T_ARRAY = 13,
1514 BAD_ALLOCATION_TYPE, // T_VOID = 15,
1515 BAD_ALLOCATION_TYPE, // T_ADDRESS = 16,
1516 BAD_ALLOCATION_TYPE, // T_NARROWOOP = 17,
1517 BAD_ALLOCATION_TYPE, // T_METADATA = 18,
1518 BAD_ALLOCATION_TYPE, // T_NARROWKLASS = 19,
1519 BAD_ALLOCATION_TYPE, // T_VALUETYPEPTR= 20,
1520 BAD_ALLOCATION_TYPE, // T_CONFLICT = 21,
1521 };
1522
1523 static FieldAllocationType basic_type_to_atype(bool is_static, BasicType type) {
1524 assert(type >= T_BOOLEAN && type < T_VOID, "only allowable values");
1525 FieldAllocationType result = _basic_type_to_atype[type + (is_static ? (T_CONFLICT + 1) : 0)];
1526 assert(result != BAD_ALLOCATION_TYPE, "bad type");
1527 return result;
1528 }
1529
1530 class ClassFileParser::FieldAllocationCount : public ResourceObj {
1531 public:
1532 u2 count[MAX_FIELD_ALLOCATION_TYPE];
1533
1534 FieldAllocationCount() {
1535 for (int i = 0; i < MAX_FIELD_ALLOCATION_TYPE; i++) {
1536 count[i] = 0;
1537 }
1538 }
1539
1540 FieldAllocationType update(bool is_static, BasicType type) {
1541 FieldAllocationType atype = basic_type_to_atype(is_static, type);
1542 if (atype != BAD_ALLOCATION_TYPE) {
1543 // Make sure there is no overflow with injected fields.
1544 assert(count[atype] < 0xFFFF, "More than 65535 fields");
1545 count[atype]++;
1546 }
1547 return atype;
1548 }
1549 };
1550
1551 // Side-effects: populates the _fields, _fields_annotations,
1552 // _fields_type_annotations fields
1553 void ClassFileParser::parse_fields(const ClassFileStream* const cfs,
1554 bool is_interface,
1555 bool is_concrete_value_type,
1556 FieldAllocationCount* const fac,
1557 ConstantPool* cp,
1558 const int cp_size,
1559 u2* const java_fields_count_ptr,
1560 TRAPS) {
1561
1673
1674 if (is_synthetic) {
1675 access_flags.set_is_synthetic();
1676 }
1677 if (generic_signature_index != 0) {
1678 access_flags.set_field_has_generic_signature();
1679 fa[generic_signature_slot] = generic_signature_index;
1680 generic_signature_slot ++;
1681 num_generic_signature ++;
1682 }
1683 }
1684
1685 FieldInfo* const field = FieldInfo::from_field_array(fa, n);
1686 field->initialize(access_flags.as_short(),
1687 name_index,
1688 signature_index,
1689 constantvalue_index);
1690 const BasicType type = cp->basic_type_for_signature_at(signature_index);
1691
1692 // Remember how many oops we encountered and compute allocation type
1693 const FieldAllocationType atype = fac->update(is_static, type);
1694 field->set_allocation_type(atype);
1695
1696 // After field is initialized with type, we can augment it with aux info
1697 if (parsed_annotations.has_any_annotations())
1698 parsed_annotations.apply_to(field);
1699 }
1700
1701 int index = length;
1702 if (num_injected != 0) {
1703 for (int n = 0; n < num_injected; n++) {
1704 // Check for duplicates
1705 if (injected[n].may_be_java) {
1706 const Symbol* const name = injected[n].name();
1707 const Symbol* const signature = injected[n].signature();
1708 bool duplicate = false;
1709 for (int i = 0; i < length; i++) {
1710 const FieldInfo* const f = FieldInfo::from_field_array(fa, i);
1711 if (name == cp->symbol_at(f->name_index()) &&
1712 signature == cp->symbol_at(f->signature_index())) {
1713 // Symbol is desclared in Java so skip this one
1714 duplicate = true;
1715 break;
1716 }
1717 }
1718 if (duplicate) {
1719 // These will be removed from the field array at the end
1720 continue;
1721 }
1722 }
1723
1724 // Injected field
1725 FieldInfo* const field = FieldInfo::from_field_array(fa, index);
1726 field->initialize(JVM_ACC_FIELD_INTERNAL,
1727 injected[n].name_index,
1728 injected[n].signature_index,
1729 0);
1730
1731 const BasicType type = FieldType::basic_type(injected[n].signature());
1732
1733 // Remember how many oops we encountered and compute allocation type
1734 const FieldAllocationType atype = fac->update(false, type);
1735 field->set_allocation_type(atype);
1736 index++;
1737 }
1738 }
1739
1740 if (is_concrete_value_type) {
1741 index = length + num_injected;
1742 FieldInfo* const field = FieldInfo::from_field_array(fa, index);
1743 field->initialize(JVM_ACC_FIELD_INTERNAL | JVM_ACC_STATIC,
1744 vmSymbols::default_value_name_enum,
1745 vmSymbols::java_lang_Object_enum,
1746 0);
1747 const BasicType type = FieldType::basic_type(vmSymbols::object_signature());
1748 const FieldAllocationType atype = fac->update(true, type);
1749 field->set_allocation_type(atype);
1750 index++;
1751 }
1752
1753 assert(NULL == _fields, "invariant");
1754
1755 _fields =
1756 MetadataFactory::new_array<u2>(_loader_data,
1757 index * FieldInfo::field_slots + num_generic_signature,
1758 CHECK);
1759 // Sometimes injected fields already exist in the Java source so
1760 // the fields array could be too long. In that case the
1761 // fields array is trimed. Also unused slots that were reserved
1762 // for generic signature indexes are discarded.
1763 {
1764 int i = 0;
1765 for (; i < index * FieldInfo::field_slots; i++) {
1766 _fields->at_put(i, fa[i]);
1767 }
1768 for (int j = total_fields * FieldInfo::field_slots;
4004 nonstatic_value_type_indexes = NEW_RESOURCE_ARRAY_IN_THREAD(THREAD, int,
4005 max_nonstatic_value_type);
4006 for (int i = 0; i < max_nonstatic_value_type; i++) {
4007 nonstatic_value_type_indexes[i] = -1;
4008 }
4009 nonstatic_value_type_klasses = NEW_RESOURCE_ARRAY_IN_THREAD(THREAD, Klass*,
4010 max_nonstatic_value_type);
4011
4012 for (AllFieldStream fs(_fields, _cp); !fs.done(); fs.next()) {
4013 if (fs.allocation_type() == STATIC_FLATTENABLE) {
4014 static_value_type_count++;
4015 } else if (fs.allocation_type() == NONSTATIC_FLATTENABLE) {
4016 Symbol* signature = fs.signature();
4017 Klass* klass = SystemDictionary::resolve_or_fail(signature,
4018 Handle(THREAD, _loader_data->class_loader()),
4019 _protection_domain, true, CHECK);
4020 assert(klass != NULL, "Sanity check");
4021 assert(klass->access_flags().is_value_type(), "Value type expected");
4022 ValueKlass* vk = ValueKlass::cast(klass);
4023 // Conditions to apply flattening or not should be defined in a single place
4024 if ( false && // Currently disabling flattening
4025 ((ValueFieldMaxFlatSize < 0) || vk->size_helper() <= ValueFieldMaxFlatSize)) {
4026 nonstatic_value_type_indexes[nonstatic_value_type_count] = fs.index();
4027 nonstatic_value_type_klasses[nonstatic_value_type_count] = klass;
4028 nonstatic_value_type_count++;
4029
4030 ValueKlass* vklass = ValueKlass::cast(klass);
4031 if (vklass->contains_oops()) {
4032 value_type_oop_map_count += vklass->nonstatic_oop_map_count();
4033 }
4034 fs.set_flattening(true);
4035 } else {
4036 not_flattened_value_types++;
4037 fs.set_flattening(false);
4038 }
4039 }
4040 }
4041
4042 // Adjusting non_static_oop_count to take into account not flattened value types;
4043 nonstatic_oop_count += not_flattened_value_types;
4044
4045 // Total non-static fields count, including every contended field
4046 unsigned int nonstatic_fields_count = fac->count[NONSTATIC_DOUBLE] + fac->count[NONSTATIC_WORD] +
4047 fac->count[NONSTATIC_SHORT] + fac->count[NONSTATIC_BYTE] +
4048 fac->count[NONSTATIC_OOP] + fac->count[NONSTATIC_FLATTENABLE];
4049
4050 const bool super_has_nonstatic_fields =
4051 (_super_klass != NULL && _super_klass->has_nonstatic_fields());
4052 const bool has_nonstatic_fields =
4053 super_has_nonstatic_fields || (nonstatic_fields_count != 0);
4054 const bool has_nonstatic_value_fields = nonstatic_value_type_count > 0;
4055
4056 if (is_value_type() && (!has_nonstatic_fields)) {
4057 // There are a number of fixes required throughout the type system and JIT
4242 real_offset = next_static_oop_offset;
4243 next_static_oop_offset += heapOopSize;
4244 break;
4245 case STATIC_BYTE:
4246 real_offset = next_static_byte_offset;
4247 next_static_byte_offset += 1;
4248 break;
4249 case STATIC_SHORT:
4250 real_offset = next_static_short_offset;
4251 next_static_short_offset += BytesPerShort;
4252 break;
4253 case STATIC_WORD:
4254 real_offset = next_static_word_offset;
4255 next_static_word_offset += BytesPerInt;
4256 break;
4257 case STATIC_DOUBLE:
4258 real_offset = next_static_double_offset;
4259 next_static_double_offset += BytesPerLong;
4260 break;
4261 case NONSTATIC_FLATTENABLE:
4262 if (fs.is_flatten()) {
4263 Klass* klass = nonstatic_value_type_klasses[next_value_type_index];
4264 assert(klass != NULL, "Klass should have been loaded and resolved earlier");
4265 assert(klass->access_flags().is_value_type(),"Must be a value type");
4266 ValueKlass* vklass = ValueKlass::cast(klass);
4267 real_offset = next_nonstatic_valuetype_offset;
4268 next_nonstatic_valuetype_offset += (vklass->size_helper()) * wordSize - vklass->first_field_offset();
4269 // aligning next value type on a 64 bits boundary
4270 next_nonstatic_valuetype_offset = align_up(next_nonstatic_valuetype_offset, BytesPerLong);
4271 next_value_type_index += 1;
4272
4273 if (vklass->contains_oops()) { // add flatten oop maps
4274 int diff = real_offset - vklass->first_field_offset();
4275 const OopMapBlock* map = vklass->start_of_nonstatic_oop_maps();
4276 const OopMapBlock* const last_map = map + vklass->nonstatic_oop_map_count();
4277 while (map < last_map) {
4278 nonstatic_oop_maps->add(map->offset() + diff, map->count());
4279 map++;
4280 }
4281 }
4282 break;
5198 // Return a pointer to just past the signature.
5199 // Return NULL if no legal signature is found.
5200 const char* ClassFileParser::skip_over_field_signature(const char* signature,
5201 bool void_ok,
5202 unsigned int length,
5203 TRAPS) const {
5204 unsigned int array_dim = 0;
5205 while (length > 0) {
5206 switch (signature[0]) {
5207 case JVM_SIGNATURE_VOID: if (!void_ok) { return NULL; }
5208 case JVM_SIGNATURE_BOOLEAN:
5209 case JVM_SIGNATURE_BYTE:
5210 case JVM_SIGNATURE_CHAR:
5211 case JVM_SIGNATURE_SHORT:
5212 case JVM_SIGNATURE_INT:
5213 case JVM_SIGNATURE_FLOAT:
5214 case JVM_SIGNATURE_LONG:
5215 case JVM_SIGNATURE_DOUBLE:
5216 return signature + 1;
5217 case JVM_SIGNATURE_CLASS:
5218 case JVM_SIGNATURE_VALUE_CLASS: {
5219 if (_major_version < JAVA_1_5_VERSION) {
5220 // Skip over the class name if one is there
5221 const char* const p = skip_over_field_name(signature + 1, true, --length);
5222
5223 // The next character better be a semicolon
5224 if (p && (p - signature) > 1 && p[0] == ';') {
5225 return p + 1;
5226 }
5227 }
5228 else {
5229 // Skip leading 'L' and ignore first appearance of ';'
5230 length--;
5231 signature++;
5232 char* c = strchr((char*) signature, ';');
5233 // Format check signature
5234 if (c != NULL) {
5235 ResourceMark rm(THREAD);
5236 int newlen = c - (char*) signature;
5237 char* sig = NEW_RESOURCE_ARRAY(char, newlen + 1);
5238 strncpy(sig, signature, newlen);
|
1503 BAD_ALLOCATION_TYPE, // 3
1504 STATIC_BYTE , // T_BOOLEAN = 4,
1505 STATIC_SHORT, // T_CHAR = 5,
1506 STATIC_WORD, // T_FLOAT = 6,
1507 STATIC_DOUBLE, // T_DOUBLE = 7,
1508 STATIC_BYTE, // T_BYTE = 8,
1509 STATIC_SHORT, // T_SHORT = 9,
1510 STATIC_WORD, // T_INT = 10,
1511 STATIC_DOUBLE, // T_LONG = 11,
1512 STATIC_OOP, // T_OBJECT = 12,
1513 STATIC_OOP, // T_ARRAY = 13,
1514 BAD_ALLOCATION_TYPE, // T_VOID = 15,
1515 BAD_ALLOCATION_TYPE, // T_ADDRESS = 16,
1516 BAD_ALLOCATION_TYPE, // T_NARROWOOP = 17,
1517 BAD_ALLOCATION_TYPE, // T_METADATA = 18,
1518 BAD_ALLOCATION_TYPE, // T_NARROWKLASS = 19,
1519 BAD_ALLOCATION_TYPE, // T_VALUETYPEPTR= 20,
1520 BAD_ALLOCATION_TYPE, // T_CONFLICT = 21,
1521 };
1522
1523 static FieldAllocationType basic_type_to_atype(bool is_static, BasicType type, bool is_flattenable) {
1524 assert(type >= T_BOOLEAN && type < T_VOID, "only allowable values");
1525 FieldAllocationType result = _basic_type_to_atype[type + (is_static ? (T_CONFLICT + 1) : 0)];
1526 assert(result != BAD_ALLOCATION_TYPE, "bad type");
1527 if (is_flattenable) {
1528 result = is_static ? STATIC_FLATTENABLE : NONSTATIC_FLATTENABLE;
1529 }
1530 return result;
1531 }
1532
1533 class ClassFileParser::FieldAllocationCount : public ResourceObj {
1534 public:
1535 u2 count[MAX_FIELD_ALLOCATION_TYPE];
1536
1537 FieldAllocationCount() {
1538 for (int i = 0; i < MAX_FIELD_ALLOCATION_TYPE; i++) {
1539 count[i] = 0;
1540 }
1541 }
1542
1543 FieldAllocationType update(bool is_static, BasicType type, bool is_flattenable) {
1544 FieldAllocationType atype = basic_type_to_atype(is_static, type, is_flattenable);
1545 if (atype != BAD_ALLOCATION_TYPE) {
1546 // Make sure there is no overflow with injected fields.
1547 assert(count[atype] < 0xFFFF, "More than 65535 fields");
1548 count[atype]++;
1549 }
1550 return atype;
1551 }
1552 };
1553
1554 // Side-effects: populates the _fields, _fields_annotations,
1555 // _fields_type_annotations fields
1556 void ClassFileParser::parse_fields(const ClassFileStream* const cfs,
1557 bool is_interface,
1558 bool is_concrete_value_type,
1559 FieldAllocationCount* const fac,
1560 ConstantPool* cp,
1561 const int cp_size,
1562 u2* const java_fields_count_ptr,
1563 TRAPS) {
1564
1676
1677 if (is_synthetic) {
1678 access_flags.set_is_synthetic();
1679 }
1680 if (generic_signature_index != 0) {
1681 access_flags.set_field_has_generic_signature();
1682 fa[generic_signature_slot] = generic_signature_index;
1683 generic_signature_slot ++;
1684 num_generic_signature ++;
1685 }
1686 }
1687
1688 FieldInfo* const field = FieldInfo::from_field_array(fa, n);
1689 field->initialize(access_flags.as_short(),
1690 name_index,
1691 signature_index,
1692 constantvalue_index);
1693 const BasicType type = cp->basic_type_for_signature_at(signature_index);
1694
1695 // Remember how many oops we encountered and compute allocation type
1696 const FieldAllocationType atype = fac->update(is_static, type, access_flags.is_flattenable());
1697 field->set_allocation_type(atype);
1698
1699 // After field is initialized with type, we can augment it with aux info
1700 if (parsed_annotations.has_any_annotations())
1701 parsed_annotations.apply_to(field);
1702 }
1703
1704 int index = length;
1705 if (num_injected != 0) {
1706 for (int n = 0; n < num_injected; n++) {
1707 // Check for duplicates
1708 if (injected[n].may_be_java) {
1709 const Symbol* const name = injected[n].name();
1710 const Symbol* const signature = injected[n].signature();
1711 bool duplicate = false;
1712 for (int i = 0; i < length; i++) {
1713 const FieldInfo* const f = FieldInfo::from_field_array(fa, i);
1714 if (name == cp->symbol_at(f->name_index()) &&
1715 signature == cp->symbol_at(f->signature_index())) {
1716 // Symbol is desclared in Java so skip this one
1717 duplicate = true;
1718 break;
1719 }
1720 }
1721 if (duplicate) {
1722 // These will be removed from the field array at the end
1723 continue;
1724 }
1725 }
1726
1727 // Injected field
1728 FieldInfo* const field = FieldInfo::from_field_array(fa, index);
1729 field->initialize(JVM_ACC_FIELD_INTERNAL,
1730 injected[n].name_index,
1731 injected[n].signature_index,
1732 0);
1733
1734 const BasicType type = FieldType::basic_type(injected[n].signature());
1735
1736 // Remember how many oops we encountered and compute allocation type
1737 const FieldAllocationType atype = fac->update(false, type, false);
1738 field->set_allocation_type(atype);
1739 index++;
1740 }
1741 }
1742
1743 if (is_concrete_value_type) {
1744 index = length + num_injected;
1745 FieldInfo* const field = FieldInfo::from_field_array(fa, index);
1746 field->initialize(JVM_ACC_FIELD_INTERNAL | JVM_ACC_STATIC,
1747 vmSymbols::default_value_name_enum,
1748 vmSymbols::java_lang_Object_enum,
1749 0);
1750 const BasicType type = FieldType::basic_type(vmSymbols::object_signature());
1751 const FieldAllocationType atype = fac->update(true, type, false);
1752 field->set_allocation_type(atype);
1753 index++;
1754 }
1755
1756 assert(NULL == _fields, "invariant");
1757
1758 _fields =
1759 MetadataFactory::new_array<u2>(_loader_data,
1760 index * FieldInfo::field_slots + num_generic_signature,
1761 CHECK);
1762 // Sometimes injected fields already exist in the Java source so
1763 // the fields array could be too long. In that case the
1764 // fields array is trimed. Also unused slots that were reserved
1765 // for generic signature indexes are discarded.
1766 {
1767 int i = 0;
1768 for (; i < index * FieldInfo::field_slots; i++) {
1769 _fields->at_put(i, fa[i]);
1770 }
1771 for (int j = total_fields * FieldInfo::field_slots;
4007 nonstatic_value_type_indexes = NEW_RESOURCE_ARRAY_IN_THREAD(THREAD, int,
4008 max_nonstatic_value_type);
4009 for (int i = 0; i < max_nonstatic_value_type; i++) {
4010 nonstatic_value_type_indexes[i] = -1;
4011 }
4012 nonstatic_value_type_klasses = NEW_RESOURCE_ARRAY_IN_THREAD(THREAD, Klass*,
4013 max_nonstatic_value_type);
4014
4015 for (AllFieldStream fs(_fields, _cp); !fs.done(); fs.next()) {
4016 if (fs.allocation_type() == STATIC_FLATTENABLE) {
4017 static_value_type_count++;
4018 } else if (fs.allocation_type() == NONSTATIC_FLATTENABLE) {
4019 Symbol* signature = fs.signature();
4020 Klass* klass = SystemDictionary::resolve_or_fail(signature,
4021 Handle(THREAD, _loader_data->class_loader()),
4022 _protection_domain, true, CHECK);
4023 assert(klass != NULL, "Sanity check");
4024 assert(klass->access_flags().is_value_type(), "Value type expected");
4025 ValueKlass* vk = ValueKlass::cast(klass);
4026 // Conditions to apply flattening or not should be defined in a single place
4027 if ((ValueFieldMaxFlatSize < 0) || (vk->size_helper() * HeapWordSize) <= ValueFieldMaxFlatSize) {
4028 nonstatic_value_type_indexes[nonstatic_value_type_count] = fs.index();
4029 nonstatic_value_type_klasses[nonstatic_value_type_count] = klass;
4030 nonstatic_value_type_count++;
4031
4032 ValueKlass* vklass = ValueKlass::cast(klass);
4033 if (vklass->contains_oops()) {
4034 value_type_oop_map_count += vklass->nonstatic_oop_map_count();
4035 }
4036 fs.set_flattened(true);
4037 } else {
4038 not_flattened_value_types++;
4039 fs.set_flattened(false);
4040 }
4041 }
4042 }
4043
4044 // Adjusting non_static_oop_count to take into account not flattened value types;
4045 nonstatic_oop_count += not_flattened_value_types;
4046
4047 // Total non-static fields count, including every contended field
4048 unsigned int nonstatic_fields_count = fac->count[NONSTATIC_DOUBLE] + fac->count[NONSTATIC_WORD] +
4049 fac->count[NONSTATIC_SHORT] + fac->count[NONSTATIC_BYTE] +
4050 fac->count[NONSTATIC_OOP] + fac->count[NONSTATIC_FLATTENABLE];
4051
4052 const bool super_has_nonstatic_fields =
4053 (_super_klass != NULL && _super_klass->has_nonstatic_fields());
4054 const bool has_nonstatic_fields =
4055 super_has_nonstatic_fields || (nonstatic_fields_count != 0);
4056 const bool has_nonstatic_value_fields = nonstatic_value_type_count > 0;
4057
4058 if (is_value_type() && (!has_nonstatic_fields)) {
4059 // There are a number of fixes required throughout the type system and JIT
4244 real_offset = next_static_oop_offset;
4245 next_static_oop_offset += heapOopSize;
4246 break;
4247 case STATIC_BYTE:
4248 real_offset = next_static_byte_offset;
4249 next_static_byte_offset += 1;
4250 break;
4251 case STATIC_SHORT:
4252 real_offset = next_static_short_offset;
4253 next_static_short_offset += BytesPerShort;
4254 break;
4255 case STATIC_WORD:
4256 real_offset = next_static_word_offset;
4257 next_static_word_offset += BytesPerInt;
4258 break;
4259 case STATIC_DOUBLE:
4260 real_offset = next_static_double_offset;
4261 next_static_double_offset += BytesPerLong;
4262 break;
4263 case NONSTATIC_FLATTENABLE:
4264 if (fs.is_flattened()) {
4265 Klass* klass = nonstatic_value_type_klasses[next_value_type_index];
4266 assert(klass != NULL, "Klass should have been loaded and resolved earlier");
4267 assert(klass->access_flags().is_value_type(),"Must be a value type");
4268 ValueKlass* vklass = ValueKlass::cast(klass);
4269 real_offset = next_nonstatic_valuetype_offset;
4270 next_nonstatic_valuetype_offset += (vklass->size_helper()) * wordSize - vklass->first_field_offset();
4271 // aligning next value type on a 64 bits boundary
4272 next_nonstatic_valuetype_offset = align_up(next_nonstatic_valuetype_offset, BytesPerLong);
4273 next_value_type_index += 1;
4274
4275 if (vklass->contains_oops()) { // add flatten oop maps
4276 int diff = real_offset - vklass->first_field_offset();
4277 const OopMapBlock* map = vklass->start_of_nonstatic_oop_maps();
4278 const OopMapBlock* const last_map = map + vklass->nonstatic_oop_map_count();
4279 while (map < last_map) {
4280 nonstatic_oop_maps->add(map->offset() + diff, map->count());
4281 map++;
4282 }
4283 }
4284 break;
5200 // Return a pointer to just past the signature.
5201 // Return NULL if no legal signature is found.
5202 const char* ClassFileParser::skip_over_field_signature(const char* signature,
5203 bool void_ok,
5204 unsigned int length,
5205 TRAPS) const {
5206 unsigned int array_dim = 0;
5207 while (length > 0) {
5208 switch (signature[0]) {
5209 case JVM_SIGNATURE_VOID: if (!void_ok) { return NULL; }
5210 case JVM_SIGNATURE_BOOLEAN:
5211 case JVM_SIGNATURE_BYTE:
5212 case JVM_SIGNATURE_CHAR:
5213 case JVM_SIGNATURE_SHORT:
5214 case JVM_SIGNATURE_INT:
5215 case JVM_SIGNATURE_FLOAT:
5216 case JVM_SIGNATURE_LONG:
5217 case JVM_SIGNATURE_DOUBLE:
5218 return signature + 1;
5219 case JVM_SIGNATURE_CLASS:
5220 {
5221 if (_major_version < JAVA_1_5_VERSION) {
5222 // Skip over the class name if one is there
5223 const char* const p = skip_over_field_name(signature + 1, true, --length);
5224
5225 // The next character better be a semicolon
5226 if (p && (p - signature) > 1 && p[0] == ';') {
5227 return p + 1;
5228 }
5229 }
5230 else {
5231 // Skip leading 'L' and ignore first appearance of ';'
5232 length--;
5233 signature++;
5234 char* c = strchr((char*) signature, ';');
5235 // Format check signature
5236 if (c != NULL) {
5237 ResourceMark rm(THREAD);
5238 int newlen = c - (char*) signature;
5239 char* sig = NEW_RESOURCE_ARRAY(char, newlen + 1);
5240 strncpy(sig, signature, newlen);
|