亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來(lái)到蟲(chóng)蟲(chóng)下載站! | ?? 資源下載 ?? 資源專(zhuān)輯 ?? 關(guān)于我們
? 蟲(chóng)蟲(chóng)下載站

?? main.java

?? java覆蓋率測(cè)試工具
?? JAVA
字號(hào):
/*
 * Cobertura - http://cobertura.sourceforge.net/
 *
 * Copyright (C) 2003 jcoverage ltd.
 * Copyright (C) 2005 Mark Doliner
 * Copyright (C) 2005 Joakim Erdfelt
 * Copyright (C) 2005 Grzegorz Lukasik
 * Copyright (C) 2006 John Lewis
 * Copyright (C) 2006 Jiri Mares 
 * Contact information for the above is given in the COPYRIGHT file.
 *
 * Cobertura is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published
 * by the Free Software Foundation; either version 2 of the License,
 * or (at your option) any later version.
 *
 * Cobertura is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 * General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with Cobertura; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
 * USA
 */

package net.sourceforge.cobertura.instrument;

import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;
import java.util.List;
import java.util.Vector;
import java.util.zip.ZipEntry;
import java.util.zip.ZipInputStream;
import java.util.zip.ZipOutputStream;

import net.sourceforge.cobertura.coveragedata.CoverageDataFileHandler;
import net.sourceforge.cobertura.coveragedata.ProjectData;
import net.sourceforge.cobertura.util.ArchiveUtil;
import net.sourceforge.cobertura.util.CommandLineBuilder;
import net.sourceforge.cobertura.util.Header;
import net.sourceforge.cobertura.util.IOUtil;
import net.sourceforge.cobertura.util.RegexUtil;

import org.apache.log4j.Logger;
import org.objectweb.asm.ClassReader;
import org.objectweb.asm.ClassWriter;

/**
 * <p>
 * Add coverage instrumentation to existing classes.
 * </p>
 *
 * <h3>What does that mean, exactly?</h3>
 * <p>
 * It means Cobertura will look at each class you give it.  It
 * loads the bytecode into memory.  For each line of source,
 * Cobertura adds a few extra instructions.  These instructions 
 * do the following:
 * </p>
 * 
 * <ol>
 * <li>Get an instance of the ProjectData class.</li>
 * <li>Call a method in this ProjectData class that increments
 * a counter for this line of code.
 * </ol>
 *
 * <p>
 * After every line in a class has been "instrumented," Cobertura
 * edits the bytecode for the class one more time and adds
 * "implements net.sourceforge.cobertura.coveragedata.HasBeenInstrumented" 
 * This is basically just a flag used internally by Cobertura to
 * determine whether a class has been instrumented or not, so
 * as not to instrument the same class twice.
 * </p>
 */
public class Main
{

	private static final Logger logger = Logger.getLogger(Main.class);

	private File destinationDirectory = null;

	private Collection ignoreRegexes = new Vector();

	private Collection ignoreBranchesRegexes = new Vector();

	private ClassPattern classPattern = new ClassPattern();

	private ProjectData projectData = null;

	/**
	 * @param entry A zip entry.
	 * @return True if the specified entry has "class" as its extension,
	 * false otherwise.
	 */
	private static boolean isClass(ZipEntry entry)
	{
		return entry.getName().endsWith(".class");
	}

	private boolean addInstrumentationToArchive(CoberturaFile file, InputStream archive,
			OutputStream output) throws Exception
	{
		ZipInputStream zis = null;
		ZipOutputStream zos = null;

		try
		{
			zis = new ZipInputStream(archive);
			zos = new ZipOutputStream(output);
			return addInstrumentationToArchive(file, zis, zos);
		}
		finally
		{
			zis = (ZipInputStream)IOUtil.closeInputStream(zis);
			zos = (ZipOutputStream)IOUtil.closeOutputStream(zos);
		}
	}

	private boolean addInstrumentationToArchive(CoberturaFile file, ZipInputStream archive,
			ZipOutputStream output) throws Exception
	{
		/*
		 * "modified" is returned and indicates that something was instrumented.
		 * If nothing is instrumented, the original entry will be used by the
		 * caller of this method.
		 */
		boolean modified = false;
		ZipEntry entry;
		while ((entry = archive.getNextEntry()) != null)
		{
			try
			{
				String entryName = entry.getName();

				/*
				 * If this is a signature file then don't copy it,
				 * but don't set modified to true.  If the only
				 * thing we do is strip the signature, just use
				 * the original entry.
				 */
				if (ArchiveUtil.isSignatureFile(entry.getName()))
				{
					continue;
				}
				ZipEntry outputEntry = new ZipEntry(entry.getName());
				outputEntry.setComment(entry.getComment());
				outputEntry.setExtra(entry.getExtra());
				outputEntry.setTime(entry.getTime());
				output.putNextEntry(outputEntry);

				// Read current entry
				byte[] entryBytes = IOUtil
						.createByteArrayFromInputStream(archive);

				// Instrument embedded archives if a classPattern has been specified
				if ((classPattern.isSpecified()) && ArchiveUtil.isArchive(entryName))
				{
					Archive archiveObj = new Archive(file, entryBytes);
					addInstrumentationToArchive(archiveObj);
					if (archiveObj.isModified())
					{
						modified = true;
						entryBytes = archiveObj.getBytes();
						outputEntry.setTime(System.currentTimeMillis());
					}
				}
				else if (isClass(entry) && classPattern.matches(entryName))
				{
					try
					{
						// Instrument class
						ClassReader cr = new ClassReader(entryBytes);
						ClassWriter cw = new ClassWriter(true);
						ClassInstrumenter cv = new ClassInstrumenter(projectData,
								cw, ignoreRegexes, ignoreBranchesRegexes);
						cr.accept(cv, false);
	
						// If class was instrumented, get bytes that define the
						// class
						if (cv.isInstrumented())
						{
							logger.debug("Putting instrumented entry: "
									+ entry.getName());
							entryBytes = cw.toByteArray();
							modified = true;
							outputEntry.setTime(System.currentTimeMillis());
						}
					}
					catch (Throwable t)
					{
						if (entry.getName().endsWith("_Stub.class"))
						{
							//no big deal - it is probably an RMI stub, and they don't need to be instrumented
							logger.debug("Problems instrumenting archive entry: " + entry.getName(), t);
						}
						else
						{
							logger.warn("Problems instrumenting archive entry: " + entry.getName(), t);
						}
					}
				}

				// Add entry to the output
				output.write(entryBytes);
				output.closeEntry();
				archive.closeEntry();
			}
			catch (Exception e)
			{
				logger.warn("Problems with archive entry: " + entry.getName(), e);
			}
			catch (Throwable t)
			{
				logger.warn("Problems with archive entry: " + entry.getName(), t);
			}
			output.flush();
		}
		return modified;
	}

	private void addInstrumentationToArchive(Archive archive) throws Exception
	{
		InputStream in = null;
		ByteArrayOutputStream out = null;
		try
		{
			in = archive.getInputStream();
			out = new ByteArrayOutputStream();
			boolean modified = addInstrumentationToArchive(archive.getCoberturaFile(), in, out);

			if (modified)
			{
				out.flush();
				byte[] bytes = out.toByteArray();
				archive.setModifiedBytes(bytes);
			}
		}
		finally
		{
			in = IOUtil.closeInputStream(in);
			out = (ByteArrayOutputStream)IOUtil.closeOutputStream(out);
		}
	}

	private void addInstrumentationToArchive(CoberturaFile archive)
	{
		logger.debug("Instrumenting archive " + archive.getAbsolutePath());

		File outputFile = null;
		ZipInputStream input = null;
		ZipOutputStream output = null;
		boolean modified = false;
		try
		{
			// Open archive
			try
			{
				input = new ZipInputStream(new FileInputStream(archive));
			}
			catch (FileNotFoundException e)
			{
				logger.warn("Cannot open archive file: "
						+ archive.getAbsolutePath(), e);
				return;
			}

			// Open output archive
			try
			{
				// check if destination folder is set
				if (destinationDirectory != null)
				{
					// if so, create output file in it
					outputFile = new File(destinationDirectory, archive.getPathname());
				}
				else
				{
					// otherwise create output file in temporary location
					outputFile = File.createTempFile(
							"CoberturaInstrumentedArchive", "jar");
					outputFile.deleteOnExit();
				}
				output = new ZipOutputStream(new FileOutputStream(outputFile));
			}
			catch (IOException e)
			{
				logger.warn("Cannot open file for instrumented archive: "
						+ archive.getAbsolutePath(), e);
				return;
			}

			// Instrument classes in archive
			try
			{
				modified = addInstrumentationToArchive(archive, input, output);
			}
			catch (Throwable e)
			{
				logger.warn("Cannot instrument archive: "
						+ archive.getAbsolutePath(), e);
				return;
			}
		}
		finally
		{
			input = (ZipInputStream)IOUtil.closeInputStream(input);
			output = (ZipOutputStream)IOUtil.closeOutputStream(output);
		}

		// If destination folder was not set, overwrite orginal archive with
		// instrumented one
		if (modified && (destinationDirectory == null))
		{
			try
			{
				logger.debug("Moving " + outputFile.getAbsolutePath() + " to "
						+ archive.getAbsolutePath());
				IOUtil.moveFile(outputFile, archive);
			}
			catch (IOException e)
			{
				logger.warn("Cannot instrument archive: "
						+ archive.getAbsolutePath(), e);
				return;
			}
		}
		if ((destinationDirectory != null) && (!modified))
		{
			outputFile.delete();
		}
	}

	private void addInstrumentationToSingleClass(File file)
	{
		logger.debug("Instrumenting class " + file.getAbsolutePath());

		InputStream inputStream = null;
		ClassWriter cw;
		ClassInstrumenter cv;
		try
		{
			inputStream = new FileInputStream(file);
			ClassReader cr = new ClassReader(inputStream);
			cw = new ClassWriter(true);
			cv = new ClassInstrumenter(projectData, cw, ignoreRegexes, ignoreBranchesRegexes);
			cr.accept(cv, false);
		}
		catch (Throwable t)
		{
			logger.warn("Unable to instrument file " + file.getAbsolutePath(),
					t);
			return;
		}
		finally
		{
			inputStream = IOUtil.closeInputStream(inputStream);
		}

		OutputStream outputStream = null;
		try
		{
			if (cv.isInstrumented())
			{
				// If destinationDirectory is null, then overwrite
				// the original, uninstrumented file.
				File outputFile;
				if (destinationDirectory == null)
					outputFile = file;
				else
					outputFile = new File(destinationDirectory, cv
							.getClassName().replace('.', File.separatorChar)
							+ ".class");

				File parentFile = outputFile.getParentFile();
				if (parentFile != null)
				{
					parentFile.mkdirs();
				}

				byte[] instrumentedClass = cw.toByteArray();
				outputStream = new FileOutputStream(outputFile);
				outputStream.write(instrumentedClass);
			}
		}
		catch (Throwable t)
		{
			logger.warn("Unable to instrument file " + file.getAbsolutePath(),
					t);
			return;
		}
		finally
		{
			outputStream = IOUtil.closeOutputStream(outputStream);
		}
	}

	// TODO: Don't attempt to instrument a file if the outputFile already
	//       exists and is newer than the input file, and the output and
	//       input file are in different locations?
	private void addInstrumentation(CoberturaFile coberturaFile)
	{
		if (coberturaFile.isClass() && classPattern.matches(coberturaFile.getPathname()))
		{
			addInstrumentationToSingleClass(coberturaFile);
		}
		else if (coberturaFile.isDirectory())
		{
			String[] contents = coberturaFile.list();
			for (int i = 0; i < contents.length; i++)
			{
				File relativeFile = new File(coberturaFile.getPathname(), contents[i]);
				CoberturaFile relativeCoberturaFile = new CoberturaFile(coberturaFile.getBaseDir(),
						relativeFile.toString());
				//recursion!
				addInstrumentation(relativeCoberturaFile);
			}
		}
	}

	private void parseArguments(String[] args)
	{
		File dataFile = CoverageDataFileHandler.getDefaultDataFile();

		// Parse our parameters
		List filePaths = new ArrayList();
		String baseDir = null;
		for (int i = 0; i < args.length; i++)
		{
			if (args[i].equals("--basedir"))
				baseDir = args[++i];
			else if (args[i].equals("--datafile"))
				dataFile = new File(args[++i]);
			else if (args[i].equals("--destination"))
				destinationDirectory = new File(args[++i]);
			else if (args[i].equals("--ignore"))
			{
				RegexUtil.addRegex(ignoreRegexes, args[++i]);
			}
			else if (args[i].equals("--ignoreBranches"))
			{
				RegexUtil.addRegex(ignoreBranchesRegexes, args[++i]);
			}
			else if (args[i].equals("--includeClasses"))
			{
				classPattern.addIncludeClassesRegex(args[++i]);
			}
			else if (args[i].equals("--excludeClasses"))
			{
				classPattern.addExcludeClassesRegex(args[++i]);
			}
			else
			{
				CoberturaFile coberturaFile = new CoberturaFile(baseDir, args[i]);
				filePaths.add(coberturaFile);
			}
		}

		// Load coverage data
		if (dataFile.isFile())
			projectData = CoverageDataFileHandler.loadCoverageData(dataFile);
		if (projectData == null)
			projectData = new ProjectData();
		
		// Instrument classes
		System.out.println("Instrumenting "	+ filePaths.size() + " "
				+ (filePaths.size() == 1 ? "file" : "files")
				+ (destinationDirectory != null ? " to "
						+ destinationDirectory.getAbsoluteFile() : ""));

		Iterator iter = filePaths.iterator();
		while (iter.hasNext())
		{
			CoberturaFile coberturaFile = (CoberturaFile)iter.next();
			if (coberturaFile.isArchive())
			{
				addInstrumentationToArchive(coberturaFile);
			}
			else
			{
				addInstrumentation(coberturaFile);
			}
		}

		// Save coverage data
		CoverageDataFileHandler.saveCoverageData(projectData, dataFile);
	}

	public static void main(String[] args)
	{
		Header.print(System.out);

		long startTime = System.currentTimeMillis();

		Main main = new Main();

		try {
			args = CommandLineBuilder.preprocessCommandLineArguments( args);
		} catch( Exception ex) {
			System.err.println( "Error: Cannot process arguments: " + ex.getMessage());
			System.exit(1);
		}
		main.parseArguments(args);

		long stopTime = System.currentTimeMillis();
		System.out.println("Instrument time: " + (stopTime - startTime) + "ms");
	}

}

?? 快捷鍵說(shuō)明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號(hào) Ctrl + =
減小字號(hào) Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
91高清视频免费看| 精品一区二区三区欧美| 91精品国产综合久久福利软件 | 国产清纯白嫩初高生在线观看91| 精品欧美久久久| 亚洲欧美日韩国产综合在线| 午夜日韩在线观看| a在线播放不卡| 7777精品伊人久久久大香线蕉经典版下载 | 婷婷久久综合九色综合伊人色| 日本欧美韩国一区三区| 国产白丝网站精品污在线入口| 色综合久久88色综合天天6| 欧美做爰猛烈大尺度电影无法无天| 欧美久久婷婷综合色| 国产亚洲一二三区| 美女性感视频久久| 91免费在线播放| 欧美色图在线观看| 中文字幕一区二区在线播放| 日韩主播视频在线| 在线视频亚洲一区| 久久久精品综合| 五月天精品一区二区三区| 91美女在线观看| 久久蜜桃av一区精品变态类天堂| 国产精品久久久久精k8| 国产成人av电影在线| 欧美日韩第一区日日骚| 亚洲香肠在线观看| 成人不卡免费av| 日韩一二三区视频| 日韩av中文字幕一区二区| 成人污视频在线观看| 91精品国产综合久久久久久久| 亚洲欧美偷拍三级| 国产高清视频一区| 国产视频一区二区在线| 日韩影院在线观看| 欧美午夜在线观看| 亚洲香肠在线观看| 日本韩国视频一区二区| 久久午夜老司机| 久久99国产精品久久99| 日韩一区二区电影网| 奇米影视一区二区三区| 在线成人高清不卡| 亚洲大尺度视频在线观看| 欧美日韩国产天堂| 亚洲福利电影网| 欧美一区二区三区在线视频| 日日夜夜精品视频天天综合网| 91视频在线观看免费| 一区二区免费在线| 日本乱人伦aⅴ精品| 亚洲国产乱码最新视频| 欧美日韩精品欧美日韩精品一| 夜夜精品浪潮av一区二区三区| 欧美性大战久久久久久久蜜臀 | 日韩免费看网站| 毛片av一区二区| 精品国产乱子伦一区| 国产精品一区二区三区网站| 国产视频一区在线播放| 日本黄色一区二区| 一区二区三区加勒比av| 7777精品伊人久久久大香线蕉超级流畅 | 亚洲免费观看高清在线观看| 欧美日韩精品一区二区| 美女脱光内衣内裤视频久久网站 | 亚洲成人资源在线| 日韩一卡二卡三卡| 国产精品一二三四五| 亚洲一区二区三区在线播放| 欧美精品视频www在线观看| 午夜精品123| 国产日产欧美一区二区三区 | 国产在线精品不卡| 国产精品久久久久久久久免费丝袜 | 久久久噜噜噜久噜久久综合| 国产精品77777| 亚洲一区二区三区四区在线观看| 欧美人妖巨大在线| 国内精品国产三级国产a久久| 国产精品国产自产拍高清av王其 | 欧美酷刑日本凌虐凌虐| 青青青爽久久午夜综合久久午夜| 欧美韩国日本不卡| 欧美人与禽zozo性伦| 99久久久精品| 日本中文字幕一区| 中文字幕av一区二区三区免费看| 欧美综合欧美视频| 国产剧情在线观看一区二区| 日韩一区欧美二区| 国产精品国产自产拍在线| 欧美一区二区三区精品| 在线观看成人免费视频| 蜜桃视频第一区免费观看| 日韩欧美专区在线| 91国偷自产一区二区开放时间| 蜜臀av性久久久久蜜臀aⅴ四虎 | 国产综合色视频| 亚洲一区二区三区四区五区黄| 精品日韩在线观看| 日韩欧美精品三级| 在线观看日韩一区| 色呦呦国产精品| 日日夜夜一区二区| 美女视频第一区二区三区免费观看网站| 欧美一区二区高清| av一区二区三区| 国产一本一道久久香蕉| 久久精品国产亚洲a| 一区av在线播放| 国产精品国产a| 国产精品久久夜| 久久免费午夜影院| 国产日本一区二区| 亚洲精品在线观看网站| 欧美三级韩国三级日本一级| 在线观看区一区二| www.在线欧美| 色天使色偷偷av一区二区| 99精品在线免费| 在线免费不卡电影| 欧美日韩五月天| 色综合久久66| 欧美曰成人黄网| 欧美在线观看视频在线| 91在线视频网址| 在线看不卡av| 在线观看区一区二| 欧美疯狂性受xxxxx喷水图片| 在线视频国产一区| 91色|porny| 欧美性猛交xxxxxx富婆| 欧美性淫爽ww久久久久无| 欧美老年两性高潮| 日韩一区二区中文字幕| 欧美男女性生活在线直播观看| 欧美色网一区二区| 欧美精选一区二区| 色婷婷久久99综合精品jk白丝 | 亚洲人成网站色在线观看| 一个色妞综合视频在线观看| 一区二区免费看| 尤物在线观看一区| 日韩精品成人一区二区在线| 久久99热这里只有精品| jizz一区二区| eeuss鲁一区二区三区| 在线亚洲高清视频| 欧美午夜免费电影| 国产日韩欧美制服另类| 国产精品少妇自拍| 日韩精品色哟哟| 蜜臂av日日欢夜夜爽一区| 99在线热播精品免费| 在线精品国精品国产尤物884a| 在线成人高清不卡| 国产精品丝袜黑色高跟| 亚洲欧美日韩中文播放| 日本最新不卡在线| 国产成人免费网站| 国产剧情av麻豆香蕉精品| av高清久久久| 欧美精品粉嫩高潮一区二区| 日本精品一级二级| 国产视频亚洲色图| 亚洲成人动漫精品| 国产91丝袜在线播放0| 色婷婷av一区二区三区gif| 色av综合在线| 精品卡一卡二卡三卡四在线| 国产精品护士白丝一区av| 九九精品一区二区| 在线观看日韩毛片| 久久综合色综合88| 国产精品白丝在线| 精品一区二区三区免费播放| 成人av免费在线| 6080午夜不卡| 国产精品美女久久久久久久久 | 精品国产乱码久久久久久夜甘婷婷 | 久久精品人人做人人综合| 亚洲你懂的在线视频| 精品一区二区国语对白| 欧美乱妇23p| 亚洲人精品午夜| 老司机精品视频线观看86| 99久久久免费精品国产一区二区| 欧美大尺度电影在线| 亚洲精品高清在线观看| 国产尤物一区二区| 欧美三级视频在线观看| 国产精品理论片| 国产精品综合一区二区| 欧美伦理视频网站| 国产精品电影一区二区|