javac bug – no unique maximal instance

While trying to compile my java class files with the 1.6 java compiler, I came across an error message that read :

no unique maximal instance exists for type variable U with upper bounds U

The weird thing was that the file compiled just fine in eclipse!

On further probing I realized it’s a javac bug (check the bug here)

Here’s the workaround -

Bug Scenario :

public class SomeObject {

<U extends SomeObject> U foo1() throws Exception {

SomeObject obj = new SomeObject();
return obj.foo1();
}

}

Solve this way :

public class SomeObject {

<U extends SomeObject> U foo1() throws Exception {

SomeObject obj = new SomeObject();
return obj.<U>foo1();
}
}

http://www.techtamasha.com/wp-content/plugins/sociofluid/images/digg_48.png http://www.techtamasha.com/wp-content/plugins/sociofluid/images/reddit_48.png http://www.techtamasha.com/wp-content/plugins/sociofluid/images/stumbleupon_48.png http://www.techtamasha.com/wp-content/plugins/sociofluid/images/delicious_48.png http://www.techtamasha.com/wp-content/plugins/sociofluid/images/furl_48.png http://www.techtamasha.com/wp-content/plugins/sociofluid/images/technorati_48.png http://www.techtamasha.com/wp-content/plugins/sociofluid/images/google_48.png http://www.techtamasha.com/wp-content/plugins/sociofluid/images/myspace_48.png http://www.techtamasha.com/wp-content/plugins/sociofluid/images/facebook_48.png http://www.techtamasha.com/wp-content/plugins/sociofluid/images/yahoobuzz_48.png http://www.techtamasha.com/wp-content/plugins/sociofluid/images/twitter_48.png

0 comments ↓

There are no comments yet...Kick things off by filling out the form below.

Leave a Comment