asciidoctor / asciidoctor-diagram

:left_right_arrow: Asciidoctor diagram extension, with support for AsciiToSVG, BlockDiag (BlockDiag, SeqDiag, ActDiag, NwDiag), Ditaa, Erd, GraphViz, Mermaid, Msc, PlantUML, Shaape, SvgBob, Syntrax, UMLet, Vega, Vega-Lite and WaveDrom.
http://asciidoctor.org
MIT License
445 stars 109 forks source link

jsyntrax diagram generation fails on Java 21 #467

Closed robertpanzer closed 3 months ago

robertpanzer commented 3 months ago

To reproduce convert the following document:

= Test
:source-highlighter: rouge
:data-uri:

== Test

[syntrax,testrail,svg]
----
indentstack(10,
  line(opt('-'), choice('0', line('1-9', loop(None, '0-9'))),
    opt('.', loop('0-9', None))),
  line(opt(choice('e', 'E'), choice(None, '+', '-'), loop('0-9', None)))
)
----

This fails when running with Java 21:

java -version
openjdk version "21.0.2" 2024-01-16 LTS
OpenJDK Runtime Environment Microsoft-8905927 (build 21.0.2+13-LTS)
OpenJDK 64-Bit Server VM Microsoft-8905927 (build 21.0.2+13-LTS, mixed mode, sharing)

The error message is:

./asciidoctorj -b pdf -r asciidoctor-diagram test.adoc --trace
OpenJDK 64-Bit Server VM warning: Options -Xverify:none and -noverify were deprecated in JDK 13 and will likely be removed in a future release.
Exception in thread "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(org/codehaus/groovy/control/CompilationUnit.java:905)
    at org.codehaus.groovy.control.CompilationUnit.processPhaseOperations(org/codehaus/groovy/control/CompilationUnit.java:671)
    at org.codehaus.groovy.control.CompilationUnit.compile(org/codehaus/groovy/control/CompilationUnit.java:635)
    at groovy.lang.GroovyClassLoader.doParseClass(groovy/lang/GroovyClassLoader.java:389)
    at groovy.lang.GroovyClassLoader.lambda$parseClass$3(groovy/lang/GroovyClassLoader.java:332)
    at org.codehaus.groovy.runtime.memoize.StampedCommonCache.compute(org/codehaus/groovy/runtime/memoize/StampedCommonCache.java:163)
    at org.codehaus.groovy.runtime.memoize.StampedCommonCache.getAndPut(org/codehaus/groovy/runtime/memoize/StampedCommonCache.java:154)
    at groovy.lang.GroovyClassLoader.parseClass(groovy/lang/GroovyClassLoader.java:330)
    at groovy.lang.GroovyShell.parseClass(groovy/lang/GroovyShell.java:526)
    at groovy.lang.GroovyShell.parse(groovy/lang/GroovyShell.java:538)
    at groovy.lang.GroovyShell.parse(groovy/lang/GroovyShell.java:570)
    at groovy.lang.GroovyShell.parse(groovy/lang/GroovyShell.java:565)
    at groovy.lang.GroovyShell$parse$0.call(groovy/lang/GroovyShell$parse$0)
    at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(org/codehaus/groovy/runtime/callsite/CallSiteArray.java:47)
    at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(org/codehaus/groovy/runtime/callsite/AbstractCallSite.java:125)
    at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(org/codehaus/groovy/runtime/callsite/AbstractCallSite.java:139)
    at org.atpfivt.jsyntrax.groovy_parser.Parser.<init>(org/atpfivt/jsyntrax/groovy_parser/Parser.groovy:29)
    at org.atpfivt.jsyntrax.Main.generateSVG(org/atpfivt/jsyntrax/Main.java:144)
    at org.asciidoctor.diagram.syntrax.Syntrax.generate(org/asciidoctor/diagram/syntrax/Syntrax.java:46)
    at org.asciidoctor.diagram.LazyDiagramGenerator.generate(org/asciidoctor/diagram/LazyDiagramGenerator.java:39)
    at org.asciidoctor.diagram.CommandProcessor.processRequest(org/asciidoctor/diagram/CommandProcessor.java:40)
    at org.asciidoctor.diagram.CommandProcessor.processRequest(org/asciidoctor/diagram/CommandProcessor.java:19)
    at jdk.internal.reflect.DirectMethodHandleAccessor.invoke(jdk/internal/reflect/DirectMethodHandleAccessor.java:103)
    at java.lang.reflect.Method.invoke(java/lang/reflect/Method.java:580)
    at org.jruby.javasupport.JavaMethod.invokeDirectWithExceptionHandling(org/jruby/javasupport/JavaMethod.java:315)
    at org.jruby.javasupport.JavaMethod.invokeDirect(org/jruby/javasupport/JavaMethod.java:176)
    at RUBY.send_request(uri:classloader:/gems/asciidoctor-diagram-2.3.1/lib/asciidoctor-diagram/util/java_jruby.rb:31)
    at RUBY.convert(uri:classloader:/gems/asciidoctor-diagram-2.3.1/lib/asciidoctor-diagram/syntrax/converter.rb:86)
    at RUBY.create_image_block(uri:classloader:/gems/asciidoctor-diagram-2.3.1/lib/asciidoctor-diagram/diagram_processor.rb:189)
    at RUBY.process(uri:classloader:/gems/asciidoctor-diagram-2.3.1/lib/asciidoctor-diagram/diagram_processor.rb:99)
pepijnve commented 3 months ago

I'm pretty sure this is a jsyntrax issue related to the version of groovy it uses. Might be best to log an issue in that project.

pepijnve commented 3 months ago

@inponomarev is this an issue you've seen before?

pepijnve commented 3 months ago

@robertpanzer I've gone ahead and published asciidoctor-diagram-jsyntrax v1.38.2 which bumps the bundled Groovy version to 4.0.22. No changes were required in the JSyntrax library itself. Could you give this a test?

robertpanzer commented 3 months ago

Thank you, @pepijnve! I have tested locally that 1.38.2 works with Java 11 and Java 21.