use of java.lang.annotation.AnnotationTypeMismatchException in project epoxy by airbnb.
the class EpoxyProcessor method findClassAnnotationWithLayout.
/**
* Looks for {@link EpoxyModelClass} annotation in the original class and his parents.
*/
private EpoxyModelClass findClassAnnotationWithLayout(TypeElement classElement) {
if (!isEpoxyModel(classElement)) {
return null;
}
EpoxyModelClass annotation = classElement.getAnnotation(EpoxyModelClass.class);
if (annotation == null) {
return null;
}
try {
int layoutRes = annotation.layout();
if (layoutRes != 0) {
return annotation;
}
} catch (AnnotationTypeMismatchException e) {
logError("Invalid layout value in %s annotation. (class: %s). %s: %s", EpoxyModelClass.class, classElement.getSimpleName(), e.getClass().getSimpleName(), e.getMessage());
return null;
}
TypeElement superclassElement = (TypeElement) typeUtils.asElement(classElement.getSuperclass());
EpoxyModelClass annotationOnSuperClass = findClassAnnotationWithLayout(superclassElement);
// Return the last annotation value we have so the proper error can be thrown if needed
return annotationOnSuperClass != null ? annotationOnSuperClass : annotation;
}
use of java.lang.annotation.AnnotationTypeMismatchException in project robovm by robovm.
the class AnnotationTypeMismatchExceptionTest method testSerialization.
public void testSerialization() throws Exception {
Method m = String.class.getMethod("length");
AnnotationTypeMismatchException original = new AnnotationTypeMismatchException(m, "poop");
ByteArrayOutputStream out = new ByteArrayOutputStream();
try {
// AnnotationTypeMismatchException is broken: it's Serializable but has a non-transient
// non-serializable field of type Method.
new ObjectOutputStream(out).writeObject(original);
fail();
} catch (NotSerializableException expected) {
}
}
use of java.lang.annotation.AnnotationTypeMismatchException in project robovm by robovm.
the class AnnotationTypeMismatchExceptionTest method test_constructorLjava_lang_reflect_MethodLjava_lang_String.
/**
* @throws ClassNotFoundException
* @throws SecurityException
* @tests java.lang.annotation.AnnotationTypeMismatchException#AnnotationTypeMismatchException(Method,
* String)
*/
@SuppressWarnings("nls")
public void test_constructorLjava_lang_reflect_MethodLjava_lang_String() throws SecurityException, ClassNotFoundException {
Method[] methods = Class.forName("java.lang.String").getMethods();
Method m = methods[0];
AnnotationTypeMismatchException e = new AnnotationTypeMismatchException(m, "some type");
assertNotNull("can not instantiate AnnotationTypeMismatchException", e);
assertSame("wrong method name", m, e.element());
assertEquals("wrong found type", "some type", e.foundType());
}
use of java.lang.annotation.AnnotationTypeMismatchException in project j2objc by google.
the class AnnotationTypeMismatchExceptionTest method testGetters.
public void testGetters() throws Exception {
Method m = String.class.getMethod("length");
AnnotationTypeMismatchException ex = new AnnotationTypeMismatchException(m, "poop");
assertSame(m, ex.element());
assertEquals("poop", ex.foundType());
}
use of java.lang.annotation.AnnotationTypeMismatchException in project j2objc by google.
the class AnnotationTypeMismatchExceptionTest method testSerialization.
public void testSerialization() throws Exception {
Method m = String.class.getMethod("length");
AnnotationTypeMismatchException original = new AnnotationTypeMismatchException(m, "poop");
ByteArrayOutputStream out = new ByteArrayOutputStream();
try {
// AnnotationTypeMismatchException is broken: it's Serializable but has a non-transient
// non-serializable field of type Method.
new ObjectOutputStream(out).writeObject(original);
fail();
} catch (NotSerializableException expected) {
}
}
Aggregations