beginners 2025-11-06

Given public DynamicArray(Class<T> type, List<T> values) how do I suppress reflection warnings? I tried with this but still get warning : (DynamicArray. ^Class Uint256 ^java.util.List [(Uint256. 1) (Uint256. 2)])

✅ 1

well this works, are there any more concise ways I wonder.. (DynamicArray. ^Class Uint256 ^java.util.List (java.util.Arrays/asList (into-array [(Uint256. 1) (Uint256. 2)])))

you shouldn't need the list type hint. do you?

now I got this: (DynamicArray. Uint256 ^java.util.List (list (Uint256. 1) (Uint256. 2))) List hint still needed

Alternatively:

(let [^java.util.List v [(Uint256. 1) (Uint256. 2)]]
  (DynamicArray. Uint256 v))

https://clojurians.slack.com/archives/C03S1KBA2/p1701965670807469?thread_ts=1701965150.618159&amp;cid=C03S1KBA2 Also read a few messages that follow - there's an arguably nicer way to do it in 1.12.

How do I do it the 1.12 way? (^[Uint256] DynamicArray. Uint256 [(Uint256. 1) (Uint256. 2)]) this doesn't seem to work.

(^[Class java.util.List] DynamicArray. Uint256 [(Uint256. 1) (Uint256. 2)])

(^[Class java.util.List] DynamicArray. Uint256 [(Uint256. 1) (Uint256. 2)]) nope, this one warns as well 😂

Oh, what the... Maybe type hints on the Class. kind of forms don't work? Ah, probably because it gets turned into (new Class). (^[Class java.util.List] DynamicArray/new Uint256 [(Uint256. 1) (Uint256. 2)]) seems to work though.

yeah, this one works 😂

And I just realized Class is not need, I can also have (^[_ java.util.List] DynamicArray/new Uint256 [(Uint256. 1) (Uint256. 2)])

And if you add (:import (java.util List)) it can be even shorter, but that might have other consequences.

thanks, I guess that's the final form given 1.12

👍 1

Hi, if I'm developing a project that uses both clojure and java, how can I reload a java .class file? Example: I have a java file compiled to a .class file to be able to import it from clojure; then I make a change to the java file, compile it again, how can I make the change available to clojure? Kinda like, reload the class definition to check if there's a newer .class file.

That's exactly what I needed. Thanks!