emul/src/main/java/java/lang/AnnotationImpl.java
branchreflection
changeset 235 bf0a77f029c4
child 236 d97770281580
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/emul/src/main/java/java/lang/AnnotationImpl.java	Sun Dec 02 12:26:14 2012 +0100
     1.3 @@ -0,0 +1,33 @@
     1.4 +/*
     1.5 + * To change this template, choose Tools | Templates
     1.6 + * and open the template in the editor.
     1.7 + */
     1.8 +package java.lang;
     1.9 +
    1.10 +import java.lang.annotation.Annotation;
    1.11 +import org.apidesign.bck2brwsr.core.JavaScriptBody;
    1.12 +
    1.13 +/**
    1.14 + *
    1.15 + * @author Jaroslav Tulach <jtulach@netbeans.org>
    1.16 + */
    1.17 +final class AnnotationImpl implements Annotation {
    1.18 +    public Class<? extends Annotation> annotationType() {
    1.19 +        return getClass();
    1.20 +    }
    1.21 +
    1.22 +    @JavaScriptBody(args = { "a", "n", "values" }, body =
    1.23 +          "var v = values;"
    1.24 +        + "for (p in values) {"
    1.25 +        + "  a[p + 'I'] = function() { return v[p]; }"
    1.26 +        + "}"
    1.27 +        + "a['$instOf_' + n] = true;"
    1.28 +        + "return a;"
    1.29 +    )
    1.30 +    private static <T extends Annotation> T create(AnnotationImpl a, String n, Object values) {
    1.31 +        return null;
    1.32 +    }
    1.33 +    static <T extends Annotation> T create(Class<T> annoClass, Object values) {
    1.34 +        return create(new AnnotationImpl(), annoClass.getName().replace('.', '_'), values);
    1.35 +    }
    1.36 +}