sshtools / maverick-synergy

Next Generation Java SSH API
https://jadaptive.com
GNU Lesser General Public License v3.0
96 stars 26 forks source link

java 8 compatibility #78

Closed mr-mister123 closed 1 year ago

mr-mister123 commented 1 year ago

I know, it's quite old, but sadly still widely used :-(

I'm trying to upgrade from 3.0.9 to 3.0.10, but it doesn't seem to be compatible to java 8 anymore. I don't know, if this is intended?!

The problem has to do with the flip-method of the java.nio.ByteBuffer class.

In java-versions <= 1.8 ByteBuffer extends java.nio.Buffer and therefor inhertis the flip method with following signature:

public final Buffer flip()

the method is final. In java > 1.8 the method is not final anymore and it's overriden in ByteBuffer changing the signature to

public ByteBuffer flip()

so returning a more specific type. Although your SocketConnection-Class doesn't make use of the returned value, it leads to problems at runtime:

java.lang.NoSuchMethodError: java.nio.ByteBuffer.flip()Ljava/nio/ByteBuffer; at com.sshtools.synergy.nio.SocketConnection.processWriteEvent(SocketConnection.java:358) at com.sshtools.synergy.nio.SshEngine$SocketReadWriteTask.doTask(SshEngine.java:979) at com.sshtools.common.ssh.ConnectionAwareTask.run(ConnectionAwareTask.java:45) at com.sshtools.common.ssh.ExecutorOperationSupport$OperationTask.executeAllTasks(ExecutorOperationSupport.java:127) at com.sshtools.common.ssh.ExecutorOperationSupport$OperationTask.run(ExecutorOperationSupport.java:84) at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) at java.util.concurrent.FutureTask.run(FutureTask.java:266) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) at java.lang.Thread.run(Thread.java:748)

Is it possible to make it usable with java 8 anymore? That would be nice!

Thanks for your efford and greetz,

Karsten

mr-mister123 commented 1 year ago

I've digged deeper into it: Rebuilding from source and compiling it using (oracle) java 8 solved the problem. no changes in source-code are required...

mr-mister123 commented 1 year ago

Sorry for createing a duplicate of #74 didn't check that