From ac8c659e3f716ec1fe40e42925000f712aebda5a Mon Sep 17 00:00:00 2001 From: Peter Thomas Date: Wed, 9 Aug 2023 17:14:10 +0530 Subject: [PATCH] improved code from prev commit #2329 --- .../java/com/intuit/karate/graal/JsFunction.java | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/karate-core/src/main/java/com/intuit/karate/graal/JsFunction.java b/karate-core/src/main/java/com/intuit/karate/graal/JsFunction.java index ff0ba5e5d..63d2b8a19 100644 --- a/karate-core/src/main/java/com/intuit/karate/graal/JsFunction.java +++ b/karate-core/src/main/java/com/intuit/karate/graal/JsFunction.java @@ -41,12 +41,10 @@ public abstract class JsFunction implements ProxyObject { public static final Object LOCK = new Object(); - protected final Value value; - protected final CharSequence source; + protected final Value value; protected JsFunction(Value v) { - this.value = v; - source = "(" + value.getSourceLocation().getCharacters() + ")"; + this.value = v; } public static ProxyExecutable wrap(Value value) { @@ -85,14 +83,16 @@ public boolean removeMember(String key) { protected static class Executable extends JsFunction implements ProxyExecutable { private final boolean lock; + private final String source; protected Executable(Value value) { this(value, false); } protected Executable(Value value, boolean lock) { - super(value); + super(value); this.lock = lock; + source = "(" + value.getSourceLocation().getCharacters() + ")"; } @Override @@ -111,7 +111,7 @@ public Object execute(Value... args) { if (je == null || je.context.equals(value.getContext())) { return new JsValue(value.execute(newArgs)).value; } - Value attached = je.evalForValue("(" + source + ")"); + Value attached = je.evalForValue(source); return new JsValue(attached.execute(newArgs)).value; }