Comments (15)
from nullaway.
com/google/common/collect/MapMakerInternalMap.java:160: warning: [NullAway] initializer method does not guarantee @NonNul l fields keySet, values, entrySet are initialized along all control-flow paths (remember to check for exceptions or early returns).
I suppose that the three fields are inherited from AbstractMap.
from nullaway.
from nullaway.
Actually looks like those fields are declared within MapMakerInternalMap:
I still think our handling of fields inherited from abstract classes is buggy 😄 But that doesn't seem to be the problem here.
from nullaway.
I take back the comment about abstract classes. I think they should be treated just like regular classes: if you declare a non-null field in an abstract class, you should also declare a constructor / initializer that sets it. Relying on sub-classes to do this work seems fragile.
@chengniansun I'm going to close this one, pls re-open if I got something wrong
from nullaway.
Oh, I am sorry for the false alarm. I found these three fields in this class, but thought they belonged to the internal class WeakKeyDummyValueSegment (I connected to my machine remotely and did not use an IDE).
I think the curry way that NullAway handles inheritance is correct, so nothing needs to be done with this bug report.
But, as an enhancement, it would help if NullAway can print the line numbers of the fields that are not initialized. Then I can easily identify these three fields.
from nullaway.
But, as an enhancement, it would help if NullAway can print the line numbers of the fields that are not initialized. Then I can easily identify these three fields.
Yeah, it's a bit tricky; should we report the error on the constructor / initializer missing the initialization, or on the fields? I agree that giving line numbers of the fields in the former case could be useful. Hopefully in most cases the IDE will solve the problem.
from nullaway.
Currently, the locations of the initializers are reported. It will be helpful if there are locations after each field in the following example.
com/google/common/collect/MapMakerInternalMap.java:160: warning: [NullAway] initializer method does not guarantee @nonnul l fields keySet (LOCATION HERE), values (LOCATION HERE), entrySet (LOCATION HERE) are initialized along all control-flow paths (remember to check for exceptions or early returns).
This is definitely not an urgent or import feature, but worth consideration. :)
from nullaway.
I've re-titled the issue and marked it as low priority, though we will try to get to it as I don't think it should be a hard fix. I've also marked it as a good first bug to fix for someone looking to learn the NullAway code and contribute.
from nullaway.
Thank you, Manu.
from nullaway.
Hi! I am interested in this enhancement.
Can you please guide me how to build the code and how should I test my changes.
from nullaway.
@swayamraina Sure!
For building, .gradlew build
on the repository root should build everything.
For testing, feel free to add a few unit tests in nullaway/src/test/java/com/uber/nullaway/NullAwayTest.java
(see e.g. tryWithResourcesSupport
for a simple example). Note that you can use these special comments // BUG: Diagnostic contains:
to check what is on the error message reported by error prone.
I suspect most changes to fix this issue will be in NullAway.java
and fairly close to where the original initialization error messages are created.
from nullaway.
I am building it against a non-android java project.
It shows the following message with build failure
SDK location not found. Define location with sdk.dir in the local.properties file or with an ANDROID_HOME environment variable.
from nullaway.
If someone is not looking into this can I contribute to this? Can someone please guide me with the requirement.
from nullaway.
@swayamraina sorry for the slow response. I'm not sure if NullAway can be built without the Android SDK installed, as we have a module that is a sample app. Can you open a separate issue on this and we can investigate?
@rahilvora what is unclear about the requirement? Hopefully this comment makes it clear what we are looking for.
from nullaway.
Related Issues (20)
- Wiki Jakarta Annotations API HOT 2
- Missing check for library models for lambdas with an expression body
- jdk Files false positive/wrong line HOT 3
- Update JSpecify package in docs HOT 1
- The combination of JSpecify + Lombok does not seem to work well HOT 6
- Method references of nullable instances are not detected HOT 1
- Detected NPE causes EP's Var rule to go nuts. HOT 5
- Validation of null in a switch-case with pattern matching does not work as expected. HOT 1
- False positive warning on switch statements with case null
- Build failure : 'options.compilerArgumentProviders.errorprone$0.name' is missing an input or output annotation. HOT 1
- Support org.apache.commons.lang3.StringUtils.isNotEmpty HOT 3
- Support for `collect()` in Streams API HOT 4
- Control flow analysis fails within a stream collector HOT 5
- Validation of null in a method used in a boolean expression does not work as expected. HOT 1
- `if (Foo.this.bar != null)` in nested class not properly analyzed HOT 1
- Rename the Jar Infer Flags `JarInferEnabled`,`JarInferUseReturnAnnotations`
- Variable checked non-null outside a `forEach` or `Stream` lambda triggers an error HOT 13
- `if` statement on a boolean does not prevent a dereferenced nullable error HOT 1
- Null `if` check and failing function to taken in account HOT 2
- Extract methods in StreamNullabilityPropagator
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from nullaway.