Top Description Fields Constructors Methods
java.lang.reflect

public Class Modifier

extends Object
Class Inheritance
Imports
java.util.StringJoiner

The Modifier class provides static methods and constants to decode class and member access modifiers. The sets of modifiers are represented as integers with distinct bit positions representing different modifiers. The values for the constants representing the modifiers are taken from the tables in sections 4.1, 4.4, 4.5, and 4.7 of The Java Virtual Machine Specification.
Authors
Nakul Saraiya, Kenneth Russell
Since
1.1
See Also
Class#getModifiers(), Member#getModifiers()

Field Summary

Modifier and TypeField and Description
public static final int
ABSTRACT

The int value representing the abstract modifier.

pack-priv static final int
pack-priv static final int
pack-priv static final int
private static final int
CLASS_MODIFIERS

The Java source modifiers that can be applied to a class.

private static final int
CONSTRUCTOR_MODIFIERS

The Java source modifiers that can be applied to a constructor.

pack-priv static final int
private static final int
FIELD_MODIFIERS

The Java source modifiers that can be applied to a field.

public static final int
FINAL

The int value representing the final modifier.

public static final int
INTERFACE

The int value representing the interface modifier.

private static final int
INTERFACE_MODIFIERS

The Java source modifiers that can be applied to an interface.

pack-priv static final int
private static final int
METHOD_MODIFIERS

The Java source modifiers that can be applied to a method.

public static final int
NATIVE

The int value representing the native modifier.

private static final int
PARAMETER_MODIFIERS

The Java source modifiers that can be applied to a method or constructor parameter.

public static final int
PRIVATE

The int value representing the private modifier.

public static final int
PROTECTED

The int value representing the protected modifier.

public static final int
PUBLIC

The int value representing the public modifier.

public static final int
STATIC

The int value representing the static modifier.

public static final int
STRICT

The int value representing the strictfp modifier.

public static final int
SYNCHRONIZED

The int value representing the synchronized modifier.

pack-priv static final int
public static final int
TRANSIENT

The int value representing the transient modifier.

pack-priv static final int
public static final int
VOLATILE

The int value representing the volatile modifier.

Constructor Summary

AccessConstructor and Description
private
Modifier()

Do not call.

Method Summary

Modifier and TypeMethod and Description
public static int

Returns:

an int value OR-ing together the source language modifiers that can be applied to a class.
classModifiers
()

Return an int value OR-ing together the source language modifiers that can be applied to a class.

public static int

Returns:

an int value OR-ing together the source language modifiers that can be applied to a constructor.
constructorModifiers
()

Return an int value OR-ing together the source language modifiers that can be applied to a constructor.

public static int

Returns:

an int value OR-ing together the source language modifiers that can be applied to a field.
fieldModifiers
()

Return an int value OR-ing together the source language modifiers that can be applied to a field.

public static int

Returns:

an int value OR-ing together the source language modifiers that can be applied to an interface.
interfaceModifiers
()

Return an int value OR-ing together the source language modifiers that can be applied to an interface.

public static boolean

Returns:

true if mod includes the abstract modifier; false otherwise.
isAbstract
(int
a set of modifiers
mod
)

Return true if the integer argument includes the abstract modifier, false otherwise.

public static boolean

Returns:

true if mod includes the final modifier; false otherwise.
isFinal
(int
a set of modifiers
mod
)

Return true if the integer argument includes the final modifier, false otherwise.

public static boolean

Returns:

true if mod includes the interface modifier; false otherwise.
isInterface
(int
a set of modifiers
mod
)

Return true if the integer argument includes the interface modifier, false otherwise.

pack-priv static boolean
isMandated(int mod)

public static boolean

Returns:

true if mod includes the native modifier; false otherwise.
isNative
(int
a set of modifiers
mod
)

Return true if the integer argument includes the native modifier, false otherwise.

public static boolean

Returns:

true if mod includes the private modifier; false otherwise.
isPrivate
(int
a set of modifiers
mod
)

Return true if the integer argument includes the private modifier, false otherwise.

public static boolean

Returns:

true if mod includes the protected modifier; false otherwise.
isProtected
(int
a set of modifiers
mod
)

Return true if the integer argument includes the protected modifier, false otherwise.

public static boolean

Returns:

true if mod includes the public modifier; false otherwise.
isPublic
(int
a set of modifiers
mod
)

Return true if the integer argument includes the public modifier, false otherwise.

public static boolean

Returns:

true if mod includes the static modifier; false otherwise.
isStatic
(int
a set of modifiers
mod
)

Return true if the integer argument includes the static modifier, false otherwise.

public static boolean

Returns:

true if mod includes the strictfp modifier; false otherwise.
isStrict
(int
a set of modifiers
mod
)

Return true if the integer argument includes the strictfp modifier, false otherwise.

public static boolean

Returns:

true if mod includes the synchronized modifier; false otherwise.
isSynchronized
(int
a set of modifiers
mod
)

Return true if the integer argument includes the synchronized modifier, false otherwise.

pack-priv static boolean
isSynthetic(int mod)

public static boolean

Returns:

true if mod includes the transient modifier; false otherwise.
isTransient
(int
a set of modifiers
mod
)

Return true if the integer argument includes the transient modifier, false otherwise.

public static boolean

Returns:

true if mod includes the volatile modifier; false otherwise.
isVolatile
(int
a set of modifiers
mod
)

Return true if the integer argument includes the volatile modifier, false otherwise.

public static int

Returns:

an int value OR-ing together the source language modifiers that can be applied to a method.
methodModifiers
()

Return an int value OR-ing together the source language modifiers that can be applied to a method.

public static int

Returns:

an int value OR-ing together the source language modifiers that can be applied to a parameter.
parameterModifiers
()

Return an int value OR-ing together the source language modifiers that can be applied to a parameter.

public static String

Returns:

a string representation of the set of modifiers represented by mod
toString
(int
a set of modifiers
mod
)

Return a string describing the access modifier flags in the specified modifier.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

ABSTRACTback to summary
public static final int ABSTRACT

The int value representing the abstract modifier.

See Also
AccessFlag#ABSTRACT
ACCESS_MODIFIERSback to summary
pack-priv static final int ACCESS_MODIFIERS
ANNOTATIONback to summary
pack-priv static final int ANNOTATION
BRIDGEback to summary
pack-priv static final int BRIDGE
CLASS_MODIFIERSback to summary
private static final int CLASS_MODIFIERS

The Java source modifiers that can be applied to a class.

Java Language Specification
8.1.1 Class Modifiers
CONSTRUCTOR_MODIFIERSback to summary
private static final int CONSTRUCTOR_MODIFIERS

The Java source modifiers that can be applied to a constructor.

Java Language Specification
8.8.3 Constructor Modifiers
ENUMback to summary
pack-priv static final int ENUM
FIELD_MODIFIERSback to summary
private static final int FIELD_MODIFIERS

The Java source modifiers that can be applied to a field.

Java Language Specification
8.3.1 Field Modifiers
FINALback to summary
public static final int FINAL

The int value representing the final modifier.

See Also
AccessFlag#FINAL
INTERFACEback to summary
public static final int INTERFACE

The int value representing the interface modifier.

See Also
AccessFlag#INTERFACE
INTERFACE_MODIFIERSback to summary
private static final int INTERFACE_MODIFIERS

The Java source modifiers that can be applied to an interface.

Java Language Specification
9.1.1 Interface Modifiers
MANDATEDback to summary
pack-priv static final int MANDATED
METHOD_MODIFIERSback to summary
private static final int METHOD_MODIFIERS

The Java source modifiers that can be applied to a method.

Java Language Specification
8.4.3 Method Modifiers
NATIVEback to summary
public static final int NATIVE

The int value representing the native modifier.

See Also
AccessFlag#NATIVE
PARAMETER_MODIFIERSback to summary
private static final int PARAMETER_MODIFIERS

The Java source modifiers that can be applied to a method or constructor parameter.

Java Language Specification
8.4.1 Formal Parameters
PRIVATEback to summary
public static final int PRIVATE

The int value representing the private modifier.

See Also
AccessFlag#PRIVATE
PROTECTEDback to summary
public static final int PROTECTED

The int value representing the protected modifier.

See Also
AccessFlag#PROTECTED
PUBLICback to summary
public static final int PUBLIC

The int value representing the public modifier.

See Also
AccessFlag#PUBLIC
STATICback to summary
public static final int STATIC

The int value representing the static modifier.

See Also
AccessFlag#STATIC
STRICTback to summary
public static final int STRICT

The int value representing the strictfp modifier.

See Also
AccessFlag#STRICT
SYNCHRONIZEDback to summary
public static final int SYNCHRONIZED

The int value representing the synchronized modifier.

See Also
AccessFlag#SYNCHRONIZED
SYNTHETICback to summary
pack-priv static final int SYNTHETIC
TRANSIENTback to summary
public static final int TRANSIENT

The int value representing the transient modifier.

See Also
AccessFlag#TRANSIENT
VARARGSback to summary
pack-priv static final int VARARGS
VOLATILEback to summary
public static final int VOLATILE

The int value representing the volatile modifier.

See Also
AccessFlag#VOLATILE

Constructor Detail

Modifierback to summary
private Modifier()

Do not call.

Method Detail

classModifiersback to summary
public static int classModifiers()

Return an int value OR-ing together the source language modifiers that can be applied to a class.

Returns:int

an int value OR-ing together the source language modifiers that can be applied to a class.

Since
1.7
Java Language Specification
8.1.1 Class Modifiers
constructorModifiersback to summary
public static int constructorModifiers()

Return an int value OR-ing together the source language modifiers that can be applied to a constructor.

Returns:int

an int value OR-ing together the source language modifiers that can be applied to a constructor.

Since
1.7
Java Language Specification
8.8.3 Constructor Modifiers
fieldModifiersback to summary
public static int fieldModifiers()

Return an int value OR-ing together the source language modifiers that can be applied to a field.

Returns:int

an int value OR-ing together the source language modifiers that can be applied to a field.

Since
1.7
Java Language Specification
8.3.1 Field Modifiers
interfaceModifiersback to summary
public static int interfaceModifiers()

Return an int value OR-ing together the source language modifiers that can be applied to an interface.

Returns:int

an int value OR-ing together the source language modifiers that can be applied to an interface.

Since
1.7
Java Language Specification
9.1.1 Interface Modifiers
isAbstractback to summary
public static boolean isAbstract(int mod)

Return true if the integer argument includes the abstract modifier, false otherwise.

Parameters
mod:int

a set of modifiers

Returns:boolean

true if mod includes the abstract modifier; false otherwise.

isFinalback to summary
public static boolean isFinal(int mod)

Return true if the integer argument includes the final modifier, false otherwise.

Parameters
mod:int

a set of modifiers

Returns:boolean

true if mod includes the final modifier; false otherwise.

isInterfaceback to summary
public static boolean isInterface(int mod)

Return true if the integer argument includes the interface modifier, false otherwise.

Parameters
mod:int

a set of modifiers

Returns:boolean

true if mod includes the interface modifier; false otherwise.

isMandatedback to summary
pack-priv static boolean isMandated(int mod)
isNativeback to summary
public static boolean isNative(int mod)

Return true if the integer argument includes the native modifier, false otherwise.

Parameters
mod:int

a set of modifiers

Returns:boolean

true if mod includes the native modifier; false otherwise.

isPrivateback to summary
public static boolean isPrivate(int mod)

Return true if the integer argument includes the private modifier, false otherwise.

Parameters
mod:int

a set of modifiers

Returns:boolean

true if mod includes the private modifier; false otherwise.

isProtectedback to summary
public static boolean isProtected(int mod)

Return true if the integer argument includes the protected modifier, false otherwise.

Parameters
mod:int

a set of modifiers

Returns:boolean

true if mod includes the protected modifier; false otherwise.

isPublicback to summary
public static boolean isPublic(int mod)

Return true if the integer argument includes the public modifier, false otherwise.

Parameters
mod:int

a set of modifiers

Returns:boolean

true if mod includes the public modifier; false otherwise.

isStaticback to summary
public static boolean isStatic(int mod)

Return true if the integer argument includes the static modifier, false otherwise.

Parameters
mod:int

a set of modifiers

Returns:boolean

true if mod includes the static modifier; false otherwise.

isStrictback to summary
public static boolean isStrict(int mod)

Return true if the integer argument includes the strictfp modifier, false otherwise.

Parameters
mod:int

a set of modifiers

Returns:boolean

true if mod includes the strictfp modifier; false otherwise.

isSynchronizedback to summary
public static boolean isSynchronized(int mod)

Return true if the integer argument includes the synchronized modifier, false otherwise.

Parameters
mod:int

a set of modifiers

Returns:boolean

true if mod includes the synchronized modifier; false otherwise.

isSyntheticback to summary
pack-priv static boolean isSynthetic(int mod)
isTransientback to summary
public static boolean isTransient(int mod)

Return true if the integer argument includes the transient modifier, false otherwise.

Parameters
mod:int

a set of modifiers

Returns:boolean

true if mod includes the transient modifier; false otherwise.

isVolatileback to summary
public static boolean isVolatile(int mod)

Return true if the integer argument includes the volatile modifier, false otherwise.

Parameters
mod:int

a set of modifiers

Returns:boolean

true if mod includes the volatile modifier; false otherwise.

methodModifiersback to summary
public static int methodModifiers()

Return an int value OR-ing together the source language modifiers that can be applied to a method.

Returns:int

an int value OR-ing together the source language modifiers that can be applied to a method.

Since
1.7
Java Language Specification
8.4.3 Method Modifiers
parameterModifiersback to summary
public static int parameterModifiers()

Return an int value OR-ing together the source language modifiers that can be applied to a parameter.

Returns:int

an int value OR-ing together the source language modifiers that can be applied to a parameter.

Since
1.8
Java Language Specification
8.4.1 Formal Parameters
toStringback to summary
public static String toString(int mod)

Return a string describing the access modifier flags in the specified modifier. For example:

   public final synchronized strictfp
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 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. Note that to perform such checking for a known kind of entity, such as a constructor or method, first AND the argument of toString with the appropriate mask from a method like constructorModifiers or methodModifiers.
Parameters
mod:int

a set of modifiers

Returns:String

a string representation of the set of modifiers represented by mod