emul/src/main/java/java/lang/AnnotationImpl.java
author Jaroslav Tulach <jaroslav.tulach@apidesign.org>
Sun, 02 Dec 2012 12:26:14 +0100
branchreflection
changeset 235 bf0a77f029c4
child 236 d97770281580
permissions -rw-r--r--
Initial support for runtime annotations
     1 /*
     2  * To change this template, choose Tools | Templates
     3  * and open the template in the editor.
     4  */
     5 package java.lang;
     6 
     7 import java.lang.annotation.Annotation;
     8 import org.apidesign.bck2brwsr.core.JavaScriptBody;
     9 
    10 /**
    11  *
    12  * @author Jaroslav Tulach <jtulach@netbeans.org>
    13  */
    14 final class AnnotationImpl implements Annotation {
    15     public Class<? extends Annotation> annotationType() {
    16         return getClass();
    17     }
    18 
    19     @JavaScriptBody(args = { "a", "n", "values" }, body =
    20           "var v = values;"
    21         + "for (p in values) {"
    22         + "  a[p + 'I'] = function() { return v[p]; }"
    23         + "}"
    24         + "a['$instOf_' + n] = true;"
    25         + "return a;"
    26     )
    27     private static <T extends Annotation> T create(AnnotationImpl a, String n, Object values) {
    28         return null;
    29     }
    30     static <T extends Annotation> T create(Class<T> annoClass, Object values) {
    31         return create(new AnnotationImpl(), annoClass.getName().replace('.', '_'), values);
    32     }
    33 }