From df7bda5637a56c6d877a82d68e76027f7055fef2 Mon Sep 17 00:00:00 2001 From: Chris Beams Date: Tue, 6 Dec 2011 12:17:54 +0000 Subject: [PATCH] Constrain targets for @Filter declaration For clarity, add @Target({}) to definition of @Filter, constraining it to complex annotation composition only; i.e. it cannot be placed on any element, only within annotations, e.g. @ComponentScan(includeFilters=@Filter(...)) is legal, while @Filter public class MyType { } is not. Also, widen @Retention from SOURCE to RUNTIME, even though it is not technically necessary, as all parsing of @Filter annotations happens via ASM, i.e. at the source level. This change is made primarily for consistency (@ComponentScan's Retention is RUNTIME) and in avoidance of potential confusion or surprise on the part of those casually browsing the code. --- .../org/springframework/context/annotation/ComponentScan.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/org.springframework.context/src/main/java/org/springframework/context/annotation/ComponentScan.java b/org.springframework.context/src/main/java/org/springframework/context/annotation/ComponentScan.java index 2b0b7d011a..577ff17351 100644 --- a/org.springframework.context/src/main/java/org/springframework/context/annotation/ComponentScan.java +++ b/org.springframework.context/src/main/java/org/springframework/context/annotation/ComponentScan.java @@ -128,7 +128,8 @@ public @interface ComponentScan { * Declares the type filter to be used as an {@linkplain ComponentScan#includeFilters() * include filter} or {@linkplain ComponentScan#includeFilters() exclude filter}. */ - @Retention(RetentionPolicy.SOURCE) + @Retention(RetentionPolicy.RUNTIME) + @Target({}) @interface Filter { /** * The type of filter to use.