You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Implement class JClass<T>, porting of the Java class java.lang.Class<T>.
Instances of the class Class represent classes and interfaces in a running Java application. An enum is a kind of class and an annotation 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.
T - the type of the class modeled by this Class object.
Class objects in Java are never instantiated directly, but are instantiated by the JVM Class Loader. Should we emulate its behaviour?
There's a problem of ciruclar dependency between JObject module and JClass module since JClass extends JObject, but JObject returns an instance of JClass in getClass() method. We could have the same problem with JString or other classes in future.
We should find a way for determine the type of an object at runtime. It's not possible with Typescript generics or interfaces (maybe to replace with annotations and abstract classes).
Implement class
JClass<T>
, porting of the Java classjava.lang.Class<T>
.Expected Behavior
extends
JObject
classimplements
JAnnotatedElement
interfaceimplements
JGenericDeclaration
interfaceimplements
JSerializable
interfaceimplements
JType
interfacepublic method
cast(obj: JObject): T
getCanonicalName(): JString
getName(): JString
getSimpleName(): JString
getTypeName(): JString
isAnnotation(): Jboolean
isArray(): Jboolean
isEnum(): Jboolean
isInstance(obj: JObject): Jboolean
isInterface(): Jboolean
newInstance(): T
toString(): JString
Do it later
forName(className: JString): JClass<?>
forName(name: JString, initialize: Jboolean, loader: JClassLoader)
asSubclass<U>(clazz: JClass<U>): JClass<? extends U>
desiredAssertionStatus(): Jboolean
getAnnotatedInterfaces(): Jarray<JAnnotatedType>
getAnnotatedSuperclass(): JAnnotatedType
getAnnotation<A extends JAnnotation>(annotationClass: JClass<A>): A
getAnnotations(): Jarray<JAnnotation>
getAnnotationsByType<A extends Annotation>(annotationClass: JClass<A>): Jarray<A>
getClasses(): Jarray<JClass<?>>
getClassLoader(): JClassLoader
getComponentType(): JClass<?>
getConstructor(...parameterTypes: Jarray<JClass<?>>): JConstructor<T>
getConstructors(): Jarray<JConstructor<?>>
getDeclaredAnnotation<A extends JAnnotation>(annotationClass: JClass<A>): A
getDeclaredAnnotations(): Jarray<JAnnotation>
getDeclaredAnnotationsByType<A extends JAnnotation>(annotationClass: JClass<A>): Jarray<A>
getDeclaredClasses(): Jarray<JClass<?>>
getDeclaredConstructor(...parameterTypes: Jarray<JClass<?>>): JConstructor<T>
getDeclaredConstructors(): Jarray<JConstructor<?>>
getDeclaredField(name: JString): JField
getDeclaredFields(): Jarray<JField>
getDeclaredMethod(name: JString, ...parameterTypes: Jarray<JClass<?>>): JMethod
getDeclaredMethods(): Jarray<JMethod>
getDeclaringClass(): JClass<?>
getEnclosingClass(): JClass<?>
getEnclosingConstructor(): JConstructor<?>
getEnclosingMethod(): JMethod
getEnumConstants(): Jarray<T>
getField(name: JString): JField
getFields(): Jarray<JField>
getGenericInterfaces(): Jarray<JType>
getGenericSuperclass(): JType
getInterfaces(): Jarray<JClass<?>>
getMethod(name: JString, ...parameterTypes: Jarray<JClass<?>>): JMethod
getMethods(): Jarray<JMethod>
getModifiers(): Jint
getPackage(): JPackage
getProtectionDomain(): JProtectionDomain
getResource(name: JString): JURL
getResourceAsStream(name: JString): JInputStream
getSigners(): Jarray<JObject>
getSuperclass(): JClass<? extends T>
getTypeParameters(): Jarray<JTypeVariable<JClass<T>>>
isAnnotationPresent(annotationClass: JClass<? extends JAnnotation>): Jboolean
isAnonymousClass(): Jboolean
isAssignableFrom(cls: JClass<?>): Jboolean
isLocalClass(): Jboolean
isMemberClass(): Jboolean
isPrimitive(): Jboolean
isSynthetic(): Jboolean
toGenericString(): JString
The text was updated successfully, but these errors were encountered: