On Wed, 31 Mar 2021 18:32:31 GMT, Mandy Chung <mch...@openjdk.org> wrote:

>> Hi Mandy, I have updated the PR with a revised version of the text above. Is 
>> that more in line what you had in mind?
>> 
>> best regards,
>> -- daniel
>
> This looks better.  I like a separate mapping section for records since the 
> mapping rules are straight-forward.   The complexity comes if we want to 
> support a record to implement `CompositeDataView` that allows a type to 
> support more flexible conversion to `CompositeData` which is why you add 
> records in the "Mappings for other types".   I am wondering if we really want 
> to support records to implement `CompositeDataView` but we may want to avoid 
> such a special case.
> 
> I suggest add subsections in "Mappings for other types":   There are two 
> mapping rules: (1) _opentype(J)_ maps `J` to `CompositeType` (2) 
> _opendata(J)_ maps `J` to `CompositeData`.   _opentype(J)_ for record class 
> does not need to refer to other types.   The common cases for _opendata(J)_ 
> for record class is using the canonical constructors.   The other less common 
> cases like using non-canonical constructors and `CompositeDataView` can state 
> that it follows the same rules as specified for other types.   "Mappings for 
> other types" does not need any change for records.   
> 
> "Reconstructing an instance of Java type J from a CompositeData" section 
> should be renamed to "Reconstructing an instance of Java type or record class 
> J from a CompositeData"
> 
> Here is a minor tweaking on "Mappings for Records"
> 
> A record is convertible to a CompositeType if and only if all its components 
> are 
> convertible to open types. Otherwise, it is not convertible.
> 
> A record class is converted to a CompositeType with one item for every record 
> component as follows.
> - The type name of this CompositeType is determined by the type name rules 
> detailed below. 
> - Each record component of type T, the item in the CompositeType has the same 
> name 
>   as the record component and of type opentype(T).
> 
> The mapping from an instance of a record class to a CompositeData 
> corresponding to 
> the CompositeType is the same as specified as for other types (add a link).
> 
> A record is reconstructed from a CompositeData using its canonical 
> constructor. 
> The canonical constructor doesn't require the presence of 
> @javax.management.ConstructorParameters 
> or @java.beans.ConstructorProperties annotations. If these annotations are 
> present on
> the canonical constructor, they will be ignored.
> 
> If the CompositeData from which the record is reconstructed doesn't contain 
> all the record components, 
> the MXBean framework will attempt to reconstruct the record in the same way 
> as specified for 
> other types (add a link).

I have updated the PR with those changes, plus a few minor adjustments.

-------------

PR: https://git.openjdk.java.net/jdk/pull/3201

Reply via email to