RFR: 8368966: Remove spurious VMStructs friends
Francesco Andreuzzi
fandreuzzi at openjdk.org
Wed Oct 1 14:26:12 UTC 2025
On Wed, 1 Oct 2025 07:34:00 GMT, Stefan Karlsson <stefank at openjdk.org> wrote:
> Was this done because you removed the one in the parent class?
Yeah that's the reasoning.
> the exposed _data field is inside GrowableArrayView, so maybe it would work to put the friend declaration there instead?
Actually I'm a bit confused. What you suggest _should not_ work, but it compiles happily. Friendship is not inherited, so we should not be able to access `GrowableArray::_data` if we move `friend class VMStructs` to `GrowableArrayView`.
I thought maybe that was a quirk of `offsetof`, but that does not seem to be the case:
#include <cstddef>
class X {
protected:
int field;
};
class Y : public X {};
class Z {
friend X;
void doStuff() {
Y y;
// both these are illegal
// int foo = y.field;
// int foo = offsetof(Y, field);
}
};
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/27583#discussion_r2394806258
More information about the hotspot-dev
mailing list