Skip to content

Commit ed85524

Browse files
committed
malva: Improve Class#getAnnotations test case
This patch improves the Class#getAnnotations test case to check that the annotation values are initialized from the classfile. Signed-off-by: Pekka Enberg <penberg@kernel.org>
1 parent 956ba06 commit ed85524

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

src/malva/java/lang/ClassTest.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
package malva.java.lang;
22

3+
import java.lang.annotation.ElementType;
34
import java.lang.annotation.Annotation;
45
import java.lang.annotation.Retention;
56
import java.lang.annotation.RetentionPolicy;
7+
import java.lang.annotation.Target;
68
import java.lang.reflect.Field;
79
import java.lang.reflect.Method;
810
import java.lang.reflect.Modifier;
@@ -56,7 +58,17 @@ public static void testGetAnnotations() {
5658
return value.annotationType();
5759
}
5860
}));
61+
assertEquals(Arrays.<String>asList("unused"), transform(UnusedClass.class.getAnnotations(),
62+
new Transformer<Annotation, String>() {
63+
@Override public String transform(Annotation value) {
64+
SuppressWarnings x = (SuppressWarnings) value;
65+
return x.value();
66+
}
67+
}));
5968
}
69+
@Retention(RetentionPolicy.RUNTIME) @Target(ElementType.TYPE) public @interface SuppressWarnings { String value(); }
70+
71+
@SuppressWarnings("unused") static class UnusedClass { }
6072

6173
public static void testGetCanonicalName() {
6274
assertEquals("java.lang.Object", Object.class.getCanonicalName());

0 commit comments

Comments
 (0)