JDK-8207329 : Add a constant for a nil UUID value of all zeros: `java.util.UUID.NIL`
  • Type: Enhancement
  • Component: core-libs
  • Sub-Component: java.util
  • Affected Version: 11
  • Priority: P4
  • Status: Closed
  • Resolution: Won't Fix
  • Submitted: 2018-07-15
  • Updated: 2020-12-01
  • Resolved: 2020-12-01
Description
A DESCRIPTION OF THE PROBLEM :
The `java.util.UUID` class represents UUID values, 128-bit values with a bit pattern defined by RFC 4122 as linked in the class documentation. Section 4.1.7 of that RFC defines a 'nil UUID' made of zeros. To quote the RFC: 'The nil UUID is special form of UUID that is specified to have all 128 bits set to zero.' 

For the convenience of Java programmers, I suggest adding a constant value to the `java.util.UUID` class named `NIL`, with a fixed value of all zeros across the bits. 

A `UUID.NIL` constant would be quite handy for code where we are passing and checking for nil UUID values as temporary placeholders or to avoid NULL values. Instead of having to repeatedly instantiate our own:

    UUID nil = new UUID( 0L , 0L ) ;
    person.id = nil ;  // Placeholder until a proper UUID value is generated later.

we could use the constant.

    person.id = UUID.NIL ;  // Placeholder until a proper UUID value is generated later.



Comments
The bug report does not make a strong case for adding a NIL constant to the UUID API. It would add (a small amount) to both footprint and startup time with very limited benefit. Any application needing a placeholder can do so itself and all existing applications take care of their own needs.
01-12-2020

Additional information from another submitter: https://github.com/openjdk/jdk/pull/1460
27-11-2020