Giter Site home page Giter Site logo

Comments (15)

msridhar avatar msridhar commented on May 17, 2024

from nullaway.

chengniansun avatar chengniansun commented on May 17, 2024

https://github.com/google/guava/blob/master/guava/src/com/google/common/collect/MapMakerInternalMap.java#L160

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.

msridhar avatar msridhar commented on May 17, 2024

from nullaway.

msridhar avatar msridhar commented on May 17, 2024

Actually looks like those fields are declared within MapMakerInternalMap:

keySet

values

entrySet

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.

msridhar avatar msridhar commented on May 17, 2024

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.

chengniansun avatar chengniansun commented on May 17, 2024

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.

msridhar avatar msridhar commented on May 17, 2024

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.

chengniansun avatar chengniansun commented on May 17, 2024

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.

msridhar avatar msridhar commented on May 17, 2024

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.

chengniansun avatar chengniansun commented on May 17, 2024

Thank you, Manu.

from nullaway.

swayamraina avatar swayamraina commented on May 17, 2024

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.

lazaroclapp avatar lazaroclapp commented on May 17, 2024

@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.

swayamraina avatar swayamraina commented on May 17, 2024

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.

rahilvora avatar rahilvora commented on May 17, 2024

If someone is not looking into this can I contribute to this? Can someone please guide me with the requirement.

from nullaway.

msridhar avatar msridhar commented on May 17, 2024

@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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.