在JRockit VM上运行hessian时有没有人遇到此异常?
Caused by: java.lang.ArrayIndexOutOfBoundsException: -418
at com.caucho.hessian.util.IdentityIntMap.put(IdentityIntMap.java:141)
at com.caucho.hessian.io.Hessian2Output.addRef(Hessian2Output.java:1285)
at com.caucho.hessian.io.UnsafeSerializer.writeObject(UnsafeSerializer.java:157)
at com.caucho.hessian.io.Hessian2Output.writeObject(Hessian2Output.java:421)
at com.caucho.hessian.io.CollectionSerializer.writeObject(CollectionSerializer.java:102)
at com.caucho.hessian.io.Hessian2Output.writeObject(Hessian2Output.java:421)
at com.caucho.hessian.io.UnsafeSerializer$ObjectFieldSerializer.serialize(UnsafeSerializer.java:293)
... 34 more
我花了一周时间来解决这个问题只是为了发现hessian与HotSpot VM一起工作正常,但始终无法使用JRockit VM序列化某些对象。我实际上提出了一个简单的修复,但它需要修改IdentityIntMap.java代码并更新粗麻布jar文件。
答案 0 :(得分:1)
这是我提出的解决方案。我无法弄清楚如何通知维护者Hessian代码,所以我在这里发布它。修改文件:
com.caucho.hessian.util.IdentityIntMap.java 从第112行开始:
public final int get(Object key)
{
int prime = _prime;
// int hash = System.identityHashCode(key) % prime;
int hash = System.identityHashCode(key);
// JRockit VMs can return a negative number which will cause this method to throw an exception
if (hash < 0)
hash = -hash;
hash = hash % prime;
...
同时更改从第135行开始的下一个方法中的代码:
public final int put(Object key, int value, boolean isReplace)
{
int prime = _prime;
// int hash = System.identityHashCode(key) % prime;
int hash = System.identityHashCode(key);
// JRockit VMs can return a negative number which will cause this method to throw an exception
if (hash < 0)
hash = -hash;
hash = hash % prime;
...