1.1 --- a/emul/src/main/java/java/lang/reflect/Method.java Wed Dec 05 09:28:31 2012 +0100
1.2 +++ b/emul/src/main/java/java/lang/reflect/Method.java Wed Dec 05 10:03:58 2012 +0100
1.3 @@ -27,6 +27,7 @@
1.4
1.5 import java.lang.annotation.Annotation;
1.6 import org.apidesign.bck2brwsr.core.JavaScriptBody;
1.7 +import org.apidesign.bck2brwsr.emul.AnnotationImpl;
1.8
1.9 /**
1.10 * A {@code Method} provides information about, and access to, a single method
1.11 @@ -535,15 +536,23 @@
1.12 return Modifier.isSynthetic(getModifiers());
1.13 }
1.14
1.15 + @JavaScriptBody(args = { "self", "ac" },
1.16 + body =
1.17 + "if (self.fld_data.anno) {"
1.18 + + " return self.fld_data.anno['L' + ac.jvmName + ';'];"
1.19 + + "} else return null;"
1.20 + )
1.21 + private Object getAnnotationData(Class<?> annotationClass) {
1.22 + throw new UnsupportedOperationException();
1.23 + }
1.24 +
1.25 /**
1.26 * @throws NullPointerException {@inheritDoc}
1.27 * @since 1.5
1.28 */
1.29 public <T extends Annotation> T getAnnotation(Class<T> annotationClass) {
1.30 - if (annotationClass == null)
1.31 - throw new NullPointerException();
1.32 -
1.33 - throw new UnsupportedOperationException();
1.34 + Object data = getAnnotationData(annotationClass);
1.35 + return data == null ? null : AnnotationImpl.create(annotationClass, data);
1.36 }
1.37
1.38 /**