ObjectMethods seems generating wrong methods for array-type field
Kengo TODA
skypencil at gmail.com
Sat Apr 17 00:51:50 UTC 2021
Hello Rémi, Raffaello,
Thanks for your reply. I got it.
I knew that it's better to make Record classes immutable, and
now learn one more new thing :)
As suggested by Rémi, I'll read the amber-spec-experts mailing list.
I want to grasp the reason to use invokedynamic in these methods.
This is my first motivation to learn about the ObjectMethods class.
Hope that the mailing list will help me to find it.
Thank you very much!
***
Kengo TODA
skypencil at gmail.com
On Wed, Apr 14, 2021 at 6:12 PM Remi Forax <forax at univ-mlv.fr> wrote:
> ----- Mail original -----
> > De: "Kengo TODA" <skypencil at gmail.com>
> > À: "core-libs-dev" <core-libs-dev at openjdk.java.net>
> > Envoyé: Mercredi 14 Avril 2021 11:03:14
> > Objet: Re: ObjectMethods seems generating wrong methods for array-type
> field
>
> Hello,
>
> > I found that the JLS 16 does not cover the array type record component:
> > https://docs.oracle.com/javase/specs/jls/se16/html/jls-8.html#jls-8.10.3
> >
> > So it could be not a core-lib issue but a JLS issue.
>
> Nope, the implementation of a record is covered in the javadoc of
> java.lang.Record
> for equals, see
> https://docs.oracle.com/en/java/javase/16/docs/api/java.base/java/lang/Record.html#equals(java.lang.Object)
>
> As you can see the spec clearly says that for any fields which is an
> object (arrays are objects), it should be semantically equivalent to
> calling java.util.Objects.equals() on those fields.
>
> So it's not a bug, it's how record.equals() works, as Raffaello said,
> records are dumb containers, this is how we have specified them.
>
> Records have been specified as part of the project Amber, you can take a
> look to the mailing list [1] for more if you want.
>
> >
> > Do I need to forward this thread to another mailing list?
> > If so, please let me know which is the preferred one.
> > I've checked https://mail.openjdk.java.net/mailman/listinfo but not so
> sure.
> >
> >
> > Thank you very much.
>
> regards,
> Rémi
>
> [1] https://mail.openjdk.java.net/mailman/listinfo/amber-spec-experts
>
> >
> > ***
> > Kengo TODA
> > skypencil at gmail.com
> >
> >
> > On Wed, Apr 14, 2021 at 9:04 AM Kengo TODA <skypencil at gmail.com> wrote:
> >
> >> Hello there,
> >>
> >>
> >> I'm Kengo TODA, an engineer learning about the Record feature.
> >> Today I found a nonintentional behavior, and it seems that the bug
> >> database has no info about it.
> >> Let me ask here to confirm it's by-design or not. If it's a bug, I want
> to
> >> try to send a patch to OpenJDK.
> >>
> >> Here is the code reproducing the nonintentional behavior:
> >> https://gist.github.com/KengoTODA/4d7ef6a5226d347ad9385241fee6bc63
> >>
> >> In short, the ObjectMethods class in OpenJDK v16 generates code
> >> that invokes the fields' method, even when the field is an array.
> >>
> >> Please help me to understand this behavior, or
> >> make an entry in the bug database to propose a patch.
> >> Thanks in advance! :)
> >>
> >> ***
> >> Kengo TODA
> >> skypencil at gmail.com
>
More information about the core-libs-dev
mailing list