Details
-
Bug
-
Status: Closed
-
Major
-
Resolution: Fixed
-
1.0-beta-4
-
None
-
None
-
beta-4 with snapshot jar from may 7
Description
In the code below, using the times loop rather than the for loop causes a crash with the message:
Exception in thread "main" java.lang.VerifyError: (class: Test$1, method: doCall signature: (Ljava/lang/Object;)Ljava/lang/Object Expecting to find object/array on stack
at Test.begin(test.groovy:17)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at org.codehaus.groovy.runtime.ReflectionMetaMethod.invoke(ReflectionMetaMethod.java:63)
at groovy.lang.MetaClass.doMethodInvoke(MetaClass.java:996)
at groovy.lang.MetaClass.invokeMethod(MetaClass.java:304)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
...
To eliminate the error, convert the comments to either use the for loop or to use the simpler version of btn.move().
Note: this is quite an odd code example, but it came from a far more complex environment using the RePast simulation environment. I've taken the original and stubbed out all the code I could in a half hr! Let me know if you need more help with this!
Here's the code:
#!/usr/bin/env groovy
import java.awt.Color
import java.util.ArrayList
public class Test {
ArrayList agents
int numAgents = 4
int spaceSize = 50
public void setup()
{ Random.createUniform() agents = new ArrayList() } public void begin() {
// for (i in 1..numAgents) {
numAgents.times
println agents.size()
}
}
public class TinyAgent {
int x; int y; Color color
public void move(int nextX, int nextY)
}
public class Random {
static Random uniform
static void createUniform()
int nextIntFromTo (int from, int to)
{(from + to / 2).intValue()}}
Test t = new Test()
t.setup(); t.begin()