jacoco core.runtime包源码分析
发布日期:2021-06-30 12:23:54 浏览次数:2 分类:技术文章

本文共 1454 字,大约阅读时间需要 4 分钟。

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();}

转载地址:https://javaedge.blog.csdn.net/article/details/105264876 如侵犯您的版权,请留言回复原文章的地址,我们会给您删除此文章,给您带来不便请您谅解!

上一篇:记一次 JVM 源码分析(4.解释器与方法执行)
下一篇:Intellij IDEA debug断点调试技巧总结

发表评论

最新留言

不错!
[***.144.177.141]2024年04月11日 13时23分10秒