Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Classloaders and classes already loaded



Title: Message
 
----- Original Message -----
From: Mark Brown
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
 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Java-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/java-dev/email@hidden

This email sent to email@hidden

References: 
 >Classloaders and classes already loaded (From: "Mark Brown" <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.