From 0602b050e648038ba4649a7a1c000e4f2e033896 Mon Sep 17 00:00:00 2001 From: halibobo1205 Date: Tue, 16 Jul 2024 21:07:50 +0800 Subject: [PATCH] feat(jvm): enhance exception handling for Java 14+ NullPointerException - update condition to check for NullPointerException instances - maintain compatibility with both pre-Java 14 and Java 14+ versions - address JEP 358 changes to NullPointerException behavior - ensure correct handling of non-empty NPE messages in Java 14+ Refs: JEP 358, JDK-8220715 --- actuator/src/main/java/org/tron/core/vm/VM.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/actuator/src/main/java/org/tron/core/vm/VM.java b/actuator/src/main/java/org/tron/core/vm/VM.java index 2150df04c64..b1d7b027601 100644 --- a/actuator/src/main/java/org/tron/core/vm/VM.java +++ b/actuator/src/main/java/org/tron/core/vm/VM.java @@ -108,7 +108,10 @@ public static void play(Program program, JumpTable jumpTable) { } catch (JVMStackOverFlowException | OutOfTimeException e) { throw e; } catch (RuntimeException e) { - if (StringUtils.isEmpty(e.getMessage())) { + // https://openjdk.org/jeps/358 + // https://bugs.openjdk.org/browse/JDK-8220715 + // since jdk 14, the NullPointerExceptions message is not empty + if (e instanceof NullPointerException || StringUtils.isEmpty(e.getMessage())) { logger.warn("Unknown Exception occurred, tx id: {}", Hex.toHexString(program.getRootTransactionId()), e); program.setRuntimeFailure(new RuntimeException("Unknown Exception"));