I have to tell that I do agree with the answer given by @dkatzel: it looks like what you really need is not obfuscation. To my understanding, obfuscation is about making the code harder to understand (in order to achieve different purposes like security, prevent copying, etc - the Wikipedia's article mentioned indeed explains it quite well).
So, considering a source code correctly done (I mean, without redundant parts or useless code, as you've put), obfuscating it (in the common sense) would simply make the code unintelligible without changing its execution path. This implies that obfuscating code usually has no (or very little) impact in the code performance, and this is different than what you want to produce for your tests. For instance, the kind of obfuscation proposed in this very cool article (http://www.kahusecurity.com/2011/brilliant-javascript-obfuscation-technique/) would not help you at all, right? (I mean, disregarding that it is about Javascript, not Java)
Thus, I think the answers already provided (specially the ones about searcing stuff at Github and using ASM) is the way to go. There is a famous obfuscated code championship for C code (http://en.wikipedia.org/wiki/International_Obfuscated_C_Code_Contest) where people try to be creative and perhaps their sources do have useless code (even though that is not the main intention) that you can use in your tests (if you find similar championships for Java code - I honestly didn't check for that).
In your shoes, I would also consider creating a very simple source code manipulation tool that would directly insert useless snippets in the .Java file, at random valid locations. You could define those snippets yourself with things like:
- { System.out.println("Hello world!"); }
- { String s; for(int i = 32; i < 127; i++) s += (char) i; s = s.toUpperCase(); }
- { new Thread(
new Runnable() {
public void run() {
System.out.println("Hello world again!");
}
}
).start();
}
- Etc
Since we are talking about a scientific research (your PhD project), I agree with you that it is important for the results of the initial prototype to be easily reproduced. Hence, by having such a tool to add snippets that are known to be useless to your simple test code, you can have a pre-validation. However, probably in the future you will also want to process well known source code (from important open source projects, for instance), pass it through your removal-useless-code-tool, present the code removed, and finally argument logically about the useless of the bits removed as well as validate the output of the modified version of the code against the previous one (without the removed stuff).
Good luck with your research, mate. :)
Cheers