Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compilation error when using Eclipse Neon with Plugin Development and with Enabled Null Anotations #229

Closed
viorica-visan opened this issue Nov 16, 2016 · 7 comments

Comments

@viorica-visan
Copy link

Hi, since I updated my workspace to use Eclipse Neon I have a compilation error.

It goes away after I uninstall my latest Groovy-Eclipse plugin.
In my whole workspace I have many plugins, only one of which has groovy files and I used the Groovy-Eclipse plugin to work with that one.
The compilation error is completelly unrelated to the groovy plugin and it turns out that it is caused by the following compination of settings:
Plug-in Dev Environment, Groovy-Eclipse + Enabled Null annotations and some special classes.

I managed to isolate the problem in a dummy project containing 2 plugins with plugin2 depending on plugin1, which I attach here:
ws.zip

Bellow, the steps to reproduce:
1.I installed Neon (4.6.1 - Build id: 20161007-1200 ) from .zip file
2. I installed Eclipse Plug-in Development Environment from http://download.eclipse.org/releases/neon
3. I created 2 plugins. They are attached in ws.zip
4. Inside plugin1 I have the interface C.java:

public interface C {
A something();
}

With A and B being in a single java file:
import plugin1.test1.A.B;;

public interface A {
void method1();
interface B {
//
}
public static class B1 implements B {
public int b1;
}
}

  1. I have an implementation of C in plugin1:
    public class C1 implements C {

    @OverRide
    public A something() {
    // TODO Auto-generated method stub
    throw new UnsupportedOperationException();
    }
    }

  2. and an implementation of C in plugin2:
    public class C2 implements C {
    @OverRide
    public A something() {
    // TODO Auto-generated method stub
    throw new UnsupportedOperationException();
    }
    }

  3. Plugin2 requires Plugin1

  4. my test package (containing all my classes) from plugin1 is exported at runtime

  5. Install the groovy-eclipse plugin from http://dist.springsource.org/snapshot/GRECLIPSE/e4.6/
    Version: 2.9.2.xx-201611151358-e46

  6. clean&build the 2 plugins

  7. If i enable the tracing (I enabled it on everything)
    I see the following errors:
    java.lang.IllegalStateException: Bad AST node structure:

  • parent [159, 161] org.eclipse.jdt.core.dom.ParameterizedType
    typeArguments [161, 163] org.eclipse.jdt.core.dom.SimpleType

----------------------------------- SOURCE BEGIN -------------------------------------
package plugin2.test2;

import plugin1.test1.A;
import plugin1.test1.A.B1;
import plugin1.test1.C;

public class C2 implements C{

@Override
public A<B1> something() {
	// TODO Auto-generated method stub
	return null;
}

}

----------------------------------- SOURCE END -------------------------------------
at org.eclipse.jdt.core.dom.ASTConverter.convert(ASTConverter.java:1486)
at org.eclipse.jdt.core.dom.CompilationUnitResolver.convert(CompilationUnitResolver.java:302)
at org.eclipse.jdt.core.dom.ASTParser.internalCreateAST(ASTParser.java:1216)
at org.eclipse.jdt.core.dom.ASTParser.createAST(ASTParser.java:812)
at org.eclipse.jdt.internal.ui.javaeditor.ASTProvider$1.run(ASTProvider.java:551)
at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42)
at org.eclipse.jdt.internal.ui.javaeditor.ASTProvider.createAST(ASTProvider.java:543)
at org.eclipse.jdt.internal.ui.javaeditor.ASTProvider.getAST(ASTProvider.java:486)
at org.eclipse.jdt.ui.SharedASTProvider.getAST(SharedASTProvider.java:128)
at org.eclipse.jdt.internal.ui.viewsupport.SelectionListenerWithASTManager$PartListenerGroup.calculateASTandInform(SelectionListenerWithASTManager.java:173)
at org.eclipse.jdt.internal.ui.viewsupport.SelectionListenerWithASTManager$PartListenerGroup$3.run(SelectionListenerWithASTManager.java:158)
at org.eclipse.core.internal.jobs.Worker.run(Worker.java:55)

But in the end i have no actual compilation error (altough the above is logged)

  1. Enable null based anotations:
    /instance/org.eclipse.jdt.core/org.eclipse.jdt.core.compiler.annotation.nullanalysis=enabled
    Btw, In this dummy test project I do not use at all null annotations.

  2. Clean and build
    The result is that i will get a compilation error in C2:
    "The return type is incompatible with C.something() C2.java"

and the previous error in error log.

This compiles fine when I uninstall the Groovy-Eclipse plugin OR when I disable the null annotations.
Also, If I extract the nested class B1 to separate file , the compilation error is also not there. But I would prefer not to do that (because in the real workspace, there might be many more examples like that).

In Eclipse Mars+corresponding groovy plugin, I didn't have this error.

It is very strange to me that the test projects I attach does not even use groovy .
The null annotations are also not used, that is why I assumed it is a bug.

In our real environment, our workaround for the moment is to uninstall the Groovy-Eclipse plugin, until it is actually needed.

Thank you.

@eric-milles
Copy link
Member

I do see this error with JDT Core 3.12.0 but not with 3.12.1 (aka Neon.1). I plan to update to the latest 4.6 maintenance branch state this weekend. Hopefully I can get enough time.

@viorica-visan
Copy link
Author

Hi, I actually see this in Neon .1 ->
Version: Neon.1a Release (4.6.1)
Build id: 20161007-1200

@eric-milles
Copy link
Member

Well, I was only able to recreate with JDT 3.12.0. I'm not sure what is bundled with your Neon 20161007. You could look at the Installation Details for the org.eclipse.jdt.core plug-in.

@viorica-visan
Copy link
Author

Hi, you are correct I am actually using org.eclipse.jdt.core 3.12.0. The strange thing is the following.
I took new eclipse neon 1a. fresh zip (Eclipse IDE for java developers), I checked the org.eclipse.jdt.core plugins and the version is 3.12.1. I installed the groovy plugin (Groovy-Eclipse feature - from http://dist.springsource.org/snapshot/GRECLIPSE/e4.6/)and I check the plugins I see org.eclipse.jdt.core 3.12.0.
It goes back to 3.12.1 when I uninstall the plugin.

@eric-milles
Copy link
Member

That's the Groovy-Eclipse JDT patch. When I update this patch to 3.12.1, I believe your issue will be fixed.

@eric-milles
Copy link
Member

Can you retest with the latest snapshot?

@viorica-visan
Copy link
Author

Confirmed. It works now. Thank you for all the help.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants