org.jboss.weld.util.bytecode
Class BytecodeUtils

java.lang.Object
  extended by org.jboss.weld.util.bytecode.BytecodeUtils

public class BytecodeUtils
extends Object

utility class for common bytecode operations

Author:
Stuart Douglas

Constructor Summary
BytecodeUtils()
           
 
Method Summary
static void add16bit(javassist.bytecode.Bytecode b, int value)
          inserts a 16 bit offset into the bytecode
static void addLoadInstruction(javassist.bytecode.Bytecode code, String type, int variable)
          Adds the correct load instruction based on the type descriptor
static void addReturnInstruction(javassist.bytecode.Bytecode code, Class<?> type)
           
static void addReturnInstruction(javassist.bytecode.Bytecode code, String type)
          Adds a return instruction given a type in JVM format.
static int loadParameters(javassist.bytecode.Bytecode b, String descriptor)
          Push all parameters onto the stack, excluding the this pointer (variable 0).
static int loadParameters(javassist.bytecode.Bytecode b, String[] params)
          Push all parameters onto the stack, excluding the this pointer (variable 0).
static void pushClassType(javassist.bytecode.Bytecode b, String classType)
          Pushes a class type onto the stack from the string representation This can also handle primitives
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BytecodeUtils

public BytecodeUtils()
Method Detail

loadParameters

public static int loadParameters(javassist.bytecode.Bytecode b,
                                 String descriptor)
Push all parameters onto the stack, excluding the this pointer (variable 0). This is usually used to prepare for a method call on a delegate


loadParameters

public static int loadParameters(javassist.bytecode.Bytecode b,
                                 String[] params)
Push all parameters onto the stack, excluding the this pointer (variable 0). This is usually used to prepare for a method call on a delegate


addLoadInstruction

public static void addLoadInstruction(javassist.bytecode.Bytecode code,
                                      String type,
                                      int variable)
Adds the correct load instruction based on the type descriptor

Parameters:
code - the bytecode to add the instruction to
type - the type of the variable
variable - the variable number

addReturnInstruction

public static void addReturnInstruction(javassist.bytecode.Bytecode code,
                                        Class<?> type)

addReturnInstruction

public static void addReturnInstruction(javassist.bytecode.Bytecode code,
                                        String type)
Adds a return instruction given a type in JVM format.

Parameters:
code - the bytecode
type - the type descriptor for the type to return

pushClassType

public static void pushClassType(javassist.bytecode.Bytecode b,
                                 String classType)
Pushes a class type onto the stack from the string representation This can also handle primitives

Parameters:
b - the bytecode
classType - the type descriptor for the class or primitive to push. This will accept both the java.lang.Object form and the Ljava/lang/Object; form

add16bit

public static void add16bit(javassist.bytecode.Bytecode b,
                            int value)
inserts a 16 bit offset into the bytecode

Parameters:
b -
value -


Copyright © 2013 Seam Framework. All Rights Reserved.