Skip to content
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

Support for record types in JDK 14 #210

Closed
FrauBoes opened this issue Jul 23, 2020 · 2 comments
Closed

Support for record types in JDK 14 #210

FrauBoes opened this issue Jul 23, 2020 · 2 comments
Assignees
Milestone

Comments

@FrauBoes
Copy link
Contributor

Hi,

I work on the JDK, and I’m curious if you are planning to support record types in JDK 14? If so, I’d be happy to help.

From a runtime reflection point of view, Java 14 added two specific methods to support records:

  1. Class::isRecord
  2. Class::getRecordComponents (and its j.l.r.RecordComponent type)
    It is with these two primitives that the whole Java Serializable record support is built upon.

On the serializing side, a record's accessors can be used to extract the values of its components . On the deserializing side, the only way to instantiate the record object is to invoke the record's canonical constructor, which is passed the appropriate component values.

It is worth noting that starting in Java 15, core reflection will no longer be able to mutate the component fields of a record object. Construction should proceed through the canonical constructor.

Again, I'd love to to help to make XStream work out-of-the-box with records, so let me know if there is anything I can contribute.

@joehni joehni self-assigned this Jul 24, 2020
@joehni joehni added this to the 1.5.x milestone Jul 24, 2020
@joehni
Copy link
Member

joehni commented Jul 24, 2020

Hi,

yes, any contribution is welcome. Personally I have not yet looked at Records at all, but if you can provide a converter, that's fine.

Regards,
Jörg

@FrauBoes
Copy link
Contributor Author

Created PR #220

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants