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

Print this page




 333     public static final int STRICT           = 0x00000800;
 334 
 335     // Bits not (yet) exposed in the public API either because they
 336     // have different meanings for fields and methods and there is no
 337     // way to distinguish between the two in this class, or because
 338     // they are not Java programming language keywords
 339     static final int BRIDGE    = 0x00000040;
 340     static final int VARARGS   = 0x00000080;
 341     static final int SYNTHETIC = 0x00001000;
 342     static final int ANNOTATION  = 0x00002000;
 343     static final int ENUM      = 0x00004000;
 344     static final int MANDATED  = 0x00008000;
 345     static boolean isSynthetic(int mod) {
 346       return (mod & SYNTHETIC) != 0;
 347     }
 348 
 349     static boolean isMandated(int mod) {
 350       return (mod & MANDATED) != 0;
 351     }
 352 










 353     /**
 354      * See JLSv3 section 8.1.1.

 355      */
 356     private static final int CLASS_MODIFIERS =
 357         Modifier.PUBLIC         | Modifier.PROTECTED    | Modifier.PRIVATE |
 358         Modifier.ABSTRACT       | Modifier.STATIC       | Modifier.FINAL   |
 359         Modifier.STRICT;
 360 
 361     /**
 362      * See JLSv3 section 9.1.1.

 363      */
 364     private static final int INTERFACE_MODIFIERS =
 365         Modifier.PUBLIC         | Modifier.PROTECTED    | Modifier.PRIVATE |
 366         Modifier.ABSTRACT       | Modifier.STATIC       | Modifier.STRICT;
 367 
 368 
 369     /**
 370      * See JLSv3 section 8.8.3.

 371      */
 372     private static final int CONSTRUCTOR_MODIFIERS =
 373         Modifier.PUBLIC         | Modifier.PROTECTED    | Modifier.PRIVATE;
 374 
 375     /**
 376      * See JLSv3 section 8.4.3.

 377      */
 378     private static final int METHOD_MODIFIERS =
 379         Modifier.PUBLIC         | Modifier.PROTECTED    | Modifier.PRIVATE |
 380         Modifier.ABSTRACT       | Modifier.STATIC       | Modifier.FINAL   |
 381         Modifier.SYNCHRONIZED   | Modifier.NATIVE       | Modifier.STRICT;
 382 
 383     /**
 384      * See JLSv3 section 8.3.1.

 385      */
 386     private static final int FIELD_MODIFIERS =
 387         Modifier.PUBLIC         | Modifier.PROTECTED    | Modifier.PRIVATE |
 388         Modifier.STATIC         | Modifier.FINAL        | Modifier.TRANSIENT |
 389         Modifier.VOLATILE;
 390 
 391     /**







 392      *
 393      */
 394     static final int ACCESS_MODIFIERS =
 395         Modifier.PUBLIC | Modifier.PROTECTED | Modifier.PRIVATE;
 396 
 397     /**
 398      * Return an {@code int} value OR-ing together the source language
 399      * modifiers that can be applied to a class.
 400      * @return an {@code int} value OR-ing together the source language
 401      * modifiers that can be applied to a class.
 402      *
 403      * @jls 8.1.1 Class Modifiers
 404      * @since 1.7
 405      */
 406     public static int classModifiers() {
 407         return CLASS_MODIFIERS;
 408     }
 409 
 410     /**
 411      * Return an {@code int} value OR-ing together the source language
 412      * modifiers that can be applied to an interface.
 413      * @return an {@code int} value OR-ing together the source language
 414      * modifiers that can be applied to an inteface.
 415      *
 416      * @jls 9.1.1 Interface Modifiers
 417      * @since 1.7
 418      */
 419     public static int interfaceModifiers() {
 420         return INTERFACE_MODIFIERS;
 421     }
 422 
 423     /**
 424      * Return an {@code int} value OR-ing together the source language
 425      * modifiers that can be applied to a constructor.
 426      * @return an {@code int} value OR-ing together the source language
 427      * modifiers that can be applied to a constructor.
 428      *
 429      * @jls 8.8.3 Constructor Modifiers
 430      * @since 1.7
 431      */
 432     public static int constructorModifiers() {
 433         return CONSTRUCTOR_MODIFIERS;
 434     }
 435 
 436     /**
 437      * Return an {@code int} value OR-ing together the source language
 438      * modifiers that can be applied to a method.
 439      * @return an {@code int} value OR-ing together the source language
 440      * modifiers that can be applied to a method.
 441      *
 442      * @jls 8.4.3 Method Modifiers
 443      * @since 1.7
 444      */
 445     public static int methodModifiers() {
 446         return METHOD_MODIFIERS;
 447     }
 448 
 449 
 450     /**
 451      * Return an {@code int} value OR-ing together the source language
 452      * modifiers that can be applied to a field.
 453      * @return an {@code int} value OR-ing together the source language
 454      * modifiers that can be applied to a field.
 455      *
 456      * @jls 8.3.1 Field Modifiers
 457      * @since 1.7
 458      */
 459     public static int fieldModifiers() {
 460         return FIELD_MODIFIERS;













 461     }
 462 }


 333     public static final int STRICT           = 0x00000800;
 334 
 335     // Bits not (yet) exposed in the public API either because they
 336     // have different meanings for fields and methods and there is no
 337     // way to distinguish between the two in this class, or because
 338     // they are not Java programming language keywords
 339     static final int BRIDGE    = 0x00000040;
 340     static final int VARARGS   = 0x00000080;
 341     static final int SYNTHETIC = 0x00001000;
 342     static final int ANNOTATION  = 0x00002000;
 343     static final int ENUM      = 0x00004000;
 344     static final int MANDATED  = 0x00008000;
 345     static boolean isSynthetic(int mod) {
 346       return (mod & SYNTHETIC) != 0;
 347     }
 348 
 349     static boolean isMandated(int mod) {
 350       return (mod & MANDATED) != 0;
 351     }
 352 
 353     // Note on the FOO_MODIFIERS fields and fooModifiers() methods:
 354     // the sets of modifiers are not guaranteed to be constants
 355     // across time and Java SE releases. Therefore, it would not be
 356     // appropriate to expose an external interface to this information
 357     // that would allow the values to be treated as Java-level
 358     // constants since the values could be constant folded and updates
 359     // to the sets of modifiers missed. Thus, the fooModifiers()
 360     // methods return an unchanging values for a given release, but a
 361     // value that can change over time.
 362 
 363     /**
 364      * The Java source modifiers that can be applied to a class.
 365      * @jls 8.1.1 Class Modifiers
 366      */
 367     private static final int CLASS_MODIFIERS =
 368         Modifier.PUBLIC         | Modifier.PROTECTED    | Modifier.PRIVATE |
 369         Modifier.ABSTRACT       | Modifier.STATIC       | Modifier.FINAL   |
 370         Modifier.STRICT;
 371 
 372     /**
 373      * The Java source modifiers that can be applied to an interface.
 374      * @jls 9.1.1 Interface Modifiers
 375      */
 376     private static final int INTERFACE_MODIFIERS =
 377         Modifier.PUBLIC         | Modifier.PROTECTED    | Modifier.PRIVATE |
 378         Modifier.ABSTRACT       | Modifier.STATIC       | Modifier.STRICT;
 379 
 380 
 381     /**
 382      * The Java source modifiers that can be applied to a constructor.
 383      * @jls 8.8.3 Constructor Modifiers
 384      */
 385     private static final int CONSTRUCTOR_MODIFIERS =
 386         Modifier.PUBLIC         | Modifier.PROTECTED    | Modifier.PRIVATE;
 387 
 388     /**
 389      * The Java source modifiers that can be applied to a method.
 390      * @jls8.4.3  Method Modifiers
 391      */
 392     private static final int METHOD_MODIFIERS =
 393         Modifier.PUBLIC         | Modifier.PROTECTED    | Modifier.PRIVATE |
 394         Modifier.ABSTRACT       | Modifier.STATIC       | Modifier.FINAL   |
 395         Modifier.SYNCHRONIZED   | Modifier.NATIVE       | Modifier.STRICT;
 396 
 397     /**
 398      * The Java source modifiers that can be applied to a field.
 399      * @jls 8.3.1  Field Modifiers
 400      */
 401     private static final int FIELD_MODIFIERS =
 402         Modifier.PUBLIC         | Modifier.PROTECTED    | Modifier.PRIVATE |
 403         Modifier.STATIC         | Modifier.FINAL        | Modifier.TRANSIENT |
 404         Modifier.VOLATILE;
 405 
 406     /**
 407      * The Java source modifiers that can be applied to a method or constructor parameter.
 408      * @jls 8.4.1 Formal Parameters
 409      */
 410     private static final int PARAMETER_MODIFIERS =
 411         Modifier.FINAL;
 412 
 413     /**
 414      *
 415      */
 416     static final int ACCESS_MODIFIERS =
 417         Modifier.PUBLIC | Modifier.PROTECTED | Modifier.PRIVATE;
 418 
 419     /**
 420      * Return an {@code int} value OR-ing together the source language
 421      * modifiers that can be applied to a class.
 422      * @return an {@code int} value OR-ing together the source language
 423      * modifiers that can be applied to a class.
 424      *
 425      * @jls 8.1.1 Class Modifiers
 426      * @since 1.7
 427      */
 428     public static int classModifiers() {
 429         return CLASS_MODIFIERS;
 430     }
 431 
 432     /**
 433      * Return an {@code int} value OR-ing together the source language
 434      * modifiers that can be applied to an interface.
 435      * @return an {@code int} value OR-ing together the source language
 436      * modifiers that can be applied to an interface.
 437      *
 438      * @jls 9.1.1 Interface Modifiers
 439      * @since 1.7
 440      */
 441     public static int interfaceModifiers() {
 442         return INTERFACE_MODIFIERS;
 443     }
 444 
 445     /**
 446      * Return an {@code int} value OR-ing together the source language
 447      * modifiers that can be applied to a constructor.
 448      * @return an {@code int} value OR-ing together the source language
 449      * modifiers that can be applied to a constructor.
 450      *
 451      * @jls 8.8.3 Constructor Modifiers
 452      * @since 1.7
 453      */
 454     public static int constructorModifiers() {
 455         return CONSTRUCTOR_MODIFIERS;
 456     }
 457 
 458     /**
 459      * Return an {@code int} value OR-ing together the source language
 460      * modifiers that can be applied to a method.
 461      * @return an {@code int} value OR-ing together the source language
 462      * modifiers that can be applied to a method.
 463      *
 464      * @jls 8.4.3 Method Modifiers
 465      * @since 1.7
 466      */
 467     public static int methodModifiers() {
 468         return METHOD_MODIFIERS;
 469     }
 470 

 471     /**
 472      * Return an {@code int} value OR-ing together the source language
 473      * modifiers that can be applied to a field.
 474      * @return an {@code int} value OR-ing together the source language
 475      * modifiers that can be applied to a field.
 476      *
 477      * @jls 8.3.1 Field Modifiers
 478      * @since 1.7
 479      */
 480     public static int fieldModifiers() {
 481         return FIELD_MODIFIERS;
 482     }
 483 
 484     /**
 485      * Return an {@code int} value OR-ing together the source language
 486      * modifiers that can be applied to a parameter.
 487      * @return an {@code int} value OR-ing together the source language
 488      * modifiers that can be applied to a parameter.
 489      *
 490      * @jls 8.4.1 Formal Parameters
 491      * @since 1.8
 492      */
 493     public static int parameterModifiers() {
 494         return PARAMETER_MODIFIERS;
 495     }
 496 }