View Javadoc
1   //start line index in expected file is 2
2   package com.puppycrawl.tools.checkstyle.grammars;
3   ;
4   import java.lang.annotation.ElementType;
5   import java.lang.annotation.Retention;
6   import java.lang.annotation.RetentionPolicy;
7   import java.lang.annotation.Target;
8   import java.util.ArrayList;
9   import java.util.Collections;
10  import java.util.Comparator;
11  import java.util.Map;
12  import java.util.List;
13  import java.util.function.IntBinaryOperator;
14  import java.util.function.Predicate;
15  import java.util.function.Supplier;
16  
17  public class InputRegressionJava8Class1 {
18      static class Inner1 { static class Inner2<V> { public void m() {} } }
19      static class Inner3<T> { public void m() {} }
20  
21      public void m() {}
22      public static void sm() {}
23      void m1() throws @Nullable Exception {}
24      public static <T> void m2(T @Nullable [] array) {}
25      public void m3() throws NullPointerException, @Nullable ArrayIndexOutOfBoundsException {}
26      public void m4(InputRegressionJava8Class1 this) {}
27      public void m5(@Nullable InputRegressionJava8Class1 this) {}
28  
29      {
30          List<String> vlist = new ArrayList<String>();
31      }
32  
33      public void instructions() {
34          // used to let inputs compile
35          boolean b = Math.random() > 0;
36  
37          int vint;
38          Object o = null;
39          List<String> vlist;
40          vlist = new ArrayList<String>();
41          Supplier<?> s;
42  
43          // annotations
44          Map.@Nullable Entry e;
45          String str = (@Nullable String) "";
46          (new Inner3()).<@Nullable String>m();
47  
48          // method reference
49          IntBinaryOperator ibo = Math::max;
50          s = InputRegressionJava8Class1::new;
51          s = Inner1.Inner2<String>::new;
52  
53          // lambda
54          Runnable r1 = () -> m();
55          Runnable r2 = () -> { m(); } ;
56          Collections.sort(vlist, (l,  r) -> l == r ? 0 : 1);
57          Predicate<?> t = (b) ? null : object -> o.equals(object);
58          Double mPi = Math.PI;
59      }
60  
61      static final Comparator<?> f = (Comparator<?>) (dateTime1, dateTime2) -> { return 0; };
62  
63      private class Inner {
64          public Inner(InputRegressionJava8Class1 InputRegressionJava8Class1.this) {}
65      }
66  }
67  ;
68  class InputRegressionJava8TypeParam <@Nullable T> {
69  }
70  @Retention(RetentionPolicy.CLASS)
71  @Target({ ElementType.TYPE_USE })
72  @interface Nullable {
73  }