harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Alexey Varlamov (JIRA)" <j...@apache.org>
Subject [jira] Updated: (HARMONY-5086) [drlvm][geronimo] AnnotatedElement.getDeclaredAnnotations() throws exception if annotation is not available
Date Fri, 16 Nov 2007 11:20:43 GMT

     [ https://issues.apache.org/jira/browse/HARMONY-5086?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]

Alexey Varlamov updated HARMONY-5086:
-------------------------------------

    Attachment: H5086test.diff
                H5086fix.diff

Vladimir, the patch reflected my suggestion just rigth, thank you.
But, while reviewing the patch I realized that my evaluation was not accurate:
it is incorrect to clear any throwable when processing annotations, there are myriads of other
reasons to fail besides unresolved annotation type (from AnnotationFormatError to any JVM
failure like OOME or SOE). 
So I re-worked your patch, and fixed relevant testcase testGetAnnotations4(). 

There are some more place to think about, I added few FIXMEs.

> [drlvm][geronimo] AnnotatedElement.getDeclaredAnnotations() throws exception if annotation
is not available
> -----------------------------------------------------------------------------------------------------------
>
>                 Key: HARMONY-5086
>                 URL: https://issues.apache.org/jira/browse/HARMONY-5086
>             Project: Harmony
>          Issue Type: Bug
>          Components: App-Oriented Bug Reports, DRLVM
>            Reporter: Vasily Zakharov
>            Assignee: Alexey Varlamov
>            Priority: Critical
>         Attachments: H5086.patch, H5086fix.diff, H5086test.diff
>
>
> When AccessibleObject.getDeclaredAnnotations() is called and the annotation class to
be returned cannot be loaded, RI just skips that annotation, and Harmony throws exception.
> To reproduce, use the following code:
> import java.lang.annotation.*;
> import java.lang.reflect.*;
> import java.net.*;
> public class Test {
>     public static void main(String[] args) {
>         try {
>             Class cls = Foo.class;
>             Field field = cls.getDeclaredFields()[0];
>             Constructor constructor = cls.getDeclaredConstructors()[0];
>             Method method = cls.getDeclaredMethods()[0];
>             int can = cls.getDeclaredAnnotations().length;
>             int fan = field.getDeclaredAnnotations().length;
>             int nan = constructor.getDeclaredAnnotations().length;
>             int man = method.getDeclaredAnnotations().length;
>             System.out.println("SUCCESS: " + can + " " + fan + " " + nan + " " + man);
>         } catch (Exception e) {
>             e.printStackTrace(System.out);
>         }
>     }
> }
> @Retention(RetentionPolicy.RUNTIME)
> @interface Ann {}
> @Ann class Foo {
>     @Ann int field;
>     @Ann Foo() {}
>     @Ann void method() {}
> }
> If the test is run normally, both RI and Harmony produce the same result, but if Ann.class
file is REMOVED, the output becomes different.
> Output on RI and Harmony with Ann.class present:
> SUCCESS: 1 1 1
> Output on RI with Ann.class removed:
> SUCCESS: 0 0 0
> Output on Harmony with Ann.class removed:
> java.lang.TypeNotPresentException: Type Ann not present
>         at org.apache.harmony.vm.VMGenericsAndAnnotations.getDeclaredAnnotations(VMGenericsAndAnnotations.java)
>         at java.lang.reflect.Field$FieldData.getAnnotations(Field.java:457)
>         at java.lang.reflect.Field.getDeclaredAnnotations(Field.java:42)
>         at Test.main(Test.java:11)
> Caused by: java.lang.NoClassDefFoundError: Ann
>         at org.apache.harmony.vm.VMGenericsAndAnnotations.getDeclaredAnnotations(VMGenericsAndAnnotations.java)
>         ... 3 more
> Caused by: java.lang.ClassNotFoundException: Ann
>         at java.net.URLClassLoader.findClass(URLClassLoader.java:894)
>         at java.lang.ClassLoader.loadClass(ClassLoader.java:575)
>         at java.lang.ClassLoader$SystemClassLoader.loadClass(ClassLoader.java:963)
>         at java.lang.ClassLoader.loadClass(ClassLoader.java:319)
>         at org.apache.harmony.vm.VMGenericsAndAnnotations.getDeclaredAnnotations(VMGenericsAndAnnotations.java)
>         ... 3 more
> This issue prevents Apache Geronimo 2.0 from starting on Harmony. 

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


Mime
View raw message