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.

To download the current JDK release, click here.
JDK 7 JDK 8 Other
7u40Fixed 8Fixed hs24Fixed
Description
The instanceKlass::all_fields_count() returns incorrect total field count:

int all_fields_count() const            { return _fields->length() / sizeof(FieldInfo::field_slots); }

Comments
EVALUATION http://hg.openjdk.java.net/lambda/lambda/hotspot/rev/c7ed11779ce8
29-06-2012

EVALUATION http://hg.openjdk.java.net/hsx/hotspot-rt/hotspot/rev/c7ed11779ce8
12-05-2012

EVALUATION http://hg.openjdk.java.net/hsx/hotspot-comp/hotspot/rev/c7ed11779ce8
10-04-2012

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; }
06-04-2012