I'm testing out a change internally where Guice will transparently change
MyAnnotation.class to an instance of MyAnnotation with all the default
values set, if MyAnnotation's methods all have default values.

For example:

  @Retention(RUNTIME)
  @BindingAnnotation
  @interface AllDefaults {
    int hasDefault() default 1;
  }

  @AllDefaults class Foo {}

  void testKey() {
    assertEquals(
        Key.get(Foo.class, Foo.class.getAnnotation(AllDefaults.class)),
        Key.get(Foo.class, AllDefaults.class));
  }

Previously that would have failed, because AllDefaults.class !=
@AllDefaults (because javac constructs @AllDefaults with the default value
of '1').

Along with that change, I'm also introducing *
Binder.requireExactBindingAnnotations()*, which instructs Guice to not use
it's error-prone "fallback" (where a binding for *@Named Foo* can be used
to inject *@Named("foo") F*oo, if the latter doesn't exist but the former
does).

Overall, this will make Guice much safer and avoid accidental mistakes.
 However, the Key/Annotation change is partially backwards-incompatible in
that you may have been using *bind(AnnotationWithDefaults.class)* as a
"fallback" (usually not intentionally!) for different annotation values.

sam

-- 
You received this message because you are subscribed to the Google Groups 
"google-guice" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/google-guice?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to