using Kaffe with VisualAge, incompatability with Sun JDK
Godmar Back
gback at cs.utah.edu
Tue Feb 2 13:16:56 PST 1999
>
>
> IBM VisualAge for Java uses the following idiom to launch create a
> bean-based application.
>
> ProjectDemo aProjectDemo;
> Class iiCls = Class.forName("ProjectDemo");
> ClassLoader iiClsLoader = iiCls.getClassLoader();
> aProjectDemo = (ProjectDemo)java.beans.Beans.instantiate(iiClsLoader,"ProjectDemo");
>
> The JDK documentation (chan, lee & kramer) state that
> Class.getClassLoader() should either return the loader for this class
> or null if the default loader was used.
>
> This is what Kaffe does. Note that IBM VA doesn't check for this
> condition (their fault). However, the Sun JDK on my DEC Alpha sez..
>
> iiClsLoader = sun.misc.Launcher$AppClassLoader at 1d8c8e58
>
> when I print the value of iiClsLoader.
Dirk,
we're well aware of the version/compatibility issues with classloaders.
It's all Sun's fault.
In 1.1, applications were not loaded by a classloader. getClassLoader()
returned null. Application classloaders were introduced in 1.2., and
that did indeed break all those applications that relied on being able
to tell whether a class was loaded by the primordial classloader or not
by checking for null. Note that contrary to what Sun claims on their
compatibility page, this was entirely legal prior to 1.2.
>
> I think it would be useful to conform to this convention, otherside
> you can't run IBM VA-based applications w/o changes.
>
There's two possibilities:
+ have getClassLoader() return a dummy loader, such as SystemClassLoader.
This was what we did for a short time, but since it broke 1.1 applications,
we undid that change. The application I was concerned about that time
was Cornell's JKernel.
This is something you can patch easily in Class.java. Change
getClassLoader like so:
public ClassLoader getClassLoader() {
ClassLoader realloader = getClassLoader0();
return (realloader != null? realloader :
SystemClassLoader.getClassLoader());
}
+ implement application classloaders as in 1.2. This will break 1.1 apps,
but hey. They'll either be updated or die anyway.
One of the advantages of being a clone is to be able to pick the raisins
out of the cake in that we don't have to support everything (unlike
Sun with their various compatibility options.) Of course, we do support
old stuff where desired and useful. This is what will eventually happen.
- Godmar
More information about the kaffe
mailing list