tools-build 2024-08-13

What java version does compile-clj compile to? Is it possible to control that?

https://clojure.github.io/tools.build/clojure.tools.build.api.html#var-compile-clj you can use :java-opts with ["-target" "8" ,,,] for that

those opts affect javac and looking at the source, compile-clj will invoke java with clojure.main that executes a script generated on the fly, that calls clojure.core/compile a bunch. And I assume that always produces class files in the version of the current JVM

you're right

It is not about compile-clj, it is in clojure.core. Clojure uses a Java library to emit it's bytecode: asm2 And it has no options to support more than one version Currently, it dont use any asm operation that is not supported by jvm1.8

but will it mark the file as java 8?

probably

Alex Miller (Clojure team) 2024-08-13T11:59:58.260269Z

Yes

Alex Miller (Clojure team) 2024-08-13T12:00:30.967179Z

Current versions of Clojure only emit Java 8 bytecode

Alex Miller (Clojure team) 2024-08-13T12:01:17.152219Z

Specifically Clojure 1.10-1-12 emits Java 8 bytecode, older emits Java 6 bytecode

Alex Miller (Clojure team) 2024-08-13T12:01:48.485319Z

We expect to move this baseline in next version after 1.12

Thanks, that is sufficient

Where are you going to move it to? Any gains from that?

Alex Miller (Clojure team) 2024-08-13T12:02:50.954699Z

Haven’t decided yet

Alex Miller (Clojure team) 2024-08-13T12:03:23.744829Z

Moving to newer bytecode version gives us access to newer JVM features