当我尝试序列化Expando时,我收到了StackoverflowError(没有追溯到我的代码)。用groovy shell再现:
... groovy-2.0.6/bin/groovysh new groovy.json.JsonBuilder(new Expando(name:'hello')).toString()
FATAL: java.lang.StackOverflowError
java.lang.StackOverflowError
at java.lang.Exception.<init>(Exception.java:77)
at java.lang.reflect.InvocationTargetException.<init>(InvocationTargetException.java:54)
at sun.reflect.GeneratedMethodAccessor13.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
...
这应该可行吗?
答案 0 :(得分:3)
适用于1.8.6:
groovy-1.8.6/bin/groovysh new groovy.json.JsonBuilder(new Expando(name:'hello')).toString();
===> {"name":"hello"}
StackoverflowError 1.8.8:
groovy-1.8.8/bin/groovysh new groovy.json.JsonBuilder(new Expando(name:'hello')).toString();
FATAL: java.lang.StackOverflowError
java.lang.StackOverflowError
看起来2.1.0rc1上存在一个错误:http://jira.codehaus.org/browse/GROOVY-5918