[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Class.forName("")
Hi,
You pointed out an interesting question. Soot does not statically
inferring dyanmically loaded class names. To be conservative, Soot allows
users provides a list of class names which possibly loaded at the rumtime.
See the tutorial:
http://www.sable.mcgill.ca/soot/tutorial/vta/
Cheers,
Feng
---------------------------------------------------------------------
Feng Qian fqian@sable.mcgill.ca
Sable Research Group http://www.sable.mcgill.ca
School of Computer Science, McGill University Montreal, Canada
On Tue, 3 Dec 2002, redhat wrote:
> Heya,
>
> I was again having a play with soot and noticed that when
> optimizing somebody elses app it wouldn't optimize some of the
> classes. (cmd: java soot.Main <cp> --whole-optimize --app project.Main)
> After looking at the source of the project I noticed that they used
> string concatenation to forName() classes into their app. <exactly what
> I thought>
> Obviously soot didn't follow these classes as they are defined
> runtime, I did wonder if it was at all possible, besides from creating
> an actual instance of the classes somewhere in the code, to optimize
> these exceptions.
>
> Although as I read the above text I wondered if it would at all be
> possible in some cases to `predict' what value would be passed to
> forName(). Yet in the example below it would seem to be logical to me,
> but perhaps very complex to code.
>
> <pseudocode>
> String string = "com.xlnt.java.awt.";
> switch(i) {
> case FRAME:
> string.concat("Frame");
> break;
> case WINDOW:
> string.concat("Window");
> break;
> default:
> string.concat("Container");
> break;
> }
> return Class.forName(string);
> </pseudocode>
>
> Thanks for any answers,
>
> blaze your trail
> --
> redhat
>
> 'I am become Shiva, destroyer of worlds'
>