import java.lang.annotation.*; import java.io.*; import java.util.*; import java.io.@SuppressWarnings Reader; import @SuppressWarnings java.io.Writer; import static java.lang.annotation.ElementType.*; /*@Target({CONSTRUCTOR, FIELD, LOCAL_VARIABLE, METHOD, PACKAGE, PARAMETER, TYPE})*/ @interface A { } @Target({TYPE_USE}) @interface TA { } @Target({TYPE_PARAMETER}) @interface TPA { } @A @TA @TPA class Outer { private Map<@TA String, @TA List<@TA @A String>> m; interface I { void m(int i); } private I i = (@TA @Override final int k) -> { }; @TA void m(T t) { } @TA void test1() { this.<@TA @TPA String>m("..."); } class FF { } Collection cs; interface BI { } class BII implements @TA BI<@TA T> { } class BIII extends @TA BII { } void tm() throws @TA RuntimeException { } class Middle { class Inner { void test() { @TA Inner v1; @TA Middle.@TA Inner v2; @TA Outer.@TA Middle.@TA Inner v3; @TA Outer v4; @TA Outer.@TA Middle v5; @TA Outer.@TA Middle.@TA Inner v6; List<@TA Outer.@TA Middle.@TA Inner> l; } } } static class StaticMiddle { static class StaticInner { void test() { @TA StaticInner v1; @TA StaticMiddle.@TA StaticInner v2; @TA Outer.@TA StaticMiddle.@TA StaticInner v3; List<@TA Outer.@TA StaticMiddle.@TA StaticInner> l; } } } { new @TA Object(); new @TA ArrayList(); ArrayList var = new @TA ArrayList(); new @TA Outer().new @TA Middle(); @A Map.@TA Entry e1; @A @TA Map.@TA Entry e2; @A java.@TA util.Map.@TA Entry e3; @A List@TA lang.@TA String> l1; Object obj = "str"; @TA String str = (@TA String)obj; boolean b = str instanceof @TA String; @TA tm(); try (@TA Reader r = new @TA FileReader("/dev/zero"); @TA Writer w = new @TA FileWriter("/dev/null")) { } catch (@TA IllegalArgumentException | @TA IOException e) { } @A @TA Unknown.@TA Unknown uu; Class c1 = @TA String.class; Class c2 = int @TA [].class; } interface IntFunction { int apply(T t); } interface Sorter { void sort(T[] a, Comparator c); } void m1(IntFunction f) { } void m2(IntFunction> f) { } void m3(Sorter s) { } void lambdas() { m1(@TA Date::getDay); m1(@TA java.util.@TA Date::getDay); m2(List<@TA String>::size); m3(Arrays::<@TA Integer>sort); Comparator cmp = (@TA Object x, @TA Object y) -> { System.out.println("x=" + x + " y=" + y); return 0; }; } void m(List<@TA ? extends Comparable> p) { } void arrays(String @TA ... docs) { @TA String @TA [] @TA [] docs1 = new @TA String @TA [2] @TA [2]; @TA int @TA [] ints = new @TA int @TA [2]; } int @TA [] mixedArrays @TA [] @TA = new int[0][0]; int @TA [] mixedArrays(int @TA [] p @TA [] @TA) @TA [] @TA { int @TA [] a @TA [] @TA = (p != null ? p : mixedArrays); return a; } void @TA misplaced() { } @TA Outer() { } class MyClass<@TA @TPA T> { } interface MyInterface<@TA @TPA E> { } static class Super { protected int aField; int getField() { return aField; } } static class This extends Super { void superField() { Outer.@TA This.super.aField = 0; IntFunction f = Outer.@TA This.super::getField; } } //todo[r.sh] /*public String toString(@TA C this) { return ""; } public boolean equals(@TA C this, @TA C other) { return false; } C(@TA C this, boolean b) { } class Outer { class Middle { class Inner { void innerMethod(@TA Outer.@TA Middle.@TA Inner this) { } } } }*/ }