JDK-7159772 : instanceKlass::all_fields_count() returns incorrect total field count
Type:Bug
Component:hotspot
Sub-Component:runtime
Affected Version:hs24
Priority:P3
Status:Closed
Resolution:Fixed
OS:generic
CPU:generic
Submitted:2012-04-06
Updated:2013-07-18
Resolved:2012-05-16
The Version table provides details related to the release that this issue/RFE will be addressed.
Unresolved : Release in which this issue/RFE will be addressed. Resolved: Release in which this issue/RFE has been resolved. Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.
The instanceKlass::all_fields_count() returns incorrect total field count:
int all_fields_count() const { return _fields->length() / sizeof(FieldInfo::field_slots); }
EVALUATION
The class fields are array of shorts. For each field, there are 7 (FieldInfo::field_slots) shorts. The sizeof(FieldInfo::field_slots) is 4, using that to calculate the total field (both java fields and injected fields) count would get the incorrect number that's larger than the actual field count.
Here is suggested fix:
int all_fields_count() const { return _fields->length() / FieldInfo::field_slots; }