-
Notifications
You must be signed in to change notification settings - Fork 7
New issue
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
Update Library Model Loader to mark fields Nullable #220
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall looks good! I have a few comments. Also, why is nullable-methods.tsv
checked in as an empty file?
annotator-core/src/main/java/edu/ucr/cs/riple/core/injectors/VirtualInjector.java
Outdated
Show resolved
Hide resolved
annotator-core/src/main/java/edu/ucr/cs/riple/core/injectors/VirtualInjector.java
Outdated
Show resolved
Hide resolved
Path path, | ||
Function<AddAnnotation, Stream<String>> mapper) { | ||
try (BufferedOutputStream os = new BufferedOutputStream(new FileOutputStream(path.toFile()))) { | ||
Set<String> rows = annotations.flatMap(mapper).collect(Collectors.toSet()); | ||
for (String row : rows) { | ||
os.write(row.getBytes(Charset.defaultCharset()), 0, row.length()); | ||
} | ||
os.flush(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not a big deal, but I don't think this call is needed, since the stream will immediately be closed afterward
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, fixed in f775354
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I still see the call to os.flush()
? Why is this needed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is the call to os.flush()
redundant (or guaranteed to be executed after the block) in try-with-resources
block ? IntelliJ only grays out call to os.close()
but not for os.flush()
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
try-with-resources
guarantees the stream will be closed, and I believe it will be flushed automatically before it is closed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok thanks for that. Then we can remove it. Fixed in 24f0a24
@@ -82,6 +83,23 @@ public static void executeCommand(Config config, String command) { | |||
} | |||
} | |||
|
|||
/** | |||
* Clears the content of the file at the given path if the file exists. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why don't you just delete the file?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, that sounds better. Fixed in 6dd203e
library-model-loader/src/main/java/edu/ucr/cs/riple/librarymodel/LibraryModelLoader.java
Show resolved
Hide resolved
@Override | ||
public ImmutableList<StreamTypeRecord> customStreamNullabilitySpecs() { | ||
return LibraryModels.super.customStreamNullabilitySpecs(); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn't this override unnecessary? It just calls the super method?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for catching this, I really don't know what I was thinking 🤦🏻♂️ de61967
library-model-loader/src/main/java/edu/ucr/cs/riple/librarymodel/LibraryModelLoader.java
Show resolved
Hide resolved
…irtualInjector.java Co-authored-by: Manu Sridharan <[email protected]>
…irtualInjector.java Co-authored-by: Manu Sridharan <[email protected]>
@msridhar Thank you very much for the review, this is ready for another round. Regarding
We weren't creating / deleting files in resource directory (which we are now 6dd203e). We used to assume the file exists and clear contents instead of deleting. With the new approach, we no longer need the file. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The PR still includes an empty nullable-methods.tsv
file. After removing that file from the PR it looks good to go
@msridhar I don't see the |
Yes, you're right. For some reason GitHub shows the change strangely. Locally git shows the file as removed. Sorry for the confusion. |
Followup on an update in NullAway recent change #878 which enables NullAway to mark fields as
@Nullable
. This PR updates ourLibraryModelsLoader
to enable communication of Annotator and NullAway to mark fields@Nullable
while analyzing downstream dependencies. This is required to prepare the code for the upcoming change which enables Annotator to be informed of impacts of making fields@Nullable
on downstream dependencies.