1 /******************************************************************************* 2 * Copyright (c) 2009, 2021 Mountainminds GmbH & Co. KG and Contributors 3 * This program and the accompanying materials are made available under 4 * the terms of the Eclipse Public License 2.0 which is available at 5 * http://www.eclipse.org/legal/epl-2.0 6 * 7 * SPDX-License-Identifier: EPL-2.0 8 * 9 * Contributors: 10 * Marc R. Hoffmann - initial API and implementation 11 * 12 *******************************************************************************/ 13 package com.vladium.emma.rt; 14 15 import java.io.File; 16 import java.io.FileOutputStream; 17 import java.io.IOException; 18 import java.io.OutputStream; 19 20 /** 21 * Compatibility layer for the EMMA runtime which allows to trigger dumps 22 * through EMMA APIs. Note that even this class emulates an EMMA API the files 23 * written are in JaCoCo execution data format. 24 * 25 * @deprecated Use {@link org.jacoco.agent.rt.IAgent} instead. 26 */ 27 @Deprecated 28 public final class RT { 29 RT()30 private RT() { 31 } 32 33 /** 34 * Writes the current execution data to the given file in JaCoCo execution 35 * data format. 36 * 37 * @param outFile 38 * file to write execution data to 39 * @param merge 40 * if <code>true</code>, execution data is appended to an 41 * existing file 42 * @param stopDataCollection 43 * ignored 44 * @throws IOException 45 * in case of problems with the file output 46 */ 47 @SuppressWarnings("unused") dumpCoverageData(final File outFile, final boolean merge, final boolean stopDataCollection)48 public static void dumpCoverageData(final File outFile, final boolean merge, 49 final boolean stopDataCollection) throws IOException { 50 final OutputStream out = new FileOutputStream(outFile, merge); 51 try { 52 out.write( 53 org.jacoco.agent.rt.RT.getAgent().getExecutionData(false)); 54 } finally { 55 out.close(); 56 } 57 } 58 59 /** 60 * Writes the current execution data to the given file in JaCoCo execution 61 * data format. If the file already exists new data is appended. 62 * 63 * @param outFile 64 * file to write execution data to 65 * @param stopDataCollection 66 * ignored 67 * @throws IOException 68 * in case of problems with the file output 69 */ dumpCoverageData(final File outFile, final boolean stopDataCollection)70 public static synchronized void dumpCoverageData(final File outFile, 71 final boolean stopDataCollection) throws IOException { 72 dumpCoverageData(outFile, true, stopDataCollection); 73 } 74 75 } 76