From a7de0786942783a28e6590979cce48e30ceb9f04 Mon Sep 17 00:00:00 2001 From: Roland Praml Date: Fri, 4 Oct 2024 16:47:36 +0200 Subject: [PATCH] Skip importing same class twice (fixes #1463) --- .../main/java/org/mozilla/javascript/ImporterTopLevel.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/rhino/src/main/java/org/mozilla/javascript/ImporterTopLevel.java b/rhino/src/main/java/org/mozilla/javascript/ImporterTopLevel.java index 2a28f116cb..8b64358de8 100644 --- a/rhino/src/main/java/org/mozilla/javascript/ImporterTopLevel.java +++ b/rhino/src/main/java/org/mozilla/javascript/ImporterTopLevel.java @@ -219,7 +219,10 @@ private static void importClass(Scriptable scope, NativeJavaClass cl) { String s = cl.getClassObject().getName(); String n = s.substring(s.lastIndexOf('.') + 1); Object val = scope.get(n, scope); - if (val != NOT_FOUND && val != cl) { + if (val != NOT_FOUND) { + if (val.equals(cl)) { + return; // do not redefine same class + } throw Context.reportRuntimeErrorById("msg.prop.defined", n); } // defineProperty(n, cl, DONTENUM);