The following probably does not matter much because I am not an OpenJDK 
contributor, but personally
I think throwing an UnsupportedOperationException is reasonable:
  1. It is consistent with the other methods which also only work for one 
specific variant
  2. Code which calls UUID.version() on a non-variant 2 UUID is obviously 
already functionally broken;
     I don't think maintaining backward compatibility here adds any value

Regarding the pull request, I would recommend the following changes:
  1. Replace ` ` with a normal space, that should work as well and is 
easier to read
  2. Add a sentence to the method description (and not only to the `@throws` 
tag), that this method
     is only meaningful for variant 2 UUIDs, see for example the documentation 
for `timestamp()` for
     how this sentence should look like to be consistent:
     
https://docs.oracle.com/en/java/javase/15/docs/api/java.base/java/util/UUID.html#timestamp()

Kind regards

Reply via email to