repositoryclassparser.java

来自「一个查找java程序里bug的程序的源代码,该程序本身也是java写的,对提高j」· Java 代码 · 共 84 行

JAVA
84
字号
/* * Bytecode Analysis Framework * Copyright (C) 2003,2004 University of Maryland *  * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. *  * This library 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 * Lesser General Public License for more details. *  * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */package edu.umd.cs.findbugs.ba;import java.io.IOException;import java.io.InputStream;import org.apache.bcel.Repository;import org.apache.bcel.classfile.ClassParser;import org.apache.bcel.classfile.JavaClass;/** * A special version of ClassParser that automatically enters * parsed classes into the Repository.  This allows us to * use the Repository to inspect the class hierarchy, based on * the current class path. */public class RepositoryClassParser {	private ClassParser classParser;	/**	 * Constructor.	 *	 * @param inputStream the input stream from which to read the class file	 * @param fileName    filename of the class file	 */	public RepositoryClassParser(InputStream inputStream, String fileName) {		classParser = new ClassParser(inputStream, fileName);	}	/**	 * Constructor.	 *	 * @param fileName name of the class file	 * @throws IOException if the file cannot be read	 */	public RepositoryClassParser(String fileName) throws IOException {		classParser = new ClassParser(fileName);	}	/**	 * Constructor.	 *	 * @param zipFile  name of a zip file containing the class	 * @param fileName name of the zip entry within the class	 * @throws IOException if the zip entry cannot be read	 */	public RepositoryClassParser(String zipFile, String fileName) throws IOException {		classParser = new ClassParser(zipFile, fileName);	}	/**	 * Parse the class file into a JavaClass object.	 * If succesful, the new JavaClass is entered into the Repository.	 *	 * @return the parsed JavaClass	 * @throws IOException if the class cannot be parsed	 */	public JavaClass parse() throws IOException {		JavaClass jclass = classParser.parse();		Repository.addClass(jclass);		return jclass;	}}// vim:ts=4

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?