Top Description Inners Fields Constructors Methods
java.lang

public final Class Class<T>

extends Object
implements Serializable, GenericDeclaration, Type, AnnotatedElement, TypeDescriptor.OfField<Class<?>>, Constable
Class Inheritance
All Implemented Interfaces
java.lang.constant.Constable, java.lang.invoke.TypeDescriptor.OfField, java.lang.invoke.TypeDescriptor, java.lang.reflect.AnnotatedElement, java.lang.reflect.Type, java.lang.reflect.GenericDeclaration, java.io.Serializable
Type Parameters
<T>
the type of the class modeled by this Class object. For example, the type of String.class is Class<String>. Use Class<?> if the class being modeled is unknown.
Imports
java.lang.annotation.Annotation, java.lang.constant.ClassDesc, .ConstantDescs, .Constable, java.lang.invoke.TypeDescriptor, .MethodHandles, java.lang.module.ModuleReader, java.lang.ref.SoftReference, java.io.IOException, .InputStream, .ObjectStreamField, java.lang.reflect.AnnotatedElement, .AnnotatedType, .AccessFlag, .Array, .Constructor, .Executable, .Field, .GenericArrayType, .GenericDeclaration, .InvocationTargetException, .Member, .Method, .Modifier, .Proxy, .RecordComponent, .Type, .TypeVariable, java.net.URL, java.security.AccessController, .PrivilegedAction, java.util.ArrayList, .Arrays, .Collection, .HashMap, .HashSet, .LinkedHashMap, .LinkedHashSet, .List, .Map, .Objects, .Optional, .Set, java.util.stream.Collectors, jdk.internal.javac.PreviewFeature, jdk.internal.loader.BootLoader, .BuiltinClassLoader, jdk.internal.misc.PreviewFeatures, .Unsafe, jdk.internal.module.Resources, jdk.internal.reflect.CallerSensitive, .CallerSensitiveAdapter, .ConstantPool, .Reflection, .ReflectionFactory, jdk.internal.vm.annotation.ForceInline, .IntrinsicCandidate, .Stable, sun.invoke.util.Wrapper, sun.reflect.generics.factory.CoreReflectionFactory, .GenericsFactory, sun.reflect.generics.repository.ClassRepository, .MethodRepository, .ConstructorRepository, sun.reflect.generics.scope.ClassScope, sun.security.util.SecurityConstants, sun.reflect.annotation.*, sun.reflect.misc.ReflectUtil

Instances of the class Class represent classes and interfaces in a running Java application. An enum class and a record class are kinds of class; an annotation interface is a kind of interface. Every array also belongs to a class that is reflected as a Class object that is shared by all arrays with the same element type and number of dimensions. The primitive Java types (boolean, byte, char, short, int, long, float, and double), and the keyword void are also represented as Class objects.

Class has no public constructor. Instead a Class object is constructed automatically by the Java Virtual Machine when a class is derived from the bytes of a class file through the invocation of one of the following methods:

The methods of class Class expose many characteristics of a class or interface. Most characteristics are derived from the class file that the class loader passed to the Java Virtual Machine or from the class file passed to Lookup::defineClass or Lookup::defineHiddenClass. A few characteristics are determined by the class loading environment at run time, such as the module returned by getModule().

The following example uses a Class object to print the class name of an object:

void printClassName(Object obj) { System.out.println("The class of " + obj + " is " + obj.getClass().getName()); }
void printClassName(Object obj) {
    System.out.println("The class of " + obj +
                       " is " + obj.getClass().getName());
}
It is also possible to get the Class object for a named class or interface (or for void) using a class literal. For example:
System.out.println("The name of class Foo is: "+Foo.class.getName());
System.out.println("The name of class Foo is: "+Foo.class.getName());

Some methods of class Class expose whether the declaration of a class or interface in Java source code was enclosed within another declaration. Other methods describe how a class or interface is situated in a nest. A nest is a set of classes and interfaces, in the same run-time package, that allow mutual access to their private members. The classes and interfaces are known as nestmates. One nestmate acts as the nest host, and enumerates the other nestmates which belong to the nest; each of them in turn records it as the nest host. The classes and interfaces which belong to a nest, including its host, are determined when class files are generated, for example, a Java compiler will typically record a top-level class as the host of a nest where the other members are the classes and interfaces whose declarations are enclosed within the top-level class declaration.

Hidden Classes

A class or interface created by the invocation of Lookup::defineHiddenClass is a hidden class or interface. All kinds of class, including enum classes and record classes, may be hidden classes; all kinds of interface, including annotation interfaces, may be hidden interfaces. The name of a hidden class or interface is not a binary name, which means the following: A hidden class or interface is never an array class, but may be the element type of an array. In all other respects, the fact that a class or interface is hidden has no bearing on the characteristics exposed by the methods of class Class.

Implicitly Declared Classes

Conventionally, a Java compiler, starting from a source file for an implicitly declared class, say HelloWorld.java, creates a similarly-named class file, HelloWorld.class, where the class stored in that class file is named "HelloWorld", matching the base names of the source and class files. For the Class object of an implicitly declared class HelloWorld, the methods to get the name and type name return results equal to "HelloWorld". The simple name of such an implicitly declared class is "HelloWorld" and the canonical name is "HelloWorld".
Since
1.0
Java Language Specification
15.8.2 Class Literals
See Also
java.lang.ClassLoader#defineClass(byte[], int, int)

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class
private static class
Class.Atomic

Atomic operations support.

private static class
private static class
Class.ReflectionData<T>

Reflection support.

Field Summary

Modifier and TypeField and Description
private static ProtectionDomain
allPermDomain

protection domain returned when the internal domain is null

private static final int
private transient volatile Class.AnnotationData
private transient volatile AnnotationType
private transient volatile Constructor<T>
private transient Object
private final ClassLoader
private transient volatile int
pack-priv transient ClassValue.ClassValueMap
private final Class<?>
private static final Class<?>[]
private static final int
private transient volatile Map<String, T>
private transient volatile T[]
private transient volatile ClassRepository
private transient Module
private transient String
private transient String
private transient volatile SoftReference<Class.ReflectionData<T>>
private static ReflectionFactory
private static final ObjectStreamField[]
serialPersistentFields

Class Class is special cased within the Serialization Stream Protocol.

private static final long
serialVersionUID

use serialVersionUID from JDK 1.1 for interoperability

private static final int

Constructor Summary

AccessConstructor and Description
private
Class(ClassLoader loader, Class<?> arrayComponentType)

Method Summary

Modifier and TypeMethod and Description
public Set<AccessFlag>

Returns:

an unmodifiable set of the access flags for this class, possibly empty
accessFlags
()

Returns an unmodifiable set of the access flags for this class, possibly empty.

private static void
private void
addSealingInfo(int modifiers, StringBuilder sb)

private Class.AnnotationData
private static boolean
public Class<?>

Returns:

a Class describing the array type
arrayType
()

Implements java.lang.invoke.TypeDescriptor.OfField.arrayType.

Returns a Class for an array type whose component type is described by this Class.

public <
the type to cast this Class object to
U
>
Class<? extends U>

Returns:

this Class object, cast to represent a subclass of the specified class object.
asSubclass
(Class<U>
the class of the type to cast this Class object to
clazz
)

Casts this Class object to represent a subclass of the class represented by the specified class object.

private String
pack-priv boolean
public T

Returns:

the object after casting, or null if obj is null
cast
(Object
the object to be cast
obj
)

Casts an object to the class or interface represented by this Class object.

private void
checkMemberAccess(SecurityManager sm, int which, Class<?> caller, boolean checkProxyInterfaces)
References Deprecated SecurityManager is deprecated or references (maybe indirectly) at least one deprecated element.

private void
checkPackageAccess(SecurityManager sm, final ClassLoader ccl, boolean checkProxyInterfaces)
References Deprecated SecurityManager is deprecated or references (maybe indirectly) at least one deprecated element.

private static void
checkPackageAccessForPermittedSubclasses(SecurityManager sm, final ClassLoader ccl, Class<?>[] subClasses)
References Deprecated SecurityManager is deprecated or references (maybe indirectly) at least one deprecated element.

public Class<?>

Returns:

a Class describing the component type, or null if this Class does not describe an array type
componentType
()

Implements java.lang.invoke.TypeDescriptor.OfField.componentType.

Returns the component type of this Class, if it describes an array type, or null otherwise.

private static <U> Constructor<U>[]
private static Field[]
private static Method[]
private Class.AnnotationData
createAnnotationData(int classRedefinedCount)

public Optional<ClassDesc>

Returns:

An Optional containing the resulting nominal descriptor, or an empty Optional if one cannot be constructed.
describeConstable
()

Implements java.lang.constant.Constable.describeConstable.

Returns a nominal descriptor for this instance, if one can be constructed, or an empty Optional if one cannot be.

public String

Returns:

the descriptor string for this Class object
descriptorString
()

Implements java.lang.invoke.TypeDescriptor.descriptorString.

Returns the descriptor string of the entity (class, interface, array class, primitive type, or void) represented by this Class object.

public boolean

Returns:

the desired assertion status of the specified class.
desiredAssertionStatus
()

Returns the assertion status that would be assigned to this class if it were to be initialized at the time this method is invoked.

private static native boolean
private Class<?>
pack-priv Map<String, T>
enumConstantDirectory()

Returns a map from simple name to enum constant.

pack-priv Method

Returns:

the Method object for the method found from this class matching the specified name and parameters, or null if not found
findMethod
(boolean
true if only public methods are examined, otherwise all methods
publicOnly
,
String
the name of the method
name
,
Class<?>...
the parameter array
parameterTypes
)

Returns the most specific Method object of this class, super class or interface that have the specified method name and parameter types.

public static Class<?>

Returns:

the Class object for the class with the specified name.
forName
(String
the binary name of the class or the string representing an array type
className
)

Returns the Class object associated with the class or interface with the given string name.

private static Class<?>
forName(String className, Class<?> caller)

public static Class<?>

Returns:

class object representing the desired class
forName
(String
the binary name of the class or the string representing an array class
name
,
boolean
if true the class will be initialized (which implies linking). See Section 12.4 of The Java Language Specification.
initialize
,
ClassLoader
class loader from which the class must be loaded
loader
)

Returns the Class object associated with the class or interface with the given string name, using the given class loader.

private static Class<?>
forName(String name, boolean initialize, ClassLoader loader, Class<?> caller)

public static Class<?>

Returns:

Class object of the given name defined in the given module; null if not found.
forName
(Module
A module
module
,
String
The binary name of the class
name
)

Returns the Class with the given binary name in the given module.

private static Class<?>
forName(Module module, String name, Class<?> caller)

private static native Class<?>
forName0(String name, boolean initialize, ClassLoader loader, Class<?> caller)

Called after security check for system loader access checks have been made.

public static Class<?>

Returns:

the Class object associated with the primitive type of the given name
forPrimitiveName
(String
the name of the primitive type to find
primitiveName
)

Returns the Class object associated with the primitive type of the given name.

public AnnotatedType[]

Returns:

an array representing the superinterfaces
getAnnotatedInterfaces
()

Returns an array of AnnotatedType objects that represent the use of types to specify superinterfaces of the entity represented by this Class object.

public AnnotatedType

Returns:

an object representing the superclass
getAnnotatedSuperclass
()

Returns an AnnotatedType object that represents the use of a type to specify the superclass of the entity represented by this Class object.

public <A extends Annotation> A
getAnnotation(Class<A>
the Class object corresponding to the annotation type
annotationClass
)

Implements java.lang.reflect.AnnotatedElement.getAnnotation.

Returns this element's annotation for the specified type if such an annotation is present, else null.

public Annotation[]
getAnnotations()

Implements java.lang.reflect.AnnotatedElement.getAnnotations.

Returns annotations that are present on this element.

public <A extends Annotation> A[]
getAnnotationsByType(Class<A>
the Class object corresponding to the annotation type
annotationClass
)

Overrides default java.lang.reflect.AnnotatedElement.getAnnotationsByType.

Returns annotations that are associated with this element.

pack-priv AnnotationType
public String

Returns:

the canonical name of the underlying class if it exists, and null otherwise.
getCanonicalName
()

Returns the canonical name of the underlying class as defined by The Java Language Specification.

private String
private int
private native int
pack-priv Object
public Class<?>[]

Returns:

the array of Class objects representing the public members of this class
getClasses
()

Returns an array containing Class objects representing all the public classes and interfaces that are members of the class represented by this Class object.

private int
private native int
public ClassLoader

Returns:

the class loader that loaded the class or interface represented by this Class object.
getClassLoader
()

Returns the class loader for the class.

pack-priv ClassLoader
public Class<?>

Returns:

the Class representing the component type of this class if this class is an array
getComponentType
()

Returns the Class representing the component type of an array.

pack-priv native ConstantPool
public Constructor<T>

Returns:

the Constructor object of the public constructor that matches the specified parameterTypes
getConstructor
(Class<?>...
the parameter array
parameterTypes
)

Returns a Constructor object that reflects the specified public constructor of the class represented by this Class object.

private Constructor<T>
getConstructor0(Class<?>[] parameterTypes, int which)

public Constructor<?>[]

Returns:

the array of Constructor objects representing the public constructors of this class
getConstructors
()

Returns an array containing Constructor objects reflecting all the public constructors of the class represented by this Class object.

public <A extends Annotation> A
getDeclaredAnnotation(Class<A>
the Class object corresponding to the annotation type
annotationClass
)

Overrides default java.lang.reflect.AnnotatedElement.getDeclaredAnnotation.

Returns this element's annotation for the specified type if such an annotation is directly present, else null.

pack-priv Map<Class<? extends Annotation>, Annotation>
public Annotation[]
getDeclaredAnnotations()

Implements java.lang.reflect.AnnotatedElement.getDeclaredAnnotations.

Returns annotations that are directly present on this element.

public <A extends Annotation> A[]
getDeclaredAnnotationsByType(Class<A>
the Class object corresponding to the annotation type
annotationClass
)

Overrides default java.lang.reflect.AnnotatedElement.getDeclaredAnnotationsByType.

Returns this element's annotation(s) for the specified type if such annotations are either directly present or indirectly present.

public Class<?>[]

Returns:

the array of Class objects representing all the declared members of this class
getDeclaredClasses
()

Returns an array of Class objects reflecting all the classes and interfaces declared as members of the class represented by this Class object.

private native Class<?>[]
public Constructor<T>

Returns:

The Constructor object for the constructor with the specified parameter list
getDeclaredConstructor
(Class<?>...
the parameter array
parameterTypes
)

Returns a Constructor object that reflects the specified constructor of the class represented by this Class object.

public Constructor<?>[]

Returns:

the array of Constructor objects representing all the declared constructors of this class
getDeclaredConstructors
()

Returns an array of Constructor objects reflecting all the constructors implicitly or explicitly declared by the class represented by this Class object.

private native Constructor<T>[]
getDeclaredConstructors0(boolean publicOnly)

public Field

Returns:

the Field object for the specified field in this class
getDeclaredField
(String
the name of the field
name
)

Returns a Field object that reflects the specified declared field of the class or interface represented by this Class object.

public Field[]

Returns:

the array of Field objects representing all the declared fields of this class
getDeclaredFields
()

Returns an array of Field objects reflecting all the fields declared by the class or interface represented by this Class object.

private native Field[]
getDeclaredFields0(boolean publicOnly)

public Method

Returns:

the Method object for the method of this class matching the specified name and parameters
getDeclaredMethod
(String
the name of the method
name
,
Class<?>...
the parameter array
parameterTypes
)

Returns a Method object that reflects the specified declared method of the class or interface represented by this Class object.

public Method[]

Returns:

the array of Method objects representing all the declared methods of this class
getDeclaredMethods
()

Returns an array containing Method objects reflecting all the declared methods of the class or interface represented by this Class object, including public, protected, default (package) access, and private methods, but excluding inherited methods.

private native Method[]
getDeclaredMethods0(boolean publicOnly)

pack-priv List<Method>

Returns:

the list of Method objects for the public methods of this class matching the specified name and parameters
getDeclaredPublicMethods
(String
the name of the method
name
,
Class<?>...
the parameter array
parameterTypes
)

Returns the list of Method objects for the declared public methods of this class or interface that have the specified method name and parameter types.

public Class<?>

Returns:

the declaring class for this class
getDeclaringClass
()

If the class or interface represented by this Class object is a member of another class, returns the Class object representing the class in which it was declared.

private native Class<?>
public Class<?>

Returns:

the immediately enclosing class of the underlying class
getEnclosingClass
()

Returns the immediately enclosing class of the underlying class.

public Constructor<?>

Returns:

the immediately enclosing constructor of the underlying class, if that class is a local or anonymous class; otherwise null.
getEnclosingConstructor
()

If this Class object represents a local or anonymous class within a constructor, returns a Constructor object representing the immediately enclosing constructor of the underlying class.

public Method

Returns:

the immediately enclosing method of the underlying class, if that class is a local or anonymous class; otherwise null.
getEnclosingMethod
()

If this Class object represents a local or anonymous class within a method, returns a Method object representing the immediately enclosing method of the underlying class.

private native Object[]
private Class.EnclosingMethodInfo
public T[]

Returns:

an array containing the values comprising the enum class represented by this Class object in the order they're declared, or null if this Class object does not represent an enum class
getEnumConstants
()

Returns the elements of this enum class or null if this Class object does not represent an enum class.

pack-priv T[]
getEnumConstantsShared()

Returns the elements of this enum class or null if this Class object does not represent an enum class; identical to getEnumConstants except that the result is uncloned, cached, and shared by all callers.

pack-priv static byte[]
private GenericsFactory
public Field

Returns:

the Field object of this class specified by name
getField
(String
the field name
name
)

Returns a Field object that reflects the specified public member field of the class or interface represented by this Class object.

private Field
public Field[]

Returns:

the array of Field objects representing the public fields
getFields
()

Returns an array containing Field objects reflecting all the accessible public fields of the class or interface represented by this Class object.

private ClassRepository
public Type[]

Returns:

an array of interfaces directly implemented by this class
getGenericInterfaces
()

Returns the Types representing the interfaces directly implemented by the class or interface represented by this Class object.

private native String
public Type

Returns:

the direct superclass of the class represented by this Class object
getGenericSuperclass
()

Returns the Type representing the direct superclass of the entity (class, interface, primitive type or void) represented by this Class object.

public Class<?>[]

Returns:

an array of interfaces directly implemented by this class
getInterfaces
()

Returns the interfaces directly implemented by the class or interface represented by this Class object.

private Class<?>[]
getInterfaces(boolean cloneArray)

private native Class<?>[]
public Method

Returns:

the Method object that matches the specified name and parameterTypes
getMethod
(String
the name of the method
name
,
Class<?>...
the list of parameters
parameterTypes
)

Returns a Method object that reflects the specified public member method of the class or interface represented by this Class object.

private Method
getMethod0(String name, Class<?>[] parameterTypes)

public Method[]

Returns:

the array of Method objects representing the public methods of this class
getMethods
()

Returns an array containing Method objects reflecting all the public methods of the class or interface represented by this Class object, including those declared by the class or interface and those inherited from superclasses and superinterfaces.

private PublicMethods.MethodList
getMethodsRecursive(String name, Class<?>[] parameterTypes, boolean includeStatic, boolean publicOnly)

public native int

Returns:

the int representing the modifiers for this class
getModifiers
()

Returns the Java language modifiers for this class or interface, encoded in an integer.

public Module

Returns:

the module that this class or interface is a member of
getModule
()

Returns the module that this class or interface is a member of.

public String

Returns:

the name of the class, interface, or other entity represented by this Class object.
getName
()

Returns the name of the entity (class, interface, array class, primitive type, or void) represented by this Class object.

public Class<?>

Returns:

the nest host of this class or interface
getNestHost
()

Returns the nest host of the nest to which the class or interface represented by this Class object belongs.

private native Class<?>
public Class<?>[]

Returns:

an array of all classes and interfaces in the same nest as this class or interface
getNestMembers
()

Returns an array containing Class objects representing all the classes and interfaces that are members of the nest to which the class or interface represented by this Class object belongs.

private native Class<?>[]
public Package

Returns:

the package of this class.
getPackage
()

Gets the package of this class.

public String

Returns:

the fully qualified package name
getPackageName
()

Returns the fully qualified package name.

public Class<?>[]

Returns:

an array of Class objects of the permitted subclasses of this class or interface, or null if this class or interface is not sealed.
getPermittedSubclasses
()

Returns an array containing Class objects representing the direct subinterfaces or subclasses permitted to extend or implement this class or interface if it is sealed.

private native Class<?>[]
pack-priv static native Class<?>
public ProtectionDomain

Returns:

the ProtectionDomain of this class
getProtectionDomain
()

Returns the ProtectionDomain of this class.

private native ProtectionDomain
getProtectionDomain0()

Returns the ProtectionDomain of this class.

pack-priv native byte[]
pack-priv native byte[]
public RecordComponent[]

Returns:

An array of RecordComponent objects representing all the record components of this record class, or null if this class is not a record class
getRecordComponents
()

Returns an array of RecordComponent objects representing all the record components of this record class, or null if this class is not a record class.

private native RecordComponent[]
private static ReflectionFactory
public URL

Returns:

A java.net.URL object; null if no resource with this name is found, the resource cannot be located by a URL, the resource is in a package that is not open to at least the caller module, or access to the resource is denied by the security manager.
getResource
(String
name of the desired resource
name
)

Finds a resource with a given name.

public InputStream

Returns:

A java.io.InputStream object; null if no resource with this name is found, the resource is in a package that is not open to at least the caller module, or access to the resource is denied by the security manager.
getResourceAsStream
(String
name of the desired resource
name
)

Finds a resource with a given name.

public native Object[]

Returns:

the signers of this class, or null if there are no signers. In particular, this method returns null if this Class object represents a primitive type or void.
getSigners
()

Gets the signers of this class.

private String
getSimpleBinaryName()

Returns the "simple binary name" of the underlying class, i.e., the binary name without the leading enclosing class name.

private native String
public String

Returns:

the simple name of the underlying class
getSimpleName
()

Returns the simple name of the underlying class as given in the source code.

private String
public native Class<? super T>

Returns:

the direct superclass of the class represented by this Class object
getSuperclass
()

Returns the Class representing the direct superclass of the entity (class, interface, primitive type or void) represented by this Class.

public String

Returns:

an informative string for the name of this class or interface
getTypeName
()

Overrides default java.lang.reflect.Type.getTypeName.

Return an informative string for the name of this class or interface.

public TypeVariable<Class<T>>[]

Returns:

an array of TypeVariable objects that represent the type variables declared by this generic declaration
getTypeParameters
()

Implements java.lang.reflect.GenericDeclaration.getTypeParameters.

Returns an array of TypeVariable objects that represent the type variables declared by the generic declaration represented by this GenericDeclaration object, in declaration order.

private boolean
private boolean
private native String
public boolean

Returns:

true if this Class object represents an annotation interface; false otherwise
isAnnotation
()

Returns true if this Class object represents an annotation interface.

public boolean
isAnnotationPresent(Class<? extends Annotation>
the Class object corresponding to the annotation type
annotationClass
)

Overrides default java.lang.reflect.AnnotatedElement.isAnnotationPresent.

Returns true if an annotation for the specified type is present on this element, else false.

public boolean

Returns:

true if and only if this class is an anonymous class.
isAnonymousClass
()

Returns true if and only if the underlying class is an anonymous class.

public native boolean

Returns:

true if this Class object represents an array class; false otherwise.
isArray
()

Implements java.lang.invoke.TypeDescriptor.OfField.isArray.

Determines if this Class object represents an array class.

public native boolean

Returns:

the boolean value indicating whether objects of the type cls can be assigned to objects of this class
isAssignableFrom
(Class<?>
the Class object to be checked
cls
)

Determines if the class or interface represented by this Class object is either the same as, or is a superclass or superinterface of, the class or interface represented by the specified Class parameter.

private boolean
public boolean

Returns:

true if and only if this class was declared as an enum in the source code
isEnum
()

Returns true if and only if this class was declared as an enum in the source code.

public native boolean

Returns:

true if and only if this class is a hidden class.
isHidden
()

Returns true if and only if the underlying class is a hidden class.

public native boolean

Returns:

true if obj is an instance of this class
isInstance
(Object
the object to check
obj
)

Determines if the specified Object is assignment-compatible with the object represented by this Class.

public native boolean

Returns:

true if this Class object represents an interface; false otherwise.
isInterface
()

Determines if this Class object represents an interface type.

public boolean

Returns:

true if and only if this class is a local class.
isLocalClass
()

Returns true if and only if the underlying class is a local class.

private boolean
isLocalOrAnonymousClass()

Returns true if this is a local class or an anonymous class.

public boolean

Returns:

true if and only if this class is a member class.
isMemberClass
()

Returns true if and only if the underlying class is a member class.

public boolean

Returns:

true if this class and c are members of the same nest; and false otherwise.
isNestmateOf
(Class<?>
the class to check
c
)

Determines if the given Class is a nestmate of the class or interface represented by this Class object.

private boolean
isOpenToCaller(String name, Class<?> caller)

Returns true if a resource with the given name can be located by the given caller.

public native boolean

Returns:

true if and only if this class represents a primitive type
isPrimitive
()

Implements java.lang.invoke.TypeDescriptor.OfField.isPrimitive.

Determines if this Class object represents a primitive type or void.

public boolean

Returns:

true if and only if this class is a record class, otherwise false
isRecord
()

Returns true if and only if this class is a record class.

private native boolean
public boolean

Returns:

true if and only if this Class object represents a sealed class or interface.
isSealed
()

Returns true if and only if this Class object represents a sealed class or interface.

public boolean

Returns:

true if and only if this class has the synthetic modifier bit set
isSynthetic
()

Returns true if and only if this class has the synthetic modifier bit set.

private boolean
isTopLevelClass()

Returns true if this is a top level class.

private String
methodToString(String name, Class<?>[] argTypes)

Helper method to get the method name from arguments.

public T

Returns:

a newly allocated instance of the class represented by this object.
newInstance
()
Deprecated since 9. This method propagates any exception thrown by the nullary constructor, including a checked exception.

Creates a new instance of the class represented by this Class object.

private Class.ReflectionData<T>
newReflectionData(SoftReference<Class.ReflectionData<T>> oldReflectionData, int classRedefinedCount)

private Constructor<T>[]
privateGetDeclaredConstructors(boolean publicOnly)

private Field[]
privateGetDeclaredFields(boolean publicOnly)

private Method[]
privateGetDeclaredMethods(boolean publicOnly)

private Field[]
private Method[]
pack-priv ProtectionDomain
private Class.ReflectionData<T>
private static native void
private String
resolveName(String name)

Add a package name prefix if the name is not absolute.

private static Field
searchFields(Field[] fields, String name)

private static Method
searchMethods(Method[] methods, String name, Class<?>[] parameterTypes)

pack-priv native void
setSigners(Object[] signers)

Set the signers of this class.

private static Class<?>
public String

Returns:

a string describing this Class, including information about modifiers and type parameters
toGenericString
()

Returns a string describing this Class, including information about modifiers, sealed/non-sealed status, and type parameters.

public String

Returns:

a string representation of this Class object.
toString
()

Overrides java.lang.Object.toString.

Converts the object to a string.

pack-priv static String
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAllwaitwaitwait