首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >与JRockit兼容的Hessian

与JRockit兼容的Hessian
EN

Stack Overflow用户
提问于 2012-01-17 23:15:05
回答 1查看 431关注 0票数 2

在JRockit虚拟机上运行hessian时,是否有人遇到此异常?

代码语言:javascript
复制
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代码并更新hessian jar文件。

EN

回答 1

Stack Overflow用户

发布于 2012-02-23 00:27:20

这是我想出的修复方法。我不知道如何通知Hessian代码的维护者,所以我把它贴在这里。修改文件:

从第112行开始的com.caucho.hessian.util.IdentityIntMap.java

代码语言:javascript
复制
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行开始更改下一个方法中的代码:

代码语言:javascript
复制
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;
  ...
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/8897037

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档