Return null if there is not the requested annotation on a method
authorJaroslav Tulach <jaroslav.tulach@apidesign.org>
Sun, 20 Mar 2016 19:37:07 +0100
changeset 19030267fb5bc8d5
parent 1902 c3dee54ecc15
child 1904 ceb231ab85f6
Return null if there is not the requested annotation on a method
rt/emul/compacttest/src/test/java/org/apidesign/bck2brwsr/tck/ReflectionAnnotationTest.java
rt/emul/mini/src/main/java/java/lang/reflect/Method.java
     1.1 --- a/rt/emul/compacttest/src/test/java/org/apidesign/bck2brwsr/tck/ReflectionAnnotationTest.java	Sun Mar 20 15:26:19 2016 +0100
     1.2 +++ b/rt/emul/compacttest/src/test/java/org/apidesign/bck2brwsr/tck/ReflectionAnnotationTest.java	Sun Mar 20 19:37:07 2016 +0100
     1.3 @@ -167,6 +167,18 @@
     1.4      }
     1.5  
     1.6      @Compare
     1.7 +    public boolean noAnnotationSingle() {
     1.8 +        Annotation arr = ReflectionAnnotationTest.class.getAnnotation(Ann.class);
     1.9 +        return arr == null;
    1.10 +    }
    1.11 +
    1.12 +    @Compare
    1.13 +    public boolean noAnnotationOnMethodSingle() throws Exception {
    1.14 +        Annotation arr = ReflectionAnnotationTest.class.getMethod("noAnnotationOnMethodSingle").getAnnotation(Ann.class);
    1.15 +        return arr == null;
    1.16 +    }
    1.17 +
    1.18 +    @Compare
    1.19      public String noDeclaredAnnotation() {
    1.20          Annotation[] arr = ReflectionAnnotationTest.class.getDeclaredAnnotations();
    1.21          if (arr == null) {
     2.1 --- a/rt/emul/mini/src/main/java/java/lang/reflect/Method.java	Sun Mar 20 15:26:19 2016 +0100
     2.2 +++ b/rt/emul/mini/src/main/java/java/lang/reflect/Method.java	Sun Mar 20 19:37:07 2016 +0100
     2.3 @@ -667,10 +667,11 @@
     2.4  
     2.5      @JavaScriptBody(args = { "ac" }, 
     2.6          body = 
     2.7 -          "var a = this._data().anno;"
     2.8 -        + "if (a) {"
     2.9 -        + "  return a['L' + ac.jvmName + ';'];"
    2.10 -        + "} else return null;"
    2.11 +          "var a = this._data().anno;\n"
    2.12 +        + "if (a) {\n"
    2.13 +        + "  a = a['L' + ac.jvmName + ';'];\n"
    2.14 +        + "}\n"
    2.15 +        + "return a ? a : null;"
    2.16      )
    2.17      private native Object getAnnotationData(Class<?> annotationClass);
    2.18