Return-Path: Delivered-To: apmail-harmony-commits-archive@www.apache.org Received: (qmail 1904 invoked from network); 22 Nov 2007 10:18:06 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 22 Nov 2007 10:18:06 -0000 Received: (qmail 60031 invoked by uid 500); 22 Nov 2007 10:17:54 -0000 Delivered-To: apmail-harmony-commits-archive@harmony.apache.org Received: (qmail 60010 invoked by uid 500); 22 Nov 2007 10:17:54 -0000 Mailing-List: contact commits-help@harmony.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@harmony.apache.org Delivered-To: mailing list commits@harmony.apache.org Received: (qmail 60001 invoked by uid 99); 22 Nov 2007 10:17:54 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 22 Nov 2007 02:17:54 -0800 X-ASF-Spam-Status: No, hits=-100.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO brutus.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 22 Nov 2007 10:18:04 +0000 Received: from brutus (localhost [127.0.0.1]) by brutus.apache.org (Postfix) with ESMTP id 0852F714201 for ; Thu, 22 Nov 2007 02:17:43 -0800 (PST) Message-ID: <4053429.1195726663024.JavaMail.jira@brutus> Date: Thu, 22 Nov 2007 02:17:43 -0800 (PST) From: "Alexey Varlamov (JIRA)" To: commits@harmony.apache.org Subject: [jira] Commented: (HARMONY-5086) [drlvm][kernel][geronimo] AnnotatedElement.getDeclaredAnnotations() throws exception if annotation is not available In-Reply-To: <1408907.1194477170675.JavaMail.jira@brutus> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-Virus-Checked: Checked by ClamAV on apache.org [ https://issues.apache.org/jira/browse/HARMONY-5086?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12544753 ] Alexey Varlamov commented on HARMONY-5086: ------------------------------------------ Vasily, this behavior is as expected, you may find the specification in j.l.reflect.AnnotatedElement description. And rationale behind this is the same as for this issue, to allow inspecting remaining annotations on an element even if some annotation/value is unavailable. > [drlvm][kernel][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.