Ensure correct boxing in compiled code for OpEq with primitives
Without this change when the operands to an == are a mix of a reference type and a primitive, the failure to box the primitive would result in a verifyerror when the compiled code is loaded. Issue: SPR-12557
This commit is contained in:
parent
3125ef784c
commit
abc3cc4dc4
|
@ -112,7 +112,13 @@ public class OpEQ extends Operator {
|
|||
}
|
||||
else {
|
||||
getLeftOperand().generateCode(mv, cf);
|
||||
if (leftPrim) {
|
||||
CodeFlow.insertBoxIfNecessary(mv, leftDesc.charAt(0));
|
||||
}
|
||||
getRightOperand().generateCode(mv, cf);
|
||||
if (rightPrim) {
|
||||
CodeFlow.insertBoxIfNecessary(mv, rightDesc.charAt(0));
|
||||
}
|
||||
Label leftNotNull = new Label();
|
||||
mv.visitInsn(DUP_X1); // Dup right on the top of the stack
|
||||
mv.visitJumpInsn(IFNONNULL,leftNotNull);
|
||||
|
|
|
@ -1285,7 +1285,20 @@ public class SpelCompilationCoverageTests extends AbstractExpressionTests {
|
|||
|
||||
@Test
|
||||
public void opEq() throws Exception {
|
||||
|
||||
String tvar = "35";
|
||||
expression = parse("#root == 35");
|
||||
Boolean bb = (Boolean)expression.getValue(tvar);
|
||||
System.out.println(bb);
|
||||
assertFalse((Boolean)expression.getValue(tvar));
|
||||
assertCanCompile(expression);
|
||||
assertFalse((Boolean)expression.getValue(tvar));
|
||||
|
||||
expression = parse("35 == #root");
|
||||
expression.getValue(tvar);
|
||||
assertFalse((Boolean)expression.getValue(tvar));
|
||||
assertCanCompile(expression);
|
||||
assertFalse((Boolean)expression.getValue(tvar));
|
||||
|
||||
TestClass7 tc7 = new TestClass7();
|
||||
expression = parse("property == 'UK'");
|
||||
assertTrue((Boolean)expression.getValue(tc7));
|
||||
|
|
Loading…
Reference in New Issue