google-code-export / google-guice

Automatically exported from code.google.com/p/google-guice
Apache License 2.0
2 stars 1 forks source link

Can not bind multiple interfaces to the same class #349

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
I am using Guice 1.0, sample code is attached.

It runs if you bind InterfaceB to Impl2 instead of Impl.

It produces the following output:
Exception in thread "main" java.lang.RuntimeException:
java.lang.reflect.InvocationTargetException
    at
com.google.inject.ConstructorInjector.construct(ConstructorInjector.java:161)
    at com.google.inject.InjectorImpl$ImplicitBinding.get(InjectorImpl.java:1006)
    at
com.google.inject.ProviderToInternalFactoryAdapter$1.call(ProviderToInternalFact
oryAdapter.java:37)
    at com.google.inject.InjectorImpl.callInContext(InjectorImpl.java:756)
    at
com.google.inject.ProviderToInternalFactoryAdapter.get(ProviderToInternalFactory
Adapter.java:35)
    at com.google.inject.Scopes$1$1.get(Scopes.java:53)
    at
com.google.inject.InternalFactoryToProviderAdapter.get(InternalFactoryToProvider
Adapter.java:41)
    at
com.google.inject.BindingBuilderImpl$FactoryProxy.get(BindingBuilderImpl.java:29
9)
    at com.google.inject.InjectorImpl$9$1.call(InjectorImpl.java:708)
    at com.google.inject.InjectorImpl.callInContext(InjectorImpl.java:747)
    at com.google.inject.InjectorImpl$9.get(InjectorImpl.java:702)
    at com.google.inject.InjectorImpl.getInstance(InjectorImpl.java:728)
    at GuiceTest.start(GuiceTest.java:22)
    at GuiceTest.main(GuiceTest.java:17)
Caused by: java.lang.reflect.InvocationTargetException
    at GuiceTest$Impl$$FastClassByGuice$$a1577db2.newInstance(<generated>)
    at
com.google.inject.cglib.reflect.FastConstructor.newInstance(FastConstructor.java
:40)
    at
com.google.inject.DefaultConstructionProxyFactory$2.newInstance(DefaultConstruct
ionProxyFactory.java:67)
    at
com.google.inject.ConstructorInjector.construct(ConstructorInjector.java:142)
    ... 13 more
Caused by: java.lang.ClassCastException: $Proxy6 cannot be cast to
GuiceTest$InterfaceB
    ... 17 more

Original issue reported on code.google.com by kristofer.karlsson@gmail.com on 19 Mar 2009 at 3:21

Attachments:

GoogleCodeExporter commented 9 years ago
Yikes. Our circular dependency management needs some love.

Committed the test case in r935.

Original comment by limpbizkit on 26 Apr 2009 at 8:37

GoogleCodeExporter commented 9 years ago

Original comment by limpbizkit on 26 Apr 2009 at 9:04