Index (Frames) | Index (No Frames) | Package | Package Tree | Tree
java.lang.reflect

Class Modifier

java.lang.Object
|
+--java.lang.reflect.Modifier


public class Modifier

extends Object

Modifier is a helper class with static methods to determine whether an int returned from getModifiers() represents static, public, protected, native, final, etc... and provides an additional method to print out all of the modifiers in an int in order.

The methods in this class use the bitmask values in the VM spec to determine the modifiers of an int. This means that a VM must return a standard mask, conformant with the VM spec. I don't know if this is how Sun does it, but I'm willing to bet money that it is.

Since:Authors:See Also:

Field Summary

static intABSTRACT

Abstract:
  • Class: may not be instantiated.
  • Method: may not be called.
static intFINAL

Final:
  • Class: no subclasses allowed.
  • Field: cannot be changed.
  • Method: cannot be overriden.
static intINTERFACE

Interface: Class: is an interface.
static intNATIVE

Native: Method: use JNI to call this method.
static intPRIVATE

Private: accessible only from the same enclosing class.
static intPROTECTED

Protected: accessible only to subclasses, or within the package.
static intPUBLIC

Public: accessible from any other class.
static intSTATIC

Static:
  • Class: no enclosing instance for nested class.
  • Field or Method: can be accessed or invoked without an instance of the declaring class.
static intSTRICT

Strictfp: Method: expressions are FP-strict.
static intSYNCHRONIZED

Synchronized: Method: lock the class while calling this method.
static intTRANSIENT

Transient: Field: not serialized or deserialized.
static intVOLATILE

Volatile: Field: cannot be cached.

Constructor Summary

Modifier()

This constructor really shouldn't be here ...

Method Summary

static booleanisAbstract(int mod)

Check whether the given modifier is abstract.
static booleanisFinal(int mod)

Check whether the given modifier is final.
static booleanisInterface(int mod)

Check whether the given modifier is an interface.
static booleanisNative(int mod)

Check whether the given modifier is native.
static booleanisPrivate(int mod)

Check whether the given modifier is private.
static booleanisProtected(int mod)

Check whether the given modifier is protected.
static booleanisPublic(int mod)

Check whether the given modifier is public.
static booleanisStatic(int mod)

Check whether the given modifier is static.
static booleanisStrict(int mod)

Check whether the given modifier is strictfp.
static booleanisSynchronized(int mod)

Check whether the given modifier is synchronized.
static booleanisTransient(int mod)

Check whether the given modifier is transient.
static booleanisVolatile(int mod)

Check whether the given modifier is volatile.
static java.lang.StringtoString(int mod)

Get a string representation of all the modifiers represented by the given int.

Field Details

ABSTRACT

public static final int ABSTRACT

Abstract:


FINAL

public static final int FINAL

Final:


INTERFACE

public static final int INTERFACE

Interface: Class: is an interface.


NATIVE

public static final int NATIVE

Native: Method: use JNI to call this method.


PRIVATE

public static final int PRIVATE

Private: accessible only from the same enclosing class.


PROTECTED

public static final int PROTECTED

Protected: accessible only to subclasses, or within the package.


PUBLIC

public static final int PUBLIC

Public: accessible from any other class.


STATIC

public static final int STATIC

Static:


STRICT

public static final int STRICT

Strictfp: Method: expressions are FP-strict.

Also used as a modifier for classes, to mean that all initializers and constructors are FP-strict, but does not show up in Class.getModifiers.


SYNCHRONIZED

public static final int SYNCHRONIZED

Synchronized: Method: lock the class while calling this method.


TRANSIENT

public static final int TRANSIENT

Transient: Field: not serialized or deserialized.


VOLATILE

public static final int VOLATILE

Volatile: Field: cannot be cached.


Constructor Details

Modifier

public Modifier()

This constructor really shouldn't be here ... there are no instance methods or variables of this class, so instantiation is worthless. However, this function is in the 1.1 spec, so it is added for completeness.


Method Details

isAbstract

public static boolean isAbstract(int mod)

Check whether the given modifier is abstract.

Parameters:

Returns:


isFinal

public static boolean isFinal(int mod)

Check whether the given modifier is final.

Parameters:

Returns:


isInterface

public static boolean isInterface(int mod)

Check whether the given modifier is an interface.

Parameters:

Returns:


isNative

public static boolean isNative(int mod)

Check whether the given modifier is native.

Parameters:

Returns:


isPrivate

public static boolean isPrivate(int mod)

Check whether the given modifier is private.

Parameters:

Returns:


isProtected

public static boolean isProtected(int mod)

Check whether the given modifier is protected.

Parameters:

Returns:


isPublic

public static boolean isPublic(int mod)

Check whether the given modifier is public.

Parameters:

Returns:


isStatic

public static boolean isStatic(int mod)

Check whether the given modifier is static.

Parameters:

Returns:


isStrict

public static boolean isStrict(int mod)

Check whether the given modifier is strictfp.

Parameters:

Returns:


isSynchronized

public static boolean isSynchronized(int mod)

Check whether the given modifier is synchronized.

Parameters:

Returns:


isTransient

public static boolean isTransient(int mod)

Check whether the given modifier is transient.

Parameters:

Returns:


isVolatile

public static boolean isVolatile(int mod)

Check whether the given modifier is volatile.

Parameters:

Returns:


toString

public static String toString(int mod)

Get a string representation of all the modifiers represented by the given int. The keywords are printed in this order: <public|protected|private> abstract static final transient volatile synchronized native strictfp interface.

Parameters:

Returns: