com.sun.tools.javac.util.Log.PrefixKind Java Examples

The following examples show how to use com.sun.tools.javac.util.Log.PrefixKind. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source Project: lua-for-android   Author: qtiuto   File: Option.java    License: BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
/**
 * Composes the initial synopsis of one of the forms for this option.
 * @param name the name of this form of the option
 * @param log the log used to localize the description of the arguments
 * @return  the synopsis
 */
private String helpSynopsis(String name, Log log) {
    StringBuilder sb = new StringBuilder();
    sb.append(name);
    if (argsNameKey == null) {
        if (choices != null) {
            if (!name.endsWith(":"))
                sb.append(" ");
            String sep = "{";
            for (String choice : choices) {
                sb.append(sep);
                sb.append(choice);
                sep = ",";
            }
            sb.append("}");
        }
    } else {
        if (!name.matches(".*[=:]$") && argKind != ArgKind.ADJACENT)
            sb.append(" ");
        sb.append(log.localize(PrefixKind.JAVAC, argsNameKey));
    }

    return sb.toString();
}
 
Example #2
Source Project: openjdk-jdk9   Author: AdoptOpenJDK   File: Option.java    License: GNU General Public License v2.0 6 votes vote down vote up
/**
 * Composes the initial synopsis of one of the forms for this option.
 * @param name the name of this form of the option
 * @param log the log used to localize the description of the arguments
 * @return  the synopsis
 */
private String helpSynopsis(String name, Log log) {
    StringBuilder sb = new StringBuilder();
    sb.append(name);
    if (argsNameKey == null) {
        if (choices != null) {
            if (!name.endsWith(":"))
                sb.append(" ");
            String sep = "{";
            for (String choice : choices) {
                sb.append(sep);
                sb.append(choice);
                sep = ",";
            }
            sb.append("}");
        }
    } else {
        if (!name.matches(".*[=:]$") && argKind != ArgKind.ADJACENT)
            sb.append(" ");
        sb.append(log.localize(PrefixKind.JAVAC, argsNameKey));
    }

    return sb.toString();
}
 
Example #3
Source Project: openjdk-jdk9   Author: AdoptOpenJDK   File: VerifyLintDescriptions.java    License: GNU General Public License v2.0 6 votes vote down vote up
public static void main(String... args) {
    ModuleLayer boot = ModuleLayer.boot();
    Module jdk_compiler = boot.findModule("jdk.compiler").get();
    ResourceBundle b = ResourceBundle.getBundle("com.sun.tools.javac.resources.javac",
                                                Locale.US,
                                                jdk_compiler);

    List<String> missing = new ArrayList<>();

    for (LintCategory lc : LintCategory.values()) {
        try {
            b.getString(PrefixKind.JAVAC.key("opt.Xlint.desc." + lc.option));
        } catch (MissingResourceException ex) {
            missing.add(lc.option);
        }
    }

    if (!missing.isEmpty()) {
        throw new UnsupportedOperationException("Lints that are missing description: " + missing);
    }
}
 
Example #4
Source Project: TencentKona-8   Author: Tencent   File: Main.java    License: GNU General Public License v2.0 5 votes vote down vote up
/** Report a usage error.
 */
void error(String key, Object... args) {
    if (apiMode) {
        String msg = log.localize(PrefixKind.JAVAC, key, args);
        throw new PropagatedException(new IllegalStateException(msg));
    }
    warning(key, args);
    log.printLines(PrefixKind.JAVAC, "msg.usage", ownName);
}
 
Example #5
Source Project: jdk8u60   Author: chenghanpeng   File: Main.java    License: GNU General Public License v2.0 5 votes vote down vote up
/** Report a usage error.
 */
void error(String key, Object... args) {
    if (apiMode) {
        String msg = log.localize(PrefixKind.JAVAC, key, args);
        throw new PropagatedException(new IllegalStateException(msg));
    }
    warning(key, args);
    log.printLines(PrefixKind.JAVAC, "msg.usage", ownName);
}
 
Example #6
Source Project: openjdk-jdk8u   Author: AdoptOpenJDK   File: Main.java    License: GNU General Public License v2.0 5 votes vote down vote up
/** Report a usage error.
 */
void error(String key, Object... args) {
    if (apiMode) {
        String msg = log.localize(PrefixKind.JAVAC, key, args);
        throw new PropagatedException(new IllegalStateException(msg));
    }
    warning(key, args);
    log.printLines(PrefixKind.JAVAC, "msg.usage", ownName);
}
 
Example #7
Source Project: lua-for-android   Author: qtiuto   File: Arguments.java    License: BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
/**
 * Initializes this Args instance with a set of command line args.
 * The args will be processed in conjunction with the full set of
 * command line options, including -help, -version etc.
 * The args may also contain class names and filenames.
 * Any errors during this call, and later during validate, will be reported
 * to the log.
 * @param ownName the name of this tool; used to prefix messages
 * @param args the args to be processed
 */
public void init(String ownName, String... args) {
    this.ownName = ownName;
    errorMode = ErrorMode.LOG;
    files = new LinkedHashSet<>();
    deferredFileManagerOptions = new LinkedHashMap<>();
    fileObjects = null;
    classNames = new LinkedHashSet<>();
    processArgs(List.from(args), Option.getJavaCompilerOptions(), cmdLineHelper, true, false);
    if (errors) {
        log.printLines(PrefixKind.JAVAC, "msg.usage", ownName);
    }
}
 
Example #8
Source Project: lua-for-android   Author: qtiuto   File: Main.java    License: BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
/** Report a usage error.
 */
void error(String key, Object... args) {
    if (apiMode) {
        String msg = log.localize(PrefixKind.JAVAC, key, args);
        throw new PropagatedException(new IllegalStateException(msg));
    }
    warning(key, args);
    log.printLines(PrefixKind.JAVAC, "msg.usage", ownName);
}
 
Example #9
Source Project: lua-for-android   Author: qtiuto   File: Main.java    License: BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
private boolean twoClassLoadersInUse(IllegalAccessError iae) {
    String msg = iae.getMessage();
    Pattern pattern = Pattern.compile("(?i)(?<=tried to access class )([a-z_$][a-z\\d_$]*\\.)*[a-z_$][a-z\\d_$]*");
    Matcher matcher = pattern.matcher(msg);
    if (matcher.find()) {
        try {
            String otherClassName = matcher.group(0);
            Class<?> otherClass = Class.forName(otherClassName);
            ClassLoader otherClassLoader = otherClass.getClassLoader();
            ClassLoader javacClassLoader = this.getClass().getClassLoader();
            if (javacClassLoader != otherClassLoader) {
                CodeSource otherClassCodeSource = otherClass.getProtectionDomain().getCodeSource();
                CodeSource javacCodeSource = this.getClass().getProtectionDomain().getCodeSource();
                if (otherClassCodeSource != null && javacCodeSource != null) {
                    log.printLines(PrefixKind.JAVAC, "err.two.class.loaders.2",
                            otherClassCodeSource.getLocation(),
                            javacCodeSource.getLocation());
                } else {
                    log.printLines(PrefixKind.JAVAC, "err.two.class.loaders.1");
                }
                return true;
            }
        } catch (Throwable t) {
            return false;
        }
    }
    return false;
}
 
Example #10
Source Project: openjdk-jdk8u-backup   Author: AdoptOpenJDK   File: Main.java    License: GNU General Public License v2.0 5 votes vote down vote up
/** Report a usage error.
 */
void error(String key, Object... args) {
    if (apiMode) {
        String msg = log.localize(PrefixKind.JAVAC, key, args);
        throw new PropagatedException(new IllegalStateException(msg));
    }
    warning(key, args);
    log.printLines(PrefixKind.JAVAC, "msg.usage", ownName);
}
 
Example #11
Source Project: openjdk-jdk9   Author: AdoptOpenJDK   File: Arguments.java    License: GNU General Public License v2.0 5 votes vote down vote up
/**
 * Initializes this Args instance with a set of command line args.
 * The args will be processed in conjunction with the full set of
 * command line options, including -help, -version etc.
 * The args may also contain class names and filenames.
 * Any errors during this call, and later during validate, will be reported
 * to the log.
 * @param ownName the name of this tool; used to prefix messages
 * @param args the args to be processed
 */
public void init(String ownName, String... args) {
    this.ownName = ownName;
    errorMode = ErrorMode.LOG;
    files = new LinkedHashSet<>();
    deferredFileManagerOptions = new LinkedHashMap<>();
    fileObjects = null;
    classNames = new LinkedHashSet<>();
    processArgs(List.from(args), Option.getJavaCompilerOptions(), cmdLineHelper, true, false);
    if (errors) {
        log.printLines(PrefixKind.JAVAC, "msg.usage", ownName);
    }
}
 
Example #12
Source Project: openjdk-jdk9   Author: AdoptOpenJDK   File: Main.java    License: GNU General Public License v2.0 5 votes vote down vote up
/** Report a usage error.
 */
void error(String key, Object... args) {
    if (apiMode) {
        String msg = log.localize(PrefixKind.JAVAC, key, args);
        throw new PropagatedException(new IllegalStateException(msg));
    }
    warning(key, args);
    log.printLines(PrefixKind.JAVAC, "msg.usage", ownName);
}
 
Example #13
Source Project: hottub   Author: dsrg-uoft   File: Main.java    License: GNU General Public License v2.0 5 votes vote down vote up
/** Report a usage error.
 */
void error(String key, Object... args) {
    if (apiMode) {
        String msg = log.localize(PrefixKind.JAVAC, key, args);
        throw new PropagatedException(new IllegalStateException(msg));
    }
    warning(key, args);
    log.printLines(PrefixKind.JAVAC, "msg.usage", ownName);
}
 
Example #14
Source Project: openjdk-8-source   Author: keerath   File: Main.java    License: GNU General Public License v2.0 5 votes vote down vote up
/** Report a usage error.
 */
void error(String key, Object... args) {
    if (apiMode) {
        String msg = log.localize(PrefixKind.JAVAC, key, args);
        throw new PropagatedException(new IllegalStateException(msg));
    }
    warning(key, args);
    log.printLines(PrefixKind.JAVAC, "msg.usage", ownName);
}
 
Example #15
Source Project: openjdk-8   Author: bpupadhyaya   File: Main.java    License: GNU General Public License v2.0 5 votes vote down vote up
/** Report a usage error.
 */
void error(String key, Object... args) {
    if (apiMode) {
        String msg = log.localize(PrefixKind.JAVAC, key, args);
        throw new PropagatedException(new IllegalStateException(msg));
    }
    warning(key, args);
    log.printLines(PrefixKind.JAVAC, "msg.usage", ownName);
}
 
Example #16
Source Project: TencentKona-8   Author: Tencent   File: Main.java    License: GNU General Public License v2.0 4 votes vote down vote up
/** Report a warning.
 */
void warning(String key, Object... args) {
    log.printRawLines(ownName + ": " + log.localize(PrefixKind.JAVAC, key, args));
}
 
Example #17
Source Project: TencentKona-8   Author: Tencent   File: Main.java    License: GNU General Public License v2.0 4 votes vote down vote up
/** 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));
}
 
Example #18
Source Project: TencentKona-8   Author: Tencent   File: Main.java    License: GNU General Public License v2.0 4 votes vote down vote up
/** Print a message reporting an input/output error.
 */
void ioMessage(Throwable ex) {
    log.printLines(PrefixKind.JAVAC, "msg.io");
    ex.printStackTrace(log.getWriter(WriterKind.NOTICE));
}
 
Example #19
Source Project: TencentKona-8   Author: Tencent   File: Main.java    License: GNU General Public License v2.0 4 votes vote down vote up
/** 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));
}
 
Example #20
Source Project: TencentKona-8   Author: Tencent   File: Main.java    License: GNU General Public License v2.0 4 votes vote down vote up
/** 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));
}
 
Example #21
Source Project: TencentKona-8   Author: Tencent   File: Main.java    License: GNU General Public License v2.0 4 votes vote down vote up
/** 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));
}
 
Example #22
Source Project: TencentKona-8   Author: Tencent   File: OptionHelper.java    License: GNU General Public License v2.0 4 votes vote down vote up
@Override
void error(String key, Object... args) {
    throw new IllegalArgumentException(log.localize(PrefixKind.JAVAC, key, args));
}
 
Example #23
Source Project: jdk8u60   Author: chenghanpeng   File: Main.java    License: GNU General Public License v2.0 4 votes vote down vote up
/** Report a warning.
 */
void warning(String key, Object... args) {
    log.printRawLines(ownName + ": " + log.localize(PrefixKind.JAVAC, key, args));
}
 
Example #24
Source Project: jdk8u60   Author: chenghanpeng   File: Main.java    License: GNU General Public License v2.0 4 votes vote down vote up
/** 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));
}
 
Example #25
Source Project: openjdk-8   Author: bpupadhyaya   File: Main.java    License: GNU General Public License v2.0 4 votes vote down vote up
/** 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));
}
 
Example #26
Source Project: jdk8u60   Author: chenghanpeng   File: Main.java    License: GNU General Public License v2.0 4 votes vote down vote up
/** 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));
}
 
Example #27
Source Project: jdk8u60   Author: chenghanpeng   File: Main.java    License: GNU General Public License v2.0 4 votes vote down vote up
/** 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));
}
 
Example #28
Source Project: jdk8u60   Author: chenghanpeng   File: Main.java    License: GNU General Public License v2.0 4 votes vote down vote up
/** 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));
}
 
Example #29
Source Project: jdk8u60   Author: chenghanpeng   File: OptionHelper.java    License: GNU General Public License v2.0 4 votes vote down vote up
@Override
void error(String key, Object... args) {
    throw new IllegalArgumentException(log.localize(PrefixKind.JAVAC, key, args));
}
 
Example #30
Source Project: openjdk-jdk8u   Author: AdoptOpenJDK   File: Main.java    License: GNU General Public License v2.0 4 votes vote down vote up
/** Report a warning.
 */
void warning(String key, Object... args) {
    log.printRawLines(ownName + ": " + log.localize(PrefixKind.JAVAC, key, args));
}