I have a code like this:
protected T doSomething(String someParam, Class clazz) {
...
}
which I use in a TestCase class:
Which compiler are you using? In this case http://code.google.com/p/jclouds/issues/detail?id=461 the openjdk seems to reveal the incompatible types while the sun jdk ignores it and compiles.
A workaround is using eclipse compiler in maven as described at Using Eclipse Java Compiler (ecj) in maven builds
This is a known bug in Eclipse: 333011: [compiler][1.5] Eclipse compiles codes which javac rejects: incompatible types . Feel free to vote for the bug and add your use case to it.
There are situations when javac and Eclipse disagree, and you should report them as bugs. It is preferred to have a standalone test case of as few Java files as possible which can be copy/pasted in Eclipse and compiled using javac from the command line without any dependencies.