-
Notifications
You must be signed in to change notification settings - Fork 134
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
Cannot get JSpecify annotations to work like org.eclipse.jdt.annotation specifically with generics #3434
Comments
It also could be because the JSpecify annotations have a true
See #2538 also For me to investigate... Line 2250 in 8d1cb65
By assumptions were correct. It is the above code that does the magic based on annotation value. A workaround is to make your own Eclipse JDT annotation with the same @Documented
@Retention(RetentionPolicy.CLASS)
public @interface FakeNonNullByDefault {
DefaultLocation[] value() default { DefaultLocation.PARAMETER, DefaultLocation.RETURN_TYPE, DefaultLocation.FIELD, DefaultLocation.TYPE_BOUND, DefaultLocation.TYPE_ARGUMENT };
public enum DefaultLocation {
PARAMETER,
RETURN_TYPE,
FIELD,
TYPE_PARAMETER,
TYPE_BOUND,
TYPE_ARGUMENT,
ARRAY_CONTENTS
}
} Or just use JDT Eclipse annotations only on the package-info.java (and the jspecify ones). |
I added the fake Eclipse JDT annotation hack for this repo and it worked: And it already found a bug (in my code): https://github.com/jstachio/ezkv/blob/f6f2f373e3e1a4bf23147b5aaea86e195bd2a800/ezkv-kvs/src/main/java/io/jstach/ezkv/kvs/DefaultKeyValuesResourceParser.java#L279 ( I have Checkerframework, Errorprone, and Nullaway (currently off) for that project and none of them found that issue. That is why I think the Eclipse null analysis is so valuable! I guess maybe we have something hardcoded for JSpecify or should have some option of where we can add default locations by annotation name? |
Thanks for sharing this feedback! |
@stephan-herrmann
I cannot replace Eclipses null annotations with JSpecify because generics appear to be not marked.
Here is the project.
https://github.com/agentgt/jdt-null-issue
The project does not work with headless at the moment because there appears to be another bug with plexus eclipse compiler not finding jspecify however it does emit the same warnings as the UI so I will paste its output here:
EDIT here are the errors in the UI
While I have checked in all the eclipse settings I'm going to show the relevant ones below:
My guess is to why this is happening is that annotations besides the eclipse ones are assumed not to target generics.
That is all other annotations are treated like:
To import my reproducible project you may need to adjust the
.classpath
to add the EEA. I have not added every EEA of the JDK but just the ones I know it needs.I'm going to tag @sebthom as they are also one of the few that know Eclipse null analysis.
If I replace all the annotations with the Eclipse ones (and make the Eclipse ones primary) the issues go away.
@stephan-herrmann I'm happy to help anyway including code diving. I know promised help before but I have finally finished a bulk of opensource work and eager on making Eclipse null analysis one of the best jspecify-like options.
The text was updated successfully, but these errors were encountered: