Fix bytecode generation for SpEL OpPlus

Without this change the plus operator would fail to
include a CHECKCAST in generated bytecode when it
was compiled in cases where one of the operands
has a runtime type of String but a statically
declared type that was not String (i.e. Object).

Issue: SPR-12426
This commit is contained in:
Andy Clement
2014-11-13 08:12:43 -08:00
parent aa892d97e0
commit 94ee763bc8
2 changed files with 32 additions and 0 deletions

View File

@@ -206,6 +206,9 @@ public class OpPlus extends Operator {
else {
cf.enterCompilationScope();
operand.generateCode(mv,cf);
if (cf.lastDescriptor() != "Ljava/lang/String") {
mv.visitTypeInsn(CHECKCAST, "java/lang/String");
}
cf.exitCompilationScope();
mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/StringBuilder", "append", "(Ljava/lang/String;)Ljava/lang/StringBuilder;", false);
}