org.jboss.byteman.agent.adapter
Class RuleTriggerMethodAdapter

java.lang.Object
  extended by MethodAdapter
      extended by org.jboss.byteman.agent.adapter.RuleMethodAdapter
          extended by org.jboss.byteman.agent.adapter.RuleGeneratorAdapter
              extended by org.jboss.byteman.agent.adapter.RuleTriggerMethodAdapter
Direct Known Subclasses:
EntryTriggerAdapter.EntryTriggerMethodAdapter, ExitTriggerAdapter.ExitTriggerMethodAdapter, FieldAccessTriggerAdapter.FieldAccessTriggerMethodAdapter, IndexParamAccessTriggerAdapter.IndexParamAccessTriggerMethodAdapter, InvokeTriggerAdapter.InvokeTriggerMethodAdapter, LineTriggerAdapter.LineTriggerMethodAdapter, SynchronizeTriggerAdapter.SynchronizeTriggerMethodAdapter, ThrowTriggerAdapter.ThrowTriggerMethodAdapter, VariableAccessTriggerAdapter.VariableAccessTriggerMethodAdapter

public class RuleTriggerMethodAdapter
extends RuleGeneratorAdapter

class which provides base functionality extended by all the location-specific method trigger adapters


Nested Class Summary
 
Nested classes/interfaces inherited from class org.jboss.byteman.agent.adapter.RuleMethodAdapter
RuleMethodAdapter.LocalVar
 
Field Summary
private  int[] argLocalIndices
           
private  Type[] argumentTypes
           
private  boolean bindingIndicesSet
           
private  boolean bindInvokeParams
           
private  boolean bindReturnOrThrowableValue
           
private  java.util.List<Binding> callArrayBindings
           
private  CFG cfg
           
protected  java.lang.String[] exceptions
           
private  boolean injected
           
private  Type returnType
           
private  RuleScript ruleScript
           
private  Type saveValueType
           
private  java.lang.String signature
           
 
Fields inherited from class org.jboss.byteman.agent.adapter.RuleGeneratorAdapter
ADD, AND, DIV, EQ, GE, GT, LE, LT, MUL, NE, NEG, OR, REM, SHL, SHR, SUB, USHR, XOR
 
Fields inherited from class org.jboss.byteman.agent.adapter.RuleMethodAdapter
access, descriptor, localVarsByName, name, rule, transformContext
 
Constructor Summary
RuleTriggerMethodAdapter(MethodVisitor mv, TransformContext transformContext, int access, java.lang.String name, java.lang.String descriptor, java.lang.String signature, java.lang.String[] exceptions)
           
 
Method Summary
private  Binding alias(Binding binding, Bindings bindings, int localIdx)
           
private  boolean doArgLoad(int saveSlot)
          stack an argument array containing all the values which need to be bound to parameters or local variables in the rule or a null pointer if no bindings are required.
private  void doArgUpdate()
          plant code to copy back any updated values from the argument array to the relevant local variable slots
private  int doInvokeBindingsSave()
           
private  int doReturnOrThrowSave()
           
 Type[] getInvokedTypes()
          method overridden by AT INVOKE method adapter allowing types for the invoked method owner, parameters and return value to be identified.
protected  java.lang.String getMethodName()
           
 Type getReturnBindingType()
          method overridden by AT INVOKE method adapter allowing the type of the $! binding to be identified.
protected  boolean inBytemanHandler()
          return true if the current block is a handler which catches a byteman exception thrown by the byteman runtime
protected  boolean inBytemanTrigger()
          return true if the current block is in a trigger block injected by Byteman
protected  void injectTriggerPoint()
          inject the rule trigger code
protected  boolean inRethrowHandler()
          return true if the current block is handler which catches a thrown exception within the scope of a monitor enter in order to be able exit the monitor and rethrow the exception
private  void setBindingIndices()
           
 void visitCode()
           
 void visitEnd()
           
 void visitFieldInsn(int opcode, java.lang.String owner, java.lang.String name, java.lang.String desc)
           
 void visitIincInsn(int var, int increment)
           
 void visitInsn(int opcode)
           
 void visitIntInsn(int opcode, int operand)
           
 void visitJumpInsn(int opcode, Label label)
           
 void visitLabel(Label label)
           
 void visitLdcInsn(java.lang.Object cst)
           
 void visitLookupSwitchInsn(Label dflt, int[] keys, Label[] labels)
           
 void visitMaxs(int maxStack, int maxLocals)
          ensure we allow enough room for any extra locals on the stack
 void visitMethodInsn(int opcode, java.lang.String owner, java.lang.String name, java.lang.String desc)
           
 void visitMultiANewArrayInsn(java.lang.String desc, int dims)
           
 void visitTableSwitchInsn(int min, int max, Label dflt, Label[] labels)
           
 void visitTriggerEnd(Label label)
           
 void visitTriggerStart(Label label)
           
 void visitTryCatchBlock(Label start, Label end, Label handler, java.lang.String type)
           
 void visitTypeInsn(int opcode, java.lang.String desc)
           
 void visitVarInsn(int opcode, int var)
          override this so we can see track which local var slots are in use and avoid overwriting them
 
Methods inherited from class org.jboss.byteman.agent.adapter.RuleGeneratorAdapter
arrayLength, arrayLoad, arrayStore, box, cast, catchException, checkCast, dup, dup2, dup2X1, dup2X2, dupX1, dupX2, endMethod, getField, getLocalType, getStatic, goTo, ifCmp, ifICmp, ifNonNull, ifNull, ifZCmp, iinc, instanceOf, invokeConstructor, invokeInterface, invokeStatic, invokeVirtual, loadArg, loadArgArray, loadArgs, loadArgs, loadLocal, loadThis, mark, mark, math, monitorEnter, monitorExit, newArray, newInstance, newLabel, newLocal, not, pop, pop2, popLocal, push, push, push, push, push, push, push, putField, putStatic, ret, returnValue, storeArg, storeLocal, swap, swap, tableSwitch, tableSwitch, throwException, throwException, unbox, visitFrame
 
Methods inherited from class org.jboss.byteman.agent.adapter.RuleMethodAdapter
getTriggerClass, lookup, visitLocalVariable
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ruleScript

private RuleScript ruleScript

signature

private java.lang.String signature

exceptions

protected java.lang.String[] exceptions

returnType

private Type returnType

argumentTypes

private Type[] argumentTypes

saveValueType

private Type saveValueType

argLocalIndices

private int[] argLocalIndices

callArrayBindings

private java.util.List<Binding> callArrayBindings

bindReturnOrThrowableValue

private boolean bindReturnOrThrowableValue

bindInvokeParams

private boolean bindInvokeParams

bindingIndicesSet

private boolean bindingIndicesSet

injected

private boolean injected

cfg

private CFG cfg
Constructor Detail

RuleTriggerMethodAdapter

RuleTriggerMethodAdapter(MethodVisitor mv,
                         TransformContext transformContext,
                         int access,
                         java.lang.String name,
                         java.lang.String descriptor,
                         java.lang.String signature,
                         java.lang.String[] exceptions)
Method Detail

getInvokedTypes

public Type[] getInvokedTypes()
method overridden by AT INVOKE method adapter allowing types for the invoked method owner, parameters and return value to be identified. this default version should never get invoked

Returns:
an array containing the types of the invoked method owner, parameters and return value

getReturnBindingType

public Type getReturnBindingType()
method overridden by AT INVOKE method adapter allowing the type of the $! binding to be identified. this default version should only get invoked for an AT EXIT rule where it returns the trigger method return type. the overridden version should only get invoked for an AFTER INVOKE rule where it returns the invoked method return type

Returns:
the appropriate return type

setBindingIndices

private void setBindingIndices()

alias

private Binding alias(Binding binding,
                      Bindings bindings,
                      int localIdx)

doReturnOrThrowSave

private int doReturnOrThrowSave()

doInvokeBindingsSave

private int doInvokeBindingsSave()

doArgLoad

private boolean doArgLoad(int saveSlot)
stack an argument array containing all the values which need to be bound to parameters or local variables in the rule or a null pointer if no bindings are required. this method also inserts a copy of the array below the initial two top entries if any of the bindings can potentially be updated by the rule, allowing the updated values to be written back on return from the call to the rule engine.

Parameters:
saveSlot - a local variable slot containing either the return value which the trigger method is about to return or the Throwable the method is about to throw. this is only valid if, respectively, the rule location is AT EXIT/AFTER INVOKE or AT THROW and the rule body contains a reference to the return value ($!) or throwable value ($@).
Returns:
true if the rule may update the argument array and hence if a copy of the array has been inserted below the initial two top entries otherwise false.

doArgUpdate

private void doArgUpdate()
plant code to copy back any updated values from the argument array to the relevant local variable slots


inBytemanHandler

protected boolean inBytemanHandler()
return true if the current block is a handler which catches a byteman exception thrown by the byteman runtime

Returns:

inBytemanTrigger

protected boolean inBytemanTrigger()
return true if the current block is in a trigger block injected by Byteman

Returns:

inRethrowHandler

protected boolean inRethrowHandler()
return true if the current block is handler which catches a thrown exception within the scope of a monitor enter in order to be able exit the monitor and rethrow the exception

Returns:

getMethodName

protected java.lang.String getMethodName()

visitCode

public void visitCode()

visitInsn

public void visitInsn(int opcode)

visitIincInsn

public void visitIincInsn(int var,
                          int increment)

visitIntInsn

public void visitIntInsn(int opcode,
                         int operand)

visitLdcInsn

public void visitLdcInsn(java.lang.Object cst)

visitVarInsn

public void visitVarInsn(int opcode,
                         int var)
Description copied from class: RuleGeneratorAdapter
override this so we can see track which local var slots are in use and avoid overwriting them

Overrides:
visitVarInsn in class RuleGeneratorAdapter

visitTypeInsn

public void visitTypeInsn(int opcode,
                          java.lang.String desc)

visitFieldInsn

public void visitFieldInsn(int opcode,
                           java.lang.String owner,
                           java.lang.String name,
                           java.lang.String desc)

visitMethodInsn

public void visitMethodInsn(int opcode,
                            java.lang.String owner,
                            java.lang.String name,
                            java.lang.String desc)

visitJumpInsn

public void visitJumpInsn(int opcode,
                          Label label)

visitLabel

public void visitLabel(Label label)

visitTriggerStart

public void visitTriggerStart(Label label)

visitTriggerEnd

public void visitTriggerEnd(Label label)

visitTableSwitchInsn

public void visitTableSwitchInsn(int min,
                                 int max,
                                 Label dflt,
                                 Label[] labels)

visitLookupSwitchInsn

public void visitLookupSwitchInsn(Label dflt,
                                  int[] keys,
                                  Label[] labels)

visitMultiANewArrayInsn

public void visitMultiANewArrayInsn(java.lang.String desc,
                                    int dims)

visitTryCatchBlock

public void visitTryCatchBlock(Label start,
                               Label end,
                               Label handler,
                               java.lang.String type)

visitMaxs

public void visitMaxs(int maxStack,
                      int maxLocals)
Description copied from class: RuleGeneratorAdapter
ensure we allow enough room for any extra locals on the stack

Overrides:
visitMaxs in class RuleGeneratorAdapter

visitEnd

public void visitEnd()

injectTriggerPoint

protected void injectTriggerPoint()
inject the rule trigger code