Skip to content

SpEL: Compiled OpNE should favor equals() to != [SPR-14863] #19429

Closed
@spring-projects-issues

Description

@spring-projects-issues

Denis Zhdanov opened SPR-14863 and commented

There is a problem with != SpEL in compiled form. It compares strings using reference identity instead of equals().

I.e. the following byte code is generated from the following expression data['my-key'] != 'my-value' (note if_acmpeq instruction usage)

invokevirtual org/denis/spring/spel/Test$MyContext/getData()Ljava/util/Map;
checkcast java/util/Map
ldc "my-key"
invokeinterface java/util/Map/get(Ljava/lang/Object;)Ljava/lang/Object; 2
ldc "my-value"
if_acmpeq 11
iconst_1
goto 12
iconst_0
invokestatic java/lang/Boolean/valueOf(Z)Ljava/lang/Boolean;
areturn

A complete standalone project which illustrates the problem can be found here

I checked spring source code and the problem is in the OpNE class.

There was a similar report for the OpEQ class (#13832) and it was fixed - OpEQ


Affects: 4.3.3

Issue Links:

Metadata

Metadata

Assignees

Labels

in: coreIssues in core modules (aop, beans, core, context, expression)type: bugA general bug

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions