Uploaded image for project: 'Clover'
  1. Clover
  2. CLOV-1839

Provide instrumentation support for Annotations in all places Java 8 allows to

    • Our product teams collect and evaluate feedback from a number of different sources. To learn more about how we use customer feedback in the planning process, check out our new feature policy.

      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

            Katherine Yabut made changes -
            Workflow Original: JAC Suggestion Workflow [ 3342208 ] New: JAC Suggestion Workflow 3 [ 3584724 ]
            Status Original: RESOLVED [ 5 ] New: Closed [ 6 ]
            Michael Andreacchio made changes -
            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 ]
            Michael Andreacchio made changes -
            Resolution New: Won't Fix [ 2 ]
            Status Original: Open [ 1 ] New: Closed [ 6 ]
            Marek Parfianowicz made changes -
            Assignee Original: Marek Parfianowicz [ mparfianowicz ]
            Marek Parfianowicz made changes -
            Fix Version/s New: 4.2.0 [ 56395 ]
            Fix Version/s Original: 4.3.0 [ 60690 ]
            Marek Parfianowicz made changes -
            Remote Link Original: This issue links to "Page (Extranet)" [ 162001 ]
            Marek Parfianowicz made changes -
            Labels New: jdk8
            Marek Parfianowicz made changes -
            Link New: This issue is duplicated by CLOV-1979 [ CLOV-1979 ]
            Marek Parfianowicz made changes -
            Assignee New: Marek Parfianowicz [ mparfianowicz ]
            Marek Parfianowicz made changes -
            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 CLOV-1934

              Unassigned Unassigned
              glewandowski Grzegorz Lewandowski
              Votes:
              4 Vote for this issue
              Watchers:
              8 Start watching this issue

                Created:
                Updated:
                Resolved: