< prev index next >

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

Print this page
rev 60127 : 8249205: Remove unnecessary trademark symbols


  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      * Do not call.
  48      */
  49     private Modifier() {throw new AssertionError();}
  50 
  51 
  52     /**
  53      * Return {@code true} if the integer argument includes the
  54      * {@code public} modifier, {@code false} otherwise.
  55      *
  56      * @param   mod a set of modifiers


 184     /**
 185      * Return {@code true} if the integer argument includes the
 186      * {@code strictfp} modifier, {@code false} otherwise.
 187      *
 188      * @param   mod a set of modifiers
 189      * @return {@code true} if {@code mod} includes the
 190      * {@code strictfp} modifier; {@code false} otherwise.
 191      */
 192     public static boolean isStrict(int mod) {
 193         return (mod & STRICT) != 0;
 194     }
 195 
 196     /**
 197      * Return a string describing the access modifier flags in
 198      * the specified modifier. For example:
 199      * <blockquote><pre>
 200      *    public final synchronized strictfp
 201      * </pre></blockquote>
 202      * The modifier names are returned in an order consistent with the
 203      * suggested modifier orderings given in sections 8.1.1, 8.3.1, 8.4.3, 8.8.3, and 9.1.1 of
 204      * <cite>The Java&trade; Language Specification</cite>.
 205      * The full modifier ordering used by this method is:
 206      * <blockquote> {@code
 207      * public protected private abstract static final transient
 208      * volatile synchronized native strictfp
 209      * interface } </blockquote>
 210      * The {@code interface} modifier discussed in this class is
 211      * not a true modifier in the Java language and it appears after
 212      * all other modifiers listed by this method.  This method may
 213      * return a string of modifiers that are not valid modifiers of a
 214      * Java entity; in other words, no checking is done on the
 215      * possible validity of the combination of modifiers represented
 216      * by the input.
 217      *
 218      * Note that to perform such checking for a known kind of entity,
 219      * such as a constructor or method, first AND the argument of
 220      * {@code toString} with the appropriate mask from a method like
 221      * {@link #constructorModifiers} or {@link #methodModifiers}.
 222      *
 223      * @param   mod a set of modifiers
 224      * @return  a string representation of the set of modifiers


 230         if ((mod & PUBLIC) != 0)        sj.add("public");
 231         if ((mod & PROTECTED) != 0)     sj.add("protected");
 232         if ((mod & PRIVATE) != 0)       sj.add("private");
 233 
 234         /* Canonical order */
 235         if ((mod & ABSTRACT) != 0)      sj.add("abstract");
 236         if ((mod & STATIC) != 0)        sj.add("static");
 237         if ((mod & FINAL) != 0)         sj.add("final");
 238         if ((mod & TRANSIENT) != 0)     sj.add("transient");
 239         if ((mod & VOLATILE) != 0)      sj.add("volatile");
 240         if ((mod & SYNCHRONIZED) != 0)  sj.add("synchronized");
 241         if ((mod & NATIVE) != 0)        sj.add("native");
 242         if ((mod & STRICT) != 0)        sj.add("strictfp");
 243         if ((mod & INTERFACE) != 0)     sj.add("interface");
 244 
 245         return sj.toString();
 246     }
 247 
 248     /*
 249      * Access modifier flag constants from tables 4.1, 4.4, 4.5, and 4.7 of
 250      * <cite>The Java&trade; Virtual Machine Specification</cite>
 251      */
 252 
 253     /**
 254      * The {@code int} value representing the {@code public}
 255      * modifier.
 256      */
 257     public static final int PUBLIC           = 0x00000001;
 258 
 259     /**
 260      * The {@code int} value representing the {@code private}
 261      * modifier.
 262      */
 263     public static final int PRIVATE          = 0x00000002;
 264 
 265     /**
 266      * The {@code int} value representing the {@code protected}
 267      * modifier.
 268      */
 269     public static final int PROTECTED        = 0x00000004;
 270 




  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 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      * Do not call.
  48      */
  49     private Modifier() {throw new AssertionError();}
  50 
  51 
  52     /**
  53      * Return {@code true} if the integer argument includes the
  54      * {@code public} modifier, {@code false} otherwise.
  55      *
  56      * @param   mod a set of modifiers


 184     /**
 185      * Return {@code true} if the integer argument includes the
 186      * {@code strictfp} modifier, {@code false} otherwise.
 187      *
 188      * @param   mod a set of modifiers
 189      * @return {@code true} if {@code mod} includes the
 190      * {@code strictfp} modifier; {@code false} otherwise.
 191      */
 192     public static boolean isStrict(int mod) {
 193         return (mod & STRICT) != 0;
 194     }
 195 
 196     /**
 197      * Return a string describing the access modifier flags in
 198      * the specified modifier. For example:
 199      * <blockquote><pre>
 200      *    public final synchronized strictfp
 201      * </pre></blockquote>
 202      * The modifier names are returned in an order consistent with the
 203      * suggested modifier orderings given in sections 8.1.1, 8.3.1, 8.4.3, 8.8.3, and 9.1.1 of
 204      * <cite>The Java Language Specification</cite>.
 205      * The full modifier ordering used by this method is:
 206      * <blockquote> {@code
 207      * public protected private abstract static final transient
 208      * volatile synchronized native strictfp
 209      * interface } </blockquote>
 210      * The {@code interface} modifier discussed in this class is
 211      * not a true modifier in the Java language and it appears after
 212      * all other modifiers listed by this method.  This method may
 213      * return a string of modifiers that are not valid modifiers of a
 214      * Java entity; in other words, no checking is done on the
 215      * possible validity of the combination of modifiers represented
 216      * by the input.
 217      *
 218      * Note that to perform such checking for a known kind of entity,
 219      * such as a constructor or method, first AND the argument of
 220      * {@code toString} with the appropriate mask from a method like
 221      * {@link #constructorModifiers} or {@link #methodModifiers}.
 222      *
 223      * @param   mod a set of modifiers
 224      * @return  a string representation of the set of modifiers


 230         if ((mod & PUBLIC) != 0)        sj.add("public");
 231         if ((mod & PROTECTED) != 0)     sj.add("protected");
 232         if ((mod & PRIVATE) != 0)       sj.add("private");
 233 
 234         /* Canonical order */
 235         if ((mod & ABSTRACT) != 0)      sj.add("abstract");
 236         if ((mod & STATIC) != 0)        sj.add("static");
 237         if ((mod & FINAL) != 0)         sj.add("final");
 238         if ((mod & TRANSIENT) != 0)     sj.add("transient");
 239         if ((mod & VOLATILE) != 0)      sj.add("volatile");
 240         if ((mod & SYNCHRONIZED) != 0)  sj.add("synchronized");
 241         if ((mod & NATIVE) != 0)        sj.add("native");
 242         if ((mod & STRICT) != 0)        sj.add("strictfp");
 243         if ((mod & INTERFACE) != 0)     sj.add("interface");
 244 
 245         return sj.toString();
 246     }
 247 
 248     /*
 249      * Access modifier flag constants from tables 4.1, 4.4, 4.5, and 4.7 of
 250      * <cite>The Java Virtual Machine Specification</cite>
 251      */
 252 
 253     /**
 254      * The {@code int} value representing the {@code public}
 255      * modifier.
 256      */
 257     public static final int PUBLIC           = 0x00000001;
 258 
 259     /**
 260      * The {@code int} value representing the {@code private}
 261      * modifier.
 262      */
 263     public static final int PRIVATE          = 0x00000002;
 264 
 265     /**
 266      * The {@code int} value representing the {@code protected}
 267      * modifier.
 268      */
 269     public static final int PROTECTED        = 0x00000004;
 270 


< prev index next >