UUID improvements for discussion

Roger Riggs Roger.Riggs at oracle.com
Mon Dec 14 20:15:40 UTC 2020


Hi,

A couple of PRs have been proposed to enhance the java.util.UUID API [3].

PR 1465 proposes a new API to create a UUID from a byte array.  [1]
Currently, the caller can convert the byte array to two longs and invoke 
the existing constructor.
The implementation has substantially the same method.

PR 1444 works to address the long standing dissatisfaction with creating 
a UUID from its string form.
The current java.util.fromString(string) method accepts input that does 
not conform to RFC 1422.
Changing the method to reject invalid input would not be a compatible 
change and has been rejected as a solution
several times.  This PR proposes to create a new `valueOf` method that 
accepts only valid input and to deprecate
the existing `fromString` method. Though it would be deprecated, the 
deprecation would serve as a warning to
new and upgraded applications. Due to compatibility concerns it is very 
unlikely that the method could be removed, perhaps ever.
The performance of creating a UUID would be the same with either method, 
the existing fromString method has been optimized.

Thoughts?

Thanks, Roger

[1] https://git.openjdk.java.net/jdk/pull/1465

[2] https://github.com/openjdk/jdk/pull/1444

[3] https://docs.oracle.com/en/java/javase/15/docs/api/java.base/java/util/UUID.html



More information about the core-libs-dev mailing list