Ensure cast correctly included for OpPlus compilation

When the plus operator is used between strings in a SpEL
expression and that expression is compiled, it is
important to include a cast if computation of any of
the operands isn't obviously leaving strings on the
stack. Likewise if the stack contents are known to
be strings, a cast should not be included.

Issue: SPR-12426
This commit is contained in:
Andy Clement
2015-11-24 13:37:53 -08:00
parent d5ca5b74a5
commit 58756b023c
2 changed files with 24 additions and 1 deletions

View File

@@ -198,7 +198,7 @@ public class OpPlus extends Operator {
else {
cf.enterCompilationScope();
operand.generateCode(mv,cf);
if (cf.lastDescriptor() != "Ljava/lang/String") {
if (!"Ljava/lang/String".equals(cf.lastDescriptor())) {
mv.visitTypeInsn(CHECKCAST, "java/lang/String");
}
cf.exitCompilationScope();