Return-Path: Delivered-To: apmail-db-jdo-dev-archive@www.apache.org Received: (qmail 82452 invoked from network); 26 Jun 2006 16:07:19 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 26 Jun 2006 16:07:19 -0000 Received: (qmail 88920 invoked by uid 500); 26 Jun 2006 16:07:19 -0000 Mailing-List: contact jdo-dev-help@db.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: jdo-dev@db.apache.org Delivered-To: mailing list jdo-dev@db.apache.org Received: (qmail 88909 invoked by uid 99); 26 Jun 2006 16:07:19 -0000 Received: from asf.osuosl.org (HELO asf.osuosl.org) (140.211.166.49) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 26 Jun 2006 09:07:19 -0700 X-ASF-Spam-Status: No, hits=0.0 required=10.0 tests= X-Spam-Check-By: apache.org Received-SPF: pass (asf.osuosl.org: local policy) Received: from [212.224.30.66] (HELO service-01.spree.de) (212.224.30.66) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 26 Jun 2006 09:07:18 -0700 Received: from [127.0.0.1] (merlin.spree.de [172.16.1.107]) (authenticated bits=0) by service-01.spree.de (8.13.4/8.13.4/Debian-3) with ESMTP id k5QG6tRu007995; Mon, 26 Jun 2006 18:06:55 +0200 Message-ID: <44A0061F.3040301@spree.de> Date: Mon, 26 Jun 2006 18:06:55 +0200 From: Michael Bouschen Organization: Tech@Spree Engineering User-Agent: Thunderbird 1.5.0.4 (Windows/20060516) MIME-Version: 1.0 To: jdo-dev@db.apache.org CC: JDO Expert Group Subject: Re: class loading issue when super class has reference to sub class References: <1151183725.449dab6d6bcfa@webmail.jpox.org> <002101c697e6$8bc25980$0400000a@ILANC> <1151232907.449e6b8bdb687@webmail.jpox.org> <006401c69851$8842f420$0400000a@ILANC> In-Reply-To: <006401c69851$8842f420$0400000a@ILANC> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Checked: Checked by ClamAV on apache.org X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N Hi, I experimented with classes where I manually added the code that is generated by the enhancer. I could reproduce the class loading issue only with jdk1.4. I do not get an exception when compiling and running the classes with jdk 1.5. I can confirm that replacing the expression jdoFieldNames.length by a constant in the implementation of jdoGetManagedFieldCount solves the problem. Regards Michael > You can still call .jdoGetManagedFieldCount() > (so the super class may be changed without recompiling the subclass) > just replace the jdoFieldNames.length component with a constant. > > Ilan > > > ----- Original Message ----- From: "Erik Bengtson" > To: ; > Sent: Sunday, June 25, 2006 12:55 PM > Subject: Re: class loading issue when super class has reference to sub > class > > >> Thanks Ilan, >> >> I will do this way them, but this requires users to recompile and >> reenhance >> child classes if super classes are changed. >> >> Regards, >> >> Erik Bengtson >> Quoting Ilan Kirsh : >> >>> Hi Erik, >>> >>> I remember similar problems with this enhanced method in the past >>> so I just checked your test with ObjectDB, but now it works well >>> with no exception. >>> >>> The code that is produced by the ObjectDB Enhancer is slightly >>> different >>> and instead of jdoFieldNames.length there is a constant that is >>> calculated >>> at enhancement time. Hopefully this change should do the difference. >>> >>> Regards, >>> >>> Ilan >>> >>> ----- Original Message ----- >>> From: "Erik Bengtson" >>> To: ; >>> Sent: Saturday, June 24, 2006 11:15 PM >>> Subject: class loading issue when super class has reference to sub >>> class >>> >>> >>> > Hi, >>> > >>> > There is an issue when initialising a class when super class has >>> > reference >>> > to >>> > sub class >>> > (Cclass extending Bclass extending Aclass and Aclass has a >>> reference to >>> > Cclass) >>> > >>> > public class Aclass { >>> > private Cclass cclass; >>> > } >>> > public class Bclass extends Aclass { >>> > } >>> > >>> > public class Cclass extends Bclass { >>> > } >>> > >>> > public class Main { >>> > public static void main(String[] args) throws Exception { >>> > //The following line throws ExceptionInInitializerError caused by >>> > java.lang.NullPointerException >>> > System.out.println(Class.forName("org.jpox.test.Bclass")); >>> > } >>> > } >>> > >>> > >>> > Exception in thread "main" java.lang.ExceptionInInitializerError >>> > at java.lang.Class.forName0(Native Method) >>> > at java.lang.Class.forName(Unknown Source) >>> > at org.jpox.test.Aclass.___jdo$loadClass(Aclass.java) >>> > at org.jpox.test.Aclass.__jdoFieldTypesInit(Aclass.java) >>> > at org.jpox.test.Aclass.(Aclass.java) >>> > at java.lang.Class.forName0(Native Method) >>> > at java.lang.Class.forName(Unknown Source) >>> > at org.jpox.test.Main.main(Main.java:6) >>> > Caused by: java.lang.NullPointerException >>> > at org.jpox.test.Bclass.jdoGetManagedFieldCount(Bclass.java) >>> > at org.jpox.test.Cclass.__jdoGetInheritedFieldCount(Cclass.java) >>> > at org.jpox.test.Cclass.(Cclass.java) >>> > ... 8 more >>> > >>> > >>> > See for a diagram >>> > http://www.jpox.org/servlet/jira/browse/ENHANCER-58 >>> > >>> > >>> > The issue is due to the implementation of the jdoGetManagedFieldCount >>> > >>> > The implementation for topmost classes in the hierarchy: >>> > protected static int jdoGetManagedFieldCount () { >>> > return jdoFieldNames.length; >>> > } >>> > The implementation for subclasses: >>> > protected static int jdoGetManagedFieldCount () { >>> > return .jdoGetManagedFieldCount() + >>> > jdoFieldNames.length; >>> > } >>> > >>> > >>> > >>> >>> >>> >> >> >> >> >> >> > -- Michael Bouschen Tech@Spree Engineering GmbH mailto:mbo.tech@spree.de http://www.tech.spree.de/ Tel.:++49/30/235 520-33 Buelowstr. 66 Fax.:++49/30/2175 2012 D-10783 Berlin