Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -313,10 +313,6 @@ public boolean platformSupported(AnnotatedElement element) {
return true;
}

public boolean sortFields() {
return false;
}

public void clearInThread() {
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Comparator;
import java.util.HashSet;
import java.util.List;
import java.util.Objects;
Expand Down Expand Up @@ -1197,22 +1196,8 @@ private ResolvedJavaField[] initializeInstanceFields(boolean includeSuperclasses
return result;
}

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

private ResolvedJavaField[] convertFields(ResolvedJavaField[] originals, List<ResolvedJavaField> list, boolean listIncludesSuperClassesFields) {
ResolvedJavaField[] localOriginals = originals;
if (universe.hostVM.sortFields()) {
/* Clone the originals; it is a reference to the wrapped type's instanceFields array. */
localOriginals = originals.clone();
Arrays.sort(localOriginals, FIELD_COMPARATOR);
}
for (ResolvedJavaField original : localOriginals) {
for (ResolvedJavaField original : originals) {
if (!original.isInternal() && universe.hostVM.platformSupported(original)) {
try {
AnalysisField aField = universe.lookup(original);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1001,15 +1001,6 @@ private void initializeSharedLayerExcludedFields() {
sharedLayerExcludedFields.add(lookupOriginalDeclaredField(NativeLibraries.class, "nativeLibraryLockMap"));
}

@Override
public boolean sortFields() {
/*
* If building layered images sort the fields by kind and name to ensure stable order.
* Sorting fields in general may lead to some issues. (GR-62599)
*/
return buildingImageLayer;
}

/** If it's not one of the known builder types it must be an original VM type. */
private static boolean isOriginalType(ResolvedJavaType type) {
return !(type instanceof OriginalClassProvider);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@
import java.util.function.Supplier;
import java.util.stream.IntStream;

import com.oracle.svm.hosted.substitute.SubstitutionMethod;
import org.graalvm.collections.EconomicMap;
import org.graalvm.nativeimage.AnnotationAccess;
import org.graalvm.nativeimage.ImageSingletons;
Expand Down Expand Up @@ -121,6 +120,7 @@
import com.oracle.svm.hosted.meta.PatchedWordConstant;
import com.oracle.svm.hosted.reflect.ReflectionFeature;
import com.oracle.svm.hosted.reflect.serialize.SerializationFeature;
import com.oracle.svm.hosted.substitute.SubstitutionMethod;
import com.oracle.svm.hosted.util.IdentityHashCodeUtil;
import com.oracle.svm.shaded.org.capnproto.PrimitiveList;
import com.oracle.svm.shaded.org.capnproto.StructList;
Expand Down Expand Up @@ -1318,6 +1318,12 @@ public void initializeBaseLayerField(AnalysisField analysisField) {
});
registerFlag(fieldData.getIsFolded(), debug -> analysisField.registerAsFolded(PERSISTED));
registerFlag(fieldData.getIsUnsafeAccessed(), debug -> analysisField.registerAsUnsafeAccessed(PERSISTED));

/*
* Inject the base layer position. If the position computed for this layer, either before
* this step or later, is different this will result in a failed guarantee.
*/
analysisField.setPosition(fieldData.getPosition());
}

private PersistedAnalysisField.Reader getFieldData(AnalysisField analysisField) {
Expand Down