United StatesChange Country, Oracle Worldwide Web Sites Communities I am a... I want to...
Bug ID: JDK-7159772 instanceKlass::all_fields_count() returns incorrect total field count
JDK-7159772 : instanceKlass::all_fields_count() returns incorrect total field count

Details
Type:
Bug
Submit Date:
2012-04-06
Status:
Closed
Updated Date:
2013-07-18
Project Name:
JDK
Resolved Date:
2012-05-16
Component:
hotspot
OS:
generic
Sub-Component:
runtime
CPU:
generic
Priority:
P3
Resolution:
Fixed
Affected Versions:
hs24
Fixed Versions:
hs24 (b10)

Related Reports
Backport:
Backport:
Backport:

Sub Tasks

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

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

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

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

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



Hardware and Software, Engineered to Work Together