Currently Guice doesn't allow null to be injected.
We like this. It helps to prevent bugs.
But there are cases where injecting null is convenient.
We'd like to reuse the JSR-305 @Nullable annotation to
indicate that null is okay:
public class Foo {
@Inject
public Foo(Bar bar, @Nullable Baz baz) { ... }
}
For this to work, we need runtime retention for @Nullable.
Otherwise we'd have to scrape the annotation from the
classfile, or introduce another annotation that like
'@InjectNullOk'. It would be unfortunate to have to annotate
one variable with both "@Nullable" and "@InjectNullOk".
Although this example is Guice-specific it applies to other
dependency-injection frameworks and containers.
Thanks,
Jesse
Previous discussions on runtime retention:
http://groups.google.com/group/jsr-305/browse_thread/thread/499a5a31727f14dc
http://groups.google.com/group/jsr-305/browse_thread/thread/99b833628adb25e1