本文整理汇总了Java中com.sun.tools.javap.JavapTask类的典型用法代码示例。如果您正苦于以下问题:Java JavapTask类的具体用法?Java JavapTask怎么用?Java JavapTask使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
JavapTask类属于com.sun.tools.javap包,在下文中一共展示了JavapTask类的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: run
import com.sun.tools.javap.JavapTask; //导入依赖的package包/类
private void run() {
File classToCheck = new File(System.getProperty("test.classes"),
getClass().getSimpleName() + ".class");
DiagnosticCollector<JavaFileObject> dc =
new DiagnosticCollector<JavaFileObject>();
StringWriter sw = new StringWriter();
PrintWriter pw = new PrintWriter(sw);
JavaFileManager fm = JavapFileManager.create(dc, pw);
JavapTask t = new JavapTask(pw, fm, dc, null,
Arrays.asList(classToCheck.getPath()));
if (t.run() != 0)
throw new Error("javap failed unexpectedly");
List<Diagnostic<? extends JavaFileObject>> diags = dc.getDiagnostics();
for (Diagnostic<? extends JavaFileObject> d: diags) {
if (d.getKind() == Diagnostic.Kind.ERROR)
throw new AssertionError(d.getMessage(Locale.ENGLISH));
}
String lineSep = System.getProperty("line.separator");
String out = sw.toString().replace(lineSep, "\n");
if (!out.equals(expOutput)) {
throw new AssertionError("The output is not equal to the one expected");
}
}
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:26,代码来源:JavapTaskCtorFailWithNPE.java
示例2: javap
import com.sun.tools.javap.JavapTask; //导入依赖的package包/类
private String javap(List<String> args, List<String> classes) {
DiagnosticCollector<JavaFileObject> dc = new DiagnosticCollector<JavaFileObject>();
StringWriter sw = new StringWriter();
PrintWriter pw = new PrintWriter(sw);
JavaFileManager fm = JavapFileManager.create(dc, pw);
JavapTask t = new JavapTask(pw, fm, dc, args, classes);
if (t.run() != 0)
throw new Error("javap failed unexpectedly");
List<Diagnostic<? extends JavaFileObject>> diags = dc.getDiagnostics();
for (Diagnostic<? extends JavaFileObject> d: diags) {
if (d.getKind() == Diagnostic.Kind.ERROR)
throw new Error(d.getMessage(Locale.ENGLISH));
}
return sw.toString();
}
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:18,代码来源:T7190862.java
注:本文中的com.sun.tools.javap.JavapTask类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论