Skip to content

Commit aaedda0

Browse files
author
Christian Wimmer
committed
Do not use the shadow heap for fields annotated with @unknown*Field
1 parent 015c26a commit aaedda0

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/ameta/AnalysisConstantReflectionProvider.java

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,8 @@ public final JavaConstant readFieldValue(ResolvedJavaField field, JavaConstant r
178178
return readValue(metaAccess, (AnalysisField) field, receiver, false);
179179
}
180180

181-
public JavaConstant readValue(UniverseMetaAccess suppliedMetaAccess, AnalysisField field, JavaConstant receiver, boolean returnSimulatedValues) {
181+
public JavaConstant readValue(UniverseMetaAccess suppliedMetaAccess, AnalysisField field, JavaConstant r, boolean returnSimulatedValues) {
182+
JavaConstant receiver = r;
182183
if (!field.isStatic()) {
183184
if (receiver.isNull() || !field.getDeclaringClass().isAssignableFrom(((TypedConstant) receiver).getType(metaAccess))) {
184185
/*
@@ -200,7 +201,17 @@ public JavaConstant readValue(UniverseMetaAccess suppliedMetaAccess, AnalysisFie
200201
}
201202
if (value == null && receiver instanceof ImageHeapConstant) {
202203
ImageHeapInstance heapObject = (ImageHeapInstance) receiver;
203-
value = heapObject.readFieldValue(field);
204+
if (field.isComputedValue() && heapObject.isBackedByHostedObject()) {
205+
/*
206+
* The shadow heap is not complete yet, fields that are annotated
207+
* with @UnknownObjectField or @UnknownPrimitiveField are not properly updated in
208+
* the shadow heap when their value becomes available. We always must read the
209+
* hosted values for such fields.
210+
*/
211+
receiver = heapObject.getHostedObject();
212+
} else {
213+
value = heapObject.readFieldValue(field);
214+
}
204215
}
205216
if (value == null) {
206217
value = universe.lookup(ReadableJavaField.readFieldValue(suppliedMetaAccess, classInitializationSupport, field.wrapped, universe.toHosted(receiver)));

0 commit comments

Comments
 (0)