[SOLVED] Lemur Java 21 compatibility

I’m currently trying to upgrade one of my projects to java 21. As far as I can see Lemur isn’t compatible with it. Giving errors like

SEVERE: Uncaught exception thrown in Thread[#31,jME3 Main,5,main]
BUG! exception in phase 'semantic analysis' in source unit 'Script1.groovy' Unsupported class file major version 65
	at org.codehaus.groovy.control.CompilationUnit$ISourceUnitOperation.doPhaseOperation(CompilationUnit.java:905)
	at org.codehaus.groovy.control.CompilationUnit.compile(CompilationUnit.java:627)
	at groovy.lang.GroovyClassLoader.doParseClass(GroovyClassLoader.java:389)
	at groovy.lang.GroovyClassLoader.lambda$parseClass$3(GroovyClassLoader.java:332)
	at org.codehaus.groovy.runtime.memoize.StampedCommonCache.compute(StampedCommonCache.java:163)
	at org.codehaus.groovy.runtime.memoize.StampedCommonCache.getAndPut(StampedCommonCache.java:154)
	at groovy.lang.GroovyClassLoader.parseClass(GroovyClassLoader.java:330)
	at groovy.lang.GroovyClassLoader.parseClass(GroovyClassLoader.java:314)
	at groovy.lang.GroovyClassLoader.parseClass(GroovyClassLoader.java:257)
	at org.codehaus.groovy.jsr223.GroovyScriptEngineImpl.getScriptClass(GroovyScriptEngineImpl.java:336)
	at org.codehaus.groovy.jsr223.GroovyScriptEngineImpl.compile(GroovyScriptEngineImpl.java:181)
	at org.codehaus.groovy.jsr223.GroovyScriptEngineImpl.compile(GroovyScriptEngineImpl.java:188)
	at com.simsilica.lemur.style.StyleLoader.compileApiResource(StyleLoader.java:109)
	at com.simsilica.lemur.style.StyleLoader.compileApi(StyleLoader.java:89)
	at com.simsilica.lemur.style.StyleLoader.<init>(StyleLoader.java:82)
	at com.simsilica.lemur.style.StyleLoader.<init>(StyleLoader.java:62)
	at com.simsilica.lemur.style.BaseStyles.loadStyleResources(BaseStyles.java:72)
	at com.onemillionworlds.starlight.Starlight.initialiseStarStyle(Starlight.java:274)
	at com.onemillionworlds.devtools.NonVrLevelLauncher.simpleInitApp(NonVrLevelLauncher.java:67)
	at com.jme3.app.SimpleApplication.initialize(SimpleApplication.java:240)
	at com.jme3.system.lwjgl.LwjglWindow.initInThread(LwjglWindow.java:607)
	at com.jme3.system.lwjgl.LwjglWindow.run(LwjglWindow.java:710)
	at java.base/java.lang.Thread.run(Thread.java:1583)
Caused by: java.lang.IllegalArgumentException: Unsupported class file major version 65
	at groovyjarjarasm.asm.ClassReader.<init>(ClassReader.java:199)
	at groovyjarjarasm.asm.ClassReader.<init>(ClassReader.java:180)
	at groovyjarjarasm.asm.ClassReader.<init>(ClassReader.java:166)

I believe this is because Lemur uses quite an old version of groovy; 2.1.9.

Assuming I’m right; I wanted to ask if there were any plans to upgrade it?

1 Like

The version of groovy used is whatever version of groovy you include in your project. Lemur does not have a direct dependency on groovy.

…so you could just try using a newer version.

Edit: corrected “gradle” to “groovy” typo

Just to check, you said gradle but I’m talking about groovy? I must admit I don’t know much about how the lemur stylesheet compile works but I assumed it was separate from gradle; couldn’t a lemur project use maven, and then there wouldn’t be any gradle at all?

1 Like

I tend to use the latest versions of libraries in my projects.
I’m using Lemur with Java 21 in my fork of the jme-vehicles repo.
To make this work, my build script specifies version 3.0.19 of Groovy:

(This script overrides what’s specified in Lemur POM.)

2 Likes

I mistyped.

If you are getting that error then somewhere in YOUR build files you have an older groovy (the scripting language) dependency. Lemur will use whatever GROOVY you have in YOUR dependencies and does not directly specify a dependency of its own.

1 Like

The Lemur POM does not have a groovy dependency.

1 Like

The Lemur POM does not have a groovy dependency.

True! One can’t override a dependency that doesn’t exist.

If there were such a dependency in the POM, a Gradle script would override it, just as it overrides the jme3-core dependency.

So the dependency must be arising elsewhere. I don’t know where yet, but wherever it’s coming from, it’s likely Richtea can override it using Gradle.

Yeah, it’s true… it could be getting the dependency elsewhere.

For example, SiO2 does have a pom-level dependency on groovy.

As you say, easily overridden in the local gradle config if we have more information.

1 Like

Yes, you’re right. I do have a groovy dependency in my build.gradle. Presumably put there when I first started using Lemur then forgotten about. Increasing its version indeed resolves the issue.

Thanks @sgold and @pspeed

3 Likes