Skip to content

Commit 6b85833

Browse files
[GR-59948] Backport to 24.1: Use a safe cast when retrieving the storage in array-based static objects.
PullRequest: graal/19398
2 parents 2b80bcb + faf9a97 commit 6b85833

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

truffle/src/com.oracle.truffle.api.staticobject/src/com/oracle/truffle/api/staticobject/ArrayBasedStaticShape.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ static <T> ArrayBasedStaticShape<T> create(ArrayBasedShapeGenerator<?> generator
111111
@Override
112112
@SuppressWarnings("cast")
113113
Object getStorage(Object obj, boolean primitive) {
114-
Object receiverObject = cast(obj, storageClass, false);
114+
Object receiverObject = checkedCast(obj, storageClass);
115115
if (safetyChecks) {
116116
checkShape(receiverObject);
117117
} else {

truffle/src/com.oracle.truffle.api.staticobject/src/com/oracle/truffle/api/staticobject/StaticShape.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ final <U> U cast(Object obj, Class<U> type, boolean checkCondition) {
175175
}
176176
}
177177

178-
private static <U> U checkedCast(Object obj, Class<U> type) {
178+
static <U> U checkedCast(Object obj, Class<U> type) {
179179
try {
180180
return type.cast(obj);
181181
} catch (ClassCastException e) {

0 commit comments

Comments
 (0)