org.sourceforge.jemm.weaver.transformation.bytecode
Class CodeOperations

java.lang.Object
  extended by org.sourceforge.jemm.weaver.transformation.bytecode.CodeOperations

public class CodeOperations
extends java.lang.Object

Additional operations for a CodeIterator that can improve the general capabilities of the CodeIterator without changing its actual structure.

Author:
Paul Keeble

Constructor Summary
CodeOperations(javassist.bytecode.CodeIterator it)
          Create a CodeOperations instance.
 
Method Summary
 int replace(int pos, byte[] newCode)
          Replaces the code with the passed byte code.
 int replace(int pos, javassist.bytecode.Bytecode code)
          Extracts the code to use from a Bytecode object and replaces the code at a particular position.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CodeOperations

public CodeOperations(javassist.bytecode.CodeIterator it)
Create a CodeOperations instance.

Parameters:
it - The target code iterator.
Method Detail

replace

public int replace(int pos,
                   byte[] newCode)
            throws javassist.bytecode.BadBytecode
Replaces the code with the passed byte code.

Parameters:
pos - The position to start the replacement at
newCode - The new byte code
Returns:
The amount of space actually added which may be larger than newCode.length
Throws:
javassist.bytecode.BadBytecode - if the gap can't be inserted.

replace

public int replace(int pos,
                   javassist.bytecode.Bytecode code)
            throws javassist.bytecode.BadBytecode
Extracts the code to use from a Bytecode object and replaces the code at a particular position.

Parameters:
pos - The position to place the code
code - The byte code to use
Returns:
The size of the bytecode inserted
Throws:
javassist.bytecode.BadBytecode
See Also:
replace(int, byte[])


Copyright © 2009. All Rights Reserved.