PenProfile 2.x

com.sun.cldchi.jvm
Class MethodTrap

java.lang.Object
  extended by com.sun.cldchi.jvm.MethodTrap

public final class MethodTrap
extends Object

Java API to support run-time method trapping from Java code. It is used internally by J2ME software stack implementations and should be placed in a hidden package. MethodTrap class allows to change execution entry of Java methods.


Field Summary
static int ACTION_BREAKPOINT
          Causes native breakpoint to happen
static int ACTION_CALLBACK
          Invoke callback function
static int ACTION_EXIT
          Causes JVM to stop
static int ACTION_STOP_ISOLATE
          Causes current isolate to stop
 
Constructor Summary
MethodTrap()
           
 
Method Summary
static void releaseTrap(int trapHandle)
          Release Java method that was previously trapped by setTrap() call.
static int setJavaTrap(String methodName, String handlerName)
          Replace the execution entry of the specified method with the execution entry of another method with the similar signature.
static int setTrap(String methodName, int callCount, int action, int targetTask)
          Trap specified Java method for JVM to take special action before the method is invoked.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ACTION_CALLBACK

public static final int ACTION_CALLBACK
Invoke callback function

See Also:
Constant Field Values

ACTION_EXIT

public static final int ACTION_EXIT
Causes JVM to stop

See Also:
Constant Field Values

ACTION_STOP_ISOLATE

public static final int ACTION_STOP_ISOLATE
Causes current isolate to stop

See Also:
Constant Field Values

ACTION_BREAKPOINT

public static final int ACTION_BREAKPOINT
Causes native breakpoint to happen

See Also:
Constant Field Values
Constructor Detail

MethodTrap

public MethodTrap()
Method Detail

setTrap

public static int setTrap(String methodName,
                          int callCount,
                          int action,
                          int targetTask)
Trap specified Java method for JVM to take special action before the method is invoked.

Parameters:
methodName - - fully-qualified name of the method to trap, looks like package.ClassName.methodName
callCount - - take an action only when the method is called callCount times
action - - the code of the action for JVM to take on the method invocation, can be one of ACTION_*
targetTask - - id of a task that should be stopped on the method call, method with the same from other tasks won't be trapped. 0 means any task will match
Returns:
trapHandle - unique identifier of the trap that can be passed to subsequent repeaseTrap() call

setJavaTrap

public static int setJavaTrap(String methodName,
                              String handlerName)
Replace the execution entry of the specified method with the execution entry of another method with the similar signature.

Parameters:
methodName - - fully-qualified name of the method to trap, looks like package.ClassName.methodName
handlerName - - fully-qualified name of the method to be invoked instead of the trapped method. The handler must have the same parameter types as the original method.

releaseTrap

public static void releaseTrap(int trapHandle)
Release Java method that was previously trapped by setTrap() call.

Parameters:
trapHandle - - the identifier of the trap that was returned by previous call to setTrap() or setJavaTrap()

PenProfile 2.x

Copyright © 2010 Livescribe Inc. All Rights Reserved.
Confidential and subject to NDA.