[lworld] RFR: 8357785: [lworld] TestResolvedJavaType fails due to unexpected getInstanceFields order [v2]
Quan Anh Mai
qamai at openjdk.org
Thu Jul 24 11:50:17 UTC 2025
On Thu, 24 Jul 2025 11:41:01 GMT, Marc Chevalier <mchevalier at openjdk.org> wrote:
>> src/hotspot/share/oops/fieldStreams.hpp line 277:
>>
>>> 275: */
>>> 276: template<typename FieldStreamType>
>>> 277: class HierarchicalFieldStream : public HierarchicalFieldStreamBase<FieldStreamType> {
>>
>> 1. It's good practice marking a class as `final` so the compiler can do more efficient devirtualization.
>> 2. It seems the `HierarchicalFieldStreamBase` is only for code reuse. Then it would be better to use private inheritance instead.
>
> 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
-------------
PR Review Comment: https://git.openjdk.org/valhalla/pull/1511#discussion_r2228284914
More information about the valhalla-dev
mailing list