src/java.base/share/classes/sun/reflect/annotation/AnnotationSupport.java

Print this page




  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any
  23  * questions.
  24  */
  25 
  26 package sun.reflect.annotation;
  27 
  28 import java.lang.annotation.*;
  29 import java.lang.reflect.*;
  30 import java.security.AccessController;
  31 import java.security.PrivilegedAction;
  32 import java.util.ArrayList;
  33 import java.util.Arrays;
  34 import java.util.List;
  35 import java.util.Map;
  36 import java.util.Objects;
  37 
  38 import sun.misc.JavaLangAccess;
  39 import sun.reflect.LangReflectAccess;
  40 import sun.reflect.ReflectionFactory;
  41 
  42 public final class AnnotationSupport {
  43     private static final JavaLangAccess LANG_ACCESS = sun.misc.SharedSecrets.getJavaLangAccess();
  44 
  45     /**
  46      * Finds and returns all annotations in {@code annotations} matching
  47      * the given {@code annoClass}.
  48      *
  49      * Apart from annotations directly present in {@code annotations} this
  50      * method searches for annotations inside containers i.e. indirectly
  51      * present annotations.
  52      *
  53      * The order of the elements in the array returned depends on the iteration
  54      * order of the provided map. Specifically, the directly present annotations
  55      * come before the indirectly present annotations if and only if the
  56      * directly present annotations come before the indirectly present
  57      * annotations in the map.
  58      *
  59      * @param annotations the {@code Map} in which to search for annotations
  60      * @param annoClass the type of annotation to search for
  61      *
  62      * @return an array of instances of {@code annoClass} or an empty
  63      *         array if none were found




  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any
  23  * questions.
  24  */
  25 
  26 package sun.reflect.annotation;
  27 
  28 import java.lang.annotation.*;
  29 import java.lang.reflect.*;
  30 import java.security.AccessController;
  31 import java.security.PrivilegedAction;
  32 import java.util.ArrayList;
  33 import java.util.Arrays;
  34 import java.util.List;
  35 import java.util.Map;
  36 import java.util.Objects;
  37 
  38 import jdk.internal.misc.SharedSecrets;
  39 import jdk.internal.misc.JavaLangAccess;
  40 import sun.reflect.ReflectionFactory;
  41 
  42 public final class AnnotationSupport {
  43     private static final JavaLangAccess LANG_ACCESS = SharedSecrets.getJavaLangAccess();
  44 
  45     /**
  46      * Finds and returns all annotations in {@code annotations} matching
  47      * the given {@code annoClass}.
  48      *
  49      * Apart from annotations directly present in {@code annotations} this
  50      * method searches for annotations inside containers i.e. indirectly
  51      * present annotations.
  52      *
  53      * The order of the elements in the array returned depends on the iteration
  54      * order of the provided map. Specifically, the directly present annotations
  55      * come before the indirectly present annotations if and only if the
  56      * directly present annotations come before the indirectly present
  57      * annotations in the map.
  58      *
  59      * @param annotations the {@code Map} in which to search for annotations
  60      * @param annoClass the type of annotation to search for
  61      *
  62      * @return an array of instances of {@code annoClass} or an empty
  63      *         array if none were found