Java Code Examples for com.sun.tools.javac.util.Options#put()

The following examples show how to use com.sun.tools.javac.util.Options#put() . 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 File: TestInferBinaryName.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
JavaFileManager getFileManager(String classpathProperty,
                               boolean symFileKind,
                               boolean zipFileIndexKind)
        throws IOException {
    Context ctx = new Context();
    Options options = Options.instance(ctx);
    options.put("useOptimizedZip",
            Boolean.toString(zipFileIndexKind == USE_ZIP_FILE_INDEX));

    if (symFileKind == IGNORE_SYMBOL_FILE)
        options.put("ignore.symbol.file", "true");
    JavacFileManager fm = new JavacFileManager(ctx, false, null);
    List<File> path = getPath(System.getProperty(classpathProperty));
    fm.setLocation(CLASS_PATH, path);
    return fm;
}
 
Example 2
Source File: TestInferBinaryName.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
JavaFileManager getFileManager(String classpathProperty,
                               boolean symFileKind,
                               boolean zipFileIndexKind)
        throws IOException {
    Context ctx = new Context();
    Options options = Options.instance(ctx);
    options.put("useOptimizedZip",
            Boolean.toString(zipFileIndexKind == USE_ZIP_FILE_INDEX));

    if (symFileKind == IGNORE_SYMBOL_FILE)
        options.put("ignore.symbol.file", "true");
    JavacFileManager fm = new JavacFileManager(ctx, false, null);
    List<File> path = getPath(System.getProperty(classpathProperty));
    fm.setLocation(CLASS_PATH, path);
    return fm;
}
 
Example 3
Source File: TestInferBinaryName.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
JavaFileManager getFileManager(String classpathProperty,
                               boolean symFileKind,
                               boolean zipFileIndexKind)
        throws IOException {
    Context ctx = new Context();
    Options options = Options.instance(ctx);
    options.put("useOptimizedZip",
            Boolean.toString(zipFileIndexKind == USE_ZIP_FILE_INDEX));

    if (symFileKind == IGNORE_SYMBOL_FILE)
        options.put("ignore.symbol.file", "true");
    JavacFileManager fm = new JavacFileManager(ctx, false, null);
    List<File> path = getPath(System.getProperty(classpathProperty));
    fm.setLocation(CLASS_PATH, path);
    return fm;
}
 
Example 4
Source File: TestInferBinaryName.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
JavaFileManager getFileManager(String classpathProperty,
                               boolean symFileKind,
                               boolean zipFileIndexKind)
        throws IOException {
    Context ctx = new Context();
    Options options = Options.instance(ctx);
    options.put("useOptimizedZip",
            Boolean.toString(zipFileIndexKind == USE_ZIP_FILE_INDEX));

    if (symFileKind == IGNORE_SYMBOL_FILE)
        options.put("ignore.symbol.file", "true");
    JavacFileManager fm = new JavacFileManager(ctx, false, null);
    List<File> path = getPath(System.getProperty(classpathProperty));
    fm.setLocation(CLASS_PATH, path);
    return fm;
}
 
Example 5
Source File: TestInferBinaryName.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
JavaFileManager getFileManager(String classpathProperty,
                               boolean symFileKind,
                               boolean zipFileIndexKind)
        throws IOException {
    Context ctx = new Context();
    Options options = Options.instance(ctx);
    options.put("useOptimizedZip",
            Boolean.toString(zipFileIndexKind == USE_ZIP_FILE_INDEX));

    if (symFileKind == IGNORE_SYMBOL_FILE)
        options.put("ignore.symbol.file", "true");
    JavacFileManager fm = new JavacFileManager(ctx, false, null);
    List<File> path = getPath(System.getProperty(classpathProperty));
    fm.setLocation(CLASS_PATH, path);
    return fm;
}
 
Example 6
Source File: Test.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
JavacFileManager createFileManager(boolean useOptimizedZip, boolean useSymbolFile) {
    Context c = new Context();
    Options options = Options.instance(c);

    options.put("useOptimizedZip", Boolean.toString(useOptimizedZip));

    if (!useSymbolFile) {
        options.put("ignore.symbol.file", "true");
    }
    return new JavacFileManager(c, false, null);
}
 
Example 7
Source File: T6877206.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
JavacFileManager createFileManager(boolean useSymbolFile) {
    Context ctx = new Context();
    Options options = Options.instance(ctx);
    if (!useSymbolFile) {
        options.put("ignore.symbol.file", "true");
    }
    return new JavacFileManager(ctx, false, null);
}
 
Example 8
Source File: T6877206.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
JavacFileManager createFileManager(boolean useOptimizedZip, boolean useSymbolFile) {
    Context ctx = new Context();
    Options options = Options.instance(ctx);
    options.put("useOptimizedZip", Boolean.toString(useOptimizedZip));
    if (!useSymbolFile) {
        options.put("ignore.symbol.file", "true");
    }
    return new JavacFileManager(ctx, false, null);
}
 
Example 9
Source File: Test.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
JavacFileManager createFileManager(boolean useOptimizedZip, boolean useSymbolFile) {
    Context c = new Context();
    Options options = Options.instance(c);

    options.put("useOptimizedZip", Boolean.toString(useOptimizedZip));

    if (!useSymbolFile) {
        options.put("ignore.symbol.file", "true");
    }
    return new JavacFileManager(c, false, null);
}
 
Example 10
Source File: JavadocTaskImpl.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
private void initContext() {
    //initialize compiler's default locale
    context.put(Locale.class, locale);
    if (!addModules.isEmpty()) {
        String names = String.join(",", addModules);
        Options opts = Options.instance(context);
        String prev = opts.get(Option.ADD_MODULES);
        opts.put(Option.ADD_MODULES, (prev == null) ? names : prev + "," + names);
    }
}
 
Example 11
Source File: T6877206.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
JavacFileManager createFileManager(boolean useOptimizedZip, boolean useSymbolFile) {
    Context ctx = new Context();
    Options options = Options.instance(ctx);
    options.put("useOptimizedZip", Boolean.toString(useOptimizedZip));
    if (!useSymbolFile) {
        options.put("ignore.symbol.file", "true");
    }
    return new JavacFileManager(ctx, false, null);
}
 
Example 12
Source File: TestLog.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
static void test(boolean genEndPos) throws IOException {
    Context context = new Context();

    Options options = Options.instance(context);
    options.put("diags", "%b:%s/%o/%e:%_%t%m|%p%m");

    Log log = Log.instance(context);
    log.multipleErrors = true;

    JavacFileManager.preRegister(context);
    ParserFactory pfac = ParserFactory.instance(context);

    final String text =
          "public class Foo {\n"
        + "  public static void main(String[] args) {\n"
        + "    if (args.length == 0)\n"
        + "      System.out.println(\"no args\");\n"
        + "    else\n"
        + "      System.out.println(args.length + \" args\");\n"
        + "  }\n"
        + "}\n";
    JavaFileObject fo = new StringJavaFileObject("Foo", text);
    log.useSource(fo);

    CharSequence cs = fo.getCharContent(true);
    Parser parser = pfac.newParser(cs, false, genEndPos, false);
    JCTree.JCCompilationUnit tree = parser.parseCompilationUnit();
    log.setEndPosTable(fo, tree.endPositions);

    TreeScanner ts = new LogTester(log, tree.endPositions);
    ts.scan(tree);

    check(log.nerrors, 4, "errors");
    check(log.nwarnings, 4, "warnings");
}
 
Example 13
Source File: TestLog.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
static void test(boolean genEndPos) throws IOException {
    Context context = new Context();

    Options options = Options.instance(context);
    options.put("diags", "%b:%s/%o/%e:%_%t%m|%p%m");

    Log log = Log.instance(context);
    log.multipleErrors = true;

    JavacFileManager.preRegister(context);
    ParserFactory pfac = ParserFactory.instance(context);

    final String text =
          "public class Foo {\n"
        + "  public static void main(String[] args) {\n"
        + "    if (args.length == 0)\n"
        + "      System.out.println(\"no args\");\n"
        + "    else\n"
        + "      System.out.println(args.length + \" args\");\n"
        + "  }\n"
        + "}\n";
    JavaFileObject fo = new StringJavaFileObject("Foo", text);
    log.useSource(fo);

    CharSequence cs = fo.getCharContent(true);
    Parser parser = pfac.newParser(cs, false, genEndPos, false);
    JCTree.JCCompilationUnit tree = parser.parseCompilationUnit();
    log.setEndPosTable(fo, tree.endPositions);

    TreeScanner ts = new LogTester(log, tree.endPositions);
    ts.scan(tree);

    check(log.nerrors, 4, "errors");
    check(log.nwarnings, 4, "warnings");
}
 
Example 14
Source File: TestLog.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
static void test(boolean genEndPos) throws IOException {
    Context context = new Context();

    Options options = Options.instance(context);
    options.put("diags", "%b:%s/%o/%e:%_%t%m|%p%m");

    Log log = Log.instance(context);
    log.multipleErrors = true;

    JavacFileManager.preRegister(context);
    ParserFactory pfac = ParserFactory.instance(context);

    final String text =
          "public class Foo {\n"
        + "  public static void main(String[] args) {\n"
        + "    if (args.length == 0)\n"
        + "      System.out.println(\"no args\");\n"
        + "    else\n"
        + "      System.out.println(args.length + \" args\");\n"
        + "  }\n"
        + "}\n";
    JavaFileObject fo = new StringJavaFileObject("Foo", text);
    log.useSource(fo);

    CharSequence cs = fo.getCharContent(true);
    Parser parser = pfac.newParser(cs, false, genEndPos, false);
    JCTree.JCCompilationUnit tree = parser.parseCompilationUnit();
    log.setEndPosTable(fo, tree.endPositions);

    TreeScanner ts = new LogTester(log, tree.endPositions);
    ts.scan(tree);

    check(log.nerrors, 4, "errors");
    check(log.nwarnings, 4, "warnings");
}
 
Example 15
Source File: Test.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
JavacFileManager createFileManager(boolean useOptimizedZip, boolean useSymbolFile) {
    Context c = new Context();
    Options options = Options.instance(c);

    options.put("useOptimizedZip", Boolean.toString(useOptimizedZip));

    if (!useSymbolFile) {
        options.put("ignore.symbol.file", "true");
    }
    return new JavacFileManager(c, false, null);
}
 
Example 16
Source File: TestLog.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
static void test(boolean genEndPos) throws IOException {
    Context context = new Context();

    Options options = Options.instance(context);
    options.put("diags", "%b:%s/%o/%e:%_%t%m|%p%m");

    Log log = Log.instance(context);
    log.multipleErrors = true;

    JavacFileManager.preRegister(context);
    ParserFactory pfac = ParserFactory.instance(context);

    final String text =
          "public class Foo {\n"
        + "  public static void main(String[] args) {\n"
        + "    if (args.length == 0)\n"
        + "      System.out.println(\"no args\");\n"
        + "    else\n"
        + "      System.out.println(args.length + \" args\");\n"
        + "  }\n"
        + "}\n";
    JavaFileObject fo = new StringJavaFileObject("Foo", text);
    log.useSource(fo);

    CharSequence cs = fo.getCharContent(true);
    Parser parser = pfac.newParser(cs, false, genEndPos, false);
    JCTree.JCCompilationUnit tree = parser.parseCompilationUnit();
    log.setEndPosTable(fo, tree.endPositions);

    TreeScanner ts = new LogTester(log, tree.endPositions);
    ts.scan(tree);

    check(log.nerrors, 4, "errors");
    check(log.nwarnings, 4, "warnings");
}
 
Example 17
Source File: TestLog.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
static void test(boolean genEndPos) throws Exception {
    Context context = new Context();

    Options options = Options.instance(context);
    options.put("diags", "%b:%s/%o/%e:%_%t%m|%p%m");

    Log log = Log.instance(context);
    Factory diagnosticFactory = JCDiagnostic.Factory.instance(context);
    Field defaultErrorFlagsField =
            JCDiagnostic.Factory.class.getDeclaredField("defaultErrorFlags");

    defaultErrorFlagsField.setAccessible(true);

    Set<DiagnosticFlag> defaultErrorFlags =
            (Set<DiagnosticFlag>) defaultErrorFlagsField.get(diagnosticFactory);

    defaultErrorFlags.add(DiagnosticFlag.MULTIPLE);

    JavacFileManager.preRegister(context);
    ParserFactory pfac = ParserFactory.instance(context);

    final String text =
          "public class Foo {\n"
        + "  public static void main(String[] args) {\n"
        + "    if (args.length == 0)\n"
        + "      System.out.println(\"no args\");\n"
        + "    else\n"
        + "      System.out.println(args.length + \" args\");\n"
        + "  }\n"
        + "}\n";
    JavaFileObject fo = new StringJavaFileObject("Foo", text);
    log.useSource(fo);

    CharSequence cs = fo.getCharContent(true);
    Parser parser = pfac.newParser(cs, false, genEndPos, false);
    JCTree.JCCompilationUnit tree = parser.parseCompilationUnit();
    log.setEndPosTable(fo, tree.endPositions);

    TreeScanner ts = new LogTester(log, tree.endPositions);
    ts.scan(tree);

    check(log.nerrors, 4, "errors");
    check(log.nwarnings, 4, "warnings");
}
 
Example 18
Source File: T6838467.java    From hottub with GNU General Public License v2.0 4 votes vote down vote up
JavacFileManager createFileManager(boolean useOptimizedZip) {
    Context ctx = new Context();
    Options options = Options.instance(ctx);
    options.put("useOptimizedZip", Boolean.toString(useOptimizedZip));
    return new JavacFileManager(ctx, false, null);
}
 
Example 19
Source File: T6838467.java    From openjdk-8 with GNU General Public License v2.0 4 votes vote down vote up
JavacFileManager createFileManager(boolean useOptimizedZip) {
    Context ctx = new Context();
    Options options = Options.instance(ctx);
    options.put("useOptimizedZip", Boolean.toString(useOptimizedZip));
    return new JavacFileManager(ctx, false, null);
}
 
Example 20
Source File: T6838467.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 4 votes vote down vote up
JavacFileManager createFileManager(boolean useOptimizedZip) {
    Context ctx = new Context();
    Options options = Options.instance(ctx);
    options.put("useOptimizedZip", Boolean.toString(useOptimizedZip));
    return new JavacFileManager(ctx, false, null);
}