11/*
2- * Copyright 2002-2017 the original author or authors.
2+ * Copyright 2002-2018 the original author or authors.
33 *
44 * Licensed under the Apache License, Version 2.0 (the "License");
55 * you may not use this file except in compliance with the License.
4040public abstract class Operator extends SpelNodeImpl {
4141
4242 private final String operatorName ;
43-
43+
4444 // The descriptors of the runtime operand values are used if the discovered declared
4545 // descriptors are not providing enough information (for example a generic type
4646 // whose accessors seem to only be returning 'Object' - the actual descriptors may
@@ -70,7 +70,8 @@ public final String getOperatorName() {
7070 }
7171
7272 /**
73- * String format for all operators is the same '(' [operand] [operator] [operand] ')'
73+ * String format for all operators is the same
74+ * {@code '(' [operand] [operator] [operand] ')'}.
7475 */
7576 @ Override
7677 public String toStringAST () {
@@ -100,8 +101,8 @@ protected boolean isCompilableOperatorUsingNumerics() {
100101 return (dc .areNumbers && dc .areCompatible );
101102 }
102103
103- /**
104- * Numeric comparison operators share very similar generated code, only differing in
104+ /**
105+ * Numeric comparison operators share very similar generated code, only differing in
105106 * two comparison instructions.
106107 */
107108 protected void generateComparisonCode (MethodVisitor mv , CodeFlow cf , int compInstruction1 , int compInstruction2 ) {
@@ -113,14 +114,14 @@ protected void generateComparisonCode(MethodVisitor mv, CodeFlow cf, int compIns
113114 DescriptorComparison dc = DescriptorComparison .checkNumericCompatibility (
114115 leftDesc , rightDesc , this .leftActualDescriptor , this .rightActualDescriptor );
115116 char targetType = dc .compatibleType ; // CodeFlow.toPrimitiveTargetDesc(leftDesc);
116-
117+
117118 cf .enterCompilationScope ();
118119 getLeftOperand ().generateCode (mv , cf );
119120 cf .exitCompilationScope ();
120121 if (unboxLeft ) {
121122 CodeFlow .insertUnboxInsns (mv , targetType , leftDesc );
122123 }
123-
124+
124125 cf .enterCompilationScope ();
125126 getRightOperand ().generateCode (mv , cf );
126127 cf .exitCompilationScope ();
@@ -136,11 +137,11 @@ protected void generateComparisonCode(MethodVisitor mv, CodeFlow cf, int compIns
136137 mv .visitJumpInsn (compInstruction1 , elseTarget );
137138 }
138139 else if (targetType == 'F' ) {
139- mv .visitInsn (FCMPG );
140+ mv .visitInsn (FCMPG );
140141 mv .visitJumpInsn (compInstruction1 , elseTarget );
141142 }
142143 else if (targetType == 'J' ) {
143- mv .visitInsn (LCMP );
144+ mv .visitInsn (LCMP );
144145 mv .visitJumpInsn (compInstruction1 , elseTarget );
145146 }
146147 else if (targetType == 'I' ) {
@@ -212,6 +213,10 @@ else if (leftNumber instanceof Byte || rightNumber instanceof Byte) {
212213 return left .toString ().equals (right .toString ());
213214 }
214215
216+ if (left instanceof Boolean && right instanceof Boolean ) {
217+ return left .equals (right );
218+ }
219+
215220 if (ObjectUtils .nullSafeEquals (left , right )) {
216221 return true ;
217222 }
@@ -225,7 +230,7 @@ else if (leftNumber instanceof Byte || rightNumber instanceof Byte) {
225230
226231 return false ;
227232 }
228-
233+
229234
230235 /**
231236 * A descriptor comparison encapsulates the result of comparing descriptor
@@ -248,7 +253,7 @@ private DescriptorComparison(boolean areNumbers, boolean areCompatible, char com
248253 this .areCompatible = areCompatible ;
249254 this .compatibleType = compatibleType ;
250255 }
251-
256+
252257 /**
253258 * Return an object that indicates whether the input descriptors are compatible.
254259 * <p>A declared descriptor is what could statically be determined (e.g. from looking
@@ -271,7 +276,7 @@ public static DescriptorComparison checkNumericCompatibility(String leftDeclared
271276
272277 boolean leftNumeric = CodeFlow .isPrimitiveOrUnboxableSupportedNumberOrBoolean (ld );
273278 boolean rightNumeric = CodeFlow .isPrimitiveOrUnboxableSupportedNumberOrBoolean (rd );
274-
279+
275280 // If the declared descriptors aren't providing the information, try the actual descriptors
276281 if (!leftNumeric && !ObjectUtils .nullSafeEquals (ld , leftActualDescriptor )) {
277282 ld = leftActualDescriptor ;
@@ -281,7 +286,7 @@ public static DescriptorComparison checkNumericCompatibility(String leftDeclared
281286 rd = rightActualDescriptor ;
282287 rightNumeric = CodeFlow .isPrimitiveOrUnboxableSupportedNumberOrBoolean (rd );
283288 }
284-
289+
285290 if (leftNumeric && rightNumeric ) {
286291 if (CodeFlow .areBoxingCompatible (ld , rd )) {
287292 return new DescriptorComparison (true , true , CodeFlow .toPrimitiveTargetDesc (ld ));
@@ -292,7 +297,7 @@ public static DescriptorComparison checkNumericCompatibility(String leftDeclared
292297 }
293298 else {
294299 return DescriptorComparison .NOT_NUMBERS ;
295- }
300+ }
296301 }
297302 }
298303
0 commit comments