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

[Java] Deserializing one pojo into another type #1998

Open
chaokunyang opened this issue Jan 8, 2025 · 4 comments
Open

[Java] Deserializing one pojo into another type #1998

chaokunyang opened this issue Jan 8, 2025 · 4 comments

Comments

@chaokunyang
Copy link
Collaborator

chaokunyang commented Jan 8, 2025

Feature Request

Continuing the discussion in #1972 (comment), we need to support deserializing one pojo into another type without the need to register class

Is your feature request related to a problem? Please describe

#1972

Describe the solution you'd like

Step1 Extend ClassDef to replace type

  /**
   * Return a new {@link ClassDef} by replacing {@code definedClass} of all fields and current {@link ClassSpec} in hierarchy 
   * from {@code cls} into {@code targetCls}.
   */
  public ClassDef replace(Class<?> cls, Class<?> targetCls) {

  }

Step2

  • Extend ClassResolver with a new readClassInfoWithMetaShare method with passed deserialized type
  • The readClassInfoWithMetaShare should return the original ClassDef first, then invoke ClassDef#replace to return a new ClassDef
  • Use that new ClassDef to create a new Deserializer to deserialize the data into passed deserialized type

Describe alternatives you've considered

No response

Additional context

#1996

@chaokunyang
Copy link
Collaborator Author

cc @orisgarno

@orisgarno
Copy link
Contributor

will start this in few days

@orisgarno
Copy link
Contributor

@chaokunyang im currenty working on it.
but do you have any idea why we need the original class(cls) public ClassDef replace(Class<?> cls, Class<?> targetCls)?
we can get from the classid from metashare? or do i miss something here?

@chaokunyang
Copy link
Collaborator Author

chaokunyang commented Jan 18, 2025

We don't need the original class, we could add a method like replaceRootClassTo(Class <?> cls)

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

No branches or pull requests

2 participants