Class ReplacementForClass<T>

java.lang.Object
de.inetsoftware.jwebassembly.module.nativecode.ReplacementForClass<T>
Type Parameters:
T - the type of the class modeled by this Class

class ReplacementForClass<T> extends Object
Replacement for java.lang.Class
  • Field Details

    • vtable

      final int vtable
      The 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

      private static ReplacementForClass<?> getClassObject(Object obj)
      Replacement for Object.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

      private static ReplacementForClass<?> classConstant(int classIdx)
      WASM code

      Get a constant Class from the table.

      Parameters:
      classIdx - the id/index of the Class.
      Returns:
      the string
      See Also:
    • getClassFromTable

      private static ReplacementForClass<?> getClassFromTable(int classIdx)
      WASM code

      Get 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 code

      Set 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 code

      Placeholder 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 code

      Load 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 Class<?> forName(String className) throws ClassNotFoundException
      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

      public T newInstance() throws InstantiationException, IllegalAccessException
      Replacement of the Java method newInstance()
      Returns:
      a newly allocated instance of the class represented by this object.
      Throws:
      InstantiationException
      IllegalAccessException
    • isInstance

      public boolean isInstance(Object obj)
      Replacement of the Java method isInstance()
      Parameters:
      obj - the object to check
      Returns:
      true if obj is an instance of this class
    • isAssignableFrom

      public boolean isAssignableFrom(Class<?> cls)
      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 method Class.isPrimitive()
      Returns:
      true if and only if this class represents a primitive type
    • getName

      public String getName()
      Replacement for Class.getName()
      Returns:
      the name
    • getClassLoader

      public ClassLoader getClassLoader()
      Replacement of the Java method getClassLoader()
    • getClassLoader0

      ClassLoader getClassLoader0()
      Replacement of the Java method getClassLoader0()
    • getSuperclass

      public Class<? super T> getSuperclass()
      Replacement of the Java methods getSuperclass()
    • getPackage

      public Package getPackage()
      Replacement of the Java methods getPackage()
    • getInterfaces

      public Class<?>[] getInterfaces()
      Replacement of the Java method getInterfaces()
      Returns:
      an array of interfaces implemented by this class.
    • getGenericInterfaces

      public 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 String getSimpleName()
      Replacement of the Java method getSimpleName()
      Returns:
      the simple name of the underlying class
    • getTypeName

      public String getTypeName()
      Replacement of the Java method getTypeName()
      Returns:
      an informative string for the name of this type
    • getCanonicalName

      public String getCanonicalName()
      Replacement of the Java method getCanonicalName()
      Returns:
      the canonical name of the underlying class
    • getMethod

      public Method getMethod(String name, Class<?>... parameterTypes)
      Replacement of the Java method getMethod()
    • getDeclaredField

      public Field getDeclaredField(String name)
      Replacement of the Java method getDeclaredField()
    • getDeclaredMethod

      public Method getDeclaredMethod(String name, Class<?>... parameterTypes)
      Replacement of the Java method getDeclaredMethod()
    • getDeclaredConstructor

      public Constructor<T> getDeclaredConstructor(Class<?>... parameterTypes)
      Replacement of the Java method getDeclaredConstructor()
    • getResourceAsStream

      public InputStream getResourceAsStream(String name)
      Replacement of the Java method getResourceAsStream()
    • getPrimitiveClass

      static ReplacementForClass<?> getPrimitiveClass(String name)
      Replacement of the native Java method Class.getPrimitiveClass(java.lang.String)
      Parameters:
      name - the class name
      Returns:
      the class
      See Also:
    • desiredAssertionStatus

      public boolean desiredAssertionStatus()
      Replacement of the native Java method Class.desiredAssertionStatus()
      Returns:
      the desired assertion status of the specified class.
    • enumConstantDirectory

      Map<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