java – 错误消息“尝试在堆栈上分割长或双”指示?

前端之家收集整理的这篇文章主要介绍了java – 错误消息“尝试在堆栈上分割长或双”指示?前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我的代码中出现以下错误

Attempt to split long or double on the stack

我对这个错误的起源无知,不知道如何调试它.这表示什么样的问题?我该怎么解决

[ERROR]  [Mon May 23 14:29:46 IST 2011]   [(class: org/apache/jsp/dashboard_jsp,method: _jspService signature:     (Ljavax/servlet/http/HttpServletRequest;Ljavax/servlet/http/HttpServletResponse;)V) Attempt to split long or double on the stack]  [10.97.34.222] hddlntdsz2350  [ session not set ] 
java.lang.VerifyError: (class: org/apache/jsp/dashboard_jsp,method: _jspService signature: (Ljavax/servlet/http/HttpServletRequest;Ljavax/servlet/http/HttpServletResponse;)V) Attempt to split long or double on the stack
at java.lang.Class.getDeclaredConstructors0(Native Method)
at java.lang.Class.privateGetDeclaredConstructors(Class.java:2389)
at java.lang.Class.getConstructor0(Class.java:2699)
at java.lang.Class.newInstance0(Class.java:326)
at java.lang.Class.newInstance(Class.java:308)
at org.jboss.web.tomcat.service.TomcatInjectionContainer.newInstance(TomcatInjectionContainer.java:273)

问题编号:
我创建了一个如下所示的模型

public class Dashboardviewmodel implements Serializable {

/** defalut serialization id */
private static final long serialVersionUID = 1L;

/**
 * Collection representing all the services
 */
private Map<Long,ServiceCustomerModel> serviceDataMap;

}

在特定的JSP页面上,我正在执行以下操作.

for (Long serviceId : dashboardviewmodel.getServices()) {
           Service service = dashboardviewmodel.getService(serviceId);
}

上述目标类中的getServices方法如下.

public Set<Long> getServices() {
    return this.serviceDataMap.keySet();
}

当在jsp中包含上述代码时.我得到错误.否则,它工作.

进一步调查:

我已经使用以下代码片段更新了dashboard.jsp文件.我无法识别为什么,但这段代码正在运行.

ArrayList<Long> test = new ArrayList<Long>();
test.addAll(dashboardviewmodel.getServices());
for (long serviceId : test) {
    Service service = dashboardviewmodel.getService(serviceId);
}

这个代码对数据有什么不同吗?

解决方法

对于 very simple reason that,Java虚拟机对涉及long和double数据类型的操作执行附加验证

A value of type long or type double
occupies two consecutive local
variables. Such a value may only be
addressed using the lesser index. For
example,a value of type double stored
in the local variable array at index n
actually occupies the local variables
with indices n and n +1; however,the
local variable at index n +1 cannot be
loaded from. It can be stored into.
However,doing so invalidates the
contents of local variable n.

当验证者确定使用不正确的指令来访问长整型或双变量(例如,尝试将索引n处的局部变量视为整数或浮点数,分割双倍/长期变量的指令时)那么所述错误标记.

在这种情况下可以做很多事情,除了修复生成这个字节码的字节码生成器.这可能是Java编译器本身,或任何像ASM,cglib或Javassist这样的字节码操作框架.

编辑:

查看堆栈跟踪后,似乎有问题的类恰好是生成的servlet(来自dashboard.jsp).检查JDK涉及编译JSP的升级是否会解决问题,这是值得的.

原文链接:https://www.f2er.com/java/125234.html

猜你在找的Java相关文章