capnproto / capnproto-java

Cap'n Proto in pure Java
Other
391 stars 86 forks source link

java 8 compatibility #103

Closed paxel closed 3 years ago

paxel commented 3 years ago

Hi David,

finally tried to use the latest fixes, and we run into issues starting with 0.1.6 I think.

Could it be that you have upgraded between 0.1.5 and 0.1.6 to java 9 or higher? Because the library is not usable with JDK8 anymore

java.lang.NoSuchMethodError: java.nio.ByteBuffer.rewind()Ljava/nio/ByteBuffer;
    at org.capnproto.SegmentBuilder.capacity(SegmentBuilder.java:39)
    at org.capnproto.SegmentBuilder.allocate(SegmentBuilder.java:54)
    at org.capnproto.BuilderArena.allocate(BuilderArena.java:140)
    at org.capnproto.MessageBuilder.getRootInternal(MessageBuilder.java:93)
    at org.capnproto.MessageBuilder.initRoot(MessageBuilder.java:119)

FYI https://www.baeldung.com/maven-java-version#java9

I'm checking if this is some issue on our side, but short of recompiling it on our side I don't see any option to fix that.

dwrensha commented 3 years ago

Thanks for the report!

CI uses Java 8, so the source code should be compatible: https://github.com/capnproto/capnproto-java/blob/f98e0fc6efe67c3593215289f27959540cb6feba/.github/workflows/ci.yml#L25

My local javac is 11.0.11, so yeah, it looks like I need to specify maven.compiler.release. But, ugh, it may be a bit complicated to get maximal compatibility: https://stackoverflow.com/questions/59049980/maven-compiler-release-as-an-replacement-for-source-and-target/65655542#65655542

paxel commented 3 years ago

yes. it sux. we created profiles to be able to compile with different jdks.

so follow up question: do you deploy libraries to maven central with the ci or local build?

dwrensha commented 3 years ago

I publish to Maven Central from my local build. If it's possible to do it from CI, then maybe we should switch to that. (I assume there's still a step where I have to run something locally, so that the gpg signature can go through.)

paxel commented 3 years ago

I can't find the place where the actual compiling happens. is it in sbt?

I assume if you add --release 8 to the javac call, the compatibility for the lib should be maxed. Until someone asks for jdk 7 support :D

letting the ci do the deployment is a bit risky, in my opinion.

dwrensha commented 3 years ago

I tried adding maven.compiler.release in https://github.com/capnproto/capnproto-java/commit/b8a5a99ef649e70968350b7355407487f8c5a487.

I uploaded a snapshot release using that change: https://oss.sonatype.org/content/repositories/snapshots/org/capnproto/runtime/0.1.9-SNAPSHOT

Can you try that and tell me if it works for you?

paxel commented 3 years ago

looks good. Meaning I can compile now under JDK8

But doesn't the CI now fail?

dwrensha commented 3 years ago

it seems to work: https://github.com/capnproto/capnproto-java/runs/3070306131?check_suite_focus=true

dwrensha commented 3 years ago

I pushed version 0.1.9 to the central repository, with this fix.

paxel commented 3 years ago

thank you 👍

David Renshaw @.***> schrieb am Fr., 16. Juli 2021, 17:39:

I pushed version 0.1.9 to the central repository, with this fix.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/capnproto/capnproto-java/issues/103#issuecomment-881539306, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAFLHGGTXM3JUIKTEZE57GLTYBHBXANCNFSM5ACQT7PQ .