[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Strange bug related to soot.Scene



On Wed, Feb 19, 2003 at 05:05:11PM -0500, Feng QIAN wrote:
> Etienne, does that mean a class can be loaded by more than two different
> class loaders at the same time? and will have two VM objects representing
> the same class at the same time?

Each Java class is part of a "runtime" package.  At runtime, a Java
package is identified by two components:
1- the compile-time package name (e.g. java.lang) 
2- the class loader that loaded the class

So, say that you load the class "java.util.Stack" using the class
loader instance CL1, then this class will be put, by the VM, in the
runtime package <java.util,CL1>.  Later, you load that same class
using the class loader instance CL2.  This time, the VM will insert
the new class into the package <java.util,CL2>.

It is important to note that, even though <java.util,CL1>.Stack and
<java.util,CL2>.Stack were (presumably) loaded from the Stack.class
file, they are dinstict classes in the VM.  In particular, static
fields of each class are distinct.

This is a somewhat simplified explanation.  A more complete
explanation can be found in the JVM specification 2nd edition.
Security implications make this even more complex; the JVM refers to
separate research articles for certain details (an OOPSLA paper, I
think).

Etienne


> 
> Cheers,
> Feng
> 
> On Wed, 19 Feb 2003, Prof. Etienne M. Gagnon wrote:
> 
> > Ondrej LHOTAK wrote:
> > > once. For applications where you need to run Soot more than once, the
> > > solution we've been using is to start a separate java VM using
> > > java.lang.Runtime exec(). I know that this is ugly, which is why we
> > > are working on a fix.
> >
> > Having worked so hard to get class-loaders to work in SableVM, I suggest a nicer
> > solution. ;)
> >
> > You can load Soot in a user-defined class loader.  Everytime you need to
> > "restart" Soot, you simply reload it in a new instance of the class loader.
> >
> > Etienne
> >
> >
> > --
> > Etienne M. Gagnon, Ph.D.             http://www.info.uqam.ca/~egagnon/
> > SableVM:                                       http://www.sablevm.org/
> > SableCC:                                       http://www.sablecc.org/
> >
> >
> 

-- 
Etienne M. Gagnon, Ph.D.             http://www.info.uqam.ca/~egagnon/
SableVM:                                       http://www.sablevm.org/
SableCC:                                       http://www.sablecc.org/