Skip to content

Commit 214fa9c

Browse files
committed
Polishing
1 parent ea534b6 commit 214fa9c

File tree

1 file changed

+38
-39
lines changed
  • spring-expression/src/main/java/org/springframework/expression/spel

1 file changed

+38
-39
lines changed

spring-expression/src/main/java/org/springframework/expression/spel/CodeFlow.java

Lines changed: 38 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -348,72 +348,72 @@ public static void insertUnboxNumberInsns(
348348
public static void insertAnyNecessaryTypeConversionBytecodes(MethodVisitor mv, char targetDescriptor, String stackDescriptor) {
349349
if (CodeFlow.isPrimitive(stackDescriptor)) {
350350
char stackTop = stackDescriptor.charAt(0);
351-
if (stackTop=='I' || stackTop=='B' || stackTop=='S' || stackTop=='C') {
352-
if (targetDescriptor=='D') {
351+
if (stackTop == 'I' || stackTop == 'B' || stackTop == 'S' || stackTop == 'C') {
352+
if (targetDescriptor == 'D') {
353353
mv.visitInsn(I2D);
354354
}
355-
else if (targetDescriptor=='F') {
355+
else if (targetDescriptor == 'F') {
356356
mv.visitInsn(I2F);
357357
}
358-
else if (targetDescriptor=='J') {
358+
else if (targetDescriptor == 'J') {
359359
mv.visitInsn(I2L);
360360
}
361-
else if (targetDescriptor=='I') {
361+
else if (targetDescriptor == 'I') {
362362
// nop
363363
}
364364
else {
365-
throw new IllegalStateException("cannot get from "+stackTop+" to "+targetDescriptor);
365+
throw new IllegalStateException("Cannot get from " + stackTop + " to " + targetDescriptor);
366366
}
367367
}
368-
else if (stackTop=='J') {
369-
if (targetDescriptor=='D') {
368+
else if (stackTop == 'J') {
369+
if (targetDescriptor == 'D') {
370370
mv.visitInsn(L2D);
371371
}
372-
else if (targetDescriptor=='F') {
372+
else if (targetDescriptor == 'F') {
373373
mv.visitInsn(L2F);
374374
}
375-
else if (targetDescriptor=='J') {
375+
else if (targetDescriptor == 'J') {
376376
// nop
377377
}
378-
else if (targetDescriptor=='I') {
378+
else if (targetDescriptor == 'I') {
379379
mv.visitInsn(L2I);
380380
}
381381
else {
382-
throw new IllegalStateException("cannot get from "+stackTop+" to "+targetDescriptor);
382+
throw new IllegalStateException("Cannot get from " + stackTop + " to " + targetDescriptor);
383383
}
384384
}
385-
else if (stackTop=='F') {
386-
if (targetDescriptor=='D') {
385+
else if (stackTop == 'F') {
386+
if (targetDescriptor == 'D') {
387387
mv.visitInsn(F2D);
388388
}
389-
else if (targetDescriptor=='F') {
389+
else if (targetDescriptor == 'F') {
390390
// nop
391391
}
392-
else if (targetDescriptor=='J') {
392+
else if (targetDescriptor == 'J') {
393393
mv.visitInsn(F2L);
394394
}
395-
else if (targetDescriptor=='I') {
395+
else if (targetDescriptor == 'I') {
396396
mv.visitInsn(F2I);
397397
}
398398
else {
399-
throw new IllegalStateException("cannot get from "+stackTop+" to "+targetDescriptor);
399+
throw new IllegalStateException("Cannot get from " + stackTop + " to " + targetDescriptor);
400400
}
401401
}
402-
else if (stackTop=='D') {
403-
if (targetDescriptor=='D') {
402+
else if (stackTop == 'D') {
403+
if (targetDescriptor == 'D') {
404404
// nop
405405
}
406-
else if (targetDescriptor=='F') {
406+
else if (targetDescriptor == 'F') {
407407
mv.visitInsn(D2F);
408408
}
409-
else if (targetDescriptor=='J') {
409+
else if (targetDescriptor == 'J') {
410410
mv.visitInsn(D2L);
411411
}
412-
else if (targetDescriptor=='I') {
412+
else if (targetDescriptor == 'I') {
413413
mv.visitInsn(D2I);
414414
}
415415
else {
416-
throw new IllegalStateException("cannot get from "+stackDescriptor+" to "+targetDescriptor);
416+
throw new IllegalStateException("Cannot get from " + stackDescriptor + " to " + targetDescriptor);
417417
}
418418
}
419419
}
@@ -530,7 +530,7 @@ public static String toDescriptorFromObject(@Nullable Object value) {
530530
}
531531

532532
/**
533-
* Returns if the descriptor is for a boolean primitive or boolean reference type.
533+
* Determine whether the descriptor is for a boolean primitive or boolean reference type.
534534
* @param descriptor type descriptor
535535
* @return {@code true} if the descriptor is boolean compatible
536536
*/
@@ -539,7 +539,7 @@ public static boolean isBooleanCompatible(@Nullable String descriptor) {
539539
}
540540

541541
/**
542-
* Returns if the descriptor is for a primitive type.
542+
* Determine whether the descriptor is for a primitive type.
543543
* @param descriptor type descriptor
544544
* @return {@code true} if a primitive type
545545
*/
@@ -548,7 +548,7 @@ public static boolean isPrimitive(@Nullable String descriptor) {
548548
}
549549

550550
/**
551-
* Returns if the descriptor is for a primitive array (e.g. "[[I").
551+
* Determine whether the descriptor is for a primitive array (e.g. "[[I").
552552
* @param descriptor the descriptor for a possible primitive array
553553
* @return {@code true} if the descriptor a primitive array
554554
*/
@@ -569,8 +569,8 @@ public static boolean isPrimitiveArray(@Nullable String descriptor) {
569569
}
570570

571571
/**
572-
* Determine if boxing/unboxing can get from one type to the other. Assumes at least
573-
* one of the types is in boxed form (i.e. single char descriptor).
572+
* Determine whether boxing/unboxing can get from one type to the other.
573+
* Assumes at least one of the types is in boxed form (i.e. single char descriptor).
574574
* @return {@code true} if it is possible to get (via boxing) from one descriptor to the other
575575
*/
576576
public static boolean areBoxingCompatible(String desc1, String desc2) {
@@ -781,9 +781,8 @@ public static void insertBoxIfNecessary(MethodVisitor mv, char ch) {
781781
}
782782

783783
/**
784-
* Deduce the descriptor for a type. Descriptors are like JVM type names but missing
785-
* the trailing ';' so for Object the descriptor is "Ljava/lang/Object" for int it is
786-
* "I".
784+
* Deduce the descriptor for a type. Descriptors are like JVM type names but missing the
785+
* trailing ';' so for Object the descriptor is "Ljava/lang/Object" for int it is "I".
787786
* @param type the type (may be primitive) for which to determine the descriptor
788787
* @return the descriptor
789788
*/
@@ -957,7 +956,7 @@ public static int arrayCodeFor(String arraytype) {
957956
case 'S': return T_SHORT;
958957
case 'Z': return T_BOOLEAN;
959958
default:
960-
throw new IllegalArgumentException("Unexpected arraytype "+arraytype.charAt(0));
959+
throw new IllegalArgumentException("Unexpected arraytype " + arraytype.charAt(0));
961960
}
962961
}
963962

@@ -971,7 +970,7 @@ public static boolean isReferenceTypeArray(String arraytype) {
971970
if (ch == '[') {
972971
continue;
973972
}
974-
return ch=='L';
973+
return (ch == 'L');
975974
}
976975
return false;
977976
}
@@ -991,10 +990,10 @@ public static void insertNewArrayCode(MethodVisitor mv, int size, String arrayty
991990
}
992991
else {
993992
if (arraytype.charAt(0) == '[') {
994-
// Handling the nested array case here. If vararg
995-
// is [[I then we want [I and not [I;
993+
// Handling the nested array case here.
994+
// If vararg is [[I then we want [I and not [I;
996995
if (CodeFlow.isReferenceTypeArray(arraytype)) {
997-
mv.visitTypeInsn(ANEWARRAY, arraytype+";");
996+
mv.visitTypeInsn(ANEWARRAY, arraytype + ";");
998997
}
999998
else {
1000999
mv.visitTypeInsn(ANEWARRAY, arraytype);
@@ -1026,7 +1025,7 @@ public static void insertNumericUnboxOrPrimitiveTypeCoercion(
10261025
}
10271026
}
10281027

1029-
public static final String toBoxedDescriptor(String primitiveDescriptor) {
1028+
public static String toBoxedDescriptor(String primitiveDescriptor) {
10301029
switch (primitiveDescriptor.charAt(0)) {
10311030
case 'I': return "Ljava/lang/Integer";
10321031
case 'J': return "Ljava/lang/Long";
@@ -1037,7 +1036,7 @@ public static final String toBoxedDescriptor(String primitiveDescriptor) {
10371036
case 'S': return "Ljava/lang/Short";
10381037
case 'Z': return "Ljava/lang/Boolean";
10391038
default:
1040-
throw new IllegalArgumentException("Unexpected non primitive descriptor "+primitiveDescriptor);
1039+
throw new IllegalArgumentException("Unexpected non primitive descriptor " + primitiveDescriptor);
10411040
}
10421041
}
10431042

0 commit comments

Comments
 (0)