interop 2023-05-25

Hi there, Im trying to remove reflection on a ^bytes type hinted parameter to a java call. If I type hint the byte-array directly, it works, but if I type hint a (when ..) to enable a null to be passed in, the reflection cant find the call, and thinks its a java.lang.Object, not a bytes! Any idea what is going on here and how to type hint this correctly?

code that works:

(KeyPair/load
      ^JSch (references/get-instance agent)
      ^bytes (utils/decode-base64 private-key-bytes)
      ^bytes (utils/decode-base64 public-key-bytes))

code that doesn't:

(KeyPair/load
      ^JSch (references/get-instance agent)
      ^bytes (when private-key-bytes (utils/decode-base64 private-key-bytes))
      ^bytes (when public-key-bytes (utils/decode-base64 public-key-bytes)))

results in a call to static method load on com.jcraft.jsch.KeyPair can't be resolved (argument types: com.jcraft.jsch.JSch, java.lang.Object, java.lang.Object).

suddenly they are java.lang.Object which is wrong

(the code works with reflection... I just would like to remove it)

Alex Miller (Clojure team) 2023-05-25T14:58:46.428289Z

you might want to pull the expr out into a let

alright, yeah that now resolves the right static method.

Is it because when is a macro?

somehow loses the metadata?