Is it an eclipse or maven-compiler-plugin bug, the generics Class cast issue?

后端 未结 3 680
执念已碎
执念已碎 2020-12-12 00:18

I have a code like this:

protected  T doSomething(String someParam, Class clazz) {
...
}

which I use in a TestCase class:

相关标签:
3条回答
  • 2020-12-12 00:53

    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.

    0 讨论(0)
  • 2020-12-12 00:59

    A workaround is using eclipse compiler in maven as described at Using Eclipse Java Compiler (ecj) in maven builds

    0 讨论(0)
  • 2020-12-12 01:13

    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.

    0 讨论(0)
提交回复
热议问题