< prev index next >

src/java.base/share/classes/java/lang/reflect/Modifier.java

Print this page




   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 java.lang.reflect;
  27 
  28 import java.security.AccessController;
  29 import java.util.StringJoiner;
  30 import jdk.internal.reflect.LangReflectAccess;
  31 import jdk.internal.reflect.ReflectionFactory;
  32 
  33 /**
  34  * The Modifier class provides {@code static} methods and
  35  * constants to decode class and member access modifiers.  The sets of
  36  * modifiers are represented as integers with distinct bit positions
  37  * representing different modifiers.  The values for the constants
  38  * representing the modifiers are taken from the tables in sections 4.1, 4.4, 4.5, and 4.7 of
  39  * <cite>The Java&trade; Virtual Machine Specification</cite>.
  40  *
  41  * @see Class#getModifiers()
  42  * @see Member#getModifiers()
  43  *
  44  * @author Nakul Saraiya
  45  * @author Kenneth Russell
  46  * @since 1.1
  47  */
  48 public class Modifier {
  49 
  50     /*
  51      * Bootstrapping protocol between java.lang and java.lang.reflect
  52      *  packages
  53      */
  54     static {
  55         ReflectionFactory factory = AccessController.doPrivileged(
  56                 new ReflectionFactory.GetReflectionFactoryAction());
  57         factory.setLangReflectAccess(new java.lang.reflect.ReflectAccess());
  58     }
  59 
  60     /**
  61      * Return {@code true} if the integer argument includes the
  62      * {@code public} modifier, {@code false} otherwise.
  63      *
  64      * @param   mod a set of modifiers
  65      * @return {@code true} if {@code mod} includes the
  66      * {@code public} modifier; {@code false} otherwise.
  67      */
  68     public static boolean isPublic(int mod) {
  69         return (mod & PUBLIC) != 0;
  70     }
  71 
  72     /**
  73      * Return {@code true} if the integer argument includes the
  74      * {@code private} modifier, {@code false} otherwise.
  75      *
  76      * @param   mod a set of modifiers
  77      * @return {@code true} if {@code mod} includes the
  78      * {@code private} modifier; {@code false} otherwise.
  79      */




   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 java.lang.reflect;
  27 

  28 import java.util.StringJoiner;


  29 
  30 /**
  31  * The Modifier class provides {@code static} methods and
  32  * constants to decode class and member access modifiers.  The sets of
  33  * modifiers are represented as integers with distinct bit positions
  34  * representing different modifiers.  The values for the constants
  35  * representing the modifiers are taken from the tables in sections 4.1, 4.4, 4.5, and 4.7 of
  36  * <cite>The Java&trade; Virtual Machine Specification</cite>.
  37  *
  38  * @see Class#getModifiers()
  39  * @see Member#getModifiers()
  40  *
  41  * @author Nakul Saraiya
  42  * @author Kenneth Russell
  43  * @since 1.1
  44  */
  45 public class Modifier {
  46 










  47     /**
  48      * Return {@code true} if the integer argument includes the
  49      * {@code public} modifier, {@code false} otherwise.
  50      *
  51      * @param   mod a set of modifiers
  52      * @return {@code true} if {@code mod} includes the
  53      * {@code public} modifier; {@code false} otherwise.
  54      */
  55     public static boolean isPublic(int mod) {
  56         return (mod & PUBLIC) != 0;
  57     }
  58 
  59     /**
  60      * Return {@code true} if the integer argument includes the
  61      * {@code private} modifier, {@code false} otherwise.
  62      *
  63      * @param   mod a set of modifiers
  64      * @return {@code true} if {@code mod} includes the
  65      * {@code private} modifier; {@code false} otherwise.
  66      */


< prev index next >