I'm am using parboiled as a dependency:
// https://mvnrepository.com/artifact/org.parboiled/parboiled-java
api 'org.parboiled:parboiled-java:1.4.1'
After updating from java 17 to 21 I am getting this error at runtime when trying to create a parser:
java.lang.RuntimeException: Error creating extended parser class: Unsupported class file major version 65
at org.parboiled.Parboiled.createParser(Parboiled.java:58)
Version 65 class files is Java 21. The parser class is now indeed compiled with target 21. Why would parboiled not work with it? Any other workarounds outside of downgrading to target 17?
Minimal reproducible example:
build.gradle
plugins {
id "application"
}
apply plugin : "java"
ext {
javaMainClass = "test.TestParser"
}
application {
mainClassName = javaMainClass
}
dependencies {
implementation 'org.parboiled:parboiled-java:1.4.1'
}
TestParser.java
package test;
import org.parboiled.BaseParser;
import org.parboiled.Parboiled;
import org.parboiled.Rule;
import org.parboiled.annotations.BuildParseTree;
@BuildParseTree
public class TestParser extends BaseParser<Object> {
public Rule InputLine() {
return Sequence(Digit(), EOI);
}
Rule Digit() {
return CharRange('0', '9');
}
public static void main(String[] args) {
TestParser parser = Parboiled.createParser(TestParser.class);
}
}
gradle run
Configuration on demand is an incubating feature.
> Task :test2:compileJava
> Task :test2:processResources NO-SOURCE
> Task :test2:classes
> Task :test2:run FAILED
Exception in thread "main" java.lang.RuntimeException: Error creating extended parser class: Unsupported class file major version 65
at org.parboiled.Parboiled.createParser(Parboiled.java:58)
at test.TestParser.main(TestParser.java:34)
Caused by: java.lang.IllegalArgumentException: Unsupported class file major version 65
at org.objectweb.asm.ClassReader.<init>(ClassReader.java:199)
at org.objectweb.asm.ClassReader.<init>(ClassReader.java:180)
at org.objectweb.asm.ClassReader.<init>(ClassReader.java:166)
at org.objectweb.asm.ClassReader.<init>(ClassReader.java:287)
at org.parboiled.transform.AsmUtils.createClassReader(AsmUtils.java:59)
at org.parboiled.transform.ClassNodeInitializer.process(ClassNodeInitializer.java:62)
at org.parboiled.transform.ParserTransformer.extendParserClass(ParserTransformer.java:44)
at org.parboiled.transform.ParserTransformer.transformParser(ParserTransformer.java:39)
at org.parboiled.Parboiled.createParser(Parboiled.java:54)
... 1 more