Skip to content

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

@viorica-visan

Description

@viorica-visan

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions