UUID reader literal is overly permissive


The first case can cause an issue if a UUID is pasted into the REPL, but the user failed to copy the last character (this is how I encountered it).




Andy Fingerhut
September 24, 2019, 4:57 PM

Someone has opened a bug against the JDK implementation for being inconsistent with the docs, here: https://bugs.openjdk.java.net/browse/JDK-8216407

Andy Fingerhut
September 24, 2019, 4:55 PM

Was curious about the behavior here a little bit, and it looks like Clojure is simply using a Java method to parse UUID strings, as shown in the implementation here:

Oddly, the Java API docs for the fromString method here: https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/util/UUID.html#fromString(java.lang.String)

claim that if the string “does not conform to the string representation as described in toString()”, then it will throw an exception. The format described the toString method here: https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/util/UUID.html#toString()

specifies precise numbers of characters for each part of the UUID, so it seems a little bit odd to me that the Java implementation of fromString is permissive like this.

It is up to others whether Clojure changes or not, but at least for some other issues efficiency and/or not working around the behavior of the underlying Java libraries has been a factor mentioned in leaving such behavior the way it is.

If that is the case here, then note that it is straightforward to customize for yourself what function is used to parse strings for the uuid tag:




Jason Felice



Affects versions