Home > Java > Java 5 Generics, Sun JDK and Eclipse JDT differences

Java 5 Generics, Sun JDK and Eclipse JDT differences

Another one of those annoying differences between Eclipse JDT and Java (SUN) JDK, especially using generics. Sometime, you have to live outside the IDE to compile the code (e.g. CI), have you ever got bitten by this:

Compilation Failure ... type parameters cannot be determined; no unique maximal instance exists for type variable <T> with upper bounds T,java.lang.Object

Solution

I don’t know whether it is fixed in the latest JDK (JDK5 u16, still has this bug), but essentially the Sun JDK compiler is not able to infer the type correctly. The solution involves helping the compiler by providing the type parameter explicitly. An example:

someObject.genericMethod() to someObject.&lt;T&gt;genericMethod()<br />
Categories: Java Tags:
  1. Jack LEE
    June 25th, 2009 at 09:03 | #1

    thanks , your suggestion worked!

  2. January 27th, 2010 at 18:42 | #2

    It’s not so simply to buy a perfect essays written, first of all if you are occupied. I give advice you to find buy essays and to be devoid from disbelief that your work will be done by writing services

  1. No trackbacks yet.

Anti-Spam Protection by WP-SpamFree