Re: I need to know if a java class import a package
Philipp Taprogge wrote:
Hi!
Thus spake Patricia Shanahan on 04/23/2007 09:53 PM:
For completeness, note that a cheater could use reflection and run time
string calculation to invoke Arrays.sort without any mention of it that
would be visible to static analysis of the class.
You could certainly try and grep your way through the submitted
source code to find those fragments.
I'm not sure whether it would be equivalent to the Halting
Problem, but it certainly could be difficult:
StringBuffer buff =
new StringBuffer("kbwb/vujm/Bssbzt");
for (int i = 0; i < buff.length; ++i)
buff.setCharAt(i, buff.charAt(i) - 1);
Class c = Class.forName(buff.toString());
...
It's occurred to me that loading the "foreign" class with
a customized ClassLoader might be the start of a way to intercept
such dodges. It still wouldn't defend against the far simpler
cheat of copying the freely-available source code of Arrays.sort
and giving it a new name.
--
Eric Sosman
esosman@acm-dot-org.invalid