[lworld] RFR: 8357785: [lworld] TestResolvedJavaType fails due to unexpected getInstanceFields order [v2]
Marc Chevalier
mchevalier at openjdk.org
Fri Jul 25 07:27:12 UTC 2025
On Thu, 24 Jul 2025 11:47:20 GMT, Quan Anh Mai <qamai at openjdk.org> wrote:
>> 1. Yes, good idea. I like that mostly for maintenance. On the other hand, despite my hopes, I never observed really compilers taking advantage of it in the wild (on made up examples, yes, of course).
>> 2. I don't think I can: the public methods of the base class would then be private, and I need them in the public interface of the class. I've tried, and indeed, it doesn't compile.
>
> I believe they do devirtualize with `final` while non-`final` methods go through the whole virtual call sequence: https://godbolt.org/z/9MM1Kqqx8
Yes, of course, it can in such cases. But in actual code, I often end up with either an object of the final type (instead of a reference), and then, final doesn't help, or a reference/pointer to a base type, and so I don't save virtual call. In the past, some big campaign of `final`izing everything were rewarded by no measurable performance improvement. But I still like it, as a hint for the reader not to try to find derived classes (but that the class actually is done implementing the thing it does), a warning that the class wasn't meant to be inherited (so be careful), and still hoping one in a while, it can save some virtual calls.
-------------
PR Review Comment: https://git.openjdk.org/valhalla/pull/1511#discussion_r2230364286
More information about the valhalla-dev
mailing list