db-jdo-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Erik Bengtson <e...@jpox.org>
Subject class loading issue when super class has reference to sub class
Date Sat, 24 Jun 2006 21:15:25 GMT
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.<clinit>(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.<clinit>(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 <pc-superclass>.jdoGetManagedFieldCount() +
jdoFieldNames.length;
}

Mime
View raw message