Skip to content

Instantly share code, notes, and snippets.

@szegedi
Created November 18, 2020 16:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save szegedi/e34eadca02df7fe9ddd98547fae4ccfe to your computer and use it in GitHub Desktop.
Save szegedi/e34eadca02df7fe9ddd98547fae4ccfe to your computer and use it in GitHub Desktop.
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