java.lang.Object
ch.ethz.inf.iks.jvmai.jvmdi.AspectInterfaceImpl
- All Implemented Interfaces:
- ch.ethz.jvmai.JVMAspectInterface
- public class AspectInterfaceImpl
- extends java.lang.Object
- implements ch.ethz.jvmai.JVMAspectInterface
About
Interface AspectInterfaceImpl represents the aspect-interface to the jvmai-system.
It's needed for initialization of the jvmai-system, management of joinpoint-watches and
for enable or disable event-notification.
An instance of this interface can be obtained by calling the method
getAspectInterface() of a jvmai-provider (class DebuggerProvider).
Implementation
The implementation of this aspect interface is based on the debugger interface of the JVM.
To receive notifications from the JVM, it uses the native code available in this class.
Bugs
The JVMDI is not
consistent over serveral J2SDK versions.
- Startup ignores the openword/closed world assumption and the list of prefixes.
- Under JDK 1.4.*, when throwing an exception within the notificaion, exception
events are wrongly sent to the debugger
- Under JDK 1.4.*, the 'GetThreadDepth' JVMDI function (name may be wrong),
does not always work correclty. Consequently, the current implementation (as of prose 0.18.0)
relies on the height of a frame relative to the frame which received
the debugger notifcation.
- Under JDK 1.4.*, the 'getBytecode' method exported by JVMDI works non-deterministically.
(first time it works, subsequent times it generates illegal opcodes). The workaround
uses BCEL and the class loader. However, this may incurr performance penalties.
- Version:
- $Revision: 1.1.1.1 $
|
Method Summary |
void |
clearExceptionCatchWatch(java.lang.Class cls)
Clears a watch on a exception catch joinpoint. |
void |
clearExceptionThrowWatch(java.lang.Class cls)
Clears a watch on a exception throw joinpoint. |
void |
clearFieldAccessWatch(java.lang.reflect.Field field)
Clears a watch on a field access joinpoint. |
void |
clearFieldModificationWatch(java.lang.reflect.Field field)
Clears a watch on a field modification joinpoint. |
void |
clearMethodEntryWatch(java.lang.reflect.Method m)
Clears a watch on a method entry joinpoint. |
void |
clearMethodExitWatch(java.lang.reflect.Method m)
Clears a watch on a method exit joinpoint. |
private void |
doClearExceptionCatchWatch(java.lang.Class trowableClass)
|
private void |
doClearExceptionWatch(java.lang.Class trowableClass)
|
private void |
doClearFieldAccessWatch(java.lang.Class c,
java.lang.reflect.Field f)
|
private void |
doClearFieldModificationWatch(java.lang.Class c,
java.lang.reflect.Field f)
|
private void |
doClearLocationWatch(java.lang.Class c,
java.lang.reflect.Method m,
int bci)
|
private byte[] |
doGetByteCode(java.lang.Class c,
java.lang.reflect.Method m)
|
private byte[] |
doGetByteCodeWithoutJvmdi(java.lang.reflect.Method m)
|
private java.util.List |
doGetClasses()
|
private void |
doOnClassLoad(java.lang.Class cls)
|
private void |
doOnExceptionCatch(ExceptionCatchJoinPointImpl jp)
|
private void |
doOnExceptionThrow(ExceptionJoinPointImpl jp)
|
private void |
doOnFieldAccess(FieldAccessJoinPointImpl jp)
|
private void |
doOnFieldModification(FieldModificationJoinPointImpl jp)
|
private void |
doOnMethodExecution(MethodExecutionJoinPointImpl jp)
|
private void |
doResumeNotification(java.lang.Thread t)
|
private void |
doSetExceptionCatchWatch(java.lang.Class throwableClass,
java.lang.Object tag)
|
private void |
doSetExceptionWatch(java.lang.Class throwableClass,
java.lang.Object tag)
|
private void |
doSetFieldAccessWatch(java.lang.Class c,
java.lang.reflect.Field f,
java.lang.Object tag)
|
private void |
doSetFieldModificationWatch(java.lang.Class c,
java.lang.reflect.Field f,
java.lang.Object tag)
|
private void |
doSetLocationWatch(java.lang.Class c,
java.lang.reflect.Method m,
int bci,
java.lang.Object tag)
|
private void |
doStartup(java.lang.Object[] prefixes,
boolean openWorld)
|
private void |
doSuspendNotification(java.lang.Thread t)
|
private void |
doTeardown()
|
private ControlFlow |
getCflow()
|
java.util.List |
getLoadedClasses()
Return a list of currently loaded clasess. |
void |
resumeNotification(java.lang.Thread thread)
Resumes notification regarding the specified thread. |
private java.util.List |
returnLocations(java.lang.reflect.Method m)
|
void |
setExceptionCatchWatch(java.lang.Class cls,
java.lang.Object aopTag)
Sets a watch on a exception catch joinpoint. |
void |
setExceptionThrowWatch(java.lang.Class cls,
java.lang.Object aopTag)
Sets a watch on a exception throw joinpoint. |
void |
setFieldAccessWatch(java.lang.reflect.Field f,
java.lang.Object aopTag)
Sets a watch on a field access joinpoint. |
void |
setFieldModificationWatch(java.lang.reflect.Field field,
java.lang.Object aopTag)
Sets a watch on a field modification joinpoint. |
void |
setJoinPointHook(ch.ethz.jvmai.JoinPointHook hook)
Sets a JoinPointHook as listener for jvmai-events. |
void |
setMethodEntryWatch(java.lang.reflect.Method m,
java.lang.Object aopTag)
Sets a watch on a method entry joinpoint. |
void |
setMethodExitWatch(java.lang.reflect.Method m,
java.lang.Object aopTag)
Sets a watch on a method exit joinpoint. |
private void |
setWatchPrecondition(java.lang.Object arg,
java.lang.Object aopTag)
|
void |
startup(java.lang.String[] packagePrefixes,
boolean openWorldAssumption)
Initializes the underlying jvmai system. |
void |
suspendNotification(java.lang.Thread thread)
Suspend notification regarding the specified thread. |
void |
teardown()
Teardown the AOP support. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
fieldAccessMap
java.util.Map fieldAccessMap
fieldModificationMap
java.util.Map fieldModificationMap
methodExecutionMap
java.util.Map methodExecutionMap
exceptionThrowMap
java.util.Map exceptionThrowMap
exceptionCatchMap
java.util.Map exceptionCatchMap
hook
ch.ethz.jvmai.JoinPointHook hook
isInitialized
public boolean isInitialized
cflows
static java.lang.ThreadLocal cflows
contingencyLoader
private java.lang.ClassLoader contingencyLoader
endLocationsMap
private java.util.HashMap endLocationsMap
AspectInterfaceImpl
public AspectInterfaceImpl()
getCflow
private ControlFlow getCflow()
startup
public void startup(java.lang.String[] packagePrefixes,
boolean openWorldAssumption)
- Initializes the underlying jvmai system.
In addition, this method takes a list of java package-names and a
boolean indicating how to interpret this prefixes. The prefixes are
used by the jvmai system to determine the set of classes beeing
relevant to the system at all.
Depeding on the value of openWorldAssumption, prefixes
are interpreted as followed:
openWorldAssumption == true
The jvmai-system is instructed to treat ALL classes as relevant,
EXCEPT the ones contained in a packages starting with one of the
supplied prefixes in packagePrefixes
openWorldAssumption == false
The jvmai-system is instructed to treat as relevant ONLY the classes
contained in a packages starting with one of the supplied prefixes
in packagePrefixes
- Specified by:
startup in interface ch.ethz.jvmai.JVMAspectInterface
setJoinPointHook
public void setJoinPointHook(ch.ethz.jvmai.JoinPointHook hook)
- Sets a JoinPointHook as listener for jvmai-events.
Whenever a watched joinpoint is reached or a class
is loaded into the virtual machine, this JoinPointHook
is notified by the aspect-interface. As long as no
JoinPointHook is set (or after setting
null),
processing of joinpoint- and classload-events is disabled
in the jvmai-system.
- Specified by:
setJoinPointHook in interface ch.ethz.jvmai.JVMAspectInterface
teardown
public void teardown()
- Description copied from interface:
ch.ethz.jvmai.JVMAspectInterface
- Teardown the AOP support. As a result,
no events will be sent to the JoinPointHook.
- Specified by:
teardown in interface ch.ethz.jvmai.JVMAspectInterface
setWatchPrecondition
private void setWatchPrecondition(java.lang.Object arg,
java.lang.Object aopTag)
setFieldAccessWatch
public void setFieldAccessWatch(java.lang.reflect.Field f,
java.lang.Object aopTag)
- Sets a watch on a field access joinpoint.
- Specified by:
setFieldAccessWatch in interface ch.ethz.jvmai.JVMAspectInterface
clearFieldAccessWatch
public void clearFieldAccessWatch(java.lang.reflect.Field field)
- Clears a watch on a field access joinpoint.
- Specified by:
clearFieldAccessWatch in interface ch.ethz.jvmai.JVMAspectInterface
setFieldModificationWatch
public void setFieldModificationWatch(java.lang.reflect.Field field,
java.lang.Object aopTag)
- Sets a watch on a field modification joinpoint.
- Specified by:
setFieldModificationWatch in interface ch.ethz.jvmai.JVMAspectInterface
clearFieldModificationWatch
public void clearFieldModificationWatch(java.lang.reflect.Field field)
- Clears a watch on a field modification joinpoint.
- Specified by:
clearFieldModificationWatch in interface ch.ethz.jvmai.JVMAspectInterface
returnLocations
private java.util.List returnLocations(java.lang.reflect.Method m)
doGetByteCodeWithoutJvmdi
private byte[] doGetByteCodeWithoutJvmdi(java.lang.reflect.Method m)
setMethodEntryWatch
public void setMethodEntryWatch(java.lang.reflect.Method m,
java.lang.Object aopTag)
- Sets a watch on a method entry joinpoint.
- Specified by:
setMethodEntryWatch in interface ch.ethz.jvmai.JVMAspectInterface
clearMethodEntryWatch
public void clearMethodEntryWatch(java.lang.reflect.Method m)
- Clears a watch on a method entry joinpoint.
- Specified by:
clearMethodEntryWatch in interface ch.ethz.jvmai.JVMAspectInterface
setMethodExitWatch
public void setMethodExitWatch(java.lang.reflect.Method m,
java.lang.Object aopTag)
- Sets a watch on a method exit joinpoint.
- Specified by:
setMethodExitWatch in interface ch.ethz.jvmai.JVMAspectInterface
clearMethodExitWatch
public void clearMethodExitWatch(java.lang.reflect.Method m)
- Clears a watch on a method exit joinpoint.
- Specified by:
clearMethodExitWatch in interface ch.ethz.jvmai.JVMAspectInterface
setExceptionThrowWatch
public void setExceptionThrowWatch(java.lang.Class cls,
java.lang.Object aopTag)
- Sets a watch on a exception throw joinpoint.
- Specified by:
setExceptionThrowWatch in interface ch.ethz.jvmai.JVMAspectInterface
clearExceptionThrowWatch
public void clearExceptionThrowWatch(java.lang.Class cls)
- Clears a watch on a exception throw joinpoint.
- Specified by:
clearExceptionThrowWatch in interface ch.ethz.jvmai.JVMAspectInterface
setExceptionCatchWatch
public void setExceptionCatchWatch(java.lang.Class cls,
java.lang.Object aopTag)
- Sets a watch on a exception catch joinpoint.
- Specified by:
setExceptionCatchWatch in interface ch.ethz.jvmai.JVMAspectInterface
clearExceptionCatchWatch
public void clearExceptionCatchWatch(java.lang.Class cls)
- Clears a watch on a exception catch joinpoint.
- Specified by:
clearExceptionCatchWatch in interface ch.ethz.jvmai.JVMAspectInterface
suspendNotification
public void suspendNotification(java.lang.Thread thread)
- Suspend notification regarding the specified thread.
Successive calls to
suspendNotification
have to be balanced by (at least) the same number of calls to
resumeNotification, or the jvmai-system
will not resume notification.
- Specified by:
suspendNotification in interface ch.ethz.jvmai.JVMAspectInterface
resumeNotification
public void resumeNotification(java.lang.Thread thread)
- Resumes notification regarding the specified thread.
Successive calls to
resumeNotification
without preceding calls to suspendNotification
will be ignored by the jvmai-system.
- Specified by:
resumeNotification in interface ch.ethz.jvmai.JVMAspectInterface
getLoadedClasses
public java.util.List getLoadedClasses()
- Description copied from interface:
ch.ethz.jvmai.JVMAspectInterface
- Return a list of currently loaded clasess.
- Specified by:
getLoadedClasses in interface ch.ethz.jvmai.JVMAspectInterface
doOnClassLoad
private void doOnClassLoad(java.lang.Class cls)
doOnMethodExecution
private void doOnMethodExecution(MethodExecutionJoinPointImpl jp)
doOnFieldAccess
private void doOnFieldAccess(FieldAccessJoinPointImpl jp)
doOnFieldModification
private void doOnFieldModification(FieldModificationJoinPointImpl jp)
doOnExceptionThrow
private void doOnExceptionThrow(ExceptionJoinPointImpl jp)
doOnExceptionCatch
private void doOnExceptionCatch(ExceptionCatchJoinPointImpl jp)
doStartup
private void doStartup(java.lang.Object[] prefixes,
boolean openWorld)
doTeardown
private void doTeardown()
doSetLocationWatch
private void doSetLocationWatch(java.lang.Class c,
java.lang.reflect.Method m,
int bci,
java.lang.Object tag)
doClearLocationWatch
private void doClearLocationWatch(java.lang.Class c,
java.lang.reflect.Method m,
int bci)
doSetFieldAccessWatch
private void doSetFieldAccessWatch(java.lang.Class c,
java.lang.reflect.Field f,
java.lang.Object tag)
doClearFieldAccessWatch
private void doClearFieldAccessWatch(java.lang.Class c,
java.lang.reflect.Field f)
doSetFieldModificationWatch
private void doSetFieldModificationWatch(java.lang.Class c,
java.lang.reflect.Field f,
java.lang.Object tag)
doClearFieldModificationWatch
private void doClearFieldModificationWatch(java.lang.Class c,
java.lang.reflect.Field f)
doSetExceptionWatch
private void doSetExceptionWatch(java.lang.Class throwableClass,
java.lang.Object tag)
doClearExceptionWatch
private void doClearExceptionWatch(java.lang.Class trowableClass)
doSetExceptionCatchWatch
private void doSetExceptionCatchWatch(java.lang.Class throwableClass,
java.lang.Object tag)
doClearExceptionCatchWatch
private void doClearExceptionCatchWatch(java.lang.Class trowableClass)
doGetByteCode
private byte[] doGetByteCode(java.lang.Class c,
java.lang.reflect.Method m)
doGetClasses
private java.util.List doGetClasses()
doSuspendNotification
private void doSuspendNotification(java.lang.Thread t)
doResumeNotification
private void doResumeNotification(java.lang.Thread t)