eclipse-null-eea-augments icon indicating copy to clipboard operation
eclipse-null-eea-augments copied to clipboard

Test illustrating usage of @SuppressWarnings("null")

Open vorburger opened this issue 8 years ago • 5 comments

The @SuppressWarnings("null") should work, based on: https://help.eclipse.org/oxygen/index.jsp?topic=%2Forg.eclipse.jdt.doc.user%2Ftasks%2Ftask-suppress_warnings.htm

However currently both on the mvn CLI and in Eclipse IDE UI Photon Milestone 2 (4.8.0M2) this appears to be completely ignored. Even @SuppressWarnings("all") is ignored:

Null type mismatch: required '@NonNull Object' but the provided value is null

This is, I'm guessing, because here we've intentionally configured it to be an Error, not a Warning - which is what we would want for production code. However, one may still want to write a test for it - and suppress it there. Currently this appears to be impossible.

vorburger avatar Sep 29 '17 01:09 vorburger

@ctron @maggu2810 @kaikreuzer @sylvainlaurent @kwin anyone got any smart ideas how to do this?

vorburger avatar Sep 29 '17 01:09 vorburger

No, you can create a method that returns an as non-null marked null, but this is a workaround around the whole nullness check.

maggu2810 avatar Sep 29 '17 05:09 maggu2810

I had already seen this problem with eclipse but have no solution :-( I suggest you add some comment to your HelloTest class to explain the situation you are reproducing.

sylvainlaurent avatar Oct 04 '17 20:10 sylvainlaurent

I don't understand why Travis CI fails: it seems it tries to build the wrong commit??

sylvainlaurent avatar Oct 04 '17 20:10 sylvainlaurent

OK, I understood : Travis performs a temp merge with master and builds the result... And the build fails because of what @vorburger shows: the compiler produces an error despite the SuppressWarnings... my bad...

sylvainlaurent avatar Oct 04 '17 20:10 sylvainlaurent

@vorburger what do you want to do with this PR. is it still relevant? it currently fails because passing a null value triggers a compiler error not a warning and thus cannot be suppressed by @SuppressWarnings("null")

sebthom avatar Oct 01 '24 11:10 sebthom