Class Modifier
java.lang.Object
java.lang.reflect.Modifier
Provides
static methods and constants to decode classfile access and property flags with corresponding
Java
language modifiers.
Modifier interpretation is context-sensitive: for example, the isSynchronized check is only meaningful for method
access flags, representing the synchronized modifier on methods.
A true return on a field access flags does not indicate that field
has the synchronized modifier.
- API Note:
- The mappings from classfile access flags to Java language modifiers have diverged during the evolution of the Java SE Platform. Many access flags and Java language modifiers are not represented in this class; the mappings represented in this class are not sufficient to reconstruct Java langugage modifiers from access flags, and vice versa.
- Since:
- 1.1
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intTheintvalue representing theabstractmodifier.static final intTheintvalue representing thefinalmodifier.static final intTheintvalue representing theinterfacemodifier.static final intTheintvalue representing thenativemodifier.static final intTheintvalue representing theprivatemodifier.static final intTheintvalue representing theprotectedmodifier.static final intTheintvalue representing thepublicmodifier.static final intTheintvalue representing thestaticmodifier.static final intTheintvalue representing thestrictfpmodifier.static final intTheintvalue representing thesynchronizedmodifier.static final intTheintvalue representing thetransientmodifier.static final intTheintvalue representing thevolatilemodifier. -
Method Summary
Modifier and TypeMethodDescriptionstatic intDeprecated.static intDeprecated.This method was originally created to support the now-deprecatedModifier::toString(int)method.static intDeprecated.This method was originally created to support the now-deprecatedModifier::toString(int)method.static intDeprecated.This method was originally created to support the now-deprecatedModifier::toString(int)method.static booleanisAbstract(int mod) Returntrueif the integer argument includes theabstractmodifier,falseotherwise.static booleanisFinal(int mod) Returntrueif the integer argument includes thefinalmodifier,falseotherwise.static booleanisInterface(int mod) Returntrueif the integer argument includes theinterfacemodifier,falseotherwise.static booleanisNative(int mod) Returntrueif the integer argument includes thenativemodifier,falseotherwise.static booleanisPrivate(int mod) Returntrueif the integer argument includes theprivatemodifier,falseotherwise.static booleanisProtected(int mod) Returntrueif the integer argument includes theprotectedmodifier,falseotherwise.static booleanisPublic(int mod) Returntrueif the integer argument includes thepublicmodifier,falseotherwise.static booleanisStatic(int mod) Returntrueif the integer argument includes thestaticmodifier,falseotherwise.static booleanisStrict(int mod) Returntrueif the integer argument includes thestrictfpmodifier,falseotherwise.static booleanisSynchronized(int mod) Returntrueif the integer argument includes thesynchronizedmodifier,falseotherwise.static booleanisTransient(int mod) Returntrueif the integer argument includes thetransientmodifier,falseotherwise.static booleanisVolatile(int mod) Returntrueif the integer argument includes thevolatilemodifier,falseotherwise.static intDeprecated.This method was originally created to support the now-deprecatedModifier::toString(int)method.static intDeprecated.This method was originally created to support the now-deprecatedModifier::toString(int)method.static StringtoString(int mod) Deprecated.Modifier interpretation is context-sensitive; this API may report an incomplete or incorrect list of Java language modifiers.Methods declared in class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitModifier and TypeMethodDescriptionprotected Objectclone()Creates and returns a copy of this object.booleanIndicates whether some other object is "equal to" this one.protected voidfinalize()Deprecated, for removal: This API element is subject to removal in a future version.Finalization is deprecated and subject to removal in a future release.final Class<?> getClass()Returns the runtime class of thisObject.inthashCode()Returns a hash code value for this object.final voidnotify()Wakes up a single thread that is waiting on this object's monitor.final voidWakes up all threads that are waiting on this object's monitor.toString()Returns a string representation of the object.final voidwait()Causes the current thread to wait until it is awakened, typically by being notified or interrupted.final voidwait(long timeoutMillis) Causes the current thread to wait until it is awakened, typically by being notified or interrupted, or until a certain amount of real time has elapsed.final voidwait(long timeoutMillis, int nanos) Causes the current thread to wait until it is awakened, typically by being notified or interrupted, or until a certain amount of real time has elapsed.
-
Field Details
-
PUBLIC
public static final int PUBLICTheintvalue representing thepublicmodifier.- See Also:
-
PRIVATE
public static final int PRIVATETheintvalue representing theprivatemodifier.- See Also:
-
PROTECTED
public static final int PROTECTEDTheintvalue representing theprotectedmodifier.- See Also:
-
STATIC
public static final int STATICTheintvalue representing thestaticmodifier.- See Also:
-
FINAL
public static final int FINALTheintvalue representing thefinalmodifier.- See Also:
-
SYNCHRONIZED
public static final int SYNCHRONIZEDTheintvalue representing thesynchronizedmodifier.- See Also:
-
VOLATILE
public static final int VOLATILETheintvalue representing thevolatilemodifier.- See Also:
-
TRANSIENT
public static final int TRANSIENTTheintvalue representing thetransientmodifier.- See Also:
-
NATIVE
public static final int NATIVETheintvalue representing thenativemodifier.- See Also:
-
INTERFACE
public static final int INTERFACETheintvalue representing theinterfacemodifier.- See Also:
-
ABSTRACT
public static final int ABSTRACTTheintvalue representing theabstractmodifier.- See Also:
-
STRICT
public static final int STRICTTheintvalue representing thestrictfpmodifier.- See Also:
-
-
Method Details
-
isPublic
public static boolean isPublic(int mod) Returntrueif the integer argument includes thepublicmodifier,falseotherwise.- Parameters:
mod- a set of modifiers- Returns:
trueifmodincludes thepublicmodifier;falseotherwise.
-
isPrivate
public static boolean isPrivate(int mod) Returntrueif the integer argument includes theprivatemodifier,falseotherwise.- Parameters:
mod- a set of modifiers- Returns:
trueifmodincludes theprivatemodifier;falseotherwise.
-
isProtected
public static boolean isProtected(int mod) Returntrueif the integer argument includes theprotectedmodifier,falseotherwise.- Parameters:
mod- a set of modifiers- Returns:
trueifmodincludes theprotectedmodifier;falseotherwise.
-
isStatic
public static boolean isStatic(int mod) Returntrueif the integer argument includes thestaticmodifier,falseotherwise.- Parameters:
mod- a set of modifiers- Returns:
trueifmodincludes thestaticmodifier;falseotherwise.
-
isFinal
public static boolean isFinal(int mod) Returntrueif the integer argument includes thefinalmodifier,falseotherwise.- Parameters:
mod- a set of modifiers- Returns:
trueifmodincludes thefinalmodifier;falseotherwise.
-
isSynchronized
public static boolean isSynchronized(int mod) Returntrueif the integer argument includes thesynchronizedmodifier,falseotherwise.- Parameters:
mod- a set of modifiers- Returns:
trueifmodincludes thesynchronizedmodifier;falseotherwise.
-
isVolatile
public static boolean isVolatile(int mod) Returntrueif the integer argument includes thevolatilemodifier,falseotherwise.- Parameters:
mod- a set of modifiers- Returns:
trueifmodincludes thevolatilemodifier;falseotherwise.
-
isTransient
public static boolean isTransient(int mod) Returntrueif the integer argument includes thetransientmodifier,falseotherwise.- Parameters:
mod- a set of modifiers- Returns:
trueifmodincludes thetransientmodifier;falseotherwise.
-
isNative
public static boolean isNative(int mod) Returntrueif the integer argument includes thenativemodifier,falseotherwise.- Parameters:
mod- a set of modifiers- Returns:
trueifmodincludes thenativemodifier;falseotherwise.
-
isInterface
public static boolean isInterface(int mod) Returntrueif the integer argument includes theinterfacemodifier,falseotherwise.- Parameters:
mod- a set of modifiers- Returns:
trueifmodincludes theinterfacemodifier;falseotherwise.
-
isAbstract
public static boolean isAbstract(int mod) Returntrueif the integer argument includes theabstractmodifier,falseotherwise.- Parameters:
mod- a set of modifiers- Returns:
trueifmodincludes theabstractmodifier;falseotherwise.
-
isStrict
public static boolean isStrict(int mod) Returntrueif the integer argument includes thestrictfpmodifier,falseotherwise.- Parameters:
mod- a set of modifiers- Returns:
trueifmodincludes thestrictfpmodifier;falseotherwise.
-
toString
Deprecated.Modifier interpretation is context-sensitive; this API may report an incomplete or incorrect list of Java language modifiers. The mappings fromclassfile access flags to Java language modifiers have diverged during the evolution of the Java SE Platform.Use
AccessFlagto examine access flags;toGenericStringmethods on reflective objects print Java language modifiers.Return a string describing the access modifier flags in the specified modifier. For example:
The modifier names are returned in an order consistent with the suggested modifier orderings given in sections 8.1.1, 8.3.1, 8.4.3, 8.8.3, and 9.1.1 of The Java Language Specification. The full modifier ordering used by this method is:public final synchronized strictfp
Thepublic protected private abstract static final transient volatile synchronized native strictfp interfaceinterfacemodifier discussed in this class is not a true modifier in the Java language and it appears after all other modifiers listed by this method. This method may return a string of modifiers that are not valid modifiers of a Java entity; in other words, no checking is done on the possible validity of the combination of modifiers represented by the input. This method also omits all access flags without a corresponding source modifier.- Parameters:
mod- a set of modifiers- Returns:
- a string representation of the set of modifiers
represented by
mod
-
classModifiers
Deprecated.This method was originally created to support the now-deprecatedModifier::toString(int)method. UseAccessFlag.Locationto inspect structure-specific access modifier properties.Return anintvalue OR-ing together the source language modifiers that can be applied to a class.- Returns:
- an
intvalue OR-ing together the source language modifiers that can be applied to a class. - See Java Language Specification:
-
8.1.1 Class Modifiers
- Since:
- 1.7
- See Also:
-
interfaceModifiers
Deprecated.This method was originally created to support the now-deprecatedModifier::toString(int)method. UseAccessFlag.Locationto inspect structure-specific access modifier properties.Return anintvalue OR-ing together the source language modifiers that can be applied to an interface.- Returns:
- an
intvalue OR-ing together the source language modifiers that can be applied to an interface. - See Java Language Specification:
-
9.1.1 Interface Modifiers
- Since:
- 1.7
- See Also:
-
constructorModifiers
Deprecated.This method was originally created to support the now-deprecatedModifier::toString(int)method. UseAccessFlag.Locationto inspect structure-specific access modifier properties.Return anintvalue OR-ing together the source language modifiers that can be applied to a constructor.- Returns:
- an
intvalue OR-ing together the source language modifiers that can be applied to a constructor. - See Java Language Specification:
-
8.8.3 Constructor Modifiers
- Since:
- 1.7
- See Also:
-
methodModifiers
Deprecated.This method was originally created to support the now-deprecatedModifier::toString(int)method. UseAccessFlag.Locationto inspect structure-specific access modifier properties.Return anintvalue OR-ing together the source language modifiers that can be applied to a method.- Returns:
- an
intvalue OR-ing together the source language modifiers that can be applied to a method. - See Java Language Specification:
-
8.4.3 Method Modifiers
- Since:
- 1.7
- See Also:
-
fieldModifiers
Deprecated.This method was originally created to support the now-deprecatedModifier::toString(int)method. UseAccessFlag.Locationto inspect structure-specific access modifier properties.Return anintvalue OR-ing together the source language modifiers that can be applied to a field.- Returns:
- an
intvalue OR-ing together the source language modifiers that can be applied to a field. - See Java Language Specification:
-
8.3.1 Field Modifiers
- Since:
- 1.7
- See Also:
-
parameterModifiers
Deprecated.This method was originally created to support the now-deprecatedModifier::toString(int)method. UseAccessFlag.Locationto inspect structure-specific access modifier properties.Return anintvalue OR-ing together the source language modifiers that can be applied to a parameter.- Returns:
- an
intvalue OR-ing together the source language modifiers that can be applied to a parameter. - See Java Language Specification:
-
8.4.1 Formal Parameters
- Since:
- 1.8
- See Also:
-
Modifier::toString(int)method.