-
Notifications
You must be signed in to change notification settings - Fork 193
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
Is groovy-eclipse project compatible with checker-framework? #799
Comments
Currently we're using Java 7. Newest versions of the frameworks require Java 8 as far as I can see - but the problem still exists in newer ( |
@croesch Could you attach your sample maven project zip (or a link to it on github)? Also do you have a java-only example that works so I could compare? I can take a look from there. Java 8 is required to use newer batch compiler, but you still should be able to target Java 7 with no issue. |
Thanks for the quick reply, I uploaded the project files croesch/groovy-spock-checkerframework-test. Please note that the application doesn't use any spock or checkerframework features currently. It's just about compiling an empty repository - if you would like some source code that uses either checkerframework or spock features, let me know - but at the current stage I think this is not necessary. Branch only-checkerframework contains the SUCCESS-bringing POM using only the checker-framework. Branch spock-groovy-checkerframework contains the FAILURE-bringing POM. EDIT run the verification (with checkerframework) via |
I was able to get the compler and tests to run successfully with this POM. I tried to remove some of the extra property indirection. This assumes Java for sources and Groovy/Java for tests. It is using the latest checker-framework; you should be able to go back to the Java 7 compatible version with a few edits. <project
xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.mycompany.app</groupId>
<artifactId>my-app</artifactId>
<version>1.0-SNAPSHOT</version>
<properties>
<maven.compiler.fork>true</maven.compiler.fork>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<org.checkerframework.version>2.6.0</org.checkerframework.version>
</properties>
<pluginRepositories>
<pluginRepository>
<id>bintray</id>
<name>Groovy Bintray</name>
<url>https://dl.bintray.com/groovy/maven</url>
<releases>
<updatePolicy>never</updatePolicy>
</releases>
<snapshots>
<enabled>false</enabled>
</snapshots>
</pluginRepository>
</pluginRepositories>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.checkerframework</groupId>
<artifactId>checker-qual</artifactId>
<version>${org.checkerframework.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.spockframework</groupId>
<artifactId>spock-core</artifactId>
<version>1.2-groovy-2.4</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.0</version>
<executions>
<execution>
<id>default-compile</id>
<phase>compile</phase>
<goals>
<goal>compile</goal>
</goals>
<configuration>
<!-- Any config specific to main compile -->
</configuration>
</execution>
<execution>
<id>default-testCompile</id>
<phase>test-compile</phase>
<goals>
<goal>testCompile</goal>
</goals>
<configuration>
<compilerId>groovy-eclipse-compiler</compilerId>
<compilerArgument>-proc:none</compilerArgument>
</configuration>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>org.codehaus.groovy</groupId>
<artifactId>groovy-eclipse-compiler</artifactId>
<version>3.3.0-01</version>
</dependency>
<dependency>
<groupId>org.codehaus.groovy</groupId>
<artifactId>groovy-eclipse-batch</artifactId>
<version>2.4.16-02</version>
</dependency>
</dependencies>
</plugin>
</plugins>
</build>
<profiles>
<profile>
<id>checker</id>
<activation>
<activeByDefault>false</activeByDefault>
</activation>
<dependencies>
<dependency>
<groupId>org.checkerframework</groupId>
<artifactId>jdk8</artifactId>
<version>${org.checkerframework.version}</version>
<scope>provided</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>properties</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<executions>
<execution>
<id>default-compile</id>
<configuration><!-- https://checkerframework.org/manual/#maven -->
<annotationProcessors>
<annotationProcessor>org.checkerframework.checker.nullness.NullnessChecker</annotationProcessor>
</annotationProcessors>
<annotationProcessorPath>
<groupId>org.checkerframework</groupId>
<artifactId>checker</artifactId>
<version>${org.checkerframework.version}</version>
</annotationProcessorPath>
</annotationProcessorPaths>
<compilerArgument>-Xbootclasspath/p:${org.checkerframework:jdk8:jar}</compilerArgument>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project> |
Oh sure, I added the repository on company's proxy repo, thx for the hint. I updated the POM. But are you sure that you run the checkerframework? You have to activate the profile
I added code in both branches that will fail if the checkerframework runs. It will produce output like this:
For me - with your updated POM - I still get the error about Internal compiler error |
I suspect this issue is to blame: pdurbin/maven-hello-world#3 I'm trying to follow the setup instructions for the specific checkerframework version: https://checkerframework.org/releases/2.1.14/manual/#maven What I am finding is that passing the 2 different type of compiler arguments is difficult. |
So I think I have everything wired up as best as can be hoped. The exception below is from the snippet of JavacTask. It is expecting a very specific ProcessingEnvironment type. I don't think the Eclipse compiler is supplying this -- it is likely supplying an instance of
public static JavacTask instance(ProcessingEnvironment processingEnvironment) {
if (!processingEnvironment.getClass().getName().equals(
"com.sun.tools.javac.processing.JavacProcessingEnvironment"))
throw new IllegalArgumentException(); // line 66 |
One idea I had late yesterday is to split compilation into two phases. In one, you could have the traditional maven java compiler run the checkerframework with compiler argument "-proc:only". In the other, you could configure the groovy compiler adapter to skip annotation processing with compiler argument "-proc:none". This should give you both checkerframework and joint groovy/java compilation. |
Thanks for the information about the different compiler arguments - did you get it working? Is your last idea of the two-phase-compilation simple to setup because I have no experience with something like that - any way could you assist me with the final solution? Checkerframework and groovy-compiler is both only important for testing (in my scenario), so it would be acceptable to have some setup that compiles multiple times with different compilers while testing whereas the "normal" compilation would only use the default compiler without further magic. |
I edited the POM above. It should use standard maven compiler for |
Thanks very much - that setup is working and I think it's an acceptable workaround. So the answer of the original question still might be |
Correct, the eclipse compiler is not compatible with the checker framework. This is because of the very strict type checking deep in the Java compiler supplied by the framework (see details above). If this were loosened up, ecj and therefore groovy-eclipse-batch could work with it. |
Hello we'd like to run some spock tests but we're also using checker-framework.
We have trouble to get the project run. Basically we posted the information on stackoverflow yesterday.
Basic question is: Is groovy-eclipse project compatible with checker-framework?
If yes: What am I doing wrong / how can I solve my issues?
Could somebody have a look at the question, I'd like to avoid redundancy but I feel like nobody could easily answer the question - so maybe you could help me. If necessary I can repost everything here :)
Thanks in advance.
The text was updated successfully, but these errors were encountered: