1.1 --- a/src/share/vm/classfile/classFileParser.cpp Tue Dec 20 12:33:05 2011 +0100 1.2 +++ b/src/share/vm/classfile/classFileParser.cpp Wed Dec 28 12:15:57 2011 -0500 1.3 @@ -1050,7 +1050,7 @@ 1.4 1.5 class FieldAllocationCount: public ResourceObj { 1.6 public: 1.7 - unsigned int count[MAX_FIELD_ALLOCATION_TYPE]; 1.8 + u2 count[MAX_FIELD_ALLOCATION_TYPE]; 1.9 1.10 FieldAllocationCount() { 1.11 for (int i = 0; i < MAX_FIELD_ALLOCATION_TYPE; i++) { 1.12 @@ -1060,6 +1060,8 @@ 1.13 1.14 FieldAllocationType update(bool is_static, BasicType type) { 1.15 FieldAllocationType atype = basic_type_to_atype(is_static, type); 1.16 + // Make sure there is no overflow with injected fields. 1.17 + assert(count[atype] < 0xFFFF, "More than 65535 fields"); 1.18 count[atype]++; 1.19 return atype; 1.20 } 1.21 @@ -1070,7 +1072,7 @@ 1.22 constantPoolHandle cp, bool is_interface, 1.23 FieldAllocationCount *fac, 1.24 objArrayHandle* fields_annotations, 1.25 - int* java_fields_count_ptr, TRAPS) { 1.26 + u2* java_fields_count_ptr, TRAPS) { 1.27 ClassFileStream* cfs = stream(); 1.28 typeArrayHandle nullHandle; 1.29 cfs->guarantee_more(2, CHECK_(nullHandle)); // length 1.30 @@ -2843,7 +2845,7 @@ 1.31 local_interfaces = parse_interfaces(cp, itfs_len, class_loader, protection_domain, _class_name, CHECK_(nullHandle)); 1.32 } 1.33 1.34 - int java_fields_count = 0; 1.35 + u2 java_fields_count = 0; 1.36 // Fields (offsets are filled in later) 1.37 FieldAllocationCount fac; 1.38 objArrayHandle fields_annotations;