Google Guice problem - Specified cast is not valid. - Type <=> Class conversion problem?

Martin Gerhardy <[email protected]> Fri, 3 Feb 2017 14:12:09 +0000
Newsgroups gmane.comp.java.ikvm.devel
Message-ID <0598D786697B0A42AAEE9344938160534068F7F5@srv023188.bigpoint.local>
Hi,

still fighting with guice - now whenever I configure a factory builder like this.

-----------------------------
java
------------------------------

public interface UserFactory {
	User create(@Assisted UserId id);
}

public interface User {
	UserId getId();
}


-----------------------------
csharp code using ikvm converted java classes from above given code
------------------------------

public class BasicUser : User {
}

public class MyModule : AbstractModule {
	protected void configure() {
		install(new FactoryModuleBuilder().implement(typeof(User), typeof(BasicUser)).build(typeof(UserFactory)));
	}
}

-------------------------------

I get


INFORMATION: An exception was caught and reported. Message: java.lang.ClassCastException: Specified cast is not valid.
java.lang.ClassCastException: Specified cast is not valid.
	at com.google.inject.internal.MoreTypes.canonicalizeForKey(MoreTypes.java:104)
	at com.google.inject.Key.<init>(Key.java:137)
	at com.google.inject.Key.get(Key.java:277)
	at com.google.inject.internal.Annotations.getKey(Annotations.java:283)
	at com.google.inject.assistedinject.FactoryProvider2.constructorHasMatchingParams(FactoryProvider2.java:552)
	at com.google.inject.assistedinject.FactoryProvider2.findMatchingConstructorInjectionPoint(FactoryProvider2.java:496)
	at com.google.inject.assistedinject.FactoryProvider2.<init>(FactoryProvider2.java:292)
	at com.google.inject.assistedinject.FactoryModuleBuilder$1.configure(FactoryModuleBuilder.java:334)
	at com.google.inject.AbstractModule.configure(AbstractModule.java:62)
	at com.google.inject.spi.Elements$RecordingBinder.install(Elements.java:340)
	at com.google.inject.AbstractModule.install(AbstractModule.java:122)

Is that just a feature that doesn't work? Looks like all the other binds are working properly for now - just not the factory builder.

Regards
Martin
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, SlashDot.org! http://sdm.link/slashdot