clj-kondo

István Karaszi 2025-01-24T16:11:35.681049Z

How do you use (Class/forName) for a Java String array? When I try to use (Class/forName "[Ljava.lang.String;") I get the following error:

error: Function name must be simple symbol but got: "[Ljava.lang.String;"

István Karaszi 2025-01-24T16:12:22.138059Z

Or I should simply use? java.lang.String/1?

2025-01-24T16:13:20.944259Z

if you're using 1.12 already, then java.lang.String/1 is preferable, I think

👍 1
István Karaszi 2025-01-24T16:13:43.331429Z

Isn’t this a false error, though?

2025-01-24T16:14:25.450749Z

yes, looks like

lassemaatta 2025-01-24T16:15:10.960009Z

user=> (Class/forName "[Ljava.lang.String;")
java.lang.String/1
seems to work fine (EDIT: homerdisappear )

István Karaszi 2025-01-24T16:15:26.524319Z

Yes, it does work fine, but clj-kondo throws a warning

István Karaszi 2025-01-24T16:16:36.675389Z

https://github.com/clj-kondo/clj-kondo/issues/2277

borkdude 2025-01-24T16:17:25.425399Z

clj-kondo is correct since the Class/forName hack only works by accident, but luckily we have clojure 1.12 now

👍 2
borkdude 2025-01-24T16:18:00.752249Z

error message could be a little clearer though

István Karaszi 2025-01-24T16:19:22.419269Z

Yeah, that could have helped

borkdude 2025-01-24T16:21:50.951879Z

The title reflects that:

(proposal: say that it must be a simple symbol)
so I'll move this to a higher priority

borkdude 2025-01-24T16:22:17.485409Z

or wait, it shouldn't be a simple symbol, in this case

borkdude 2025-01-24T16:22:24.135789Z

whatever, I'll make a note

Alex Miller (Clojure team) 2025-01-24T16:51:33.492619Z

that's not a hack that works by accident, that's how Class/forName works

2025-01-24T16:51:49.332359Z

in extend-protocol calls?

Alex Miller (Clojure team) 2025-01-24T16:54:20.301789Z

oh, I missed that context at top

👍 1
Alex Miller (Clojure team) 2025-01-24T16:55:22.429659Z

I think symbol is certainly now preferred there

borkdude 2025-01-24T19:30:45.278049Z

PR is up: https://github.com/clj-kondo/clj-kondo/pull/2471

🙏 1
🎉 2
István Karaszi 2025-01-24T22:36:23.110149Z

You are a beast, @borkdude!