Ambiguity in java generics 1.6 earlier version and the later -
Ambiguity in java generics 1.6 earlier version and the later -
recently encounter weird problem respect java generics
. simplified problem snippet below :
public static void main(string[] args) { string s = "hello"; system.out.println(blindlyreturngetobject()); } private static <t> t getobject() { homecoming (t) new object(); } private static <t> t blindlyreturngetobject() { homecoming getobject(); }
in case of jdk 1.6.0_03
, before versions, getting infamous compilation error
type parameters of <t>t cannot determined; no unique maximal instance exists type variable t upper bounds t,java.lang.object
whereas code works in jdk 1.6.0_26
, later versions.
is there anyway rid of issue before version of jdk 1.6
since our build servers still running in before version of jdk 1.6
?
while googling related issue, came across bug raised in sun
related generics type inference
issue.
http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6302954
so found fixed in later versions of jdk 1.6.0_20
, hence working in jdk 1.6.0_26
thought worth sharing.
java generics jdk1.6
Comments
Post a Comment