Java源码示例:com.sun.tools.javac.util.Abort

示例1
public Processor next() {
    try {
        return iterator.next();
    } catch (ServiceConfigurationError sce) {
        log.error("proc.bad.config.file", sce.getLocalizedMessage());
        throw new Abort(sce);
    } catch (UnsupportedClassVersionError ucve) {
        log.error("proc.cant.load.class", ucve.getLocalizedMessage());
        throw new Abort(ucve);
    } catch (ClassFormatError cfe) {
        log.error("proc.cant.load.class", cfe.getLocalizedMessage());
        throw new Abort(cfe);
    } catch (Throwable t) {
        log.error("proc.bad.config.file", t.getLocalizedMessage());
        throw new Abort(t);
    }
}
 
示例2
public Processor next() {
    try {
        return iterator.next();
    } catch (ServiceConfigurationError sce) {
        log.error("proc.bad.config.file", sce.getLocalizedMessage());
        throw new Abort(sce);
    } catch (UnsupportedClassVersionError ucve) {
        log.error("proc.cant.load.class", ucve.getLocalizedMessage());
        throw new Abort(ucve);
    } catch (ClassFormatError cfe) {
        log.error("proc.cant.load.class", cfe.getLocalizedMessage());
        throw new Abort(cfe);
    } catch (Throwable t) {
        log.error("proc.bad.config.file", t.getLocalizedMessage());
        throw new Abort(t);
    }
}
 
示例3
@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;
    }
}
 
示例4
public final Type getType(String type) {
    JavaSource source = new JavaSource(type);
    MyAttr.theType = null;
    MyAttr.typeParameters = List.nil();
    tool.clear();
    List<JavaFileObject> inputs = of(source);
    try {
        tool.compile(inputs);
    } catch (Throwable ex) {
        throw new Abort(ex);
    }
    if (typeVariables != null) {
        return types.subst(MyAttr.theType, MyAttr.typeParameters, typeVariables);
    }
    return MyAttr.theType;
}
 
示例5
/**
 * Handle a security exception thrown during initializing the
 * Processor iterator.
 */
private void handleException(String key, Exception e) {
    if (e != null) {
        log.error(key, e.getLocalizedMessage());
        throw new Abort(e);
    } else {
        log.error(key);
        throw new Abort();
    }
}
 
示例6
ServiceIterator(ClassLoader classLoader, Log log) {
    this.log = log;
    try {
        try {
            loader = ServiceLoader.load(Processor.class, classLoader);
            this.iterator = loader.iterator();
        } catch (Exception e) {
            // Fail softly if a loader is not actually needed.
            this.iterator = handleServiceLoaderUnavailability("proc.no.service", null);
        }
    } catch (Throwable t) {
        log.error("proc.service.problem");
        throw new Abort(t);
    }
}
 
示例7
public boolean hasNext() {
    try {
        return iterator.hasNext();
    } catch(ServiceConfigurationError sce) {
        log.error("proc.bad.config.file", sce.getLocalizedMessage());
        throw new Abort(sce);
    } catch (Throwable t) {
        log.error("proc.bad.config.file", t.getLocalizedMessage());
        throw new Abort(t);
    }
}
 
示例8
/**
 * Handle a security exception thrown during initializing the
 * Processor iterator.
 */
private void handleException(String key, Exception e) {
    if (e != null) {
        log.error(key, e.getLocalizedMessage());
        throw new Abort(e);
    } else {
        log.error(key);
        throw new Abort();
    }
}
 
示例9
ServiceIterator(ClassLoader classLoader, Log log) {
    this.log = log;
    try {
        try {
            loader = ServiceLoader.load(Processor.class, classLoader);
            this.iterator = loader.iterator();
        } catch (Exception e) {
            // Fail softly if a loader is not actually needed.
            this.iterator = handleServiceLoaderUnavailability("proc.no.service", null);
        }
    } catch (Throwable t) {
        log.error("proc.service.problem");
        throw new Abort(t);
    }
}
 
示例10
public boolean hasNext() {
    try {
        return iterator.hasNext();
    } catch(ServiceConfigurationError sce) {
        log.error("proc.bad.config.file", sce.getLocalizedMessage());
        throw new Abort(sce);
    } catch (Throwable t) {
        throw new Abort(t);
    }
}
 
示例11
public Processor next() {
    try {
        return iterator.next();
    } catch (ServiceConfigurationError sce) {
        log.error("proc.bad.config.file", sce.getLocalizedMessage());
        throw new Abort(sce);
    } catch (Throwable t) {
        throw new Abort(t);
    }
}
 
示例12
/**
 * Handle a security exception thrown during initializing the
 * Processor iterator.
 */
private void handleException(String key, Exception e) {
    if (e != null) {
        log.error(key, e.getLocalizedMessage());
        throw new Abort(e);
    } else {
        log.error(key);
        throw new Abort();
    }
}
 
示例13
public boolean hasNext() {
    try {
        return iterator.hasNext();
    } catch (Throwable t) {
        if ("ServiceConfigurationError".
            equals(t.getClass().getSimpleName())) {
            log.error("proc.bad.config.file", t.getLocalizedMessage());
        }
        throw new Abort(t);
    }
}
 
示例14
public Processor next() {
    try {
        return (Processor)(iterator.next());
    } catch (Throwable t) {
        if ("ServiceConfigurationError".
            equals(t.getClass().getSimpleName())) {
            log.error("proc.bad.config.file", t.getLocalizedMessage());
        } else {
            log.error("proc.processor.constructor.error", t.getLocalizedMessage());
        }
        throw new Abort(t);
    }
}
 
示例15
/**
 * Main method: compile a list of files, return all compiled classes
 *
 * @param sourceFileObjects file objects to be compiled
 * @param classnames        class names to process for annotations
 * @param processors        user provided annotation processors to bypass
 *                          discovery, {@code null} means that no processors were provided
 */
public void compile(List<JavaFileObject> sourceFileObjects,
                    List<String> classnames,
                    Iterable<? extends Processor> processors) {
    if (processors != null && processors.iterator().hasNext())
        explicitAnnotationProcessingRequested = true;
    // as a JavaCompiler can only be used once, throw an exception if
    // it has been used before.
    if (hasBeenUsed)
        throw new AssertionError("attempt to reuse JavaCompiler");
    hasBeenUsed = true;

    // forcibly set the equivalent of -Xlint:-options, so that no further
    // warnings about command line options are generated from this point on
    options.put(XLINT_CUSTOM + "-" + LintCategory.OPTIONS.option, "true");
    options.remove(XLINT_CUSTOM + LintCategory.OPTIONS.option);

    start_msec = now();

    try {
        initProcessAnnotations(processors);

        // These method calls must be chained to avoid memory leaks
        delegateCompiler =
                processAnnotations(
                        enterTrees(stopIfError(CompileState.PARSE, parseFiles(sourceFileObjects))),
                        classnames);

        delegateCompiler.compile2();
        delegateCompiler.close();
        elapsed_msec = delegateCompiler.elapsed_msec;
    } catch (Abort ex) {
        if (devVerbose)
            ex.printStackTrace(System.err);
    } finally {
        if (procEnvImpl != null)
            procEnvImpl.close();
    }
}
 
示例16
public void close(boolean disposeNames) {
    rootClasses = null;
    reader = null;
    make = null;
    writer = null;
    enter = null;
    if (todo != null)
        todo.clear();
    todo = null;
    parserFactory = null;
    syms = null;
    source = null;
    attr = null;
    chk = null;
    gen = null;
    flow = null;
    transTypes = null;
    lower = null;
    annotate = null;
    types = null;

    log.flush();
    try {
        fileManager.flush();
    } catch (IOException e) {
        throw new Abort(e);
    } finally {
        if (names != null && disposeNames)
            names.dispose();
        names = null;
    }
}
 
示例17
/**
 * Handle a security exception thrown during initializing the
 * Processor iterator.
 */
private void handleException(String key, Exception e) {
    if (e != null) {
        log.error(key, e.getLocalizedMessage());
        throw new Abort(e);
    } else {
        log.error(key);
        throw new Abort();
    }
}
 
示例18
ServiceIterator(ClassLoader classLoader, Log log) {
    this.log = log;
    try {
        try {
            loader = ServiceLoader.load(Processor.class, classLoader);
            this.iterator = loader.iterator();
        } catch (Exception e) {
            // Fail softly if a loader is not actually needed.
            this.iterator = handleServiceLoaderUnavailability("proc.no.service", null);
        }
    } catch (Throwable t) {
        log.error("proc.service.problem");
        throw new Abort(t);
    }
}
 
示例19
public boolean hasNext() {
    try {
        return iterator.hasNext();
    } catch(ServiceConfigurationError sce) {
        log.error("proc.bad.config.file", sce.getLocalizedMessage());
        throw new Abort(sce);
    } catch (Throwable t) {
        log.error("proc.bad.config.file", t.getLocalizedMessage());
        throw new Abort(t);
    }
}
 
示例20
public <S> ServiceLoader<S> getServiceLoader(Class<S> service) {
    if (fileManager.hasLocation(ANNOTATION_PROCESSOR_MODULE_PATH)) {
        try {
            return fileManager.getServiceLoader(ANNOTATION_PROCESSOR_MODULE_PATH, service);
        } catch (IOException e) {
            throw new Abort(e);
        }
    } else {
        return ServiceLoader.load(service, getProcessorClassLoader());
    }
}
 
示例21
/**
 * Handle a security exception thrown during initializing the
 * Processor iterator.
 */
private void handleException(String key, Exception e) {
    if (e != null) {
        log.error(key, e.getLocalizedMessage());
        throw new Abort(e);
    } else {
        log.error(key);
        throw new Abort();
    }
}
 
示例22
ServiceIterator(ClassLoader classLoader, Log log) {
    this.log = log;
    try {
        try {
            loader = ServiceLoader.load(Processor.class, classLoader);
            this.iterator = loader.iterator();
        } catch (Exception e) {
            // Fail softly if a loader is not actually needed.
            this.iterator = handleServiceLoaderUnavailability("proc.no.service", null);
        }
    } catch (Throwable t) {
        log.error(Errors.ProcServiceProblem);
        throw new Abort(t);
    }
}
 
示例23
@Override
public boolean hasNext() {
    try {
        return internalHasNext();
    } catch(ServiceConfigurationError sce) {
        log.error(Errors.ProcBadConfigFile(sce.getLocalizedMessage()));
        throw new Abort(sce);
    } catch (Throwable t) {
        throw new Abort(t);
    }
}
 
示例24
@Override
public Processor next() {
    try {
        return internalNext();
    } catch (ServiceConfigurationError sce) {
        log.error(Errors.ProcBadConfigFile(sce.getLocalizedMessage()));
        throw new Abort(sce);
    } catch (Throwable t) {
        throw new Abort(t);
    }
}
 
示例25
/**
 * Handle a security exception thrown during initializing the
 * Processor iterator.
 */
private void handleException(String key, Exception e) {
    if (e != null) {
        log.error(key, e.getLocalizedMessage());
        throw new Abort(e);
    } else {
        log.error(key);
        throw new Abort();
    }
}
 
示例26
ServiceIterator(ClassLoader classLoader, Log log) {
    this.log = log;
    try {
        try {
            loader = ServiceLoader.load(Processor.class, classLoader);
            this.iterator = loader.iterator();
        } catch (Exception e) {
            // Fail softly if a loader is not actually needed.
            this.iterator = handleServiceLoaderUnavailability("proc.no.service", null);
        }
    } catch (Throwable t) {
        log.error("proc.service.problem");
        throw new Abort(t);
    }
}
 
示例27
public boolean hasNext() {
    try {
        return iterator.hasNext();
    } catch(ServiceConfigurationError sce) {
        log.error("proc.bad.config.file", sce.getLocalizedMessage());
        throw new Abort(sce);
    } catch (Throwable t) {
        throw new Abort(t);
    }
}
 
示例28
public Processor next() {
    try {
        return iterator.next();
    } catch (ServiceConfigurationError sce) {
        log.error("proc.bad.config.file", sce.getLocalizedMessage());
        throw new Abort(sce);
    } catch (Throwable t) {
        throw new Abort(t);
    }
}
 
示例29
/**
 * Handle a security exception thrown during initializing the
 * Processor iterator.
 */
private void handleException(String key, Exception e) {
    if (e != null) {
        log.error(key, e.getLocalizedMessage());
        throw new Abort(e);
    } else {
        log.error(key);
        throw new Abort();
    }
}
 
示例30
public boolean hasNext() {
    try {
        return iterator.hasNext();
    } catch (Throwable t) {
        if ("ServiceConfigurationError".
            equals(t.getClass().getSimpleName())) {
            log.error("proc.bad.config.file", t.getLocalizedMessage());
        }
        throw new Abort(t);
    }
}