[
https://issues.jboss.org/browse/JASSIST-158?page=com.atlassian.jira.plugi...
]
Scott Marlow commented on JASSIST-158:
--------------------------------------
I think the patch appears correct, since an array on the operand stack should be
represented by one unit (not two).
Section 2.6.2 in JVM spec (SE 7 edition):
{quote}
At any point in time, an operand stack has an associated depth, where a value of type long
or double contributes two units to the depth and a value of any other type contributes one
unit.
{quote}
Method calls with a parameter of long[] or double[] are compiled to
incorrect bytecode resulting in errors such as java.lang.VerifyError: ... Inconsistent
args_size for opc_invokeinterface
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Key: JASSIST-158
URL:
https://issues.jboss.org/browse/JASSIST-158
Project: Javassist
Issue Type: Bug
Affects Versions: 3.16.1-GA
Reporter: Jens Deppe
Assignee: Shigeru Chiba
I believe this patch fixes the problem:
Method calls with a parameter of long[] or double[] are compiled to incorrect bytecode.
For example, the following piece of code...
{code}
long[] aLongArray;
PdxWriter writer;
...
writer.writeLongArray("aLongArray", aLongArray);
{code}
Produces code similar to this:
{code}
13: aload_1
14: ldc #32; //String aLongArray
16: aload_0
17: getfield #35; //Field aLongArray:[J
20: invokeinterface #39, 4; //InterfaceMethod
com/gemstone/gemfire/pdx/PdxWriter.writeLongArray:(Ljava/lang/String;[J)Lcom/gemstone/gemfire/pdx/PdxWriter;
25: pop
{code}
Following the code, it looks like getfield calculates an incorrect stackdepth when
applied to a long[] or double[], resulting in an incorrect number of args applied to
invokeinterface.
The following patch seems to fix things.
{code}
Index: src/main/javassist/compiler/MemberCodeGen.java
===================================================================
--- src/main/javassist/compiler/MemberCodeGen.java (revision 624)
+++ src/main/javassist/compiler/MemberCodeGen.java (working copy)
@@ -957,7 +957,7 @@
else
className = null;
- boolean is2byte = (c == 'J' || c == 'D');
+ boolean is2byte = ((c == 'J' || c == 'D') && dim == 0);
return is2byte;
}
{code}
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see:
http://www.atlassian.com/software/jira