前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >jacoco core.runtime包源码分析

jacoco core.runtime包源码分析

作者头像
JavaEdge
发布2020-05-26 17:01:17
4890
发布2020-05-26 17:01:17
举报
文章被收录于专栏:JavaEdgeJavaEdge

1 IExecutionDataAccessorGenerator

被 instrument 的类需要一段代码,该代码从运行时获取 boolean[]实例。 该机制是针对于运行时的,因此由该接口抽象。 实现由 IRuntime 实现提供,并由 instrumentation process过程使用。

唯一方法

代码语言:javascript
复制
	/**
	 * 此方法生成获得具有给定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 实现类

代码语言:javascript
复制
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();

}
本文参与 腾讯云自媒体分享计划,分享自作者个人站点/博客。
原始发表:2020-04-03 ,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体分享计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • 1 IExecutionDataAccessorGenerator
    • IRuntime 实现类
    领券
    问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档