-
Suggestion
-
Resolution: Won't Fix
Provide support for instrumentation of annotations in all places where Java 8 allows developer put them. E.g annotation on types or in different parts of method declaration.
Please note that javac compiler itself does not understand such annotations - it's up to annotation processors to handle them correctly.
However, as Clover does perform instrumentation "offline" (i.e. not inside the javac process), we must at least allow these annotations to be present (i.e. do not throw parse exceptions); Clover does not need to understand them, however.
void some (@RequestBody(required = false) String @Nullable [] arguments) { } static @interface Readonly { } static @interface NonNull { } static @interface NonEmpty { } // annotations for method receivers public int size() @Readonly { return 0; } // annotations inside generic type arguments Map<@NonNull String, @NonEmpty List<@Readonly Document>> files; // annotations inside arrays // docs1 is an unmodifiable one-dimensional array of mutable Documents Document[@Readonly] docs1; // docs2 is a mutable array whose elements are unmodifiable one-dimensional arrays of mutable Documents Document[][@Readonly] docs2 = new Document[2][@Readonly 12]; public void annotationInTypeCast(Object myObject) { String myString; // annotation in typecast myString = (@NonNull String)myObject; } public void annotationInInstanceOf(Object myString) { // type tests boolean isNonNull = myString instanceof @NonNull String; } public void annotationInObjectCreation() { Set myNonEmptyStringSet = new HashSet(); // object creation new @Readonly @NonEmpty ArrayList(myNonEmptyStringSet); } //type parameter bounds: //class Folder { ... } // t.b.d. // class inheritance abstract class UnmodifiableList<T> implements @Readonly List<@Readonly T> { } // throws clauses class TemperatureException extends Exception { } @interface Critical { }S void monitorTemperature() throws @Critical TemperatureException { throw new TemperatureException(); }
Scope:
Extend ANTLR grammar (java.g) to handle these constructs
- method return values, thrown exceptions
- generic types, including upper and lower bounds, wildcards
- nested classes
- arrays
and varargs
- type casting and instanceof
- "new" keyword - constructors, including nested and generic ones
- generic methods
- class/interface inheritance
- method and constructor references
Out of scope:
- explicit "this" receiver (if required to handle) - tracked in
CLOV-1934
Form Name |
---|
[CLOV-1839] Provide instrumentation support for Annotations in all places Java 8 allows to
Workflow | Original: JAC Suggestion Workflow [ 3342208 ] | New: JAC Suggestion Workflow 3 [ 3584724 ] |
Status | Original: RESOLVED [ 5 ] | New: Closed [ 6 ] |
Workflow | Original: New Clover Workflow [ 1018940 ] | New: JAC Suggestion Workflow [ 3342208 ] |
Issue Type | Original: Improvement [ 4 ] | New: Suggestion [ 10000 ] |
Status | Original: Closed [ 6 ] | New: Resolved [ 5 ] |
Resolution | New: Won't Fix [ 2 ] | |
Status | Original: Open [ 1 ] | New: Closed [ 6 ] |
Assignee | Original: Marek Parfianowicz [ mparfianowicz ] |
Fix Version/s | New: 4.2.0 [ 56395 ] | |
Fix Version/s | Original: 4.3.0 [ 60690 ] |
Remote Link | Original: This issue links to "Page (Extranet)" [ 162001 ] |
Labels | New: jdk8 |
Assignee | New: Marek Parfianowicz [ mparfianowicz ] |
Description |
Original:
Provide support for instrumentation of annotations in all places where Java 8 allows developer put them. E.g annotation on types or in different parts of method declaration.
Please note that javac compiler itself does not understand such annotations - it's up to annotation processors to handle them correctly. However, as Clover does perform instrumentation "offline" (i.e. not inside the javac process), we must at least allow these annotations to be present (i.e. do not throw parse exceptions); Clover does not need to understand them, however. {code:java} void some (@RequestBody(required = false) String @Nullable [] arguments) { } static @interface Readonly { } static @interface NonNull { } static @interface NonEmpty { } // annotations for method receivers public int size() @Readonly { return 0; } // annotations inside generic type arguments Map<@NonNull String, @NonEmpty List<@Readonly Document>> files; // annotations inside arrays // docs1 is an unmodifiable one-dimensional array of mutable Documents Document[@Readonly] docs1; // docs2 is a mutable array whose elements are unmodifiable one-dimensional arrays of mutable Documents Document[][@Readonly] docs2 = new Document[2][@Readonly 12]; public void annotationInTypeCast(Object myObject) { String myString; // annotation in typecast myString = (@NonNull String)myObject; } public void annotationInInstanceOf(Object myString) { // type tests boolean isNonNull = myString instanceof @NonNull String; } public void annotationInObjectCreation() { Set myNonEmptyStringSet = new HashSet(); // object creation new @Readonly @NonEmpty ArrayList(myNonEmptyStringSet); } //type parameter bounds: //class Folder { ... } // t.b.d. // class inheritance abstract class UnmodifiableList<T> implements @Readonly List<@Readonly T> { } // throws clauses class TemperatureException extends Exception { } @interface Critical { }S void monitorTemperature() throws @Critical TemperatureException { throw new TemperatureException(); } {code} *Scope:* Extend ANTLR grammar (java.g) to handle these constructs * method return values, thrown exceptions (/) * generic types, including upper and lower bounds, wildcards (/) * nested classes (/) * arrays (/) and varargs (x) * type casting and instanceof (/) * "new" keyword - constructors, including nested and generic ones (/) * generic methods (/) * class/interface inheritance (/) * method and constructor references (x) * explicit "this" receiver (if required to handle) (x) |
New:
Provide support for instrumentation of annotations in all places where Java 8 allows developer put them. E.g annotation on types or in different parts of method declaration.
Please note that javac compiler itself does not understand such annotations - it's up to annotation processors to handle them correctly. However, as Clover does perform instrumentation "offline" (i.e. not inside the javac process), we must at least allow these annotations to be present (i.e. do not throw parse exceptions); Clover does not need to understand them, however. {code:java} void some (@RequestBody(required = false) String @Nullable [] arguments) { } static @interface Readonly { } static @interface NonNull { } static @interface NonEmpty { } // annotations for method receivers public int size() @Readonly { return 0; } // annotations inside generic type arguments Map<@NonNull String, @NonEmpty List<@Readonly Document>> files; // annotations inside arrays // docs1 is an unmodifiable one-dimensional array of mutable Documents Document[@Readonly] docs1; // docs2 is a mutable array whose elements are unmodifiable one-dimensional arrays of mutable Documents Document[][@Readonly] docs2 = new Document[2][@Readonly 12]; public void annotationInTypeCast(Object myObject) { String myString; // annotation in typecast myString = (@NonNull String)myObject; } public void annotationInInstanceOf(Object myString) { // type tests boolean isNonNull = myString instanceof @NonNull String; } public void annotationInObjectCreation() { Set myNonEmptyStringSet = new HashSet(); // object creation new @Readonly @NonEmpty ArrayList(myNonEmptyStringSet); } //type parameter bounds: //class Folder { ... } // t.b.d. // class inheritance abstract class UnmodifiableList<T> implements @Readonly List<@Readonly T> { } // throws clauses class TemperatureException extends Exception { } @interface Critical { }S void monitorTemperature() throws @Critical TemperatureException { throw new TemperatureException(); } {code} *Scope:* Extend ANTLR grammar (java.g) to handle these constructs * method return values, thrown exceptions (/) * generic types, including upper and lower bounds, wildcards (/) * nested classes (/) * arrays (/) and varargs (x) * type casting and instanceof (/) * "new" keyword - constructors, including nested and generic ones (/) * generic methods (/) * class/interface inheritance (/) * method and constructor references (x) *Out of scope:* * explicit "this" receiver (if required to handle) - tracked in |