[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [equinox-dev] (no subject)

It would be better if you tell us what you're actually trying to
achieve. Messing around with classloaders is usually not necessary,
unless working with a legacy library that forces you to do it.

Nevertheless, to answer your actual question: if your code is in
"MyClass" then MyClass.class.getClassLoader() will return the
classloader that loaded it -- just as it always does in Java. So if
MyClass is part of a bundle then its classloader will be the bundle
classloader.

Be careful NOT to use "this.getClass().getClassLoader()" because
somebody may subclass your class, in which case "this" will not be the
"this" you thought it was!

Regards
Neil

On Wed, Mar 30, 2011 at 12:04 PM, æç <duanqi25@xxxxxxxxx> wrote:
> Hi everyone,
> ÂÂ Â Â Âcould you please tell me how can I get the ClassLoader of the
> current bundle?It seems the
> Activator.bundleContext.getClass().getClassLoader() can't work.
> ÂÂ Â Looking forward your reply,Thanks.
> _______________________________________________
> equinox-dev mailing list
> equinox-dev@xxxxxxxxxxx
> https://dev.eclipse.org/mailman/listinfo/equinox-dev
>
>