From 2bfc5b5305b58a6ea544940423f1be82966aa357 Mon Sep 17 00:00:00 2001 From: Alexey Andreev Date: Wed, 30 Oct 2019 15:40:28 +0300 Subject: [PATCH] JS: fix error in strict mode when NPE is never instantiated directly --- .../java/org/teavm/backend/javascript/JavaScriptTarget.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/core/src/main/java/org/teavm/backend/javascript/JavaScriptTarget.java b/core/src/main/java/org/teavm/backend/javascript/JavaScriptTarget.java index fb0ce2900..db7b149d8 100644 --- a/core/src/main/java/org/teavm/backend/javascript/JavaScriptTarget.java +++ b/core/src/main/java/org/teavm/backend/javascript/JavaScriptTarget.java @@ -290,6 +290,11 @@ public class JavaScriptTarget implements TeaVMTarget, TeaVMJavaScriptHost { exceptionCons.getVariable(0).propagate(dependencyAnalyzer.getType( ArrayIndexOutOfBoundsException.class.getName())); exceptionCons.use(); + + exceptionCons = dependencyAnalyzer.linkMethod(new MethodReference( + NullPointerException.class, "", void.class)); + exceptionCons.getVariable(0).propagate(dependencyAnalyzer.getType(NullPointerException.class.getName())); + exceptionCons.use(); } if (stackTraceIncluded) {