Skip to content

Commit 82fa4ef

Browse files
committed
Polishing
Issue: SPR-14863
1 parent 388e173 commit 82fa4ef

File tree

4 files changed

+1193
-1151
lines changed

4 files changed

+1193
-1151
lines changed

spring-expression/src/main/java/org/springframework/expression/spel/ast/OpEQ.java

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,9 @@ public OpEQ(int pos, SpelNodeImpl... operands) {
3636
this.exitTypeDescriptor = "Z";
3737
}
3838

39+
3940
@Override
40-
public BooleanTypedValue getValueInternal(ExpressionState state)
41-
throws EvaluationException {
41+
public BooleanTypedValue getValueInternal(ExpressionState state) throws EvaluationException {
4242
Object left = getLeftOperand().getValueInternal(state).getValue();
4343
Object right = getRightOperand().getValueInternal(state).getValue();
4444
this.leftActualDescriptor = CodeFlow.toDescriptorFromObject(left);
@@ -86,11 +86,9 @@ public void generateCode(MethodVisitor mv, CodeFlow cf) {
8686
}
8787

8888
String operatorClassName = Operator.class.getName().replace('.', '/');
89-
String evaluationContextClassName = EvaluationContext.class.getName().replace('.',
90-
'/');
91-
mv.visitMethodInsn(INVOKESTATIC, operatorClassName, "equalityCheck", "(L"
92-
+ evaluationContextClassName + ";Ljava/lang/Object;Ljava/lang/Object;)Z",
93-
false);
89+
String evaluationContextClassName = EvaluationContext.class.getName().replace('.', '/');
90+
mv.visitMethodInsn(INVOKESTATIC, operatorClassName, "equalityCheck",
91+
"(L" + evaluationContextClassName + ";Ljava/lang/Object;Ljava/lang/Object;)Z", false);
9492
cf.pushDescriptor("Z");
9593
}
9694

spring-expression/src/main/java/org/springframework/expression/spel/ast/OpNE.java

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,9 @@ public OpNE(int pos, SpelNodeImpl... operands) {
3737
this.exitTypeDescriptor = "Z";
3838
}
3939

40+
4041
@Override
41-
public BooleanTypedValue getValueInternal(ExpressionState state)
42-
throws EvaluationException {
42+
public BooleanTypedValue getValueInternal(ExpressionState state) throws EvaluationException {
4343
Object left = getLeftOperand().getValueInternal(state).getValue();
4444
Object right = getRightOperand().getValueInternal(state).getValue();
4545
this.leftActualDescriptor = CodeFlow.toDescriptorFromObject(left);
@@ -87,11 +87,9 @@ public void generateCode(MethodVisitor mv, CodeFlow cf) {
8787
}
8888

8989
String operatorClassName = Operator.class.getName().replace('.', '/');
90-
String evaluationContextClassName = EvaluationContext.class.getName().replace('.',
91-
'/');
92-
mv.visitMethodInsn(INVOKESTATIC, operatorClassName, "equalityCheck", "(L"
93-
+ evaluationContextClassName + ";Ljava/lang/Object;Ljava/lang/Object;)Z",
94-
false);
90+
String evaluationContextClassName = EvaluationContext.class.getName().replace('.', '/');
91+
mv.visitMethodInsn(INVOKESTATIC, operatorClassName, "equalityCheck",
92+
"(L" + evaluationContextClassName + ";Ljava/lang/Object;Ljava/lang/Object;)Z", false);
9593

9694
// Invert the boolean
9795
Label notZero = new Label();

spring-expression/src/main/java/org/springframework/expression/spel/ast/Operator.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,16 @@ else if (targetType == 'I') {
159159
cf.pushDescriptor("Z");
160160
}
161161

162+
163+
/**
164+
* Perform an equality check for the given operand values.
165+
* <p>This method is not just used for reflective comparisons in subclasses
166+
* but also from compiled expression code, which is why it needs to be
167+
* declared as {@code public static} here.
168+
* @param context the current evaluation context
169+
* @param left the left-hand operand value
170+
* @param right the right-hand operand value
171+
*/
162172
public static boolean equalityCheck(EvaluationContext context, Object left, Object right) {
163173
if (left instanceof Number && right instanceof Number) {
164174
Number leftNumber = (Number) left;

0 commit comments

Comments
 (0)