2

Different developers use differnt IDE in my team. One Intellij Idea user wrote code like this

public class Bar<A> extends AbstractSet<Bar.Inner> { class Inner { } @Override public Iterator<Inner> iterator() { return null; } @Override public int size() { return 0; } } 

Other one (eclipse user) said that it compiles only with replacement

 public Iterator<Inner> iterator() { 

to

 public Iterator<Bar.Inner> iterator() { 

or

 extends AbstractSet<Bar.Inner> 

to

 extends AbstractSet<Bar<A>.Inner> extends AbstractSet<Bar<?>.Inner>//other variant 

What is right compiler's behaviour? Where I can get list of such issues?

additional info
eclipse:

  • version: Helios Service Release 1
  • build: 20100917-0705
  • jdk: 1.6.0_23 (instaled on computer)

idea:

  • version: 10.0.2
  • build: 103.72
  • jdk: 1.6.0_21 (by Help -> About)

UPD It's my fail. Idea reports about it but only at application building. But, I think, it's Idea's bug too.

7
  • wondering if they use same JDK? Is it possible one uses openJDK, other Sun? Just my 2%. Commented Feb 14, 2011 at 14:33
  • @Nishant, They use Sun JDK. But probablly different versions. I should check. Commented Feb 14, 2011 at 14:36
  • @Nishant, They use Sun JDK. But different versions (Post updated). Commented Feb 14, 2011 at 14:48
  • 1
    In Eclipse, Window > Preferences > Java > Installed JREs see if points to right JDK directory i.e. 1.6.0_23 ? Also see if their compiler level is set to the right version i.e. 1.6. In Eclipse it can be seen from Window > Preferences > Java > compiler. 1.6.0_23 vs 1.6.0_21 should not have this much change. IDE may not necessarily use the installed JDK. Commented Feb 14, 2011 at 14:59
  • @Nishant, Thanks for info about eclipse. Eclipse use installed JDK. Compiler compliance level is set to 1.6. Commented Feb 14, 2011 at 15:07

5 Answers 5

2

This would seem more likely an underlying JDK version issue than an IDE one - have you checked they're all using identical versions, e.g. JDK 1.6.0_23?

Sign up to request clarification or add additional context in comments.

1 Comment

Shouldn't be the case, because eclipse uses it's internal compiler indepent from installed ones.
1

The JDK version you see in about dialog is the java version IDEA is run with. JDK used for compiling is at Project Structure -> Project -> Project SDK.

I've tested your code on IDEA Community 10.0.1 on windows with java 1.6_20, openjdk 1.6.20, and java 1.7.0. All three gave me compiler errors. You can also set your IDEA to use eclipse compiler: Settings -> Compiler -> Java Compiler -> Use compiler: Eclipse. It also gives a compilation error:

Eclipse compiler:

The return type is incompatible with <Test.Inner>.iterator() 

Java 7:

Bar is not abstract and does not override abstract method iterator() in AbstractCollection iterator() in Bar cannot override iterator() in AbstractCollection method does not override or implement a method from a supertype 

Java 6 and OpenJDK 6:

Bar is not abstract and does not override abstract method iterator() in java.util.AbstractCollection iterator() in Bar cannot override iterator() in java.util.AbstractCollection; attempting to use incompatible return type found : java.util.Iterator<Bar<A>.Inner> required: java.util.Iterator<Bar.Inner> method does not override or implement a method from a supertype 

So it's not an IDEA issue, it's something with the JDK you use to compile.

Comments

1

I'll bet the Eclipse JDK is an IBM variant that's different from Sun.

1 Comment

Do you know where I can get list of differences?
1

As duffymo stated before, Eclipse doesn't use JDK from Sun but uses their own compiler (which has better support for continuous compiling and ignoring some errors during execution).

However, the objective of Eclipse's team is to have consistent behavior wit Sun JDK as much as possible. So if you get an error that you think should be fixed, you should report a bug to Eclipse team.

Another behavior like this can be read in my blog.

Comments

0

I had the same error some time ago. Eclipse was buggy here, and the compiler didn't complain while compiling with javac showed errors. I filed a bug a long time ago, but they don't seem to have it in the database anymore.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.