当前位置: 首页>>代码示例>>Java>>正文


Java ClassPath类代码示例

本文整理汇总了Java中org.apache.bcel.util.ClassPath的典型用法代码示例。如果您正苦于以下问题:Java ClassPath类的具体用法?Java ClassPath怎么用?Java ClassPath使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


ClassPath类属于org.apache.bcel.util包,在下文中一共展示了ClassPath类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: main

import org.apache.bcel.util.ClassPath; //导入依赖的package包/类
public static void main(String[] args) throws Exception {
	CommandLineArgs commandLine = new CommandLineArgs(args);
	
	StringBuffer classPathString = new StringBuffer();
	for(String c: commandLine.getClassPath()) {
		if (classPathString.length()!=0)
			classPathString.append(":"+c);
		else
			classPathString.append(c);
	}
	ClassPath.setDefaultClassPath(new ClassPath(classPathString.toString()));
	
	LinkedList<File> fileList = LogFiles.orderedLogFileList(commandLine.getLogFile());
	
	LinkedList<String> classList = makeClassList(fileList,commandLine.getLogged());

	DaCapoOutputHandler output = new DaCapoOutputHandler(commandLine.getOutputStream(),commandLine.getIndividual());
	
	String[] classFileList = makeClassFileList(classList, commandLine.getClassPath());
	
	MetricsFilter.runMetrics(classFileList, output);
	output.reportTotal();
}
 
开发者ID:RuiChen08,项目名称:dacapobench,代码行数:24,代码来源:CKJM.java

示例2: getDisplayList

import org.apache.bcel.util.ClassPath; //导入依赖的package包/类
public static VectorD getDisplayList(String sourceFileName, String className) {
VectorD displayList = (VectorD) table.get(sourceFileName);
String sourceFilePath;

if (displayList != null) return displayList;
if (sourceFileName.equals("UnknownFile.java")) return new VectorD();

BufferedReader r;
  
if (Debugger.DEMO) return getDemoList(sourceFileName);

ClassPath.ClassFile cf = Repository.lookupClassFile(className);

if (cf != null) sourceFilePath = getSourceFileName(cf, sourceFileName);
else sourceFilePath = getSourceFileName(className, sourceFileName);

r = getReader(sourceFilePath);
if (r == null) r = getReaderFN(sourceFileName, className); 
if (r == null) r = getReaderFN2(sourceFileName, className);
return(buildFileLines(r, sourceFileName));
   }
 
开发者ID:OmniscientDebugger,项目名称:LewisOmniscientDebugger,代码行数:22,代码来源:CodePane.java

示例3: ClassProvider

import org.apache.bcel.util.ClassPath; //导入依赖的package包/类
/**
 * Constructs a <code>ClassProvider</code> object.
 * 
 * @param bootClasspath - a path that will be prepended to the default 
 * class path.
 * @param classpath - a path that will be apppended to the default class 
 * path.
 * @param verbose - a verbose output.
 */
public ClassProvider(String bootClasspath, String classpath, boolean verbose) {
    StringBuffer pathString = new StringBuffer();

    // Append the given boot class path, if any.
    if (bootClasspath != null) {
        pathString.append(bootClasspath).append(File.pathSeparatorChar);
    }

    // Append the default class path.
    pathString.append(getSystemClassPath()).append(File.pathSeparatorChar);

    // Append the given class path, if any.
    if (classpath != null) {
        pathString.append(classpath).append(File.pathSeparatorChar);
    }

    if (verbose) {
        System.out.println("class.path: " + pathString.toString());
    }

    this.classpath = new ClassPath(pathString.toString());
    this.verbose = verbose;
    this.cache = new HashMap();
}
 
开发者ID:shannah,项目名称:cn1,代码行数:34,代码来源:ClassProvider.java

示例4: addSystemClasspathComponents

import org.apache.bcel.util.ClassPath; //导入依赖的package包/类
/**
 * Add components of system classpath.
 * @throws IOException
 */
public void addSystemClasspathComponents() throws IOException {
	String systemClassPath = ClassPath.getClassPath();
	StringTokenizer tok = new StringTokenizer(systemClassPath, File.pathSeparator);
	while (tok.hasMoreTokens()) {
		String entryName = tok.nextToken();
		try {
			urlClassPath.addURL(entryName);
		}
		catch (IOException e) {
			System.err.println("Warning: couldn't add path to classpath: " + entryName);
		}
	}
}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:18,代码来源:URLClassPathRepository.java

示例5: getSourceFileName

import org.apache.bcel.util.ClassPath; //导入依赖的package包/类
private static String getSourceFileName(ClassPath.ClassFile cf, String sourceFileName) {
    String path = cf.getPath();
    int dot = path.lastIndexOf("/");
    if (dot < 0)
	return Debugger.DIRECTORY + sourceFileName;
    else
	return path.substring(0, dot+1)+sourceFileName;	// /export/home/.../RegressionTests/Quick.java
}
 
开发者ID:OmniscientDebugger,项目名称:LewisOmniscientDebugger,代码行数:9,代码来源:CodePane.java

示例6: addAverroesLibraryClassFile

import org.apache.bcel.util.ClassPath; //导入依赖的package包/类
/**
 * Add the generated AverroesLibraryClass file to the Jar file.
 * 
 * @throws IOException
 * @throws URISyntaxException
 */
public void addAverroesLibraryClassFile() throws IOException, URISyntaxException {
	File dir = Paths.libraryClassesOutputDirectory();
	File placeholderJar = Paths.placeholderLibraryJarFile();
	File averroesLibraryClassJar = Paths.averroesLibraryClassJarFile();

	File file = FileUtils.listFiles(dir, new String[] { "class" }, true).stream()
			.filter(f -> relativize(dir, f).equals(Names.AVERROES_LIBRARY_CLASS_BC_SIG + ".class"))
			.collect(Collectors.toList()).get(0);
	String className = relativize(dir, file);

	// Add the class file to the separately crafted JAR file.
	if (file.isFile()) {
		add(dir, file);
	} else {
		throw new IllegalStateException("cannot find " + Names.AVERROES_LIBRARY_CLASS
				+ System.getProperty("line.separator") + "Invalid path given: " + fileName);
	}
	close();

	// Set BCEL's repository class path.
	SyntheticRepository rep = SyntheticRepository.getInstance(new ClassPath(averroesLibraryClassJar
			+ File.pathSeparator + placeholderJar + File.pathSeparator + Paths.organizedApplicationJarFile()));
	Repository.setRepository(rep);

	// Now add the class files (including ones from placeholder JAR) to the
	// BCEL repository.
	ClassParser parser = new ClassParser(averroesLibraryClassJar.getPath(), className);
	JavaClass cls = parser.parse();
	bcelClasses.add(cls);

	// Now we need to add all the BCEL classes (including ones from previous
	// placeholder JAR to force BCEL to load
	// those crafted files when it looks them up
	bcelClasses.forEach(c -> Repository.getRepository().storeClass(c));

	// Now verify all the generated class files
	verify();
}
 
开发者ID:karimhamdanali,项目名称:averroes,代码行数:45,代码来源:JarFile.java

示例7: loadClass

import org.apache.bcel.util.ClassPath; //导入依赖的package包/类
/** Loads the specified class as a BCEL class from the given class path */
public static JavaClass loadClass(ClassPath classPath, String className)
		throws IOException {
	InputStream inputStream = null;
	try {
		ClassFile classFile = classPath.getClassFile(className);
		inputStream = classFile.getInputStream();
		return new ClassParser(inputStream, className).parse();
	} finally {
		FileSystemUtils.close(inputStream);
	}
}
 
开发者ID:vimaier,项目名称:conqat,代码行数:13,代码来源:JavaElementUtils.java

示例8: getJavaClass

import org.apache.bcel.util.ClassPath; //导入依赖的package包/类
/**
 * Returns a JavaClass object which represents a class file with the given
 * name.
 * 
 * @param name - a fully qualified name of a class.
 * @return a JavaClass object which represents a class file with the given
 * name.
 * @throws ClassNotFoundException if a class file with the given name is
 * not found.
 */
public synchronized JavaClass getJavaClass(String name)
        throws ClassNotFoundException {
    try {
        // Try to get the class from the cache.
        JavaClass result = (JavaClass) cache.get(name);
        // If cache doesn't contain such a class load it from a class path.
        if (result == null) {
            // Get a file and parse its contents.
            ClassPath.ClassFile cf = classpath.getClassFile(name);
            InputStream is = cf.getInputStream();
            ClassParser parser = new ClassParser(is, cf.getPath());
            result = parser.parse();
            // Put the parsed class file into the cache.
            cache.put(name, result);

            if (verbose) {
                StringBuffer s = new StringBuffer();
                // If we use BCEL 5.1 or later one day we definitely
                // should remove the following if and replace 
                // cf.getPath() with cf.getBase()!
                if (!(is instanceof FileInputStream)) {
                    s.append("class.path:");
                }
                s.append(cf.getPath());
                System.out.println(name + " loaded from " + s);
            }
        } else {
            if (verbose) {
                System.out.println(name + " retrieved from a cache");
            }
        }
        return result;
    } catch (Exception e) {
        throw new ClassNotFoundException(name, e);
    }
}
 
开发者ID:shannah,项目名称:cn1,代码行数:47,代码来源:ClassProvider.java

示例9: lookupClassFile

import org.apache.bcel.util.ClassPath; //导入依赖的package包/类
/**
 * @return class file object for given Java class by looking on the
 *  system class path; returns null if the class file can't be
 *  found
 */
public static ClassPath.ClassFile lookupClassFile( String class_name ) {
    try {
        ClassPath path = _repository.getClassPath();
        if (path == null) {
            return null;
        }
        return path.getClassFile(class_name);
    } catch (IOException e) {
        return null;
    }
}
 
开发者ID:Hu6,项目名称:VestaClient,代码行数:17,代码来源:Repository.java

示例10: ClassScanner

import org.apache.bcel.util.ClassPath; //导入依赖的package包/类
/**
 * Initializes a new scanner.
 * 
 * @param paths
 *            the paths that should be scanned. A {@link Repository} is created with this paths. Must not be
 *            <code>null</code>.
 * @param filter
 *            the filter to use. Must not be <code>null</code>.
 */
public ClassScanner(final Collection<File> paths, final ClassFilter filter) {
	if (paths == null) {
		throw new IllegalArgumentException("paths must not be null");
	}
	if (filter == null) {
		throw new IllegalArgumentException("filter must not be null");
	}

	final ClassPath classPath = new ClassPath(StringUtil.joinIterable(new HashSet<File>(paths), ":"));
	this.repository = SyntheticRepository.getInstance(classPath);
	this.filter = filter;
}
 
开发者ID:DesignAndDeploy,项目名称:dnd,代码行数:22,代码来源:ClassScanner.java

示例11: lookupClassFile

import org.apache.bcel.util.ClassPath; //导入依赖的package包/类
/**
 * @return class file object for given Java class.
 */
public static ClassPath.ClassFile lookupClassFile(String class_name) {
    try {
        return ClassPath.SYSTEM_CLASS_PATH.getClassFile(class_name);
    } catch (IOException e) {
        return null;
    }
}
 
开发者ID:miuirussia,项目名称:KJBE,代码行数:11,代码来源:Repository.java

示例12: getClassPath

import org.apache.bcel.util.ClassPath; //导入依赖的package包/类
public ClassPath getClassPath() {
	return new ClassPath(urlClassPath.getClassPath());
}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:4,代码来源:URLClassPathRepository.java

示例13: getClassPath

import org.apache.bcel.util.ClassPath; //导入依赖的package包/类
/**
 * This returns the class path. As far as we can tell this is never called
 * from within BCEL.
 */
@Override
public ClassPath getClassPath() {
	return classPath;
}
 
开发者ID:vimaier,项目名称:conqat,代码行数:9,代码来源:CachingRepository.java

示例14: getClassPath

import org.apache.bcel.util.ClassPath; //导入依赖的package包/类
public ClassPath getClassPath() {
    return new ClassPath(urlClassPath.getClassPath());
}
 
开发者ID:ytus,项目名称:findbugs-all-the-bugs,代码行数:4,代码来源:URLClassPathRepository.java

示例15: getClassPath

import org.apache.bcel.util.ClassPath; //导入依赖的package包/类
public ClassPath getClassPath() {
    throw new UnsupportedOperationException();
}
 
开发者ID:ytus,项目名称:findbugs-all-the-bugs,代码行数:4,代码来源:AnalysisCacheToRepositoryAdapter.java


注:本文中的org.apache.bcel.util.ClassPath类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。