ObjectInstantiationException with regards to object names in containers

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?

You definitely should report that as error to Gradle.
Somehow its class decorator generates a constructor signature that the JRE itself then cannot parse as it is invalid.
This is definitely a Gradle bug.

In the meantime I suggest you either implement Named yourself or switch to field injection like

abstract class MyClass : MyInterface {
    @get:Inject
    abstract val providers: ProviderFactory
}