Fork me on GitHub
#clj-kondo
<
2024-04-18
>
lavh15:04:17

👋 Hello people! In the company I work, we are migrating our services to Java 21. Yesterday we had a production issue because one of the services where using something like (Thread/sleep (get-from-json-config config)) This code works until Java 17, but with Java 21 it fails because sleep can receive a long or a Duration now. We are already using clj-kondo in the pipeline, but the reflection warning is off, and we wouldn't like to turn it on for all cases for while. Is there a way I can check only these specific reflection cases related with Thread/sleep?

borkdude15:04:33

Unfortunately not right now

Alex Miller (Clojure team)15:04:25

when you say "it fails", what do you mean?

borkdude15:04:41

I guess lavh means: reflection happens. Not sure what the failure is though. With native-image this can cause an issue

Alex Miller (Clojure team)15:04:02

yes, should become reflective. I was not thinking of native-image though, that makes sense

Alex Miller (Clojure team)15:04:09

presumably adding the ^long type hint should resolve and works in both older and newer jdks

Alex Miller (Clojure team)15:04:39

I updated that to clarify "fail".

🙏 2
seancorfield17:04:47

This sort of thing is why we have (set! *warn-on-reflection* true) in every file and we fail CI if a) a new file is added without that line or b) a new reflection warning in our own code appears... Stricter than you're talking about but it caught all the Thread/sleep issues when we updated past JDK 17...