Clojure 1.11.3
Clojure 1.11.3 is now available. CLJ-2843 - Reflective calls to Java methods that take primitive long or double now work when passed a narrower boxed number at runtime (Integer, Short, Byte, Float). Previously, these methods were not matched during reflection and an error was thrown. Java 21 added an overload to the method Thread/sleep in the 1-arity. When upgrading to Java 21, existing Clojure calls to Thread/sleep become reflective, but continue to work. As usual, you can detect reflection with *warn-on-reflection* and address with a type hint (here, ^long ) to choose the desired overload. Previously, passing a Short or Integer value to a reflective call like Thread/sleep that takes a long would not match, that has been corrected.

Clojure 1.11.3 has been released, bringing a significant improvement in how reflective calls to Java methods handle primitive long and double types. This version addresses the issue outlined in CLJ-2843, which previously caused errors when passing narrower boxed numbers like Integer, Short, Byte, or Float to methods expecting a primitive long or double during runtime.
In Clojure 1.11.3, reflective calls now correctly match and work with these narrower boxed numbers. This means that developers no longer encounter errors when using these types with Java methods that expect a primitive long or double. This enhancement ensures smoother interoperability between Clojure and Java, allowing for more flexible and efficient programming.
Another notable change in Clojure 1.11.3 is its compatibility with Java 21. Java 21 introduced an overload to the Thread/sleep method in its 1-arity, which means it now has multiple methods with the same name but different parameters. When upgrading to Java 21, existing Clojure calls to Thread/sleep automatically become reflective. Despite this change, these calls continue to function as expected, providing seamless integration with the updated Java version.
To help developers manage and understand reflective calls, Clojure provides the *warn-on-reflection* flag. This flag can be enabled to warn users when a reflective call is detected, allowing them to take appropriate action. If a specific overload is desired, developers can use a type hint, such as ^long, to explicitly choose the intended method.
The improvements in Clojure 1.11.3 not only resolve previous issues but also enhance the overall stability and compatibility of the language with newer Java versions. By addressing the CLJ-2843 bug and adapting to Java 21's changes, Clojure continues to evolve as a robust and reliable tool for functional programming.
For developers already using Clojure, upgrading to version 1.11.3 is highly recommended to take advantage of these enhancements. The updated version ensures smoother operation with Java methods and provides better support for newer Java releases. As always, Clojure's commitment to interoperability and reliability makes it an excellent choice for both new and experienced programmers.
In conclusion, Clojure 1.11.3 represents a significant step forward in addressing reflective call issues and ensuring compatibility with Java 21. With improved handling of primitive long and double types, as well as enhanced support for reflective calls, this version offers a more robust and efficient development experience. By resolving previous challenges and adapting to new Java features, Clojure continues to demonstrate its dedication to innovation and reliability in the functional programming community.









