Java – the error message “attempt to split long or double on the stack” indicates?

The following error occurred in my code:

I am ignorant of the origin of this error and do not know how to debug it What kind of problem does this mean? What should I do?

[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)

Question number: I created a model as shown below

public class Dashboardviewmodel implements Serializable {

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

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

}

On a specific JSP page, I am doing the following

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

The getservices method in the above target class is as follows

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

When the above code is included in the JSP I got a mistake Otherwise, it works

Further investigation:

I have updated the dashboard with the following code snippet JSP file I don't know why, but this code is running

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

Does this code make any difference to the data?

Solution

For very simple reason that, the Java virtual machine performs additional validation on operations involving long and double data types

The error is marked when the verifier determines that an incorrect instruction is used to access a long integer or double variable (for example, when trying to treat a local variable at index n as an integer or floating point number and split a double / long variable)

There are many things you can do in this case, except fix the bytecode generator that generates this bytecode This could be the java compiler itself, or any bytecode manipulation framework like ASM, cglib, or javassist

Edit:

After looking at the stack trace, the class that seems to have a problem happens to be the generated servlet (from dashboard. JSP) It is worth checking whether the upgrade of JDK involving compiling JSP will solve the problem

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>