< prev index next >

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

Print this page
rev 51958 : 8211122: Reduce the number of internal classes made accessible to jdk.unsupported
Reviewed-by: alanb, dfuchs, kvn
   1 /*
   2  * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  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 jdk.internal.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


   1 /*
   2  * Copyright (c) 2012, 2018, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  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.access.SharedSecrets;
  39 import jdk.internal.access.JavaLangAccess;
  40 import jdk.internal.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


< prev index next >