Details
-
Wish
-
Status: Closed
-
Major
-
Resolution: Duplicate
-
1.6.4
-
None
-
None
Description
Verbose version of the test passes, but it is a little ugly.
public static final String FOO_CLASS = "class Foo { int getResult() { return 1; } } ; Foo.class"; public static final String FOO = "class Foo { int getResult() { return 1; } }"; public void testClassEvalVerbose() throws ScriptException { ScriptEngineManager factory = new ScriptEngineManager(); ScriptEngine engine = factory.getEngineByName("groovy"); assertEquals("Foo", ((Class) engine.eval(FOO_CLASS)).getCanonicalName()); } public void testClassEvalBrief() throws ScriptException { ScriptEngineManager factory = new ScriptEngineManager(); ScriptEngine engine = factory.getEngineByName("groovy"); assertEquals("Foo", ((Class) engine.eval(FOO)).getCanonicalName()); }
Brief version throws:
javax.script.ScriptException: javax.script.ScriptException: org.codehaus.groovy.runtime.metaclass.MissingMethodExceptionNoStack: No signature of method: Foo.main() is applicable for argument types: ([Ljava.lang.String values: [[]]
at org.codehaus.groovy.jsr223.GroovyScriptEngineImpl.eval(GroovyScriptEngineImpl.java:119)
at javax.script.AbstractScriptEngine.eval(AbstractScriptEngine.java:247)
at com.jtstand.TestStepScriptTest.testClassEvalBrief(TestStepScriptTest.java:42)
Caused by: javax.script.ScriptException: org.codehaus.groovy.runtime.metaclass.MissingMethodExceptionNoStack: No signature of method: Foo.main() is applicable for argument types: ([Ljava.lang.String values: [[]]
at org.codehaus.groovy.jsr223.GroovyScriptEngineImpl.eval(GroovyScriptEngineImpl.java:307)
at org.codehaus.groovy.jsr223.GroovyScriptEngineImpl.eval(GroovyScriptEngineImpl.java:113)
... 28 more
Caused by: org.codehaus.groovy.runtime.metaclass.MissingMethodExceptionNoStack: No signature of method: Foo.main() is applicable for argument types: ([Ljava.lang.String values: [[]]
Why?
Is this what JSR223 specifies to do?
To sad if yes!
Attachments
Issue Links
- is duplicated by
-
GROOVY-3816 Should be possible to declare a class in a script and use it in another script with JSR223
- Closed