I have a GIN @Inject
invocation where I use the optional=true
attribute, but it is simply not honored / not working (and an error is being thrown because my class is not bound, which is true).
I'm using GIN via .gwt.xml
file like this:
<extend-configuration-property name="gin.ginjector.modules" value="com.example.client.ClientModule" />
In the above example ClientModule extends com.google.gwt.inject.client.AbstractGinModule
.
Then I have a class where I requestStaticInjection
like this:
requestStaticInjection(Example.class);
In Example.java
I have:
class Example {
@com.google.inject.Inject(optional=true)
protected static SomeUnboundInterface someUnboundInterface = null;
...
}
But I get an error during app startup like this:
[INFO] [ERROR] No binding found for com.example.SomeUnboundInterface in com.gwtplatform.mvp.client.DesktopGinjector
[INFO] [ERROR] Errors in 'gen/com/gwtplatform/mvp/client/DesktopGinjectorProvider.java'
[INFO] [ERROR] Line 8: Failed to resolve 'com.gwtplatform.mvp.client.DesktopGinjector' via deferred binding
Well, that's actually true; My SomeUnboundInterface is indeed not bound; however I was hoping that using the optional=true
attribute would work.
Please note that the official documentation does not say that for GIN, this attribute is supported. However, it does say so for GUICE, so I was hoping it would work for GIN as well.
Do you know of any solution so that I don't get an error if a particular dependency is not bound?
Edit: Forgot to mention version. GWT 2.8.1; GIN 2.1; GWTP 1.6