Assisted inject can't match generics parameters correctly
- Dominant language
- Java
- Stars
- 12.7k
- Forks
- 1.7k
- Avg merge
- 11m
- Merged PRs (30d)
- 2
Description
_From [dtm+external@google.com](https://code.google.com/u/115440404260700484642/) on July 08, 2008 16:12:27_
I have a class with a constructor as:
public class Foo<I extends Baz> {
public Foo(BarService service,
FooProcessor<I> processor,
BazHelper baz,
Class<I> iClass) {
...
}
}
Three of those paramters are generally gotten from guice, while the fourth
(the class) is a constant depending on where in the code I create a Foo.
(FooProcessor has a zero-arg constructor, so guice can fill it in no matter
what type is used as a parameter)
This would seem like a perfect use case for `@` AssistedInject , but trying this:
public interface FooFactory {
<I extends Baz> Foo<I> create(Class<I> iClass);
}
and putting `@`Assisted in the right place on the constructor led to this
exception while creating the injector:
java.lang.IllegalArgumentException: class test.Foo has no `@`AssistInject
constructor that takes the `@`Assisted parameters [java.lang.Class<I>] in
that order. `@`AssistInject constructors are [public
test.Foo(test.BarService,test.FooProcessor,test.BazHelper,java.lang.Class)]
at
com.google.inject.assistedinject.FactoryProvider.createMethodMapping(FactoryProvider.java:195)
at
com.google.inject.assistedinject.FactoryProvider.<init>(FactoryProvider.java:102)
at
com.google.inject.assistedinject.FactoryProvider.newFactory(FactoryProvider.java:96)
at test.FooModule.configure(FooModule.java:138)
at com.google.inject.AbstractModule.configure(AbstractModule.java:66)
...
(class names changed to obscure internal details)
_Original issue: http://code.google.com/p/google-guice/issues/detail?id=218_
Contributor guide
Assessment
This issue has not been assessed yet.