diff --git a/pom.xml b/pom.xml
index 74b813ee9..48c117b0d 100644
--- a/pom.xml
+++ b/pom.xml
@@ -981,8 +981,8 @@
**/GeneratedJavaLexer.class
**/JavadocParser.class
-
- **/Input*
+
+ **/checks/annotation/InputAnnotationLocation4*
diff --git a/src/it/resources/com/google/checkstyle/test/chapter4formatting/rule412nonemptyblocks/InputRightCurlyDoWhile.java b/src/it/resources/com/google/checkstyle/test/chapter4formatting/rule412nonemptyblocks/InputRightCurlyDoWhile.java
index abca4a186..e2847dbe1 100644
--- a/src/it/resources/com/google/checkstyle/test/chapter4formatting/rule412nonemptyblocks/InputRightCurlyDoWhile.java
+++ b/src/it/resources/com/google/checkstyle/test/chapter4formatting/rule412nonemptyblocks/InputRightCurlyDoWhile.java
@@ -16,7 +16,7 @@ public class InputRightCurlyDoWhile {
public void foo2() {
int i = 1;
while (i < 5) {
- System.out.print(i + " ");
+ String.CASE_INSENSITIVE_ORDER.equals(i + " ");
i++;
}
}
@@ -25,36 +25,36 @@ public class InputRightCurlyDoWhile {
int i = 1;
do {
i++;
- System.out.print(i + " ");
+ String.CASE_INSENSITIVE_ORDER.equals(i + " ");
} while (i < 5);
}
public void foo4() {
int prog, user;
prog = (int)(Math.random() * 10) + 1;
- Scanner input = new Scanner(System.in);
+ Scanner input = new Scanner(System.in, "utf-8");
if( input.hasNextInt() ) {
do {
user = input.nextInt();
if(user == prog) {
- System.out.println("Good!");
+ String.CASE_INSENSITIVE_ORDER.equals("Good!");
} else {
if (user > 0 && user <= 10) {
- System.out.print("Bad! ");
+ String.CASE_INSENSITIVE_ORDER.equals("Bad! ");
if( prog < user ) {
- System.out.println("My number is less than yours.");
+ String.CASE_INSENSITIVE_ORDER.equals("My number is less than yours.");
} else {
- System.out.println("My number is greater than yours.");
+ String.CASE_INSENSITIVE_ORDER.equals("My number is greater than yours.");
}
} else {
- System.out.println("Error!");
+ String.CASE_INSENSITIVE_ORDER.equals("Error!");
}
}
} while( user != prog );
} else {
- System.out.println("Error!");
+ String.CASE_INSENSITIVE_ORDER.equals("Error!");
}
- System.out.println("Goodbye!");
+ String.CASE_INSENSITIVE_ORDER.equals("Goodbye!");
}
public void foo5() {
diff --git a/src/it/resources/com/google/checkstyle/test/chapter4formatting/rule4822variabledistance/InputVariableDeclarationUsageDistanceCheck.java b/src/it/resources/com/google/checkstyle/test/chapter4formatting/rule4822variabledistance/InputVariableDeclarationUsageDistanceCheck.java
index dbe608891..d68487bbe 100644
--- a/src/it/resources/com/google/checkstyle/test/chapter4formatting/rule4822variabledistance/InputVariableDeclarationUsageDistanceCheck.java
+++ b/src/it/resources/com/google/checkstyle/test/chapter4formatting/rule4822variabledistance/InputVariableDeclarationUsageDistanceCheck.java
@@ -408,7 +408,7 @@ public class InputVariableDeclarationUsageDistanceCheck {
{
int mm = Integer.parseInt("2");
long timeNow = 0;
- Calendar cal = Calendar.getInstance();
+ Calendar cal = Calendar.getInstance(TimeZone.getDefault(), Locale.getDefault());
cal.setTimeInMillis(timeNow);
cal.set(Calendar.SECOND, 0);
cal.set(Calendar.MILLISECOND, 0);
@@ -417,7 +417,7 @@ public class InputVariableDeclarationUsageDistanceCheck {
}
public void testIssue32_3(MyObject[] objects) {
- Calendar cal = Calendar.getInstance();
+ Calendar cal = Calendar.getInstance(TimeZone.getDefault(), Locale.getDefault());
for(int i=0; i {
- System.out.println("Hello world one!");
+ String.valueOf("Hello world one!");
};
- static Runnable r2 = () -> System.out.println("Hello world two!");
+ static Runnable r2 = () -> String.valueOf("Hello world two!");
- static Runnable r3 = () -> {System.out.println("Hello world two!");};
+ static Runnable r3 = () -> {String.valueOf("Hello world two!");};
static Runnable r4 = () ->
{
- System.out.println("Hello world one!");
+ String.valueOf("Hello world one!");
};
}
diff --git a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/blocks/InputLeftCurlyOther.java b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/blocks/InputLeftCurlyOther.java
index 5a29cab0e..6363e26cf 100644
--- a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/blocks/InputLeftCurlyOther.java
+++ b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/blocks/InputLeftCurlyOther.java
@@ -90,11 +90,11 @@ class InputLeftCurlyOther
boolean flag = true;
if (flag) {
System.identityHashCode("heh");
- flag = !flag; } System.err.
- println("Xe-xe");
+ flag = !flag; } String.CASE_INSENSITIVE_ORDER.
+ equals("Xe-xe");
// it is ok to have rcurly on the same line as previous
// statement if lcurly on the same line.
- if (flag) { System.err.println("it is ok."); }
+ if (flag) { String.CASE_INSENSITIVE_ORDER.equals("it is ok."); }
}
}
diff --git a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/blocks/InputRightCurlyAloneOrSingleline.java b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/blocks/InputRightCurlyAloneOrSingleline.java
index e982e59cd..3b12eb0c4 100644
--- a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/blocks/InputRightCurlyAloneOrSingleline.java
+++ b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/blocks/InputRightCurlyAloneOrSingleline.java
@@ -2,7 +2,7 @@ package com.puppycrawl.tools.checkstyle.checks.blocks;
public class InputRightCurlyAloneOrSingleline {
- public boolean equals(Object other) { boolean flag = true; return flag; }
+ public boolean equals(Object other) { boolean flag = true; return flag; }
public int hashCode()
{
@@ -173,7 +173,7 @@ public class InputRightCurlyAloneOrSingleline {
boolean flag = true;
if (flag) {
System.identityHashCode("heh");
- flag = !flag; } System.err. //violation
- println("Xe-xe");
+ flag = !flag; } String.CASE_INSENSITIVE_ORDER. //violation
+ equals("Xe-xe");
}
}
diff --git a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/blocks/InputRightCurlyAnnotations.java b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/blocks/InputRightCurlyAnnotations.java
index 03ccc4b2b..07fb6b358 100644
--- a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/blocks/InputRightCurlyAnnotations.java
+++ b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/blocks/InputRightCurlyAnnotations.java
@@ -213,7 +213,7 @@ class InputRightCurlyAnnotations
boolean flag = true;
if (flag) {
System.identityHashCode("heh");
- flag = !flag; } System.err. //violation
- println("Xe-xe");
+ flag = !flag; } String.CASE_INSENSITIVE_ORDER. //violation
+ equals("Xe-xe");
}
}
diff --git a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/blocks/InputRightCurlyDoWhile.java b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/blocks/InputRightCurlyDoWhile.java
index b9019a775..a4616bfea 100644
--- a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/blocks/InputRightCurlyDoWhile.java
+++ b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/blocks/InputRightCurlyDoWhile.java
@@ -16,7 +16,7 @@ public class InputRightCurlyDoWhile {
public void foo2() {
int i = 1;
while (i < 5) {
- System.out.print(i + " ");
+ String.CASE_INSENSITIVE_ORDER.equals(i + " ");
i++;
}
}
@@ -25,36 +25,36 @@ public class InputRightCurlyDoWhile {
int i = 1;
do {
i++;
- System.out.print(i + " ");
+ String.CASE_INSENSITIVE_ORDER.equals(i + " ");
} while (i < 5);
}
public void foo4() {
int prog, user;
prog = (int)(Math.random() * 10) + 1;
- Scanner input = new Scanner(System.in);
+ Scanner input = new Scanner(System.in, "utf-8");
if( input.hasNextInt() ) {
do {
user = input.nextInt();
if(user == prog) {
- System.out.println("Good!");
+ String.CASE_INSENSITIVE_ORDER.equals("Good!");
} else {
if (user > 0 && user <= 10) {
- System.out.print("Bad! ");
+ String.CASE_INSENSITIVE_ORDER.equals("Bad! ");
if( prog < user ) {
- System.out.println("My number is less than yours.");
+ String.CASE_INSENSITIVE_ORDER.equals("My number is less than yours.");
} else {
- System.out.println("My number is greater than yours.");
+ String.CASE_INSENSITIVE_ORDER.equals("My number is greater than yours.");
}
} else {
- System.out.println("Error!");
+ String.CASE_INSENSITIVE_ORDER.equals("Error!");
}
}
} while( user != prog );
} else {
- System.out.println("Error!");
+ String.CASE_INSENSITIVE_ORDER.equals("Error!");
}
- System.out.println("Goodbye!");
+ String.CASE_INSENSITIVE_ORDER.equals("Goodbye!");
}
public void foo5() {
diff --git a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/blocks/InputRightCurlyLineBreakBefore.java b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/blocks/InputRightCurlyLineBreakBefore.java
index 15e953162..64f4ac119 100644
--- a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/blocks/InputRightCurlyLineBreakBefore.java
+++ b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/blocks/InputRightCurlyLineBreakBefore.java
@@ -49,7 +49,7 @@ class InputRightCurlyLineBreakBefore
void method2()
{
boolean flag = false;
- if (flag) { System.err.println("foo"); }
+ if (flag) { String.valueOf("foo"); }
}
}
diff --git a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/blocks/InputSingleLineLambda.java b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/blocks/InputSingleLineLambda.java
index d21550146..2dd67f7b9 100644
--- a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/blocks/InputSingleLineLambda.java
+++ b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/blocks/InputSingleLineLambda.java
@@ -2,9 +2,9 @@
package com.puppycrawl.tools.checkstyle.checks.blocks;
public class InputSingleLineLambda {
- static Runnable r1 = ()->System.out.println("Hello world one!");
- static Runnable r2 = () -> System.out.println("Hello world two!");
- static Runnable r3 = () ->
- System.out.println("Hello world two!");
- static Runnable r4 = () -> {System.out.println("Hello world two!");};
+ static Runnable r1 = ()->String.CASE_INSENSITIVE_ORDER.equals("Hello world one!");
+ static Runnable r2 = () -> String.CASE_INSENSITIVE_ORDER.equals("Hello world two!");
+ static Runnable r3 = () ->
+ String.CASE_INSENSITIVE_ORDER.equals("Hello world two!");
+ static Runnable r4 = () -> {String.CASE_INSENSITIVE_ORDER.equals("Hello world two!");};
}
\ No newline at end of file
diff --git a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/coding/InputFallThrough.java b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/coding/InputFallThrough.java
index bc302a047..246f2310f 100644
--- a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/coding/InputFallThrough.java
+++ b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/coding/InputFallThrough.java
@@ -57,7 +57,7 @@ public class InputFallThrough
} while(true);
case 16:
for (int j1 = 0; j1 < 10; j1++) {
- System.err.println("something");
+ String.valueOf("something");
return;
}
case 17:
@@ -190,7 +190,7 @@ public class InputFallThrough
} while(true);
case 16:
for (int j1 = 0; j1 < 10; j1++) {
- System.err.println("something");
+ String.valueOf("something");
return;
}
case 17:
diff --git a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/coding/InputFallThrough2.java b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/coding/InputFallThrough2.java
index 2c8c9e92a..33c380347 100644
--- a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/coding/InputFallThrough2.java
+++ b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/coding/InputFallThrough2.java
@@ -69,16 +69,16 @@ public class InputFallThrough2 {
System.identityHashCode("0xCAFED00D");
}
else {
- System.out.printf("0x4B1D");
+ String.CASE_INSENSITIVE_ORDER.equals("0x4B1D");
}
break;
case 10:
int var3 = 0xDEADBEEF;
switch (var3) {
case 0xCAFEBABE:
- System.out.printf("0x1CEB00DA");
+ String.CASE_INSENSITIVE_ORDER.equals("0x1CEB00DA");
default:
- System.out.printf("");
+ String.CASE_INSENSITIVE_ORDER.equals("");
}
if(true) {
break;
diff --git a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/coding/InputFinalLocalVariableAssignedMultipleTimes.java b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/coding/InputFinalLocalVariableAssignedMultipleTimes.java
index fb9678189..31f4c1beb 100644
--- a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/coding/InputFinalLocalVariableAssignedMultipleTimes.java
+++ b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/coding/InputFinalLocalVariableAssignedMultipleTimes.java
@@ -1,7 +1,7 @@
package com.puppycrawl.tools.checkstyle.checks.coding;
import java.util.HashMap;
-import java.util.SortedMap;
+import java.util.Locale;
import com.google.common.collect.Maps;
@@ -217,7 +217,7 @@ public class InputFinalLocalVariableAssignedMultipleTimes {
isSyntheticMethod = m.equals("");
className = this.getClass().getName();
kind = 2;
- if ("".equals(m.toLowerCase())) {
+ if ("".equals(m.toLowerCase(Locale.getDefault()))) {
final int i = className.lastIndexOf('$');
if (i + 1 < className.length() && Character.isDigit(className.charAt(i + 1))) {
isParameterToInitMethodofAnonymousInnerClass = true;
@@ -228,7 +228,7 @@ public class InputFinalLocalVariableAssignedMultipleTimes {
throw new IllegalStateException("impossible");
}
- if (!m.equals("") && !"".equals(m.toLowerCase())) {
+ if (!m.equals("") && !"".equals(m.toLowerCase(Locale.getDefault()))) {
final String c = "className";
// get inherited annotation
String inheritedAnnotations = new String();
@@ -246,7 +246,7 @@ public class InputFinalLocalVariableAssignedMultipleTimes {
}
}
if (n == null) {
- System.out.println("# of inherited annotations : " + inheritedAnnotations.length());
+ String.CASE_INSENSITIVE_ORDER.equals("# of inherited annotations : " + inheritedAnnotations.length());
}
if (!inheritedAnnotations.isEmpty()) {
if (inheritedAnnotations.length() == 1) {
@@ -269,7 +269,7 @@ public class InputFinalLocalVariableAssignedMultipleTimes {
return null;
}
if (inheritedAnnotations.equals("")) {
- System.out.println("looking for default annotations: " + " defines " + m);
+ String.CASE_INSENSITIVE_ORDER.equals("looking for default annotations: " + " defines " + m);
}
} // if not static
} // associated with method
@@ -312,7 +312,7 @@ public class InputFinalLocalVariableAssignedMultipleTimes {
// look for default annotation
n = new String(className);
if (n == null) {
- System.out.println("Default annotation for " + kind + " is " + n);
+ String.CASE_INSENSITIVE_ORDER.equals("Default annotation for " + kind + " is " + n);
}
if (n != null) {
return n;
@@ -320,7 +320,7 @@ public class InputFinalLocalVariableAssignedMultipleTimes {
n = new String(className);
if (n == null) {
- System.out.println("Default annotation for any is " + n);
+ String.CASE_INSENSITIVE_ORDER.equals("Default annotation for any is " + n);
}
if (n != null) {
return n;
@@ -330,7 +330,7 @@ public class InputFinalLocalVariableAssignedMultipleTimes {
className = className.substring(0, p + 1) + "package-info";
n = new String(className);
if (n == null) {
- System.out.println("Default annotation for " + kind + " is " + n);
+ String.CASE_INSENSITIVE_ORDER.equals("Default annotation for " + kind + " is " + n);
}
if (n != null) {
return n;
@@ -338,7 +338,7 @@ public class InputFinalLocalVariableAssignedMultipleTimes {
n = new String(className);
if (n == null) {
- System.out.println("Default annotation for any is " + n);
+ String.CASE_INSENSITIVE_ORDER.equals("Default annotation for any is " + n);
}
if (n != null) {
return n;
@@ -347,7 +347,7 @@ public class InputFinalLocalVariableAssignedMultipleTimes {
return n;
}
catch (Exception e) {
- System.out.println(e);
+ String.CASE_INSENSITIVE_ORDER.equals(e);
;
return null;
}
@@ -386,7 +386,7 @@ public class InputFinalLocalVariableAssignedMultipleTimes {
// Taken from Guava
public static int foo13(int p, int q, int mode) {
- System.out.println(mode);
+ String.CASE_INSENSITIVE_ORDER.equals(mode);
;
if (q == 0) {
throw new ArithmeticException("/ by zero"); // for GWT
@@ -409,7 +409,7 @@ public class InputFinalLocalVariableAssignedMultipleTimes {
boolean increment; // violation
switch (mode) {
case 1:
- System.out.println(rem == 0);
+ String.CASE_INSENSITIVE_ORDER.equals(rem == 0);
// fall through
case 2:
increment = false;
diff --git a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/coding/InputHiddenFieldLambdas.java b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/coding/InputHiddenFieldLambdas.java
index 0fc0cc093..8492931ad 100644
--- a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/coding/InputHiddenFieldLambdas.java
+++ b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/coding/InputHiddenFieldLambdas.java
@@ -16,7 +16,7 @@ public class InputHiddenFieldLambdas {
List numbers = Arrays.asList(1, 2, 3, 4, 5, 6);
Integer value = new Integer(1);
{
- numbers.forEach((Integer value) -> System.out.println(value)); // 1 violation
+ numbers.forEach((Integer value) -> String.valueOf(value)); // 1 violation
}
/**
@@ -27,7 +27,7 @@ public class InputHiddenFieldLambdas {
static List firstNames = Arrays.asList("Andrei", "Michal", "Roman", "Vladislav");
String name = new String();
static {
- firstNames.forEach((String name) -> System.out.println(name));
+ firstNames.forEach((String name) -> String.valueOf(name));
}
/**
@@ -38,7 +38,7 @@ public class InputHiddenFieldLambdas {
static List carBrands = Arrays.asList("BMW", "Mazda", "Volkswagen");
String brand = new String();
static {
- carBrands.forEach(brand -> System.out.println(brand));
+ carBrands.forEach(brand -> String.valueOf(brand));
}
/**
@@ -48,7 +48,7 @@ public class InputHiddenFieldLambdas {
static List languageCodes = Arrays.asList("de", "ja", "fr", "pt");
static String languageCode = new String();
{
- languageCodes.forEach(languageCode -> System.out.println(languageCode)); // 1 violation
+ languageCodes.forEach(languageCode -> String.valueOf(languageCode)); // 1 violation
}
/**
@@ -98,7 +98,7 @@ public class InputHiddenFieldLambdas {
static String note = new String();
private void foo4() {
List acceptableNotes = Arrays.asList("C", "D", "E", "F", "G", "A", "B");
- acceptableNotes.forEach(note -> System.out.println(note)); // 1 violation
+ acceptableNotes.forEach(note -> String.valueOf(note)); // 1 violation
}
/**
@@ -109,7 +109,7 @@ public class InputHiddenFieldLambdas {
String letter = new String("a");
private static void foo5() {
List acceptableAlphabet = Arrays.asList("a", "b", "c");
- acceptableAlphabet.forEach(letter -> System.out.println(letter));
+ acceptableAlphabet.forEach(letter -> String.valueOf(letter));
}
@FunctionalInterface
@@ -126,7 +126,7 @@ public class InputHiddenFieldLambdas {
Function multiAdder = (String stringValue, Integer intValue) -> { // 2 violations
return Integer.parseInt(stringValue) + intValue;
};
- System.out.println(multiAdder.apply ("22.4", 2));
+ String.valueOf(multiAdder.apply ("22.4", 2));
}
/**
@@ -137,7 +137,7 @@ public class InputHiddenFieldLambdas {
Function adder = (Integer integerValue, Double doubleValue) -> { // 1 violation
return integerValue + doubleValue;
};
- System.out.println(adder.apply(2, 2.2));
+ String.valueOf(adder.apply(2, 2.2));
}
/**
@@ -149,7 +149,7 @@ public class InputHiddenFieldLambdas {
Function stringConcat = (firstString, secondString) -> { // 2 violations
return firstString + secondString;
};
- System.out.println(stringConcat.apply("A", "B"));
+ String.valueOf(stringConcat.apply("A", "B"));
}
@FunctionalInterface
@@ -205,8 +205,8 @@ public class InputHiddenFieldLambdas {
{
FunctionWithComplexGenerics, Map> someWierdFunc =
(List justSomeList, Map justSomeMap) -> { // 2 violations
- System.out.println(justSomeList);
- System.out.println(justSomeMap);
+ String.valueOf(justSomeList);
+ String.valueOf(justSomeMap);
return new HashMap<>();
};
}
diff --git a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/coding/InputRequireThis.java b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/coding/InputRequireThis.java
index 0c6d45597..b7f9a3950 100644
--- a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/coding/InputRequireThis.java
+++ b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/coding/InputRequireThis.java
@@ -19,7 +19,7 @@ public class InputRequireThis {
this.method1();
}
catch (RuntimeException e) {
- e.printStackTrace();
+ e.toString();
}
this.i--;
diff --git a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/coding/InputRequireThisStatic.java b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/coding/InputRequireThisStatic.java
index d6c80e670..227534683 100644
--- a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/coding/InputRequireThisStatic.java
+++ b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/coding/InputRequireThisStatic.java
@@ -2,7 +2,7 @@ package com.puppycrawl.tools.checkstyle.checks.coding;
import java.io.BufferedReader;
import java.io.FileNotFoundException;
-import java.io.FileReader;
+import java.io.InputStreamReader;
import java.io.IOException;
public final class InputRequireThisStatic {
@@ -14,7 +14,7 @@ public final class InputRequireThisStatic {
public BufferedReader instanceField2;
static {
- try (BufferedReader instanceField2 = new BufferedReader(new FileReader(""))) {
+ try (BufferedReader instanceField2 = new BufferedReader(new InputStreamReader(null, "utf-8"))) {
instanceField2.readLine();
}
catch (FileNotFoundException e) {
@@ -42,7 +42,7 @@ public final class InputRequireThisStatic {
}
static void test2() {
- try (BufferedReader instanceField2 = new BufferedReader(new FileReader(""))) {
+ try (BufferedReader instanceField2 = new BufferedReader(new InputStreamReader(null, "utf-8"))) {
instanceField2.readLine();
}
catch (IOException e) {
diff --git a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/coding/InputStringLiteralEquality.java b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/coding/InputStringLiteralEquality.java
index 8a8f13af7..581474f7d 100644
--- a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/coding/InputStringLiteralEquality.java
+++ b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/coding/InputStringLiteralEquality.java
@@ -39,7 +39,7 @@ public class InputStringLiteralEquality
// what some of us get paid for :-)
}
- if ("Rick".toUpperCase() == "Rick".toLowerCase())
+ if ("Rick".toUpperCase(java.util.Locale.getDefault()) == "Rick".toLowerCase(java.util.Locale.getDefault()))
{
// completly dynamic, don't flag
}
diff --git a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/coding/InputVariableDeclarationUsageDistance.java b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/coding/InputVariableDeclarationUsageDistance.java
index 39c8ff6d8..8f6ab3e22 100644
--- a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/coding/InputVariableDeclarationUsageDistance.java
+++ b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/coding/InputVariableDeclarationUsageDistance.java
@@ -408,7 +408,7 @@ public class InputVariableDeclarationUsageDistance {
{
int mm = Integer.parseInt("2");
long timeNow = 0;
- Calendar cal = Calendar.getInstance();
+ Calendar cal = Calendar.getInstance(TimeZone.getDefault(), Locale.getDefault());
cal.setTimeInMillis(timeNow);
cal.set(Calendar.SECOND, 0);
cal.set(Calendar.MILLISECOND, 0);
@@ -417,7 +417,7 @@ public class InputVariableDeclarationUsageDistance {
}
public void testIssue32_3(MyObject[] objects) {
- Calendar cal = Calendar.getInstance();
+ Calendar cal = Calendar.getInstance(TimeZone.getDefault(), Locale.getDefault());
for(int i=0; i x.run(); //indent:4 exp:4
- Printer r5 = s -> System.out.print(s); //indent:4 exp:4
+ Printer r5 = s -> String.CASE_INSENSITIVE_ORDER.equals(s); //indent:4 exp:4
- Printer r6 = s -> System.out //indent:4 exp:4
- .print(s); //indent:8 exp:8
+ Printer r6 = s -> String.CASE_INSENSITIVE_ORDER //indent:4 exp:4
+ .equals(s); //indent:8 exp:8
Runnable r7 = () //indent:4 exp:4
-> //indent:8 exp:8
@@ -80,11 +80,11 @@ public class InputFinalInDefaultMethods { //indent:0 exp:0
() -> x.run(); //indent:8 exp:8
Printer r51 = //indent:4 exp:4
- s -> System.out.print(s); //indent:8 exp:8
+ s -> String.CASE_INSENSITIVE_ORDER.equals(s); //indent:8 exp:8
Printer r61 = //indent:4 exp:4
- s -> System.out //indent:8 exp:8
- .print(s); //indent:12 exp:12
+ s -> String.CASE_INSENSITIVE_ORDER //indent:8 exp:8
+ .equals(s); //indent:12 exp:12
Object o1 = new Thread( //indent:4 exp:4
() -> { //indent:8 exp:8
@@ -97,16 +97,16 @@ public class InputFinalInDefaultMethods { //indent:0 exp:0
SomeInterface i1 = (LongTypeName //indent:4 exp:4
arg) -> { //indent:8 exp:8
- System.out.print(arg.toString()); //indent:6 exp:6
+ String.CASE_INSENSITIVE_ORDER.equals(arg.toString()); //indent:6 exp:6
}; //indent:4 exp:4
Printer[] manyRunnable = new Printer[]{ //indent:4 exp:4
- s -> System.out.print(s), //indent:8 exp:6,8
- s -> { System.out.print(s); }, //indent:8 exp:6,8
- s -> System.out //indent:8 exp:6,8
- .print(s), //indent:12 exp:12
+ s -> String.CASE_INSENSITIVE_ORDER.equals(s), //indent:8 exp:6,8
+ s -> { String.CASE_INSENSITIVE_ORDER.equals(s); }, //indent:8 exp:6,8
+ s -> String.CASE_INSENSITIVE_ORDER //indent:8 exp:6,8
+ .equals(s), //indent:12 exp:12
s -> { //indent:8 exp:6,8
- System.out.print(s); //indent:10 exp:10
+ String.CASE_INSENSITIVE_ORDER.equals(s); //indent:10 exp:10
}, //indent:8 exp:8
}; //indent:4 exp:4
} //indent:2 exp:2
@@ -143,11 +143,11 @@ public class InputFinalInDefaultMethods { //indent:0 exp:0
public void f() { //indent:2 exp:2
Stream.of("d2", "a2", "b1", "b3", "c") //indent:4 exp:4
.map(s -> { //indent:8 exp:8
- System.out.println("map: " + s); //indent:10 exp:10
- return s.toUpperCase(); //indent:10 exp:10
+ String.CASE_INSENSITIVE_ORDER.equals("map: " + s); //indent:10 exp:10
+ return s.toUpperCase(java.util.Locale.getDefault()); //indent:10 exp:10
}) //indent:8 exp:8
.anyMatch(s -> { //indent:8 exp:8
- System.out.println("anyMatch: " + s); //indent:10 exp:10
+ String.CASE_INSENSITIVE_ORDER.equals("anyMatch: " + s); //indent:10 exp:10
return s.startsWith("A"); //indent:10 exp:10
}); //indent:8 exp:8
@@ -158,12 +158,12 @@ public class InputFinalInDefaultMethods { //indent:0 exp:0
.collect(Collectors.groupingBy(p -> p.age)); //indent:8 exp:8
personsByAge //indent:4 exp:4
- .forEach((age, p) -> System.out.format("age %s: %s\n", age, p)); //indent:8 exp:8
+ .forEach((age, p) -> String.CASE_INSENSITIVE_ORDER.equals("age %s: %s\n")); //indent:8 exp:8
Collector personNameCollector = //indent:4 exp:4
Collector.of( //indent:8 exp:8
() -> new StringJoiner(" | "), //indent:12 exp:12
- (j, p) -> j.add(p.name.toUpperCase()), //indent:12 exp:12
+ (j, p) -> j.add(p.name.toUpperCase(java.util.Locale.getDefault())), //indent:12 exp:12
(j1, j2) -> j1.merge(j2), //indent:12 exp:12
StringJoiner::toString); //indent:12 exp:12
@@ -176,15 +176,15 @@ public class InputFinalInDefaultMethods { //indent:0 exp:0
Stream.of("d2", "a2", "b1", "b3", "c") //indent:4 exp:4
.filter(s -> { //indent:8 exp:8
- System.out.println("filter: " + s); //indent:9 exp:10 warn
+ String.CASE_INSENSITIVE_ORDER.equals("filter: " + s); //indent:9 exp:10 warn
return s.startsWith("a"); //indent:11 exp:10 warn
}) //indent:8 exp:8
.map(s -> { //indent:8 exp:8
- System.out.println("map: " + s); //indent:10 exp:10
- return s.toUpperCase(); //indent:10 exp:10
+ String.CASE_INSENSITIVE_ORDER.equals("map: " + s); //indent:10 exp:10
+ return s.toUpperCase(java.util.Locale.getDefault()); //indent:10 exp:10
}) //indent:7 exp:8 warn
.forEach(s -> //indent:8 exp:8
- System.out.println("forEach: " + s)); //indent:12 exp:12
+ String.CASE_INSENSITIVE_ORDER.equals("forEach: " + s)); //indent:12 exp:12
IntStream.range(1, 4) //indent:4 exp:4
.mapToObj(i -> new Foo("Foo" + i)) //indent:8 exp:8
@@ -192,7 +192,7 @@ public class InputFinalInDefaultMethods { //indent:0 exp:0
.mapToObj(i -> new Bar("Bar" + i + " <- " + f.name)) //indent:12 exp:12
.forEach(f.bars::add)) //indent:12 exp:12
.flatMap(f -> f.bars.stream()) //indent:8 exp:8
- .forEach(b -> System.out.println(b.name)); //indent:8 exp:8
+ .forEach(b -> String.CASE_INSENSITIVE_ORDER.equals(b.name)); //indent:8 exp:8
IntStream.range(1, 4) //indent:4 exp:4
.mapToObj(i -> new Foo("Foo" + i)) //indent:8 exp:8
@@ -200,7 +200,7 @@ public class InputFinalInDefaultMethods { //indent:0 exp:0
.mapToObj(i -> new Bar("Bar" + i + " <- " + f.name)) //indent:12 exp:12
.forEach(f.bars::add)) //indent:12 exp:12
.flatMap(f -> f.bars.stream()) //indent:8 exp:8
- .forEach(b -> System.out.println(b.name)); //indent:8 exp:8
+ .forEach(b -> String.CASE_INSENSITIVE_ORDER.equals(b.name)); //indent:8 exp:8
} //indent:2 exp:2
Runnable r2r(Runnable x) { //indent:2 exp:2
diff --git a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/indentation/InputInvalidLabelIndent.java b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/indentation/InputInvalidLabelIndent.java
index 7be34f839..c05261f52 100644
--- a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/indentation/InputInvalidLabelIndent.java
+++ b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/indentation/InputInvalidLabelIndent.java
@@ -38,9 +38,9 @@ public class InputInvalidLabelIndent { //indent:0 exp:0
label4: //indent:4 exp:4
System.identityHashCode("toplevel"); //indent:6 exp:8,12 warn
label5: //indent:4 exp:4
- System //indent:6 exp:8,12 warn
- .out. //indent:12 exp:>=10
- println("toplevel"); //indent:16 exp:>=16
+ String //indent:6 exp:8,12 warn
+ .CASE_INSENSITIVE_ORDER. //indent:12 exp:>=10
+ equals("toplevel"); //indent:16 exp:>=16
} //indent:4 exp:4
} //indent:0 exp:0
diff --git a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/indentation/InputInvalidMethodIndent.java b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/indentation/InputInvalidMethodIndent.java
index ec707eb42..ec6ac0f3b 100644
--- a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/indentation/InputInvalidMethodIndent.java
+++ b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/indentation/InputInvalidMethodIndent.java
@@ -154,7 +154,7 @@ public class InputInvalidMethodIndent { //indent:0 exp:0
// 11); //indent:0 exp:0
- System.out.toString() //indent:8 exp:8
+ String.CASE_INSENSITIVE_ORDER.toString() //indent:8 exp:8
.equals("blah"); //indent:6 exp:12 warn
diff --git a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/indentation/InputLambda1.java b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/indentation/InputLambda1.java
index d50a6e609..dede16b7f 100644
--- a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/indentation/InputLambda1.java
+++ b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/indentation/InputLambda1.java
@@ -11,7 +11,7 @@ import java.util.stream.IntStream; //indent:0 exp:0
import java.util.stream.Stream; //indent:0 exp:0
public class InputLambda1 { //indent:0 exp:0
-
+ private static final java.util.logging.Logger LOG = java.util.logging.Logger.getLogger(InputLambda1.class.getName()); //indent:2 exp:2
interface Printer //indent:2 exp:2
{ //indent:2 exp:2
void print(String s); //indent:4 exp:4
@@ -36,10 +36,10 @@ public class InputLambda1 { //indent:0 exp:0
Runnable r4 = () -> x.run(); //indent:4 exp:4
- Printer r5 = s -> System.out.print(s); //indent:4 exp:4
+ Printer r5 = s -> LOG.info(s); //indent:4 exp:4
- Printer r6 = s -> System.out //indent:4 exp:4
- .print(s); //indent:8 exp:8
+ Printer r6 = s -> String.CASE_INSENSITIVE_ORDER //indent:4 exp:4
+ .equals(s); //indent:8 exp:8
Runnable r7 = () //indent:4 exp:4
-> //indent:8 exp:8
@@ -80,11 +80,11 @@ public class InputLambda1 { //indent:0 exp:0
() -> x.run(); //indent:8 exp:8
Printer r51 = //indent:4 exp:4
- s -> System.out.print(s); //indent:8 exp:8
+ s -> LOG.info(s); //indent:8 exp:8
Printer r61 = //indent:4 exp:4
- s -> System.out //indent:8 exp:8
- .print(s); //indent:12 exp:12
+ s -> String.CASE_INSENSITIVE_ORDER //indent:8 exp:8
+ .equals(s); //indent:12 exp:12
Object o1 = new Thread( //indent:4 exp:4
() -> { //indent:8 exp:8
@@ -97,16 +97,16 @@ public class InputLambda1 { //indent:0 exp:0
SomeInterface i1 = (LongTypeName //indent:4 exp:4
arg) -> { //indent:8 exp:8
- System.out.print(arg.toString()); //indent:6 exp:6
+ LOG.info(arg.toString()); //indent:6 exp:6
}; //indent:4 exp:4
Printer[] manyRunnable = new Printer[]{ //indent:4 exp:4
- s -> System.out.print(s), //indent:8 exp:6,8
- s -> { System.out.print(s); }, //indent:8 exp:6,8
- s -> System.out //indent:8 exp:6,8
- .print(s), //indent:12 exp:12
+ s -> LOG.info(s), //indent:8 exp:6,8
+ s -> { LOG.info(s); }, //indent:8 exp:6,8
+ s -> LOG //indent:8 exp:6,8
+ .info(s), //indent:12 exp:12
s -> { //indent:8 exp:6,8
- System.out.print(s); //indent:10 exp:10
+ LOG.info(s); //indent:10 exp:10
}, //indent:8 exp:8
}; //indent:4 exp:4
} //indent:2 exp:2
@@ -143,11 +143,11 @@ public class InputLambda1 { //indent:0 exp:0
public void f() { //indent:2 exp:2
Stream.of("d2", "a2", "b1", "b3", "c") //indent:4 exp:4
.map(s -> { //indent:8 exp:8
- System.out.println("map: " + s); //indent:10 exp:10
- return s.toUpperCase(); //indent:10 exp:10
+ LOG.info("map: " + s); //indent:10 exp:10
+ return s.toUpperCase(java.util.Locale.getDefault()); //indent:10 exp:10
}) //indent:8 exp:8
.anyMatch(s -> { //indent:8 exp:8
- System.out.println("anyMatch: " + s); //indent:10 exp:10
+ LOG.info("anyMatch: " + s); //indent:10 exp:10
return s.startsWith("A"); //indent:10 exp:10
}); //indent:8 exp:8
@@ -158,12 +158,12 @@ public class InputLambda1 { //indent:0 exp:0
.collect(Collectors.groupingBy(p -> p.age)); //indent:8 exp:8
personsByAge //indent:4 exp:4
- .forEach((age, p) -> System.out.format("age %s: %s\n", age, p)); //indent:8 exp:8
+ .forEach((age, p) -> LOG.info("age %s: %s\n")); //indent:8 exp:8
Collector personNameCollector = //indent:4 exp:4
Collector.of( //indent:8 exp:8
() -> new StringJoiner(" | "), //indent:12 exp:12
- (j, p) -> j.add(p.name.toUpperCase()), //indent:12 exp:12
+ (j, p) -> j.add(p.name.toUpperCase(java.util.Locale.getDefault())), //indent:12 exp:12
(j1, j2) -> j1.merge(j2), //indent:12 exp:12
StringJoiner::toString); //indent:12 exp:12
@@ -176,15 +176,15 @@ public class InputLambda1 { //indent:0 exp:0
Stream.of("d2", "a2", "b1", "b3", "c") //indent:4 exp:4
.filter(s -> { //indent:8 exp:8
- System.out.println("filter: " + s); //indent:9 exp:10 warn
+ LOG.info(("filter: " + s)); //indent:9 exp:10 warn
return s.startsWith("a"); //indent:11 exp:10 warn
}) //indent:8 exp:8
.map(s -> { //indent:8 exp:8
- System.out.println("map: " + s); //indent:10 exp:10
- return s.toUpperCase(); //indent:10 exp:10
+ LOG.info("map: " + s); //indent:10 exp:10
+ return s.toUpperCase(java.util.Locale.getDefault()); //indent:10 exp:10
}) //indent:7 exp:8 warn
.forEach(s -> //indent:8 exp:8
- System.out.println("forEach: " + s)); //indent:12 exp:12
+ LOG.info("forEach: " + s)); //indent:12 exp:12
IntStream.range(1, 4) //indent:4 exp:4
.mapToObj(i -> new Foo("Foo" + i)) //indent:8 exp:8
@@ -192,7 +192,7 @@ public class InputLambda1 { //indent:0 exp:0
.mapToObj(i -> new Bar("Bar" + i + " <- " + f.name)) //indent:12 exp:12
.forEach(f.bars::add)) //indent:12 exp:12
.flatMap(f -> f.bars.stream()) //indent:8 exp:8
- .forEach(b -> System.out.println(b.name)); //indent:8 exp:8
+ .forEach(b -> LOG.info(b.name)); //indent:8 exp:8
IntStream.range(1, 4) //indent:4 exp:4
.mapToObj(i -> new Foo("Foo" + i)) //indent:8 exp:8
@@ -200,7 +200,7 @@ public class InputLambda1 { //indent:0 exp:0
.mapToObj(i -> new Bar("Bar" + i + " <- " + f.name)) //indent:12 exp:12
.forEach(f.bars::add)) //indent:12 exp:12
.flatMap(f -> f.bars.stream()) //indent:8 exp:8
- .forEach(b -> System.out.println(b.name)); //indent:8 exp:8
+ .forEach(b -> LOG.info(b.name)); //indent:8 exp:8
} //indent:2 exp:2
Runnable r2r(Runnable x) { //indent:2 exp:2
diff --git a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/indentation/InputValidDotIndent.java b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/indentation/InputValidDotIndent.java
index c1373182b..bb914053a 100644
--- a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/indentation/InputValidDotIndent.java
+++ b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/indentation/InputValidDotIndent.java
@@ -24,19 +24,19 @@ public class InputValidDotIndent { //indent:0 exp:0
System.lineSeparator(); //indent:8 exp:8
- System. //indent:8 exp:8
- out.println(); //indent:12 exp:12
+ String. //indent:8 exp:8
+ CASE_INSENSITIVE_ORDER.reversed(); //indent:12 exp:12
- System.out. //indent:8 exp:8
- println(); //indent:12 exp:12
+ String.CASE_INSENSITIVE_ORDER. //indent:8 exp:8
+ reversed(); //indent:12 exp:12
- System. //indent:8 exp:8
- out. //indent:12 exp:12
- println(); //indent:16 exp:16
+ String. //indent:8 exp:8
+ CASE_INSENSITIVE_ORDER. //indent:12 exp:12
+ reversed(); //indent:16 exp:16
- System //indent:8 exp:8
- .out //indent:12 exp:12
- .println(); //indent:16 exp:16
+ String //indent:8 exp:8
+ .CASE_INSENSITIVE_ORDER //indent:12 exp:12
+ .reversed(); //indent:16 exp:16
BevelBorder border = new javax.swing.border.BevelBorder(BevelBorder.LOWERED); //indent:8 exp:8
border = new javax.swing.border. //indent:8 exp:8
diff --git a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/indentation/InputValidForIndent.java b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/indentation/InputValidForIndent.java
index 31f040ebf..838a142b4 100644
--- a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/indentation/InputValidForIndent.java
+++ b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/indentation/InputValidForIndent.java
@@ -79,11 +79,11 @@ public class InputValidForIndent { //indent:0 exp:0
} //indent:8 exp:8
for ( final int index : indices ) { //indent:8 exp:8
- System.err.println(index); //indent:12 exp:12
+ String.CASE_INSENSITIVE_ORDER.equals(index); //indent:12 exp:12
} //indent:8 exp:8
for ( final int index : indices ) //indent:8 exp:8
{ //indent:8 exp:8
- System.err.println(index); //indent:12 exp:12
+ String.CASE_INSENSITIVE_ORDER.equals(index); //indent:12 exp:12
} //indent:8 exp:8
} //indent:4 exp:4
} //indent:0 exp:0
diff --git a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/indentation/InputValidMethodIndent.java b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/indentation/InputValidMethodIndent.java
index 4bec1edf4..4fec8eb6b 100644
--- a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/indentation/InputValidMethodIndent.java
+++ b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/indentation/InputValidMethodIndent.java
@@ -179,7 +179,7 @@ public class InputValidMethodIndent extends java.awt.event.MouseAdapter implemen
+ " at indentation level not at correct indentation, " //indent:16 exp:>=12
+ method1()); //indent:16 exp:>=12
- System.out.toString() //indent:8 exp:8
+ String.CASE_INSENSITIVE_ORDER.toString() //indent:8 exp:8
.equals("blah"); //indent:12 exp:>=12
diff --git a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/metrics/InputComplexitySwitchBlocks.java b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/metrics/InputComplexitySwitchBlocks.java
index ef302b82f..ef6838025 100644
--- a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/metrics/InputComplexitySwitchBlocks.java
+++ b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/metrics/InputComplexitySwitchBlocks.java
@@ -7,13 +7,13 @@ public class InputComplexitySwitchBlocks {
case "Java":
case "C#":
case "C++":
- System.out.printf(programmingLanguage + " is an object oriented programming language.");
+ String.CASE_INSENSITIVE_ORDER.equals(programmingLanguage + " is an object oriented programming language.");
break;
case "C":
- System.out.printf(programmingLanguage + " is not an object oriented programming language.");
+ String.CASE_INSENSITIVE_ORDER.equals(programmingLanguage + " is not an object oriented programming language.");
break;
default:
- System.out.printf(programmingLanguage + " is unknown language.");
+ String.CASE_INSENSITIVE_ORDER.equals(programmingLanguage + " is unknown language.");
break;
}
}
diff --git a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/modifier/InputFinalInTryWithResource.java b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/modifier/InputFinalInTryWithResource.java
index 24dbad437..996d68d7d 100644
--- a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/modifier/InputFinalInTryWithResource.java
+++ b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/modifier/InputFinalInTryWithResource.java
@@ -1,9 +1,9 @@
package com.puppycrawl.tools.checkstyle.checks.modifier;
import java.io.BufferedReader;
-import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
+import java.io.InputStreamReader;
import java.lang.annotation.ElementType;
import java.lang.annotation.Target;
@@ -14,18 +14,18 @@ public class InputFinalInTryWithResource {
catch (RuntimeException e) {
}
- try (@NotNull BufferedReader br = new BufferedReader(new FileReader(""))) {
+ try (@NotNull BufferedReader br = new BufferedReader(new InputStreamReader(null, "utf-8"))) {
}
catch (IOException e) {
}
- try (final BufferedReader br = new BufferedReader(new FileReader(""))) {
+ try (final BufferedReader br = new BufferedReader(new InputStreamReader(null, "utf-8"))) {
}
catch (IOException e) {
}
- try (final BufferedReader br = new BufferedReader(new FileReader(""));
- final BufferedReader br2 = new BufferedReader(new FileReader(""))) {
+ try (final BufferedReader br = new BufferedReader(new InputStreamReader(null, "utf-8"));
+ final BufferedReader br2 = new BufferedReader(new InputStreamReader(null, "utf-8"))) {
}
catch (IOException e) {
}
diff --git a/src/test/resources/com/puppycrawl/tools/checkstyle/grammars/InputRegressionJavaClass1.java b/src/test/resources/com/puppycrawl/tools/checkstyle/grammars/InputRegressionJavaClass1.java
index 04684c646..fa26ac03f 100644
--- a/src/test/resources/com/puppycrawl/tools/checkstyle/grammars/InputRegressionJavaClass1.java
+++ b/src/test/resources/com/puppycrawl/tools/checkstyle/grammars/InputRegressionJavaClass1.java
@@ -4,8 +4,8 @@ import static java.lang.String.valueOf;
import java.io.BufferedReader;
import java.io.FileNotFoundException;
-import java.io.FileReader;
import java.io.IOException;
+import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
@@ -312,9 +312,9 @@ public class InputRegressionJavaClass1 {
} catch (IOException | ArrayIndexOutOfBoundsException e) {
} catch (Exception e) {
} finally {}
- try (BufferedReader br = new BufferedReader(new FileReader(""))) {}
- try (BufferedReader br1 = new BufferedReader(new FileReader(""));
- BufferedReader br2 = new BufferedReader(new FileReader(""));) {}
+ try (BufferedReader br = new BufferedReader(new InputStreamReader(null, "utf-8"))) {}
+ try (BufferedReader br1 = new BufferedReader(new InputStreamReader(null, "utf-8"));
+ BufferedReader br2 = new BufferedReader(new InputStreamReader(null, "utf-8"));) {}
// access
test4 = InputRegressionJavaClass1.class;
diff --git a/src/test/resources/com/puppycrawl/tools/checkstyle/grammars/InputRegressionJavaClass1Ast.txt b/src/test/resources/com/puppycrawl/tools/checkstyle/grammars/InputRegressionJavaClass1Ast.txt
index 35c9f97b2..bf1c0c6de 100644
--- a/src/test/resources/com/puppycrawl/tools/checkstyle/grammars/InputRegressionJavaClass1Ast.txt
+++ b/src/test/resources/com/puppycrawl/tools/checkstyle/grammars/InputRegressionJavaClass1Ast.txt
@@ -39,15 +39,15 @@ IMPORT -> import [7:0]
| |--DOT -> . [7:11]
| | |--IDENT -> java [7:7]
| | `--IDENT -> io [7:12]
-| `--IDENT -> FileReader [7:15]
-`--SEMI -> ; [7:25]
+| `--IDENT -> IOException [7:15]
+`--SEMI -> ; [7:26]
IMPORT -> import [8:0]
|--DOT -> . [8:14]
| |--DOT -> . [8:11]
| | |--IDENT -> java [8:7]
| | `--IDENT -> io [8:12]
-| `--IDENT -> IOException [8:15]
-`--SEMI -> ; [8:26]
+| `--IDENT -> InputStreamReader [8:15]
+`--SEMI -> ; [8:32]
IMPORT -> import [9:0]
|--DOT -> . [9:16]
| |--DOT -> . [9:11]
@@ -2259,16 +2259,19 @@ CLASS_DEF -> CLASS_DEF [17:0]
| | | | |--ELIST -> ELIST [315:52]
| | | | | `--EXPR -> EXPR [315:52]
| | | | | `--LITERAL_NEW -> new [315:52]
- | | | | | |--IDENT -> FileReader [315:56]
- | | | | | |--LPAREN -> ( [315:66]
- | | | | | |--ELIST -> ELIST [315:67]
- | | | | | | `--EXPR -> EXPR [315:67]
- | | | | | | `--STRING_LITERAL -> "" [315:67]
- | | | | | `--RPAREN -> ) [315:69]
- | | | | `--RPAREN -> ) [315:70]
- | | | `--RPAREN -> ) [315:71]
- | | `--SLIST -> { [315:73]
- | | `--RCURLY -> } [315:74]
+ | | | | | |--IDENT -> InputStreamReader [315:56]
+ | | | | | |--LPAREN -> ( [315:73]
+ | | | | | |--ELIST -> ELIST [315:74]
+ | | | | | | |--EXPR -> EXPR [315:74]
+ | | | | | | | `--LITERAL_NULL -> null [315:74]
+ | | | | | | |--COMMA -> , [315:78]
+ | | | | | | `--EXPR -> EXPR [315:80]
+ | | | | | | `--STRING_LITERAL -> "utf-8" [315:80]
+ | | | | | `--RPAREN -> ) [315:87]
+ | | | | `--RPAREN -> ) [315:88]
+ | | | `--RPAREN -> ) [315:89]
+ | | `--SLIST -> { [315:91]
+ | | `--RCURLY -> } [315:92]
| |--LITERAL_TRY -> try [316:8]
| | |--RESOURCE_SPECIFICATION -> RESOURCE_SPECIFICATION [316:12]
| | | |--LPAREN -> ( [316:12]
@@ -2286,14 +2289,17 @@ CLASS_DEF -> CLASS_DEF [17:0]
| | | | | |--ELIST -> ELIST [316:53]
| | | | | | `--EXPR -> EXPR [316:53]
| | | | | | `--LITERAL_NEW -> new [316:53]
- | | | | | | |--IDENT -> FileReader [316:57]
- | | | | | | |--LPAREN -> ( [316:67]
- | | | | | | |--ELIST -> ELIST [316:68]
- | | | | | | | `--EXPR -> EXPR [316:68]
- | | | | | | | `--STRING_LITERAL -> "" [316:68]
- | | | | | | `--RPAREN -> ) [316:70]
- | | | | | `--RPAREN -> ) [316:71]
- | | | | |--SEMI -> ; [316:72]
+ | | | | | | |--IDENT -> InputStreamReader [316:57]
+ | | | | | | |--LPAREN -> ( [316:74]
+ | | | | | | |--ELIST -> ELIST [316:75]
+ | | | | | | | |--EXPR -> EXPR [316:75]
+ | | | | | | | | `--LITERAL_NULL -> null [316:75]
+ | | | | | | | |--COMMA -> , [316:79]
+ | | | | | | | `--EXPR -> EXPR [316:81]
+ | | | | | | | `--STRING_LITERAL -> "utf-8" [316:81]
+ | | | | | | `--RPAREN -> ) [316:88]
+ | | | | | `--RPAREN -> ) [316:89]
+ | | | | |--SEMI -> ; [316:90]
| | | | `--RESOURCE -> RESOURCE [317:16]
| | | | |--MODIFIERS -> MODIFIERS [317:16]
| | | | |--TYPE -> TYPE [317:16]
@@ -2307,17 +2313,20 @@ CLASS_DEF -> CLASS_DEF [17:0]
| | | | |--ELIST -> ELIST [317:56]
| | | | | `--EXPR -> EXPR [317:56]
| | | | | `--LITERAL_NEW -> new [317:56]
- | | | | | |--IDENT -> FileReader [317:60]
- | | | | | |--LPAREN -> ( [317:70]
- | | | | | |--ELIST -> ELIST [317:71]
- | | | | | | `--EXPR -> EXPR [317:71]
- | | | | | | `--STRING_LITERAL -> "" [317:71]
- | | | | | `--RPAREN -> ) [317:73]
- | | | | `--RPAREN -> ) [317:74]
- | | | |--SEMI -> ; [317:75]
- | | | `--RPAREN -> ) [317:76]
- | | `--SLIST -> { [317:78]
- | | `--RCURLY -> } [317:79]
+ | | | | | |--IDENT -> InputStreamReader [317:60]
+ | | | | | |--LPAREN -> ( [317:77]
+ | | | | | |--ELIST -> ELIST [317:78]
+ | | | | | | |--EXPR -> EXPR [317:78]
+ | | | | | | | `--LITERAL_NULL -> null [317:78]
+ | | | | | | |--COMMA -> , [317:82]
+ | | | | | | `--EXPR -> EXPR [317:84]
+ | | | | | | `--STRING_LITERAL -> "utf-8" [317:84]
+ | | | | | `--RPAREN -> ) [317:91]
+ | | | | `--RPAREN -> ) [317:92]
+ | | | |--SEMI -> ; [317:93]
+ | | | `--RPAREN -> ) [317:94]
+ | | `--SLIST -> { [317:96]
+ | | `--RCURLY -> } [317:97]
| |--EXPR -> EXPR [320:14]
| | `--ASSIGN -> = [320:14]
| | |--IDENT -> test4 [320:8]
diff --git a/src/test/resources/com/puppycrawl/tools/checkstyle/grammars/comments/InputFullOfBlockComments.java b/src/test/resources/com/puppycrawl/tools/checkstyle/grammars/comments/InputFullOfBlockComments.java
index 97592086b..59164ab85 100644
--- a/src/test/resources/com/puppycrawl/tools/checkstyle/grammars/comments/InputFullOfBlockComments.java
+++ b/src/test/resources/com/puppycrawl/tools/checkstyle/grammars/comments/InputFullOfBlockComments.java
@@ -6,7 +6,7 @@
21
*/ String/*22*/ main/*23*/(/*24*/String/*25*/[/*26*/]/*27*/ args/*28*/)/*29*/ {/*30*/
/*31*/String /*32*/line /*33*/= /*34*/"/*I'm NOT comment*/blabla"/*35*/;/*36*/
- /*37*/System/*38*/./* 39 */out/*40*/./*41*/println/*42*/(/*43*/line/*44*/)/*45*/;/*46*/
+ /*37*/String/*38*/./* 39 */CASE_INSENSITIVE_ORDER/*40*/./*41*/equals/*42*/(/*43*/line/*44*/)/*45*/;/*46*/
Integer[] array = null;
/*50*/for/*51*/ (/*52*/Integer/*53*/ i/*54*/:/*55*/ array/*56*/)/*57*/ {/*58*/
/*59*/
diff --git a/src/test/resources/com/puppycrawl/tools/checkstyle/grammars/comments/InputFullOfBlockCommentsAst.txt b/src/test/resources/com/puppycrawl/tools/checkstyle/grammars/comments/InputFullOfBlockCommentsAst.txt
index fb5629c55..bb87caa00 100644
--- a/src/test/resources/com/puppycrawl/tools/checkstyle/grammars/comments/InputFullOfBlockCommentsAst.txt
+++ b/src/test/resources/com/puppycrawl/tools/checkstyle/grammars/comments/InputFullOfBlockCommentsAst.txt
@@ -157,15 +157,15 @@ CLASS_DEF -> CLASS_DEF [3:6]
| | |--COMMENT_CONTENT -> 35 [8:69]
| | `--BLOCK_COMMENT_END -> */ [8:70]
| |--SEMI -> ; [8:73]
- | |--EXPR -> EXPR [9:60]
- | | |--BLOCK_COMMENT_BEGIN -> /* [9:54]
- | | | |--COMMENT_CONTENT -> 42 [9:56]
- | | | `--BLOCK_COMMENT_END -> */ [9:57]
- | | `--METHOD_CALL -> ( [9:60]
- | | |--BLOCK_COMMENT_BEGIN -> /* [9:34]
- | | | |--COMMENT_CONTENT -> 40 [9:36]
- | | | `--BLOCK_COMMENT_END -> */ [9:37]
- | | |--DOT -> . [9:40]
+ | |--EXPR -> EXPR [9:78]
+ | | |--BLOCK_COMMENT_BEGIN -> /* [9:72]
+ | | | |--COMMENT_CONTENT -> 42 [9:74]
+ | | | `--BLOCK_COMMENT_END -> */ [9:75]
+ | | `--METHOD_CALL -> ( [9:78]
+ | | |--BLOCK_COMMENT_BEGIN -> /* [9:53]
+ | | | |--COMMENT_CONTENT -> 40 [9:55]
+ | | | `--BLOCK_COMMENT_END -> */ [9:56]
+ | | |--DOT -> . [9:59]
| | | |--BLOCK_COMMENT_BEGIN -> /* [9:14]
| | | | |--COMMENT_CONTENT -> 38 [9:16]
| | | | `--BLOCK_COMMENT_END -> */ [9:17]
@@ -176,36 +176,36 @@ CLASS_DEF -> CLASS_DEF [3:6]
| | | | |--BLOCK_COMMENT_BEGIN -> /* [9:2]
| | | | | |--COMMENT_CONTENT -> 37 [9:4]
| | | | | `--BLOCK_COMMENT_END -> */ [9:5]
- | | | | |--IDENT -> System [9:8]
+ | | | | |--IDENT -> String [9:8]
| | | | |--BLOCK_COMMENT_BEGIN -> /* [9:21]
| | | | | |--COMMENT_CONTENT -> 39 [9:23]
| | | | | `--BLOCK_COMMENT_END -> */ [9:28]
- | | | | `--IDENT -> out [9:31]
- | | | |--BLOCK_COMMENT_BEGIN -> /* [9:41]
- | | | | |--COMMENT_CONTENT -> 41 [9:43]
- | | | | `--BLOCK_COMMENT_END -> */ [9:44]
- | | | `--IDENT -> println [9:47]
- | | |--ELIST -> ELIST [9:67]
- | | | `--EXPR -> EXPR [9:67]
- | | | |--BLOCK_COMMENT_BEGIN -> /* [9:61]
- | | | | |--COMMENT_CONTENT -> 43 [9:63]
- | | | | `--BLOCK_COMMENT_END -> */ [9:64]
- | | | `--IDENT -> line [9:67]
- | | |--BLOCK_COMMENT_BEGIN -> /* [9:71]
- | | | |--COMMENT_CONTENT -> 44 [9:73]
- | | | `--BLOCK_COMMENT_END -> */ [9:74]
- | | `--RPAREN -> ) [9:77]
- | |--BLOCK_COMMENT_BEGIN -> /* [9:78]
- | | |--COMMENT_CONTENT -> 45 [9:80]
- | | `--BLOCK_COMMENT_END -> */ [9:81]
- | |--SEMI -> ; [9:84]
+ | | | | `--IDENT -> CASE_INSENSITIVE_ORDER [9:31]
+ | | | |--BLOCK_COMMENT_BEGIN -> /* [9:60]
+ | | | | |--COMMENT_CONTENT -> 41 [9:62]
+ | | | | `--BLOCK_COMMENT_END -> */ [9:63]
+ | | | `--IDENT -> equals [9:66]
+ | | |--ELIST -> ELIST [9:85]
+ | | | `--EXPR -> EXPR [9:85]
+ | | | |--BLOCK_COMMENT_BEGIN -> /* [9:79]
+ | | | | |--COMMENT_CONTENT -> 43 [9:81]
+ | | | | `--BLOCK_COMMENT_END -> */ [9:82]
+ | | | `--IDENT -> line [9:85]
+ | | |--BLOCK_COMMENT_BEGIN -> /* [9:89]
+ | | | |--COMMENT_CONTENT -> 44 [9:91]
+ | | | `--BLOCK_COMMENT_END -> */ [9:92]
+ | | `--RPAREN -> ) [9:95]
+ | |--BLOCK_COMMENT_BEGIN -> /* [9:96]
+ | | |--COMMENT_CONTENT -> 45 [9:98]
+ | | `--BLOCK_COMMENT_END -> */ [9:99]
+ | |--SEMI -> ; [9:102]
| |--VARIABLE_DEF -> VARIABLE_DEF [10:9]
| | |--MODIFIERS -> MODIFIERS [10:9]
| | |--TYPE -> TYPE [10:9]
| | | `--ARRAY_DECLARATOR -> [ [10:9]
- | | | |--BLOCK_COMMENT_BEGIN -> /* [9:85]
- | | | | |--COMMENT_CONTENT -> 46 [9:87]
- | | | | `--BLOCK_COMMENT_END -> */ [9:88]
+ | | | |--BLOCK_COMMENT_BEGIN -> /* [9:103]
+ | | | | |--COMMENT_CONTENT -> 46 [9:105]
+ | | | | `--BLOCK_COMMENT_END -> */ [9:106]
| | | |--IDENT -> Integer [10:2]
| | | `--RBRACK -> ] [10:10]
| | |--IDENT -> array [10:12]
diff --git a/src/test/resources/com/puppycrawl/tools/checkstyle/grammars/comments/InputFullOfSinglelineComments.java b/src/test/resources/com/puppycrawl/tools/checkstyle/grammars/comments/InputFullOfSinglelineComments.java
index 8f2f7c706..eaa80580e 100644
--- a/src/test/resources/com/puppycrawl/tools/checkstyle/grammars/comments/InputFullOfSinglelineComments.java
+++ b/src/test/resources/com/puppycrawl/tools/checkstyle/grammars/comments/InputFullOfSinglelineComments.java
@@ -49,11 +49,11 @@ i//47
+//48
""//49
;//50
-System//51
+String//51
.//52
-out//53
+CASE_INSENSITIVE_ORDER//53
.//54
-println//55
+equals//55
(//56
line//57
)//58
diff --git a/src/test/resources/com/puppycrawl/tools/checkstyle/grammars/comments/InputFullOfSinglelineCommentsAst.txt b/src/test/resources/com/puppycrawl/tools/checkstyle/grammars/comments/InputFullOfSinglelineCommentsAst.txt
index 63b329c7f..edbc2edfc 100644
--- a/src/test/resources/com/puppycrawl/tools/checkstyle/grammars/comments/InputFullOfSinglelineCommentsAst.txt
+++ b/src/test/resources/com/puppycrawl/tools/checkstyle/grammars/comments/InputFullOfSinglelineCommentsAst.txt
@@ -174,24 +174,24 @@ CLASS_DEF -> CLASS_DEF [16:0]
| | | `--COMMENT_CONTENT -> 49\n [50:4]
| | |--SEMI -> ; [51:0]
| | |--EXPR -> EXPR [57:0]
- | | | |--SINGLE_LINE_COMMENT -> // [56:7]
- | | | | `--COMMENT_CONTENT -> 55\n [56:9]
+ | | | |--SINGLE_LINE_COMMENT -> // [56:6]
+ | | | | `--COMMENT_CONTENT -> 55\n [56:8]
| | | `--METHOD_CALL -> ( [57:0]
- | | | |--SINGLE_LINE_COMMENT -> // [54:3]
- | | | | `--COMMENT_CONTENT -> 53\n [54:5]
+ | | | |--SINGLE_LINE_COMMENT -> // [54:22]
+ | | | | `--COMMENT_CONTENT -> 53\n [54:24]
| | | |--DOT -> . [55:0]
| | | | |--SINGLE_LINE_COMMENT -> // [52:6]
| | | | | `--COMMENT_CONTENT -> 51\n [52:8]
| | | | |--DOT -> . [53:0]
| | | | | |--SINGLE_LINE_COMMENT -> // [51:1]
| | | | | | `--COMMENT_CONTENT -> 50\n [51:3]
- | | | | | |--IDENT -> System [52:0]
+ | | | | | |--IDENT -> String [52:0]
| | | | | |--SINGLE_LINE_COMMENT -> // [53:1]
| | | | | | `--COMMENT_CONTENT -> 52\n [53:3]
- | | | | | `--IDENT -> out [54:0]
+ | | | | | `--IDENT -> CASE_INSENSITIVE_ORDER [54:0]
| | | | |--SINGLE_LINE_COMMENT -> // [55:1]
| | | | | `--COMMENT_CONTENT -> 54\n [55:3]
- | | | | `--IDENT -> println [56:0]
+ | | | | `--IDENT -> equals [56:0]
| | | |--ELIST -> ELIST [58:0]
| | | | `--EXPR -> EXPR [58:0]
| | | | |--SINGLE_LINE_COMMENT -> // [57:1]
diff --git a/src/test/resources/com/puppycrawl/tools/checkstyle/grammars/java8/InputDefaultMethods.java b/src/test/resources/com/puppycrawl/tools/checkstyle/grammars/java8/InputDefaultMethods.java
index 06b1d3cbf..2fae7f6e1 100644
--- a/src/test/resources/com/puppycrawl/tools/checkstyle/grammars/java8/InputDefaultMethods.java
+++ b/src/test/resources/com/puppycrawl/tools/checkstyle/grammars/java8/InputDefaultMethods.java
@@ -3,7 +3,7 @@ package com.puppycrawl.tools.checkstyle.grammars.java8;
public interface InputDefaultMethods {
default public void doSomething(){
- System.out.println("Something done.");
+ String.CASE_INSENSITIVE_ORDER.equals("Something done.");
}
public void doOneMoreThing();
diff --git a/src/test/resources/com/puppycrawl/tools/checkstyle/grammars/java8/InputLambda1.java b/src/test/resources/com/puppycrawl/tools/checkstyle/grammars/java8/InputLambda1.java
index 057be2349..050a8c9ab 100644
--- a/src/test/resources/com/puppycrawl/tools/checkstyle/grammars/java8/InputLambda1.java
+++ b/src/test/resources/com/puppycrawl/tools/checkstyle/grammars/java8/InputLambda1.java
@@ -1,9 +1,14 @@
//Compilable with Java8
package com.puppycrawl.tools.checkstyle.grammars.java8;
+
+import java.util.logging.Logger;
+
public class InputLambda1 {
-
- static Runnable r1 = ()->System.out.println("Hello world one!");
- static Runnable r2 = () -> System.out.println("Hello world two!");
+
+ private static final Logger LOG = Logger.getLogger(InputLambda1.class.getName());
+
+ static Runnable r1 = ()->LOG.info("Hello world one!");
+ static Runnable r2 = () -> LOG.info("Hello world two!");
public static void main(String[] args) {
r1.run();
diff --git a/src/test/resources/com/puppycrawl/tools/checkstyle/grammars/java8/InputLambda10.java b/src/test/resources/com/puppycrawl/tools/checkstyle/grammars/java8/InputLambda10.java
index 3779282aa..edbeafc12 100644
--- a/src/test/resources/com/puppycrawl/tools/checkstyle/grammars/java8/InputLambda10.java
+++ b/src/test/resources/com/puppycrawl/tools/checkstyle/grammars/java8/InputLambda10.java
@@ -1,16 +1,21 @@
//Compilable with Java8
package com.puppycrawl.tools.checkstyle.grammars.java8;
+
+import java.util.logging.Logger;
+
public class InputLambda10 {
+ private static final Logger LOG = Logger.getLogger(InputLambda10.class.getName());
+
public static void testVoidLambda(TestOfVoidLambdas test) {
- System.out.println("Method called");
+ LOG.info("Method called");
test.doSmth("fef");
}
public static void main(String[] args) {
- testVoidLambda(s1 -> System.out.println(s1));
+ testVoidLambda(s1 -> LOG.info(s1));
}
private interface TestOfVoidLambdas {
diff --git a/src/test/resources/com/puppycrawl/tools/checkstyle/grammars/java8/InputLambda11.java b/src/test/resources/com/puppycrawl/tools/checkstyle/grammars/java8/InputLambda11.java
index 43cfbd437..3634591d7 100644
--- a/src/test/resources/com/puppycrawl/tools/checkstyle/grammars/java8/InputLambda11.java
+++ b/src/test/resources/com/puppycrawl/tools/checkstyle/grammars/java8/InputLambda11.java
@@ -1,16 +1,21 @@
//Compilable with Java8
package com.puppycrawl.tools.checkstyle.grammars.java8;
+
+import java.util.logging.Logger;
+
public class InputLambda11 {
+ private static final Logger LOG = Logger.getLogger(InputLambda11.class.getName());
+
public static void testVoidLambda(TestOfVoidLambdas test) {
- System.out.println("Method called");
+ LOG.info("Method called");
test.doSmth("fef");
}
public static void main(String[] args) {
- testVoidLambda(s1 -> {System.out.println(s1);});
+ testVoidLambda(s1 -> {LOG.info(s1);});
}
private interface TestOfVoidLambdas {
diff --git a/src/test/resources/com/puppycrawl/tools/checkstyle/grammars/java8/InputLambda12.java b/src/test/resources/com/puppycrawl/tools/checkstyle/grammars/java8/InputLambda12.java
index 8fc2e9ba7..1301cf9ab 100644
--- a/src/test/resources/com/puppycrawl/tools/checkstyle/grammars/java8/InputLambda12.java
+++ b/src/test/resources/com/puppycrawl/tools/checkstyle/grammars/java8/InputLambda12.java
@@ -1,16 +1,21 @@
//Compilable with Java8
package com.puppycrawl.tools.checkstyle.grammars.java8;
+
+import java.util.logging.Logger;
+
public class InputLambda12 {
+ private static final Logger LOG = Logger.getLogger(InputLambda12.class.getName());
+
public static void testVoidLambda(TestOfVoidLambdas test) {
- System.out.println("Method called");
+ LOG.info("Method called");
test.doSmth("fef", 5);
}
public static void main(String[] args) {
- testVoidLambda((String s1, Integer i2) -> System.out.println(s1));
+ testVoidLambda((String s1, Integer i2) -> LOG.info(s1));
}
private interface TestOfVoidLambdas {
diff --git a/src/test/resources/com/puppycrawl/tools/checkstyle/grammars/java8/InputLambda13.java b/src/test/resources/com/puppycrawl/tools/checkstyle/grammars/java8/InputLambda13.java
index 7e81fcbfe..8c8b3fb4f 100644
--- a/src/test/resources/com/puppycrawl/tools/checkstyle/grammars/java8/InputLambda13.java
+++ b/src/test/resources/com/puppycrawl/tools/checkstyle/grammars/java8/InputLambda13.java
@@ -1,9 +1,14 @@
//Compilable with Java8
package com.puppycrawl.tools.checkstyle.grammars.java8;
+
+import java.util.logging.Logger;
+
public class InputLambda13 {
+ private static final Logger LOG = Logger.getLogger(InputLambda13.class.getName());
+
public static void testVoidLambda(TestOfVoidLambdas test) {
- System.out.println("Method called");
+ LOG.info("Method called");
test.doSmth("fef", 5);
}
@@ -11,7 +16,7 @@ public class InputLambda13 {
public static void main(String[] args) {
testVoidLambda((String s1, Integer i2) -> {
- System.out.println(s1);
+ LOG.info(s1);
});
}
diff --git a/src/test/resources/com/puppycrawl/tools/checkstyle/grammars/java8/InputLambda14.java b/src/test/resources/com/puppycrawl/tools/checkstyle/grammars/java8/InputLambda14.java
index 9b1fe1c0f..ba532abe3 100644
--- a/src/test/resources/com/puppycrawl/tools/checkstyle/grammars/java8/InputLambda14.java
+++ b/src/test/resources/com/puppycrawl/tools/checkstyle/grammars/java8/InputLambda14.java
@@ -2,17 +2,20 @@
package com.puppycrawl.tools.checkstyle.grammars.java8;
import java.util.Arrays;
import java.util.List;
+import java.util.logging.Logger;
public class InputLambda14 {
-
+
+ private static final Logger LOG = Logger.getLogger(InputLambda14.class.getName());
+
public static void main(String args[]) {
List numbers = Arrays.asList(1, 2, 3, 4, 5);
numbers.forEach(first -> {
- System.out.println("first");
- System.out.println("second");
- System.out.println("third");
+ LOG.info("first");
+ LOG.info("second");
+ LOG.info("third");
});
}
}
diff --git a/src/test/resources/com/puppycrawl/tools/checkstyle/grammars/java8/InputLambda15.java b/src/test/resources/com/puppycrawl/tools/checkstyle/grammars/java8/InputLambda15.java
index 9f6070a5f..c797deedc 100644
--- a/src/test/resources/com/puppycrawl/tools/checkstyle/grammars/java8/InputLambda15.java
+++ b/src/test/resources/com/puppycrawl/tools/checkstyle/grammars/java8/InputLambda15.java
@@ -1,8 +1,11 @@
//Compilable with Java8
package com.puppycrawl.tools.checkstyle.grammars.java8;
import java.util.function.Function;
+import java.util.logging.Logger;
+
public class InputLambda15
{
+ private static final Logger LOG = Logger.getLogger(InputLambda15.class.getName());
public static void main(String[] args) {
InputLambda15 ex = new InputLambda15();
@@ -10,17 +13,17 @@ public class InputLambda15
Function log = d -> ex.log(d);
Function exp = d -> ex.exp(d);
InputLambda15 compose = new InputLambda15();
- System.out.println(compose.calculate(sin.compose(log), 0.8));
+ LOG.info(compose.calculate(sin.compose(log), 0.8).toString());
// prints log:sin:-0.22
- System.out.println(compose.calculate(sin.andThen(log), 0.8));
+ LOG.info(compose.calculate(sin.andThen(log), 0.8).toString());
// prints sin:log:-0.33
- System.out.println(compose.calculate(sin.compose(log).andThen(exp), 0.8));
+ LOG.info(compose.calculate(sin.compose(log).andThen(exp), 0.8).toString());
//log:sin:exp:0.80
- System.out.println(compose.calculate(sin.compose(log).compose(exp), 0.8));
+ LOG.info(compose.calculate(sin.compose(log).compose(exp), 0.8).toString());
//exp:log:sin:0.71
- System.out.println(compose.calculate(sin.andThen(log).compose(exp), 0.8));
+ LOG.info(compose.calculate(sin.andThen(log).compose(exp), 0.8).toString());
//exp:sin:log:-0.23
- System.out.println(compose.calculate(sin.andThen(log).andThen(exp), 0.8));
+ LOG.info(compose.calculate(sin.andThen(log).andThen(exp), 0.8).toString());
//sin:log:exp:0.71
}
@@ -32,19 +35,19 @@ public class InputLambda15
public Double sin(Double d)
{
- System.out.print("sin:");
+ LOG.info("sin:");
return Math.sin(d);
}
public Double log(Double d)
{
- System.out.print("log:");
+ LOG.info("log:");
return Math.log(d);
}
public Double exp(Double d)
{
- System.out.print("exp:");
+ LOG.info("exp:");
return Math.exp(d);
}
}
diff --git a/src/test/resources/com/puppycrawl/tools/checkstyle/grammars/java8/InputLambda2.java b/src/test/resources/com/puppycrawl/tools/checkstyle/grammars/java8/InputLambda2.java
index d408f599f..89e9715b6 100644
--- a/src/test/resources/com/puppycrawl/tools/checkstyle/grammars/java8/InputLambda2.java
+++ b/src/test/resources/com/puppycrawl/tools/checkstyle/grammars/java8/InputLambda2.java
@@ -1,15 +1,20 @@
//Compilable with Java8
package com.puppycrawl.tools.checkstyle.grammars.java8;
+
+import java.util.logging.Logger;
+
public class InputLambda2 {
+ private static final Logger LOG = Logger.getLogger(InputLambda2.class.getName());
+
public static void testVoidLambda(TestOfVoidLambdas test) {
- System.out.println("Method called");
+ LOG.info("Method called");
test.doSmth();
}
public static void main(String[] args) {
- testVoidLambda(() -> System.out.println("Method in interface called"));
+ testVoidLambda(() -> LOG.info("Method in interface called"));
}
private interface TestOfVoidLambdas {
diff --git a/src/test/resources/com/puppycrawl/tools/checkstyle/grammars/java8/InputLambda3.java b/src/test/resources/com/puppycrawl/tools/checkstyle/grammars/java8/InputLambda3.java
index 96d5db518..4e607688e 100644
--- a/src/test/resources/com/puppycrawl/tools/checkstyle/grammars/java8/InputLambda3.java
+++ b/src/test/resources/com/puppycrawl/tools/checkstyle/grammars/java8/InputLambda3.java
@@ -1,16 +1,21 @@
//Compilable with Java8
package com.puppycrawl.tools.checkstyle.grammars.java8;
+
+import java.util.logging.Logger;
+
public class InputLambda3 {
-
+
+ private static final Logger LOG = Logger.getLogger(InputLambda3.class.getName());
+
public static void testVoidLambda(TestOfVoidLambdas test) {
- System.out.println("Method called");
+ LOG.info("Method called");
test.doSmth();
}
public static void main(String[] args) {
testVoidLambda(() -> {
- System.out.println("Method in interface called");
+ LOG.info("Method in interface called");
});
}
diff --git a/src/test/resources/com/puppycrawl/tools/checkstyle/grammars/java8/InputLambda4.java b/src/test/resources/com/puppycrawl/tools/checkstyle/grammars/java8/InputLambda4.java
index cfeebe648..e37b443ff 100644
--- a/src/test/resources/com/puppycrawl/tools/checkstyle/grammars/java8/InputLambda4.java
+++ b/src/test/resources/com/puppycrawl/tools/checkstyle/grammars/java8/InputLambda4.java
@@ -2,12 +2,15 @@
package com.puppycrawl.tools.checkstyle.grammars.java8;
import java.util.Arrays;
import java.util.List;
+import java.util.logging.Logger;
public class InputLambda4 {
-
+
+ private static final Logger LOG = Logger.getLogger(InputLambda4.class.getName());
+
public void doSomething() {
List numbers = Arrays.asList(1, 2, 3, 4, 5, 6);
- numbers.forEach((Integer value) -> System.out.println(value));
+ numbers.forEach((Integer value) -> LOG.info(value.toString()));
}
}
diff --git a/src/test/resources/com/puppycrawl/tools/checkstyle/grammars/java8/InputLambda5.java b/src/test/resources/com/puppycrawl/tools/checkstyle/grammars/java8/InputLambda5.java
index 7102f71e6..29452d407 100644
--- a/src/test/resources/com/puppycrawl/tools/checkstyle/grammars/java8/InputLambda5.java
+++ b/src/test/resources/com/puppycrawl/tools/checkstyle/grammars/java8/InputLambda5.java
@@ -2,13 +2,16 @@
package com.puppycrawl.tools.checkstyle.grammars.java8;
import java.util.Arrays;
import java.util.List;
+import java.util.logging.Logger;
public class InputLambda5 {
-
+
+ private static final Logger LOG = Logger.getLogger(InputLambda5.class.getName());
+
public void doSomething() {
List numbers = Arrays.asList(1, 2, 3, 4, 5, 6);
- numbers.forEach((Integer value) -> {System.out.println(value);});
+ numbers.forEach((Integer value) -> {LOG.info(value.toString());});
}
}
diff --git a/src/test/resources/com/puppycrawl/tools/checkstyle/grammars/java8/InputLambda6.java b/src/test/resources/com/puppycrawl/tools/checkstyle/grammars/java8/InputLambda6.java
index 49f04d004..b95d57f7c 100644
--- a/src/test/resources/com/puppycrawl/tools/checkstyle/grammars/java8/InputLambda6.java
+++ b/src/test/resources/com/puppycrawl/tools/checkstyle/grammars/java8/InputLambda6.java
@@ -2,12 +2,15 @@
package com.puppycrawl.tools.checkstyle.grammars.java8;
import java.util.Arrays;
import java.util.List;
+import java.util.logging.Logger;
public class InputLambda6 {
+ private static final Logger LOG = Logger.getLogger(InputLambda6.class.getName());
+
public void doSomething() {
List numbers = Arrays.asList(1, 2, 3, 4, 5, 6);
- numbers.forEach((value) -> System.out.println(value));
+ numbers.forEach((value) -> LOG.info(value.toString()));
}
}
diff --git a/src/test/resources/com/puppycrawl/tools/checkstyle/grammars/java8/InputLambda7.java b/src/test/resources/com/puppycrawl/tools/checkstyle/grammars/java8/InputLambda7.java
index 9138d68ed..f8a602ba1 100644
--- a/src/test/resources/com/puppycrawl/tools/checkstyle/grammars/java8/InputLambda7.java
+++ b/src/test/resources/com/puppycrawl/tools/checkstyle/grammars/java8/InputLambda7.java
@@ -2,14 +2,17 @@
package com.puppycrawl.tools.checkstyle.grammars.java8;
import java.util.Arrays;
import java.util.List;
+import java.util.logging.Logger;
public class InputLambda7 {
+ private static final Logger LOG = Logger.getLogger(InputLambda7.class.getName());
+
public void doSomething() {
List numbers = Arrays.asList(1, 2, 3, 4, 5, 6);
numbers.forEach((value) -> {
- System.out.println(value);
+ LOG.info(value.toString());
});
}
}
diff --git a/src/test/resources/com/puppycrawl/tools/checkstyle/grammars/java8/InputLambda8.java b/src/test/resources/com/puppycrawl/tools/checkstyle/grammars/java8/InputLambda8.java
index 1c3dcf3e3..529f60002 100644
--- a/src/test/resources/com/puppycrawl/tools/checkstyle/grammars/java8/InputLambda8.java
+++ b/src/test/resources/com/puppycrawl/tools/checkstyle/grammars/java8/InputLambda8.java
@@ -1,15 +1,21 @@
//Compilable with Java8
package com.puppycrawl.tools.checkstyle.grammars.java8;
+
+import java.util.logging.Logger;
+
public class InputLambda8 {
+
+ private static final Logger LOG = Logger.getLogger(InputLambda8.class.getName());
+
public static void testVoidLambda(TestOfVoidLambdas test) {
- System.out.println("Method called");
+ LOG.info("Method called");
test.doSmth("fef", 2);
}
public static void main(String[] args) {
- testVoidLambda((s1, s2) -> System.out.println(s1 + s2));
+ testVoidLambda((s1, s2) -> LOG.info(s1 + s2));
}
private interface TestOfVoidLambdas {
diff --git a/src/test/resources/com/puppycrawl/tools/checkstyle/grammars/java8/InputLambda9.java b/src/test/resources/com/puppycrawl/tools/checkstyle/grammars/java8/InputLambda9.java
index 287bac92e..e8a04215b 100644
--- a/src/test/resources/com/puppycrawl/tools/checkstyle/grammars/java8/InputLambda9.java
+++ b/src/test/resources/com/puppycrawl/tools/checkstyle/grammars/java8/InputLambda9.java
@@ -1,15 +1,21 @@
//Compilable with Java8
package com.puppycrawl.tools.checkstyle.grammars.java8;
+
+import java.util.logging.Logger;
+
public class InputLambda9 {
+
+ private static final Logger LOG = Logger.getLogger(InputLambda9.class.getName());
+
public static void testVoidLambda(TestOfVoidLambdas test) {
- System.out.println("Method called");
+ LOG.info("Method called");
test.doSmth("fef", 2);
}
public static void main(String[] args) {
- testVoidLambda((s1, s2) -> {System.out.println(s1 + s2);});
+ testVoidLambda((s1, s2) -> {LOG.info(s1 + s2);});
}
private interface TestOfVoidLambdas {
diff --git a/src/test/resources/com/puppycrawl/tools/checkstyle/grammars/java8/InputMethodReferences.java b/src/test/resources/com/puppycrawl/tools/checkstyle/grammars/java8/InputMethodReferences.java
index a72cf8d21..f654b85cd 100644
--- a/src/test/resources/com/puppycrawl/tools/checkstyle/grammars/java8/InputMethodReferences.java
+++ b/src/test/resources/com/puppycrawl/tools/checkstyle/grammars/java8/InputMethodReferences.java
@@ -12,7 +12,7 @@ public class InputMethodReferences extends ParentClass
List numbers = Arrays.asList(1,2,3,4,5,6);
- numbers.forEach(System.out::println);
+ numbers.forEach(String.CASE_INSENSITIVE_ORDER::equals);
InputMethodReferences tl = new InputMethodReferences();
String roster = new String();