Class ReplacementForClass<T>
java.lang.Object
de.inetsoftware.jwebassembly.module.nativecode.ReplacementForClass<T>
- Type Parameters:
T- the type of the class modeled by thisClass
Replacement for java.lang.Class
-
Field Summary
Fields -
Constructor Summary
ConstructorsModifierConstructorDescriptionprivateReplacementForClass(int vtable, int classIdx) Create a instance -
Method Summary
Modifier and TypeMethodDescriptionprivate static ReplacementForClass<?> classConstant(int classIdx) WASM codebooleanReplacement of the native Java methodClass.desiredAssertionStatus()Replacement of the Java method enumConstantDirectory() Returns a map from simple name to enum constant.static Class<?> Replacement of the Java method forName(String)Replacement of the Java method getCanonicalName()private static ReplacementForClass<?> getClassFromTable(int classIdx) WASM codeReplacement of the Java method getClassLoader()(package private) ClassLoaderReplacement of the Java method getClassLoader0()private static ReplacementForClass<?> getClassObject(Object obj) Replacement forObject.getClass().Replacement of the native Java method getComponentType()getDeclaredConstructor(Class<?>... parameterTypes) Replacement of the Java method getDeclaredConstructor()getDeclaredField(String name) Replacement of the Java method getDeclaredField()getDeclaredMethod(String name, Class<?>... parameterTypes) Replacement of the Java method getDeclaredMethod()Type[]Replacement of the Java method getGenericInterfaces()Class<?>[]Replacement of the Java method getInterfaces()private static intgetIntFromMemory(int pos) WASM codeReplacement of the Java method getMethod()getName()Replacement forClass.getName()Replacement of the Java methods getPackage()(package private) static ReplacementForClass<?> getPrimitiveClass(String name) Replacement of the native Java methodClass.getPrimitiveClass(String)getResourceAsStream(String name) Replacement of the Java method getResourceAsStream()Replacement of the Java method getSimpleName()Replacement of the Java methods getSuperclass()Replacement of the Java method getTypeName()booleanisArray()Replacement of the Java method isArray()booleanisAssignableFrom(Class<?> cls) Replacement of the Java method isAssignableFrom()booleanisInstance(Object obj) Replacement of the Java method isInstance()booleanReplacement of the Java method isInterface()booleanReplacement of the Java methodClass.isPrimitive()Replacement of the Java method newInstance()private static voidsetClassIntoTable(int strIdx, ReplacementForClass<?> clazz) WASM codeprivate static intWASM code
-
Field Details
-
vtable
final int vtableThe pointer in the memory for the class/type description. -
classIdx
final int classIdx
-
-
Constructor Details
-
ReplacementForClass
private ReplacementForClass(int vtable, int classIdx) Create a instance- Parameters:
vtable- the pointer in the memory for the class/type description.classIdx- the class index, the ID of the class
-
-
Method Details
-
getClassObject
Replacement forObject.getClass(). The documentation of the memory of the type description is done in method:invalid reference
TypeManager.StructType#writeToStream(java.io.ByteArrayOutputStream, java.util.function.ToIntFunction)- Parameters:
obj- the instance- Returns:
- the class
-
classConstant
WASM codeGet a constant Class from the table.
- Parameters:
classIdx- the id/index of the Class.- Returns:
- the string
- See Also:
-
getClassFromTable
WASM codeGet a Class instance from the Class table. Should be inlined from the optimizer.
- Parameters:
classIdx- the id/index of the Class.- Returns:
- the string or null if not already set.
-
setClassIntoTable
WASM codeSet a Class instance in the Class table. Should be inlined from the optimizer.
- Parameters:
strIdx- the id/index of the string.clazz- the Class instance
-
typeTableMemoryOffset
private static int typeTableMemoryOffset()WASM codePlaceholder for a synthetic function. Should be inlined from the optimizer.
- Returns:
- the memory offset of the string data in the element section
-
getIntFromMemory
private static int getIntFromMemory(int pos) WASM codeLoad an i32 from memory. The offset must be aligned. Should be inlined from the optimizer.
- Parameters:
pos- the memory position- Returns:
- the value from the memory
-
forName
Replacement of the Java method forName(String)- Parameters:
className- the fully qualified name of the desired class.- Returns:
- the
Classobject for the class with the specified name. - Throws:
ClassNotFoundException
-
newInstance
Replacement of the Java method newInstance()- Returns:
- a newly allocated instance of the class represented by this object.
- Throws:
InstantiationExceptionIllegalAccessException
-
isInstance
Replacement of the Java method isInstance()- Parameters:
obj- the object to check- Returns:
- true if
objis an instance of this class
-
isAssignableFrom
Replacement of the Java method isAssignableFrom()- Parameters:
cls- the class to check- Returns:
- true, if type
clscan be assigned to objects of this class
-
isInterface
public boolean isInterface()Replacement of the Java method isInterface()- Returns:
trueif this object represents an interface;
-
isArray
public boolean isArray()Replacement of the Java method isArray()- Returns:
trueif this object represents an array class;
-
isPrimitive
public boolean isPrimitive()Replacement of the Java methodClass.isPrimitive()- Returns:
- true if and only if this class represents a primitive type
-
getName
-
getClassLoader
Replacement of the Java method getClassLoader() -
getClassLoader0
ClassLoader getClassLoader0()Replacement of the Java method getClassLoader0() -
getSuperclass
-
getPackage
Replacement of the Java methods getPackage() -
getInterfaces
Replacement of the Java method getInterfaces()- Returns:
- an array of interfaces implemented by this class.
-
getGenericInterfaces
Replacement of the Java method getGenericInterfaces()- Returns:
- an array of interfaces implemented by this class
-
getComponentType
Replacement of the native Java method getComponentType() -
getSimpleName
Replacement of the Java method getSimpleName()- Returns:
- the simple name of the underlying class
-
getTypeName
Replacement of the Java method getTypeName()- Returns:
- an informative string for the name of this type
-
getCanonicalName
Replacement of the Java method getCanonicalName()- Returns:
- the canonical name of the underlying class
-
getMethod
-
getDeclaredField
-
getDeclaredMethod
-
getDeclaredConstructor
Replacement of the Java method getDeclaredConstructor() -
getResourceAsStream
Replacement of the Java method getResourceAsStream() -
getPrimitiveClass
Replacement of the native Java methodClass.getPrimitiveClass(String)- Parameters:
name- the class name- Returns:
- the class
- See Also:
-
desiredAssertionStatus
public boolean desiredAssertionStatus()Replacement of the native Java methodClass.desiredAssertionStatus()- Returns:
- the desired assertion status of the specified class.
-
enumConstantDirectory
-