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

Re: Custom SourceLocator's possible?



On Mon, Oct 20, 2003 at 10:40:10PM -0700, Archie Cobbs wrote:
> Hi,
> 
> I'm using Soot in "library mode" instead of "application mode",
> i.e., invoking it from other Java classes rather than on the
> command line.
> 
> It doesn't seem currently possible in Soot to specify a custom
> implementation of SourceLocator.. this is the class that actually
> locates the classfiles in the filesystem that Soot reads and processes
> (by searching the soot-class-path, etc).
> 
> First, just want to verify that this is indeed the case and I'm
> not missing something..

Yes, this appears to be the case. SourceLocator has always been a
singleton, which means that there's only one of them and it's not meant
to be replaced or subclassed. I'm not saying that this is necessarily
a good design decision, just that this is how it's always been.

> Second, my hack is to use a native method to set the otherwise private
> field "instanceSourceLocator" of the G.v() object to point to an instance
> of my custom class that subclasses soot.util.SourceLocator.. will this
> work as expected?

This should work. If having to replace the SourceLocator is something
that people commonly need, a cleaner solution would be to make the
SourceLocator not be a singleton but rather a field of the Scene which
could be overwritten to replace it.

Ondrej

> 
> Thanks,
> -Archie
> 
> __________________________________________________________________________
> Archie Cobbs     *    Halloo Communications    *     http://www.halloo.com