1
2
3
4
5
6
7
8
9
10 package com.puppycrawl.tools.checkstyle.checks.coding.requirethis;
11
12 import java.io.BufferedReader;
13 import java.io.FileNotFoundException;
14 import java.io.InputStreamReader;
15 import java.io.IOException;
16
17 public final class InputRequireThisStatic {
18 public static String staticField1 = "";
19
20 public static String staticField2 = new String(staticField1);
21
22 public String instanceField1;
23 public BufferedReader instFld2;
24
25 static {
26 try (BufferedReader instFld2 = new BufferedReader(new InputStreamReader(null, "utf-8"))) {
27 instFld2.readLine();
28 }
29 catch (FileNotFoundException e) {
30 }
31 catch (IOException e) {
32 }
33 }
34
35 public String get() {
36 return staticField1;
37 }
38
39 void foo50(String staticField1) {
40 staticField1 = staticField1;
41 }
42
43 void foo52(String staticField1) {
44 staticField1 += staticField1;
45 }
46
47 static void test(String instanceField1) {
48 if (instanceField1 == null) {
49 instanceField1 = staticField1;
50 }
51 }
52
53 static void test2() {
54 try (BufferedReader instFld2 = new BufferedReader(new InputStreamReader(null, "utf-8"))) {
55 instFld2.readLine();
56 }
57 catch (IOException e) {
58 }
59 }
60 }