Return-Path: Delivered-To: apmail-harmony-commits-archive@www.apache.org Received: (qmail 83729 invoked from network); 24 Nov 2007 02:13:06 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 24 Nov 2007 02:13:06 -0000 Received: (qmail 84848 invoked by uid 500); 24 Nov 2007 02:12:54 -0000 Delivered-To: apmail-harmony-commits-archive@harmony.apache.org Received: (qmail 84824 invoked by uid 500); 24 Nov 2007 02:12: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 84806 invoked by uid 99); 24 Nov 2007 02:12:54 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 23 Nov 2007 18:12: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; Sat, 24 Nov 2007 02:13:04 +0000 Received: from brutus (localhost [127.0.0.1]) by brutus.apache.org (Postfix) with ESMTP id 0EADB714159 for ; Fri, 23 Nov 2007 18:12:43 -0800 (PST) Message-ID: <553203.1195870363049.JavaMail.jira@brutus> Date: Fri, 23 Nov 2007 18:12:43 -0800 (PST) From: "Vasily Zakharov (JIRA)" To: commits@harmony.apache.org Subject: [jira] Updated: (HARMONY-5005) [drlvm][kernel][geronimo] Field.getGenericType() fails on a parametrized class from custom classloader In-Reply-To: <14759198.1193110970652.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-5005?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Vasily Zakharov updated HARMONY-5005: ------------------------------------- Patch Info: [Patch Available] > [drlvm][kernel][geronimo] Field.getGenericType() fails on a parametrized class from custom classloader > ------------------------------------------------------------------------------------------------------ > > Key: HARMONY-5005 > URL: https://issues.apache.org/jira/browse/HARMONY-5005 > Project: Harmony > Issue Type: Bug > Components: App-Oriented Bug Reports, DRLVM > Reporter: Vasily Zakharov > Assignee: Gregory Shimansky > Priority: Critical > Attachments: 01-H5005-formatting.patch, 02-H5005.patch > > > java.lang.reflect.Field.getGenericType() fails if the field it's called upon is a parametrized class unavailable through the system class loader. To reproduce use the following code: > import java.lang.reflect.*; > import java.net.*; > public class Test { > public static void main(String[] args) { > try { > ClassLoader loader = new URLClassLoader(new URL[] { new URL("file:foo.jar") } ); > Class cls = loader.loadClass("Foo"); > Field field = cls.getDeclaredField("field"); > Type type = field.getGenericType(); > System.out.println("SUCCESS: " + type); > } catch (Exception e) { > e.printStackTrace(System.out); > } > } > } > class Foo { > java.util.List field; > } > After compilation create a foo.jar containing Foo.class and then make sure to remove Foo.class file: > $ jar cvf foo.jar Foo.class > $ rm Foo.class > $ java Test > Output on RI: > SUCCESS: java.util.List > Output on Harmony: > java.lang.TypeNotPresentException: Type Foo not present > at org.apache.harmony.lang.reflect.support.AuxiliaryCreator.createTypeArgs(AuxiliaryCreator.java:216) > at org.apache.harmony.lang.reflect.parser.Parser.parseFieldGenericType(Parser.java:358) > at java.lang.reflect.Field.getGenericType(Field.java:72) > at Test.main(Test.java:9) > Caused by: java.lang.ClassNotFoundException: Foo > at org.apache.harmony.lang.reflect.support.AuxiliaryLoader.findClass(AuxiliaryLoader.java:119) > at org.apache.harmony.lang.reflect.support.AuxiliaryCreator.createTypeArg(AuxiliaryCreator.java:192) > at org.apache.harmony.lang.reflect.support.AuxiliaryCreator.createTypeArgs(AuxiliaryCreator.java:214) > at org.apache.harmony.lang.reflect.parser.Parser.parseFieldGenericType(Parser.java:358) > ... 2 more > My guess is the problem lies in AuxiliaryLoader.findClass() method, line 67 - the method explicitly uses system class loader to load the target class, which clearly fails if the target class is available through some other classloader. It seems logical to use the classloader of the class whose field is being processed instead. However, the fix seems non-trivial as in the existing architecture the information on the containing class is lost when Parser is called. > 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.