On Thu, 26 Nov 2020 18:59:57 GMT, Richard Fussenegger 
<github.com+1059453+fleshgrin...@openjdk.org> wrote:

>> Made byte constructor public and changed the length assertion to an 
>> `IllegalArgumentException`, added a `getBytes` method that allows users to 
>> retrieve the raw bytes of the UUID, and created a new private constructor 
>> with an optimized construction for byte arrays that can set the version as 
>> desired and the variant to RFC 4122. Also changed the existing static 
>> factory methods to use the new constructor and removed the duplicate code 
>> from them where the variant and version is being set.
>> 
>> Report 
>> [5023614](https://bugs.java.com/bugdatabase/view_bug.do?bug_id=5023614) asks 
>> for more than what I provided and with different names. However, I believe 
>> that there is no value in providing methods to deal with `DataInput` and 
>> `DataOutput` because they would only encapsulate single method calls that 
>> the caller can directly write as well (e.g. `output.write(uuid.getBytes())` 
>> vs `uuid.write(output)`). Hence, I consider this change to satisfy the 
>> feature request.
>
> Richard Fussenegger has refreshed the contents of this pull request, and 
> previous commits have been removed. The incremental views will show 
> differences compared to the previous content of the PR. The pull request 
> contains one new commit since the last revision:
> 
>   5023614: UUID needs methods to get most/leastSigBits and write to DataOutput
>   
>   Made byte constructor public and changed the length assertion to an 
> `IllegalArgumentException`, added a `getBytes` method that allows users to 
> retrieve the raw bytes of the UUID, and created a new private constructor 
> with an optimized construction for byte arrays that can set the version as 
> desired and the variant to RFC 4122. Also changed the existing static factory 
> methods to use the new constructor and removed the duplicate code from them 
> where the variant and version is being set. Report 
> [5023614](https://bugs.java.com/bugdatabase/view_bug.do?bug_id=5023614) asks 
> for more than what I provided and with different names. However, I believe 
> that there is no value in providing methods to deal with `DataInput` and 
> `DataOutput` because they would only encapsulate single method calls that the 
> caller can directly write as well (e.g. `output.write(uuid.getBytes())` vs 
> `uuid.write(output)`). Hence, I consider this change to satisfy the feature 
> request.

src/java.base/share/classes/java/util/UUID.java line 151:

> 149:      * @throws IllegalArgumentException if {@code bytes} is not of 
> length 16.
> 150:      * @since 16
> 151:      */

I think you need to agreement first on whether to add this API. Maybe there is 
a case for a new factory method rather than a constructor? Are there any 
concerns with creating UUIDs with random bytes.

If it goes ahead then I assume the the javadoc will need a bit of work to 
specify how the byte[] is mapped to the 128-bit value.

You might need to tweak a few other things like the javadoc styles and coding 
style to get it consistent with the existing code. That's for later.

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

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

Reply via email to