Class - JRE Emulation | JRE Emulation
public final class

Class

extends Object
implements AnnotatedElement GenericDeclaration Serializable Type
java.lang.Object
   ↳ java.lang.Class<T>

Class Overview

Stub implementation of java.lang.Class.

See Also

Summary

Public Constructors
Class()
Public Methods
<U> Class<? extends U> asSubclass(Class<U> clazz)
T cast(Object obj)
boolean desiredAssertionStatus()
static Class<?> forName(String name, boolean initialize, ClassLoader loader)
static Class<?> forName(String className)
<A extends Annotation> A getAnnotation(Class<A> annotationClass)
Annotation[] getAnnotations()
Returns annotations that are present on this element.
<T extends Annotation> T[] getAnnotationsByType(Class<T> annotationClass)
Returns annotations that are associated with this element.
String getCanonicalName()
ClassLoader getClassLoader()
Class[]<?> getClasses()
Class<?> getComponentType()
Constructor<T> getConstructor(Class...<?> parameterTypes)
Constructor[]<?> getConstructors()
<T extends Annotation> T getDeclaredAnnotation(Class<T> annotationClass)
Returns this element's annotation for the specified type if such an annotation is directly present, else null.
Annotation[] getDeclaredAnnotations()
Returns annotations that are directly present on this element.
<T extends Annotation> T[] getDeclaredAnnotationsByType(Class<T> annotationClass)
Returns this element's annotation(s) for the specified type if such annotations are either directly present or indirectly present.
Class[]<?> getDeclaredClasses()
Constructor<T> getDeclaredConstructor(Class...<?> parameterTypes)
Constructor[]<?> getDeclaredConstructors()
Field getDeclaredField(String name)
Field[] getDeclaredFields()
Method getDeclaredMethod(String name, Class...<?> parameterTypes)
Method[] getDeclaredMethods()
Class<?> getDeclaringClass()
Class<?> getEnclosingClass()
Constructor<?> getEnclosingConstructor()
Method getEnclosingMethod()
T[] getEnumConstants()
Field getField(String name)
Field[] getFields()
Type[] getGenericInterfaces()
Type getGenericSuperclass()
Class[]<?> getInterfaces()
Method getMethod(String name, Class...<?> parameterTypes)
Method[] getMethods()
int getModifiers()
String getName()
Package getPackage()
ProtectionDomain getProtectionDomain()
URL getResource(String name)
InputStream getResourceAsStream(String name)
Object[] getSigners()
String getSimpleName()
Class<? super T> getSuperclass()
String getTypeName()
TypeVariable[]<Class<T>> getTypeParameters()
Returns the declared type parameters in declaration order.
boolean isAnnotation()
boolean isAnnotationPresent(Class<? extends Annotation> annotationType)
Returns true if an annotation for the specified type is present on this element, else false.
boolean isAnonymousClass()
boolean isArray()
boolean isAssignableFrom(Class<?> cls)
boolean isEnum()
boolean isInstance(Object obj)
boolean isInterface()
boolean isLocalClass()
boolean isMemberClass()
boolean isPrimitive()
boolean isSynthetic()
T newInstance()
String toGenericString()
String toString()
Returns a string containing a concise, human-readable description of this object.
Inherited Methods
[Expand]
From class java.lang.Object
From interface java.lang.reflect.AnnotatedElement
From interface java.lang.reflect.GenericDeclaration

Public Constructors

public Class ()

Public Methods

public Class<? extends U> asSubclass (Class<U> clazz)

public T cast (Object obj)

public boolean desiredAssertionStatus ()

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

public static Class<?> forName (String className)

public A getAnnotation (Class<A> annotationClass)

public Annotation[] getAnnotations ()

Returns annotations that are present on this element. If there are no annotations present on this element, the return value is an array of length 0. The caller of this method is free to modify the returned array; it will have no effect on the arrays returned to other callers.

Returns
  • annotations present on this element

public T[] getAnnotationsByType (Class<T> annotationClass)

Returns annotations that are associated with this element. If there are no annotations associated with this element, the return value is an array of length 0. The difference between this method and getAnnotation(Class) is that this method detects if its argument is a repeatable annotation type (JLS 9.6), and if so, attempts to find one or more annotations of that type by "looking through" a container annotation. The caller of this method is free to modify the returned array; it will have no effect on the arrays returned to other callers.

Parameters
annotationClass the Class object corresponding to the annotation type
Returns
  • all this element's annotations for the specified annotation type if associated with this element, else an array of length zero

public String getCanonicalName ()

public ClassLoader getClassLoader ()

public Class[]<?> getClasses ()

public Class<?> getComponentType ()

public Constructor<T> getConstructor (Class...<?> parameterTypes)

public Constructor[]<?> getConstructors ()

public T getDeclaredAnnotation (Class<T> annotationClass)

Returns this element's annotation for the specified type if such an annotation is directly present, else null. This method ignores inherited annotations. (Returns null if no annotations are directly present on this element.)

Parameters
annotationClass the Class object corresponding to the annotation type
Returns
  • this element's annotation for the specified annotation type if directly present on this element, else null

public Annotation[] getDeclaredAnnotations ()

Returns annotations that are directly present on this element. This method ignores inherited annotations. If there are no annotations directly present on this element, the return value is an array of length 0. The caller of this method is free to modify the returned array; it will have no effect on the arrays returned to other callers.

Returns
  • annotations directly present on this element

public T[] getDeclaredAnnotationsByType (Class<T> annotationClass)

Returns this element's annotation(s) for the specified type if such annotations are either directly present or indirectly present. This method ignores inherited annotations. If there are no specified annotations directly or indirectly present on this element, the return value is an array of length 0. The difference between this method and getDeclaredAnnotation(Class) is that this method detects if its argument is a repeatable annotation type (JLS 9.6), and if so, attempts to find one or more annotations of that type by "looking through" a container annotation if one is present. The caller of this method is free to modify the returned array; it will have no effect on the arrays returned to other callers.

Parameters
annotationClass the Class object corresponding to the annotation type
Returns
  • all this element's annotations for the specified annotation type if directly or indirectly present on this element, else an array of length zero

public Class[]<?> getDeclaredClasses ()

public Constructor<T> getDeclaredConstructor (Class...<?> parameterTypes)

public Constructor[]<?> getDeclaredConstructors ()

public Field getDeclaredField (String name)

public Field[] getDeclaredFields ()

public Method getDeclaredMethod (String name, Class...<?> parameterTypes)

public Method[] getDeclaredMethods ()

public Class<?> getDeclaringClass ()

public Class<?> getEnclosingClass ()

public Constructor<?> getEnclosingConstructor ()

public Method getEnclosingMethod ()

public T[] getEnumConstants ()

public Field getField (String name)

public Field[] getFields ()

public Type[] getGenericInterfaces ()

public Type getGenericSuperclass ()

public Class[]<?> getInterfaces ()

public Method getMethod (String name, Class...<?> parameterTypes)

public Method[] getMethods ()

public int getModifiers ()

public String getName ()

public Package getPackage ()

public ProtectionDomain getProtectionDomain ()

public URL getResource (String name)

public InputStream getResourceAsStream (String name)

public Object[] getSigners ()

public String getSimpleName ()

public Class<? super T> getSuperclass ()

public String getTypeName ()

public TypeVariable[]<Class<T>> getTypeParameters ()

Returns the declared type parameters in declaration order. If there are no type parameters, this method returns a zero length array.

Returns
  • the declared type parameters in declaration order

public boolean isAnnotation ()

public boolean isAnnotationPresent (Class<? extends Annotation> annotationType)

Returns true if an annotation for the specified type is present on this element, else false. This method is designed primarily for convenient access to marker annotations.

The truth value returned by this method is equivalent to: getAnnotation(annotationClass) != null

The body of the default method is specified to be the code above.

Parameters
annotationType the Class object corresponding to the annotation type
Returns
  • true if an annotation for the specified annotation type is present on this element, else false

public boolean isAnonymousClass ()

public boolean isArray ()

public boolean isAssignableFrom (Class<?> cls)

public boolean isEnum ()

public boolean isInstance (Object obj)

public boolean isInterface ()

public boolean isLocalClass ()

public boolean isMemberClass ()

public boolean isPrimitive ()

public boolean isSynthetic ()

public T newInstance ()

public String toGenericString ()

public String toString ()

Returns a string containing a concise, human-readable description of this object. Subclasses are encouraged to override this method and provide an implementation that takes into account the object's type and data. The default implementation is equivalent to the following expression:

   getClass().getName() + '@' + Integer.toHexString(hashCode())

See Writing a useful toString method if you intend implementing your own toString method.

Returns
  • a printable representation of this object.