Details
-
Type:
Bug
-
Status:
Closed
-
Priority:
Major
-
Resolution: Fixed
-
Affects Version/s: None
-
Fix Version/s: 1.0-JSR-6
-
Component/s: None
-
Labels:None
-
Environment:any java platform
-
Number of attachments :
Description
How does one call methods on variables passed via a Binding object? The following simple example where y is a variable passed in Binding object and is an Integer object fails to run in the script line "foo
"
//-----------------------------java code-----------------------------
package groovytest;
import groovy.lang.Binding;
import groovy.lang.GroovyShell;
import groovy.lang.Script;
import java.util.HashMap;
public class GroovyJavaInterOpTest {
final static int NUMRUNNERS = 2;
static String scrStr1 =
"def foo
\n" +
"{\n" +
" println x;\n" +
"}\n" +
"foo
\n" +
"";
public static void main(String[] args) throws Exception {
GroovyShell gr = new GroovyShell();
Script sc = gr.parse(scrStr1);
HashMap map = new HashMap();
map.put("y", new Integer(4));
sc.setBinding(new Binding(map));
sc.run();
}
}
//----------------------------end-java-code---------------------------------
test java file