A Generics problem

The following code is highlighted as an error, although it compiles :

Map m1 = new HashMap();
Map m2 = new HashMap();
boolean contains = m1.entrySet().containsAll(_m2.entrySet()_);



7 comments

I forgot to report the version. it's 4.0.Build#1165.

0

Are you compiling with JDK1.5? IDEA does not yet support JDK1.5's implementation of variance in generics, so certain method declarations in the JDK1.5 confuse IDEA. I think this is probably your problem.

0

???
The first page of the IDEA home pages(http://www.jetbrains.com/idea/index.html) clearly states:

Generics Support
IDEA’s code generation and refactoring are now Generics-aware. Begin using this new feature of the Java language right away, even with the beta-version of Java SDK 1.5. Set your target JDK to version 1.5 (beta is available for download at http://java.sun.com) and start doing Generics immediately.

Or does it mean that ONLY code generation and refactoring are Generics-aware(with 1.5), and sytax check is NOT? It sounds very confusing.

0

It's not about being generics-aware, it's about understanding all of the generics syntax. I don't think any part of IDEA understands variance (things like <? extends List>), and I think it's wrong to say that IDEA is compatible with JDK1.5's generics implementation.

0

Keith,
Thank you for your explanation. I now understand the situation.

As a big fun of IDEA, I recommend JetBrain to state
the limitation clearly somewhere people can not miss
to ensure there is no expectation mismatch.

0

Please post the bug into the www.intellij.net/tracker

--
regards,
Alexey Kudravtsev
Software Developer
JetBrains, Inc
http://www.jetbrains.com
"Develop with pleasure!"


"Kei Sugimoto" <no_mail@jetbrains.com> wrote in message news:19424385.1077017752142.JavaMail.itn@is.intellij.net...

The following code is highlighted as an error, although it compiles :

>

Map m1 = new HashMap();
Map m2 = new HashMap();
boolean contains = m1.entrySet().containsAll(_m2.entrySet()_);

>
>
>
>


0

Thank you, Alexey.
I posted it in Tracker as #30003.

Kei

0

Please sign in to leave a comment.