src/share/vm/classfile/classFileParser.cpp

changeset 3374
05de27e852c4
parent 3360
4ceaf61479fc
parent 3373
cd5d8cafcc84
child 3384
2b3acb34791f
equal deleted inserted replaced
3365:5ee33ff9b1c4 3374:05de27e852c4
1049 return result; 1049 return result;
1050 } 1050 }
1051 1051
1052 class FieldAllocationCount: public ResourceObj { 1052 class FieldAllocationCount: public ResourceObj {
1053 public: 1053 public:
1054 unsigned int count[MAX_FIELD_ALLOCATION_TYPE]; 1054 u2 count[MAX_FIELD_ALLOCATION_TYPE];
1055 1055
1056 FieldAllocationCount() { 1056 FieldAllocationCount() {
1057 for (int i = 0; i < MAX_FIELD_ALLOCATION_TYPE; i++) { 1057 for (int i = 0; i < MAX_FIELD_ALLOCATION_TYPE; i++) {
1058 count[i] = 0; 1058 count[i] = 0;
1059 } 1059 }
1060 } 1060 }
1061 1061
1062 FieldAllocationType update(bool is_static, BasicType type) { 1062 FieldAllocationType update(bool is_static, BasicType type) {
1063 FieldAllocationType atype = basic_type_to_atype(is_static, type); 1063 FieldAllocationType atype = basic_type_to_atype(is_static, type);
1064 // Make sure there is no overflow with injected fields.
1065 assert(count[atype] < 0xFFFF, "More than 65535 fields");
1064 count[atype]++; 1066 count[atype]++;
1065 return atype; 1067 return atype;
1066 } 1068 }
1067 }; 1069 };
1068 1070
1069 1071
1070 typeArrayHandle ClassFileParser::parse_fields(Symbol* class_name, 1072 typeArrayHandle ClassFileParser::parse_fields(Symbol* class_name,
1071 constantPoolHandle cp, bool is_interface, 1073 constantPoolHandle cp, bool is_interface,
1072 FieldAllocationCount *fac, 1074 FieldAllocationCount *fac,
1073 objArrayHandle* fields_annotations, 1075 objArrayHandle* fields_annotations,
1074 int* java_fields_count_ptr, TRAPS) { 1076 u2* java_fields_count_ptr, TRAPS) {
1075 ClassFileStream* cfs = stream(); 1077 ClassFileStream* cfs = stream();
1076 typeArrayHandle nullHandle; 1078 typeArrayHandle nullHandle;
1077 cfs->guarantee_more(2, CHECK_(nullHandle)); // length 1079 cfs->guarantee_more(2, CHECK_(nullHandle)); // length
1078 u2 length = cfs->get_u2_fast(); 1080 u2 length = cfs->get_u2_fast();
1079 *java_fields_count_ptr = length; 1081 *java_fields_count_ptr = length;
2859 local_interfaces = objArrayHandle(THREAD, Universe::the_empty_system_obj_array()); 2861 local_interfaces = objArrayHandle(THREAD, Universe::the_empty_system_obj_array());
2860 } else { 2862 } else {
2861 local_interfaces = parse_interfaces(cp, itfs_len, class_loader, protection_domain, _class_name, CHECK_(nullHandle)); 2863 local_interfaces = parse_interfaces(cp, itfs_len, class_loader, protection_domain, _class_name, CHECK_(nullHandle));
2862 } 2864 }
2863 2865
2864 int java_fields_count = 0; 2866 u2 java_fields_count = 0;
2865 // Fields (offsets are filled in later) 2867 // Fields (offsets are filled in later)
2866 FieldAllocationCount fac; 2868 FieldAllocationCount fac;
2867 objArrayHandle fields_annotations; 2869 objArrayHandle fields_annotations;
2868 typeArrayHandle fields = parse_fields(class_name, cp, access_flags.is_interface(), &fac, &fields_annotations, 2870 typeArrayHandle fields = parse_fields(class_name, cp, access_flags.is_interface(), &fac, &fields_annotations,
2869 &java_fields_count, 2871 &java_fields_count,

mercurial