Correctly load client or server specific decorators from classpath (#1592)
The current approach that attempts to downcast never worked; all Rust decorators were being loaded, and the cast was doing nothing, because the generic type parameter is erased at runtime. Attempting to downcast a generic class `C<T>` to `C<U>` where `U: T` is not possible to do in Kotlin (and presumably all JVM-based languages) _at runtime_. Not even when using reified type parameters of inline functions. See https://kotlinlang.org/docs/generics.html#type-erasure for details. This commit thus goes for another approach, suggested in the linked Stack Overflow question [0]: add a method to the loaded classes that signals at runtime the generic type parameter (`ClientCodegenContext` or `ServerCodegenContext`) they can work with, in order to filter them. This commit also simplifies the way the Python server project loads the Python server-specific decorators, by deleting the combined decorator `PythonServerCodegenDecorator`, which was being loaded from the classpath, and instead directly using `CombinedCodegenDecorator` and passing it the Python server-specific decorators in the `extras` parameter. [0]: https://stackoverflow.com/questions/5451734/loading-generic-service-implementations-via-java-util-serviceloader
Loading
Please register or sign in to comment