Skip to content
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

Make the compiled package runnable on Java 7 or any later version #38

Merged
merged 5 commits into from
Jul 1, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 20 additions & 10 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,29 @@

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>1.7</maven.compiler.source>
<maven.compiler.target>1.7</maven.compiler.target>
Comment on lines +43 to +44
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For anyone else who doesn't remember - we're bumping the minimum Java version from 6 to 7, because the runtime was actually already incompatible with Java 6. See #34 (comment)

</properties>

<profiles>
<profile>
<id>jdk9</id>
<activation>
<jdk>[1.9,)</jdk>
</activation>
<properties>
<maven.compiler.release>7</maven.compiler.release>
</properties>
</profile>
</profiles>

<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.10.1</version>
Copy link
Member Author

@generalmimon generalmimon Jul 1, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just noting why I updated to this version: I had to update maven-compiler-plugin at least to 3.6 (it was 3.1), see https://maven.apache.org/plugins/maven-compiler-plugin/compile-mojo.html#release:

<release>
The -release argument for the Java compiler, supported since Java9

  • Type: java.lang.String
  • Since: 3.6
  • Required: No
  • User Property: maven.compiler.release

At first, I thought I would update to some older version, e.g. 3.6.2, but I saw this at https://mvnrepository.com/artifact/org.apache.maven.plugins/maven-compiler-plugin/3.6.2:

Vulnerabilities Vulnerabilities from dependencies:
CVE-2022-29599
CVE-2020-15250

It may or may not be serious or relevant, but I thought it would be easier and safer to just raise the requirement to a later version. But 3.8.1 has these vulnerabilities still listed, and the oldest version where this is apparently fixed is 3.9.0. I have finally decided to update to the latest version 3.10.1 (it's not such a leap anymore) and it still works, as far as I can tell (see https://github.com/generalmimon/ks-java-runtime-test/actions), so it seems fine to me.

</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
Expand All @@ -60,7 +79,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>2.9.1</version>
<version>3.2.0</version>
<executions>
<execution>
<id>attach-javadocs</id>
Expand Down Expand Up @@ -111,15 +130,6 @@
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<source>6</source>
<target>6</target>
</configuration>
</plugin>
</plugins>
</build>

Expand Down
5 changes: 3 additions & 2 deletions src/main/java/io/kaitai/struct/ByteBufferKaitaiStream.java
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,9 @@ public ByteBuffer asRoBuffer() {
/**
* Closes the stream safely. If there was an open file associated with it, closes that file.
* For streams that were reading from in-memory array, does nothing.
* @implNote
* <p>
* @implNote Unfortunately, there is no simple way to close memory-mapped ByteBuffer in
* Unfortunately, there is no simple way to close memory-mapped ByteBuffer in
* Java and unmap underlying file. As {@link MappedByteBuffer} documentation suggests,
* "mapped byte buffer and the file mapping that it represents remain valid until the
* buffer itself is garbage-collected". Thus, the best we can do is to delete all
Expand All @@ -128,7 +129,7 @@ public ByteBuffer asRoBuffer() {
* </p>
* <p>
* For more examples and suggestions, see:
* https://stackoverflow.com/questions/2972986/how-to-unmap-a-file-from-memory-mapped-using-filechannel-in-java
* <a href="https://stackoverflow.com/q/2972986">How to unmap a file from memory mapped using FileChannel in java?</a>
* </p>
* @throws IOException if FileChannel can't be closed
*/
Expand Down