[prev in list] [next in list] [prev in thread] [next in thread] 

List:       openjdk-serviceability-dev
Subject:    Re: RFR: 8264124: Update MXBean specification and implementation to extend mapping of CompositeType 
From:       Mandy Chung <mchung () openjdk ! java ! net>
Date:       2021-03-31 21:47:08
Message-ID: T1CmwpTcj2TCC7KSDu_OU4SmgA1XoJONDwnJysyniy0=.462d05d2-5100-4ec3-a13e-4d6a44336950 () github ! com
[Download RAW message or body]

On Wed, 31 Mar 2021 21:02:51 GMT, Daniel Fuchs <dfuchs@openjdk.org> wrote:

> > This RFE proposes to extend the MXBean framework to define a mapping to records.
> > 
> > The MXBean framework already defines a mapping of `CompositeType` to plain java \
> > objects. Records are a natural representation of CompositeTypes. A record can be \
> > easily reconstructed from a `CompositeData` through the record canonical \
> > constructor. A clear advantage of records over plain java objects is that the \
> > canonical constructor will not need to be annotated in order to map composite \
> > data property names to constructor parameter names. 
> > With this RFE, here is an example comparing coding a composite type `NamedNumber` \
> > that consists of an `int` and a `String`, using records and using a plain java \
> > class. In both case, the `CompositeType` looks like this: 
> > CompositeType(
> > "NamedNumber",                      // typeName
> > "NamedNumber",                      // description
> > new String[] {"number", "name"},    // itemNames
> > new String[] {"number", "name"},    // itemDescriptions
> > new OpenType[] {SimpleType.INTEGER,
> > SimpleType.STRING}  // itemTypes
> > );
> > 
> > The plain Java class needs a public constructor annotated with \
> > `@ConstructorParameters` annotation: 
> > public class NamedNumber {
> > public int getNumber() {return number;}
> > public String getName() {return name;}
> > @ConstructorParameters({"number", "name"})
> > public NamedNumber(int number, String name) {
> > this.number = number;
> > this.name = name;
> > }
> > private final int number;
> > private final String name;
> > }
> > 
> > And the equivalent with a record class: 
> > 
> > public record NamedNumber(int number, String name) {}
> 
> Daniel Fuchs has updated the pull request incrementally with two additional commits \
> since the last revision: 
> - minor style issue
> - minor style issue

Thanks for making the change.  The spec change looks good to me.

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

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


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic