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
ConstructorsModifierConstructorDescriptionprivate
ReplacementForClass
(int vtable, int classIdx) Create a instance -
Method Summary
Modifier and TypeMethodDescriptionprivate static ReplacementForClass
<?> classConstant
(int classIdx) WASM codeboolean
Replacement 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) ClassLoader
Replacement 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 int
getIntFromMemory
(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(java.lang.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()boolean
isArray()
Replacement of the Java method isArray()boolean
isAssignableFrom
(Class<?> cls) Replacement of the Java method isAssignableFrom()boolean
isInstance
(Object obj) Replacement of the Java method isInstance()boolean
Replacement of the Java method isInterface()boolean
Replacement of the Java methodClass.isPrimitive()
Replacement of the Java method newInstance()private static void
setClassIntoTable
(int strIdx, ReplacementForClass<?> clazz) WASM codeprivate static int
WASM 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
Class
object 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:
InstantiationException
IllegalAccessException
-
isInstance
Replacement of the Java method isInstance()- Parameters:
obj
- the object to check- Returns:
- true if
obj
is an instance of this class
-
isAssignableFrom
Replacement of the Java method isAssignableFrom()- Parameters:
cls
- the class to check- Returns:
- true, if type
cls
can be assigned to objects of this class
-
isInterface
public boolean isInterface()Replacement of the Java method isInterface()- Returns:
true
if this object represents an interface;
-
isArray
public boolean isArray()Replacement of the Java method isArray()- Returns:
true
if 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
Replacement forClass.getName()
- Returns:
- the name
-
getClassLoader
Replacement of the Java method getClassLoader() -
getClassLoader0
ClassLoader getClassLoader0()Replacement of the Java method getClassLoader0() -
getSuperclass
Replacement of the Java methods 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
Replacement of the Java method getMethod() -
getDeclaredField
Replacement of the Java method getDeclaredField() -
getDeclaredMethod
Replacement of the Java method getDeclaredMethod() -
getDeclaredConstructor
Replacement of the Java method getDeclaredConstructor() -
getResourceAsStream
Replacement of the Java method getResourceAsStream() -
getPrimitiveClass
Replacement of the native Java methodClass.getPrimitiveClass(java.lang.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
Replacement of the Java method enumConstantDirectory() Returns a map from simple name to enum constant. This package-private method is used internally by Enum to implement
-