Add Null checking where applicable
See original GitHub issueMethods annotated by @NotNull should produce a NullPointerException if invoked by a null argument. As of now, only intent is indicated.
Issue Analytics
- State:
- Created 3 years ago
- Comments:5 (5 by maintainers)
Top Results From Across the Web
Add null checks for all (parameters) - Visual Studio
Learn how to create and add if statements to your code that check nullity of all the nullable, non-checked parameters.
Read more >visualstudio-docs/add-null-checks-for-parameters.md at main
Learn how to create and add if statements to your code that check nullity of all the nullable, non-checked parameters. SEO-VS-2020. 09/17/2019.
Read more >How do I check for null values in JavaScript?
I'm going to do something that is almost never a good idea: change the code in this answer. Specifically, remove the totally unnecessary...
Read more >Null Checking | ReSharper Documentation
Use this page to customize generating null-checking routines for exceptions and assertions. Null checks for exceptions and assertions.
Read more >Working with SQL NULL values
For example, in the following query, the ISNULL() function replaces the NULL values in the row with the specified value.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

If you compile in intellij then it automatically does this instrumentation btw.
My dream is that the compiler can do all this for us i.e. confirm at compile time. There are a few tools I have looked at:
Unfortunately both of these work the opposite way to IntelliJ: IntelliJ assumes that everything is nullable unless you explicitly annotate with @NotNull whereas both of these tools assume the opposite. I believe that you can configure the checkers framework to work the same way as Intellij but I have not spent the time.
If we were to follow the compile time static analysis approach on all our products then we could that all our null-related contracts are being respected, although our customers would not get the same assurances for their code.
After some consideration, I agree with you @JerryShea . There are some potentially dangerous corner cases that may be affected by instrumentation. It is better to explicitly use
Objects.requireNonNull()where applicable.