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

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? filelocker.java

?? java覆蓋率測試工具
?? JAVA
字號:
/* Cobertura - http://cobertura.sourceforge.net/
 *
 * Copyright (C) 2006 John Lewis
 * Copyright (C) 2006 Mark Doliner
 *
 * Note: This file is dual licensed under the GPL and the Apache
 * Source License 1.1 (so that it can be used from both the main
 * Cobertura classes and the ant tasks).
 *
 * 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.util;

import java.io.File;
import java.io.FileNotFoundException;
import java.io.RandomAccessFile;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;

/**
 * This class controls access to any file so that multiple JVMs will
 * not be able to write to the file at the same time.
 *
 * A file called "filename.lock" is created and Java's FileLock class
 * is used to lock the file.
 *
 * The java.nio classes were introduced in Java 1.4, so this class
 * does a no-op when used with Java 1.3.  The class maintains
 * compatability with Java 1.3 by accessing the java.nio classes
 * using reflection.
 *
 * @author John Lewis
 * @author Mark Doliner
 */
public class FileLocker
{

	/**
	 * An object of type FileLock, created using reflection.
	 */
	private Object lock = null;

	/**
	 * An object of type FileChannel, created using reflection.
	 */
	private Object lockChannel = null;

	/**
	 * A file called "filename.lock" that resides in the same directory
	 * as "filename"
	 */
	private File lockFile;

	public FileLocker(File file)
	{
		String lockFileName = file.getName() + ".lock";
		File parent = file.getParentFile();
		if (parent == null)
		{
			lockFile = new File(lockFileName);
		}
		else
		{
			lockFile = new File(parent, lockFileName);
		}
		lockFile.deleteOnExit();
	}

	/**
	 * Obtains a lock on the file.  This blocks until the lock is obtained.
	 */
	public boolean lock()
	{
		String useNioProperty = System.getProperty("cobertura.use.java.nio");
		if (System.getProperty("java.version").startsWith("1.3") ||
				((useNioProperty != null) && useNioProperty.equalsIgnoreCase("false")))
		{
			return true;
		}

		try
		{
			Class aClass = Class.forName("java.io.RandomAccessFile");
			Method method = aClass.getDeclaredMethod("getChannel", (Class[])null);
			lockChannel = method.invoke(new RandomAccessFile(lockFile, "rw"), (Object[])null);
		}
		catch (FileNotFoundException e)
		{
			System.err.println("Unable to get lock channel for " + lockFile.getAbsolutePath()
					+ ": " + e.getLocalizedMessage());
			return false;
		}
		catch (InvocationTargetException e)
		{
			System.err.println("Unable to get lock channel for " + lockFile.getAbsolutePath()
					+ ": " + e.getLocalizedMessage());
			return false;
		}
		catch (Throwable t)
		{
			System.err.println("Unable to execute RandomAccessFile.getChannel() using reflection: "
					+ t.getLocalizedMessage());
			t.printStackTrace();
		}

		try
		{
			Class aClass = Class.forName("java.nio.channels.FileChannel");
			Method method = aClass.getDeclaredMethod("lock", (Class[])null);
			lock = method.invoke(lockChannel, (Object[])null);
		}
		catch (InvocationTargetException e)
		{
			System.err.println("---------------------------------------");
			e.printStackTrace(System.err);
			System.err.println("---------------------------------------");
			System.err.println("Unable to get lock on " + lockFile.getAbsolutePath() + ": "
					+ e.getLocalizedMessage());
			System.err.println("This is known to happen on Linux kernel 2.6.20.");
			System.err.println("Make sure cobertura.jar is in the root classpath of the jvm ");
			System.err.println("process running the instrumented code.  If the instrumented code ");
			System.err.println("is running in a web server, this means cobertura.jar should be in ");
			System.err.println("the web server's lib directory.");
			System.err.println("Don't put multiple copies of cobertura.jar in different WEB-INF/lib directories.");
			System.err.println("Only one classloader should load cobertura.  It should be the root classloader.");
			System.err.println("---------------------------------------");
			return false;
		}
		catch (Throwable t)
		{
			System.err.println("Unable to execute FileChannel.lock() using reflection: "
					+ t.getLocalizedMessage());
			t.printStackTrace();
		}

		return true;
	}

	/**
	 * Releases the lock on the file.
	 */
	public void release()
	{
		if (lock != null)
			lock = releaseFileLock(lock);
		if (lockChannel != null)
			lockChannel = closeChannel(lockChannel);
		lockFile.delete();
	}

	private static Object releaseFileLock(Object lock)
	{
		try
		{
			Class aClass = Class.forName("java.nio.channels.FileLock");
			Method method = aClass.getDeclaredMethod("isValid", (Class[])null);
			if (((Boolean)method.invoke(lock, (Object[])null)).booleanValue())
			{
				method = aClass.getDeclaredMethod("release", (Class[])null);
				method.invoke(lock, (Object[])null);
				lock = null;
			}
		}
		catch (Throwable t)
		{
			System.err.println("Unable to release locked file: " + t.getLocalizedMessage());
		}
		return lock;
	}

	private static Object closeChannel(Object channel)
	{
		try
		{
			Class aClass = Class.forName("java.nio.channels.spi.AbstractInterruptibleChannel");
			Method method = aClass.getDeclaredMethod("isOpen", (Class[])null);
			if (((Boolean)method.invoke(channel, (Object[])null)).booleanValue())
			{
				method = aClass.getDeclaredMethod("close", (Class[])null);
				method.invoke(channel, (Object[])null);
				channel = null;
			}
		}
		catch (Throwable t)
		{
			System.err.println("Unable to close file channel: " + t.getLocalizedMessage());
		}
		return channel;
	}

}

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
一区二区三区不卡在线观看| 蜜桃视频一区二区三区| 精品一区二区三区欧美| 久久综合五月天婷婷伊人| 国产一区美女在线| 国产精品福利一区二区三区| 欧美无砖专区一中文字| 中文字幕免费不卡在线| 五月天激情综合| 在线播放欧美女士性生活| 男女视频一区二区| 日韩欧美一区二区免费| 久久国产视频网| 国产精品免费免费| 欧美日韩激情一区| 激情综合网天天干| 亚洲少妇中出一区| 91精品国产综合久久精品麻豆| 蜜臀av性久久久久蜜臀aⅴ | 国产999精品久久久久久| 91黄视频在线观看| 麻豆成人免费电影| 一区二区三区国产精华| 日韩欧美资源站| 色综合久久88色综合天天免费| 偷拍自拍另类欧美| 国产精品进线69影院| 91精品国产欧美一区二区成人 | 视频一区国产视频| 国产精品色眯眯| 日韩精品一区国产麻豆| 色综合激情久久| 有坂深雪av一区二区精品| 色婷婷一区二区| 国产成人免费高清| 激情综合亚洲精品| 蜜臀av一区二区三区| 亚洲综合激情小说| 成人免费小视频| 亚洲视频一二三区| 国产精品国产自产拍高清av| 久久久蜜桃精品| 精品国产乱子伦一区| 日韩一区国产二区欧美三区| 欧美日韩国产大片| 在线成人午夜影院| 日韩小视频在线观看专区| 色天使久久综合网天天| 99在线精品视频| 在线观看区一区二| 精品一区二区在线看| 色婷婷av久久久久久久| 成a人片亚洲日本久久| 国产精品正在播放| 亚洲国产成人av| 国产日韩欧美在线一区| 国产女人18水真多18精品一级做 | 久久色.com| 亚洲欧美激情一区二区| 亚洲精选视频免费看| 天堂精品中文字幕在线| 亚洲国产一区二区a毛片| 日韩国产欧美视频| 久久精品久久精品| 成人av在线网| 欧美久久久久免费| 国产精品丝袜在线| 亚洲午夜激情av| 成人性生交大片免费看中文| 97精品久久久午夜一区二区三区| 欧美影院一区二区三区| 日韩精品中文字幕在线一区| 亚洲欧洲在线观看av| 免费人成黄页网站在线一区二区| 国产成人精品影视| 欧美高清性hdvideosex| 国产精品伦理在线| 中文字幕综合网| 国产精品69毛片高清亚洲| 欧美日本一区二区| 中文字幕中文字幕在线一区 | 日韩伦理免费电影| 石原莉奈在线亚洲三区| 一本大道久久a久久精品综合| 欧美成人bangbros| 亚洲大型综合色站| 成人中文字幕电影| 亚洲精品在线一区二区| 天天操天天色综合| 欧美性感一区二区三区| 亚洲欧美日韩久久| 99久久免费视频.com| 国产精品无遮挡| 国产成人久久精品77777最新版本| 在线播放91灌醉迷j高跟美女| 日韩美女久久久| 97久久超碰国产精品电影| 一区二区三区欧美久久| 欧美精品一区二区三区高清aⅴ| 午夜私人影院久久久久| 8x福利精品第一导航| 日韩国产精品久久久| 日韩一区二区三区av| 久久狠狠亚洲综合| 国产午夜精品久久久久久久| 成人性生交大片免费看中文 | 成人午夜免费视频| 亚洲日本一区二区三区| 在线免费视频一区二区| aaa欧美色吧激情视频| 亚洲三级理论片| 欧美精选一区二区| 国产真实乱偷精品视频免| 欧美经典三级视频一区二区三区| 大陆成人av片| 青青草伊人久久| 亚洲图片欧美激情| 日韩欧美另类在线| 在线观看亚洲精品| 蜜桃av噜噜一区| 亚洲一区二区黄色| 夜夜亚洲天天久久| 国内精品写真在线观看| 91社区在线播放| 久久久99免费| 日韩成人精品视频| 欧洲av在线精品| 国产精品国产三级国产有无不卡 | 国产宾馆实践打屁股91| 7777精品伊人久久久大香线蕉超级流畅| 欧美精品一区二区蜜臀亚洲| 五月天丁香久久| 欧美日韩一二区| 欧美极品美女视频| 五月婷婷另类国产| 色一区在线观看| 中文字幕的久久| 波多野结衣中文一区| 久久你懂得1024| 国内精品久久久久影院薰衣草| 欧美一卡2卡三卡4卡5免费| 五月天激情小说综合| 欧美一区二区在线免费观看| 日韩精品1区2区3区| 538在线一区二区精品国产| 日韩中文字幕区一区有砖一区 | 欧洲精品中文字幕| 亚洲国产另类av| 9191成人精品久久| 极品少妇xxxx精品少妇| 欧美国产精品久久| 欧美色成人综合| 国产 日韩 欧美大片| 精品国产91乱码一区二区三区| 国产乱码精品一区二区三| 欧美一区二区三区免费大片| 国产白丝精品91爽爽久久| 国产精品久久毛片| 欧美私人免费视频| 久久er精品视频| 亚洲精品国产一区二区精华液 | 欧美色综合影院| 美国毛片一区二区三区| 中文字幕一区二区三区乱码在线| 欧美在线观看一二区| 激情综合色播五月| 亚洲电影你懂得| 国产精品久久久99| 精品欧美黑人一区二区三区| 99re热视频精品| 粉嫩av一区二区三区粉嫩| 日本中文字幕一区二区有限公司| 国产精品日韩成人| 欧美精品一区在线观看| 欧美老女人第四色| 欧洲精品视频在线观看| 99精品久久只有精品| 国产精品中文字幕欧美| 美腿丝袜亚洲色图| 蜜臀99久久精品久久久久久软件| 一区二区三区蜜桃网| 一区二区三区加勒比av| 一区二区三区四区亚洲| 伊人一区二区三区| 夜夜嗨av一区二区三区中文字幕 | 欧美精品日日鲁夜夜添| 日本精品一区二区三区四区的功能| 高清国产一区二区| 成人av免费在线播放| 色系网站成人免费| 欧美在线观看禁18| 日韩情涩欧美日韩视频| 久久久久久久久久久99999| 久久精品一级爱片| 国产午夜亚洲精品不卡| 亚洲天堂网中文字| 亚洲综合色区另类av| 日韩成人一区二区| 岛国av在线一区| 欧美剧情片在线观看|