Uploaded image for project: 'Groovy'
  1. Groovy
  2. GROOVY-1567

behavior of Groovyshell and GroovyScriptEngine is not similar

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Minor
    • Resolution: Fixed
    • 1.0-JSR-6
    • 1.5
    • None
    • None
    • Windows XP

    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.

      Attachments

        Activity

          People

            Unassigned Unassigned
            tommyadam Thomas Adam
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: