Suppose I have my own custom classes like so:
interface MyInterface : Named {
// ...
}
abstract class MyClass @Inject constructor(private val providers: ProviderFactory) : MyInterface {
// ...
}
Now, suppose I have this:
abstract class MyExtension @Inject constructor(private val objects: ObjectFactory) {
val container = objects.polymorphicDomainObjectContainer(MyInterface::class.java)
init {
container.registerBinding(MyClass::class.java, MyClass::class.java)
}
}
If I have in my code something like so:
configure<MyExtension> {
container.register<MyClass>("foo")
}
Registration is fine, but if I then do
the<MyExtension>().container.named("foo").get()
I seem to get an ObjectInstantiationException
relating to MyClass
, relating to its constructor (It’s a GenericSignatureFormatError
). It appears that Gradle does not normally extend MyClass
with an implementation of the Named
portion therein; how should I fix this issue? Can I do so without manually implementing Named
?