本文整理汇总了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();
}
示例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));
}
示例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();
}
示例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);
}
}
}
示例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
}
示例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();
}
示例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);
}
}
示例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);
}
}
示例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;
}
}
示例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;
}
示例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;
}
}
示例12: getClassPath
import org.apache.bcel.util.ClassPath; //导入依赖的package包/类
public ClassPath getClassPath() {
return new ClassPath(urlClassPath.getClassPath());
}
示例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;
}
示例14: getClassPath
import org.apache.bcel.util.ClassPath; //导入依赖的package包/类
public ClassPath getClassPath() {
return new ClassPath(urlClassPath.getClassPath());
}
示例15: getClassPath
import org.apache.bcel.util.ClassPath; //导入依赖的package包/类
public ClassPath getClassPath() {
throw new UnsupportedOperationException();
}