-
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
Compiler error for function with static return type #308
Comments
Are you using |
Yes, all but one method was annotated with I would prefer to keep the annotation thought, if it improves performance. |
I'm just asking because it helps in creating a smaller example that recreates the problem. Can you show the class structure? That is take out all the method bodies? Sometimes something like an inner class or an overloaded method or a varargs param triggers the issue. |
I started reducing the code until I noticed that an annotation in a constructor was also required to trigger the issue. Following that, I managed to produce this example that recreates the problem |
How is the @nonnull annotation supplied to your project? When I try to recreate, I need to sub out for it and everything works fine. I'm thinking the annotation class is not available for the static compilation class loader.
|
@eric-milles The @NonNull comes from checker-framework defined in the build.gradle, which I've now added. I can reproduce the problem both with |
Is the issue reproducible from the command line (i.e. outside of Eclipse)? This may be a core Groovy bug.
|
No. |
@eaaltonen Sorry I lost track of this issue. Is this still reproducible with the current snapshot. |
@eaaltonen In this particular case, I think package mypack;
import org.checkerframework.checker.nullness.qual.NonNull;
public class JavaClass {
public JavaClass(@NonNull OtherClass a, int b) {
}
} @Target({ElementType.TYPE_USE, ElementType.TYPE_PARAMETER})
public @interface NonNull {} A typical nullness annotation that I have seen before looks like this: package edu.umd.cs.findbugs.annotations;
...
@Target({ElementType.FIELD, ElementType.METHOD, ElementType.PARAMETER, ElementType.LOCAL_VARIABLE})
public @interface NonNull {} Ultimately, I think this issue is a case of annotation with runtime retention but has not been supplied on the classpath. The type system of JDT is trying to resolve all referenced types and cannot find NonNull. |
To my understanding, the annotation is saying that "the value of parameter a must never be This is supported by the example at https://checkerframework.org/manual/#example-use
which the |
As for the error message, it is no longer present in either the actual code or the example problem. Current installed plugin versions are:
so, all good now. |
Environment:
I changed a function
to
And now I'm looking at the following stack trace
I tried to create a small example to reproduce the problem, but the small example was too small to trigger the problem.
The text was updated successfully, but these errors were encountered: