Re: Issue 771 in google-guice: Annotations.isAllDefaultMethods returns false for method less interfaces.
Comment #13 on issue 771 by sberlin: Annotations.isAllDefaultMethods returns false for method less interfaces. https://code.google.com/p/google-guice/issues/detail?id=771 Guice is migrated to GitHub. Please use https://github.com/google/guice/issues/771 instead. -- You received this message because this project is configured to send all issue notifications to this address. You may adjust your notification preferences at: https://code.google.com/hosting/settings -- You received this message because you are subscribed to the Google Groups google-guice-dev group. To unsubscribe from this group and stop receiving emails from it, send an email to google-guice-dev+unsubscr...@googlegroups.com. To post to this group, send email to google-guice-dev@googlegroups.com. Visit this group at http://groups.google.com/group/google-guice-dev. For more options, visit https://groups.google.com/d/optout.
Re: Issue 771 in google-guice: Annotations.isAllDefaultMethods returns false for method less interfaces.
Comment #12 on issue 771 by pavel.sk...@gmail.com: Annotations.isAllDefaultMethods returns false for method less interfaces. https://code.google.com/p/google-guice/issues/detail?id=771 It is called from com.google.inject.internal.Annotations.generateAnnotation(ClassT) and when using annotation like this, than it fails. @Qualifier @Retention(RetentionPolicy.RUNTIME) public static @interface Synchronous { } -- You received this message because this project is configured to send all issue notifications to this address. You may adjust your notification preferences at: https://code.google.com/hosting/settings -- You received this message because you are subscribed to the Google Groups google-guice-dev group. To unsubscribe from this group and stop receiving emails from it, send an email to google-guice-dev+unsubscr...@googlegroups.com. To post to this group, send email to google-guice-dev@googlegroups.com. Visit this group at http://groups.google.com/group/google-guice-dev. For more options, visit https://groups.google.com/d/optout.
Re: Issue 771 in google-guice: Annotations.isAllDefaultMethods returns false for method less interfaces.
Comment #1 on issue 771 by sberlin: Annotations.isAllDefaultMethods returns false for method less interfaces. http://code.google.com/p/google-guice/issues/detail?id=771 Is this causing a bug? The method is in inject/internal, and AFAIK it's working as it's expected to work. It returns true if there's any methods in the class every method has a default value. Your statement, This class returns true if the annotation class has at least one method that has a default value set. does not seem to be true based on reading the code. It returns true if the annotation class has at least one method and *every* method has a default value set. -- You received this message because this project is configured to send all issue notifications to this address. You may adjust your notification preferences at: https://code.google.com/hosting/settings -- You received this message because you are subscribed to the Google Groups google-guice-dev group. To unsubscribe from this group and stop receiving emails from it, send an email to google-guice-dev+unsubscr...@googlegroups.com. To post to this group, send email to google-guice-dev@googlegroups.com. Visit this group at http://groups.google.com/group/google-guice-dev. For more options, visit https://groups.google.com/groups/opt_out.
Re: Issue 771 in google-guice: Annotations.isAllDefaultMethods returns false for method less interfaces.
Comment #2 on issue 771 by henn...@schmiedehausen.org: Annotations.isAllDefaultMethods returns false for method less interfaces. http://code.google.com/p/google-guice/issues/detail?id=771 This annotation returns false: public @interface Foo { } This annotation returns true: public @interface Bar { String value() default ; } Clearly, the first one should return true, too... :-) -- You received this message because this project is configured to send all issue notifications to this address. You may adjust your notification preferences at: https://code.google.com/hosting/settings -- You received this message because you are subscribed to the Google Groups google-guice-dev group. To unsubscribe from this group and stop receiving emails from it, send an email to google-guice-dev+unsubscr...@googlegroups.com. To post to this group, send email to google-guice-dev@googlegroups.com. Visit this group at http://groups.google.com/group/google-guice-dev. For more options, visit https://groups.google.com/groups/opt_out.
Re: Issue 771 in google-guice: Annotations.isAllDefaultMethods returns false for method less interfaces.
Comment #3 on issue 771 by henn...@schmiedehausen.org: Annotations.isAllDefaultMethods returns false for method less interfaces. http://code.google.com/p/google-guice/issues/detail?id=771 And yes, it only returns true if all declared methods have a default value set. The question is, what would happen if no methods are declared. IMHO that should return true, not false. -- You received this message because this project is configured to send all issue notifications to this address. You may adjust your notification preferences at: https://code.google.com/hosting/settings -- You received this message because you are subscribed to the Google Groups google-guice-dev group. To unsubscribe from this group and stop receiving emails from it, send an email to google-guice-dev+unsubscr...@googlegroups.com. To post to this group, send email to google-guice-dev@googlegroups.com. Visit this group at http://groups.google.com/group/google-guice-dev. For more options, visit https://groups.google.com/groups/opt_out.
Re: Issue 771 in google-guice: Annotations.isAllDefaultMethods returns false for method less interfaces.
Comment #4 on issue 771 by sberlin: Annotations.isAllDefaultMethods returns false for method less interfaces. http://code.google.com/p/google-guice/issues/detail?id=771 What bug is this causing? The code is in internal and is intended for internal use in Guice. External code should not use it because it can change at any time. If this isn't causing a bug, I'm inclined to close it, because it's doing what it's designed to do. -- You received this message because this project is configured to send all issue notifications to this address. You may adjust your notification preferences at: https://code.google.com/hosting/settings -- You received this message because you are subscribed to the Google Groups google-guice-dev group. To unsubscribe from this group and stop receiving emails from it, send an email to google-guice-dev+unsubscr...@googlegroups.com. To post to this group, send email to google-guice-dev@googlegroups.com. Visit this group at http://groups.google.com/group/google-guice-dev. For more options, visit https://groups.google.com/groups/opt_out.
Re: Issue 771 in google-guice: Annotations.isAllDefaultMethods returns false for method less interfaces.
Comment #8 on issue 771 by henn...@schmiedehausen.org: Annotations.isAllDefaultMethods returns false for method less interfaces. http://code.google.com/p/google-guice/issues/detail?id=771 So, the problem is that any piece of code has to drag around this dichtonomy between Annotation (IAW Names.named() and friends) and Class? extends Annotation (if using a marker annotation). There is no good way to pull them together so that subsequent code can use an XXX to represent both. Key is really close to it but when handing a key around, there are still two methods to check, whether it was created from an Annotation or a Class? extends Annotation. The code example above does something very different (and you will see why your ofType comment does not apply): - I have a key that represents a type and either an Annotation or a Class? extends Annotation - I want to create a new key for a different class that has the same Annotation or Class? extends Annotation (the use case is that I bind an object with those and want to inject dependencies that were bound the same way into the objects). To create this key, I now need to inspect the Key passed in and figure out whether it was created from an Annotation (then getAnnotation() returns non-null) or an AnnotationType (then getAnnotationType() returns non null). This would be so much simpler if for any AnnotationType (Class? extends Annotation) used as a marker annotation, the getAnnotation() would actually return something (a fake implementation of the Marker annotation passed in). Is it a bug? Well, as you mention that this is intentional, maybe not. Is it a bad API? Probably because it forces me to do this crab walk of checking left / checking right all the time. And the irony of it all is that I can actually fix that trivially in my code by using public @interface Bar { String workaroundGuiceImplementationLimitation() default ; } as a marker interface and then only look at clazzKey.getAnnotation() above. (In my internal code, the method has a different name). And given that the proposed change would actually align with the current behavior (instead of creating an instance only if 1..n methods with default present, this now creates an instance when 0..n methods with default are present). I simply think that right now, the code is just not doing the right thing. So it is a bug. IMHO. -- You received this message because this project is configured to send all issue notifications to this address. You may adjust your notification preferences at: https://code.google.com/hosting/settings -- You received this message because you are subscribed to the Google Groups google-guice-dev group. To unsubscribe from this group and stop receiving emails from it, send an email to google-guice-dev+unsubscr...@googlegroups.com. To post to this group, send email to google-guice-dev@googlegroups.com. Visit this group at http://groups.google.com/group/google-guice-dev. For more options, visit https://groups.google.com/groups/opt_out.
Re: Issue 771 in google-guice: Annotations.isAllDefaultMethods returns false for method less interfaces.
Comment #9 on issue 771 by mccu...@gmail.com: Annotations.isAllDefaultMethods returns false for method less interfaces. http://code.google.com/p/google-guice/issues/detail?id=771 I have a key that represents a type and either an Annotation or a Class? extends Annotation I want to create a new key for a different class that has the same Annotation or Class? extends Annotation This sounds exactly like Key.ofType: Returns a new key of the specified type with the same annotation as this key Using your previous example you could rewrite it as: private static Key? findDependencyKey(TypeLiteral? type, Key? clazzKey) { return classKey.ofType(type); } and if you want to guarantee there is at least an annotation instance or marker then use: private static Key? findDependencyKey(TypeLiteral? type, Key? clazzKey) { if (classKey.getAnnotationType() != null) { return classKey.ofType(type); } else { throw new ProviderException(Neither annotation nor annotation type found!); } } because Key.getAnnotationType() will only return null when there's no annotation instance or marker. -- You received this message because this project is configured to send all issue notifications to this address. You may adjust your notification preferences at: https://code.google.com/hosting/settings -- You received this message because you are subscribed to the Google Groups google-guice-dev group. To unsubscribe from this group and stop receiving emails from it, send an email to google-guice-dev+unsubscr...@googlegroups.com. To post to this group, send email to google-guice-dev@googlegroups.com. Visit this group at http://groups.google.com/group/google-guice-dev. For more options, visit https://groups.google.com/groups/opt_out.
Re: Issue 771 in google-guice: Annotations.isAllDefaultMethods returns false for method less interfaces.
Comment #10 on issue 771 by sberlin: Annotations.isAllDefaultMethods returns false for method less interfaces. http://code.google.com/p/google-guice/issues/detail?id=771 I don't buy that it's a bug. The code is doing exactly what it was written to do. You can argue that the current API Guice exposes makes what you want to do cumbersome -- but there's no bug in the code. Your workarounds are exploiting implementation details that can change (and actually wouldn't have worked in 3.0 -- the creating fake implementations is only introduced in 4.0). I still don't understand why ofType doesn't work -- it seems to do exactly what you want: create a key with a new Type/TypeLiteral with the exact same annotation or annotation class. Can you explain why that method doesn't work for you? It seems that the method exists solely for your use-case. Creating fake implementations for marker interfaces would be a waste of memory. The approach to fixing this should be, What is the right thing to do? It should not be, what's the smallest change I can make to solve my current problem. -- You received this message because this project is configured to send all issue notifications to this address. You may adjust your notification preferences at: https://code.google.com/hosting/settings -- You received this message because you are subscribed to the Google Groups google-guice-dev group. To unsubscribe from this group and stop receiving emails from it, send an email to google-guice-dev+unsubscr...@googlegroups.com. To post to this group, send email to google-guice-dev@googlegroups.com. Visit this group at http://groups.google.com/group/google-guice-dev. For more options, visit https://groups.google.com/groups/opt_out.
Re: Issue 771 in google-guice: Annotations.isAllDefaultMethods returns false for method less interfaces.
Comment #11 on issue 771 by henn...@schmiedehausen.org: Annotations.isAllDefaultMethods returns false for method less interfaces. http://code.google.com/p/google-guice/issues/detail?id=771 Guess, I read the explanation for ofType wrong. Thanks for pointing this out, I will try this. -- You received this message because this project is configured to send all issue notifications to this address. You may adjust your notification preferences at: https://code.google.com/hosting/settings -- You received this message because you are subscribed to the Google Groups google-guice-dev group. To unsubscribe from this group and stop receiving emails from it, send an email to google-guice-dev+unsubscr...@googlegroups.com. To post to this group, send email to google-guice-dev@googlegroups.com. Visit this group at http://groups.google.com/group/google-guice-dev. For more options, visit https://groups.google.com/groups/opt_out.