Skip to content

Commit 49fabf0

Browse files
author
loushaokun
committed
modify Platform::throwException to support Android
1 parent 434d8c9 commit 49fabf0

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

java/fory-core/src/main/java/org/apache/fory/memory/Platform.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -285,8 +285,15 @@ public static boolean arrayEquals(
285285
return true;
286286
}
287287

288+
private static <T extends Throwable> void sneakyThrow(Throwable throwable) throws T {
289+
throw (T) throwable; // 将受检异常强制转换为一个未知的泛型异常类型并抛出
290+
}
291+
288292
/** Raises an exception bypassing compiler checks for checked exceptions. */
289293
public static void throwException(Throwable t) {
294+
if (IS_ANDROID) {
295+
sneakyThrow(t);
296+
}
290297
UNSAFE.throwException(t);
291298
}
292299

0 commit comments

Comments
 (0)