Details
-
Bug
-
Status: Closed
-
Minor
-
Resolution: Fixed
-
1.0-JSR-6
-
None
-
None
-
Mac OSX Intel
Description
I've been playing a little with running Groovy scripts from within Java. Pretty simple how I am doing this:
Binding binding=new Binding();
int[] i=new int[1];
binding.setVariable("i", i);
GroovyShell shell=new GroovyShell(getClass().getClassLoader(), binding);
shell.evaluate("i[0]++");
Now the strange thing is that a compiler error occurs at i[0]++. I'd expected that it would take the first element of the array and increment it. Apparently I'm wrong. Here's the exception:
org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed, General error during class
generation: BinaryExpression appeared on LHS. .
Node: org.codehaus.groovy.ast.expr.BinaryExpression. At [1:2] Script1.groovy
the script i[0]+=1 works.