Skip to content

Commit b30a4ab

Browse files
committed
[GR-62599] Sort fields by name and type.
PullRequest: graal/20323
2 parents 7535e6e + c60402c commit b30a4ab

File tree

1 file changed

+7
-1
lines changed
  • substratevm/src/com.oracle.graal.pointsto/src/com/oracle/graal/pointsto/meta

1 file changed

+7
-1
lines changed

substratevm/src/com.oracle.graal.pointsto/src/com/oracle/graal/pointsto/meta/AnalysisType.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1228,7 +1228,13 @@ private ResolvedJavaField[] initializeInstanceFields(boolean includeSuperclasses
12281228
return result;
12291229
}
12301230

1231-
static final Comparator<ResolvedJavaField> FIELD_COMPARATOR = Comparator.comparing(ResolvedJavaField::getJavaKind).thenComparing(ResolvedJavaField::getName);
1231+
/**
1232+
* Sort fields by the field's name *and* type. Note that sorting by name is not enough as the
1233+
* class file format doesn't disallow duplicated names with differing types in the same class.
1234+
* Even though you cannot declare duplicated names in source code the class file can be
1235+
* manipulated such that two fields will have the same name.
1236+
*/
1237+
static final Comparator<ResolvedJavaField> FIELD_COMPARATOR = Comparator.comparing(ResolvedJavaField::getName).thenComparing(f -> f.getType().toJavaName());
12321238

12331239
private ResolvedJavaField[] convertFields(ResolvedJavaField[] originals, List<ResolvedJavaField> list, boolean listIncludesSuperClassesFields) {
12341240
ResolvedJavaField[] localOriginals = originals;

0 commit comments

Comments
 (0)