Just ran a quick test, and the following code fails:
public class Main {
    public static void main(String[] args) {
        Guice.createInjector(new AbstractModule() {
            protected void configure() {
                bind(Blah.class).in(Scopes.SINGLETON);
            }
        }).getInstance(Blah.class);
    }
    interface Blah{}
}

With a NPE. The binding does not have a target so Guice cannot use it. When
Guice does not find any valid bindings, it will start looking for
@ImplementedBy and the like, in your case find it, and use that binding
instead.
The real problem here is that you're allowed to create a binding that will
never work, which is something Guice should probably detect.

Nice to hear that you like the book!

Robbie

On Thu, Sep 4, 2008 at 10:56 PM, Robbie Vanbrabant <
[EMAIL PROTECTED]> wrote:

> Actually now I have a good look at the issue, I think that's a different
> one.
> Normally binding configuration always takes precedence over annotation
> configuration, so it's normal that your last tryout works. It seems strange
> to me that the bind(NewsService.class).in(Scopes.SINGLETON) does not produce
> an error though. Hmm
>
> Robbie
>
>
> On Thu, Sep 4, 2008 at 10:53 PM, javadoc <[EMAIL PROTECTED]> wrote:
>
>>
>> Robbie Vanbrabant:
>> > Known issue: http://code.google.com/p/google-guice/issues/detail?id=150
>> > Seems to be fixed in the trunk.
>>
>> duh! should have looked there.
>> thanks.
>>
>> cu uwe
>>
>> PS: nice book, robbie!
>>
>> >>
>>
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"google-guice" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/google-guice?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to