We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
@NonNull
Describe the bug
private void test (@NonNull String @NonNull [] args)
Such double annotation allows null strings in the array.
To Reproduce Define test functions
private void t1 (@NonNull String[] args) {} private void t2 (String @NonNull [] args) {} private void t3 (@NonNull String @NonNull [] args) {}
Then call all 3
try { t1(null); } catch (Exception e) { System.out.println("t1(null) error"); } try { t1(new String[] { null }); } catch (Exception e) { System.out.println("t1(new String[] { null }) error"); } try { t2(null); } catch (Exception e) { System.out.println("t2(null) error"); } try { t2(new String[] { null }); } catch (Exception e) { System.out.println("t2(new String[] { null }) error"); } try { t3(null); } catch (Exception e) { System.out.println("t3(null) error"); } try { t3(new String[] { null }); } catch (Exception e) { System.out.println("t3(new String[] { null }) error"); }
Expected output:
t1(new String[] { null }) error t2(null) error t3(null) error t3(new String[] { null }) error
Actual output:
t1(null) error t2(null) error t3(null) error
Expected behavior
private void test (@NonNull String[] args)
Such annotation should prohibit null strings in array.
private void test (String @NonNull [] args)
Such annotation should prohibit null array. (works now)
Such double annotation should prohibit null array and null strings in array both.
Version info (please complete the following information):
javac 17.0.10
java-17-openjdk-amd64
lombok 1.18.30
6.4.0
Additional context Meanwhile, IDEA is smart enough to properly warn on annotations:
The text was updated successfully, but these errors were encountered:
Hi, is this issue still open for contribution? if yes, then shall I pick it up?
Sorry, something went wrong.
I think yes, contributions are always welcome!
Probably a feature request, not a bug. It was never mentioned anywhere that @NonNull checks array elements.
A similar request (#2271) was rejected a few years ago.
No branches or pull requests
Describe the bug
Such double annotation allows null strings in the array.
To Reproduce
Define test functions
Then call all 3
Expected output:
Actual output:
Expected behavior
Such annotation should prohibit null strings in array.
Such annotation should prohibit null array. (works now)
Such double annotation should prohibit null array and null strings in array both.
Version info (please complete the following information):
javac 17.0.10
fromjava-17-openjdk-amd64
lombok 1.18.30
6.4.0
Additional context
Meanwhile, IDEA is smart enough to properly warn on annotations:
The text was updated successfully, but these errors were encountered: