当前位置: 首页>>代码示例>>Java>>正文


Java AnnotationProcessorFactory类代码示例

本文整理汇总了Java中com.sun.mirror.apt.AnnotationProcessorFactory的典型用法代码示例。如果您正苦于以下问题:Java AnnotationProcessorFactory类的具体用法?Java AnnotationProcessorFactory怎么用?Java AnnotationProcessorFactory使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


AnnotationProcessorFactory类属于com.sun.mirror.apt包,在下文中一共展示了AnnotationProcessorFactory类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: processing

import com.sun.mirror.apt.AnnotationProcessorFactory; //导入依赖的package包/类
private static int processing(AnnotationProcessorFactory factory,
                              PrintWriter out,
                              String... args) {
    if (out == null)
        out = new PrintWriter(System.err, true);
    com.sun.tools.apt.main.Main compiler =
        new com.sun.tools.apt.main.Main("apt", out);
    return compiler.compile(args, factory);
}
 
开发者ID:unktomi,项目名称:form-follows-function,代码行数:10,代码来源:Main.java

示例2: main

import com.sun.mirror.apt.AnnotationProcessorFactory; //导入依赖的package包/类
public static int main(String[] args, File episode) throws Exception {
    ClassLoader cl = Runner.class.getClassLoader();
    Class apt = cl.loadClass("com.sun.tools.apt.Main");
    Method processMethod = apt.getMethod("process",AnnotationProcessorFactory.class, String[].class);

    com.sun.tools.internal.jxc.apt.SchemaGenerator r = new com.sun.tools.internal.jxc.apt.SchemaGenerator();
    if(episode!=null)
        r.setEpisodeFile(episode);
    return (Integer) processMethod.invoke(null, r, args);
}
 
开发者ID:alexkasko,项目名称:openjdk-icedtea7,代码行数:11,代码来源:SchemaGenerator.java

示例3: compile

import com.sun.mirror.apt.AnnotationProcessorFactory; //导入依赖的package包/类
/** Main method: compile a list of files, return all compiled classes
 *  @param filenames     The names of all files to be compiled.
 */
public List<ClassSymbol> compile(List<String> filenames,
                                 Map<String, String> origOptions,
                                 ClassLoader aptCL,
                                 AnnotationProcessorFactory providedFactory,
                                 java.util.Set<Class<? extends AnnotationProcessorFactory> > productiveFactories,
                                 java.util.Set<java.io.File> aggregateGenFiles)
    throws Throwable {
    // as a JavaCompiler can only be used once, throw an exception if
    // it has been used before.
    assert !hasBeenUsed : "attempt to reuse JavaCompiler";
    hasBeenUsed = true;

    this.aggregateGenFiles = aggregateGenFiles;

    long msec = System.currentTimeMillis();

    ListBuffer<ClassSymbol> classes = new ListBuffer<ClassSymbol>();
    try {
        //parse all files
        ListBuffer<JCCompilationUnit> trees = new ListBuffer<JCCompilationUnit>();
        for (List<String> l = filenames; l.nonEmpty(); l = l.tail) {
            if (classesAsDecls) {
                if (! l.head.endsWith(".java") ) { // process as class file
                    ClassSymbol cs = reader.enterClass(names.fromString(l.head));
                    try {
                        cs.complete();
                    } catch(Symbol.CompletionFailure cf) {
                        bark.aptError("CantFindClass", l);
                        continue;
                    }

                    classes.append(cs); // add to list of classes
                    continue;
                }
            }
            trees.append(parse(l.head));
        }

        //enter symbols for all files
        List<JCCompilationUnit> roots = trees.toList();

        if (errorCount() == 0) {
            boolean prev = bark.setDiagnosticsIgnored(true);
            try {
                enter.main(roots);
            }
            finally {
                bark.setDiagnosticsIgnored(prev);
            }
        }

        if (errorCount() == 0) {
            apt.main(roots,
                     classes,
                     origOptions, aptCL,
                     providedFactory,
                     productiveFactories);
            genSourceFileNames.addAll(apt.getSourceFileNames());
            genClassFileNames.addAll(apt.getClassFileNames());
        }

    } catch (Abort ex) {
    }

    if (verbose)
        printVerbose("total", Long.toString(System.currentTimeMillis() - msec));

    chk.reportDeferredDiagnostics();

    printCount("error", errorCount());
    printCount("warn", warningCount());

    return classes.toList();
}
 
开发者ID:unktomi,项目名称:form-follows-function,代码行数:78,代码来源:JavaCompiler.java

示例4: main

import com.sun.mirror.apt.AnnotationProcessorFactory; //导入依赖的package包/类
public static void main(String argv[]) {
    AnnotationProcessorFactory factory = new StaticApf();
    System.exit(com.sun.tools.apt.Main.process(factory, argv));
}
 
开发者ID:unktomi,项目名称:form-follows-function,代码行数:5,代码来源:WrappedStaticApf.java

示例5: compile

import com.sun.mirror.apt.AnnotationProcessorFactory; //导入依赖的package包/类
/** Main method: compile a list of files, return all compiled classes
 *  @param filenames     The names of all files to be compiled.
 */
public List<ClassSymbol> compile(List<String> filenames,
                                 Map<String, String> origOptions,
                                 ClassLoader aptCL,
                                 AnnotationProcessorFactory providedFactory,
                                 java.util.Set<Class<? extends AnnotationProcessorFactory> > productiveFactories,
                                 java.util.Set<java.io.File> aggregateGenFiles)
    throws Throwable {
    // as a JavaCompiler can only be used once, throw an exception if
    // it has been used before.
    assert !hasBeenUsed : "attempt to reuse JavaCompiler";
    hasBeenUsed = true;

    this.aggregateGenFiles = aggregateGenFiles;

    long msec = System.currentTimeMillis();

    ListBuffer<ClassSymbol> classes = new ListBuffer<ClassSymbol>();
    try {
        JavacFileManager fm = (JavacFileManager)fileManager;
        //parse all files
        ListBuffer<JCCompilationUnit> trees = new ListBuffer<JCCompilationUnit>();
        for (List<String> l = filenames; l.nonEmpty(); l = l.tail) {
            if (classesAsDecls) {
                if (! l.head.endsWith(".java") ) { // process as class file
                    ClassSymbol cs = reader.enterClass(names.fromString(l.head));
                    try {
                        cs.complete();
                    } catch(Symbol.CompletionFailure cf) {
                        bark.aptError("CantFindClass", l);
                        continue;
                    }

                    classes.append(cs); // add to list of classes
                    continue;
                }
            }
            JavaFileObject fo = fm.getJavaFileObjectsFromStrings(List.of(l.head)).iterator().next();
            trees.append(parse(fo));
        }

        //enter symbols for all files
        List<JCCompilationUnit> roots = trees.toList();

        if (errorCount() == 0) {
            boolean prev = bark.setDiagnosticsIgnored(true);
            try {
                enter.main(roots);
            }
            finally {
                bark.setDiagnosticsIgnored(prev);
            }
        }

        if (errorCount() == 0) {
            apt.main(roots,
                     classes,
                     origOptions, aptCL,
                     providedFactory,
                     productiveFactories);
            genSourceFileNames.addAll(apt.getSourceFileNames());
            genClassFileNames.addAll(apt.getClassFileNames());
        }

    } catch (Abort ex) {
    }

    if (verbose)
        log.printVerbose("total", Long.toString(System.currentTimeMillis() - msec));

    chk.reportDeferredDiagnostics();

    printCount("error", errorCount());
    printCount("warn", warningCount());

    return classes.toList();
}
 
开发者ID:aducode,项目名称:openjdk-source-code-learn,代码行数:80,代码来源:AptJavaCompiler.java

示例6: compile

import com.sun.mirror.apt.AnnotationProcessorFactory; //导入依赖的package包/类
/** Main method: compile a list of files, return all compiled classes
 *  @param filenames     The names of all files to be compiled.
 */
public List<ClassSymbol> compile(List<String> filenames,
                                 Map<String, String> origOptions,
                                 ClassLoader aptCL,
                                 AnnotationProcessorFactory providedFactory,
                                 java.util.Set<Class<? extends AnnotationProcessorFactory> > productiveFactories,
                                 java.util.Set<java.io.File> aggregateGenFiles)
    throws Throwable {
    // as a JavaCompiler can only be used once, throw an exception if
    // it has been used before.
    assert !hasBeenUsed : "attempt to reuse JavaCompiler";
    hasBeenUsed = true;

    this.aggregateGenFiles = aggregateGenFiles;

    long msec = System.currentTimeMillis();

    ListBuffer<ClassSymbol> classes = new ListBuffer<ClassSymbol>();
    try {
        JavacFileManager fm = (JavacFileManager)fileManager;
        //parse all files
        ListBuffer<JCCompilationUnit> trees = new ListBuffer<JCCompilationUnit>();
        for (List<String> l = filenames; l.nonEmpty(); l = l.tail) {
            if (classesAsDecls) {
                if (! l.head.endsWith(".java") ) { // process as class file
                    ClassSymbol cs = reader.enterClass(names.fromString(l.head));
                    try {
                        cs.complete();
                    } catch(Symbol.CompletionFailure cf) {
                        bark.aptError("CantFindClass", l);
                        continue;
                    }

                    classes.append(cs); // add to list of classes
                    continue;
                }
            }
            JavaFileObject fo = fm.getJavaFileObjectsFromStrings(List.of(l.head)).iterator().next();
            trees.append(parse(fo));
        }

        //enter symbols for all files
        List<JCCompilationUnit> roots = trees.toList();

        if (errorCount() == 0) {
            boolean prev = bark.setDiagnosticsIgnored(true);
            try {
                enter.main(roots);
            }
            finally {
                bark.setDiagnosticsIgnored(prev);
            }
        }

        if (errorCount() == 0) {
            apt.main(roots,
                     classes,
                     origOptions, aptCL,
                     providedFactory,
                     productiveFactories);
            genSourceFileNames.addAll(apt.getSourceFileNames());
            genClassFileNames.addAll(apt.getClassFileNames());
        }

    } catch (Abort ex) {
    }

    if (verbose)
        printVerbose("total", Long.toString(System.currentTimeMillis() - msec));

    chk.reportDeferredDiagnostics();

    printCount("error", errorCount());
    printCount("warn", warningCount());

    return classes.toList();
}
 
开发者ID:lucasicf,项目名称:metricgenerator-jdk-compiler,代码行数:80,代码来源:JavaCompiler.java

示例7: process

import com.sun.mirror.apt.AnnotationProcessorFactory; //导入依赖的package包/类
/** Programmatic interface.  If any argument
 * is <tt>null</tt>, a <tt>NullPointerException</tt> is thrown.
 * The &quot;<tt>-factory</tt>&quot; and &quot;<tt>-factorypath</tt>&quot;
 * command line parameters are ignored by this entry point.
 *
 * @param factory The annotation processor factory to use
 * @param args   The command line parameters.
 * @param out    Where the tool's output is directed.
 */
public static int process(AnnotationProcessorFactory factory, PrintWriter out,
                          String... args) {
    if (out == null)
        throw new NullPointerException("Parameter out cannot be null.");
    if (factory == null)
        throw new NullPointerException("Parameter factory cannot be null");
    return processing(factory, out, args);
}
 
开发者ID:unktomi,项目名称:form-follows-function,代码行数:18,代码来源:Main.java


注:本文中的com.sun.mirror.apt.AnnotationProcessorFactory类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。