RFR: 8255992: JFR EventWriter does not use first string from StringPool with id 0

Jie Kang jkang at openjdk.java.net
Thu Nov 12 14:02:10 UTC 2020


On Thu, 12 Nov 2020 10:11:17 GMT, Erik Gahlin <egahlin at openjdk.org> wrote:

>> This allows string pool entry with id 0 to be written in short form for the event data.
>
> The id 0 is reserved for representing null in JFR constant pools, and should not be used to represent real values in the file format. Strings are special, since they have their own way to represent null, but I still think it is bad form to use id 0 for a real value (even if it should happen to work).
> 
> Perhaps the counter should start with 1, or incrementAndGet() should be used?

That makes sense, thanks for taking a look. I have chosen to start the `AtomicLong` with one as it will hopefully be more clear that it was an explicit choice compared to `incrementAndGet()`.

-------------

PR: https://git.openjdk.java.net/jdk/pull/1097


More information about the hotspot-jfr-dev mailing list