Skip to content

Commit

Permalink
Mark array types of elemental-type-supertypes as reachable
Browse files Browse the repository at this point in the history
  • Loading branch information
Christian Wimmer committed May 17, 2021
1 parent a55d731 commit f422d95
Showing 1 changed file with 16 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -582,11 +582,22 @@ public void registerAsReachable() {
registerAsAllocated(null);

componentType.registerAsReachable();
if (elementalType.isInterface()) {
universe.objectType().getArrayClass(dimension).registerAsReachable();
}
if (dimension >= 2) {
universe.objectType().getArrayClass(dimension - 1).registerAsReachable();

/*
* For a class B extends A, the array type A[] is not a superclass of the array type
* B[]. So there is no strict need to make A[] reachable when B[] is reachable. But
* it turns out that this is puzzling for users, and there are frameworks that
* instantiate such arrays programmatically using Array.newInstance(). To reduce the
* amount of manual configuration that is necessary, we mark all array types of the
* elemental supertypes and superinterfaces also as reachable.
*/
for (int i = 1; i <= dimension; i++) {
if (elementalType.superClass != null) {
elementalType.superClass.getArrayClass(i).registerAsReachable();
}
for (AnalysisType iface : elementalType.interfaces) {
iface.getArrayClass(i).registerAsReachable();
}
}
}

Expand Down

0 comments on commit f422d95

Please sign in to comment.