Eclipse ecj problems

Eclipse is one fine IDE. It has it’s great features, it’ fast and has a lot of plugins, and it uses ecj compiler instead of plain old javac from Sun, oops Oracle ;).

I’m not sure if you know, but ecj uses quite specific compilation process. Regular compilers build tree of dependencies before starting anything. Then, they do bottom up compilation process for every dependency. So if you have classes:

/* File: com/a.java */
package com;
import com.b.*;
public class a {
public void doSth() {
b var = new b();
}
}


/* File: com/b/b.java */
package com.b;
import com.c.d;
public class b {
}

and you have NO c.java file, thus your b.java file will not compile. Then javac compiler will give you an error about c package, and no class file will be generated. But Eclipse ecj works different. It of course gives you an error, but this does not prevent it from creating a.class. It does a top down compilation process and it will create class files for code that will never work. It just assumes that classes used in code in classes depend at is right.

Now what does it change in real life? I’m using Netbeans and can’t compile some other guys code because it uses classes that fails on compilation. Eclipse woks fine, classes are generated, everybody is happy. Until you launch the code ant try to run methods that use this failed code. I wonder what will happen…

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: