gwtproject / gwt

GWT Open Source Project
http://www.gwtproject.org
1.52k stars 376 forks source link

RequestFactoryScanner should ignore overriden methods from RequestFactory #7590

Open dankurka opened 9 years ago

dankurka commented 9 years ago

Originally reported on Google Code with ID 7593

Found in GWT Release (e.g. 2.4.0, 2.5.0 RC):

2.4.0

Encountered on OS / Browser (e.g. WinXP, IE8-9, FF7):

Win7

Detailed description (please be as specific as possible):

When using GIN, it is possible to annotate an interface method with @Inject, for example

public interface SamplePlaceHistoryMapper extends PlaceHistoryMapperWithFactory<PlaceHistoryFactory>
{

    @Inject
    @Override
    void setFactory(PlaceHistoryFactory factory);
}

in module: bind(PlaceHistoryMapper.class).to(SamplePlaceHistoryMapper.class).in(Singleton.class);

When injecting a PlaceHistoryMapper, GIN will fallback to GWT.create() to instantiate
the correct type (SamplePlaceHistoryMapper) then inject its factory.

I would like to do the same to initialize a RequestFactory

public interface SampleRequestFactory extends RequestFactory {

    ...

    @Inject
    @Override
    void initialize(EventBus eventBus);
}

But at compile-time, I get a NPE "This method must have no parameters" thrown by RequestFactoryScanner.

Workaround if you have one:

Bind and inject the RequestFactory in a specific @Provides method in the GIN module.

Reported by xavier.dury on 2012-08-14 13:47:07

dankurka commented 9 years ago

Reported by t.broyer on 2012-08-16 15:12:12

dankurka commented 9 years ago
With GWT 2.6.0, now I have the following error:

java.lang.reflect.InvocationTargetException
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:606)
    at eg.gwt.sample.framework.client.ProxyGwtCreateHandler$1.invoke(ProxyGwtCreateHandler.java:29)
    ... 30 more
Caused by: java.lang.ClassCastException: void
    at java.lang.Class.asSubclass(Class.java:3126)
    at com.google.web.bindery.requestfactory.vm.InProcessRequestFactory$RequestFactoryHandler.invoke(InProcessRequestFactory.java:63)
    at com.sun.proxy.$Proxy116.initialize(Unknown Source)
    at eg.gwt.sample.framework.client.RequestFactoryGwtCreateHandler$1.initialize(RequestFactoryGwtCreateHandler.java:25)
    ... 35 more

No more NPE but InProcessRequestFactory's InvocationHandler expects that each method
of a RequestFactory returns a subclass of RequestContext.
There should be special rules to handle RequestFactory's methods like initialize(...).

At compilation time, RfValidator also fails (but I can't see where as maven is swallowing
the exception at some point).

Reported by xavier.dury on 2014-04-01 14:25:38