openhab-core/itests/org.openhab.core.io.net.tests
Wouter Born 648cfac66d Avoid ByteBuffer incompatibility when compiling with JDK9+ (#686)
Incompatible code can be used/generated when using JDK8 on the command line and JDK11 in Eclipse (or vice versa).

The explanation for this is given in https://github.com/apache/felix/pull/114 :

Java 9 introduces overridden methods with covariant return types for the following methods in java.nio.ByteBuffer:

* position​(int newPosition)
* limit​(int newLimit)
* flip​()
* clear​()
* mark​()
* reset​()
* rewind​()

In Java 9 they all now return ByteBuffer, whereas the methods they override return Buffer,
resulting in exceptions like this when executing on Java 8 and lower:
java.lang.NoSuchMethodError: java.nio.ByteBuffer.limit(I)Ljava/nio/ByteBuffer
This is because the generated byte code includes the static return type of the method, which is not found on Java 8 and lower because the overloaded methods with covariant return types don't exist (the issue appears even with source and target 8 or lower in compilation parameters).
The solution is to cast ByteBuffer instances to Buffer before calling the method.

Signed-off-by: Wouter Born <github@maindrain.net>
2019-03-31 14:45:29 +02:00
..
src/main Avoid ByteBuffer incompatibility when compiling with JDK9+ (#686) 2019-03-31 14:45:29 +02:00
.classpath update Maven project settings (Eclipse IDE) 2019-02-06 15:56:00 +01:00
.project add some tests and prepare infrastructure (#531) 2019-02-05 09:32:49 +01:00
itest.bndrun bump Gson to 2.8.2 (#648) 2019-03-13 23:23:37 +01:00
NOTICE Updated NOTICE files to openHAB (#578) 2019-02-15 10:46:18 +01:00
pom.xml add some tests and prepare infrastructure (#531) 2019-02-05 09:32:49 +01:00