@Test  
public void testGroovy() throws NoSuchMethodException, SecurityException {
        String expr = "groovyTest.getSplitString(record.str,',',1);";
        Map<String, String> record = new HashMap<String, String>();
        record.put("str", "B,C,D");
       
      //实例化一个CompilerConfiguration对象
        CompilerConfiguration CFG = new CompilerConfiguration();
        CFG.setScriptBaseClass(groovyTest.class.getName());
        
        //实例化一个GroovyShell对象
        GroovyShell shell = new GroovyShell(CFG);
        
        Script script;
        script=shell.parse(expr);        Binding binding = new Binding();
        binding.setVariable("record", record);
        script.setBinding(binding);
        
        Object value=script.run();
        System.out.println(value.toString());    }    public static String getSplitString(String value, String splitMark, int index) {
        String[] arr = value.split(splitMark);
        return arr[index - 1];
    }
运行testGroovy()后报错:
org.codehaus.groovy.runtime.InvokerInvocationException: java.lang.StackOverflowError
at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:97)
at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:233)
at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1086)
at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:910)
at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:731)
at Script1.invokeMethod(Script1.groovy)
at org.codehaus.groovy.runtime.InvokerHelper$2.run(InvokerHelper.java:436)
at com.taobao.uitest.testcase.groovyTest.testGroovy(groovyTest.java:50)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:84)
at org.testng.internal.Invoker.invokeMethod(Invoker.java:714)
at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:901)
at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:1231)
查看了各个帖子说是死循环或者递归。我这代码看不到这两块,求破!