You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@harmony.apache.org by galaxy <ti...@gmail.com> on 2009/08/05 09:41:23 UTC

About the jre classloader

Hi all
I have a question about the jre classloader .
In my work of jre osgi , I have to implement a new classloader to load the
classes since the
classloading mechanism is very different from the default one .
So I am thinking of the
Thread.currentThread().setContextClassloader(myclassloader),
but this is not very useful.
for example [1] , the stdout will print systemclassloader or null depends on
the class to load ..
So how to make sure that a " new ClassLoader " will use my classloader
instead of loading every one using myClassLoader.loadClass(String)

[1]
Thread.currentThread().setContextClassloader(myclassloader),
ClassType object = new ClassType();
system.out.println(object.getClass().getClassLoader())




-- 
regards
Tian

Re: About the jre classloader

Posted by Pavel Pervov <pm...@gmail.com>.
You can replace it from command line.

2009/8/6, galaxy <ti...@gmail.com>:
> Could we have a method to replace the system classloader dynamically  ?
>
> 2009/8/5 Pavel Pervov <pm...@gmail.com>
>
>> For application classes - replace system classloader. For jre classes
>> - implement osgi in VM's bootstrap classloader.
>>
>> 2009/8/5, galaxy <ti...@gmail.com>:
>> > Hi, Pavel
>> > Thanks for the reply .
>> > So how could I make my classloader to execute the new ?
>> >
>> > 2009/8/5 Pavel Pervov <pm...@gmail.com>
>> >
>> >> Hello, Tian.
>> >> Thread context classloader is not used on new opcode. The initiating
>> >> class loader of ClassType will be the class loader, which executes new
>> >> instead. The defining loader will depend on the class being loaded and
>> >> VM setup.
>> >>
>> >> 2009/8/5, galaxy <ti...@gmail.com>:
>> >> > Hi all
>> >> > I have a question about the jre classloader .
>> >> > In my work of jre osgi , I have to implement a new classloader to
>> >> > load
>> >> the
>> >> > classes since the
>> >> > classloading mechanism is very different from the default one .
>> >> > So I am thinking of the
>> >> > Thread.currentThread().setContextClassloader(myclassloader),
>> >> > but this is not very useful.
>> >> > for example [1] , the stdout will print systemclassloader or null
>> >> > depends
>> >> on
>> >> > the class to load ..
>> >> > So how to make sure that a " new ClassLoader " will use my
>> >> > classloader
>> >> > instead of loading every one using myClassLoader.loadClass(String)
>> >> >
>> >> > [1]
>> >> > Thread.currentThread().setContextClassloader(myclassloader),
>> >> > ClassType object = new ClassType();
>> >> > system.out.println(object.getClass().getClassLoader())
>> >> >
>> >> >
>> >> >
>> >> >
>> >> > --
>> >> > regards
>> >> > Tian
>> >> >
>> >>
>> >
>> >
>> >
>> > --
>> > regards
>> > Tian
>> >
>>
>
>
>
> --
> regards
> Tian
>

Re: About the jre classloader

Posted by galaxy <ti...@gmail.com>.
Could we have a method to replace the system classloader dynamically  ?

2009/8/5 Pavel Pervov <pm...@gmail.com>

> For application classes - replace system classloader. For jre classes
> - implement osgi in VM's bootstrap classloader.
>
> 2009/8/5, galaxy <ti...@gmail.com>:
> > Hi, Pavel
> > Thanks for the reply .
> > So how could I make my classloader to execute the new ?
> >
> > 2009/8/5 Pavel Pervov <pm...@gmail.com>
> >
> >> Hello, Tian.
> >> Thread context classloader is not used on new opcode. The initiating
> >> class loader of ClassType will be the class loader, which executes new
> >> instead. The defining loader will depend on the class being loaded and
> >> VM setup.
> >>
> >> 2009/8/5, galaxy <ti...@gmail.com>:
> >> > Hi all
> >> > I have a question about the jre classloader .
> >> > In my work of jre osgi , I have to implement a new classloader to load
> >> the
> >> > classes since the
> >> > classloading mechanism is very different from the default one .
> >> > So I am thinking of the
> >> > Thread.currentThread().setContextClassloader(myclassloader),
> >> > but this is not very useful.
> >> > for example [1] , the stdout will print systemclassloader or null
> >> > depends
> >> on
> >> > the class to load ..
> >> > So how to make sure that a " new ClassLoader " will use my classloader
> >> > instead of loading every one using myClassLoader.loadClass(String)
> >> >
> >> > [1]
> >> > Thread.currentThread().setContextClassloader(myclassloader),
> >> > ClassType object = new ClassType();
> >> > system.out.println(object.getClass().getClassLoader())
> >> >
> >> >
> >> >
> >> >
> >> > --
> >> > regards
> >> > Tian
> >> >
> >>
> >
> >
> >
> > --
> > regards
> > Tian
> >
>



-- 
regards
Tian

Re: About the jre classloader

Posted by Pavel Pervov <pm...@gmail.com>.
For application classes - replace system classloader. For jre classes
- implement osgi in VM's bootstrap classloader.

2009/8/5, galaxy <ti...@gmail.com>:
> Hi, Pavel
> Thanks for the reply .
> So how could I make my classloader to execute the new ?
>
> 2009/8/5 Pavel Pervov <pm...@gmail.com>
>
>> Hello, Tian.
>> Thread context classloader is not used on new opcode. The initiating
>> class loader of ClassType will be the class loader, which executes new
>> instead. The defining loader will depend on the class being loaded and
>> VM setup.
>>
>> 2009/8/5, galaxy <ti...@gmail.com>:
>> > Hi all
>> > I have a question about the jre classloader .
>> > In my work of jre osgi , I have to implement a new classloader to load
>> the
>> > classes since the
>> > classloading mechanism is very different from the default one .
>> > So I am thinking of the
>> > Thread.currentThread().setContextClassloader(myclassloader),
>> > but this is not very useful.
>> > for example [1] , the stdout will print systemclassloader or null
>> > depends
>> on
>> > the class to load ..
>> > So how to make sure that a " new ClassLoader " will use my classloader
>> > instead of loading every one using myClassLoader.loadClass(String)
>> >
>> > [1]
>> > Thread.currentThread().setContextClassloader(myclassloader),
>> > ClassType object = new ClassType();
>> > system.out.println(object.getClass().getClassLoader())
>> >
>> >
>> >
>> >
>> > --
>> > regards
>> > Tian
>> >
>>
>
>
>
> --
> regards
> Tian
>

Re: About the jre classloader

Posted by galaxy <ti...@gmail.com>.
Hi, Pavel
Thanks for the reply .
So how could I make my classloader to execute the new ?

2009/8/5 Pavel Pervov <pm...@gmail.com>

> Hello, Tian.
> Thread context classloader is not used on new opcode. The initiating
> class loader of ClassType will be the class loader, which executes new
> instead. The defining loader will depend on the class being loaded and
> VM setup.
>
> 2009/8/5, galaxy <ti...@gmail.com>:
> > Hi all
> > I have a question about the jre classloader .
> > In my work of jre osgi , I have to implement a new classloader to load
> the
> > classes since the
> > classloading mechanism is very different from the default one .
> > So I am thinking of the
> > Thread.currentThread().setContextClassloader(myclassloader),
> > but this is not very useful.
> > for example [1] , the stdout will print systemclassloader or null depends
> on
> > the class to load ..
> > So how to make sure that a " new ClassLoader " will use my classloader
> > instead of loading every one using myClassLoader.loadClass(String)
> >
> > [1]
> > Thread.currentThread().setContextClassloader(myclassloader),
> > ClassType object = new ClassType();
> > system.out.println(object.getClass().getClassLoader())
> >
> >
> >
> >
> > --
> > regards
> > Tian
> >
>



-- 
regards
Tian

Re: About the jre classloader

Posted by Pavel Pervov <pm...@gmail.com>.
...class loader of a class, executing new...

2009/8/5, Pavel Pervov <pm...@gmail.com>:
> Hello, Tian.
> Thread context classloader is not used on new opcode. The initiating
> class loader of ClassType will be the class loader, which executes new
> instead. The defining loader will depend on the class being loaded and
> VM setup.
>
> 2009/8/5, galaxy <ti...@gmail.com>:
>> Hi all
>> I have a question about the jre classloader .
>> In my work of jre osgi , I have to implement a new classloader to load
>> the
>> classes since the
>> classloading mechanism is very different from the default one .
>> So I am thinking of the
>> Thread.currentThread().setContextClassloader(myclassloader),
>> but this is not very useful.
>> for example [1] , the stdout will print systemclassloader or null depends
>> on
>> the class to load ..
>> So how to make sure that a " new ClassLoader " will use my classloader
>> instead of loading every one using myClassLoader.loadClass(String)
>>
>> [1]
>> Thread.currentThread().setContextClassloader(myclassloader),
>> ClassType object = new ClassType();
>> system.out.println(object.getClass().getClassLoader())
>>
>>
>>
>>
>> --
>> regards
>> Tian
>>
>

Re: About the jre classloader

Posted by Pavel Pervov <pm...@gmail.com>.
Hello, Tian.
Thread context classloader is not used on new opcode. The initiating
class loader of ClassType will be the class loader, which executes new
instead. The defining loader will depend on the class being loaded and
VM setup.

2009/8/5, galaxy <ti...@gmail.com>:
> Hi all
> I have a question about the jre classloader .
> In my work of jre osgi , I have to implement a new classloader to load the
> classes since the
> classloading mechanism is very different from the default one .
> So I am thinking of the
> Thread.currentThread().setContextClassloader(myclassloader),
> but this is not very useful.
> for example [1] , the stdout will print systemclassloader or null depends on
> the class to load ..
> So how to make sure that a " new ClassLoader " will use my classloader
> instead of loading every one using myClassLoader.loadClass(String)
>
> [1]
> Thread.currentThread().setContextClassloader(myclassloader),
> ClassType object = new ClassType();
> system.out.println(object.getClass().getClassLoader())
>
>
>
>
> --
> regards
> Tian
>