<div dir="ltr"><div dir="ltr"><div class="gmail_default" style="font-family:arial,helvetica,sans-serif"><br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Thu, Jun 13, 2024 at 8:39 AM Alan Bateman <<a href="mailto:Alan.Bateman@oracle.com">Alan.Bateman@oracle.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><u></u>
<div>
On 12/06/2024 15:23, David Lloyd wrote:<br>
<blockquote type="cite">
<div dir="ltr">
<div dir="ltr">
<div style="font-family:arial,helvetica,sans-serif"><br>
</div>
</div>
:<br>
<div dir="ltr">
<div class="gmail_quote">
<div style="font-family:arial,helvetica,sans-serif">.</div>
</div>
</div>
<div class="gmail_quote">
<div><br>
</div>
<div>
<div style="font-family:arial,helvetica,sans-serif">I have a
*very* rough prototype up [1]. It adds two new accessor
methods to `ReflectionFactory`:
`defaultReadObjectForSerialization` and
`defaultWriteObjectForSerialization`. It was easier than
expected, due largely to the classfile API, which is
really nice.</div>
<div style="font-family:arial,helvetica,sans-serif"><br>
</div>
<div style="font-family:arial,helvetica,sans-serif">These
methods create an artificial `readObject`/`writeObject`
method in a hidden+nestmate class connected to the
original class, which uses the stream's
`GetField`/`PutField` to access the stream data and normal
field operations to access the class fields. For usage,
these methods can be used when
`read|writeObjectForSerialization` return `null`, *or*
when `defaultRead|WriteObject` is used.</div>
<br>
</div>
</div>
</div>
</blockquote>
Good to hear you've got a prototype to discuss. I don't think I can
look at what you have in your own repo but I do have a question. Do
the defaultXXX methods return a method handle or do they fail/null
when there are read/writeObject methods? Asking if they will bypass
these methods.<br></div></blockquote><div><br></div><div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif">They will still return a method handle in this case. The method handle doesn't *bypass* the provided methods - per se - for example if the fields in question are `transient` then these methods would not access them. But, I could not think of any other way to deal with the `defaultReadObject`/`defaultWriteObject` situation than to allow serialization libraries to do this (where the OIS/OOS implementation is being asked by the serialized class to read or write the field values from/to the serialization stream). Maybe you have another idea?</div><br></div></div><span class="gmail_signature_prefix">-- </span><br><div dir="ltr" class="gmail_signature"><div dir="ltr">- DML • he/him<br></div></div></div>