clj-kondo

https://github.com/clj-kondo/clj-kondo
Stefan 2020-11-12T08:50:19.407300Z

Hi! This morning, besides CLJ-Kondo also VSCode was updated. Now I’m getting this error:

Exception in thread "main" java.lang.UnsupportedClassVersionError: clj_kondo/lsp_server/main : Unsupported major.minor version 52.0
	at java.lang.ClassLoader.defineClass1(Native Method)
	at java.lang.ClassLoader.defineClass(ClassLoader.java:808)
	at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
	at java.net.URLClassLoader.defineClass(URLClassLoader.java:443)
	at java.net.URLClassLoader.access$100(URLClassLoader.java:65)
	at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
	at java.net.URLClassLoader$1.run(URLClassLoader.java:349)
	at java.security.AccessController.doPrivileged(Native Method)
	at java.net.URLClassLoader.findClass(URLClassLoader.java:348)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:430)
	at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:329)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:363)
	at sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:588)
[Info  - 9:42:46 AM] Connection to server got closed. Server will restart.
Has anyone else also seen it? My colleague (who is on Windows, I’m on Mac) does not have this issue apparently…

borkdude 2020-11-12T08:51:41.408100Z

hmm, this might be due to me accidentally using Java 11 for deployment? But then I would have expected version 55.0 not being supported, since 52.0 is the old one

borkdude 2020-11-12T08:52:24.408400Z

Are you using Java 1.7 or something on your system?

borkdude 2020-11-12T09:49:02.408600Z

^ @stefan.van.den.oord

Stefan 2020-11-12T09:49:32.409Z

@borkdude I’m using java 8 for this (but I also have java 7 around)

borkdude 2020-11-12T09:50:27.409600Z

Java SE 8 = 52
Java SE 7 = 51
https://stackoverflow.com/questions/22489398/unsupported-major-minor-version-52-0 My explanation would be that java 7 is on your path and this gets used by VScode

Stefan 2020-11-12T09:53:47.411200Z

I’m using asdf-vm so “that should not be possible” 😉 But your reasoning is correct. I’ll see if I can find out what vscode is using. But does your release explain that this now happens for the first time then?

borkdude 2020-11-12T09:55:04.412100Z

Could happen when the Java compiler emits bytecode that's only supported by Java 8 possibly? And it didn't before because it wasn't necessary? Dunno. Maybe you can type java -version in a vscode terminal

Stefan 2020-11-12T09:55:36.412600Z

openjdk version “1.8.0_265” OpenJDK Runtime Environment (AdoptOpenJDK)(build 1.8.0_265-b01) OpenJDK 64-Bit Server VM (AdoptOpenJDK)(build 25.265-b01, mixed mode)

pez 2020-11-12T09:58:55.413700Z

There could also be that Calva’s jackInEnv setting is in play, @stefan.van.den.oord.

borkdude 2020-11-12T09:58:59.413900Z

$ file ./clj_kondo/core__init.class
./clj_kondo/core__init.class: compiled Java class data, version 52.0 (Java 1.8)

borkdude 2020-11-12T09:59:02.414100Z

seems ok

Stefan 2020-11-12T09:59:51.414400Z

@pez Just defaults there…

borkdude 2020-11-12T10:00:50.414800Z

I don't have any other explanation than that Java 7 or older is invoked. Maybe remove it from your system and try again.

Stefan 2020-11-12T10:02:15.415400Z

I can try indeed. It won’t be a solution though because java7 is required for the product I’m developing on. 😞

borkdude 2020-11-12T10:06:05.416300Z

Either that or fix the path issue that is causing java7 to take precedence. Or make a PR that runs the clj-kondo server in a docker container ;) (Don't know if that's a good idea or not)

Stefan 2020-11-12T10:08:55.417200Z

I first need to understand why this broke. Java 7 is not on my path normally, thanks to asdf-vm. Tuesday it still worked.

borkdude 2020-11-12T10:10:01.417300Z

You could try to test if the older version of clj-kondo from the marketplace does work for you.

Stefan 2020-11-12T10:19:02.417500Z

Already did, same problem 😞 It does seem to be a local issue on my machine.

Stefan 2020-11-12T10:20:38.417700Z

Removing java 7 fixes it, so definitely local issue.

Stefan 2020-11-12T14:45:47.417900Z

Oh wow that was an interesting corner case. Using asdf-vm the required versions of all tools can be set on a per-directory basis. The global default is java 8, and in that one project I locally set it to java 7. When I open a terminal, it will use the default and all is fine. In this specific case, I happened to have shut down my mac with an open terminal window in that specific folder. After rebooting, the apps got automatically relaunched, and iTerm happily created the terminal in that folder again, causing it to default to Java 7. Pff. Anyway, solved. Thanks!

👍 1