----- Original Message -----
Sent: Friday, December 17, 2004 10:59
AM
Subject: Classloaders and classes already
loaded
1.) Just change
the Mac launcher to include /System/Library/Java and don't use a "custom"
class loader.
I think this is
actually the recommended approach or generally suggested approach for
Cocoa/Java?
2.) Is there a way
to unload the native library or class loader?
Just come up with
a new one is generally easier. It might be easier to direct your processing to
the correct classloader. Reflection can be handy in working with multiples as
casting or creating new instances with the incorrect class loader can lead to
IllegalAccessException's or ClassCastError's.
Basically though
you need to be sure you pass the initial class load to the correct loader. All
requests to resolve subsequent classes off that should automatically go to the
right one after that.
3.) Is there a way
to ask if a class is loaded, and if so, then create an instance of it, even
though I don't have the class loader?
You can get the
ClassLoader for any object with....
obj.getClass().getClassLoader();
So anytime you
have a class you can get it's loader. Even static Class for names should get
passed to whatever the default classloader is and you can find that as well
from the obtained class. The very primordial classloader might return as null
in some instances, been a while - just remembered that. Since its the default
you shouldn't need to anything special to load a class of that though..
Mike
Hall mikehall at spacestar dot
net