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