-
Notifications
You must be signed in to change notification settings - Fork 745
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
A couple of fixes in MoreAnnotations #4620
Conversation
Thanks for the fix!
So the tests for this If you have a self-contained example that could be used as a test like the ones in this file, I can help add it: https://github.com/google/error-prone/pull/4621/files#diff-e6d404ec63bd19b1baf132220462ccf5fba126f25dc6c6f1773b83c71fc12b20
Interesting. Is that a public jar you could attach to the bug, ideally both the ijar and the non-ijar jar for the same library? I'd be interested in taking a look at it, if it's a ijar bug I can try to get that routed. |
I'll try to look at tests later. For the enum constant case, this was the jar: I don't know if I can share the ijar. The reference in the client code was to |
The bytecode for
This isn't bytecode that you can get from javac, there's no way to write type annotations on the type of a desugared enum constant field. Annotating enum constants just results in declaration annotations, not type annotations: import org.checkerframework.checker.initialization.qual.Initialized;
import org.checkerframework.checker.nullness.qual.NonNull;
import org.checkerframework.checker.nullness.qual.UnknownKeyFor;
enum E {
@UnknownKeyFor
@NonNull
@Initialized
ONE
}
So this is kind of weird, but I guess it's a field in bytecode, and if there are type annotations there it's probably fine to just interpret them like we would for normal fields. |
Thanks for digging in, @cushon! And sorry for the |
@cushon I've attempted to add a test for the explicitly-annotated lambda case but I'm not sure if it will pass. It's possible the |
As a follow up i re-tested NullAway with the linked Apache Beam jar and confirmed I could reproduce the previous crash, and that the line |
Sounds good, thanks for confirming. The test passes as-is, thanks for adding it. |
I discovered these issues while using this code in NullAway; see uber/NullAway#1055. (We support older Error Prone versions so can't directly call this API and had to adapt the code instead.) The previous code didn't handle explicit annotations on lambda parameters (e.g., `(@nullable Object x) -> { ... }`) and annotations on enum constants. Not sure the best way to add tests for this but happy to add them if given a suggestion. Actually the enum constant case was weird; I was unable to repro with bytecodes output by `javac` and I only observed the case with an `ijar` from Bazel. FYI @cpovirk @cushon Fixes #4620 FUTURE_COPYBARA_INTEGRATE_REVIEW=#4620 from msridhar:more-annotations-tweaks fb3690b PiperOrigin-RevId: 686729409
I discovered these issues while using this code in NullAway; see uber/NullAway#1055. (We support older Error Prone versions so can't directly call this API and had to adapt the code instead.) The previous code didn't handle explicit annotations on lambda parameters (e.g.,
(@Nullable Object x) -> { ... }
) and annotations on enum constants. Not sure the best way to add tests for this but happy to add them if given a suggestion. Actually the enum constant case was weird; I was unable to repro with bytecodes output byjavac
and I only observed the case with anijar
from Bazel.FYI @cpovirk @cushon