Deterministic naming of subclasses of `java/lang/reflect/Proxy`
Joseph D. Darcy
joe.darcy at oracle.com
Thu May 23 04:38:18 UTC 2024
On 5/22/2024 11:19 AM, Aman Sharma wrote:
>
> Hi,
>
[snip]
> Notice the difference in the order of fields and `helpCommand` method
> is mapped to a different field name in both classes. This happens
> because the method array returned by `getMethods` is not sorted in any
> particular order
> <https://github.com/openjdk/jdk/blob/master/src/java.base/share/classes/java/lang/Class.java#L2178>
> when generating a proxy class. What dictates this order? And why is it
> not deterministic?
>
>
> Regards,
> Aman Sharma
As a general comment, it is _not_ the goal of the API specification to
(over) specify exact behavior in cases like this.
See as an example the discussion concerning behavioral compatibility
starting around slide 46 of
"Contributing to OpenJDK: Participating in stewardship for the long-term,"
https://jcp.org/aboutJava/communityprocess/ec-public/materials/2023-06-13/Contributing_to_OpenJDK_2023_04_12.pdf
This approach has evolved over the years and releases.
In this case semantically, the array returned by getMethod is a set and
the no particular meaning should be read into the order of the elements.
HTH,
-Joe
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.org/pipermail/core-libs-dev/attachments/20240522/4035bb26/attachment-0001.htm>
More information about the core-libs-dev
mailing list