Mercurial > hg > truffle
comparison src/share/vm/classfile/classFileParser.cpp @ 4744:cd5d8cafcc84
7123315: instanceKlass::_static_oop_field_count and instanceKlass::_java_fields_count should be u2 type.
Summary: Change instanceKlass::_static_oop_field_count and instanceKlass::_java_fields_count to u2 type.
Reviewed-by: never, bdelsart, dholmes
Contributed-by: Jiangli Zhou <jiangli.zhou@oracle.com>
author | jiangli |
---|---|
date | Wed, 28 Dec 2011 12:15:57 -0500 |
parents | e6b1331a51d2 |
children | 05de27e852c4 |
comparison
equal
deleted
inserted
replaced
4743:dca455dea3a7 | 4744:cd5d8cafcc84 |
---|---|
1048 return result; | 1048 return result; |
1049 } | 1049 } |
1050 | 1050 |
1051 class FieldAllocationCount: public ResourceObj { | 1051 class FieldAllocationCount: public ResourceObj { |
1052 public: | 1052 public: |
1053 unsigned int count[MAX_FIELD_ALLOCATION_TYPE]; | 1053 u2 count[MAX_FIELD_ALLOCATION_TYPE]; |
1054 | 1054 |
1055 FieldAllocationCount() { | 1055 FieldAllocationCount() { |
1056 for (int i = 0; i < MAX_FIELD_ALLOCATION_TYPE; i++) { | 1056 for (int i = 0; i < MAX_FIELD_ALLOCATION_TYPE; i++) { |
1057 count[i] = 0; | 1057 count[i] = 0; |
1058 } | 1058 } |
1059 } | 1059 } |
1060 | 1060 |
1061 FieldAllocationType update(bool is_static, BasicType type) { | 1061 FieldAllocationType update(bool is_static, BasicType type) { |
1062 FieldAllocationType atype = basic_type_to_atype(is_static, type); | 1062 FieldAllocationType atype = basic_type_to_atype(is_static, type); |
1063 // Make sure there is no overflow with injected fields. | |
1064 assert(count[atype] < 0xFFFF, "More than 65535 fields"); | |
1063 count[atype]++; | 1065 count[atype]++; |
1064 return atype; | 1066 return atype; |
1065 } | 1067 } |
1066 }; | 1068 }; |
1067 | 1069 |
1068 | 1070 |
1069 typeArrayHandle ClassFileParser::parse_fields(Symbol* class_name, | 1071 typeArrayHandle ClassFileParser::parse_fields(Symbol* class_name, |
1070 constantPoolHandle cp, bool is_interface, | 1072 constantPoolHandle cp, bool is_interface, |
1071 FieldAllocationCount *fac, | 1073 FieldAllocationCount *fac, |
1072 objArrayHandle* fields_annotations, | 1074 objArrayHandle* fields_annotations, |
1073 int* java_fields_count_ptr, TRAPS) { | 1075 u2* java_fields_count_ptr, TRAPS) { |
1074 ClassFileStream* cfs = stream(); | 1076 ClassFileStream* cfs = stream(); |
1075 typeArrayHandle nullHandle; | 1077 typeArrayHandle nullHandle; |
1076 cfs->guarantee_more(2, CHECK_(nullHandle)); // length | 1078 cfs->guarantee_more(2, CHECK_(nullHandle)); // length |
1077 u2 length = cfs->get_u2_fast(); | 1079 u2 length = cfs->get_u2_fast(); |
1078 *java_fields_count_ptr = length; | 1080 *java_fields_count_ptr = length; |
2841 local_interfaces = objArrayHandle(THREAD, Universe::the_empty_system_obj_array()); | 2843 local_interfaces = objArrayHandle(THREAD, Universe::the_empty_system_obj_array()); |
2842 } else { | 2844 } else { |
2843 local_interfaces = parse_interfaces(cp, itfs_len, class_loader, protection_domain, _class_name, CHECK_(nullHandle)); | 2845 local_interfaces = parse_interfaces(cp, itfs_len, class_loader, protection_domain, _class_name, CHECK_(nullHandle)); |
2844 } | 2846 } |
2845 | 2847 |
2846 int java_fields_count = 0; | 2848 u2 java_fields_count = 0; |
2847 // Fields (offsets are filled in later) | 2849 // Fields (offsets are filled in later) |
2848 FieldAllocationCount fac; | 2850 FieldAllocationCount fac; |
2849 objArrayHandle fields_annotations; | 2851 objArrayHandle fields_annotations; |
2850 typeArrayHandle fields = parse_fields(class_name, cp, access_flags.is_interface(), &fac, &fields_annotations, | 2852 typeArrayHandle fields = parse_fields(class_name, cp, access_flags.is_interface(), &fac, &fields_annotations, |
2851 &java_fields_count, | 2853 &java_fields_count, |