com.sun.tools.javac.util.ClientCodeException Java Examples

The following examples show how to use com.sun.tools.javac.util.ClientCodeException. 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: APTUtils.java    From netbeans with Apache License 2.0 6 votes vote down vote up
@Override
@Messages("ERR_ProcessorException=Annotation processor {0} failed with an exception: {1}")
public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) {
    if (!valid) {
        return false;
    }
    try {
        return delegate.process(annotations, roundEnv);
    } catch (ClientCodeException | ThreadDeath | Abort err) {
        valid = false;
        throw err;
    } catch (Throwable t) {
        valid = false;
        Element el = roundEnv.getRootElements().isEmpty() ? null : roundEnv.getRootElements().iterator().next();
        StringBuilder exception = new StringBuilder();
        exception.append(t.getMessage()).append("\n");
        for (StackTraceElement ste : t.getStackTrace()) {
            exception.append(ste).append("\n");
        }
        processingEnv.getMessager().printMessage(Diagnostic.Kind.NOTE, Bundle.ERR_ProcessorException(delegate.getClass().getName(), exception.toString()), el);
        return false;
    }
}
 
Example #2
Source File: JavadocTaskImpl.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
public Boolean call() {
    if (!used.getAndSet(true)) {
        initContext();
        Start jdoc = new Start(context);
        try {
            return jdoc.begin(docletClass, options, fileObjects);
        } catch (ClientCodeException e) {
            throw new RuntimeException(e.getCause());
        }
    } else {
        throw new IllegalStateException("multiple calls to method 'call'");
    }
}
 
Example #3
Source File: JavacProcessingEnvironment.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
ProcessorState(Processor p, Log log, Source source, ProcessingEnvironment env) {
    processor = p;
    contributed = false;

    try {
        processor.init(env);

        checkSourceVersionCompatibility(source, log);

        supportedAnnotationPatterns = new ArrayList<Pattern>();
        for (String importString : processor.getSupportedAnnotationTypes()) {
            supportedAnnotationPatterns.add(importStringToPattern(importString,
                                                                  processor,
                                                                  log));
        }

        supportedOptionNames = new ArrayList<String>();
        for (String optionName : processor.getSupportedOptions() ) {
            if (checkOptionName(optionName, log))
                supportedOptionNames.add(optionName);
        }

    } catch (ClientCodeException e) {
        throw e;
    } catch (Throwable t) {
        throw new AnnotationProcessingError(t);
    }
}
 
Example #4
Source File: JavadocTaskImpl.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
public Boolean call() {
    if (!used.getAndSet(true)) {
        initContext();
        Start jdoc = new Start(context);
        try {
            return jdoc.begin(docletClass, options, fileObjects);
        } catch (ClientCodeException e) {
            throw new RuntimeException(e.getCause());
        }
    } else {
        throw new IllegalStateException("multiple calls to method 'call'");
    }
}
 
Example #5
Source File: JavacProcessingEnvironment.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
ProcessorState(Processor p, Log log, Source source, ProcessingEnvironment env) {
    processor = p;
    contributed = false;

    try {
        processor.init(env);

        checkSourceVersionCompatibility(source, log);

        supportedAnnotationPatterns = new ArrayList<Pattern>();
        for (String importString : processor.getSupportedAnnotationTypes()) {
            supportedAnnotationPatterns.add(importStringToPattern(importString,
                                                                  processor,
                                                                  log));
        }

        supportedOptionNames = new ArrayList<String>();
        for (String optionName : processor.getSupportedOptions() ) {
            if (checkOptionName(optionName, log))
                supportedOptionNames.add(optionName);
        }

    } catch (ClientCodeException e) {
        throw e;
    } catch (Throwable t) {
        throw new AnnotationProcessingError(t);
    }
}
 
Example #6
Source File: JavadocTaskImpl.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
public Boolean call() {
    if (!used.getAndSet(true)) {
        initContext();
        Start jdoc = new Start(context);
        try {
            return jdoc.begin(docletClass, options, fileObjects);
        } catch (ClientCodeException e) {
            throw new RuntimeException(e.getCause());
        }
    } else {
        throw new IllegalStateException("multiple calls to method 'call'");
    }
}
 
Example #7
Source File: JavacProcessingEnvironment.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
ProcessorState(Processor p, Log log, Source source, ProcessingEnvironment env) {
    processor = p;
    contributed = false;

    try {
        processor.init(env);

        checkSourceVersionCompatibility(source, log);

        supportedAnnotationPatterns = new ArrayList<Pattern>();
        for (String importString : processor.getSupportedAnnotationTypes()) {
            supportedAnnotationPatterns.add(importStringToPattern(importString,
                                                                  processor,
                                                                  log));
        }

        supportedOptionNames = new ArrayList<String>();
        for (String optionName : processor.getSupportedOptions() ) {
            if (checkOptionName(optionName, log))
                supportedOptionNames.add(optionName);
        }

    } catch (ClientCodeException e) {
        throw e;
    } catch (Throwable t) {
        throw new AnnotationProcessingError(t);
    }
}
 
Example #8
Source File: JavadocTaskImpl.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
public Boolean call() {
    if (!used.getAndSet(true)) {
        initContext();
        Start jdoc = new Start(context);
        try {
            return jdoc.begin(docletClass, options, fileObjects);
        } catch (ClientCodeException e) {
            throw new RuntimeException(e.getCause());
        }
    } else {
        throw new IllegalStateException("multiple calls to method 'call'");
    }
}
 
Example #9
Source File: JavadocTaskImpl.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
public Boolean call() {
    if (!used.getAndSet(true)) {
        initContext();
        Start jdoc = new Start(context);
        try {
            return jdoc.begin(docletClass, options, fileObjects);
        } catch (ClientCodeException e) {
            throw new RuntimeException(e.getCause());
        }
    } else {
        throw new IllegalStateException("multiple calls to method 'call'");
    }
}
 
Example #10
Source File: JavacProcessingEnvironment.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
ProcessorState(Processor p, Log log, Source source, boolean allowModules, ProcessingEnvironment env) {
    processor = p;
    contributed = false;

    try {
        processor.init(env);

        checkSourceVersionCompatibility(source, log);

        supportedAnnotationPatterns = new ArrayList<>();
        for (String importString : processor.getSupportedAnnotationTypes()) {
            supportedAnnotationPatterns.add(importStringToPattern(allowModules,
                                                                  importString,
                                                                  processor,
                                                                  log));
        }

        supportedOptionNames = new ArrayList<>();
        for (String optionName : processor.getSupportedOptions() ) {
            if (checkOptionName(optionName, log))
                supportedOptionNames.add(optionName);
        }

    } catch (ClientCodeException e) {
        throw e;
    } catch (Throwable t) {
        throw new AnnotationProcessingError(t);
    }
}
 
Example #11
Source File: JavacProcessingEnvironment.java    From javaide with GNU General Public License v3.0 5 votes vote down vote up
ProcessorState(Processor p, Log log, Source source, ProcessingEnvironment env) {
    processor = p;
    contributed = false;

    try {
        processor.init(env);

        checkSourceVersionCompatibility(source, log);

        supportedAnnotationPatterns = new ArrayList<Pattern>();
        for (String importString : processor.getSupportedAnnotationTypes()) {
            supportedAnnotationPatterns.add(importStringToPattern(importString,
                                                                  processor,
                                                                  log));
        }

        supportedOptionNames = new ArrayList<String>();
        for (String optionName : processor.getSupportedOptions() ) {
            if (checkOptionName(optionName, log))
                supportedOptionNames.add(optionName);
        }

    } catch (ClientCodeException e) {
        throw e;
    } catch (Throwable t) {
        throw new AnnotationProcessingError(t);
    }
}
 
Example #12
Source File: JavacProcessingEnvironment.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
ProcessorState(Processor p, Log log, Source source, ProcessingEnvironment env) {
    processor = p;
    contributed = false;

    try {
        processor.init(env);

        checkSourceVersionCompatibility(source, log);

        supportedAnnotationPatterns = new ArrayList<Pattern>();
        for (String importString : processor.getSupportedAnnotationTypes()) {
            supportedAnnotationPatterns.add(importStringToPattern(importString,
                                                                  processor,
                                                                  log));
        }

        supportedOptionNames = new ArrayList<String>();
        for (String optionName : processor.getSupportedOptions() ) {
            if (checkOptionName(optionName, log))
                supportedOptionNames.add(optionName);
        }

    } catch (ClientCodeException e) {
        throw e;
    } catch (Throwable t) {
        throw new AnnotationProcessingError(t);
    }
}
 
Example #13
Source File: JavadocTaskImpl.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
public Boolean call() {
    if (!used.getAndSet(true)) {
        initContext();
        Start jdoc = new Start(context);
        try {
            return jdoc.begin(docletClass, options, fileObjects);
        } catch (ClientCodeException e) {
            throw new RuntimeException(e.getCause());
        }
    } else {
        throw new IllegalStateException("multiple calls to method 'call'");
    }
}
 
Example #14
Source File: JavacProcessingEnvironment.java    From lua-for-android with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
ProcessorState(Processor p, Log log, Source source, boolean allowModules, ProcessingEnvironment env) {
    processor = p;
    contributed = false;

    try {
        processor.init(env);

        checkSourceVersionCompatibility(source, log);

        supportedAnnotationPatterns = new ArrayList<>();
        for (String importString : processor.getSupportedAnnotationTypes()) {
            supportedAnnotationPatterns.add(importStringToPattern(allowModules,
                                                                  importString,
                                                                  processor,
                                                                  log));
        }

        supportedOptionNames = new ArrayList<>();
        for (String optionName : processor.getSupportedOptions() ) {
            if (checkOptionName(optionName, log))
                supportedOptionNames.add(optionName);
        }

    } catch (ClientCodeException e) {
        throw e;
    } catch (Throwable t) {
        throw new AnnotationProcessingError(t);
    }
}
 
Example #15
Source File: JavacProcessingEnvironment.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
ProcessorState(Processor p, Log log, Source source, ProcessingEnvironment env) {
    processor = p;
    contributed = false;

    try {
        processor.init(env);

        checkSourceVersionCompatibility(source, log);

        supportedAnnotationPatterns = new ArrayList<Pattern>();
        for (String importString : processor.getSupportedAnnotationTypes()) {
            supportedAnnotationPatterns.add(importStringToPattern(importString,
                                                                  processor,
                                                                  log));
        }

        supportedOptionNames = new ArrayList<String>();
        for (String optionName : processor.getSupportedOptions() ) {
            if (checkOptionName(optionName, log))
                supportedOptionNames.add(optionName);
        }

    } catch (ClientCodeException e) {
        throw e;
    } catch (Throwable t) {
        throw new AnnotationProcessingError(t);
    }
}
 
Example #16
Source File: JavadocTaskImpl.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
public Boolean call() {
    if (!used.getAndSet(true)) {
        initContext();
        Start jdoc = new Start(context);
        try {
            return jdoc.begin(docletClass, options, fileObjects);
        } catch (ClientCodeException e) {
            throw new RuntimeException(e.getCause());
        }
    } else {
        throw new IllegalStateException("multiple calls to method 'call'");
    }
}
 
Example #17
Source File: JavacProcessingEnvironment.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
ProcessorState(Processor p, Log log, Source source, ProcessingEnvironment env) {
    processor = p;
    contributed = false;

    try {
        processor.init(env);

        checkSourceVersionCompatibility(source, log);

        supportedAnnotationPatterns = new ArrayList<Pattern>();
        for (String importString : processor.getSupportedAnnotationTypes()) {
            supportedAnnotationPatterns.add(importStringToPattern(importString,
                                                                  processor,
                                                                  log));
        }

        supportedOptionNames = new ArrayList<String>();
        for (String optionName : processor.getSupportedOptions() ) {
            if (checkOptionName(optionName, log))
                supportedOptionNames.add(optionName);
        }

    } catch (ClientCodeException e) {
        throw e;
    } catch (Throwable t) {
        throw new AnnotationProcessingError(t);
    }
}
 
Example #18
Source File: JavacProcessingEnvironment.java    From java-n-IDE-for-Android with Apache License 2.0 5 votes vote down vote up
ProcessorState(Processor p, Log log, Source source, ProcessingEnvironment env) {
    processor = p;
    contributed = false;

    try {
        processor.init(env);

        checkSourceVersionCompatibility(source, log);

        supportedAnnotationPatterns = new ArrayList<Pattern>();
        for (String importString : processor.getSupportedAnnotationTypes()) {
            supportedAnnotationPatterns.add(importStringToPattern(importString,
                                                                  processor,
                                                                  log));
        }

        supportedOptionNames = new ArrayList<String>();
        for (String optionName : processor.getSupportedOptions() ) {
            if (checkOptionName(optionName, log))
                supportedOptionNames.add(optionName);
        }

    } catch (ClientCodeException e) {
        throw e;
    } catch (Throwable t) {
        throw new AnnotationProcessingError(t);
    }
}
 
Example #19
Source File: JavacProcessingEnvironment.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
ProcessorState(Processor p, Log log, Source source, ProcessingEnvironment env) {
    processor = p;
    contributed = false;

    try {
        processor.init(env);

        checkSourceVersionCompatibility(source, log);

        supportedAnnotationPatterns = new ArrayList<Pattern>();
        for (String importString : processor.getSupportedAnnotationTypes()) {
            supportedAnnotationPatterns.add(importStringToPattern(importString,
                                                                  processor,
                                                                  log));
        }

        supportedOptionNames = new ArrayList<String>();
        for (String optionName : processor.getSupportedOptions() ) {
            if (checkOptionName(optionName, log))
                supportedOptionNames.add(optionName);
        }

    } catch (ClientCodeException e) {
        throw e;
    } catch (Throwable t) {
        throw new AnnotationProcessingError(t);
    }
}
 
Example #20
Source File: JavadocTaskImpl.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
public Boolean call() {
    if (!used.getAndSet(true)) {
        initContext();
        Start jdoc = new Start(context);
        try {
            return jdoc.begin(docletClass, options, fileObjects);
        } catch (ClientCodeException e) {
            throw new RuntimeException(e.getCause());
        }
    } else {
        throw new IllegalStateException("multiple calls to method 'call'");
    }
}
 
Example #21
Source File: JavacTool.java    From openjdk-8 with GNU General Public License v2.0 4 votes vote down vote up
public JavacTask getTask(Writer out,
                         JavaFileManager fileManager,
                         DiagnosticListener<? super JavaFileObject> diagnosticListener,
                         Iterable<String> options,
                         Iterable<String> classes,
                         Iterable<? extends JavaFileObject> compilationUnits,
                         Context context)
{
    try {
        ClientCodeWrapper ccw = ClientCodeWrapper.instance(context);

        if (options != null)
            for (String option : options)
                option.getClass(); // null check
        if (classes != null) {
            for (String cls : classes)
                if (!SourceVersion.isName(cls)) // implicit null check
                    throw new IllegalArgumentException("Not a valid class name: " + cls);
        }
        if (compilationUnits != null) {
            compilationUnits = ccw.wrapJavaFileObjects(compilationUnits); // implicit null check
            for (JavaFileObject cu : compilationUnits) {
                if (cu.getKind() != JavaFileObject.Kind.SOURCE) {
                    String kindMsg = "Compilation unit is not of SOURCE kind: "
                            + "\"" + cu.getName() + "\"";
                    throw new IllegalArgumentException(kindMsg);
                }
            }
        }

        if (diagnosticListener != null)
            context.put(DiagnosticListener.class, ccw.wrap(diagnosticListener));

        if (out == null)
            context.put(Log.outKey, new PrintWriter(System.err, true));
        else
            context.put(Log.outKey, new PrintWriter(out, true));

        if (fileManager == null)
            fileManager = getStandardFileManager(diagnosticListener, null, null);
        fileManager = ccw.wrap(fileManager);

        context.put(JavaFileManager.class, fileManager);

        processOptions(context, fileManager, options);
        Main compiler = new Main("javacTask", context.get(Log.outKey));
        return new JavacTaskImpl(compiler, options, context, classes, compilationUnits);
    } catch (ClientCodeException ex) {
        throw new RuntimeException(ex.getCause());
    }
}
 
Example #22
Source File: JavacTool.java    From openjdk-jdk8u with GNU General Public License v2.0 4 votes vote down vote up
public JavacTask getTask(Writer out,
                         JavaFileManager fileManager,
                         DiagnosticListener<? super JavaFileObject> diagnosticListener,
                         Iterable<String> options,
                         Iterable<String> classes,
                         Iterable<? extends JavaFileObject> compilationUnits,
                         Context context)
{
    try {
        ClientCodeWrapper ccw = ClientCodeWrapper.instance(context);

        if (options != null)
            for (String option : options)
                option.getClass(); // null check
        if (classes != null) {
            for (String cls : classes)
                if (!SourceVersion.isName(cls)) // implicit null check
                    throw new IllegalArgumentException("Not a valid class name: " + cls);
        }
        if (compilationUnits != null) {
            compilationUnits = ccw.wrapJavaFileObjects(compilationUnits); // implicit null check
            for (JavaFileObject cu : compilationUnits) {
                if (cu.getKind() != JavaFileObject.Kind.SOURCE) {
                    String kindMsg = "Compilation unit is not of SOURCE kind: "
                            + "\"" + cu.getName() + "\"";
                    throw new IllegalArgumentException(kindMsg);
                }
            }
        }

        if (diagnosticListener != null)
            context.put(DiagnosticListener.class, ccw.wrap(diagnosticListener));

        if (out == null)
            context.put(Log.outKey, new PrintWriter(System.err, true));
        else
            context.put(Log.outKey, new PrintWriter(out, true));

        if (fileManager == null)
            fileManager = getStandardFileManager(diagnosticListener, null, null);
        fileManager = ccw.wrap(fileManager);

        context.put(JavaFileManager.class, fileManager);

        processOptions(context, fileManager, options);
        Main compiler = new Main("javacTask", context.get(Log.outKey));
        return new JavacTaskImpl(compiler, options, context, classes, compilationUnits);
    } catch (ClientCodeException ex) {
        throw new RuntimeException(ex.getCause());
    }
}
 
Example #23
Source File: JavadocTool.java    From TencentKona-8 with GNU General Public License v2.0 4 votes vote down vote up
public DocumentationTask getTask(
        Writer out,
        JavaFileManager fileManager,
        DiagnosticListener<? super JavaFileObject> diagnosticListener,
        Class<?> docletClass,
        Iterable<String> options,
        Iterable<? extends JavaFileObject> compilationUnits,
        Context context) {
    try {
        ClientCodeWrapper ccw = ClientCodeWrapper.instance(context);

        if (options != null) {
            for (String option : options)
                option.getClass(); // null check
        }

        if (compilationUnits != null) {
            compilationUnits = ccw.wrapJavaFileObjects(compilationUnits); // implicit null check
            for (JavaFileObject cu : compilationUnits) {
                if (cu.getKind() != JavaFileObject.Kind.SOURCE) {
                    final String kindMsg = "All compilation units must be of SOURCE kind";
                    throw new IllegalArgumentException(kindMsg);
                }
            }
        }

        if (diagnosticListener != null)
            context.put(DiagnosticListener.class, ccw.wrap(diagnosticListener));

        if (out == null)
            context.put(Log.outKey, new PrintWriter(System.err, true));
        else if (out instanceof PrintWriter)
            context.put(Log.outKey, ((PrintWriter) out));
        else
            context.put(Log.outKey, new PrintWriter(out, true));

        if (fileManager == null)
            fileManager = getStandardFileManager(diagnosticListener, null, null);
        fileManager = ccw.wrap(fileManager);
        context.put(JavaFileManager.class, fileManager);

        return new JavadocTaskImpl(context, docletClass, options, compilationUnits);
    } catch (ClientCodeException ex) {
        throw new RuntimeException(ex.getCause());
    }
}
 
Example #24
Source File: JavadocTool.java    From openjdk-8 with GNU General Public License v2.0 4 votes vote down vote up
public DocumentationTask getTask(
        Writer out,
        JavaFileManager fileManager,
        DiagnosticListener<? super JavaFileObject> diagnosticListener,
        Class<?> docletClass,
        Iterable<String> options,
        Iterable<? extends JavaFileObject> compilationUnits,
        Context context) {
    try {
        ClientCodeWrapper ccw = ClientCodeWrapper.instance(context);

        if (options != null) {
            for (String option : options)
                option.getClass(); // null check
        }

        if (compilationUnits != null) {
            compilationUnits = ccw.wrapJavaFileObjects(compilationUnits); // implicit null check
            for (JavaFileObject cu : compilationUnits) {
                if (cu.getKind() != JavaFileObject.Kind.SOURCE) {
                    final String kindMsg = "All compilation units must be of SOURCE kind";
                    throw new IllegalArgumentException(kindMsg);
                }
            }
        }

        if (diagnosticListener != null)
            context.put(DiagnosticListener.class, ccw.wrap(diagnosticListener));

        if (out == null)
            context.put(Log.outKey, new PrintWriter(System.err, true));
        else if (out instanceof PrintWriter)
            context.put(Log.outKey, ((PrintWriter) out));
        else
            context.put(Log.outKey, new PrintWriter(out, true));

        if (fileManager == null)
            fileManager = getStandardFileManager(diagnosticListener, null, null);
        fileManager = ccw.wrap(fileManager);
        context.put(JavaFileManager.class, fileManager);

        return new JavadocTaskImpl(context, docletClass, options, compilationUnits);
    } catch (ClientCodeException ex) {
        throw new RuntimeException(ex.getCause());
    }
}
 
Example #25
Source File: JavacTool.java    From openjdk-8-source with GNU General Public License v2.0 4 votes vote down vote up
public JavacTask getTask(Writer out,
                         JavaFileManager fileManager,
                         DiagnosticListener<? super JavaFileObject> diagnosticListener,
                         Iterable<String> options,
                         Iterable<String> classes,
                         Iterable<? extends JavaFileObject> compilationUnits,
                         Context context)
{
    try {
        ClientCodeWrapper ccw = ClientCodeWrapper.instance(context);

        if (options != null)
            for (String option : options)
                option.getClass(); // null check
        if (classes != null) {
            for (String cls : classes)
                if (!SourceVersion.isName(cls)) // implicit null check
                    throw new IllegalArgumentException("Not a valid class name: " + cls);
        }
        if (compilationUnits != null) {
            compilationUnits = ccw.wrapJavaFileObjects(compilationUnits); // implicit null check
            for (JavaFileObject cu : compilationUnits) {
                if (cu.getKind() != JavaFileObject.Kind.SOURCE) {
                    String kindMsg = "Compilation unit is not of SOURCE kind: "
                            + "\"" + cu.getName() + "\"";
                    throw new IllegalArgumentException(kindMsg);
                }
            }
        }

        if (diagnosticListener != null)
            context.put(DiagnosticListener.class, ccw.wrap(diagnosticListener));

        if (out == null)
            context.put(Log.outKey, new PrintWriter(System.err, true));
        else
            context.put(Log.outKey, new PrintWriter(out, true));

        if (fileManager == null)
            fileManager = getStandardFileManager(diagnosticListener, null, null);
        fileManager = ccw.wrap(fileManager);

        context.put(JavaFileManager.class, fileManager);

        processOptions(context, fileManager, options);
        Main compiler = new Main("javacTask", context.get(Log.outKey));
        return new JavacTaskImpl(compiler, options, context, classes, compilationUnits);
    } catch (ClientCodeException ex) {
        throw new RuntimeException(ex.getCause());
    }
}
 
Example #26
Source File: JavacTool.java    From TencentKona-8 with GNU General Public License v2.0 4 votes vote down vote up
public JavacTask getTask(Writer out,
                         JavaFileManager fileManager,
                         DiagnosticListener<? super JavaFileObject> diagnosticListener,
                         Iterable<String> options,
                         Iterable<String> classes,
                         Iterable<? extends JavaFileObject> compilationUnits,
                         Context context)
{
    try {
        ClientCodeWrapper ccw = ClientCodeWrapper.instance(context);

        if (options != null)
            for (String option : options)
                option.getClass(); // null check
        if (classes != null) {
            for (String cls : classes)
                if (!SourceVersion.isName(cls)) // implicit null check
                    throw new IllegalArgumentException("Not a valid class name: " + cls);
        }
        if (compilationUnits != null) {
            compilationUnits = ccw.wrapJavaFileObjects(compilationUnits); // implicit null check
            for (JavaFileObject cu : compilationUnits) {
                if (cu.getKind() != JavaFileObject.Kind.SOURCE) {
                    String kindMsg = "Compilation unit is not of SOURCE kind: "
                            + "\"" + cu.getName() + "\"";
                    throw new IllegalArgumentException(kindMsg);
                }
            }
        }

        if (diagnosticListener != null)
            context.put(DiagnosticListener.class, ccw.wrap(diagnosticListener));

        if (out == null)
            context.put(Log.outKey, new PrintWriter(System.err, true));
        else
            context.put(Log.outKey, new PrintWriter(out, true));

        if (fileManager == null)
            fileManager = getStandardFileManager(diagnosticListener, null, null);
        fileManager = ccw.wrap(fileManager);

        context.put(JavaFileManager.class, fileManager);

        processOptions(context, fileManager, options);
        Main compiler = new Main("javacTask", context.get(Log.outKey));
        return new JavacTaskImpl(compiler, options, context, classes, compilationUnits);
    } catch (ClientCodeException ex) {
        throw new RuntimeException(ex.getCause());
    }
}
 
Example #27
Source File: JavadocTool.java    From jdk8u60 with GNU General Public License v2.0 4 votes vote down vote up
public DocumentationTask getTask(
        Writer out,
        JavaFileManager fileManager,
        DiagnosticListener<? super JavaFileObject> diagnosticListener,
        Class<?> docletClass,
        Iterable<String> options,
        Iterable<? extends JavaFileObject> compilationUnits,
        Context context) {
    try {
        ClientCodeWrapper ccw = ClientCodeWrapper.instance(context);

        if (options != null) {
            for (String option : options)
                option.getClass(); // null check
        }

        if (compilationUnits != null) {
            compilationUnits = ccw.wrapJavaFileObjects(compilationUnits); // implicit null check
            for (JavaFileObject cu : compilationUnits) {
                if (cu.getKind() != JavaFileObject.Kind.SOURCE) {
                    final String kindMsg = "All compilation units must be of SOURCE kind";
                    throw new IllegalArgumentException(kindMsg);
                }
            }
        }

        if (diagnosticListener != null)
            context.put(DiagnosticListener.class, ccw.wrap(diagnosticListener));

        if (out == null)
            context.put(Log.outKey, new PrintWriter(System.err, true));
        else if (out instanceof PrintWriter)
            context.put(Log.outKey, ((PrintWriter) out));
        else
            context.put(Log.outKey, new PrintWriter(out, true));

        if (fileManager == null)
            fileManager = getStandardFileManager(diagnosticListener, null, null);
        fileManager = ccw.wrap(fileManager);
        context.put(JavaFileManager.class, fileManager);

        return new JavadocTaskImpl(context, docletClass, options, compilationUnits);
    } catch (ClientCodeException ex) {
        throw new RuntimeException(ex.getCause());
    }
}
 
Example #28
Source File: JavadocTool.java    From openjdk-8-source with GNU General Public License v2.0 4 votes vote down vote up
public DocumentationTask getTask(
        Writer out,
        JavaFileManager fileManager,
        DiagnosticListener<? super JavaFileObject> diagnosticListener,
        Class<?> docletClass,
        Iterable<String> options,
        Iterable<? extends JavaFileObject> compilationUnits,
        Context context) {
    try {
        ClientCodeWrapper ccw = ClientCodeWrapper.instance(context);

        if (options != null) {
            for (String option : options)
                option.getClass(); // null check
        }

        if (compilationUnits != null) {
            compilationUnits = ccw.wrapJavaFileObjects(compilationUnits); // implicit null check
            for (JavaFileObject cu : compilationUnits) {
                if (cu.getKind() != JavaFileObject.Kind.SOURCE) {
                    final String kindMsg = "All compilation units must be of SOURCE kind";
                    throw new IllegalArgumentException(kindMsg);
                }
            }
        }

        if (diagnosticListener != null)
            context.put(DiagnosticListener.class, ccw.wrap(diagnosticListener));

        if (out == null)
            context.put(Log.outKey, new PrintWriter(System.err, true));
        else if (out instanceof PrintWriter)
            context.put(Log.outKey, ((PrintWriter) out));
        else
            context.put(Log.outKey, new PrintWriter(out, true));

        if (fileManager == null)
            fileManager = getStandardFileManager(diagnosticListener, null, null);
        fileManager = ccw.wrap(fileManager);
        context.put(JavaFileManager.class, fileManager);

        return new JavadocTaskImpl(context, docletClass, options, compilationUnits);
    } catch (ClientCodeException ex) {
        throw new RuntimeException(ex.getCause());
    }
}
 
Example #29
Source File: JavacTool.java    From hottub with GNU General Public License v2.0 4 votes vote down vote up
public JavacTask getTask(Writer out,
                         JavaFileManager fileManager,
                         DiagnosticListener<? super JavaFileObject> diagnosticListener,
                         Iterable<String> options,
                         Iterable<String> classes,
                         Iterable<? extends JavaFileObject> compilationUnits,
                         Context context)
{
    try {
        ClientCodeWrapper ccw = ClientCodeWrapper.instance(context);

        if (options != null)
            for (String option : options)
                option.getClass(); // null check
        if (classes != null) {
            for (String cls : classes)
                if (!SourceVersion.isName(cls)) // implicit null check
                    throw new IllegalArgumentException("Not a valid class name: " + cls);
        }
        if (compilationUnits != null) {
            compilationUnits = ccw.wrapJavaFileObjects(compilationUnits); // implicit null check
            for (JavaFileObject cu : compilationUnits) {
                if (cu.getKind() != JavaFileObject.Kind.SOURCE) {
                    String kindMsg = "Compilation unit is not of SOURCE kind: "
                            + "\"" + cu.getName() + "\"";
                    throw new IllegalArgumentException(kindMsg);
                }
            }
        }

        if (diagnosticListener != null)
            context.put(DiagnosticListener.class, ccw.wrap(diagnosticListener));

        if (out == null)
            context.put(Log.outKey, new PrintWriter(System.err, true));
        else
            context.put(Log.outKey, new PrintWriter(out, true));

        if (fileManager == null)
            fileManager = getStandardFileManager(diagnosticListener, null, null);
        fileManager = ccw.wrap(fileManager);

        context.put(JavaFileManager.class, fileManager);

        processOptions(context, fileManager, options);
        Main compiler = new Main("javacTask", context.get(Log.outKey));
        return new JavacTaskImpl(compiler, options, context, classes, compilationUnits);
    } catch (ClientCodeException ex) {
        throw new RuntimeException(ex.getCause());
    }
}
 
Example #30
Source File: JavadocTool.java    From hottub with GNU General Public License v2.0 4 votes vote down vote up
public DocumentationTask getTask(
        Writer out,
        JavaFileManager fileManager,
        DiagnosticListener<? super JavaFileObject> diagnosticListener,
        Class<?> docletClass,
        Iterable<String> options,
        Iterable<? extends JavaFileObject> compilationUnits,
        Context context) {
    try {
        ClientCodeWrapper ccw = ClientCodeWrapper.instance(context);

        if (options != null) {
            for (String option : options)
                option.getClass(); // null check
        }

        if (compilationUnits != null) {
            compilationUnits = ccw.wrapJavaFileObjects(compilationUnits); // implicit null check
            for (JavaFileObject cu : compilationUnits) {
                if (cu.getKind() != JavaFileObject.Kind.SOURCE) {
                    final String kindMsg = "All compilation units must be of SOURCE kind";
                    throw new IllegalArgumentException(kindMsg);
                }
            }
        }

        if (diagnosticListener != null)
            context.put(DiagnosticListener.class, ccw.wrap(diagnosticListener));

        if (out == null)
            context.put(Log.outKey, new PrintWriter(System.err, true));
        else if (out instanceof PrintWriter)
            context.put(Log.outKey, ((PrintWriter) out));
        else
            context.put(Log.outKey, new PrintWriter(out, true));

        if (fileManager == null)
            fileManager = getStandardFileManager(diagnosticListener, null, null);
        fileManager = ccw.wrap(fileManager);
        context.put(JavaFileManager.class, fileManager);

        return new JavadocTaskImpl(context, docletClass, options, compilationUnits);
    } catch (ClientCodeException ex) {
        throw new RuntimeException(ex.getCause());
    }
}