Due to incompatible changes in java.nio.ByteBuffer between Java 8 and 11 (methods clear() and flip() of class java.nio.ByteBuffer) calling org.hsqldb.jdbc.JDBCClobClient.getAsciiStream() from alternative jar using JDK8 throws a NoSuchMethodError. The issue as well as resolutions are described at https://stackoverflow.com/questions/61267495/exception-in-thread-main-java-lang-nosuchmethoderror-java-nio-bytebuffer-flip.
In order to reproduce the issue compile and run the following piece of code using JDK8:
try (
Connection connection = DriverManager.getConnection("jdbc:hsqldb:mem:.");
Statement statement = connection.createStatement();
ResultSet resultSet = statement.executeQuery("SELECT CAST('test_value' AS CLOB) FROM INFORMATION_SCHEMA.SYSTEM_USERS")
) {
if (resultSet.next()) {
Clob clob = resultSet.getClob(1);
try (InputStream asciiStreamFromClob = clob.getAsciiStream()) { }
}
}
Which HSQLDB jar did you use for your test?
I used
hsqldb-6.2.1-jdk8.jar.I have created and attached a small reproducer. Just extract the archive and run
./gradlew test -Dorg.gradle.java.home=/path_to_jdk8_directory.Last edit: Tobias Riemenschneider 2022-01-20
Thanks for reporting and the test.
The jar on Maven was compiled with JDK 11, which caused the incompatibility issue. The hsqldb-jdk8.jar in the distribution zip from SourceForge was compiled with JDK 8 and shouldn't show the same issue.
Thanks for your quick response. I just did a quick retest on my side and the hsqldb-jdk8.jar from the distribution zip fixed the reported issue.
Fixed in trunk (for Maven jars going forward) with commit 6448.
To cross build for Java version x, set build properties ant.build.javac.target and javac.bootcp.override. For goal of target 8, we need the latter set to paths to the 8 rt.jar and jce.jar. Make sure to do a full clean (like with clean-all target/task) so nothing from previous build state gets used.
I verified that a hsqldb.jar built this way works with Tobias's test setup. (Thanks for that).
Last edit: Blaine Simpson 2022-03-09
Fixed in 2.7.0 and later.