fmgasparino / google-gin

Automatically exported from code.google.com/p/google-gin
Apache License 2.0
0 stars 0 forks source link

Problem with java generic methods in GINjector #66

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. define ginjector that use generics in method definition, like
@GinModules(RemoteServiceModule.class)
public interface RemoteServiceGinjector extends Ginjector {
    <T extends IDomainObject<?>> ILoaderServiceAsync<T> getLoaderService();
}
2. call GWT.create(RemoteServiceGinjector.class)
3. GinjectorGenerator fails with the following exception
Caused by: java.lang.ClassNotFoundException: T extends
sk.seges.sesam.domain.IDomainObject<?>

What is the expected output? What do you see instead?
Generator should process generics correctly without exceptions.

What version of the product are you using? On what operating system?
gwt-gin trunk version - revision 117
OS: Windows XP

Please provide any additional information below.

[ERROR] Generator 'com.google.gwt.inject.rebind.GinjectorGenerator' threw
threw an exception while rebinding
'sk.seges.acris.rpc.service.RemoteServiceGinjector'
com.google.inject.ProvisionException: Guice provision errors:

1) Error creating key for interface
sk.seges.acris.rpc.service.ILoaderServiceAsync<T>

1 error
    at  at com.google.gwt.inject.rebind.util.KeyUtil.getKey(KeyUtil.java:151)
    at com.google.gwt.inject.rebind.util.KeyUtil.getKey(KeyUtil.java:75)
    at
com.google.gwt.inject.rebind.BindingsProcessor.addUnresolvedEntriesForInjectorIn
terface(BindingsProcessor.java:323)
...
Caused by: java.lang.ClassNotFoundException: T extends
sk.seges.sesam.domain.IDomainObject<?>

Original issue reported on code.google.com by nejakyus...@gmail.com on 13 Nov 2009 at 10:51

GoogleCodeExporter commented 9 years ago
I haven't been able to trace this to a cause yet but I'll look into it this 
week.

Original comment by aragos on 17 Nov 2009 at 1:05

GoogleCodeExporter commented 9 years ago
Aright, I investigates this further. The short answer: what you're trying to do 
is
not possible.

The long answer: You're asking Gin to generate a class initialization with a 
type
parameter that is not specified at compile-time. Since Gin runs during the GWT
compilation process, it cannot possibly know how you'll call this class
initialization. Therefore it doesn't know what your type parameter is.

In addition, I assume that ILoaderServiceAsync is a GWT RPC async interface. 
These
are instantiated by calling GWT.create(). GWT.create() does not support 
generics -
none of the type parameters could be passed on. It also doesn't seem to make 
sense to
extend a GWT RPC interface (which is what you imply with "T extends ...").

Maybe I just misunderstand what you're trying to do. But right now I fear I 
can't
help you. 

Original comment by aragos on 25 Nov 2009 at 9:38