Class Modifier
public final class Modifier extends Object
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
| Modifier and Type | Field | Description |
|---|---|---|
static final int |
ABSTRACT |
The int value representing the abstract modifier. |
static final int |
FINAL |
The int value representing the final modifier. |
static final int |
INTERFACE |
The int value representing the interface modifier. |
static final int |
NATIVE |
The int value representing the native modifier. |
static final int |
PRIVATE |
The int value representing the private modifier. |
static final int |
PROTECTED |
The int value representing the protected modifier. |
static final int |
PUBLIC |
The int value representing the public modifier. |
static final int |
STATIC |
The int value representing the static modifier. |
static final int |
STRICT |
The int value representing the strictfp modifier. |
static final int |
SYNCHRONIZED |
The int value representing the synchronized modifier. |
static final int |
TRANSIENT |
The int value representing the transient modifier. |
static final int |
VOLATILE |
The int value representing the volatile modifier. |
Method Summary
| Modifier and Type | Method | Description |
|---|---|---|
static int |
classModifiers() |
Deprecated. |
static int |
constructorModifiers() |
Deprecated. This method was originally created to support the now-deprecated Modifier::toString(int) method. |
static int |
fieldModifiers() |
Deprecated. This method was originally created to support the now-deprecated Modifier::toString(int) method. |
static int |
interfaceModifiers() |
Deprecated. This method was originally created to support the now-deprecated Modifier::toString(int) method. |
static boolean |
isAbstract |
Return true if the integer argument includes the abstract modifier, false otherwise. |
static boolean |
isFinal |
Return true if the integer argument includes the final modifier, false otherwise. |
static boolean |
isInterface |
Return true if the integer argument includes the interface modifier, false otherwise. |
static boolean |
isNative |
Return true if the integer argument includes the native modifier, false otherwise. |
static boolean |
isPrivate |
Return true if the integer argument includes the private modifier, false otherwise. |
static boolean |
isProtected |
Return true if the integer argument includes the protected modifier, false otherwise. |
static boolean |
isPublic |
Return true if the integer argument includes the public modifier, false otherwise. |
static boolean |
isStatic |
Return true if the integer argument includes the static modifier, false otherwise. |
static boolean |
isStrict |
Return true if the integer argument includes the strictfp modifier, false otherwise. |
static boolean |
isSynchronized |
Return true if the integer argument includes the synchronized modifier, false otherwise. |
static boolean |
isTransient |
Return true if the integer argument includes the transient modifier, false otherwise. |
static boolean |
isVolatile |
Return true if the integer argument includes the volatile modifier, false otherwise. |
static int |
methodModifiers() |
Deprecated. This method was originally created to support the now-deprecated Modifier::toString(int) method. |
static int |
parameterModifiers() |
Deprecated. This method was originally created to support the now-deprecated Modifier::toString(int) method. |
static String |
toString |
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, wait | Modifier and Type | Method | Description |
|---|---|---|
protected Object |
clone() |
Creates and returns a copy of this object. |
boolean |
equals |
Indicates whether some other object is "equal to" this one. |
protected void |
finalize() |
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 this Object. |
int |
hashCode() |
Returns a hash code value for this object. |
final void |
notify() |
Wakes up a single thread that is waiting on this object's monitor. |
final void |
notifyAll() |
Wakes up all threads that are waiting on this object's monitor. |
String |
toString() |
Returns a string representation of the object. |
final void |
wait() |
Causes the current thread to wait until it is awakened, typically by being notified or interrupted. |
final void |
wait |
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 void |
wait |
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 PUBLIC
int value representing the public modifier.- See Also:
PRIVATE
public static final int PRIVATE
int value representing the private modifier.- See Also:
PROTECTED
public static final int PROTECTED
int value representing the protected modifier.- See Also:
STATIC
public static final int STATIC
int value representing the static modifier.- See Also:
FINAL
public static final int FINAL
int value representing the final modifier.- See Also:
SYNCHRONIZED
public static final int SYNCHRONIZED
int value representing the synchronized modifier.- See Also:
VOLATILE
public static final int VOLATILE
int value representing the volatile modifier.- See Also:
TRANSIENT
public static final int TRANSIENT
int value representing the transient modifier.- See Also:
NATIVE
public static final int NATIVE
int value representing the native modifier.- See Also:
INTERFACE
public static final int INTERFACE
int value representing the interface modifier.- See Also:
ABSTRACT
public static final int ABSTRACT
int value representing the abstract modifier.- See Also:
STRICT
public static final int STRICT
int value representing the strictfp modifier.- See Also:
Method Details
isPublic
public static boolean isPublic(int mod)
true if the integer argument includes the public modifier, false otherwise.- Parameters:
-
mod- a set of modifiers - Returns:
-
trueifmodincludes thepublicmodifier;falseotherwise.
isPrivate
public static boolean isPrivate(int mod)
true if the integer argument includes the private modifier, false otherwise.- Parameters:
-
mod- a set of modifiers - Returns:
-
trueifmodincludes theprivatemodifier;falseotherwise.
isProtected
public static boolean isProtected(int mod)
true if the integer argument includes the protected modifier, false otherwise.- Parameters:
-
mod- a set of modifiers - Returns:
-
trueifmodincludes theprotectedmodifier;falseotherwise.
isStatic
public static boolean isStatic(int mod)
true if the integer argument includes the static modifier, false otherwise.- Parameters:
-
mod- a set of modifiers - Returns:
-
trueifmodincludes thestaticmodifier;falseotherwise.
isFinal
public static boolean isFinal(int mod)
true if the integer argument includes the final modifier, false otherwise.- Parameters:
-
mod- a set of modifiers - Returns:
-
trueifmodincludes thefinalmodifier;falseotherwise.
isSynchronized
public static boolean isSynchronized(int mod)
true if the integer argument includes the synchronized modifier, false otherwise.- Parameters:
-
mod- a set of modifiers - Returns:
-
trueifmodincludes thesynchronizedmodifier;falseotherwise.
isVolatile
public static boolean isVolatile(int mod)
true if the integer argument includes the volatile modifier, false otherwise.- Parameters:
-
mod- a set of modifiers - Returns:
-
trueifmodincludes thevolatilemodifier;falseotherwise.
isTransient
public static boolean isTransient(int mod)
true if the integer argument includes the transient modifier, false otherwise.- Parameters:
-
mod- a set of modifiers - Returns:
-
trueifmodincludes thetransientmodifier;falseotherwise.
isNative
public static boolean isNative(int mod)
true if the integer argument includes the native modifier, false otherwise.- Parameters:
-
mod- a set of modifiers - Returns:
-
trueifmodincludes thenativemodifier;falseotherwise.
isInterface
public static boolean isInterface(int mod)
true if the integer argument includes the interface modifier, false otherwise.- Parameters:
-
mod- a set of modifiers - Returns:
-
trueifmodincludes theinterfacemodifier;falseotherwise.
isAbstract
public static boolean isAbstract(int mod)
true if the integer argument includes the abstract modifier, false otherwise.- Parameters:
-
mod- a set of modifiers - Returns:
-
trueifmodincludes theabstractmodifier;falseotherwise.
isStrict
public static boolean isStrict(int mod)
true if the integer argument includes the strictfp modifier, false otherwise.- Parameters:
-
mod- a set of modifiers - Returns:
-
trueifmodincludes thestrictfpmodifier;falseotherwise.
toString
@Deprecated(since="27") public static String toString(int mod)
class file access flags to Java language modifiers have diverged during the evolution of the Java SE Platform. Use AccessFlag to examine access flags; toGenericString methods on reflective objects print Java language modifiers.
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
public protected private abstract static final transient
volatile synchronized native strictfp
interface The interface modifier 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(since="27") public static int classModifiers()
Modifier::toString(int) method. Use AccessFlag.Location to inspect structure-specific access modifier properties.int value 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(since="27") public static int interfaceModifiers()
Modifier::toString(int) method. Use AccessFlag.Location to inspect structure-specific access modifier properties.int value 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(since="27") public static int constructorModifiers()
Modifier::toString(int) method. Use AccessFlag.Location to inspect structure-specific access modifier properties.int value 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(since="27") public static int methodModifiers()
Modifier::toString(int) method. Use AccessFlag.Location to inspect structure-specific access modifier properties.int value 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(since="27") public static int fieldModifiers()
Modifier::toString(int) method. Use AccessFlag.Location to inspect structure-specific access modifier properties.int value 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(since="27") public static int parameterModifiers()
Modifier::toString(int) method. Use AccessFlag.Location to inspect structure-specific access modifier properties.int value 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:
© 1993, 2025, Oracle and/or its affiliates. All rights reserved.
Documentation extracted from Debian's OpenJDK Development Kit package.
Licensed under the GNU General Public License, version 2, with the Classpath Exception.
Various third party code in OpenJDK is licensed under different licenses (see Debian package).
Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.
Modifier::toString(int)method.