-
Notifications
You must be signed in to change notification settings - Fork 166
Description
In the near future, Java will start restricting deep reflection - for example, setAccessible(true) will become a problem.
The current approach to solution cloning relies heavily on deep reflection, and it can not be fixed. For example, the cloner will use setAccessible(true) to be able to write a final field after the encapsulating object was already created. A new approach to cloning will be necessary. Possibilities include:
- @JsonCreator-like approach.
- @ConstructorProperties-like approach.
PlanningClonableinterface; maybe not ideal.- Wait until Java finishes serialization 2.0, which will likely provide mechanisms for this. Unfortunately, as this would require an upgrade of the minimum version of the JDK, this is unlikely to be applicable any time soon; a solution to this issue will likely be required earlier.
Gizmo cloner
We already support the Gizmo-based cloner, which does not use deep reflection. However, outside of Quarkus, it requires all mutable fields to be public, which arguably no user would be excited about doing. If we decide to go for the @JsonCreator approach, we may be able to fully generate cloners even without forcing the user to accept such workarounds, giving peak performance to everyone in all circumstances. As an added bonus, this would allow us to only have a single implementation of the cloner.