@Override public void onLaunching(Platform platform, MetaClass metaClass, OptionsByType optionsByType) { if (enabled && metaClass != null && JavaApplication.class.isAssignableFrom(metaClass.getImplementationClass(platform, optionsByType))) { try { // determine the classpath of the JaCoCo runtime agent jar (should be something like jacocoagent-x.y.z.jar) ClassPath jacocoPath = ClassPath.ofClass(RT.class); // define a JavaAgent for JaCoCo JavaAgent javaAgent = JavaAgent.using(jacocoPath.toString(), parameters); optionsByType.add(javaAgent); } catch (Exception e) { // ignored } } }