Skip to content

Commit

Permalink
Extend the comparison function to all platforms
Browse files Browse the repository at this point in the history
  • Loading branch information
fg1417 committed Oct 8, 2024
1 parent cb946c1 commit 3034f28
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 7 deletions.
6 changes: 0 additions & 6 deletions src/hotspot/share/classfile/fieldLayoutBuilder.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -101,17 +101,11 @@ class LayoutRawBlock : public ResourceObj {
// sort fields in decreasing order.
// Note: with line types, the comparison should include alignment constraint if sizes are equals
static int compare_size_inverted(LayoutRawBlock** x, LayoutRawBlock** y) {
#if defined (_WINDOWS) || defined (__APPLE__)
// qsort() on Windows/macOS reverse the order of fields with the same size
// the extension of the comparison function below preserves this order
int diff = (*y)->size() - (*x)->size();
if (diff == 0) {
diff = (*x)->field_index() - (*y)->field_index();
}
return diff;
#else
return (*y)->size() - (*x)->size();
#endif // _WINDOWS || __APPLE__
}

};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
/*
* @test
* @bug 8341471
* @summary [macOS_aarch64] Reversed field layout caused by unstable sorting
* @summary Reversed field layout caused by unstable sorting
* @modules java.base/jdk.internal.misc
* @run main/othervm TestFieldLayout
*/
Expand Down

0 comments on commit 3034f28

Please sign in to comment.