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

-Alint=trustArrayLenZero is not correctly working to recoganise @ArrayLen() annotation #6702

Open
Rohanraj123 opened this issue Jul 8, 2024 · 7 comments

Comments

@Rohanraj123
Copy link

Rohanraj123 commented Jul 8, 2024

-Alint=trustArrayLenZero command line option is suggested to resolve the errors created by CF for toArray() method.
Reference

We have tried to resolve the error :
https://github.com/checkstyle/checkstyle/blob/b16e96a757ccee5be66fabb8e666823ca3cb558a/config/checker-framework-suppressions/checker-nullness-optional-interning-suppressions.xml#L154-L163

created due to toArray() method. We tried to use @ArrayLen() annotation in Checkstyle, but even after adding the command line option in pom.xml file, It either does'nt recoganises the @ArrayLen() or not works correctly.


Link to the PR

Passed the command in
<CompilerArguments> like this : <Alint>trustArrayZeroLen</Alint>

@mernst
Copy link
Member

mernst commented Jul 8, 2024

I'm sorry you are having trouble.
Can you please provide a simpler example that does not depend on a dozen changes across 5 files? For example, can you provide a standalone example, to verify that the problem has nothing to do with your build system?

Thanks!

@Rohanraj123
Copy link
Author

Rohanraj123 commented Jul 9, 2024

Screenshot from 2024-07-09 06-49-34

Screenshot from 2024-07-09 06-49-31

Screenshot from 2024-07-09 06-49-16

Screenshot from 2024-07-09 06-49-09

@mernst These are the results i found when I actually configured checker framework in one of the demo project.

It says Unsupported Command line option : Alint=trustArrayLenZero
I would be favour if you could help us out configuring checker correctly if there is something wrong.

I also pushed it to github, check it out if you want : Here

@romani
Copy link

romani commented Jul 14, 2024

@mernst, please let us know if we need to provide more details or something.

@smillst
Copy link
Member

smillst commented Jul 15, 2024

trustArrayLenZero is only a lint option for the Nullness Checker. You are passing it to the other checkers listed in the pom file. To just pass it to the Nullness Checker use -ANullnessChecker_lint=trustArrayLenZero.

@Rohanraj123
Copy link
Author

Thanks for the help, it works !

@Rohanraj123
Copy link
Author

@smillst Even after putting this -ANullnessChecker_lint=trustArrayLenZero command line . It only recoganises the annotation when placed like this :

private static final Configuration @ArrayLen(0) [] EMPTY_CONFIGURATION_ARRAY =
         new Configuration[0];

This is a not a good place to put your annotation, Also Plexus-component-metadata doesnt generate the metadata when annotation placed here . Reference

When I place it like this ;
private static final @ArrayLen(0) Configuration[] EMPTY_CONFIGURATION_ARRAY = new Configuration[0];
It still doesnt recoganises the annotation .
Screenshot from 2024-07-18 20-07-31

@smillst
Copy link
Member

smillst commented Jul 18, 2024

@smillst Even after putting this -ANullnessChecker_lint=trustArrayLenZero command line . It only recoganises the annotation when placed like this :

private static final Configuration @ArrayLen(0) [] EMPTY_CONFIGURATION_ARRAY =
         new Configuration[0];

This is a not a good place to put your annotation,

This is the expected place to put the array annotations. Here's the explanation: https://checkerframework.org/manual/#faq-array-syntax-meaning.

Also Plexus-component-metadata doesnt generate the metadata when annotation placed here .

Because placing annotation before [] is legal java syntax, that sounds like a bug in Plexus-component-metadata . I'm not familiar with that tool.

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

No branches or pull requests

4 participants