Issue #2541: Activate forbidden-apis on test input files (#3402)

This commit is contained in:
Andrei Selkin 2016-08-12 06:24:53 +03:00 committed by Roman Ivanov
parent dfae5adb1f
commit b4e884c2ff
54 changed files with 359 additions and 285 deletions

View File

@ -981,8 +981,8 @@
<!-- generated classes, unfortunately use problematic api -->
<exclude>**/GeneratedJavaLexer.class</exclude>
<exclude>**/JavadocParser.class</exclude>
<!-- Tests related -->
<exclude>**/Input*</exclude>
<!-- excluded till https://github.com/policeman-tools/forbidden-apis/issues/108-->
<exclude>**/checks/annotation/InputAnnotationLocation4*</exclude>
</excludes>
</configuration>
<executions>

View File

@ -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() {

View File

@ -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<objects.length; i++) {
objects[i].setEnabled(true);
objects[i].setColor(0x121212);

View File

@ -120,19 +120,19 @@ class InputFinalParameters
void method1()
{
try {
System.err.println("");
String.CASE_INSENSITIVE_ORDER.equals("");
}
catch (java.lang.NullPointerException npe) {
npe.printStackTrace();
npe.getMessage();
}
catch (@MyAnnotation3 final ClassCastException e) {
e.printStackTrace();
e.getMessage();
}
catch (RuntimeException e) {
e.printStackTrace();
e.getMessage();
}
catch (@MyAnnotation3 NoClassDefFoundError e) {
e.printStackTrace();
e.getMessage();
}
}

View File

@ -35,7 +35,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
}

View File

@ -53,7 +53,7 @@ class InputLeftCurlyLineBreakAfter
void method2()
{
boolean flag = false;
if (flag) { System.err.println("foo"); }
if (flag) { String.valueOf("foo"); }
}
}

View File

@ -4,15 +4,15 @@ package com.puppycrawl.tools.checkstyle.checks.blocks;
public class InputLeftCurlyNewLineOptionWithLambda
{
static Runnable r1 = () -> {
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!");
};
}

View File

@ -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."); }
}
}

View File

@ -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");
}
}

View File

@ -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");
}
}

View File

@ -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() {

View File

@ -49,7 +49,7 @@ class InputRightCurlyLineBreakBefore
void method2()
{
boolean flag = false;
if (flag) { System.err.println("foo"); }
if (flag) { String.valueOf("foo"); }
}
}

View File

@ -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!");};
}

View File

@ -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:

View File

@ -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;

View File

@ -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 ("<init>".equals(m.toLowerCase())) {
if ("<init>".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("") && !"<init>".equals(m.toLowerCase())) {
if (!m.equals("") && !"<init>".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;

View File

@ -16,7 +16,7 @@ public class InputHiddenFieldLambdas {
List<Integer> 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<String> 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<String> 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<String> 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<String> 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<String> 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 <String, Integer> 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 <Integer, Double> 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 <String, String> 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<List<Double>, Map<String, Object>> someWierdFunc =
(List<Double> justSomeList, Map<String, Object> justSomeMap) -> { // 2 violations
System.out.println(justSomeList);
System.out.println(justSomeMap);
String.valueOf(justSomeList);
String.valueOf(justSomeMap);
return new HashMap<>();
};
}

View File

@ -19,7 +19,7 @@ public class InputRequireThis {
this.method1();
}
catch (RuntimeException e) {
e.printStackTrace();
e.toString();
}
this.i--;

View File

@ -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) {

View File

@ -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
}

View File

@ -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<objects.length; i++) {
objects[i].setEnabled(true);
objects[i].setColor(0x121212);

View File

@ -145,7 +145,7 @@ public class InputCommentsIndentationCommentIsAtTheEndOfBlock {
for (int i = 0; i < 5; i++) {
org.junit.Assert.assertEquals(expected.get(i), array[i]);
}
String s = String.format("The array element "
String s = String.format(java.util.Locale.ENGLISH, "The array element "
+ "immediately following the end of the collection should be nulled",
array[1]);
// the above example was taken from hibernate-orm and was modified a bit
@ -158,7 +158,7 @@ public class InputCommentsIndentationCommentIsAtTheEndOfBlock {
for (int i = 0; i < 5; i++) {
org.junit.Assert.assertEquals(expected.get(i), array[i]);
}
String s = String.format("The array element "
String s = String.format(java.util.Locale.ENGLISH, "The array element "
+ "immediately following the end of the collection should be nulled",
array[1]);
// violation
@ -175,13 +175,13 @@ public class InputCommentsIndentationCommentIsAtTheEndOfBlock {
}
public String foo25() {
return String.format("%d",
return String.format(java.util.Locale.ENGLISH, "%d",
1);
// comment
}
public String foo26() {
return String.format("%d",
return String.format(java.util.Locale.ENGLISH, "%d",
1);
// violation
}
@ -196,14 +196,14 @@ public class InputCommentsIndentationCommentIsAtTheEndOfBlock {
public String foo28() {
int a = 5;
return String.format("%d",
return String.format(java.util.Locale.ENGLISH, "%d",
1);
// comment
}
public String foo29() {
int a = 5;
return String.format("%d",
return String.format(java.util.Locale.ENGLISH, "%d",
1);
// violation
}
@ -422,7 +422,7 @@ public class InputCommentsIndentationCommentIsAtTheEndOfBlock {
void foo62() {
if (true) {
System.out.println();
String.CASE_INSENSITIVE_ORDER.equals("");
}
else {
@ -437,7 +437,7 @@ public class InputCommentsIndentationCommentIsAtTheEndOfBlock {
void foo63() {
try {
System.out.println();
String.CASE_INSENSITIVE_ORDER.equals("");
}
catch (Exception e){

View File

@ -36,10 +36,10 @@ public class InputFinalInDefaultMethods { //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 -> 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<Person, StringJoiner, String> 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

View File

@ -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

View File

@ -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

View File

@ -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<Person, StringJoiner, String> 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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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;
}
}

View File

@ -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) {
}

View File

@ -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;

View File

@ -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]

View File

@ -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*/

View File

@ -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]

View File

@ -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

View File

@ -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]

View File

@ -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();

View File

@ -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();

View File

@ -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 {

View File

@ -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 {

View File

@ -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 {

View File

@ -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);
});
}

View File

@ -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<Integer> 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");
});
}
}

View File

@ -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<Double, Double> log = d -> ex.log(d);
Function<Double, Double> 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);
}
}

View File

@ -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 {

View File

@ -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");
});
}

View File

@ -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<Integer> 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()));
}
}

View File

@ -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<Integer> 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());});
}
}

View File

@ -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<Integer> numbers = Arrays.asList(1, 2, 3, 4, 5, 6);
numbers.forEach((value) -> System.out.println(value));
numbers.forEach((value) -> LOG.info(value.toString()));
}
}

View File

@ -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<Integer> numbers = Arrays.asList(1, 2, 3, 4, 5, 6);
numbers.forEach((value) -> {
System.out.println(value);
LOG.info(value.toString());
});
}
}

View File

@ -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 {

View File

@ -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 {

View File

@ -12,7 +12,7 @@ public class InputMethodReferences<T> extends ParentClass
List<Integer> 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();