Java interoperability, or interop, lets Clojure code use Java classes, methods, objects, and libraries. This makes Java SDK capabilities such as cryptography, networking, graphics, and math available without reimplementing them in Clojure. section 1.4 section 5.1
Choose the form that fits the operation:
- Use `.` to access a Java method or attribute, `..` for chained calls, and `doto` for a sequence of side-effecting calls. section 21.0
- Use `new` to construct an object. Use `try`, `catch`, `finally`, and `throw` for exception handling; `ex-info` and `ex-data` carry data with exceptions. section 21.0
- Use `bean` for a map-like interface to an object, `clojure.reflect` to inspect classes, and array functions or macros to create and transform Java arrays. section 21.0
A Clojure entry point to a Java method
An imported Java class can be called inside a Clojure function: `(defn plus [x y] (IntegerMath/plus x y))`. In an example with overloaded `plus` methods, mapping that wrapper over numbers produces `(4 5 6)`, but calls the `Object` overload. Even converting the arguments with `int` at the caller does not change that selection through the ordinary wrapper. Defining the wrapper with `definline` instead lets a direct call expand to the Java call at the call site; with those conversions, the example selects the `int` overload. section 4.5
`definline` provides both an ordinary function and an inline expansion. Direct calls can use the expansion, allowing type information to reach the Java call; passing the function as a higher-order argument uses its ordinary function definition instead. Reserve this optimization for cases that need it: `definline` was still marked experimental in Clojure 1.10. For routine work, interop is simply a way to use the Java capability already at hand alongside Clojure’s own functions. section 4.5 section 5.1

