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
Upgrade to Error Prone 2.3.3 #295
Conversation
Most of the noise in this diff falls under a few categories: - UnusedVariable check - Strong enforcement of immutables (no mixing, using them in autovalue) - Use Types.isSameType() for type comparisons (instead of .equals()) - Use state.getSourceForNode() for representing trees rather than Tree#toString() - Use fluent APIs for assertions in tests Resolves uber#286
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 still blocked on faster buck support for XPlugin
? We don't want to make upstream NullAway incompatible with our internal infra.
jar-infer/jar-infer-lib/src/main/java/com/uber/nullaway/jarinfer/DefinitelyDerefedParams.java
Show resolved
Hide resolved
nullaway/src/main/java/com/uber/nullaway/handlers/LibraryModelsHandler.java
Show resolved
Hide resolved
That issue started with 2.3.2 though, which NullAway is already on. That's why I thought this was fair game :). We can also roll it back to 2.3.2 and keep most of the fixes for things it raised for now as a preparation step. |
I think it’s fine to update to EP 2.3.3 for building NullAway. But NullAway probably shouldn’t have a dependency on EP >= 2.3.2. Can we tease these apart? |
Let me take a look at separating them. Want to reiterate though that we're already on 2.3.2, which has the plugin change. 2.3.3 wouldn't be a new change in that regard |
Yeah we’ve been sloppy. The important thing is to not use any APIs introduced in 2.3.2 or later, for now. |
Alright I've separated the error prone API version from the one used to build against, and lowered the API version to 2.3.1 in d01f759 Let me know what you want to do about the other comments! |
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.
Some nits/questions/musings, but, overall, happy to merge this! Thanks, Zac! @msridhar ?
@@ -16,7 +16,8 @@ | |||
|
|||
def versions = [ | |||
checkerFramework : "2.5.5", | |||
errorProne : "2.3.2", | |||
errorProne : "2.3.3", // The version of error prone running on this project | |||
errorProneApi : "2.3.1", // The version of error prone built against and shipped |
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 dream of a day they once again are both one and the same, but, for now, thanks for this :)
jar-infer/jar-infer-lib/src/main/java/com/uber/nullaway/jarinfer/DefinitelyDerefedParams.java
Show resolved
Hide resolved
@@ -919,7 +917,7 @@ private boolean fieldAlwaysInitializedBeforeRead( | |||
if (classTreePath == null) { | |||
throw new IllegalStateException( | |||
"could not find enclosing class / enum / interface for " | |||
+ enclosingBlockPath.getLeaf()); | |||
+ state.getSourceForNode(enclosingBlockPath.getLeaf())); |
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.
Minor concern here: state. getSourceForNode
performs file IO to retrieve the code, where JTree.toString()
uses a visitor to reconstruct the string representation from the in-memory AST. This means toString()
is faster. As long as we are only calling getSourceForNode
for reporting actual errors (with imply IO anyways), it's probably fine to call this API, but we don't want to use it anywhere else, as it might cause a performance regression.
Related: getSourceForNode
uses CompilationUnitTree.getSourceFile
, which just reads JCCompilationUnit.sourcefile
in JavaC. Do we know if that field is always set? Can javac operate on streams of java sources that are not files? (The JVM certainly can when loading bytecode, so... )
Either way, I think this is all fine for our use cases until we see an issue from this (either performance related or with getting the file) but well... any thoughts, @msridhar ?
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.
This is fine I think. We should not be turning ASTs into Strings in any perf-critical computation.
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.
Yep agreed. Double checked and this is only used in exception messaging
} | ||
ImmutableSet.Builder<Element> resultBuilder = ImmutableSet.builder(); |
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.
👍
nullaway/src/main/java/com/uber/nullaway/handlers/LibraryModelsHandler.java
Show resolved
Hide resolved
@@ -17,6 +17,7 @@ | |||
|
|||
private CompilationTestHelper compilationHelper; | |||
|
|||
@SuppressWarnings("CheckReturnValue") |
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 documentation for "CheckReturnValue" is unusually unhelpful. But from what I understand, this is complaining that we are not "using" the result from .newInstance(...)
, even though we are assigning it to a field, correct?
The weird thing is, this seems like perfectly idiomatic Error Prone test code, e.g.: https://github.com/google/error-prone/blob/master/test_helpers/src/test/java/com/google/errorprone/CompilationTestHelperTest.java#L45
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.
Yeah I don't fully understand why we need to suppress here either
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.
It's because setArgs
is annoyingly marked as @CheckReturnValue
, as they marked the entire package with that annotation
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 the great cleanup!
Most of the noise in this diff falls under a few categories:
Resolves #286