438 /** Utility method to query the modifier flags of this member. */ 439 public boolean isVolatile() { 440 return Modifier.isVolatile(flags); 441 } 442 /** Utility method to query the modifier flags of this member. */ 443 public boolean isAbstract() { 444 return Modifier.isAbstract(flags); 445 } 446 /** Utility method to query the modifier flags of this member. */ 447 public boolean isNative() { 448 return Modifier.isNative(flags); 449 } 450 // let the rest (native, volatile, transient, etc.) be tested via Modifier.isFoo 451 452 // unofficial modifier flags, used by HotSpot: 453 static final int BRIDGE = 0x00000040; 454 static final int VARARGS = 0x00000080; 455 static final int SYNTHETIC = 0x00001000; 456 static final int ANNOTATION = 0x00002000; 457 static final int ENUM = 0x00004000; 458 static final int FLATTENABLE = 0x00000100; 459 static final int FLATTENED = 0x00008000; 460 461 /** Utility method to query the modifier flags of this member; returns false if the member is not a method. */ 462 public boolean isBridge() { 463 return testAllFlags(IS_METHOD | BRIDGE); 464 } 465 /** Utility method to query the modifier flags of this member; returns false if the member is not a method. */ 466 public boolean isVarargs() { 467 return testAllFlags(VARARGS) && isInvocable(); 468 } 469 /** Utility method to query the modifier flags of this member; returns false if the member is not a method. */ 470 public boolean isSynthetic() { 471 return testAllFlags(SYNTHETIC); 472 } 473 474 /* 475 * Query whether this member is a flattenable field. 476 * 477 * A flattenable field whose type must be of value class with ACC_FLATTENABLE flag set. 478 * A field of value type may or may not be flattenable. 479 */ 480 public boolean isFlattenable() { return (flags & FLATTENABLE) == FLATTENABLE; } 481 482 /** Query whether this member is a flat value field */ 483 public boolean isFlatValue() { return (flags & FLATTENED) == FLATTENED; } 484 485 /** Query whether this member can be assigned to null. */ 486 public boolean canBeNull() { return !isFlattenable(); } 487 488 static final String CONSTRUCTOR_NAME = "<init>"; // the ever-popular 489 490 // modifiers exported by the JVM: 491 static final int RECOGNIZED_MODIFIERS = 0xFFFF; 492 493 // private flags, not part of RECOGNIZED_MODIFIERS: 494 static final int 495 IS_METHOD = MN_IS_METHOD, // method (not constructor) 496 IS_CONSTRUCTOR = MN_IS_CONSTRUCTOR, // constructor 497 IS_FIELD = MN_IS_FIELD, // field 498 IS_TYPE = MN_IS_TYPE, // nested type 499 CALLER_SENSITIVE = MN_CALLER_SENSITIVE; // @CallerSensitive annotation detected 500 501 static final int ALL_ACCESS = Modifier.PUBLIC | Modifier.PRIVATE | Modifier.PROTECTED; 502 static final int ALL_KINDS = IS_METHOD | IS_CONSTRUCTOR | IS_FIELD | IS_TYPE; 503 static final int IS_INVOCABLE = IS_METHOD | IS_CONSTRUCTOR; 504 static final int IS_FIELD_OR_METHOD = IS_METHOD | IS_FIELD; 505 static final int SEARCH_ALL_SUPERS = MN_SEARCH_SUPERCLASSES | MN_SEARCH_INTERFACES; 506 | 438 /** Utility method to query the modifier flags of this member. */ 439 public boolean isVolatile() { 440 return Modifier.isVolatile(flags); 441 } 442 /** Utility method to query the modifier flags of this member. */ 443 public boolean isAbstract() { 444 return Modifier.isAbstract(flags); 445 } 446 /** Utility method to query the modifier flags of this member. */ 447 public boolean isNative() { 448 return Modifier.isNative(flags); 449 } 450 // let the rest (native, volatile, transient, etc.) be tested via Modifier.isFoo 451 452 // unofficial modifier flags, used by HotSpot: 453 static final int BRIDGE = 0x00000040; 454 static final int VARARGS = 0x00000080; 455 static final int SYNTHETIC = 0x00001000; 456 static final int ANNOTATION = 0x00002000; 457 static final int ENUM = 0x00004000; 458 static final int FLATTENED = 0x00008000; 459 460 /** Utility method to query the modifier flags of this member; returns false if the member is not a method. */ 461 public boolean isBridge() { 462 return testAllFlags(IS_METHOD | BRIDGE); 463 } 464 /** Utility method to query the modifier flags of this member; returns false if the member is not a method. */ 465 public boolean isVarargs() { 466 return testAllFlags(VARARGS) && isInvocable(); 467 } 468 /** Utility method to query the modifier flags of this member; returns false if the member is not a method. */ 469 public boolean isSynthetic() { 470 return testAllFlags(SYNTHETIC); 471 } 472 473 /** Query whether this member is a flattened field */ 474 public boolean isFlattened() { return (flags & FLATTENED) == FLATTENED; } 475 476 /** Query whether this member can be assigned to null. */ 477 public boolean canBeNull() { 478 if (isField()) { 479 Class<?> type = getFieldType(); 480 return type == type.asBoxType(); 481 } 482 return false; 483 } 484 485 static final String CONSTRUCTOR_NAME = "<init>"; // the ever-popular 486 487 // modifiers exported by the JVM: 488 static final int RECOGNIZED_MODIFIERS = 0xFFFF; 489 490 // private flags, not part of RECOGNIZED_MODIFIERS: 491 static final int 492 IS_METHOD = MN_IS_METHOD, // method (not constructor) 493 IS_CONSTRUCTOR = MN_IS_CONSTRUCTOR, // constructor 494 IS_FIELD = MN_IS_FIELD, // field 495 IS_TYPE = MN_IS_TYPE, // nested type 496 CALLER_SENSITIVE = MN_CALLER_SENSITIVE; // @CallerSensitive annotation detected 497 498 static final int ALL_ACCESS = Modifier.PUBLIC | Modifier.PRIVATE | Modifier.PROTECTED; 499 static final int ALL_KINDS = IS_METHOD | IS_CONSTRUCTOR | IS_FIELD | IS_TYPE; 500 static final int IS_INVOCABLE = IS_METHOD | IS_CONSTRUCTOR; 501 static final int IS_FIELD_OR_METHOD = IS_METHOD | IS_FIELD; 502 static final int SEARCH_ALL_SUPERS = MN_SEARCH_SUPERCLASSES | MN_SEARCH_INTERFACES; 503 |