本文整理汇总了Java中org.apache.bcel.Repository.setRepository方法的典型用法代码示例。如果您正苦于以下问题:Java Repository.setRepository方法的具体用法?Java Repository.setRepository怎么用?Java Repository.setRepository使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.bcel.Repository
的用法示例。
在下文中一共展示了Repository.setRepository方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: clearRepository
import org.apache.bcel.Repository; //导入方法依赖的package包/类
/**
* Clear the Repository and update it to reflect the classpath
* specified by the current project.
*/
private void clearRepository() {
// Purge repository of previous contents
Repository.clearCache();
// Clear InnerClassAccessMap cache.
InnerClassAccessMap.instance().clearCache();
// Create a URLClassPathRepository based on the current project,
// and make it current.
URLClassPathRepository repository = new URLClassPathRepository();
Repository.setRepository(repository);
}
示例2: addAverroesLibraryClassFile
import org.apache.bcel.Repository; //导入方法依赖的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();
}
示例3: transform
import org.apache.bcel.Repository; //导入方法依赖的package包/类
public byte[] transform(final byte[] original) {
if(repository == null) {
return doTransform(original);
} else {
synchronized(repositoryLock) {
org.apache.bcel.util.Repository old = Repository.getRepository();
Repository.setRepository(repository);
try {
return doTransform(original);
} finally {
Repository.setRepository(old);
}
}
}
}
示例4: setClassLoader
import org.apache.bcel.Repository; //导入方法依赖的package包/类
/**
* Stores the class loader and makes it the Repository's class loader.
* @param aClassLoader class loader to resolve classes with.
*/
public void setClassLoader(ClassLoader aClassLoader)
{
Repository.setRepository(new ClassLoaderRepository(aClassLoader));
mClassLoader = aClassLoader;
}
示例5: clearRepository
import org.apache.bcel.Repository; //导入方法依赖的package包/类
@Override
public void clearRepository() {
// Set the backing store for the BCEL Repository to
// be the AnalysisCache.
Repository.setRepository(new AnalysisCacheToRepositoryAdapter());
}
示例6: clearRepository
import org.apache.bcel.Repository; //导入方法依赖的package包/类
/**
* Clear the BCEL Repository in preparation for analysis.
*/
public void clearRepository() {
// Set the backing store for the BCEL Repository to
// be the AnalysisCache.
Repository.setRepository(new AnalysisCacheToRepositoryAdapter());
}