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

Gradle plugin not working with error-prone #1362

Closed
boris-petrov opened this issue Jun 25, 2017 · 3 comments · Fixed by #2748
Closed

Gradle plugin not working with error-prone #1362

boris-petrov opened this issue Jun 25, 2017 · 3 comments · Fixed by #2748
Milestone

Comments

@boris-petrov
Copy link

boris-petrov commented Jun 25, 2017

For a reproduction:

https://github.com/boris-petrov/checker-framework-issue

If you run a gradle build on this, it fails with:

:compileJavaerror: InvocationTargetException when invoking constructor for class org.checkerframework.checker.nullness.KeyForAnnotatedTypeFactory; Underlying cause: java.lang.NoSuchMethodError: org.checkerframework.javacutil.InternalUtils.getClassLoaderForClass(Ljava/lang/Class;)Ljava/lang/ClassLoader;; invoke the compiler with -AprintErrorStack to see the stack trace.

In our project it actually fails with:

java.lang.NoSuchMethodException: com.sun.tools.javac.code.TypeAnnotationPosition.copy(com.sun.tools.javac.code.TypeAnnotationPosition)
        at java.lang.Class.getMethod(Class.java:1786)
        at org.checkerframework.javacutil.TypeAnnotationUtils$12.call9(TypeAnnotationUtils.java:736)
        at org.checkerframework.javacutil.TypeAnnotationUtils$12.call9(TypeAnnotationUtils.java:720)
        at org.checkerframework.javacutil.TypeAnnotationUtils.call8or9(TypeAnnotationUtils.java:315)
        at org.checkerframework.javacutil.TypeAnnotationUtils.copyTAPosition(TypeAnnotationUtils.java:719)
        at org.checkerframework.framework.type.TypesIntoElements$TCConvert.visitDeclared(TypesIntoElements.java:385)
        at org.checkerframework.framework.type.TypesIntoElements$TCConvert.visitDeclared(TypesIntoElements.java:301)
        at org.checkerframework.framework.type.AnnotatedTypeMirror$AnnotatedDeclaredType.accept(AnnotatedTypeMirror.java:900)
        at org.checkerframework.framework.type.visitor.AnnotatedTypeScanner.scan(AnnotatedTypeScanner.java:89)
        at org.checkerframework.framework.type.TypesIntoElements$TCConvert.scan(TypesIntoElements.java:319)
        at org.checkerframework.framework.type.TypesIntoElements.generateTypeCompounds(TypesIntoElements.java:294)
        at org.checkerframework.framework.type.TypesIntoElements.storeMethod(TypesIntoElements.java:113)
        at org.checkerframework.framework.type.TypesIntoElements.store(TypesIntoElements.java:85)
        at org.checkerframework.framework.type.AnnotatedTypeFactory.postProcessClassTree(AnnotatedTypeFactory.java:1005)
        at org.checkerframework.common.basetype.BaseTypeVisitor.visitClass(BaseTypeVisitor.java:295)
        at org.checkerframework.common.basetype.BaseTypeVisitor.visitClass(BaseTypeVisitor.java:160)
        at com.sun.tools.javac.tree.JCTree$JCClassDecl.accept(JCTree.java:778)
        at com.sun.source.util.TreePathScanner.scan(TreePathScanner.java:52)
        at org.checkerframework.framework.source.SourceVisitor.visit(SourceVisitor.java:66)
        at org.checkerframework.framework.source.SourceChecker.typeProcess(SourceChecker.java:960)
        at org.checkerframework.common.basetype.BaseTypeChecker.typeProcess(BaseTypeChecker.java:494)
        at org.checkerframework.javacutil.AbstractTypeProcessor$AttributionTaskListener.finished(AbstractTypeProcessor.java:185)
        at com.sun.tools.javac.api.ClientCodeWrapper$WrappedTaskListener.finished(ClientCodeWrapper.java:706)
        at com.sun.tools.javac.api.MultiTaskListener.finished(MultiTaskListener.java:120)
        at com.sun.tools.javac.main.JavaCompiler.flow(JavaCompiler.java:1277)
        at com.sun.tools.javac.main.JavaCompiler.flow(JavaCompiler.java:1226)
        at com.sun.tools.javac.main.JavaCompiler.compile(JavaCompiler.java:840)
        at com.sun.tools.javac.api.JavacTaskImpl$1.call(JavacTaskImpl.java:97)
        at com.sun.tools.javac.api.JavacTaskImpl$1.call(JavacTaskImpl.java:93)
        at com.sun.tools.javac.api.JavacTaskImpl.handleExceptions(JavacTaskImpl.java:128)
        at com.sun.tools.javac.api.JavacTaskImpl.doCall(JavacTaskImpl.java:93)
        at com.sun.tools.javac.api.JavacTaskImpl.call(JavacTaskImpl.java:87)
        at com.google.errorprone.BaseErrorProneJavaCompiler$1.call(BaseErrorProneJavaCompiler.java:99)
        at com.google.errorprone.BaseErrorProneCompiler.run(BaseErrorProneCompiler.java:137)
        at com.google.errorprone.BaseErrorProneCompiler.run(BaseErrorProneCompiler.java:108)
        at com.google.errorprone.ErrorProneCompiler.run(ErrorProneCompiler.java:119)
        at com.google.errorprone.ErrorProneCompiler.compile(ErrorProneCompiler.java:66)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:498)
        at net.ltgt.gradle.errorprone.ErrorProneCompiler.execute(ErrorProneCompiler.java:63)
        at net.ltgt.gradle.errorprone.ErrorProneCompiler.execute(ErrorProneCompiler.java:24)
        at org.gradle.api.internal.tasks.compile.NormalizingJavaCompiler.delegateAndHandleErrors(NormalizingJavaCompiler.java:99)
        ...

But I guess the issue is the same - some incompatibility with error-prone. Could it be perhaps as they depend on (and I guess use) javac from Java 9?

P.S. If you comment out line 2 in build.gradle in the reproduction, it works fine.

@wmdietlGC
Copy link
Contributor

This issue is probably caused by the use of a Java 9 compiler by error-prone.
This is therefore blocked on #1224 at which point we should be able to use the same Java 9 compiler.

@boris-petrov
Copy link
Author

boris-petrov commented Jun 29, 2017

Thank you. Well, I definitely agree with @youk on this. JDK9 compatibility is way more important than anything else - the new Java is around the corner and there will be (and already are) lots of people who cannot use the Checker Framework because of that.

Thank you for the response and I'm looking forward to your fixing this. :)

@mernst mernst added this to the High milestone Jul 5, 2017
@wmdietl wmdietl removed their assignment Nov 14, 2017
@smillst
Copy link
Member

smillst commented Sep 30, 2019

The Checker Framework is now compatible with the Java 9 compiler, but ErrorProne uses an old version of the dataflow.jar. This needs to be shadow before the Checker Framework and ErrorProne can be run together.

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

Successfully merging a pull request may close this issue.

5 participants