-
Notifications
You must be signed in to change notification settings - Fork 37.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
CoroutineUtils assumes Kotlin value class has an accessible constructor #32573
Comments
I suspect it is a duplicate of #32536, could you please test with Spring Framework Instantiation of value class parameters is sadly required due to the fact that Kotlin reflection require the boxed value. That's unfortunate, but that's not something where we are not in control. |
Indeed, 6.1.6-SNAPSHOT addresses this. 6.1.5 fails with
whereas there is no longer a failure on 6.1.6-SNAPSHOT. Not understanding why instantiation of value-class parameters is required:
Even with allowing access to private constructors that can still subvert the developer's creation strategy for any given object - in my code example above, there's a factory function on the Companion object doing the creation. In that case it doesn't do much, but if it did that would be problematic to have an instance "created" without going through the specified creation strategy. Perhaps there are several use cases here - instantiation of a value class instance from java via reflection (as noted in #32324), proxying (where value class instance already exists), and perhaps others. Perhaps |
Affects: Spring Framework 6.1.x / Spring Boot 3.2.x
With Spring Boot 3.1.x (Spring Framework 6.0.x) proxies around Kotlin suspending functions that took a value class were able to handle value class arguments that did not have an accessible constructor, such as:
Spring 6.1.x, in #32324, refactored CoroutineUtils to require an accessible primary constructor, failing with an IllegalAccessException if the constructor is not accessible.
As a workaround have disabled (currently unneeded) proxying of these interfaces (@repository), in preference to weakening the value class encapsulation.
This broke during a Spring Boot 3.1.5 -> 3.2.4 upgrade.
Its also not clear why instantiation is required, as the argument value already exists and is of the same type - is there perhaps a performance impact here as well?
The text was updated successfully, but these errors were encountered: