Package jadex.bytecode
Class SASM
- java.lang.Object
-
- jadex.bytecode.SASM
-
public class SASM extends java.lang.ObjectStatic ASM helper methods.
-
-
Field Summary
Fields Modifier and Type Field Description protected static WeakKeyValueMap<java.lang.ClassLoader,IByteCodeClassLoader>SHARED_CLASSLOADERSShared ClassLoader cache.static booleanSHARED_LOADERS_MODEEnables the shared bytecode classloader mode.
-
Constructor Summary
Constructors Constructor Description SASM()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static IByteCodeClassLoadercreateByteCodeClassLoader(java.lang.ClassLoader... parents)Creates a byte code ClassLoader.static IByteCodeClassLoadergetByteCodeClassLoader(java.lang.ClassLoader parent)Generates a ByteCodeClassLoader for loading a generated class.static IByteCodeClassLoadergetByteCodeClassLoader(java.lang.ClassLoader parent, boolean sharedloaders)Generates a ByteCodeClassLoader for loading a generated class.static org.objectweb.asm.tree.ClassNodegetClassNode(java.lang.Class<?> clazz, java.lang.ClassLoader classloader)Get a class node for a class.static voidmakeBasicType(org.objectweb.asm.tree.InsnList nl, org.objectweb.asm.Type type)Make a value a basic type.static voidmakeObject(org.objectweb.asm.tree.InsnList nl, org.objectweb.asm.Type type)Make a value to an object.static intmakeObject(org.objectweb.asm.tree.InsnList nl, org.objectweb.asm.Type arg, int pos)Make a value to an object.static voidmakeReturn(org.objectweb.asm.tree.InsnList nl, org.objectweb.asm.Type type)Make a suitable return statement.static voidpushImmediate(org.objectweb.asm.tree.InsnList nl, int immediate)Push an immediate (constant) integer value onto the stack with the best set of instructions.static voidpushImmediate(org.objectweb.asm.tree.InsnList nl, long immediate)Push an immediate (constant) long value onto the stack with the best set of instructions.static java.lang.Class<?>toClass(java.lang.String name, byte[] data, java.lang.ClassLoader loader, java.security.ProtectionDomain domain)Transform byte Array into Class and define it in classloader.
-
-
-
Field Detail
-
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 WeakKeyValueMap<java.lang.ClassLoader,IByteCodeClassLoader> SHARED_CLASSLOADERS
Shared ClassLoader cache.
-
-
Method Detail
-
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.type- The value type.pos- The position of the value on the registers (default=1, 0 is this).- 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 java.lang.Class<?> toClass(java.lang.String name, byte[] data, java.lang.ClassLoader loader, java.security.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(java.lang.Class<?> clazz, java.lang.ClassLoader classloader)Get a class node for a class.- Parameters:
clazz- The clazz.- Returns:
- The class node.
-
getByteCodeClassLoader
public static IByteCodeClassLoader getByteCodeClassLoader(java.lang.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(java.lang.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(java.lang.ClassLoader... parents)
Creates a byte code ClassLoader.- Parameters:
parents- ClassLoader parents, first parameters is the getParent() ClassLoader.- Returns:
- The loader.
-
-