FileDocCategorySizeDatePackage
MethodTrap.javaAPI DocphoneME MR2 API (J2ME)3742Wed May 02 17:59:54 BST 2007com.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.

Fields Summary
public static final int
ACTION_CALLBACK
Invoke callback function
public static final int
ACTION_EXIT
Causes JVM to stop
public static final int
ACTION_STOP_ISOLATE
Causes current isolate to stop
public static final int
ACTION_BREAKPOINT
Causes native breakpoint to happen
Constructors Summary
Methods Summary
public static native voidreleaseTrap(int trapHandle)
Release Java method that was previously trapped by setTrap() call.

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

public static native intsetJavaTrap(java.lang.String methodName, java.lang.String handlerName)
Replace the execution entry of the specified method with the execution entry of another method with the similar signature.

param
methodName - fully-qualified name of the method to trap, looks like package.ClassName.methodName
param
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.

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

param
methodName - fully-qualified name of the method to trap, looks like package.ClassName.methodName
param
callCount - take an action only when the method is called callCount times
param
action - the code of the action for JVM to take on the method invocation, can be one of ACTION_*
param
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
return
trapHandle - unique identifier of the trap that can be passed to subsequent repeaseTrap() call