Writing Obfuscated Code Using Java Generics Part 1
By Angsuman Chakraborty, Gaea News NetworkMonday, November 14, 2005
Let’s begin with a simple example for this installment.
import java.util.Collection;
public class TestType {
public static <Collection> Collection myMethod(Collection a) {
return a;
}
public static void main(String ... args) {
System.out.println(myMethod("Hello World"));
}
}
Note:
1. The import statement is obviously not required. It has been added for effect.
2. Yes, this code compiles and runs.
What we can learn from this simple example:
1. Yes, you can use any valid identifier as a type name; no need to stick to bland Sun prescribed T, K & V
2. DO NOT use an existing class name as type identifier. It can seriously obfuscate your code.
YOUR VIEW POINT