diff --git a/core/src/test/java/com/google/errorprone/bugpatterns/ImmutableSetForContainsTest.java b/core/src/test/java/com/google/errorprone/bugpatterns/ImmutableSetForContainsTest.java index f5d993e6116..030d5196d66 100644 --- a/core/src/test/java/com/google/errorprone/bugpatterns/ImmutableSetForContainsTest.java +++ b/core/src/test/java/com/google/errorprone/bugpatterns/ImmutableSetForContainsTest.java @@ -413,9 +413,9 @@ public void listOfClassOrDistinctInstances_uniqueElements_iterating_replacesWith "import java.util.ArrayList;", "class Test {", " private static final ImmutableList> CLS_LIST = ", - " ImmutableList.of(Long.class, Double.class);", + " ImmutableList.of(Long.class, Double.class);", " private static final ImmutableList OBJ_LIST =", - " ImmutableList.of(new Long(1), new Double(2.0));", + " ImmutableList.of(new String(\"\"), new Object());", " private void myFunc() {", " CLS_LIST.stream().forEach(System.out::println);", " OBJ_LIST.forEach(System.out::println);", @@ -430,9 +430,9 @@ public void listOfClassOrDistinctInstances_uniqueElements_iterating_replacesWith "import java.util.ArrayList;", "class Test {", " private static final ImmutableSet> CLS_LIST = ", - " ImmutableSet.of(Long.class, Double.class);", + " ImmutableSet.of(Long.class, Double.class);", " private static final ImmutableSet OBJ_LIST =", - " ImmutableSet.of(new Long(1), new Double(2.0));", + " ImmutableSet.of(new String(\"\"), new Object());", " private void myFunc() {", " CLS_LIST.stream().forEach(System.out::println);", " OBJ_LIST.forEach(System.out::println);", diff --git a/core/src/test/java/com/google/errorprone/bugpatterns/LambdaFunctionalInterfaceTest.java b/core/src/test/java/com/google/errorprone/bugpatterns/LambdaFunctionalInterfaceTest.java index a08a4c3cc58..5b472cc4e9d 100644 --- a/core/src/test/java/com/google/errorprone/bugpatterns/LambdaFunctionalInterfaceTest.java +++ b/core/src/test/java/com/google/errorprone/bugpatterns/LambdaFunctionalInterfaceTest.java @@ -194,7 +194,7 @@ public void testRefactoringGenericToPrimitive() { "import java.util.function.Function;", " public class NumbertoT { ", " private int sumAll(Function sizeConv) {", - " return sizeConv.apply((T) new Integer(3));", + " return sizeConv.apply((T) Integer.valueOf(3));", " }", " public int getSumAll() {", " return sumAll(o -> 2);", @@ -206,7 +206,7 @@ public void testRefactoringGenericToPrimitive() { " import java.util.function.ToIntFunction;", " public class NumbertoT { ", " private int sumAll(ToIntFunction sizeConv) {", - " return sizeConv.applyAsInt((T) new Integer(3));", + " return sizeConv.applyAsInt((T) Integer.valueOf(3));", " }", " public int getSumAll() {", " return sumAll(o -> 2);", diff --git a/core/src/test/java/com/google/errorprone/bugpatterns/LockOnBoxedPrimitiveTest.java b/core/src/test/java/com/google/errorprone/bugpatterns/LockOnBoxedPrimitiveTest.java index b3215cb77f1..b7bdb77cdc6 100644 --- a/core/src/test/java/com/google/errorprone/bugpatterns/LockOnBoxedPrimitiveTest.java +++ b/core/src/test/java/com/google/errorprone/bugpatterns/LockOnBoxedPrimitiveTest.java @@ -92,14 +92,14 @@ public void detectsSynchronizedBoxedLocks_encapsulated_boxedInitializers() throw .addSourceLines( "Test.java", "class Test {", - " private Object badByteLock = new Byte((byte)1);", - " private Object badShortLock = new Short((short)1);", - " private Object badIntLock = new Integer(1);", - " private Object badLongLock = new Long(1);", - " private Object badFloatLock = new Float(1.0);", - " private Object badDoubleLock = new Double(1.0);", - " private Object badBooleanLock = new Boolean(false);", - " private Object badCharLock = new Character('c');", + " private Object badByteLock = Byte.valueOf((byte)1);", + " private Object badShortLock = Short.valueOf((short)1);", + " private Object badIntLock = Integer.valueOf(1);", + " private Object badLongLock = Long.valueOf(1);", + " private Object badFloatLock = Float.valueOf(1.0f);", + " private Object badDoubleLock = Double.valueOf(1.0);", + " private Object badBooleanLock = Boolean.valueOf(false);", + " private Object badCharLock = Character.valueOf('c');", " private void test() {", bugOnSynchronizedBlock("badByteLock"), bugOnSynchronizedBlock("badShortLock"), @@ -258,14 +258,14 @@ public void detectsMonitorMethodBoxedLock_encapsulated_boxedInitializers() throw .addSourceLines( "Test.java", "class Test {", - " private Object badByteLock = new Byte((byte)1);", - " private Object badShortLock = new Short((short)1);", - " private Object badIntLock = new Integer(1);", - " private Object badLongLock = new Long(1);", - " private Object badFloatLock = new Float(1.0);", - " private Object badDoubleLock = new Double(1.0);", - " private Object badBooleanLock = new Boolean(false);", - " private Object badCharLock = new Character('c');", + " private Object badByteLock = Byte.valueOf((byte)1);", + " private Object badShortLock = Short.valueOf((short)1);", + " private Object badIntLock = Integer.valueOf(1);", + " private Object badLongLock = Long.valueOf(1);", + " private Object badFloatLock = Float.valueOf(1.0f);", + " private Object badDoubleLock = Double.valueOf(1.0);", + " private Object badBooleanLock = Boolean.valueOf(false);", + " private Object badCharLock = Character.valueOf('c');", " private void test() throws InterruptedException {", bugOnMonitorMethods("badByteLock"), bugOnMonitorMethods("badShortLock"), diff --git a/core/src/test/java/com/google/errorprone/bugpatterns/MathRoundIntLongTest.java b/core/src/test/java/com/google/errorprone/bugpatterns/MathRoundIntLongTest.java index db7b68eb584..da83c8873f2 100644 --- a/core/src/test/java/com/google/errorprone/bugpatterns/MathRoundIntLongTest.java +++ b/core/src/test/java/com/google/errorprone/bugpatterns/MathRoundIntLongTest.java @@ -54,7 +54,7 @@ public void deleteRoundMethodIntClass() { "Test.java", // "class Test {", " void f() {", - " Integer i = new Integer(3);", + " Integer i = Integer.valueOf(3);", " int y = Math.round(i);", " }", "}") @@ -62,7 +62,7 @@ public void deleteRoundMethodIntClass() { "Test.java", // "class Test {", " void f() {", - " Integer i = new Integer(3);", + " Integer i = Integer.valueOf(3);", " int y = i;", " }", "}") @@ -99,7 +99,7 @@ public void replaceRoundMethodLongClass() { "Test.java", // "class Test {", " void f() {", - " Long l = new Long(\"3\");", + " Long l = Long.valueOf(\"3\");", " int y = Math.round(l);", " }", "}") @@ -108,7 +108,7 @@ public void replaceRoundMethodLongClass() { "import com.google.common.primitives.Ints;", "class Test {", " void f() {", - " Long l = new Long(\"3\");", + " Long l = Long.valueOf(\"3\");", " int y = Ints.saturatedCast(l);", " }", "}") @@ -122,7 +122,7 @@ public void roundingFloatNegative() { "Test.java", // "class Test {", " void f() {", - " Float f = new Float(\"3\");", + " Float f = Float.valueOf(\"3\");", " int y = Math.round(f);", " }", "}") @@ -137,7 +137,7 @@ public void roundingDoubleNegative() { "Test.java", // "class Test {", " void f() {", - " Double d = new Double(\"3\");", + " Double d = Double.valueOf(\"3\");", " Long y = Math.round(d);", " }", "}") diff --git a/core/src/test/java/com/google/errorprone/bugpatterns/ObjectsHashCodePrimitiveTest.java b/core/src/test/java/com/google/errorprone/bugpatterns/ObjectsHashCodePrimitiveTest.java index 3f088a02c34..d25d97e9285 100644 --- a/core/src/test/java/com/google/errorprone/bugpatterns/ObjectsHashCodePrimitiveTest.java +++ b/core/src/test/java/com/google/errorprone/bugpatterns/ObjectsHashCodePrimitiveTest.java @@ -289,7 +289,7 @@ public void hashCodeBoxedPrimitiveNegative() { "Test.java", // "import java.util.Objects;", "class Test {", - " Integer x = new Integer(3);", + " Integer x = Integer.valueOf(3);", " void f() {", " int y = Objects.hashCode(x);", " }", @@ -305,7 +305,7 @@ public void hashCodeOtherMethodNegative() { "Test.java", // "import java.util.Objects;", "class Test {", - " Integer x = new Integer(3);", + " Integer x = Integer.valueOf(3);", " void f() {", " int y = x.hashCode();", " }", diff --git a/core/src/test/java/com/google/errorprone/bugpatterns/UnusedVariableTest.java b/core/src/test/java/com/google/errorprone/bugpatterns/UnusedVariableTest.java index 94f1ccac7c9..4b2f5c42aa5 100644 --- a/core/src/test/java/com/google/errorprone/bugpatterns/UnusedVariableTest.java +++ b/core/src/test/java/com/google/errorprone/bugpatterns/UnusedVariableTest.java @@ -219,7 +219,7 @@ public void unusedLocalVar() { " notUsedLocal = this.calculate()", " + 1 ;", " notUsedLocal--;", - " notUsedLocal += new Integer(1);", + " notUsedLocal += Integer.valueOf(1);", " System.out.println(usedLocal);", " }", " System.out.println(usedLocal);", diff --git a/core/src/test/java/com/google/errorprone/bugpatterns/formatstring/FormatStringAnnotationCheckerTest.java b/core/src/test/java/com/google/errorprone/bugpatterns/formatstring/FormatStringAnnotationCheckerTest.java index b598401ccff..43a2c55d452 100644 --- a/core/src/test/java/com/google/errorprone/bugpatterns/formatstring/FormatStringAnnotationCheckerTest.java +++ b/core/src/test/java/com/google/errorprone/bugpatterns/formatstring/FormatStringAnnotationCheckerTest.java @@ -113,7 +113,7 @@ public void testMatches_succeedsForCompileTimeConstantFormatString() { " @FormatMethod public static void log(@FormatString String s, Object... args) {}", " public static void callLog() {", " final String formatString = \"%d\";", - " log(formatString, new Integer(0));", + " log(formatString, Integer.valueOf(0));", " }", "}") .doTest(); diff --git a/core/src/test/java/com/google/errorprone/dataflow/nullnesspropagation/testdata/NullnessPropagationTransferCases2.java b/core/src/test/java/com/google/errorprone/dataflow/nullnesspropagation/testdata/NullnessPropagationTransferCases2.java index 231131ede5b..292bcd00a84 100644 --- a/core/src/test/java/com/google/errorprone/dataflow/nullnesspropagation/testdata/NullnessPropagationTransferCases2.java +++ b/core/src/test/java/com/google/errorprone/dataflow/nullnesspropagation/testdata/NullnessPropagationTransferCases2.java @@ -50,7 +50,7 @@ static String staticReturnNullable() { static final String CONSTANT_DERIVED_STRING = CONSTANT_DERIVED_BOOLEAN ? CONSTANT_STRING : ""; static final MyClass CONSTANT_OTHER_CLASS = new MyClass(); static final Integer[] CONSTANT_OBJECT_ARRAY = new Integer[7]; - static final Integer[] CONSTANT_ARRAY_INITIALIZER = {new Integer(5)}; + static final Integer[] CONSTANT_ARRAY_INITIALIZER = {Integer.valueOf(5)}; static final Object CONSTANT_NO_INITIALIZER; static { diff --git a/core/src/test/java/com/google/errorprone/matchers/method/MethodInvocationMatcherTest.java b/core/src/test/java/com/google/errorprone/matchers/method/MethodInvocationMatcherTest.java index 2dbd3b0b582..8df1aed18ec 100644 --- a/core/src/test/java/com/google/errorprone/matchers/method/MethodInvocationMatcherTest.java +++ b/core/src/test/java/com/google/errorprone/matchers/method/MethodInvocationMatcherTest.java @@ -84,7 +84,7 @@ public void invocationMatchers() { " // BUG: Diagnostic contains: ", " String s = \"5\".toString();", " // BUG: Diagnostic contains: ", - " int result = new Integer(5).compareTo(6);", + " int result = Integer.valueOf(5).compareTo(6);", " // BUG: Diagnostic contains: ", " return String.valueOf(5);", " }", diff --git a/docs/bugpattern/MissingTestCall.md b/docs/bugpattern/MissingTestCall.md index 216fade428f..aa43189c673 100644 --- a/docs/bugpattern/MissingTestCall.md +++ b/docs/bugpattern/MissingTestCall.md @@ -7,7 +7,7 @@ of any use. new EqualsTester() .addEqualityGroup("hello", new String("hello")) .addEqualityGroup("world", new String("world")) - .addEqualityGroup(2, new Integer(2)); + .addEqualityGroup(2, Integer.valueOf(2)); // Oops: forgot to call `testEquals()` } ```