[kaffe] Class pool handling

Helmer Krämer hkraemer at freenet.de
Fri Jan 30 12:51:02 PST 2004

On Fri, 30 Jan 2004 19:46:08 +0100
Guilhem Lavaux <guilhem at kaffe.org> wrote:

> Hi,
> I'm trying to make ant-1.6.0 work with kaffe and I've stopped on a 
> strange problem: it appears that the interface AntMain is loaded twice 
> by kaffe. The first time is using the primary class loader, the second 
> time using URLClassLoader. This causes the VM to consider the two 
> entries concerning AntMain as two interfaces different and so when ant 
> tries to cast a class inheriting AntMain there is an exception which is 
> raised.
> So my question is: could classes be loaded multiple times if we're using 
> different class loaders (I haven't yet read completely the JLS) ? If 
> it's the case we should modify instanceof (in soft.c). If it's not we 
> have to modify loadClass (classMethod.c) to look for any existing entry 
> of a class in the pool.

AFAIK, two classes are considered equal iff they have the same
name and the same class loader (JVM spec §5.3). So instanceof
in soft.c is ok. Searching the whole class pool for a class is
also wrong since it would violate the class loader hierarchy.

Digging in my local tree I think this is what's causing the bug
in ant:

Index: libraries/javalib/java/security/SecureClassLoader.java
RCS file: /cvs/kaffe/kaffe/libraries/javalib/java/security/SecureClassLoader.java,v
retrieving revision 1.4
diff -u -r1.4 SecureClassLoader.java
--- libraries/javalib/java/security/SecureClassLoader.java	6 Aug 2002 10:45:32 -0000	1.4
+++ libraries/javalib/java/security/SecureClassLoader.java	30 Jan 2004 20:45:21 -0000
@@ -21,7 +21,6 @@
 	protected SecureClassLoader() {
-		this(SecureClassLoader.class.getClassLoader());

Could you try this ?


More information about the kaffe mailing list