View Javadoc
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:30 
13          }
14      }
15      
16      public class B {
17          public int create(int i, int j) [][] {//incorrect, 17:40
18              return new int     [3][i + j] ;//incorrect,18:27
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:23
30              return new int  [ i + j ]    [ i + j ]               [ 0 ]     ;//incorrect 30:27,38,51
31          }
32      }
33      
34      public class E {
35          public int create(int i, int j, int   [][] k)[] [][] {//incorrect, 35:44,56
36              int e [][] [] = new int[i + j] [2][i + j];//incorrect, 36:18,23,43
37              e [0] [1][2] = 0; e[1][1][1] = 0;//incorrect, 37:14,18
38              return e;
39          }
40      }
41      public static class F {
42          public static Integer [][][] create(int i, int j) {//incorrect, 42:23
43              int[][] [] f= new int[   0][1    ][    2    ]   ;
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:28,31,34
49              //cannot build with this check - generic array creation error, but whitespaces still catched
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];
53              g[  0][0   ][   0   ]=0;
54              g [0][0][0]=0;//incorrect 54:14
55              g[0] [0][0]=0;//incorrect 55:17
56              g [0] [0] [0]        =0;//incorrect 56:14,18,22
57              return null;
58          }
59  
60      }
61      public class H {
62          public List<Integer> create(int i, int j)     []      [][] {//incorrect, 62:46,53
63              return null;
64          }
65      }
66      
67      Object someStuff4 = boolean [].class;//incorrect, 67:32
68      String[][] someStuff5 = new String[4][9];
69      String[][] someStuff6 = (java.lang.String  []  []) someStuff5;//incorrect, 69:46,50
70      String[][] someStuff7 = (String [][]) someStuff5;//incorrect, 70:36
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      //incorrect 81:40
81      Integer someStuff9[][][] = (Integer [][][]) InputNoWhitespaceAfterArrayDeclarations2.F.create(1,2);
82      
83      //type arguments
84      List<char[]> someStuff10;//correct
85      List<char [][]> someStuff11;//incorrect 85:14
86      List<InputNoWhitespaceAfterArrayDeclarations2.A []> someStuff12;//incorrect 86:52
87      public void foo(java.util.List<? extends String[]> bar, Comparable<? super Object []> baz) { }//incorrect 87:86
88      
89      Integer someStuff13 = F.create(1,1)[0][0][0];
90      Integer someStuff131 = F.create(1,1)  [0][0]   [0];//incorrect 90:41,49
91      Object[] someStuff14 = (Object[]) null;
92      Object[] someStuff15 = (Object  []  ) null;//incorrect 92:35
93      
94      byte someStuff16 = ((byte[]) someStuff4) [0];//incorrect 94:45
95      
96      public void bar() {
97          if(someStuff15 instanceof Object  []) {//incorrect 97:41
98      
99          }
100         if(someStuff15 instanceof Object[]  []) {//incorrect 100:43
101           
102         }
103         if(someStuff15 instanceof Object[][]) {
104           
105         }
106         Object[] a = null;
107 
108         if(a instanceof Object  []) {//incorrect
109           
110         }
111         if(a instanceof Object[][]) {
112           
113         }
114     }
115 
116 }