Return-Path: Delivered-To: apmail-harmony-commits-archive@www.apache.org Received: (qmail 28768 invoked from network); 26 Nov 2007 12:33:16 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 26 Nov 2007 12:33:16 -0000 Received: (qmail 43163 invoked by uid 500); 26 Nov 2007 12:33:04 -0000 Delivered-To: apmail-harmony-commits-archive@harmony.apache.org Received: (qmail 43140 invoked by uid 500); 26 Nov 2007 12:33:04 -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 43131 invoked by uid 99); 26 Nov 2007 12:33:04 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 26 Nov 2007 04:33:04 -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; Mon, 26 Nov 2007 12:33:06 +0000 Received: from brutus (localhost [127.0.0.1]) by brutus.apache.org (Postfix) with ESMTP id 00BC5714231 for ; Mon, 26 Nov 2007 04:32:45 -0800 (PST) Message-ID: <30451439.1196080365000.JavaMail.jira@brutus> Date: Mon, 26 Nov 2007 04:32:44 -0800 (PST) From: "Vasily Zakharov (JIRA)" To: commits@harmony.apache.org Subject: [jira] Closed: (HARMONY-5180) [drlvm][kernel][geronimo] Annotations get loaded with wrong classloader In-Reply-To: <10311965.1195870363467.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-5180?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Vasily Zakharov closed HARMONY-5180. ------------------------------------ Alexey, thank you very much for the quick fix! The problem is resolved, closing the issue. > [drlvm][kernel][geronimo] Annotations get loaded with wrong classloader > ----------------------------------------------------------------------- > > Key: HARMONY-5180 > URL: https://issues.apache.org/jira/browse/HARMONY-5180 > Project: Harmony > Issue Type: Bug > Components: App-Oriented Bug Reports, DRLVM > Reporter: Vasily Zakharov > Assignee: Alexey Varlamov > Priority: Critical > > Consider the following test: > Test.java: > import java.net.*; > public class Test { > public static void main(String[] args) { > try { > ClassLoader loader = new URLClassLoader(new URL[] { new URL("file:run.jar") } ); > loader.loadClass("Run").getMethod("run").invoke(null); > System.out.println("SUCCESS"); > } catch (Exception e) { > e.printStackTrace(System.out); > } > } > } > Run.java: > import java.lang.annotation.*; > import java.lang.reflect.*; > import java.net.*; > public class Run { > public static void run() throws Exception { > ClassLoader loader = new URLClassLoader(new URL[] { new URL("file:foo.jar") } ); > Class cls = loader.loadClass("Foo"); > Field field = cls.getDeclaredField("field"); > Annotation ann = field.getDeclaredAnnotations()[0]; > Class annClass = ann.getClass(); > Method method = annClass.getMethod("value"); > Class ret = (Class) method.invoke(ann); > System.out.println("Ann: " + ret.getName()); > } > } > @Retention(RetentionPolicy.RUNTIME) > @interface Ann { > Class value(); > } > class Bar {} > class Foo { > @Ann(Bar.class) int field; > } > Use the following sequence to build and run: > $ javac Test.java Run.java > $ jar cvf run.jar Run.class > $ jar cvf foo.jar Foo.class Bar.class > $ rm Run.class Foo.class Bar.class > $ java Test > Make sure to remove all class files except Test.class and Ann.class, or the test would behave incorrectly. > Output on RI: > Ann: Bar > SUCCESS > Output on DRLVM: > java.lang.reflect.InvocationTargetException > at java.lang.reflect.VMReflection.invokeMethod(VMReflection.java) > at java.lang.reflect.Method.invoke(Method.java:317) > at Test.main(Test.java:6) > Caused by: java.lang.reflect.InvocationTargetException > at java.lang.reflect.VMReflection.invokeMethod(VMReflection.java) > at java.lang.reflect.Method.invoke(Method.java:317) > at Run.run(Run.java:12) > at java.lang.reflect.VMReflection.invokeMethod(VMReflection.java) > ... 2 more > Caused by: java.lang.TypeNotPresentException: Type Bar not present > at org.apache.harmony.lang.annotation.AnnotationMember.rethrowError(AnnotationMember.java:298) > at org.apache.harmony.lang.annotation.AnnotationMember.validateValue(AnnotationMember.java:341) > at org.apache.harmony.lang.annotation.AnnotationFactory.invoke(AnnotationFactory.java:311) > at .$Proxy0.value(Unknown Source) > at java.lang.reflect.VMReflection.invokeMethod(VMReflection.java) > ... 5 more > Caused by: java.lang.NoClassDefFoundError: Bar > 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 Run.run(Run.java:9) > at java.lang.reflect.VMReflection.invokeMethod(VMReflection.java) > ... 2 more > Caused by: java.lang.ClassNotFoundException: Bar > 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) > ... 6 more > We have the following 5 classes: > Test: loads and accesses Run > Run: loads and accesses Foo > Foo: is annotated by Ann > Ann: has a value of class Bar > Bar: dummy > loaded by the following 3 class loaders: > System: Test, Ann > run.jar: Run > foo.jar: Foo, Bar > The problem is when resolving the field annotation value, DRLVM uses the class loader of the annotation class Ann (in this test, system class loader, which has no access to Bar), instead of the class loader of the containing class Foo. > 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.