db-derby-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Daniel John Debrunner <...@debrunners.com>
Subject Re: context classloader versus default classloader
Date Tue, 22 Nov 2005 23:55:37 GMT
David W. Van Couvering wrote:

> Hi.  I am a little confused between two different "current classloaders"
> that are available to appication code:
> 
> this.getClass().getClassLoader() -- what I call the "default classloader"
> 
> Thread.currentThread.getContextClassLoader() -- what I call the "context
> classloader"
> 
> When I am creating my own classloader, I want to identify the parent
> classloader.  Which one of these should I use?  I noticed that the
> engine code uses the context classloader to load application classes,
> but sets the default classloader to be its parent when creating a
> classloader for loading generated bytecode.
> 
> Any and all tips would be most appreciated.

I guess a lot depends on why you are creating the class loader.

The context class loader is specific to the current thread and can be
short lived. Thus assigning the current thread's context class loader to
an object that can be shared by multiple threads, or one that may live
longer than the current thread seems to make no sense.

Dan.


Mime
View raw message