@@ -1649,7 +1649,7 @@ bool InstanceKlass::find_local_field(Symbol* name, Symbol* sig, fieldDescriptor*
16491649 Symbol* f_name = fs.name ();
16501650 Symbol* f_sig = fs.signature ();
16511651 if (f_name == name && f_sig == sig) {
1652- fd->reinitialize (const_cast <InstanceKlass*>(this ), fs.index ());
1652+ fd->reinitialize (const_cast <InstanceKlass*>(this ), fs.to_FieldInfo ());
16531653 return true ;
16541654 }
16551655 }
@@ -1718,7 +1718,7 @@ Klass* InstanceKlass::find_field(Symbol* name, Symbol* sig, bool is_static, fiel
17181718bool InstanceKlass::find_local_field_from_offset (int offset, bool is_static, fieldDescriptor* fd) const {
17191719 for (JavaFieldStream fs (this ); !fs.done (); fs.next ()) {
17201720 if (fs.offset () == offset) {
1721- fd->reinitialize (const_cast <InstanceKlass*>(this ), fs.index ());
1721+ fd->reinitialize (const_cast <InstanceKlass*>(this ), fs.to_FieldInfo ());
17221722 if (fd->is_static () == is_static) return true ;
17231723 }
17241724 }
@@ -1779,19 +1779,16 @@ void InstanceKlass::do_nonstatic_fields(FieldClosure* cl) {
17791779 if (super != nullptr ) {
17801780 super->do_nonstatic_fields (cl);
17811781 }
1782- fieldDescriptor fd;
1783- int length = java_fields_count ();
1784- for (int i = 0 ; i < length; i += 1 ) {
1785- fd.reinitialize (this , i);
1782+ for (JavaFieldStream fs (this ); !fs.done (); fs.next ()) {
1783+ fieldDescriptor& fd = fs.field_descriptor ();
17861784 if (!fd.is_static ()) {
17871785 cl->do_field (&fd);
17881786 }
17891787 }
17901788}
17911789
1792- // first in Pair is offset, second is index.
1793- static int compare_fields_by_offset (Pair<int ,int >* a, Pair<int ,int >* b) {
1794- return a->first - b->first ;
1790+ static int compare_fields_by_offset (FieldInfo* a, FieldInfo* b) {
1791+ return a->offset () - b->offset ();
17951792}
17961793
17971794void InstanceKlass::print_nonstatic_fields (FieldClosure* cl) {
@@ -1800,26 +1797,20 @@ void InstanceKlass::print_nonstatic_fields(FieldClosure* cl) {
18001797 super->print_nonstatic_fields (cl);
18011798 }
18021799 ResourceMark rm;
1803- fieldDescriptor fd;
18041800 // In DebugInfo nonstatic fields are sorted by offset.
1805- GrowableArray<Pair<int ,int > > fields_sorted;
1806- int i = 0 ;
1801+ GrowableArray<FieldInfo> fields_sorted;
18071802 for (AllFieldStream fs (this ); !fs.done (); fs.next ()) {
18081803 if (!fs.access_flags ().is_static ()) {
1809- fd = fs.field_descriptor ();
1810- Pair<int ,int > f (fs.offset (), fs.index ());
1811- fields_sorted.push (f);
1812- i++;
1804+ fields_sorted.push (fs.to_FieldInfo ());
18131805 }
18141806 }
1815- if (i > 0 ) {
1816- int length = i;
1817- assert (length == fields_sorted.length (), " duh" );
1818- // _sort_Fn is defined in growableArray.hpp.
1807+ int length = fields_sorted.length ();
1808+ if (length > 0 ) {
18191809 fields_sorted.sort (compare_fields_by_offset);
1810+ fieldDescriptor fd;
18201811 for (int i = 0 ; i < length; i++) {
1821- fd.reinitialize (this , fields_sorted.at (i). second );
1822- assert (!fd.is_static () && fd.offset () == fields_sorted.at (i).first , " only nonstatic fields" );
1812+ fd.reinitialize (this , fields_sorted.at (i));
1813+ assert (!fd.is_static () && fd.offset () == checked_cast< int >( fields_sorted.at (i).offset ()) , " only nonstatic fields" );
18231814 cl->do_field (&fd);
18241815 }
18251816 }
0 commit comments