Skip to content

Commit a5ef94d

Browse files
author
Maja Skoko
committed
Fields sorting in HostedUniverse.
1 parent f50d283 commit a5ef94d

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/meta/HostedUniverse.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -630,5 +630,7 @@ public int compare(HostedMethod o1, HostedMethod o2) {
630630
* keeps the order unchanged and therefore keeps the field order we get from the hosting VM.
631631
*/
632632
static final Comparator<HostedField> FIELD_COMPARATOR_RELAXED = Comparator.comparing(HostedField::getJavaKind).reversed();
633+
static final Comparator<HostedField> FIELD_COMPARATOR_RELAXED_WITH_NAME = Comparator.comparing(HostedField::getJavaKind).reversed()
634+
.thenComparing(m -> m.getDeclaringClass().wrapped.getComparableName()).thenComparing(HostedField::getName);
633635

634636
}

substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/meta/UniverseBuilder.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ public void build(DebugContext debug) {
197197
hUniverse.orderedMethods = new ArrayList<>(hUniverse.methods.values());
198198
Collections.sort(hUniverse.orderedMethods, HostedUniverse.METHOD_COMPARATOR);
199199
hUniverse.orderedFields = new ArrayList<>(hUniverse.fields.values());
200-
Collections.sort(hUniverse.orderedFields, HostedUniverse.FIELD_COMPARATOR_RELAXED);
200+
Collections.sort(hUniverse.orderedFields, HostedUniverse.FIELD_COMPARATOR_RELAXED_WITH_NAME);
201201
profilingInformationBuildTask.join();
202202
}
203203
}
@@ -637,7 +637,7 @@ private void layoutStaticFields() {
637637
}
638638

639639
// Sort so that a) all Object fields are consecutive, and b) bigger types come first.
640-
Collections.sort(fields, HostedUniverse.FIELD_COMPARATOR_RELAXED);
640+
Collections.sort(fields, HostedUniverse.FIELD_COMPARATOR_RELAXED_WITH_NAME);
641641

642642
ObjectLayout layout = ConfigurationValues.getObjectLayout();
643643

0 commit comments

Comments
 (0)