1
2
3
4
5
6
7 package com.puppycrawl.tools.checkstyle.checks.coding.unusedlocalvariable;
8
9 public class InputUnusedLocalVariableNestedClasses2 {
10
11 static class A {
12 static class B {
13 void foo() {
14 class C {
15 int a = 12;
16 }
17 }
18
19 class C {
20 int q = 13;
21 }
22 }
23 }
24 }
25
26 class d {
27 void testLocalClasses() {
28 int a = 12;
29 int q = 13;
30 InputUnusedLocalVariableNestedClasses2.A.B.C obj =
31 new InputUnusedLocalVariableNestedClasses2.A.B().new C() {
32 void method() {
33 q += a;
34 }
35 };
36 }
37 }
38
39 class InputUnusedLocalVariableSameNameLen1 {
40 class A {
41 class B {
42 class C {
43 int b = 12;
44
45 void method() {
46 int b = 12;
47 int a = 12;
48 C obj = new C() {
49 void method() {
50 b += a;
51 }
52 };
53 obj.getClass();
54 }
55
56 void anotherMethod() {
57 int b = 12;
58 InputUnusedLocalVariableSameNameLen1.A.B.C obj =
59 new com.puppycrawl.tools.checkstyle.checks.coding.unusedlocalvariable
60 .InputUnusedLocalVariableSameNameLen1()
61 .new A().new B().new C() {
62 void anotherMethod() {
63 b += 1;
64 }
65 };
66 obj.anotherMethod();
67 }
68 }
69 }
70
71 void method() {
72 int a = 12;
73 InputUnusedLocalVariable obj
74 = new com.puppycrawl.tools.checkstyle.checks.coding
75 .unusedlocalvariable.InputUnusedLocalVariable() {
76 void method() {
77 a += 12;
78 }
79 };
80 obj.getClass();
81 }
82 }
83
84 interface Tester {
85 void test();
86 }
87
88 interface TU<U> {
89 public void foo(U u);
90 }
91
92 public static <U> void exec(TU<U> lambda, U x) {
93 lambda.foo(x);
94 }
95
96 void test1() {
97 final Integer N1 = 1;
98 class A {
99 Integer n2 = 20;
100
101 void test() {
102 final Integer N2 = 2;
103 class B {
104 void test() {
105 final Integer N3 = 3;
106 exec((final Integer x) -> new Tester() {
107 public void test() {
108 int s = Integer.valueOf(x + n2 + N1 + N2 + N3);
109
110 }
111 }.test(), 30);
112 }
113 }
114 new B().test();
115 }
116 }
117 new A().test();
118 }
119 }