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
Add support for Nullable as a TYPE_USE annotation #1193
Comments
Possible workaround: in our case, I could easily switch to |
FWIW, we decided (both Guice and Dagger) to ignore type annotations for qualifiers at least for the time being because of the complications that they may introduce into the key/type system that weren't previously considered. This may be entirely different, as I'm not familiar with this part of Guice, but there's always the consideration of something like this: class Foo<T> {
@Inject Foo(T t) {}
}
class Bar {
@Inject Bar(Foo<@Nullable String> fooOfNullableString) {}
} |
To clarify what I believe is happening here, the annotations that describe annotations and the reflection API to get information about annotations was extended in jdk8. Annotations such as |
Java support for annotation metadata has evolved, and projects providing implementations of @nullable has been adopting those new features. This has had the side effect of some commonly used @nullable annotations not working as expected with Guice. This change uses reflection to extract new style @nullable annotations as well as old style ones. Addresses the issue described in google#1193
There are a lot of things that "Guice supports |
It looks to me like 5.0.0 (though use 5.0.1 instead), released earlier this year, contains the change that lets you write As discussed above, Guice could theoretically do more with type-use annotations, but this at least makes them not worse than declaration annotations. Possibly that's enough to close this issue. Anyone who migrates from declaration annotations to type-use annotations may need to move some annotations along the way:
(That's just how type-use-annotation syntax works.) (I don't see mention of this in the release notes. Maybe it should be added?) |
This was fixed in 1a410a8. |
I wanted to switch from JSR305 to Checker Framework
@Nullable
, but it breaks my@Nullable
injection points:Apparently, this is because Guice only looks at field and parameter annotations, not TYPE_USE annotations:
guice/core/src/com/google/inject/spi/InjectionPoint.java
Lines 117 to 119 in eface21
Note: I couldn't use the Java 7-compatible annotations from the Checker Framework either because it's named
@NullableDecl
, and Guice only looks at annotations named@Nullable
.The text was updated successfully, but these errors were encountered: