From dabca714923b705e599f7a3f4002ab383c850f19 Mon Sep 17 00:00:00 2001 From: Rick Ossendrijver Date: Wed, 2 Feb 2022 14:18:44 +0100 Subject: [PATCH 1/4] PrimitiveComparison: Add type arguments if needed --- .../bugpatterns/PrimitiveComparisonCheck.java | 35 ++++++++++++++----- .../PrimitiveComparisonCheckTest.java | 32 ++++++++--------- 2 files changed, 40 insertions(+), 27 deletions(-) diff --git a/error-prone-contrib/src/main/java/tech/picnic/errorprone/bugpatterns/PrimitiveComparisonCheck.java b/error-prone-contrib/src/main/java/tech/picnic/errorprone/bugpatterns/PrimitiveComparisonCheck.java index 44b2d7db05..8d24c2938f 100644 --- a/error-prone-contrib/src/main/java/tech/picnic/errorprone/bugpatterns/PrimitiveComparisonCheck.java +++ b/error-prone-contrib/src/main/java/tech/picnic/errorprone/bugpatterns/PrimitiveComparisonCheck.java @@ -37,7 +37,6 @@ */ // XXX: Add more documentation. Explain how this is useful in the face of refactoring to more // specific types. -// XXX: Change this checker's name? @AutoService(BugChecker.class) @BugPattern( name = "PrimitiveComparison", @@ -77,23 +76,44 @@ public Description matchMethodInvocation(MethodInvocationTree tree, VisitorState } return getPotentiallyBoxedReturnType(tree.getArguments().get(0)) - .flatMap(cmpType -> tryFix(tree, state, cmpType, isStatic)) + .flatMap(cmpType -> tryMakeMethodCallMorePrecise(tree, cmpType, isStatic, state)) .map(fix -> describeMatch(tree, fix)) .orElse(Description.NO_MATCH); } - private static Optional tryFix( - MethodInvocationTree tree, VisitorState state, Type cmpType, boolean isStatic) { + private static Optional tryMakeMethodCallMorePrecise( + MethodInvocationTree tree, Type cmpType, boolean isStatic, VisitorState state) { return Optional.ofNullable(ASTHelpers.getSymbol(tree)) .map(methodSymbol -> methodSymbol.getSimpleName().toString()) .flatMap( actualMethodName -> - Optional.of(getPreferredMethod(state, cmpType, isStatic)) + Optional.of(getPreferredMethod(cmpType, isStatic, state)) .filter(not(actualMethodName::equals))) + .map( + preferredMethodName -> + prefixWithTypeArgumentsIfNeeded(preferredMethodName, tree, cmpType, state)) .map(preferredMethodName -> suggestFix(tree, preferredMethodName, state)); } - private static String getPreferredMethod(VisitorState state, Type cmpType, boolean isStatic) { + private static String prefixWithTypeArgumentsIfNeeded( + String preferredMethodName, MethodInvocationTree tree, Type cmpType, VisitorState state) { + int typeArguments = tree.getTypeArguments().size(); + boolean methodNameIsComparing = preferredMethodName.equals("comparing"); + + if (typeArguments == 0 || (typeArguments == 1 && !methodNameIsComparing)) { + return preferredMethodName; + } + + String optionalSecondTypeArgument = + methodNameIsComparing ? ", " + cmpType.tsym.getSimpleName() : ""; + return String.format( + "<%s%s>%s", + Util.treeToString(tree.getTypeArguments().get(0), state), + optionalSecondTypeArgument, + preferredMethodName); + } + + private static String getPreferredMethod(Type cmpType, boolean isStatic, VisitorState state) { Types types = state.getTypes(); Symtab symtab = state.getSymtab(); @@ -128,9 +148,6 @@ private static Optional getPotentiallyBoxedReturnType(ExpressionTree tree) } } - // XXX: We drop explicitly specified generic type information. In case the number of type - // arguments before and after doesn't match, that's for the better. But if we e.g. replace - // `comparingLong` with `comparingInt`, then we should retain it. private static Fix suggestFix( MethodInvocationTree tree, String preferredMethodName, VisitorState state) { ExpressionTree expr = tree.getMethodSelect(); diff --git a/error-prone-contrib/src/test/java/tech/picnic/errorprone/bugpatterns/PrimitiveComparisonCheckTest.java b/error-prone-contrib/src/test/java/tech/picnic/errorprone/bugpatterns/PrimitiveComparisonCheckTest.java index f8111e0ea4..dfbd5ded15 100644 --- a/error-prone-contrib/src/test/java/tech/picnic/errorprone/bugpatterns/PrimitiveComparisonCheckTest.java +++ b/error-prone-contrib/src/test/java/tech/picnic/errorprone/bugpatterns/PrimitiveComparisonCheckTest.java @@ -426,8 +426,6 @@ void stringComparison() { .doTest(); } - // XXX: If the explicit `` generic type information was necessary, then this - // replacement drops too much information. @Test void replacementWithPrimitiveVariants() { refactoringTestHelper @@ -459,13 +457,13 @@ void replacementWithPrimitiveVariants() { "import java.util.Comparator;", "", "interface A extends Comparable {", - " Comparator bCmp = Comparator.comparingInt(o -> (byte) 0);", - " Comparator cCmp = Comparator.comparingInt(o -> (char) 0);", - " Comparator sCmp = Comparator.comparingInt(o -> (short) 0);", - " Comparator iCmp = Comparator.comparingInt(o -> 0);", - " Comparator lCmp = Comparator.comparingLong(o -> 0L);", - " Comparator fCmp = Comparator.comparingDouble(o -> 0.0f);", - " Comparator dCmp = Comparator.comparingDouble(o -> 0.0);", + " Comparator bCmp = Comparator.comparingInt(o -> (byte) 0);", + " Comparator cCmp = Comparator.comparingInt(o -> (char) 0);", + " Comparator sCmp = Comparator.comparingInt(o -> (short) 0);", + " Comparator iCmp = Comparator.comparingInt(o -> 0);", + " Comparator lCmp = Comparator.comparingLong(o -> 0L);", + " Comparator fCmp = Comparator.comparingDouble(o -> 0.0f);", + " Comparator dCmp = Comparator.comparingDouble(o -> 0.0);", "", " default void m() {", " bCmp.thenComparingInt(o -> (byte) 0);", @@ -480,8 +478,6 @@ void replacementWithPrimitiveVariants() { .doTest(TestMode.TEXT_MATCH); } - // XXX: If the explicit `` generic type information was necessary, then this replacement drops - // too much information. @Test void replacementWithBoxedVariants() { refactoringTestHelper @@ -513,13 +509,13 @@ void replacementWithBoxedVariants() { "import java.util.Comparator;", "", "interface A extends Comparable {", - " Comparator bCmp = Comparator.comparing(o -> Byte.valueOf((byte) 0));", - " Comparator cCmp = Comparator.comparing(o -> Character.valueOf((char) 0));", - " Comparator sCmp = Comparator.comparing(o -> Short.valueOf((short) 0));", - " Comparator iCmp = Comparator.comparing(o -> Integer.valueOf(0));", - " Comparator lCmp = Comparator.comparing(o -> Long.valueOf(0));", - " Comparator fCmp = Comparator.comparing(o -> Float.valueOf(0));", - " Comparator dCmp = Comparator.comparing(o -> Double.valueOf(0));", + " Comparator bCmp = Comparator.comparing(o -> Byte.valueOf((byte) 0));", + " Comparator cCmp = Comparator.comparing(o -> Character.valueOf((char) 0));", + " Comparator sCmp = Comparator.comparing(o -> Short.valueOf((short) 0));", + " Comparator iCmp = Comparator.comparing(o -> Integer.valueOf(0));", + " Comparator lCmp = Comparator.comparing(o -> Long.valueOf(0));", + " Comparator fCmp = Comparator.comparing(o -> Float.valueOf(0));", + " Comparator dCmp = Comparator.comparing(o -> Double.valueOf(0));", "", " default void m() {", " bCmp.thenComparing(o -> Byte.valueOf((byte) 0));", From 8b133f997e1ec846c23f0a90c417e203f65007d7 Mon Sep 17 00:00:00 2001 From: Rick Ossendrijver Date: Tue, 15 Feb 2022 14:24:51 +0100 Subject: [PATCH 2/4] Apply suggestions --- .../bugpatterns/PrimitiveComparisonCheck.java | 20 ++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/error-prone-contrib/src/main/java/tech/picnic/errorprone/bugpatterns/PrimitiveComparisonCheck.java b/error-prone-contrib/src/main/java/tech/picnic/errorprone/bugpatterns/PrimitiveComparisonCheck.java index 8d24c2938f..460847e405 100644 --- a/error-prone-contrib/src/main/java/tech/picnic/errorprone/bugpatterns/PrimitiveComparisonCheck.java +++ b/error-prone-contrib/src/main/java/tech/picnic/errorprone/bugpatterns/PrimitiveComparisonCheck.java @@ -7,6 +7,7 @@ import static com.google.errorprone.matchers.method.MethodMatchers.instanceMethod; import static com.google.errorprone.matchers.method.MethodMatchers.staticMethod; import static java.util.function.Predicate.not; +import static java.util.stream.Collectors.joining; import com.google.auto.service.AutoService; import com.google.common.base.VerifyException; @@ -30,6 +31,7 @@ import java.util.Comparator; import java.util.Optional; import java.util.function.Function; +import java.util.stream.Stream; /** * A {@link BugChecker} which flags {@code Comparator#comparing*} invocations that can be replaced @@ -91,11 +93,11 @@ private static Optional tryMakeMethodCallMorePrecise( .filter(not(actualMethodName::equals))) .map( preferredMethodName -> - prefixWithTypeArgumentsIfNeeded(preferredMethodName, tree, cmpType, state)) + mayPrefixWithTypeArguments(preferredMethodName, tree, cmpType, state)) .map(preferredMethodName -> suggestFix(tree, preferredMethodName, state)); } - private static String prefixWithTypeArgumentsIfNeeded( + private static String mayPrefixWithTypeArguments( String preferredMethodName, MethodInvocationTree tree, Type cmpType, VisitorState state) { int typeArguments = tree.getTypeArguments().size(); boolean methodNameIsComparing = preferredMethodName.equals("comparing"); @@ -104,13 +106,13 @@ private static String prefixWithTypeArgumentsIfNeeded( return preferredMethodName; } - String optionalSecondTypeArgument = - methodNameIsComparing ? ", " + cmpType.tsym.getSimpleName() : ""; - return String.format( - "<%s%s>%s", - Util.treeToString(tree.getTypeArguments().get(0), state), - optionalSecondTypeArgument, - preferredMethodName); + String typeArgument = + Stream.concat( + Stream.of(Util.treeToString(tree.getTypeArguments().get(0), state)), + Stream.of(cmpType.tsym.getSimpleName()).filter(u -> methodNameIsComparing)) + .collect(joining(",")); + + return String.format("<%s>%s", typeArgument, preferredMethodName); } private static String getPreferredMethod(Type cmpType, boolean isStatic, VisitorState state) { From 451792c1856ead0af9af31b3a5219c0cf2ce049f Mon Sep 17 00:00:00 2001 From: Rick Ossendrijver Date: Sat, 9 Apr 2022 09:54:46 +0200 Subject: [PATCH 3/4] Some feedback from yesterday ;) --- .../errorprone/bugpatterns/PrimitiveComparisonCheck.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/error-prone-contrib/src/main/java/tech/picnic/errorprone/bugpatterns/PrimitiveComparisonCheck.java b/error-prone-contrib/src/main/java/tech/picnic/errorprone/bugpatterns/PrimitiveComparisonCheck.java index 460847e405..8cbb99f53a 100644 --- a/error-prone-contrib/src/main/java/tech/picnic/errorprone/bugpatterns/PrimitiveComparisonCheck.java +++ b/error-prone-contrib/src/main/java/tech/picnic/errorprone/bugpatterns/PrimitiveComparisonCheck.java @@ -99,10 +99,10 @@ private static Optional tryMakeMethodCallMorePrecise( private static String mayPrefixWithTypeArguments( String preferredMethodName, MethodInvocationTree tree, Type cmpType, VisitorState state) { - int typeArguments = tree.getTypeArguments().size(); - boolean methodNameIsComparing = preferredMethodName.equals("comparing"); + int typeArgumentsCount = tree.getTypeArguments().size(); + boolean methodNameIsComparing = "comparing".equals(preferredMethodName); - if (typeArguments == 0 || (typeArguments == 1 && !methodNameIsComparing)) { + if (typeArgumentsCount == 0 || (typeArgumentsCount == 1 && !methodNameIsComparing)) { return preferredMethodName; } From c873787ad056296da4a7c42cb89fc58e4ad055ef Mon Sep 17 00:00:00 2001 From: Stephan Schroevers Date: Sat, 9 Apr 2022 14:59:46 +0200 Subject: [PATCH 4/4] Suggestions --- .../bugpatterns/PrimitiveComparisonCheck.java | 33 ++++--- .../PrimitiveComparisonCheckTest.java | 98 +++++++++++++------ 2 files changed, 91 insertions(+), 40 deletions(-) diff --git a/error-prone-contrib/src/main/java/tech/picnic/errorprone/bugpatterns/PrimitiveComparisonCheck.java b/error-prone-contrib/src/main/java/tech/picnic/errorprone/bugpatterns/PrimitiveComparisonCheck.java index 8cbb99f53a..3750631c4c 100644 --- a/error-prone-contrib/src/main/java/tech/picnic/errorprone/bugpatterns/PrimitiveComparisonCheck.java +++ b/error-prone-contrib/src/main/java/tech/picnic/errorprone/bugpatterns/PrimitiveComparisonCheck.java @@ -78,12 +78,12 @@ public Description matchMethodInvocation(MethodInvocationTree tree, VisitorState } return getPotentiallyBoxedReturnType(tree.getArguments().get(0)) - .flatMap(cmpType -> tryMakeMethodCallMorePrecise(tree, cmpType, isStatic, state)) + .flatMap(cmpType -> attemptMethodInvocationReplacement(tree, cmpType, isStatic, state)) .map(fix -> describeMatch(tree, fix)) .orElse(Description.NO_MATCH); } - private static Optional tryMakeMethodCallMorePrecise( + private static Optional attemptMethodInvocationReplacement( MethodInvocationTree tree, Type cmpType, boolean isStatic, VisitorState state) { return Optional.ofNullable(ASTHelpers.getSymbol(tree)) .map(methodSymbol -> methodSymbol.getSimpleName().toString()) @@ -93,26 +93,35 @@ private static Optional tryMakeMethodCallMorePrecise( .filter(not(actualMethodName::equals))) .map( preferredMethodName -> - mayPrefixWithTypeArguments(preferredMethodName, tree, cmpType, state)) + prefixTypeArgumentsIfRelevant(preferredMethodName, tree, cmpType, state)) .map(preferredMethodName -> suggestFix(tree, preferredMethodName, state)); } - private static String mayPrefixWithTypeArguments( + /** + * Prefixes the given method name with generic type parameters if it replaces a {@code + * Comparator#comparing{,Double,Long,Int}} method which also has generic type parameters. + * + *

Such type parameters are retained as they are likely required. + * + *

Note that any type parameter to {@code Comparator#thenComparing} is likely redundant, and in + * any case becomes obsolete once that method is replaced with {@code + * Comparator#thenComparing{Double,Long,Int}}. Conversion in the opposite direction does not + * require the introduction of a generic type parameter. + */ + private static String prefixTypeArgumentsIfRelevant( String preferredMethodName, MethodInvocationTree tree, Type cmpType, VisitorState state) { - int typeArgumentsCount = tree.getTypeArguments().size(); - boolean methodNameIsComparing = "comparing".equals(preferredMethodName); - - if (typeArgumentsCount == 0 || (typeArgumentsCount == 1 && !methodNameIsComparing)) { + if (tree.getTypeArguments().isEmpty() || preferredMethodName.startsWith("then")) { return preferredMethodName; } - String typeArgument = + String typeArguments = Stream.concat( Stream.of(Util.treeToString(tree.getTypeArguments().get(0), state)), - Stream.of(cmpType.tsym.getSimpleName()).filter(u -> methodNameIsComparing)) - .collect(joining(",")); + Stream.of(cmpType.tsym.getSimpleName()) + .filter(u -> "comparing".equals(preferredMethodName))) + .collect(joining(", ", "<", ">")); - return String.format("<%s>%s", typeArgument, preferredMethodName); + return typeArguments + preferredMethodName; } private static String getPreferredMethod(Type cmpType, boolean isStatic, VisitorState state) { diff --git a/error-prone-contrib/src/test/java/tech/picnic/errorprone/bugpatterns/PrimitiveComparisonCheckTest.java b/error-prone-contrib/src/test/java/tech/picnic/errorprone/bugpatterns/PrimitiveComparisonCheckTest.java index dfbd5ded15..90e9cf9727 100644 --- a/error-prone-contrib/src/test/java/tech/picnic/errorprone/bugpatterns/PrimitiveComparisonCheckTest.java +++ b/error-prone-contrib/src/test/java/tech/picnic/errorprone/bugpatterns/PrimitiveComparisonCheckTest.java @@ -434,21 +434,35 @@ void replacementWithPrimitiveVariants() { "import java.util.Comparator;", "", "interface A extends Comparable {", - " Comparator bCmp = Comparator.comparing(o -> (byte) 0);", - " Comparator cCmp = Comparator.comparing(o -> (char) 0);", - " Comparator sCmp = Comparator.comparing(o -> (short) 0);", - " Comparator iCmp = Comparator.comparing(o -> 0);", - " Comparator lCmp = Comparator.comparing(o -> 0L);", - " Comparator fCmp = Comparator.comparing(o -> 0.0f);", - " Comparator dCmp = Comparator.comparing(o -> 0.0);", + " Comparator bCmp = Comparator.comparing(o -> (byte) 0);", + " Comparator bCmp2 = Comparator.comparing(o -> (byte) 0);", + " Comparator cCmp = Comparator.comparing(o -> (char) 0);", + " Comparator cCmp2 = Comparator.comparing(o -> (char) 0);", + " Comparator sCmp = Comparator.comparing(o -> (short) 0);", + " Comparator sCmp2 = Comparator.comparing(o -> (short) 0);", + " Comparator iCmp = Comparator.comparing(o -> 0);", + " Comparator iCmp2 = Comparator.comparing(o -> 0);", + " Comparator lCmp = Comparator.comparing(o -> 0L);", + " Comparator lCmp2 = Comparator.comparing(o -> 0L);", + " Comparator fCmp = Comparator.comparing(o -> 0.0f);", + " Comparator fCmp2 = Comparator.comparing(o -> 0.0f);", + " Comparator dCmp = Comparator.comparing(o -> 0.0);", + " Comparator dCmp2 = Comparator.comparing(o -> 0.0);", "", " default void m() {", + " bCmp.thenComparing(o -> (byte) 0);", " bCmp.thenComparing(o -> (byte) 0);", + " cCmp.thenComparing(o -> (char) 0);", " cCmp.thenComparing(o -> (char) 0);", + " sCmp.thenComparing(o -> (short) 0);", " sCmp.thenComparing(o -> (short) 0);", + " iCmp.thenComparing(o -> 0);", " iCmp.thenComparing(o -> 0);", + " lCmp.thenComparing(o -> 0L);", " lCmp.thenComparing(o -> 0L);", + " fCmp.thenComparing(o -> 0.0f);", " fCmp.thenComparing(o -> 0.0f);", + " dCmp.thenComparing(o -> 0.0);", " dCmp.thenComparing(o -> 0.0);", " }", "}") @@ -457,22 +471,36 @@ void replacementWithPrimitiveVariants() { "import java.util.Comparator;", "", "interface A extends Comparable {", - " Comparator bCmp = Comparator.comparingInt(o -> (byte) 0);", - " Comparator cCmp = Comparator.comparingInt(o -> (char) 0);", - " Comparator sCmp = Comparator.comparingInt(o -> (short) 0);", - " Comparator iCmp = Comparator.comparingInt(o -> 0);", - " Comparator lCmp = Comparator.comparingLong(o -> 0L);", - " Comparator fCmp = Comparator.comparingDouble(o -> 0.0f);", - " Comparator dCmp = Comparator.comparingDouble(o -> 0.0);", + " Comparator bCmp = Comparator.comparingInt(o -> (byte) 0);", + " Comparator bCmp2 = Comparator.comparingInt(o -> (byte) 0);", + " Comparator cCmp = Comparator.comparingInt(o -> (char) 0);", + " Comparator cCmp2 = Comparator.comparingInt(o -> (char) 0);", + " Comparator sCmp = Comparator.comparingInt(o -> (short) 0);", + " Comparator sCmp2 = Comparator.comparingInt(o -> (short) 0);", + " Comparator iCmp = Comparator.comparingInt(o -> 0);", + " Comparator iCmp2 = Comparator.comparingInt(o -> 0);", + " Comparator lCmp = Comparator.comparingLong(o -> 0L);", + " Comparator lCmp2 = Comparator.comparingLong(o -> 0L);", + " Comparator fCmp = Comparator.comparingDouble(o -> 0.0f);", + " Comparator fCmp2 = Comparator.comparingDouble(o -> 0.0f);", + " Comparator dCmp = Comparator.comparingDouble(o -> 0.0);", + " Comparator dCmp2 = Comparator.comparingDouble(o -> 0.0);", "", " default void m() {", " bCmp.thenComparingInt(o -> (byte) 0);", + " bCmp.thenComparingInt(o -> (byte) 0);", + " cCmp.thenComparingInt(o -> (char) 0);", " cCmp.thenComparingInt(o -> (char) 0);", " sCmp.thenComparingInt(o -> (short) 0);", + " sCmp.thenComparingInt(o -> (short) 0);", + " iCmp.thenComparingInt(o -> 0);", " iCmp.thenComparingInt(o -> 0);", " lCmp.thenComparingLong(o -> 0L);", + " lCmp.thenComparingLong(o -> 0L);", + " fCmp.thenComparingDouble(o -> 0.0f);", " fCmp.thenComparingDouble(o -> 0.0f);", " dCmp.thenComparingDouble(o -> 0.0);", + " dCmp.thenComparingDouble(o -> 0.0);", " }", "}") .doTest(TestMode.TEXT_MATCH); @@ -486,13 +514,20 @@ void replacementWithBoxedVariants() { "import java.util.Comparator;", "", "interface A extends Comparable {", - " Comparator bCmp = Comparator.comparingInt(o -> Byte.valueOf((byte) 0));", - " Comparator cCmp = Comparator.comparingInt(o -> Character.valueOf((char) 0));", - " Comparator sCmp = Comparator.comparingInt(o -> Short.valueOf((short) 0));", - " Comparator iCmp = Comparator.comparingInt(o -> Integer.valueOf(0));", - " Comparator lCmp = Comparator.comparingLong(o -> Long.valueOf(0));", - " Comparator fCmp = Comparator.comparingDouble(o -> Float.valueOf(0));", - " Comparator dCmp = Comparator.comparingDouble(o -> Double.valueOf(0));", + " Comparator bCmp = Comparator.comparingInt(o -> Byte.valueOf((byte) 0));", + " Comparator bCmp2 = Comparator.comparingInt(o -> Byte.valueOf((byte) 0));", + " Comparator cCmp = Comparator.comparingInt(o -> Character.valueOf((char) 0));", + " Comparator cCmp2 = Comparator.comparingInt(o -> Character.valueOf((char) 0));", + " Comparator sCmp = Comparator.comparingInt(o -> Short.valueOf((short) 0));", + " Comparator sCmp2 = Comparator.comparingInt(o -> Short.valueOf((short) 0));", + " Comparator iCmp = Comparator.comparingInt(o -> Integer.valueOf(0));", + " Comparator iCmp2 = Comparator.comparingInt(o -> Integer.valueOf(0));", + " Comparator lCmp = Comparator.comparingLong(o -> Long.valueOf(0));", + " Comparator lCmp2 = Comparator.comparingLong(o -> Long.valueOf(0));", + " Comparator fCmp = Comparator.comparingDouble(o -> Float.valueOf(0));", + " Comparator fCmp2 = Comparator.comparingDouble(o -> Float.valueOf(0));", + " Comparator dCmp = Comparator.comparingDouble(o -> Double.valueOf(0));", + " Comparator dCmp2 = Comparator.comparingDouble(o -> Double.valueOf(0));", "", " default void m() {", " bCmp.thenComparingInt(o -> Byte.valueOf((byte) 0));", @@ -509,13 +544,20 @@ void replacementWithBoxedVariants() { "import java.util.Comparator;", "", "interface A extends Comparable {", - " Comparator bCmp = Comparator.comparing(o -> Byte.valueOf((byte) 0));", - " Comparator cCmp = Comparator.comparing(o -> Character.valueOf((char) 0));", - " Comparator sCmp = Comparator.comparing(o -> Short.valueOf((short) 0));", - " Comparator iCmp = Comparator.comparing(o -> Integer.valueOf(0));", - " Comparator lCmp = Comparator.comparing(o -> Long.valueOf(0));", - " Comparator fCmp = Comparator.comparing(o -> Float.valueOf(0));", - " Comparator dCmp = Comparator.comparing(o -> Double.valueOf(0));", + " Comparator bCmp = Comparator.comparing(o -> Byte.valueOf((byte) 0));", + " Comparator bCmp2 = Comparator.comparing(o -> Byte.valueOf((byte) 0));", + " Comparator cCmp = Comparator.comparing(o -> Character.valueOf((char) 0));", + " Comparator cCmp2 = Comparator.comparing(o -> Character.valueOf((char) 0));", + " Comparator sCmp = Comparator.comparing(o -> Short.valueOf((short) 0));", + " Comparator sCmp2 = Comparator.comparing(o -> Short.valueOf((short) 0));", + " Comparator iCmp = Comparator.comparing(o -> Integer.valueOf(0));", + " Comparator iCmp2 = Comparator.comparing(o -> Integer.valueOf(0));", + " Comparator lCmp = Comparator.comparing(o -> Long.valueOf(0));", + " Comparator lCmp2 = Comparator.comparing(o -> Long.valueOf(0));", + " Comparator fCmp = Comparator.comparing(o -> Float.valueOf(0));", + " Comparator fCmp2 = Comparator.comparing(o -> Float.valueOf(0));", + " Comparator dCmp = Comparator.comparing(o -> Double.valueOf(0));", + " Comparator dCmp2 = Comparator.comparing(o -> Double.valueOf(0));", "", " default void m() {", " bCmp.thenComparing(o -> Byte.valueOf((byte) 0));",