Class SASM

java.lang.Object
jadex.bytecode.SASM

public class SASM extends Object
Static ASM helper methods.
  • Field Details

    • SHARED_LOADERS_MODE

      public static boolean SHARED_LOADERS_MODE
      Enables the shared bytecode classloader mode. If false, a new classloader is generated for each generated class for easier unloading, but potentially wastes more memory.
    • SHARED_CLASSLOADERS

      protected static final jadex.collection.WeakKeyValueMap<ClassLoader,IByteCodeClassLoader> SHARED_CLASSLOADERS
      Shared ClassLoader cache.
  • Constructor Details

    • SASM

      public SASM()
  • Method Details

    • pushImmediate

      public static void pushImmediate(org.objectweb.asm.tree.InsnList nl, int immediate)
      Push an immediate (constant) integer value onto the stack with the best set of instructions.
      Parameters:
      nl - The instruction list.
      immediate - The immediate value.
    • pushImmediate

      public static void pushImmediate(org.objectweb.asm.tree.InsnList nl, long immediate)
      Push an immediate (constant) long value onto the stack with the best set of instructions.
      Parameters:
      nl - The instruction list.
      immediate - The immediate value.
    • makeObject

      public static void makeObject(org.objectweb.asm.tree.InsnList nl, org.objectweb.asm.Type type)
      Make a value to an object.
      Parameters:
      nl - The instruction list.
      type - The value type.
    • makeObject

      public static int makeObject(org.objectweb.asm.tree.InsnList nl, org.objectweb.asm.Type arg, int pos)
      Make a value to an object.
      Parameters:
      nl - The instruction list.
      pos - The position of the value on the registers (default=1, 0 is this).
      type - The value type.
      Returns:
      The updated position value.
    • makeBasicType

      public static void makeBasicType(org.objectweb.asm.tree.InsnList nl, org.objectweb.asm.Type type)
      Make a value a basic type.
      Parameters:
      nl - The instruction list.
      type - The value type.
    • makeReturn

      public static void makeReturn(org.objectweb.asm.tree.InsnList nl, org.objectweb.asm.Type type)
      Make a suitable return statement.
      Parameters:
      nl - The instruction list.
      type - The value type.
    • toClass

      public static Class<?> toClass(String name, byte[] data, ClassLoader loader, ProtectionDomain domain)
      Transform byte Array into Class and define it in classloader.
      Returns:
      the loaded class or null, if the class is not valid, such as Map.entry "inner Classes".
    • getClassNode

      public static org.objectweb.asm.tree.ClassNode getClassNode(Class<?> clazz, ClassLoader classloader)
      Get a class node for a class.
      Parameters:
      clazz - The clazz.
      Returns:
      The class node.
    • getByteCodeClassLoader

      public static IByteCodeClassLoader getByteCodeClassLoader(ClassLoader parent)
      Generates a ByteCodeClassLoader for loading a generated class.
      Parameters:
      parent - Parent ClassLoader.
      sharedloader - Set true, to use shared loaders.
      Returns:
      The ByteCodeClassLoader.
    • getByteCodeClassLoader

      public static IByteCodeClassLoader getByteCodeClassLoader(ClassLoader parent, boolean sharedloaders)
      Generates a ByteCodeClassLoader for loading a generated class.
      Parameters:
      parent - Parent ClassLoader.
      sharedloader - Set true, to use shared loaders.
      Returns:
      The ByteCodeClassLoader.
    • createByteCodeClassLoader

      public static final IByteCodeClassLoader createByteCodeClassLoader(ClassLoader... parents)
      Creates a byte code ClassLoader.
      Parameters:
      parents - ClassLoader parents, first parameters is the getParent() ClassLoader.
      Returns:
      The loader.