[ 
http://issues.apache.org/jira/browse/DERBY-1075?page=comments#action_12371362 ] 

David Van Couvering commented on DERBY-1075:
--------------------------------------------

This is a very common misunderstanding of setContextClassLoader, and one that 
has thrown many of us, including myself, for quite a loop.  It turns out that 
setContextClassLoader() is of *absolutely no use* unless someone later on in 
the same thread decides to grab it using getContextClassLoader() and use it.  
It appears to be most commonly used by application servers, who want to use a 
separate classloader for each thread.

That said, it is worth noting that 
org.apache.derby.impl.services.reflect.ReflectClassesJava2 appears to use 
getContextClassLoader.  It appears to be used to load classes that are not in 
derby.jar (e.g. application classes), I *think* if the class can't be found by 
the default classloader.   I'm not sure if this is the right thing to do, but 
this is what it does.  You might just try not setting the context classloader 
and see what happens, but I guess if you want to be safe you might as well go 
and set it.

But you're right, the way to get a class to use a specific classloader as its 
*default* classloader (which is *different* from the context classloader) is to 
use Class.forName() or otherwise explicitly load that class using the 
classloader you want.  Then whenever it does "new" it uses that classloader.

I'll attach the code, once I find it.

> Combine the script and the test available for upgrade testing into a java test
> ------------------------------------------------------------------------------
>
>          Key: DERBY-1075
>          URL: http://issues.apache.org/jira/browse/DERBY-1075
>      Project: Derby
>         Type: Sub-task
>     Reporter: Deepa Remesh
>     Assignee: Deepa Remesh
>     Priority: Minor
>      Fix For: 10.2.0.0
>  Attachments: derby-1075-patch1-draft.diff, derby-1075-patch1-draft.status, 
> derby-1075-v1.diff, derby-1075-v1.status, loader.java, loader_v2.java
>
> Separating a part of DERBY-514 into a sub-task. This sub-task is to combine 
> the script 'runphases.ksh' and the java file 'phaseTester.java' into a single 
> java test. This will help to later add the upgrade tests into the regression 
> suite. Also, this sub-task can be done independent of DERBY-1049 which is 
> blocking DERBY-514.

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira

Reply via email to