diff options
author | Andrei Selkin <andreyselkin@gmail.com> | 2016-02-21 10:09:37 +0300 |
---|---|---|
committer | Roman Ivanov <ivanov-jr@mail.ru> | 2016-02-21 09:02:33 -0800 |
commit | 63c85593a57d75e82ed076576d0f3718c1fb4833 (patch) | |
tree | b3c37ff09f55386fa826d3a046d0ad10750a5e5a /src/test/resources-noncompilable | |
parent | 7450f13dfcf2f222c4bac344f21c5105f7430b61 (diff) | |
download | checkstyle-63c85593a57d75e82ed076576d0f3718c1fb4833.tar.gz |
Issue #903: Skip type annotations from validation of ModifierOrderCheck (part 2)
Diffstat (limited to 'src/test/resources-noncompilable')
-rw-r--r-- | src/test/resources-noncompilable/com/puppycrawl/tools/checkstyle/checks/modifier/InputTypeAnnotations.java | 53 |
1 files changed, 47 insertions, 6 deletions
diff --git a/src/test/resources-noncompilable/com/puppycrawl/tools/checkstyle/checks/modifier/InputTypeAnnotations.java b/src/test/resources-noncompilable/com/puppycrawl/tools/checkstyle/checks/modifier/InputTypeAnnotations.java index a92f940f0..327b0a4f1 100644 --- a/src/test/resources-noncompilable/com/puppycrawl/tools/checkstyle/checks/modifier/InputTypeAnnotations.java +++ b/src/test/resources-noncompilable/com/puppycrawl/tools/checkstyle/checks/modifier/InputTypeAnnotations.java @@ -1,4 +1,3 @@ -//Compilable with Java8 package com.puppycrawl.tools.checkstyle.checks.modifier; import java.io.File; @@ -6,13 +5,12 @@ import java.io.IOException; import java.io.Serializable; import java.lang.annotation.ElementType; import java.lang.annotation.Target; -import java.util.Arrays; import java.util.Collection; import java.util.Comparator; import java.util.List; import java.util.Map; -public class InputTypeAnnotations { +public class InputTypeAnnotations extends MyClass { // Simple type definitions with type annotations private @TypeAnnotation String hello = "Hello, World!"; @@ -78,9 +76,52 @@ public class InputTypeAnnotations { class Nested { } class T { } + + // Type annotation on method return type + @Override + public @TypeAnnotation String toString() { return ""; } + + @Override + @TypeAnnotation public int hashCode() { return 1; } + + public @TypeAnnotation int foo8() { return 1; } + + public @TypeAnnotation boolean equals(Object obj) { return super.equals(obj); } + +// @TypeAnnotation void foo9() { } <-- Compiletime error: void type cannot be annotated with type annotation + + @Override + void foo10() { + super.foo10(); + } } -@Target({ElementType.FIELD, ElementType.LOCAL_VARIABLE, ElementType.PARAMETER, - ElementType.TYPE_PARAMETER, ElementType.TYPE_USE}) +class MyClass { + + // It is annotation on method, but not on type! + @MethodAnnotation void foo10() {} + private @MethodAnnotation void foo11() {} + + public @TypeAnnotation MyClass() {} + @ConstructorAnnotation public MyClass(String name) {} +} + +enum MyEnum { + @TypeAnnotation A; +} + +interface IInterfacable { + default @TypeAnnotation String foo() { + return null; + } +} + +@Target({ + ElementType.FIELD, ElementType.LOCAL_VARIABLE, ElementType.PARAMETER, + ElementType.TYPE_PARAMETER, ElementType.TYPE_USE}) @interface TypeAnnotation { -}
\ No newline at end of file +} + +@interface MethodAnnotation {} + +@interface ConstructorAnnotation {} |