Created
November 18, 2020 16:49
-
-
Save szegedi/e34eadca02df7fe9ddd98547fae4ccfe to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import javax.script.*; | |
public class X { | |
public static void main(String[] args) throws ScriptException, NoSuchMethodException { | |
ScriptEngineManager scriptEngineManager = new ScriptEngineManager(); | |
ScriptEngine engine = scriptEngineManager.getEngineByName("nashorn"); | |
Compilable ce = (Compilable) engine; | |
CompiledScript cs; | |
try { | |
String script = "function f1602838289254hw9b() {\n" + | |
"var responses = JSON.parse(org.example.MockHttpUtils.sendGetRequest([{\n" + | |
"url:'https://rz.xx.com/test',\n" + | |
"params: {\n" + | |
"id: 0,\n" + | |
"// uuid\n" + | |
"uuid:1,\n" + | |
"styleid: \")\",\n" + | |
"// styleId\n" + | |
"templateid: 0 // backend templateId\n" + | |
"}\n" + | |
"}]));\n" + | |
"var e = responses[2]\n" + | |
"return responses\n" + | |
"}"; | |
ce.compile(script); | |
engine.eval(script); | |
} catch (Exception e) { | |
e.printStackTrace(); | |
} | |
System.out.println((((Invocable)engine).invokeFunction("f1602838289254hw9b"))); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment