Martin Gerhardy
2017-02-03 14:12:09 UTC
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
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