groovy
  1. groovy
  2. GROOVY-1567

behavior of Groovyshell and GroovyScriptEngine is not similar

    Details

    • Type: Bug Bug
    • Status: Closed Closed
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: 1.0-JSR-6
    • Fix Version/s: 1.5
    • Component/s: None
    • Labels:
      None
    • Environment:
      Windows XP
    • Number of attachments :
      0

      Description

      I embedded groovy in my java application and tried to run the short script below.

      import java.lang.Thread
      import java.lang.Runnable

      t = new Thread()

      {System.out.println("Hi")}

      t.start()
      t.join()

      I embedded groovy first with the Groovyshell and the Result is as expected (Console output "Hi")

      Binding binding = new Binding();
      GroovyShell shell = new GroovyShell(binding);
      String[] test=null;
      Object result = shell.run(new File(path+"/"+file), test);

      The second try was with the GroovyScriptEngine:

      String[] roots = new String[]

      {path }

      ;
      GroovyScriptEngine gse = new GroovyScriptEngine(roots);
      Binding binding = new Binding();
      gse.run(file, binding);

      In this case I got a exception:
      groovy.lang.MissingMethodException: No signature of method t.start() is applicable for argument types: () values: {}
      at groovy.lang.MetaClassImpl.invokeStaticMethod(MetaClassImpl.java:507)
      at org.codehaus.groovy.runtime.Invoker.invokeMethod(Invoker.java:138)
      at org.codehaus.groovy.runtime.InvokerHelper.invokeMethod(InvokerHelper.java:104)
      at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.invokeMethod(ScriptBytecodeAdapter.java:85)
      at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.invokeNoArgumentsMethod(ScriptBytecodeAdapter.java:175)

      I don't know if it is really a bug.

        Activity

        Guillaume Laforge made changes -
        Field Original Value New Value
        Assignee Guillaume Laforge [ guillaume ]
        Andres Almiray made changes -
        Fix Version/s 1.1 [ 13904 ]
        Status Open [ 1 ] Resolved [ 5 ]
        Resolution Fixed [ 1 ]
        Paul King made changes -
        Status Resolved [ 5 ] Closed [ 6 ]

          People

          • Assignee:
            Unassigned
            Reporter:
            Thomas Adam
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: