[vmkit-commits] [vmkit] r180309 - Test file for field annotations
Peter Senna Tschudin
peter.senna at gmail.com
Thu Apr 25 09:54:32 PDT 2013
Author: peter.senna
Date: Thu Apr 25 11:52:49 2013
New Revision: 180309
URL: http://llvm.org/viewvc/llvm-project?rev=180309&view=rev
Log:
Test file for field annotations
(cherry picked from commit b54bb97f2836cf4183814bfb87e2b77e3f087e11)
Added:
vmkit/trunk/tests/AnnotationClassTest.java
Added: vmkit/trunk/tests/AnnotationClassTest.java
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/tests/AnnotationClassTest.java?rev=180309&view=auto
==============================================================================
--- vmkit/trunk/tests/AnnotationClassTest.java (added)
+++ vmkit/trunk/tests/AnnotationClassTest.java Thu Apr 25 11:52:49 2013
@@ -0,0 +1,35 @@
+import java.lang.Deprecated;
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Field;
+
+/**
+ * Created with IntelliJ IDEA.
+ * User: inti
+ * Date: 11/14/12
+ * Time: 11:08 PM
+ * To change this template use File | Settings | File Templates.
+ */
+public class AnnotationClassTest {
+ static class Sample {
+ @Deprecated
+ public int x;
+ }
+
+ public static void main(String[] args) throws Exception {
+ Field f = Sample.class.getField("x");
+ Sample sample = new Sample();
+ sample.x = 14;
+
+ Annotation xx = f.getAnnotation(Deprecated.class);
+ //Annotation[] a = f.getDeclaredAnnotations();
+
+ check(f.getInt(sample) == 14);
+ f.setInt(sample, 17);
+ check(f.getInt(sample) == 17);
+ check(xx.annotationType().getCanonicalName().equals("java.lang.Deprecated"));
+ }
+
+ private static void check(boolean b) throws Exception {
+ if (!b) throw new Exception("Test failed!!!");
+ }
+}
More information about the vmkit-commits
mailing list