[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Class.forName("")
redhat wrote:
> 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,
We are at the moment working on exactly this problem of inferring possible
values for string expressions. Our technique will be able to handle situations
similar to the one above. We expect to have an implementation ready sometime
during january. Most likely it will be in a form that is easily integrated into
Soot.
Aske Simon Christensen
BRICS, University of Aarhus