Class ReplacementForClass<T>
- java.lang.Object
-
- de.inetsoftware.jwebassembly.module.nativecode.ReplacementForClass<T>
-
- Type Parameters:
T- the type of the class modeled by thisClass
class ReplacementForClass<T> extends java.lang.ObjectReplacement for java.lang.Class
-
-
Constructor Summary
Constructors Modifier Constructor Description privateReplacementForClass(int vtable, int classIdx)Create a instance
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description private static ReplacementForClass<?>classConstant(int classIdx)WASM codebooleandesiredAssertionStatus()Replacement of the native Java methodClass.desiredAssertionStatus()(package private) java.util.Map<java.lang.String,T>enumConstantDirectory()Replacement of the Java method enumConstantDirectory() Returns a map from simple name to enum constant.static java.lang.Class<?>forName(java.lang.String className)Replacement of the Java method forName(String)java.lang.StringgetCanonicalName()Replacement of the Java method getCanonicalName()private static ReplacementForClass<?>getClassFromTable(int classIdx)WASM codejava.lang.ClassLoadergetClassLoader()Replacement of the Java method getClassLoader()(package private) java.lang.ClassLoadergetClassLoader0()Replacement of the Java method getClassLoader0()private static ReplacementForClass<?>getClassObject(java.lang.Object obj)Replacement forObject.getClass().ReplacementForClass<?>getComponentType()Replacement of the native Java method getComponentType()java.lang.reflect.Constructor<T>getDeclaredConstructor(java.lang.Class<?>... parameterTypes)Replacement of the Java method getDeclaredConstructor()java.lang.reflect.FieldgetDeclaredField(java.lang.String name)Replacement of the Java method getDeclaredField()java.lang.reflect.MethodgetDeclaredMethod(java.lang.String name, java.lang.Class<?>... parameterTypes)Replacement of the Java method getDeclaredMethod()java.lang.reflect.Type[]getGenericInterfaces()Replacement of the Java method getGenericInterfaces()java.lang.Class<?>[]getInterfaces()Replacement of the Java method getInterfaces()private static intgetIntFromMemory(int pos)WASM codejava.lang.reflect.MethodgetMethod(java.lang.String name, java.lang.Class<?>... parameterTypes)Replacement of the Java method getMethod()java.lang.StringgetName()Replacement forClass.getName()java.lang.PackagegetPackage()Replacement of the Java methods getPackage()(package private) static ReplacementForClass<?>getPrimitiveClass(java.lang.String name)Replacement of the native Java methodClass.getPrimitiveClass(java.lang.String)java.io.InputStreamgetResourceAsStream(java.lang.String name)Replacement of the Java method getResourceAsStream()java.lang.StringgetSimpleName()Replacement of the Java method getSimpleName()java.lang.Class<? super T>getSuperclass()Replacement of the Java methods getSuperclass()java.lang.StringgetTypeName()Replacement of the Java method getTypeName()booleanisArray()Replacement of the Java method isArray()booleanisAssignableFrom(java.lang.Class<?> cls)Replacement of the Java method isAssignableFrom()booleanisInstance(java.lang.Object obj)Replacement of the Java method isInstance()booleanisInterface()Replacement of the Java method isInterface()booleanisPrimitive()Replacement of the Java methodClass.isPrimitive()TnewInstance()Replacement of the Java method newInstance()private static voidsetClassIntoTable(int strIdx, ReplacementForClass<?> clazz)WASM codeprivate static inttypeTableMemoryOffset()WASM code
-
-
-
Method Detail
-
getClassObject
private static ReplacementForClass<?> getClassObject(java.lang.Object obj)
Replacement forObject.getClass(). The documentation of the memory of the type description is done in method:TypeManager.StructType#writeToStream(java.io.ByteArrayOutputStream, java.util.function.ToIntFunction)- Parameters:
obj- the instance- Returns:
- the class
-
classConstant
private static ReplacementForClass<?> classConstant(int classIdx)
WASM codeGet a constant Class from the table.
- Parameters:
classIdx- the id/index of the Class.- Returns:
- the string
- See Also:
TypeManager.getClassConstantFunction()
-
getClassFromTable
private static ReplacementForClass<?> getClassFromTable(int classIdx)
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
private static void setClassIntoTable(int strIdx, ReplacementForClass<?> clazz)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
public static java.lang.Class<?> forName(java.lang.String className) throws java.lang.ClassNotFoundExceptionReplacement 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:
java.lang.ClassNotFoundException
-
newInstance
public T newInstance() throws java.lang.InstantiationException, java.lang.IllegalAccessException
Replacement of the Java method newInstance()- Returns:
- a newly allocated instance of the class represented by this object.
- Throws:
java.lang.InstantiationExceptionjava.lang.IllegalAccessException
-
isInstance
public boolean isInstance(java.lang.Object obj)
Replacement of the Java method isInstance()- Parameters:
obj- the object to check- Returns:
- true if
objis an instance of this class
-
isAssignableFrom
public boolean isAssignableFrom(java.lang.Class<?> cls)
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
public java.lang.String getName()
Replacement forClass.getName()- Returns:
- the name
-
getClassLoader
public java.lang.ClassLoader getClassLoader()
Replacement of the Java method getClassLoader()
-
getClassLoader0
java.lang.ClassLoader getClassLoader0()
Replacement of the Java method getClassLoader0()
-
getSuperclass
public java.lang.Class<? super T> getSuperclass()
Replacement of the Java methods getSuperclass()
-
getPackage
public java.lang.Package getPackage()
Replacement of the Java methods getPackage()
-
getInterfaces
public java.lang.Class<?>[] getInterfaces()
Replacement of the Java method getInterfaces()- Returns:
- an array of interfaces implemented by this class.
-
getGenericInterfaces
public java.lang.reflect.Type[] getGenericInterfaces()
Replacement of the Java method getGenericInterfaces()- Returns:
- an array of interfaces implemented by this class
-
getComponentType
public ReplacementForClass<?> getComponentType()
Replacement of the native Java method getComponentType()
-
getSimpleName
public java.lang.String getSimpleName()
Replacement of the Java method getSimpleName()- Returns:
- the simple name of the underlying class
-
getTypeName
public java.lang.String getTypeName()
Replacement of the Java method getTypeName()- Returns:
- an informative string for the name of this type
-
getCanonicalName
public java.lang.String getCanonicalName()
Replacement of the Java method getCanonicalName()- Returns:
- the canonical name of the underlying class
-
getMethod
public java.lang.reflect.Method getMethod(java.lang.String name, java.lang.Class<?>... parameterTypes)Replacement of the Java method getMethod()
-
getDeclaredField
public java.lang.reflect.Field getDeclaredField(java.lang.String name)
Replacement of the Java method getDeclaredField()
-
getDeclaredMethod
public java.lang.reflect.Method getDeclaredMethod(java.lang.String name, java.lang.Class<?>... parameterTypes)Replacement of the Java method getDeclaredMethod()
-
getDeclaredConstructor
public java.lang.reflect.Constructor<T> getDeclaredConstructor(java.lang.Class<?>... parameterTypes)
Replacement of the Java method getDeclaredConstructor()
-
getResourceAsStream
public java.io.InputStream getResourceAsStream(java.lang.String name)
Replacement of the Java method getResourceAsStream()
-
getPrimitiveClass
static ReplacementForClass<?> getPrimitiveClass(java.lang.String name)
Replacement of the native Java methodClass.getPrimitiveClass(java.lang.String)- Parameters:
name- the class name- Returns:
- the class
- See Also:
TypeManager.PRIMITIVE_CLASSES
-
desiredAssertionStatus
public boolean desiredAssertionStatus()
Replacement of the native Java methodClass.desiredAssertionStatus()- Returns:
- the desired assertion status of the specified class.
-
enumConstantDirectory
java.util.Map<java.lang.String,T> 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
-
-