Skip to content

Commit a376e8e

Browse files
authored
Merge pull request #148 from bulasevich/GR-59858
[Backport] [GR-59858] Mark type of hidden field reachable.
2 parents 1a57bff + 3d52084 commit a376e8e

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

substratevm/src/com.oracle.graal.pointsto/src/com/oracle/graal/pointsto/heap/ImageHeapScanner.java

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -174,8 +174,15 @@ public TypeData computeTypeData(AnalysisType type) {
174174
return data;
175175
}
176176

177-
void markTypeInstantiated(AnalysisType type, ScanReason reason) {
177+
void markTypeReachable(AnalysisType type, ScanReason reason) {
178178
if (universe.sealed() && !type.isReachable()) {
179+
throw AnalysisError.typeNotFound(type);
180+
}
181+
type.registerAsReachable(reason);
182+
}
183+
184+
void markTypeInstantiated(AnalysisType type, ScanReason reason) {
185+
if (universe.sealed() && !type.isInstantiated()) {
179186
throw AnalysisError.shouldNotReachHere("Universe is sealed. New type reachable: " + type.toJavaName());
180187
}
181188
universe.getBigbang().registerTypeAsInHeap(type, reason);
@@ -254,7 +261,7 @@ protected ImageHeapConstant createImageHeapObject(JavaConstant constant, ScanRea
254261
newImageHeapConstant = createImageHeapInstance(constant, type, reason);
255262
AnalysisType typeFromClassConstant = (AnalysisType) constantReflection.asJavaType(constant);
256263
if (typeFromClassConstant != null) {
257-
typeFromClassConstant.registerAsReachable(reason);
264+
markTypeReachable(typeFromClassConstant, reason);
258265
}
259266
}
260267
return newImageHeapConstant;
@@ -277,7 +284,7 @@ private ImageHeapArray createImageHeapObjectArray(JavaConstant constant, Analysi
277284

278285
private ImageHeapInstance createImageHeapInstance(JavaConstant constant, AnalysisType type, ScanReason reason) {
279286
/* We are about to query the type's fields, the type must be marked as reachable. */
280-
type.registerAsReachable(reason);
287+
markTypeReachable(type, reason);
281288
ResolvedJavaField[] instanceFields = type.getInstanceFields(true);
282289
ImageHeapInstance instance = new ImageHeapInstance(type, constant, instanceFields.length);
283290
for (ResolvedJavaField javaField : instanceFields) {

substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/reflect/ReflectionDataBuilder.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -544,6 +544,7 @@ private void checkSubtypeForOverridingField(AnalysisField field, AnalysisType su
544544
AnalysisField subclassField = (AnalysisField) javaField;
545545
if (subclassField.getName().equals(field.getName())) {
546546
hidingFields.add(subclassField);
547+
subclassField.getType().registerAsReachable("Is the declared type of a hiding Field used by reflection");
547548
}
548549
}
549550
} catch (UnsupportedFeatureException | LinkageError e) {

0 commit comments

Comments
 (0)