@Test public void testAutoCallSingularStaticMethod() throws ScriptException { ScriptEngineManager manager = new ScriptEngineManager(); ScriptEngine engine = manager.getEngineByName("java"); Object result = engine.eval("" + "public class Script {" + " public String getMessage(String message) {" + " return \"Message: \" + message;" + " }" + " public static String main() {" + " return new Script().getMessage(\"Hello\");" + " }" + "}"); assertThat(result).isEqualTo("Message: Hello"); }
@Override public Object eval(Reader reader) throws ScriptException { return eval(readScript(reader)); }
JavaScriptEngine implements ScriptEngine, Compilable { @Override public Object eval(Reader reader) throws ScriptException { return eval(readScript(reader)); } }
JavaScriptEngine implements ScriptEngine, Compilable { @Override public Object eval(Reader reader) throws ScriptException { return eval(readScript(reader)); }  }
JavaScriptEngine implements ScriptEngine, Compilable { @Override public Object eval(Reader reader) throws ScriptException { return eval(readScript(reader)); }  void setNameStrategy(NameStrategy nameStrategy); void setConstructorStrategy(ConstructorStrategy constructorStrategy); void setExecutionStrategyFactory(ExecutionStrategyFactory executionStrategyFactory); void setExecutionClassLoader(ClassLoader executionClassLoader); void setIsolation(Isolation isolation); @Override ScriptContext getContext(); @Override void setContext(ScriptContext context); @Override Bindings createBindings(); @Override Bindings getBindings(int scope); @Override void setBindings(Bindings bindings, int scope); @Override void put(String key, Object value); @Override Object get(String key); @Override Object eval(Reader reader); @Override Object eval(String script); @Override Object eval(Reader reader, ScriptContext context); @Override Object eval(String script, ScriptContext context); @Override Object eval(Reader reader, Bindings bindings); @Override Object eval(String script, Bindings bindings); @Override CompiledScript compile(Reader reader); @Override JavaCompiledScript compile(String script); @Override ScriptEngineFactory getFactory(); }
JavaScriptEngine implements ScriptEngine, Compilable { @Override public Object eval(Reader reader) throws ScriptException { return eval(readScript(reader)); }  void setNameStrategy(NameStrategy nameStrategy); void setConstructorStrategy(ConstructorStrategy constructorStrategy); void setExecutionStrategyFactory(ExecutionStrategyFactory executionStrategyFactory); void setExecutionClassLoader(ClassLoader executionClassLoader); void setIsolation(Isolation isolation); @Override ScriptContext getContext(); @Override void setContext(ScriptContext context); @Override Bindings createBindings(); @Override Bindings getBindings(int scope); @Override void setBindings(Bindings bindings, int scope); @Override void put(String key, Object value); @Override Object get(String key); @Override Object eval(Reader reader); @Override Object eval(String script); @Override Object eval(Reader reader, ScriptContext context); @Override Object eval(String script, ScriptContext context); @Override Object eval(Reader reader, Bindings bindings); @Override Object eval(String script, Bindings bindings); @Override CompiledScript compile(Reader reader); @Override JavaCompiledScript compile(String script); @Override ScriptEngineFactory getFactory();  }