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

Class.forName("")



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'