本文整理汇总了Java中javax.tools.StandardJavaFileManager.inferBinaryName方法的典型用法代码示例。如果您正苦于以下问题:Java StandardJavaFileManager.inferBinaryName方法的具体用法?Java StandardJavaFileManager.inferBinaryName怎么用?Java StandardJavaFileManager.inferBinaryName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.tools.StandardJavaFileManager
的用法示例。
在下文中一共展示了StandardJavaFileManager.inferBinaryName方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: analyzeModule
import javax.tools.StandardJavaFileManager; //导入方法依赖的package包/类
void analyzeModule(StandardJavaFileManager fm, String moduleName)
throws
IOException,
ConstantPoolException,
InvalidDescriptor {
JavaFileManager.Location location =
fm.getLocationForModule(StandardLocation.SYSTEM_MODULES, moduleName);
if (location == null)
throw new AssertionError("can't find module " + moduleName);
for (JavaFileObject file : fm.list(location, "", EnumSet.of(CLASS), true)) {
String className = fm.inferBinaryName(location, file);
int index = className.lastIndexOf('.');
String pckName = index == -1 ? "" : className.substring(0, index);
if (shouldAnalyzePackage(pckName)) {
analyzeClassFile(ClassFile.read(file.openInputStream()));
}
}
}
示例2: makeStub
import javax.tools.StandardJavaFileManager; //导入方法依赖的package包/类
void makeStub(StandardJavaFileManager fm, CompilationUnitTree tree) throws IOException {
CompilationUnitTree tree2 = new StubMaker().translate(tree);
CompilationUnitTree tree3 = new ImportCleaner(fm).removeRedundantImports(tree2);
String className = fm.inferBinaryName(StandardLocation.SOURCE_PATH, tree.getSourceFile());
JavaFileObject fo = fm.getJavaFileForOutput(StandardLocation.SOURCE_OUTPUT,
className, JavaFileObject.Kind.SOURCE, null);
// System.err.println("Writing " + className + " to " + fo.getName());
Writer out = fo.openWriter();
try {
new Pretty(out, true).printExpr((JCTree) tree3);
} finally {
out.close();
}
}