Pre-check
- [x] I am sure that all the content I provide is in English.
Search before asking
- [x] I had searched in the issues and found no similar issues.
Apache Dubbo Component
Java SDK (apache/dubbo)
Dubbo Version
3.3.4
Steps to reproduce this issue
Use record class as a get parameter.
What you expected to happen
Support record class as a get parameter.
Anything else
No response
Are you willing to submit a pull request to fix on your own?
- [x] Yes I am willing to submit a pull request on my own!
Code of Conduct
- [x] I agree to follow this project's Code of Conduct
Comment From: NingleXu
Hi, I'm trying to improve support for Java record
types, but since record
is only available from JDK 16+, I'm not sure where to place the related unit tests in a JDK 8-compatible codebase.
Would it make sense to create a separate test module that only compiles under JDK 16+? Or is there a recommended way in the Dubbo project to handle version-specific features like this?
Comment From: AlbumenJ
Would it make sense to create a separate test module that only compiles under JDK 16+? Or is there a recommended way in the Dubbo project to handle version-specific features like this?
Yes, ut only in a separated module would be fine. FYI https://github.com/apache/dubbo-hessian-lite
Comment From: NingleXu
Yes, ut only in a separated module would be fine. FYI https://github.com/apache/dubbo-hessian-lite
Thanks! I’ll give that a try.
Comment From: oxsean
@NingleXu Any question about this?
Comment From: NingleXu
I’ve been quite busy lately and may not have time to continue on this immediately.
But I’d still like to help solve this when I can.
Here’s my current thought process for the fix:
1. Update BeanMeta.resolveConstructor
:
Use RecordUtils.isRecord(type)
to check if the class is a record, and if so, get the canonical constructor via RecordUtils.getCanonicalConstructor(type)
.
2. Refactor BeanArgumentBinder.bind
logic:
For records, instead of using setter-based logic like
current.setValue(...)
and meta.setValue(...)
,
construct the arguments array directly (e.g., args[i] = ...
) and then invoke the record constructor.
By the way, does this approach sound reasonable? Hope this helps if anyone wants to pick it up in the meantime!