RFR: JDK-8266503: [UL] Make Decorations safely copy-able and reduce their size [v2]
Thomas Stuefe
stuefe at openjdk.java.net
Fri May 7 05:42:51 UTC 2021
On Thu, 6 May 2021 21:24:56 GMT, Xin Liu <xliu at openjdk.org> wrote:
>> Hmm, would not the compiler warn you if you leave member initialization out?
>>
>> Your idea is not bad, but I usually avoid adding debug only members because you end up with different memory size and layout of data structures between debug and opt builds, which may have strange consequences when hunting bugs.
>>
>> Idk. I can do this here, I have no strong feelings either way.
>
> C++ won't warn you if you don't initialize member variables. Unlike Java, C++ even doesn't zero them for you by default.
>
> eg.
>
> #include <stdio.h>
> class T{
> public:
> int a, b, c;
> T() : b(0) {}
> };
>
> int main() {
> T t;
> printf("%d\n", t.a); // random value on stack
> printf("%d\n", t.b); // 0
> printf("%d\n", t.c); // random value on stack
> }
>
>
> It's relatively safe now because all member variables you added to LogDecorations are "scalars". If we extend an object decorator, printing an uninitialized object may result in undefined behavior.
>
> I am fine with/without it. can leave it to the future.
Okay, I'll add the check
-------------
PR: https://git.openjdk.java.net/jdk/pull/3874
More information about the hotspot-runtime-dev
mailing list