Project SDK not used when compiling Java code
When including ':java-source-paths' in project.clj and using a Project SDK (in my case Java 8) I get the following problem when starting repl:
#error {
:cause org/some/util/SomeJavaClass has been compiled by a more recent version of the Java Runtime (class file version 55.0), this version of the Java Runtime only recognizes class file versions up to 52.0
It seems that the Java source is compiled using the Java version available on system path rather than using the one specified wihtin Project SDK.
Cursive: 1.9.4-eap3-2020.2 IntelliJ: 2020.2.1
Interesting, I'm not entirely sure why that is happening, it's possible that the Java source is being compiled using the JDK used by IntelliJ itself - I'm not sure at which stage lein compiles Java classes.
Does adding this option to your project.clj help?
:javac-options ["-target" "1.8" "-source" "1.8"]
Yes! Adding this option makes it compile. I guess it is still not using the project SDK, but at least the class files are compatible. This resolves my problem. Thanks!
Exactly, I'd have to investigate to fully figure it out, but I suspect that your IntelliJ JDK (probably 11) is doing the compiling somehow. But I'm glad the workaround works around!
@hplatou you can also change the jdk version required for the project by going into the top-left-corner in intellij then in Main Menu -> File -> Project Structure and change the jdk version accordingly.
- Then intellij will pick up the new jdk specified
cc: @cursive-ide