Re: Imported Java lib can't find classes compiled on the fly

2013-03-17 Thread Víctor M . Valenzuela
There's the alternative signature Class.forName(String, boolean,
ClassLoader). I got the Java side to use that instead of a plain
Class.forName, passing it a custom ClassLoader (see my immediately previous
reply).

On Sun, Mar 17, 2013 at 12:38 PM, Marko Topolnik
wrote:

> No built-in Java mechanism (such as Class/forName) relies on the context
> classloader, that's just a mechanism that was supposed to help other
> frameworks manage class loading. Every such framework would have to
> explicitly getContextClassLoader to use it.
>
>
> On Sunday, March 17, 2013 4:05:51 AM UTC+1, vemv wrote:
>
>> My guess is it was set via Thread.currentThread().**
>> setContextClassLoader()...?
>>
>> On Sun, Mar 17, 2013 at 3:07 AM, Víctor M. Valenzuela wrote:
>>
>>> Yeah I was working in that direction now!
>>>
>>> Anyway, how come (Class/forName) can work if used from the repl? My
>>> understanding is that the classloader provided by Class is different from
>>> DynamicClassLoader.
>>>
>>>
>>> On Sun, Mar 17, 2013 at 3:01 AM, Michael Klishin 
>>> wrote:
>>>

 2013/3/17 vemv 

> I guess that somehow the Java library uses a different classloader or
> something like that? Any possible solution?


 Clojure itself uses a separate classloader: a 
 clojure.lang.**DynamicClassLoader
 instance.

 If you can use an instance of that classloader, you should be fine.
 --
 MK

 http://github.com/**michaelklishin 
 http://twitter.com/**michaelklishin 

 --
 --
 You received this message because you are subscribed to the Google
 Groups "Clojure" group.
 To post to this group, send email to clo...@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+u...@**googlegroups.com

 For more options, visit this group at
 http://groups.google.com/**group/clojure?hl=en
 ---
 You received this message because you are subscribed to a topic in the
 Google Groups "Clojure" group.
 To unsubscribe from this topic, visit https://groups.google.com/d/**
 topic/clojure/-n3jul1IeZ8/**unsubscribe?hl=en
 .
  To unsubscribe from this group and all its topics, send an email to
 clojure+u...@**googlegroups.com.

 For more options, visit 
 https://groups.google.com/**groups/opt_out
 .



>>>
>>>
>>  --
> --
> 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
> ---
> You received this message because you are subscribed to a topic in the
> Google Groups "Clojure" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/clojure/-n3jul1IeZ8/unsubscribe?hl=en.
> To unsubscribe from this group and all its topics, send an email to
> clojure+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>

-- 
-- 
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
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Imported Java lib can't find classes compiled on the fly

2013-03-17 Thread Marko Topolnik
No built-in Java mechanism (such as Class/forName) relies on the context 
classloader, that's just a mechanism that was supposed to help other 
frameworks manage class loading. Every such framework would have to 
explicitly getContextClassLoader to use it.

On Sunday, March 17, 2013 4:05:51 AM UTC+1, vemv wrote:
>
> My guess is it was set via 
> Thread.currentThread().setContextClassLoader()...?
>
> On Sun, Mar 17, 2013 at 3:07 AM, Víctor M. Valenzuela 
> 
> > wrote:
>
>> Yeah I was working in that direction now!
>>
>> Anyway, how come (Class/forName) can work if used from the repl? My 
>> understanding is that the classloader provided by Class is different from 
>> DynamicClassLoader.
>>
>>
>> On Sun, Mar 17, 2013 at 3:01 AM, Michael Klishin 
>> 
>> > wrote:
>>
>>>
>>> 2013/3/17 vemv >
>>>
 I guess that somehow the Java library uses a different classloader or 
 something like that? Any possible solution?
>>>
>>>
>>> Clojure itself uses a separate classloader: a 
>>> clojure.lang.DynamicClassLoader instance.
>>>
>>> If you can use an instance of that classloader, you should be fine.
>>> -- 
>>> MK
>>>
>>> http://github.com/michaelklishin
>>> http://twitter.com/michaelklishin
>>>  
>>> -- 
>>> -- 
>>> You received this message because you are subscribed to the Google
>>> Groups "Clojure" group.
>>> To post to this group, send email to clo...@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+u...@googlegroups.com 
>>> For more options, visit this group at
>>> http://groups.google.com/group/clojure?hl=en
>>> --- 
>>> You received this message because you are subscribed to a topic in the 
>>> Google Groups "Clojure" group.
>>> To unsubscribe from this topic, visit 
>>> https://groups.google.com/d/topic/clojure/-n3jul1IeZ8/unsubscribe?hl=en.
>>> To unsubscribe from this group and all its topics, send an email to 
>>> clojure+u...@googlegroups.com .
>>> For more options, visit https://groups.google.com/groups/opt_out.
>>>  
>>>  
>>>
>>
>>
>

-- 
-- 
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
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Imported Java lib can't find classes compiled on the fly

2013-03-17 Thread dennis zhuang
You can make the clojure class loader by yourself:

(import '(clojure.lang RT))
(def class-loader (RT/makeClassLoader))

user=> (.loadClass class-loader "user.Foo")
user.Foo



2013/3/17 vemv 

> Most definitely :) But that something is hard/confusing should'nt be
> enough reason to give up.
>
>
> On Sunday, March 17, 2013 4:11:34 AM UTC+1, James Xu wrote:
>
>> Then things will get complicated and ugly.
>>
>>   原始邮件
>> *发件人:* Víctor M. Valenzuela
>> *收件人:* clojure
>> *发送时间:* 2013年3月17日(周日) 11:05
>> *主题:* Re: Imported Java lib can't find classes compiled on the fly
>>
>> My guess is it was set via Thread.currentThread().**
>> setContextClassLoader()...?
>>
>> On Sun, Mar 17, 2013 at 3:07 AM, Víctor M. Valenzuela wrote:
>>
>>> Yeah I was working in that direction now!
>>>
>>> Anyway, how come (Class/forName) can work if used from the repl? My
>>> understanding is that the classloader provided by Class is different from
>>> DynamicClassLoader.
>>>
>>>
>>> On Sun, Mar 17, 2013 at 3:01 AM, Michael Klishin 
>>> wrote:
>>>
>>>>
>>>> 2013/3/17 vemv 
>>>>
>>>> I guess that somehow the Java library uses a different classloader or
>>>>> something like that? Any possible solution?
>>>>
>>>>
>>>> Clojure itself uses a separate classloader: a 
>>>> clojure.lang.**DynamicClassLoader
>>>> instance.
>>>>
>>>> If you can use an instance of that classloader, you should be fine.
>>>> --
>>>> MK
>>>>
>>>> http://github.com/**michaelklishin <http://github.com/michaelklishin>
>>>> http://twitter.com/**michaelklishin <http://twitter.com/michaelklishin>
>>>>
>>>> --
>>>> --
>>>> You received this message because you are subscribed to the Google
>>>> Groups "Clojure" group.
>>>> To post to this group, send email to clo...@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+u...@**googlegroups.com
>>>>
>>>> For more options, visit this group at
>>>> http://groups.google.com/**group/clojure?hl=en<http://groups.google.com/group/clojure?hl=en>
>>>> ---
>>>> You received this message because you are subscribed to a topic in the
>>>> Google Groups "Clojure" group.
>>>> To unsubscribe from this topic, visit https://groups.google.com/d/**
>>>> topic/clojure/-n3jul1IeZ8/**unsubscribe?hl=en<https://groups.google.com/d/topic/clojure/-n3jul1IeZ8/unsubscribe?hl=en>
>>>> .
>>>>  To unsubscribe from this group and all its topics, send an email to
>>>> clojure+u...@**googlegroups.com.
>>>>
>>>> For more options, visit 
>>>> https://groups.google.com/**groups/opt_out<https://groups.google.com/groups/opt_out>
>>>> .
>>>>
>>>>
>>>>
>>>
>>>
>>  --
>> --
>> You received this message because you are subscribed to the Google
>> Groups "Clojure" group.
>> To post to this group, send email to clo...@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+u...@**googlegroups.com
>>
>> For more options, visit this group at
>> http://groups.google.com/**group/clojure?hl=en<http://groups.google.com/group/clojure?hl=en>
>> ---
>> You received this message because you are subscribed to the Google Groups
>> "Clojure" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to clojure+u...@**googlegroups.com.
>>
>> For more options, visit 
>> https://groups.google.com/**groups/opt_out<https://groups.google.com/groups/opt_out>
>> .
>>
>>
>>
>  --
> --
> 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://gro

Re: Imported Java lib can't find classes compiled on the fly

2013-03-16 Thread vemv
Most definitely :) But that something is hard/confusing should'nt be enough 
reason to give up.

On Sunday, March 17, 2013 4:11:34 AM UTC+1, James Xu wrote:
>
> Then things will get complicated and ugly.
>
>  原始邮件  
> *发件人:* Víctor M. Valenzuela>
> *收件人:* clojure>
> *发送时间:* 2013年3月17日(周日) 11:05
> *主题:* Re: Imported Java lib can't find classes compiled on the fly
>
> My guess is it was set via 
> Thread.currentThread().setContextClassLoader()...?
>
> On Sun, Mar 17, 2013 at 3:07 AM, Víctor M. Valenzuela 
> 
> > wrote:
>
>> Yeah I was working in that direction now!
>>
>> Anyway, how come (Class/forName) can work if used from the repl? My 
>> understanding is that the classloader provided by Class is different from 
>> DynamicClassLoader.
>>
>>
>> On Sun, Mar 17, 2013 at 3:01 AM, Michael Klishin 
>> 
>> > wrote:
>>
>>>
>>> 2013/3/17 vemv >
>>>
>>>> I guess that somehow the Java library uses a different classloader or 
>>>> something like that? Any possible solution?
>>>
>>>
>>> Clojure itself uses a separate classloader: a 
>>> clojure.lang.DynamicClassLoader instance.
>>>
>>> If you can use an instance of that classloader, you should be fine.
>>> -- 
>>> MK
>>>
>>> http://github.com/michaelklishin
>>> http://twitter.com/michaelklishin
>>>  
>>> -- 
>>> -- 
>>> You received this message because you are subscribed to the Google
>>> Groups "Clojure" group.
>>> To post to this group, send email to clo...@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+u...@googlegroups.com 
>>> For more options, visit this group at
>>> http://groups.google.com/group/clojure?hl=en
>>> --- 
>>> You received this message because you are subscribed to a topic in the 
>>> Google Groups "Clojure" group.
>>> To unsubscribe from this topic, visit 
>>> https://groups.google.com/d/topic/clojure/-n3jul1IeZ8/unsubscribe?hl=en.
>>> To unsubscribe from this group and all its topics, send an email to 
>>> clojure+u...@googlegroups.com .
>>> For more options, visit https://groups.google.com/groups/opt_out.
>>>  
>>>  
>>>
>>
>>
>  -- 
> -- 
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send email to clo...@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+u...@googlegroups.com 
> For more options, visit this group at
> http://groups.google.com/group/clojure?hl=en
> --- 
> You received this message because you are subscribed to the Google Groups 
> "Clojure" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to clojure+u...@googlegroups.com. 
> For more options, visit https://groups.google.com/groups/opt_out.
>  
>  
>

-- 
-- 
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
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Imported Java lib can't find classes compiled on the fly

2013-03-16 Thread xumingming64398966
Then things will get complicated and ugly. 原始邮件 发件人: Víctor M. Valenzuela收件人: clojure发送时间: 2013年3月17日(周日) 11:05主题: Re: Imported Java lib can't find classes compiled on the flyMy guess is it was set via Thread.currentThread().setContextClassLoader()...?On Sun, Mar 17, 2013 at 3:07 AM, Víctor M. Valenzuela  wrote:
Yeah I was working in that direction now!Anyway, how come (Class/forName) can work if used from the repl? My understanding is that the classloader provided by Class is different from DynamicClassLoader.

On Sun, Mar 17, 2013 at 3:01 AM, Michael Klishin  wrote:

2013/3/17 vemv 



I guess that somehow the Java library uses a different classloader or something like that? Any possible solution?Clojure itself uses a separate classloader: a clojure.lang.DynamicClassLoader instance.



If you can use an instance of that classloader, you should be fine.-- MKhttp://github.com/michaelklishin

http://twitter.com/michaelklishin






-- 
-- 
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
--- 
You received this message because you are subscribed to a topic in the Google Groups "Clojure" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/clojure/-n3jul1IeZ8/unsubscribe?hl=en.
To unsubscribe from this group and all its topics, send an email to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 





-- 
-- 
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
--- 
You received this message because you are subscribed to the Google Groups "Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 





-- 
-- 
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
--- 
You received this message because you are subscribed to the Google Groups "Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 


Re: Imported Java lib can't find classes compiled on the fly

2013-03-16 Thread Víctor M . Valenzuela
My guess is it was set via
Thread.currentThread().setContextClassLoader()...?

On Sun, Mar 17, 2013 at 3:07 AM, Víctor M. Valenzuela  wrote:

> Yeah I was working in that direction now!
>
> Anyway, how come (Class/forName) can work if used from the repl? My
> understanding is that the classloader provided by Class is different from
> DynamicClassLoader.
>
>
> On Sun, Mar 17, 2013 at 3:01 AM, Michael Klishin <
> michael.s.klis...@gmail.com> wrote:
>
>>
>> 2013/3/17 vemv 
>>
>>> I guess that somehow the Java library uses a different classloader or
>>> something like that? Any possible solution?
>>
>>
>> Clojure itself uses a separate classloader: a
>> clojure.lang.DynamicClassLoader instance.
>>
>> If you can use an instance of that classloader, you should be fine.
>> --
>> MK
>>
>> http://github.com/michaelklishin
>> http://twitter.com/michaelklishin
>>
>> --
>> --
>> 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
>> ---
>> You received this message because you are subscribed to a topic in the
>> Google Groups "Clojure" group.
>> To unsubscribe from this topic, visit
>> https://groups.google.com/d/topic/clojure/-n3jul1IeZ8/unsubscribe?hl=en.
>> To unsubscribe from this group and all its topics, send an email to
>> clojure+unsubscr...@googlegroups.com.
>> For more options, visit https://groups.google.com/groups/opt_out.
>>
>>
>>
>
>

-- 
-- 
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
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Imported Java lib can't find classes compiled on the fly

2013-03-16 Thread Víctor M . Valenzuela
Yeah I was working in that direction now!

Anyway, how come (Class/forName) can work if used from the repl? My
understanding is that the classloader provided by Class is different from
DynamicClassLoader.

On Sun, Mar 17, 2013 at 3:01 AM, Michael Klishin <
michael.s.klis...@gmail.com> wrote:

>
> 2013/3/17 vemv 
>
>> I guess that somehow the Java library uses a different classloader or
>> something like that? Any possible solution?
>
>
> Clojure itself uses a separate classloader: a
> clojure.lang.DynamicClassLoader instance.
>
> If you can use an instance of that classloader, you should be fine.
> --
> MK
>
> http://github.com/michaelklishin
> http://twitter.com/michaelklishin
>
> --
> --
> 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
> ---
> You received this message because you are subscribed to a topic in the
> Google Groups "Clojure" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/clojure/-n3jul1IeZ8/unsubscribe?hl=en.
> To unsubscribe from this group and all its topics, send an email to
> clojure+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>

-- 
-- 
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
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Imported Java lib can't find classes compiled on the fly

2013-03-16 Thread Michael Klishin
2013/3/17 vemv 

> I guess that somehow the Java library uses a different classloader or
> something like that? Any possible solution?


Clojure itself uses a separate classloader: a
clojure.lang.DynamicClassLoader instance.

If you can use an instance of that classloader, you should be fine.
-- 
MK

http://github.com/michaelklishin
http://twitter.com/michaelklishin

-- 
-- 
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
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Imported Java lib can't find classes compiled on the fly

2013-03-16 Thread vemv
Related with my immediately previous question (generate static methods at 
runtime),
 
but not the same.

There's a Java lib which I import and run from a Clojure repl. In that 
repl, if I perform e.g. (defrecord Foo []), then I can succesfully run 
(Class/forName 
"user.Foo").

But if then the Java code gets to execute Class.forName("user.Foo"); it 
will complain that it can't find the class.

I guess that somehow the Java library uses a different classloader or 
something like that? Any possible solution?

Thanks - Victor

-- 
-- 
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
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.