Skip to content
Open
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 @@ -19,6 +19,8 @@

package org.apache.fory.serializer;

import org.apache.fory.platform.GraalvmSupport;

import java.lang.reflect.Array;
import java.lang.reflect.Field;
import java.lang.reflect.Modifier;
Expand Down Expand Up @@ -109,6 +111,9 @@ public AbstractObjectSerializer(
this.isRecord = RecordUtils.isRecord(type);
this.objectInstantiator = objectInstantiator;
this.objectGraphMemoryBytes = GraphMemoryEstimates.shallowObjectBytes(type);
if (GraalvmSupport.isGraalBuildTime()) {
buildFieldsInfo();
}
}

// Keep exception construction and message formatting off the field write success path.
Expand Down Expand Up @@ -1099,6 +1104,10 @@ private Object copyNotPrimitiveField(
return copyFieldValue(copyContext, fieldAccessor.getObject(targetObject), typeId);
}

void setFieldInfos(SerializationFieldInfo[] fieldInfos) {
this.fieldInfos = fieldInfos;
}

private SerializationFieldInfo[] buildFieldsInfo() {
List<Descriptor> descriptors = new ArrayList<>();
if (RecordUtils.isRecord(type)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@ public ObjectSerializer(
}
FieldGroups fieldGroups = FieldGroups.buildFieldInfos(typeResolver, grouper);
allFields = fieldGroups.allFields;
setFieldInfos(allFields);
}

@Override
Expand Down Expand Up @@ -337,4 +338,4 @@ public static void checkClassVersion(Class<?> cls, int readHash, int classVersio
cls, readHash, classVersionHash));
}
}
}
}
Loading