Re: Clojure in OSGi and *use-context-classloader*

2012-11-16 Thread Nick Mudge
Hi there,
Thanks for your post. I had the same problem and your solution is what I 
need.

To answer your question, USE_CONTEXT_CLASSLOADER still returns true in the 
following method (which is also in RT.java) because it is being bound to 
true when making a DynamicClassLoader:

static public ClassLoader makeClassLoader(){
return (ClassLoader) AccessController.doPrivileged(new PrivilegedAction(){
public Object run(){
try{
Var.pushThreadBindings(RT.map(USE_CONTEXT_CLASSLOADER, RT.T));
// getRootClassLoader();
return new DynamicClassLoader(baseLoader());
}
finally{
Var.popThreadBindings();
}
}
});
}

So what I did was change the binding to RT.map(USE_CONTEXT_CLASSLOADER, 
RT.F), and that works.

On Saturday, June 30, 2012 3:03:02 PM UTC-7, Maris wrote:
>
>
> I am using clojure in apache karaf which has Thread context class loader 
> set to karaf jars.
>
> I changed use-context-classloader to false in RT.java:
>
> final static public Var USE_CONTEXT_CLASSLOADER =
> Var.intern(CLOJURE_NS, Symbol.intern("*use-context-classloader*"), 
> F).setDynamic();
>
> For some reason booleanCast(USE_CONTEXT_CLASSLOADER.deref()) doesn't 
> always return false  and RT still managed to create DynamicClassloader with 
> thread context classloader as parent.  Of course,   it wasn't able to 
> find any clojure classes.
>
> To make it work I commented out this line in baseLoader() method.
>
> else if (booleanCast(USE_CONTEXT_CLASSLOADER.deref())) {
> return Thread.currentThread().getContextClassLoader();
> }
>
> Why booleanCast(USE_CONTEXT_CLASSLOADER.deref()) doesn't always return 
> false ? 
>
>

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Re: Clojure in OSGi and *use-context-classloader*

2012-07-02 Thread Jacek Laskowski
On Sun, Jul 1, 2012 at 12:03 AM, Maris  wrote:

> Why booleanCast(USE_CONTEXT_CLASSLOADER.deref()) doesn't always return false
> ?

Could it be that you run multiple threads and the var is true in a
thread and false in the other? Just a guess.

Jacek

-- 
Jacek Laskowski
Functional languages (Clojure), Java EE, and IBM WebSphere -
http://blog.japila.pl
"Never discourage anyone who continually makes progress, no matter how
slow." Plato

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Clojure in OSGi and *use-context-classloader*

2012-06-30 Thread Maris

I am using clojure in apache karaf which has Thread context class loader 
set to karaf jars.

I changed use-context-classloader to false in RT.java:

final static public Var USE_CONTEXT_CLASSLOADER =
Var.intern(CLOJURE_NS, Symbol.intern("*use-context-classloader*"), 
F).setDynamic();

For some reason booleanCast(USE_CONTEXT_CLASSLOADER.deref()) doesn't always 
return false  and RT still managed to create DynamicClassloader with thread 
context 
classloader as parent.  Of course,   it wasn't able to find any clojure 
classes.

To make it work I commented out this line in baseLoader() method.

else if (booleanCast(USE_CONTEXT_CLASSLOADER.deref())) {
return Thread.currentThread().getContextClassLoader();
}

Why booleanCast(USE_CONTEXT_CLASSLOADER.deref()) doesn't always return 
false ? 

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en