native icon indicating copy to clipboard operation
native copied to clipboard

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

Open dcharkes opened this issue 1 year ago • 4 comments
trafficstars

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 avatar Aug 14 '24 06:08 dcharkes

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 avatar Aug 14 '24 07:08 dcharkes

  • https://github.com/dart-lang/native/issues/627

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

dcharkes avatar Aug 14 '24 07:08 dcharkes

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

dcharkes avatar Aug 14 '24 07:08 dcharkes

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

HosseinYousefi avatar Aug 19 '24 11:08 HosseinYousefi