[kaffe] Class pool handling
Guilhem Lavaux
guilhem@kaffe.org
Fri Jan 30 12:58:01 2004
Helmer Kr=E4mer wrote:
>On Fri, 30 Jan 2004 19:46:08 +0100
>Guilhem Lavaux <guilhem@kaffe.org> wrote:
>
> =20
>
>>Hi,
>>
>>I'm trying to make ant-1.6.0 work with kaffe and I've stopped on a=20
>>strange problem: it appears that the interface AntMain is loaded twice=20
>>by kaffe. The first time is using the primary class loader, the second=20
>>time using URLClassLoader. This causes the VM to consider the two=20
>>entries concerning AntMain as two interfaces different and so when ant=20
>>tries to cast a class inheriting AntMain there is an exception which is=
=20
>>raised.
>>
>>So my question is: could classes be loaded multiple times if we're usin=
g=20
>>different class loaders (I haven't yet read completely the JLS) ? If=20
>>it's the case we should modify instanceof (in soft.c). If it's not we=20
>>have to modify loadClass (classMethod.c) to look for any existing entry=
=20
>>of a class in the pool.
>> =20
>>
>
>AFAIK, two classes are considered equal iff they have the same
>name and the same class loader (JVM spec =A75.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.
> =20
>
I've seen this but I wasn't sure I had read all paragraphs. ;-)
>Digging in my local tree I think this is what's causing the bug
>in ant:
>
>Index: libraries/javalib/java/security/SecureClassLoader.java
>=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
>RCS file: /cvs/kaffe/kaffe/libraries/javalib/java/security/SecureClassLo=
ader.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 2=
0:45:21 -0000
>@@ -21,7 +21,6 @@
> }
>=20
> protected SecureClassLoader() {
>- this(SecureClassLoader.class.getClassLoader());
> }
>
>Could you try this ?
>
>Regards,
>Helmer
> =20
>
That's much better ! Ant is now starting peacefully.
Thank you,
Guilhem.