-
Notifications
You must be signed in to change notification settings - Fork 18
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Can't use kaitai-struct-runtime on JDK 8: NoSuchMethodError #34
Comments
The pom.xml already configures maven-compiler-plugin so that the source and target language level are set to Java 6, but this just corresponds to javac's kaitai_struct_java_runtime/pom.xml Lines 118 to 121 in ea3abf8
From what I've read, at least on Java 9 and newer, it should be enough to replace the Also I'm wondering why the language level is still set to Java 6 - the runtime uses |
Now when I know how
Yeah, it really isn't. The If we want to stay compatible with Java 8 and older (on the side of the KS runtime library development machine), then I think the best thing we can do is this: <plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
<!-- For Java 8 and older -->
<!-- <source>7</source>
<target>7</target> -->
<!-- /For Java 8 and older -->
<!-- For Java 9+ -->
<release>7</release>
<!-- /For Java 9+ -->
</configuration>
</plugin> Any users of Java 8 or older will have to uncomment the I tried to find if there is some So IMHO this little discomfort of not working on Java 8 out-of-the-box and having to do a small local change in the |
How about using the Maven concepts of profiles and toolchains instead? Profiles can be used to trigger concrete builds with special aspects and toolchains to provide different JDKs compatible with different versions. I've tested a bit with my available version of the runtime and a concrete JDK 8 and 11. The following is my <?xml version="1.0" encoding="UTF-8"?>
<toolchains>
<toolchain>
<type>jdk</type>
<provides>
<version>1.6</version>
<vendor>OpenJDK</vendor>
</provides>
<configuration>
<jdkHome>C:\Program Files\Java\jdk-8</jdkHome>
</configuration>
</toolchain>
<toolchain>
<type>jdk</type>
<provides>
<version>1.8</version>
<vendor>OpenJDK</vendor>
</provides>
<configuration>
<jdkHome>C:\Program Files\Java\jdk-8</jdkHome>
</configuration>
</toolchain>
<toolchain>
<type>jdk</type>
<provides>
<version>11</version>
<vendor>OpenJDK</vendor>
</provides>
<configuration>
<jdkHome>C:\Program Files\Java\jdk-11</jdkHome>
</configuration>
</toolchain>
</toolchains> The following is what I changed in <profiles>
<profile>
<id>JDK-8</id>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-toolchains-plugin</artifactId>
<version>1.1</version>
<executions>
<execution>
<goals>
<goal>toolchain</goal>
</goals>
</execution>
</executions>
<configuration>
<toolchains>
<jdk>
<version>1.8</version>
</jdk>
</toolchains>
</configuration>
</plugin>
</plugins>
</build>
</profile>
<profile>
<id>JDK-11</id>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-toolchains-plugin</artifactId>
<version>1.1</version>
<executions>
<execution>
<goals>
<goal>toolchain</goal>
</goals>
</execution>
</executions>
<configuration>
<toolchains>
<jdk>
<version>11</version>
</jdk>
</toolchains>
</configuration>
</plugin>
</plugins>
</build>
</profile>
</profiles> The different JDKs/profiles can be targeted on the shell like the following: mvn package -P JDK-8
mvn package -P JDK-11 By changing the node The good thing about the approach above is that all other plugins etc. are simply shared by all profiles, so that one doesn't need to specify things redundantly. Without providing any concrete profile, simply what is available as |
I have run into this same issue. Would it be possible to get a new push of 0.9 to Maven? |
@ams-tschoening Your suggestion is probably in the right direction, but it looks quite intimidating and I suppose it only works for versions JDK 8 and 11. But today, I've come across this solution on SO (https://stackoverflow.com/a/65655542). It also uses profiles, but it's simpler and I believe it's exactly what we want: <profile>
<id>java-8-api</id>
<activation>
<jdk>[9,)</jdk>
</activation>
<properties>
<maven.compiler.release>8</maven.compiler.release>
</properties>
</profile> |
Can't run kaitai on JDK 8 or you get this exception:
Please build with
--release 8
to avoid this problem.The problem is described in more detail here.
The text was updated successfully, but these errors were encountered: