1 IExecutionDataAccessorGenerator

被 instrument 的類需要一段代碼,該代碼從運作時擷取 boolean[]執行個體。
該機制是針對于運作時的,是以由該接口抽象。 實作由 IRuntime 實作提供,并由 instrumentation process過程使用。
唯一方法
/**
* 此方法生成獲得具有給定id的類的coverage資料結構所需的位元組碼。 通常,instrumentation 過程會将此代碼嵌入到在類初始化時調用的方法中。甚至可以在目标VM外部随時調用此方法。
*
* 生成的代碼必須将 boolean[] 執行個體推入操作數棧。 除此結果對象外,生成的代碼不得對嵌入方法或類的結構進行任何假設。 生成的代碼不得使用或配置設定局部變量。
*
* @param classid
* @param classname
* VM class name
* @param probecount
* probe count for this class
* @param mv
* code output
* @return additional stack size required by the implementation, including
* the instance pushed to the stack
*/
int generateDataAccessor(long classid, String classname, int probecount,
MethodVisitor mv);
IRuntime 實作類
package org.jacoco.core.runtime;
/**
* 此接口表示一種特定的機制,用于在運作時收集目标VM中的執行資訊。
*/
public interface IRuntime extends IExecutionDataAccessorGenerator {
/**
* start coverage runtime.
* This method MUST be called before any class instrumented for this runtime is loaded.
* 必須在加載為此運作時檢測到的任何類之前調用此方法。
*
* @param data
* the execution data for this runtime
* @throws Exception
* any internal problem during startup
*/
void startup(RuntimeData data) throws Exception;
/**
* Allows the coverage runtime to cleanup internals. This class should be
* called when classes instrumented for this runtime are not used any more.
* 允許coverage運作時清理内部。 當不再使用為此運作時檢測的類時,應調用該類。
*/
void shutdown();
}