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 org.jacoco.ant; 14 15 import java.io.FileInputStream; 16 import java.io.FileOutputStream; 17 import java.io.InputStream; 18 import java.io.OutputStream; 19 20 import org.jacoco.core.internal.InputStreams; 21 import org.jacoco.core.internal.instr.InstrSupport; 22 import org.objectweb.asm.ClassReader; 23 import org.objectweb.asm.ClassWriter; 24 25 /** 26 * Test utility to remove debug information from class files. 27 */ 28 public class RemoveDebugInfos { 29 main(String[] args)30 public static void main(String[] args) throws Exception { 31 final InputStream in = new FileInputStream(args[0]); 32 final ClassReader reader = InstrSupport 33 .classReaderFor(InputStreams.readFully(in)); 34 in.close(); 35 36 final ClassWriter writer = new ClassWriter(0); 37 reader.accept(writer, ClassReader.SKIP_DEBUG); 38 39 final OutputStream out = new FileOutputStream(args[1]); 40 out.write(writer.toByteArray()); 41 out.close(); 42 } 43 44 } 45