Found an issue in clojure 1.12 which I thought was fixed due to Reflector.java changes, but it seems not (yet)
$ JAVA_HOME=~/Downloads/graalvm-jdk-17.0.12+8.1/Contents/Home clj
Clojure 1.12.0
user=> (/ 1 200)
1/200
user=> (Thread/sleep (/ 1 200))
nil
user=>
$ JAVA_HOME=~/Downloads/graalvm-jdk-22.0.1+8.1/Contents/Home clj
Clojure 1.12.0
user=> (/ 1 200)
1/200
user=> (Thread/sleep (/ 1 200))
Execution error (IllegalArgumentException) at user/eval3 (REPL:1).
No matching method sleep found taking 1 argsIt was supposed to fix (Thread/sleep 0.005) ?
Also no:
user=> (Thread/sleep 0.005)
Execution error (IllegalArgumentException) at user/eval5 (REPL:1).
No matching method sleep found taking 1 argsNo i meant, I was under the impression that something was fixed at some point relating to something that changed in java related to longs/ints passed to Thread/sleep, but does that also imply it's supposed to do something with floats/doubles? I might be thinking of something different than you're referring to.
could be... at least, code that used to work in JDK 17 now doesn't work anymore in JDK19+ which was the more general problem here which lead to Reflector changes
this one I believe: https://github.com/clojure/clojure/commit/3e2bfe64fd111323944ad98e9150898d893d74d1
The tests in that patch do work, but there's more cases that did work in JDK17
So in jdk 17 it rounded the ms to sleep for to zero there? Or 1?
Wouldn't have expected either really. Since at some point it would have to turn into a call to Thread/sleep(long millis), right?
yeah, I think there would be a cast inserted somewhere. not sure if this was defined behavior but I got similar error reports for bb when migrating to JDK19+ which I fixed using a workaround
I guess thinking about it as (long (/ 1 200)) makes a bit more sense than "rounding". Sorry for the side track, just was curious
I don't disagree necessarily, just wondering myself too
It is because java added a new overload on sleep
You now have a ratio, and two signatures and it matches neither
The changes in clojure above are about adjusting how the reflector handles widening and boxing, being able to pass a boxed Integer to a method that takes a primitive long
yes, makes sense. I'll just tell people to change their scripts in bb then and I'll remove the workaround that I had in place pre 1.12, as their code would now also crash with 1.12
Clojure does cast in these situations when there is one signature, but the target has changed
Ah I see the original issue wasn't even about these non-long-ish types: https://github.com/babashka/babashka/issues/1619, just about Integer, so yes, this is fixed in 1.12. Thanks all!