1   package com.puppycrawl.tools.checkstyle.checks.whitespace.nowhitespaceafter;
2   
3   import java.util.List;
4   
5   import com.puppycrawl.tools.checkstyle.api.TokenTypes;
6   
7   public class InputNoWhitespaceAfterArrayDeclarations2
8   {
9   
10      public class A {
11          public int[][] create(int i, int j) {
12              return new int[3] [3];//incorrect, 12:31
13          }
14      }
15  
16      public class B {
17          public int create(int i, int j) [][] {//incorrect, 17:41
18              return new int     [3][i + j] ;//incorrect,18:32
19          }
20      }
21  
22      public class C {
23          public int[][] create(int i, int j) {
24              return new int[i + j][i + j];//correct
25          }
26      }
27  
28      public class D {
29          public int[][]   [] create(int i, int j) {//incorrect, 29:26
30              return new int  [ i + j ]    [ i + j ]               [ 0 ]     ;//incorrect 30:29,42,66
31          }
32      }
33  
34      public class E {
35          public int create(int i, int j, int   [][] k)[] [][] {//incorrect, 35:47,57
36              int e [][] [] = new int[i + j] [2][i + j];//incorrect, 36:19,24,44
37              e [0] [1][2] = 0; e[1][1][1] = 0;//incorrect, 37:15,19
38              return e;
39          }
40      }
41      public static class F {
42          public static Integer [][][] create(int i, int j) {//incorrect, 42:31
43              int[][] [] f= new int[   0][1    ][    2    ]   ;//incorrect, 43:21
44              return new Integer[i + j][i + j][0];
45          }
46      }
47      public class G {
48          public List<String> [] [] [] create(int i, int j) {//incorrect, 48:29,32,35
49              //cannot build with check - generic array creation error, but whitespaces still caught
50              //List<String> g[][] [] = new List<String> [0][1][2];//incorrect 49:33,55
51              //return new List<String>[i + j][i + j][0];//correct
52              int g[][][] = new int [0][1][2];//incorrect 52:35
53              g[  0][0   ][   0   ]=0;
54              g [0][0][0]=0;//incorrect 54:15
55              g[0] [0][0]=0;//incorrect 55:18
56              g [0] [0] [0]        =0;//incorrect 56:15,19,23
57              return null;
58          }
59  
60      }
61      public class H {
62          public List<Integer> create(int i, int j)     []      [][] {//incorrect, 62:55,63
63              return null;
64          }
65      }
66  
67      Object someStuff4 = boolean [].class;//incorrect, 67:33
68      String[][] someStuff5 = new String[4][9];
69      String[][] someStuff6 = (java.lang.String  []  []) someStuff5;//incorrect, 69:48,52
70      String[][] someStuff7 = (String [][]) someStuff5;//incorrect, 70:37
71  
72      //this is legal until allowLineBreaks is set to false
73      int someStuff8
74      [];
75  
76      //this is legal until allowLineBreaks is set to false
77      int[]
78      someStuff81;
79  
80  
81      Integer someStuff9[][][] = (Integer [][][]) F.create(1,2);//incorrect 81:41
82  
83      //type arguments
84      List<char[]> someStuff10;//correct
85      List<char [][]> someStuff11;//incorrect 85:15
86      List<InputNoWhitespaceAfterArrayDeclarations2.A []> someStuff12;//incorrect 86:53
87      void foo(List<? extends String[]> bar, Comparable<? super Object []> baz) { }//incorrect 87:70
88  
89      Integer someStuff13 = F.create(1,1)[0][0][0];
90      Integer someStuff131 = F.create(1,1)  [0][0]   [0];//incorrect 90:43,52
91      Object[] someStuff14 = (Object[]) null;
92      Object[] someStuff15 = (Object  []  ) null;//incorrect 92:37
93  
94      byte someStuff16 = ((byte[]) someStuff4) [0];//incorrect 94:46
95  
96      public void bar() {
97          if(someStuff15 instanceof Object  []) {//incorrect 97:43
98  
99          }
100         if(someStuff15 instanceof Object[]  []) {//incorrect 100:45
101 
102         }
103         if(someStuff15 instanceof Object[][]) {
104 
105         }
106         Object[] a = null;
107 
108         if(a instanceof Object  []) {//incorrect 108:33
109 
110         }
111         if(a instanceof Object[][]) {
112 
113         }
114     }
115 
116 }