1.1 --- a/rt/emul/mini/src/main/java/java/lang/reflect/Method.java Sun Aug 02 11:56:45 2015 +0200
1.2 +++ b/rt/emul/mini/src/main/java/java/lang/reflect/Method.java Sun Mar 20 09:05:43 2016 +0100
1.3 @@ -672,9 +672,20 @@
1.4 + " return a['L' + ac.jvmName + ';'];"
1.5 + "} else return null;"
1.6 )
1.7 - private Object getAnnotationData(Class<?> annotationClass) {
1.8 - throw new UnsupportedOperationException();
1.9 - }
1.10 + private native Object getAnnotationData(Class<?> annotationClass);
1.11 +
1.12 + @JavaScriptBody(args = {},
1.13 + body =
1.14 + "var a = this._data().anno;\n"
1.15 + + "if (a) {\n"
1.16 + + " var arr = [];\n"
1.17 + + " for (p in a) {\n"
1.18 + + " arr.push(p);\n"
1.19 + + " }\n"
1.20 + + " return arr;\n"
1.21 + + "} else return [];\n"
1.22 + )
1.23 + private native String[] getAnnotationNames();
1.24
1.25 /**
1.26 * @throws NullPointerException {@inheritDoc}
1.27 @@ -689,7 +700,19 @@
1.28 * @since 1.5
1.29 */
1.30 public Annotation[] getDeclaredAnnotations() {
1.31 - throw new UnsupportedOperationException();
1.32 + String[] arr = getAnnotationNames();
1.33 + Annotation[] res = new Annotation[arr.length];
1.34 + for (int i = 0; i < arr.length; i++) {
1.35 + String forName = arr[i].substring(1, arr[i].length() - 1).replace('/', '.');
1.36 + final Class<? extends Annotation> annoType;
1.37 + try {
1.38 + annoType = Class.forName(forName).asSubclass(Annotation.class);
1.39 + } catch (ClassNotFoundException ex) {
1.40 + throw new IllegalStateException(forName);
1.41 + }
1.42 + res[i] = getAnnotation(annoType);
1.43 + }
1.44 + return res;
1.45 }
1.46
1.47 /**