dart-lang / native

Dart packages related to FFI and native assets bundling.
BSD 3-Clause "New" or "Revised" License
155 stars 43 forks source link

[jnigen] Document what version of Java to use and how to use the right one. #1430

Open dcharkes opened 2 months ago

dcharkes commented 2 months ago
Picked up JAVA_TOOL_OPTIONS: -Dfile.encoding=UTF8
Exception in thread "main" java.lang.RuntimeException: java.lang.IllegalArgumentException: Unsupported class file major version 65
        at com.github.dart_lang.jnigen.apisummarizer.util.ExceptionUtil.wrapCheckedException(ExceptionUtil.java:22)
        at com.github.dart_lang.jnigen.apisummarizer.disasm.AsmSummarizer.run(AsmSummarizer.java:21)
        at com.github.dart_lang.jnigen.apisummarizer.Main.main(Main.java:129)
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 com.github.dart_lang.jnigen.apisummarizer.util.ExceptionUtil.wrapCheckedException(ExceptionUtil.java:20)
        ... 2 more

Fatal: Cannot generate summary: FormatException: Unexpected end of input (at character 1)

Maybe we can parse exceptions throw in the summarizer, and tell users what to do. (I'm assuming something is wrong with my Java version here.)

dcharkes commented 2 months ago

And on another machine:

Picked up JAVA_TOOL_OPTIONS: -Dfile.encoding=UTF8
Exception in thread "main" java.lang.RuntimeException: java.lang.IllegalArgumentException: Unsupported class file major version 66
        at com.github.dart_lang.jnigen.apisummarizer.util.ExceptionUtil.wrapCheckedException(ExceptionUtil.java:22)
        at com.github.dart_lang.jnigen.apisummarizer.disasm.AsmSummarizer.run(AsmSummarizer.java:21)
        at com.github.dart_lang.jnigen.apisummarizer.Main.main(Main.java:129)
Caused by: java.lang.IllegalArgumentException: Unsupported class file major version 66
        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 com.github.dart_lang.jnigen.apisummarizer.util.ExceptionUtil.wrapCheckedException(ExceptionUtil.java:20)
        ... 2 more

Fatal: Cannot generate summary: FormatException: Unexpected end of input (at character 1)
dcharkes commented 2 months ago

This is closed, but users have to find this issue.

dcharkes commented 2 months ago

The summarizer itself is already compiled to the right version

pkgs/jnigen/java/pom.xml

    <properties>
        <maven.compiler.source>11</maven.compiler.source>
        <maven.compiler.target>11</maven.compiler.target>

But our javac invocations in the tests do not specify a target. https://stackoverflow.com/questions/11364761/how-do-i-compile-a-java-with-support-for-older-versions-of-java#comment84680930_11364761

HosseinYousefi commented 2 months ago

We specify the versions here: https://github.com/dart-lang/native/tree/main/pkgs/jnigen#java-tooling