|
Re: type mismatch: cannot convert from element type object [message #632473 is a reply to message #629604] |
Wed, 13 October 2010 05:58 |
Walter Harley Messages: 847 Registered: July 2009 |
Senior Member |
|
|
Roland Roberts wrote:
> Eclipse Helios is telling me I have an error here, but the code does
> compile fine. What is baffling is that the code where it claims I have
> an Object, the method is declared to return a Collection<Context>.
> Here's a snippet:
>
> for (Context c : Context.getContexts()) {
> updateCount += c.validateModel(update);
> }
>
> The method Context.getContexts() is declared, in another class, as:
>
> public static synchronized Collection<Context> getContexts() {
> ....
> return Collections.unmodifiableCollection(new
> ArrayList<Context>(contextMapByID.values()));
> }
>
> In my compiler preferences, Java > Compiler > Errors/Warnings > Generic
> Types, the "Unchecked generic type operation" is set to "Warning" (as
> are the other two items). But I'm not sure how that would even apply
> anyway. I've tried forcing Eclipse to rebuild the project to no avail.
> I'm confused as to how Eclipse concludes that that method is returning a
> Collection of Object given the call signature. Any clues on what
> settings I need to get Eclipse to see this correctly?
>
> TIA,
>
> roland
Exactly what is the error you are getting? And what are your compiler
compliance settings (that is, are you compiling for 1.5, 1.6, ...?)
Can you reproduce the problem in a small but complete code snippet that you
could post here?
What do you mean by "Eclipse Helios is telling me I have an error here, but the
code does compile file" - do you mean it compiles fine at the command line with
javac? What version of javac?
Are you certain that the declaration of Context that is being imported into the
first class is the declaration you want? (There are a lot of classes named
Context, in different packages...).
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.04870 seconds