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 Fri, 7 May 2021 05:39:06 GMT, Thomas Stuefe <stuefe at openjdk.org> wrote:
>> 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
(I think static checkers like Sonarcloud would pick those simple errors up)
-------------
PR: https://git.openjdk.java.net/jdk/pull/3874
More information about the hotspot-runtime-dev
mailing list