本文整理汇总了Java中com.sun.tools.javac.util.Log.WriterKind类的典型用法代码示例。如果您正苦于以下问题:Java WriterKind类的具体用法?Java WriterKind怎么用?Java WriterKind使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
WriterKind类属于com.sun.tools.javac.util.Log包,在下文中一共展示了WriterKind类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: init
import com.sun.tools.javac.util.Log.WriterKind; //导入依赖的package包/类
@Override
public void init(Context context, Log log, JavaCompiler compiler) {
super.init(context, log, compiler);
errWriter = log.getWriter(WriterKind.ERROR);
implicitDependencyExtractor =
new ImplicitDependencyExtractor(
dependencyModule.getUsedClasspath(),
dependencyModule.getImplicitDependenciesMap(),
dependencyModule.getPlatformJars());
checkingTreeScanner = context.get(CheckingTreeScanner.class);
if (checkingTreeScanner == null) {
Set<Path> platformJars = dependencyModule.getPlatformJars();
checkingTreeScanner =
new CheckingTreeScanner(dependencyModule, diagnostics, missingTargets, platformJars);
context.put(CheckingTreeScanner.class, checkingTreeScanner);
}
initTargetMap();
}
示例2: feMessage
import com.sun.tools.javac.util.Log.WriterKind; //导入依赖的package包/类
/** Print a message reporting a fatal error.
*/
void feMessage(Throwable ex) {
log.printRawLines(ex.getMessage());
if (ex.getCause() != null && options.isSet("dev")) {
ex.getCause().printStackTrace(log.getWriter(WriterKind.NOTICE));
}
}
示例3: showClass
import com.sun.tools.javac.util.Log.WriterKind; //导入依赖的package包/类
/** Display the location and checksum of a class. */
void showClass(String className) {
PrintWriter pw = log.getWriter(WriterKind.NOTICE);
pw.println("javac: show class: " + className);
URL url = getClass().getResource('/' + className.replace('.', '/') + ".class");
if (url == null)
pw.println(" class not found");
else {
pw.println(" " + url);
try {
final String algorithm = "MD5";
byte[] digest;
MessageDigest md = MessageDigest.getInstance(algorithm);
DigestInputStream in = new DigestInputStream(url.openStream(), md);
try {
byte[] buf = new byte[8192];
int n;
do { n = in.read(buf); } while (n > 0);
digest = md.digest();
} finally {
in.close();
}
StringBuilder sb = new StringBuilder();
for (byte b: digest)
sb.append(String.format("%02x", b));
pw.println(" " + algorithm + " checksum: " + sb);
} catch (Exception e) {
pw.println(" cannot compute digest: " + e);
}
}
}
示例4: printCount
import com.sun.tools.javac.util.Log.WriterKind; //导入依赖的package包/类
/** Print numbers of errors and warnings.
*/
public void printCount(String kind, int count) {
if (count != 0) {
String key;
if (count == 1)
key = "count." + kind;
else
key = "count." + kind + ".plural";
log.printLines(WriterKind.ERROR, key, String.valueOf(count));
log.flush(Log.WriterKind.ERROR);
}
}
示例5: feMessage
import com.sun.tools.javac.util.Log.WriterKind; //导入依赖的package包/类
/** Print a message reporting a fatal error.
*/
void feMessage(Throwable ex, Options options) {
log.printRawLines(ex.getMessage());
if (ex.getCause() != null && options.isSet("dev")) {
ex.getCause().printStackTrace(log.getWriter(WriterKind.NOTICE));
}
}
示例6: showClass
import com.sun.tools.javac.util.Log.WriterKind; //导入依赖的package包/类
/** Display the location and checksum of a class. */
void showClass(String className) {
PrintWriter pw = log.getWriter(WriterKind.NOTICE);
pw.println("javac: show class: " + className);
URL url = getClass().getResource('/' + className.replace('.', '/') + ".class");
if (url != null) {
pw.println(" " + url);
}
try (InputStream in = getClass().getResourceAsStream('/' + className.replace('.', '/') + ".class")) {
final String algorithm = "MD5";
byte[] digest;
MessageDigest md = MessageDigest.getInstance(algorithm);
try (DigestInputStream din = new DigestInputStream(in, md)) {
byte[] buf = new byte[8192];
int n;
do { n = din.read(buf); } while (n > 0);
digest = md.digest();
}
StringBuilder sb = new StringBuilder();
for (byte b: digest)
sb.append(String.format("%02x", b));
pw.println(" " + algorithm + " checksum: " + sb);
} catch (NoSuchAlgorithmException | IOException e) {
pw.println(" cannot compute digest: " + e);
}
}
示例7: help
import com.sun.tools.javac.util.Log.WriterKind; //导入依赖的package包/类
protected void help(Log log, String descr) {
String synopses = Arrays.stream(names)
.map(s -> helpSynopsis(s, log))
.collect(Collectors.joining(", "));
// If option synopses and description fit on a single line of reasonable length,
// display using COMPACT_FORMAT
if (synopses.length() < DEFAULT_SYNOPSIS_WIDTH
&& !descr.contains("\n")
&& (SMALL_INDENT.length() + DEFAULT_SYNOPSIS_WIDTH + 1 + descr.length() <= DEFAULT_MAX_LINE_LENGTH)) {
log.printRawLines(WriterKind.STDOUT, String.format(COMPACT_FORMAT, synopses, descr));
return;
}
// If option synopses fit on a single line of reasonable length, show that;
// otherwise, show 1 per line
if (synopses.length() <= DEFAULT_MAX_LINE_LENGTH) {
log.printRawLines(WriterKind.STDOUT, SMALL_INDENT + synopses);
} else {
for (String name: names) {
log.printRawLines(WriterKind.STDOUT, SMALL_INDENT + helpSynopsis(name, log));
}
}
// Finally, show the description
log.printRawLines(WriterKind.STDOUT, LARGE_INDENT + descr.replace("\n", "\n" + LARGE_INDENT));
}
示例8: bugMessage
import com.sun.tools.javac.util.Log.WriterKind; //导入依赖的package包/类
/** Print a message reporting an internal error.
*/
void bugMessage(Throwable ex) {
log.printLines(PrefixKind.JAVAC, "msg.bug", JavaCompiler.version());
ex.printStackTrace(log.getWriter(WriterKind.NOTICE));
}
示例9: ioMessage
import com.sun.tools.javac.util.Log.WriterKind; //导入依赖的package包/类
/** Print a message reporting an input/output error.
*/
void ioMessage(Throwable ex) {
log.printLines(PrefixKind.JAVAC, "msg.io");
ex.printStackTrace(log.getWriter(WriterKind.NOTICE));
}
示例10: resourceMessage
import com.sun.tools.javac.util.Log.WriterKind; //导入依赖的package包/类
/** Print a message reporting an out-of-resources error.
*/
void resourceMessage(Throwable ex) {
log.printLines(PrefixKind.JAVAC, "msg.resource");
ex.printStackTrace(log.getWriter(WriterKind.NOTICE));
}
示例11: apMessage
import com.sun.tools.javac.util.Log.WriterKind; //导入依赖的package包/类
/** Print a message reporting an uncaught exception from an
* annotation processor.
*/
void apMessage(AnnotationProcessingError ex) {
log.printLines(PrefixKind.JAVAC, "msg.proc.annotation.uncaught.exception");
ex.getCause().printStackTrace(log.getWriter(WriterKind.NOTICE));
}
示例12: pluginMessage
import com.sun.tools.javac.util.Log.WriterKind; //导入依赖的package包/类
/** Print a message reporting an uncaught exception from an
* annotation processor.
*/
void pluginMessage(Throwable ex) {
log.printLines(PrefixKind.JAVAC, "msg.plugin.uncaught.exception");
ex.printStackTrace(log.getWriter(WriterKind.NOTICE));
}
示例13: printNote
import com.sun.tools.javac.util.Log.WriterKind; //导入依赖的package包/类
protected void printNote(String lines) {
log.printRawLines(Log.WriterKind.NOTICE, lines);
}
示例14: handleReleaseOptions
import com.sun.tools.javac.util.Log.WriterKind; //导入依赖的package包/类
/**
* Handles the {@code --release} option.
*
* @param additionalOptions a predicate to handle additional options implied by the
* {@code --release} option. The predicate should return true if all the additional
* options were processed successfully.
* @return true if successful, false otherwise
*/
public boolean handleReleaseOptions(Predicate<Iterable<String>> additionalOptions) {
String platformString = options.get(Option.RELEASE);
checkOptionAllowed(platformString == null,
option -> error("err.release.bootclasspath.conflict", option.getPrimaryName()),
Option.BOOT_CLASS_PATH, Option.XBOOTCLASSPATH, Option.XBOOTCLASSPATH_APPEND,
Option.XBOOTCLASSPATH_PREPEND,
Option.ENDORSEDDIRS, Option.DJAVA_ENDORSED_DIRS,
Option.EXTDIRS, Option.DJAVA_EXT_DIRS,
Option.SOURCE, Option.TARGET,
Option.SYSTEM, Option.UPGRADE_MODULE_PATH);
if (platformString != null) {
PlatformDescription platformDescription = PlatformUtils.lookupPlatformDescription(platformString);
if (platformDescription == null) {
error("err.unsupported.release.version", platformString);
return false;
}
options.put(Option.SOURCE, platformDescription.getSourceVersion());
options.put(Option.TARGET, platformDescription.getTargetVersion());
context.put(PlatformDescription.class, platformDescription);
if (!additionalOptions.test(platformDescription.getAdditionalOptions()))
return false;
Collection<Path> platformCP = platformDescription.getPlatformPath();
if (platformCP != null) {
JavaFileManager fm = getFileManager();
if (!(fm instanceof StandardJavaFileManager)) {
error("err.release.not.standard.file.manager");
return false;
}
try {
StandardJavaFileManager sfm = (StandardJavaFileManager) fm;
if (Source.instance(context).allowModules()) {
sfm.handleOption("--system", Arrays.asList("none").iterator());
sfm.setLocationFromPaths(StandardLocation.UPGRADE_MODULE_PATH, platformCP);
} else {
sfm.setLocationFromPaths(StandardLocation.PLATFORM_CLASS_PATH, platformCP);
}
} catch (IOException ex) {
log.printLines(PrefixKind.JAVAC, "msg.io");
ex.printStackTrace(log.getWriter(WriterKind.NOTICE));
return false;
}
}
}
return true;
}
示例15: init
import com.sun.tools.javac.util.Log.WriterKind; //导入依赖的package包/类
@Override public void init(JavacTask task, String... args) {
Context context = ((BasicJavacTask) task).getContext();
Log log = Log.instance(context);
task.addTaskListener(new TaskListenerImpl(log.getWriter(WriterKind.NOTICE)));
}