Spec-Zone.ru › OpenJDK 27

Class Modifier

java.lang.Object
java.lang.reflect.Modifier
public final class Modifier extends Object
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:
  • AccessFlag
  • Modifier
  • Java programming language and JVM modeling in core reflection
  • Class.getModifiers()
  • Member.getModifiers()
  • Parameter.getModifiers()

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.
This method was originally created to support the now-deprecated Modifier::toString(int) method.
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(int mod)
Return true if the integer argument includes the abstract modifier, false otherwise.
static boolean isFinal(int mod)
Return true if the integer argument includes the final modifier, false otherwise.
static boolean isInterface(int mod)
Return true if the integer argument includes the interface modifier, false otherwise.
static boolean isNative(int mod)
Return true if the integer argument includes the native modifier, false otherwise.
static boolean isPrivate(int mod)
Return true if the integer argument includes the private modifier, false otherwise.
static boolean isProtected(int mod)
Return true if the integer argument includes the protected modifier, false otherwise.
static boolean isPublic(int mod)
Return true if the integer argument includes the public modifier, false otherwise.
static boolean isStatic(int mod)
Return true if the integer argument includes the static modifier, false otherwise.
static boolean isStrict(int mod)
Return true if the integer argument includes the strictfp modifier, false otherwise.
static boolean isSynchronized(int mod)
Return true if the integer argument includes the synchronized modifier, false otherwise.
static boolean isTransient(int mod)
Return true if the integer argument includes the transient modifier, false otherwise.
static boolean isVolatile(int mod)
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(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, wait
Modifier and Type Method Description
protected Object clone()
Creates and returns a copy of this object.
boolean equals(Object obj)
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(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 void wait(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 PUBLIC
The int value representing the public modifier.
See Also:
  • AccessFlag.PUBLIC
  • Constant Field Values

PRIVATE

public static final int PRIVATE
The int value representing the private modifier.
See Also:
  • AccessFlag.PRIVATE
  • Constant Field Values

PROTECTED

public static final int PROTECTED
The int value representing the protected modifier.
See Also:
  • AccessFlag.PROTECTED
  • Constant Field Values

STATIC

public static final int STATIC
The int value representing the static modifier.
See Also:
  • AccessFlag.STATIC
  • Constant Field Values

FINAL

public static final int FINAL
The int value representing the final modifier.
See Also:
  • AccessFlag.FINAL
  • Constant Field Values

SYNCHRONIZED

public static final int SYNCHRONIZED
The int value representing the synchronized modifier.
See Also:
  • AccessFlag.SYNCHRONIZED
  • Constant Field Values

VOLATILE

public static final int VOLATILE
The int value representing the volatile modifier.
See Also:
  • AccessFlag.VOLATILE
  • Constant Field Values

TRANSIENT

public static final int TRANSIENT
The int value representing the transient modifier.
See Also:
  • AccessFlag.TRANSIENT
  • Constant Field Values

NATIVE

public static final int NATIVE
The int value representing the native modifier.
See Also:
  • AccessFlag.NATIVE
  • Constant Field Values

INTERFACE

public static final int INTERFACE
The int value representing the interface modifier.
See Also:
  • AccessFlag.INTERFACE
  • Constant Field Values

ABSTRACT

public static final int ABSTRACT
The int value representing the abstract modifier.
See Also:
  • AccessFlag.ABSTRACT
  • Constant Field Values

STRICT

public static final int STRICT
The int value representing the strictfp modifier.
See Also:
  • AccessFlag.STRICT
  • Constant Field Values

Method Details

isPublic

public static boolean isPublic(int mod)
Return true if the integer argument includes the public modifier, false otherwise.
Parameters:
mod - a set of modifiers
Returns:
true if mod includes the public modifier; false otherwise.

isPrivate

public static boolean isPrivate(int mod)
Return true if the integer argument includes the private modifier, false otherwise.
Parameters:
mod - a set of modifiers
Returns:
true if mod includes the private modifier; false otherwise.

isProtected

public static boolean isProtected(int mod)
Return true if the integer argument includes the protected modifier, false otherwise.
Parameters:
mod - a set of modifiers
Returns:
true if mod includes the protected modifier; false otherwise.

isStatic

public static boolean isStatic(int mod)
Return true if the integer argument includes the static modifier, false otherwise.
Parameters:
mod - a set of modifiers
Returns:
true if mod includes the static modifier; false otherwise.

isFinal

public static boolean isFinal(int mod)
Return true if the integer argument includes the final modifier, false otherwise.
Parameters:
mod - a set of modifiers
Returns:
true if mod includes the final modifier; false otherwise.

isSynchronized

public static boolean isSynchronized(int mod)
Return true if the integer argument includes the synchronized modifier, false otherwise.
Parameters:
mod - a set of modifiers
Returns:
true if mod includes the synchronized modifier; false otherwise.

isVolatile

public static boolean isVolatile(int mod)
Return true if the integer argument includes the volatile modifier, false otherwise.
Parameters:
mod - a set of modifiers
Returns:
true if mod includes the volatile modifier; false otherwise.

isTransient

public static boolean isTransient(int mod)
Return true if the integer argument includes the transient modifier, false otherwise.
Parameters:
mod - a set of modifiers
Returns:
true if mod includes the transient modifier; false otherwise.

isNative

public static boolean isNative(int mod)
Return true if the integer argument includes the native modifier, false otherwise.
Parameters:
mod - a set of modifiers
Returns:
true if mod includes the native modifier; false otherwise.

isInterface

public static boolean isInterface(int mod)
Return true if the integer argument includes the interface modifier, false otherwise.
Parameters:
mod - a set of modifiers
Returns:
true if mod includes the interface modifier; false otherwise.

isAbstract

public static boolean isAbstract(int mod)
Return true if the integer argument includes the abstract modifier, false otherwise.
Parameters:
mod - a set of modifiers
Returns:
true if mod includes the abstract modifier; false otherwise.

isStrict

public static boolean isStrict(int mod)
Return true if the integer argument includes the strictfp modifier, false otherwise.
Parameters:
mod - a set of modifiers
Returns:
true if mod includes the strictfp modifier; false otherwise.

toString

@Deprecated(since="27") public static String toString(int mod)
Deprecated.
Modifier interpretation is context-sensitive; this API may report an incomplete or incorrect list of Java language modifiers. The mappings from 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.

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. 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()
Deprecated.
This method was originally created to support the now-deprecated Modifier::toString(int) method. Use AccessFlag.Location to inspect structure-specific access modifier properties.
Return an int value OR-ing together the source language modifiers that can be applied to a class.
Returns:
an int value 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:
  • AccessFlag.Location.CLASS
  • AccessFlag.Location.INNER_CLASS

interfaceModifiers

@Deprecated(since="27") public static int interfaceModifiers()
Deprecated.
This method was originally created to support the now-deprecated Modifier::toString(int) method. Use AccessFlag.Location to inspect structure-specific access modifier properties.
Return an int value OR-ing together the source language modifiers that can be applied to an interface.
Returns:
an int value 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:
  • AccessFlag.Location.CLASS
  • AccessFlag.Location.INNER_CLASS

constructorModifiers

@Deprecated(since="27") public static int constructorModifiers()
Deprecated.
This method was originally created to support the now-deprecated Modifier::toString(int) method. Use AccessFlag.Location to inspect structure-specific access modifier properties.
Return an int value OR-ing together the source language modifiers that can be applied to a constructor.
Returns:
an int value 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:
  • AccessFlag.Location.METHOD

methodModifiers

@Deprecated(since="27") public static int methodModifiers()
Deprecated.
This method was originally created to support the now-deprecated Modifier::toString(int) method. Use AccessFlag.Location to inspect structure-specific access modifier properties.
Return an int value OR-ing together the source language modifiers that can be applied to a method.
Returns:
an int value 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:
  • AccessFlag.Location.METHOD

fieldModifiers

@Deprecated(since="27") public static int fieldModifiers()
Deprecated.
This method was originally created to support the now-deprecated Modifier::toString(int) method. Use AccessFlag.Location to inspect structure-specific access modifier properties.
Return an int value OR-ing together the source language modifiers that can be applied to a field.
Returns:
an int value 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:
  • AccessFlag.Location.FIELD

parameterModifiers

@Deprecated(since="27") public static int parameterModifiers()
Deprecated.
This method was originally created to support the now-deprecated Modifier::toString(int) method. Use AccessFlag.Location to inspect structure-specific access modifier properties.
Return an int value OR-ing together the source language modifiers that can be applied to a parameter.
Returns:
an int value 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:
  • AccessFlag.Location.METHOD_PARAMETER

Report a bug or suggest an enhancement
For further API reference and developer documentation see the Java SE Documentation, which contains more detailed, developer-targeted descriptions with conceptual overviews, definitions of terms, workarounds, and working code examples. Other versions.
Java is a trademark or registered trademark of Oracle and/or its affiliates in the US and other countries.
Copyright © 1993, 2026, Oracle and/or its affiliates, 500 Oracle Parkway, Redwood Shores, CA 94065 USA.
All rights reserved. Use is subject to license terms and the documentation redistribution policy.

© 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.

Spec-Zone.ru

Настройки Оффлайн Что нового Помощь О нас
Spec-Zone .ru
спецификации, руководства, описания, API