If Butler is an inner class, you'll need to use the three-arg newParameterizedType method and pass the outer class as the owner argument. sam
On Fri, Nov 5, 2010 at 9:37 AM, lahnsurfer <maju...@gmx.de> wrote: > Following your advice (Thanx!) i changed the findButler method: > > private Butler<Person> findButler(Person person, Injector injector){ > Class<? extends Person> personClass = person.getClass(); > > ParameterizedType parameterizedButler = > Types.newParameterizedType(Butler.class, > personClass); > Key<?> key = Key.get(parameterizedButler); > Butler<Person> butler = (Butler<Person>) injector.getInstance(key); > > return butler; > } > > But now I'm getting an IllegalArgumentException that i don't > understand: > > java.lang.IllegalArgumentException: No owner type for enclosed > interface test.com.jaculon.core.guice.GuiceInjectServiceTest$Butler > at > com.google.inject.internal.Preconditions.checkArgument(Preconditions.java: > 113) > at com.google.inject.internal.MoreTypes > $ParameterizedTypeImpl.<init>(MoreTypes.java:476) > at > com.google.inject.util.Types.newParameterizedTypeWithOwner(Types.java: > 60) > at com.google.inject.util.Types.newParameterizedType(Types.java:49) > at > > test.com.jaculon.core.guice.GuiceInjectServiceTest.findButler(GuiceInjectServiceTest.java: > 84) > at > > test.com.jaculon.core.guice.GuiceInjectServiceTest.testGetInstance(GuiceInjectServiceTest.java: > 76) > > Any Ideas? > > On 5 Nov., 14:08, Esko Luontola <esko.luont...@gmail.com> wrote: > > You should be able to use the Types.newParameterizedType method, like > > this: > > > > https://github.com/orfjackal/dimdwarf/blob/83e6dadb48841b7bd3532580a0... > > -- > You received this message because you are subscribed to the Google Groups > "google-guice" group. > To post to this group, send email to google-gu...@googlegroups.com. > To unsubscribe from this group, send email to > google-guice+unsubscr...@googlegroups.com<google-guice%2bunsubscr...@googlegroups.com> > . > For more options, visit this group at > http://groups.google.com/group/google-guice?hl=en. > > -- You received this message because you are subscribed to the Google Groups "google-guice" group. To post to this group, send email to google-gu...@googlegroups.com. To unsubscribe from this group, send email to google-guice+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/google-guice?hl=en.