remove the generics declaration, using the raw Class type: Class implClass Class providedClass
so the compiler wont complain. On Sun, Mar 27, 2011 at 7:21 PM, Joshua Davis <[email protected]> wrote: > Hi everyone, > > Bit of weird question here - > > I was just working on an idea I had to make a 'scanner' that > automatically builds a Guice module from annotated classes found in a > class loader. It was going along pretty well until I hit a stumbling > block: I can't seem to get javac to understand > binder.bind(providedClass).toProvider(providerClass) when both classes > have been found via reflection. > > Here's the code: > > private void bindProvider(Class<?> implClass, Scope scope) { > // implClass is known to implement Provider > Class<?> providedClass = null; > // Find the provided type... > Type[] types = implClass.getGenericInterfaces(); > // ... bunch of reflection API calls here ... > > binder.bind(providedClass).toProvider((Class<? extends > Provider<?>>) implClass).in(scope); > } > > Javac says: "cannot find symbol method > toProvider(java.lang.Class<capture#546 of ? extends > com.google.inject.Provider<?>>)". I assume this is because > providedClass is not known at compile time. But... that's kinda the > point. > > Any ideas? Maybe I shouldn't be using the DSL-ish classes from > Binder? > > > > > > > -- > You received this message because you are subscribed to the Google Groups > "google-guice" group. > To post to this group, send email to [email protected]. > To unsubscribe from this group, send email to > [email protected]. > 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 [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/google-guice?hl=en.
