Eclipse is having trouble with bounded wildcards

3 views
Skip to first unread message

Joel Confino

unread,
Apr 16, 2012, 11:17:37 PM4/16/12
to Atlas Development and Discussion
I wanted to mention an issue I was having with Eclipse and the Atlas
codebase to hopefully save someone who also sadly uses Eclipse from
some wasted time. It seems like the Eclipse compiler doesn't agree
with the Mac JDK compiler concerning whether or not it is legal to do
something like:
public List<Foo> getStuff() {
List<? extends Foo> fooList = getFooList();
return fooList;
}

Specifically Eclipse complains (more than complains, says its an
error) that you need to explicitly cast fooList (of type List<?
extends Foo>) to List<Foo> in order to return it. The Maven build,
using the Mac JDK 1.6, thinks that's perfectly legal without the
cast. This construct comes up in
com.ning.atlas.plugin.StaticPluginSystem. Not exactly sure how to
make Eclipse happy except adding in the cast (yeah I could switch to
VI or Netbeans but I'd prefer not to) but I guess that my problem. I
tried 2 different Eclipse versions but no luck. Apparently I'm not
the first person with this problem:

http://code.google.com/p/jclouds/issues/detail?id=461
http://stackoverflow.com/questions/5633424/is-it-a-eclipse-or-maven-compiler-plugin-bug-the-generics-class-cast-issue

Brian McCallister

unread,
Apr 16, 2012, 11:30:01 PM4/16/12
to atla...@googlegroups.com
Blech, wildcards are a mess :-( 

I don't really know my way around Eclipse, so would love a patch to remedy it ;-)

-Brian

Joel Confino

unread,
Apr 17, 2012, 9:30:48 PM4/17/12
to Atlas Development and Discussion
I think I created a GitHub pull request with the minor "fix" to make
Eclipse happy. I've never done it before, but I read the GitHub docs
and it looks pretty straight forward.

https://github.com/ning/atlas/pull/3
> >http://stackoverflow.com/questions/5633424/is-it-a-eclipse-or-maven-c...

Joel Confino

unread,
Apr 18, 2012, 8:23:36 PM4/18/12
to Atlas Development and Discussion
Your alternative works, i.e. made Eclipse happy, and it is better
because no cast is needed. Excellent. I closed the pull request (I
assume that is the correct GitHub workflow).

Maybe.<Provisioner>definitely(...)
Reply all
Reply to author
Forward
0 new messages