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

Print this page




 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


 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 }


 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 JLS 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 JLS 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 JLS section 8.8.3.
 371      */
 372     private static final int CONSTRUCTOR_MODIFIERS =
 373         Modifier.PUBLIC         | Modifier.PROTECTED    | Modifier.PRIVATE;
 374 
 375     /**
 376      * See JLS 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 JLS 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      * See JLS section 8.4.1.
 393      */
 394     private static final int PARAMETER_MODIFIERS =
 395         Modifier.FINAL;
 396 
 397     /**
 398      *
 399      */
 400     static final int ACCESS_MODIFIERS =
 401         Modifier.PUBLIC | Modifier.PROTECTED | Modifier.PRIVATE;
 402 
 403     /**
 404      * Return an {@code int} value OR-ing together the source language
 405      * modifiers that can be applied to a class.
 406      * @return an {@code int} value OR-ing together the source language
 407      * modifiers that can be applied to a class.
 408      *
 409      * @jls 8.1.1 Class Modifiers
 410      * @since 1.7
 411      */
 412     public static int classModifiers() {
 413         return CLASS_MODIFIERS;
 414     }
 415 
 416     /**
 417      * Return an {@code int} value OR-ing together the source language


 435      * @jls 8.8.3 Constructor Modifiers
 436      * @since 1.7
 437      */
 438     public static int constructorModifiers() {
 439         return CONSTRUCTOR_MODIFIERS;
 440     }
 441 
 442     /**
 443      * Return an {@code int} value OR-ing together the source language
 444      * modifiers that can be applied to a method.
 445      * @return an {@code int} value OR-ing together the source language
 446      * modifiers that can be applied to a method.
 447      *
 448      * @jls 8.4.3 Method Modifiers
 449      * @since 1.7
 450      */
 451     public static int methodModifiers() {
 452         return METHOD_MODIFIERS;
 453     }
 454 
 455     /**
 456      * Return an {@code int} value OR-ing together the source language
 457      * modifiers that can be applied to a parameter.
 458      * @return an {@code int} value OR-ing together the source language
 459      * modifiers that can be applied to a parameter.
 460      *
 461      * @jls 8.4.1 Formal Parameters
 462      * @since 1.8
 463      */
 464     public static int parameterModifiers() {
 465         return PARAMETER_MODIFIERS;
 466     }
 467 
 468     /**
 469      * Return an {@code int} value OR-ing together the source language
 470      * modifiers that can be applied to a field.
 471      * @return an {@code int} value OR-ing together the source language
 472      * modifiers that can be applied to a field.
 473      *
 474      * @jls 8.3.1 Field Modifiers
 475      * @since 1.7
 476      */
 477     public static int fieldModifiers() {
 478         return FIELD_MODIFIERS;
 479     }
 480 }