public class MethodEditor
extends de.uni_hildesheim.sse.monitoring.runtime.instrumentation.lib.BehaviorEditor
clear() after
usage! This class is public for testing.| Modifier and Type | Field and Description |
|---|---|
private static HashMap<java.lang.String,java.lang.String> |
annotatedFields
Stores the relation among annotated fields and recording ids (may be
null if not specified).
|
private ISemanticsCollector |
collector
Stores the semantics collector (may be null).
|
static java.lang.String[] |
GET_INPUT_ERROR_STREAM_CLASSES
Stores all classes which need instrumentation of a
getErrorStream (as InputStream) method. |
static java.lang.String[] |
GET_INPUT_STREAM_CLASSES
Stores all classes which need instrumentation of a
getInputStream method. |
static java.lang.String[] |
GET_OPEN_STREAM_CLASSES
Stores all classes which need instrumentation of a
getOpenStream method. |
static java.lang.String[] |
GET_OUTPUT_STREAM_CLASSES
Stores all classes which need instrumentation of a
getOutputStream method. |
private GroupAccountingType |
groupAccounting
Stores the group accounting type.
|
private ValueContext |
lastFieldAccessContext
Stores the context annotation of the last field access.
|
private java.lang.String |
lastFieldAccessType
Stores the type of the last field access.
|
private MemoryAccountingType |
memoryAccounting
Stores how memory use shall be monitored.
|
private int |
memRecord
Stores the (temporary) instrumentation record of memory resouces to
facilitate safe monitoring-class redefinition.
|
private boolean |
monitorCpuTime
Stores whether CPU time shall be monitored.
|
private boolean |
monitorFileIo
Stores whether file I/O shall be monitored.
|
private boolean |
monitorNetIo
Stores whether network I/O shall be monitored.
|
private static ArrayList<MethodEditor> |
POOL
Stores the instance pool.
|
private Monitor |
semantics
Stores the semantics to be applied.
|
protected static java.lang.String |
URL_TYPE_EXPR
Defines the call to determine the type of a stream.
|
| Modifier | Constructor and Description |
|---|---|
private |
MethodEditor()
Creates a new method editor (and prevents instantiation from outside
this package).
|
| Modifier and Type | Method and Description |
|---|---|
(package private) void |
assignSemantics(java.lang.String cls,
java.lang.String name,
java.lang.String methodSignature)
Assigns the stored monitoring semantics to the given method
(
methodSignature) in class with name cls. |
void |
clear()
Clears temporary variables for instance reuse.
|
void |
editFieldAccess(java.lang.String name,
java.lang.String type,
boolean isWriter)
Instruments a field access for notifying the recorder about value
changes.
|
void |
editMethodCall(java.lang.String name,
java.lang.String signature,
java.lang.String targetClass)
Instruments a method call.
|
void |
editNewArray()
Instruments the creation of an array.
|
void |
editNewExpression(java.lang.String type)
Instruments an object creation.
|
private java.lang.String |
getContextValueChangeCallRecId(de.uni_hildesheim.sse.monitoring.runtime.instrumentation.lib.IStatementModifier mod)
Returns the context id for the current method call.
|
private static java.lang.String |
getFieldId(de.uni_hildesheim.sse.monitoring.runtime.instrumentation.lib.IField field)
Produces an id for the given field.
|
private static java.lang.String |
getFieldId(java.lang.String declaringClassName,
java.lang.String name)
Produces an id for the given field.
|
static MethodEditor |
getFromPool(Monitor semantics,
boolean useSumResources,
ISemanticsCollector collector,
boolean inherited)
Returns an instance from the pool.
|
GroupAccountingType |
getGroupAccountingType()
Returns the group accounting type.
|
MemoryAccountingType |
getMemoryAccountingType()
Returns the memory accounting type.
|
int |
getMemRecord()
Returns the instrumentation record for memory.
|
boolean |
instrumentCpuTime()
Returns whether CPU time shall be monitored.
|
boolean |
instrumentFileIo()
Returns whether file I/O shall be monitored.
|
boolean |
instrumentNetIo()
Returns whether network I/O shall be monitored.
|
protected boolean |
mcDeclaringClassInstanceOf(de.uni_hildesheim.sse.monitoring.runtime.instrumentation.lib.IStatementModifier mod,
java.lang.String[] types)
Returns whether the declaring class of the current method call
is instance of at least one of the given
types,
whereby types may be superclasses. |
protected boolean |
processNetIoMethodCall(de.uni_hildesheim.sse.monitoring.runtime.instrumentation.lib.IStatementModifier mod,
java.lang.String name)
Processes a net I/O method call (intended to be called if library
is not instrumented or overhead instrumentation is done).
|
protected boolean |
processOtherIoMethodCall(de.uni_hildesheim.sse.monitoring.runtime.instrumentation.lib.IStatementModifier mod,
java.lang.String name)
Processes other I/O method (in case that library is instrumented).
|
static void |
put(de.uni_hildesheim.sse.monitoring.runtime.instrumentation.lib.IField field,
java.lang.String id)
Stores an annotated field.
|
static void |
release(MethodEditor editor)
Releases the given instance.
|
void |
setGroup(Monitor semantics,
boolean useSumResources,
ISemanticsCollector collector,
boolean inherited)
Defines the actual group annotation.
|
void |
setInstrumentationRecord(MethodInstrumented record)
Defines the instrumentation record for the current method under
transformation.
|
public static final java.lang.String[] GET_OUTPUT_STREAM_CLASSES
getOutputStream method. Do not refer
via classes as these classes should not be loaded
before (dynamic) instrumentation.public static final java.lang.String[] GET_INPUT_STREAM_CLASSES
getInputStream method. Do not refer
via classes as these classes should not be loaded
before (dynamic) instrumentation.public static final java.lang.String[] GET_INPUT_ERROR_STREAM_CLASSES
getErrorStream (as InputStream) method. Do not refer
via classes as these classes should not be loaded
before (dynamic) instrumentation.public static final java.lang.String[] GET_OPEN_STREAM_CLASSES
getOpenStream method. Do not refer
via classes as these classes should not be loaded
before (dynamic) instrumentation.protected static final java.lang.String URL_TYPE_EXPR
private static HashMap<java.lang.String,java.lang.String> annotatedFields
private static final ArrayList<MethodEditor> POOL
private java.lang.String lastFieldAccessType
private ValueContext lastFieldAccessContext
private int memRecord
private ISemanticsCollector collector
private Monitor semantics
private boolean monitorCpuTime
private MemoryAccountingType memoryAccounting
private GroupAccountingType groupAccounting
private boolean monitorFileIo
private boolean monitorNetIo
private MethodEditor()
public static final MethodEditor getFromPool(Monitor semantics, boolean useSumResources, ISemanticsCollector collector, boolean inherited)
semantics - the actual group annotation (may be null)useSumResources - use the sum resources specified in the
configuration instead of groupcollector - the instance to be used for collecting semantics for
future retransformations (may be null)inherited - whether semantics is inheritedpublic static final void release(MethodEditor editor)
editor - the instance to releaseprotected boolean processNetIoMethodCall(de.uni_hildesheim.sse.monitoring.runtime.instrumentation.lib.IStatementModifier mod,
java.lang.String name)
throws de.uni_hildesheim.sse.monitoring.runtime.instrumentation.lib.InstrumenterException
mod - the statement modifier instancename - the name of the method being calledde.uni_hildesheim.sse.monitoring.runtime.instrumentation.lib.InstrumenterException - if new code cannot be compiledprotected boolean mcDeclaringClassInstanceOf(de.uni_hildesheim.sse.monitoring.runtime.instrumentation.lib.IStatementModifier mod,
java.lang.String[] types)
throws de.uni_hildesheim.sse.monitoring.runtime.instrumentation.lib.InstrumenterException
types,
whereby types may be superclasses.mod - the statement modifiertypes - the classes to test fortrue if clazz is a subclass of
at least one of types, false elsede.uni_hildesheim.sse.monitoring.runtime.instrumentation.lib.InstrumenterException - declaring class not foundprotected boolean processOtherIoMethodCall(de.uni_hildesheim.sse.monitoring.runtime.instrumentation.lib.IStatementModifier mod,
java.lang.String name)
throws de.uni_hildesheim.sse.monitoring.runtime.instrumentation.lib.InstrumenterException
mod - the statement modifier instancename - the name of the method being calledde.uni_hildesheim.sse.monitoring.runtime.instrumentation.lib.InstrumenterException - in case that new code cannot be compiledpublic void setGroup(Monitor semantics, boolean useSumResources, ISemanticsCollector collector, boolean inherited)
semantics - the actual annotation holding the monitoring group
semanticsuseSumResources - use the sum resources specified in the
configuration instead of groupcollector - the instance to be used for collecting semantics for
future retransformations (may be null)inherited - whether semantics is inheritedpublic boolean instrumentCpuTime()
true if CPU time shall be monitored,
false elsepublic boolean instrumentNetIo()
true if network I/O shall be monitored,
false elsepublic boolean instrumentFileIo()
true if file I/O shall be monitored,
false elsepublic MemoryAccountingType getMemoryAccountingType()
public GroupAccountingType getGroupAccountingType()
void assignSemantics(java.lang.String cls,
java.lang.String name,
java.lang.String methodSignature)
methodSignature) in class with name cls.cls - the class to assign the semantics toname - the name of the methodmethodSignature - the signature of the method to assign the
semantics topublic static void put(de.uni_hildesheim.sse.monitoring.runtime.instrumentation.lib.IField field,
java.lang.String id)
field - the annotated filedid - the annotated recorded idpublic void editNewExpression(java.lang.String type)
throws de.uni_hildesheim.sse.monitoring.runtime.instrumentation.lib.InstrumenterException
editNewExpression in class de.uni_hildesheim.sse.monitoring.runtime.instrumentation.lib.BehaviorEditortype - the type to be createdde.uni_hildesheim.sse.monitoring.runtime.instrumentation.lib.InstrumenterException - in case that the new code does not compilepublic void editNewArray()
throws de.uni_hildesheim.sse.monitoring.runtime.instrumentation.lib.InstrumenterException
editNewArray in class de.uni_hildesheim.sse.monitoring.runtime.instrumentation.lib.BehaviorEditorde.uni_hildesheim.sse.monitoring.runtime.instrumentation.lib.InstrumenterException - in case that the new code does not compilepublic void editMethodCall(java.lang.String name,
java.lang.String signature,
java.lang.String targetClass)
throws de.uni_hildesheim.sse.monitoring.runtime.instrumentation.lib.InstrumenterException
mc* methods in
BehaviorEditor.getCodeModifier().editMethodCall in class de.uni_hildesheim.sse.monitoring.runtime.instrumentation.lib.BehaviorEditorname - the name of the method being calledsignature - the JVM signature of the methodtargetClass - the class being calledde.uni_hildesheim.sse.monitoring.runtime.instrumentation.lib.InstrumenterException - in case that the new code does not compileprivate java.lang.String getContextValueChangeCallRecId(de.uni_hildesheim.sse.monitoring.runtime.instrumentation.lib.IStatementModifier mod)
throws de.uni_hildesheim.sse.monitoring.runtime.instrumentation.lib.InstrumenterException
ValueContext method and return the id.mod - the statement modifier to gather information fromde.uni_hildesheim.sse.monitoring.runtime.instrumentation.lib.InstrumenterException - in case that the method call or the
declaring class cannot be foundpublic void editFieldAccess(java.lang.String name,
java.lang.String type,
boolean isWriter)
throws de.uni_hildesheim.sse.monitoring.runtime.instrumentation.lib.InstrumenterException
editFieldAccess in class de.uni_hildesheim.sse.monitoring.runtime.instrumentation.lib.BehaviorEditorname - the name of the fieldtype - the type of the fieldisWriter - whether the field value is changedde.uni_hildesheim.sse.monitoring.runtime.instrumentation.lib.InstrumenterException - in case that the new code does not compileprivate static java.lang.String getFieldId(de.uni_hildesheim.sse.monitoring.runtime.instrumentation.lib.IField field)
field - the field to return the id forprivate static java.lang.String getFieldId(java.lang.String declaringClassName,
java.lang.String name)
declaringClassName - the name of the class declaring the fieldname - the name of the fieldpublic void clear()
public void setInstrumentationRecord(MethodInstrumented record)
record - the instrumentation record (null clears the record)public int getMemRecord()