Example usage for java.lang.annotation AnnotationTypeMismatchException getClass

List of usage examples for java.lang.annotation AnnotationTypeMismatchException getClass

Introduction

In this page you can find the example usage for java.lang.annotation AnnotationTypeMismatchException getClass.

Prototype

@HotSpotIntrinsicCandidate
public final native Class<?> getClass();

Source Link

Document

Returns the runtime class of this Object .

Usage

From source file:cop.raml.processor.RestProcessor.java

/**
 * This method is responsible for calling {@link #processMethod(RestApi, ExecutableElement)} and catch all exceptions.
 *
 * @param api           rest api//  ww  w  .  j  av  a2 s. c  o m
 * @param methodElement method element
 */
private void processMethodWithCatchException(@NotNull RestApi api, @NotNull ExecutableElement methodElement) {
    try {
        processMethod(api, methodElement);
    } catch (AnnotationTypeMismatchException e) {
        String className = methodElement.getEnclosingElement().getSimpleName().toString();
        String message = String.format(
                "Unable to read annotation parameter '%s' for %s.%s(). Try to use simple inline String.",
                e.element().getName(), className, methodElement.getSimpleName());
        AnnotationMirror annotationMirror = getAnnotationMirror(methodElement,
                e.element().getDeclaringClass().getName());
        AnnotationValue annotationValue = getAnnotationValue(annotationMirror, e.element().getName() + "()");
        ThreadLocalContext.getMessager().printMessage(WARNING, message, methodElement, annotationMirror,
                annotationValue);
    } catch (Exception e) {
        String message = String.format("%s: %s", e.getClass().getName(), e.getStackTrace()[0]);
        ThreadLocalContext.getMessager().printMessage(WARNING, message, methodElement);
    }
}