RFR: 8333796: Add missing serialization functionality to sun.reflect.ReflectionFactory
David M. Lloyd
duke at openjdk.org
Mon Jul 22 15:21:34 UTC 2024
On Tue, 16 Jul 2024 18:34:00 GMT, Roger Riggs <rriggs at openjdk.org> wrote:
> Is there a high level description of how these methods would be used?
They would be used identically to how the `readObjectForSerialization` and `writeObjectForSerialization` methods are used. The caller would pass the object as a pseudo-"receiver" and the OIS/OOS, and it would be as if the caller had called a method handle to a `readObject` or `writeObject` that writes or reads the serializable fields of the object based on acquiring a `GetField`/`PutField` object.
> There seems to be a lot of generation of code that duplicates what OIS/OOS already do and that seems unnecessary.
The current iteration simulates the behavior described above by generating methods that exactly and literally implements the behavior as specified. That said, I agree that there could possibly be a way to reuse OIS/OOS code for this instead, so that the method works *as if* it had been generated (but instead would be a stub which calls the relevant OIS/OOS method(s) with the appropriate arguments). It might require some small refactoring. My initial thought was to avoid touching that code as much as possible, but I can look into reusing the existing `Unsafe`-based code more and see what that would look like.
-------------
PR Comment: https://git.openjdk.org/jdk/pull/19702#issuecomment-2243219626
More information about the core-libs-dev
mailing list