armanbilge / epollcat

minimum viable runtime
Apache License 2.0
63 stars 6 forks source link

Build breaks on java.net.StandardSocketOptions.SO_REUSEPORT (Java8) #142

Open larsjaas opened 1 year ago

larsjaas commented 1 year ago

Hi,

I'm trying to build epollcat on my Intel macOS Ventura 13.4.1 macbook pro, and just doing a straight out-of-the-box sbt compile breaks like this:

douglas~/Code/larsa/scala-native/epollcat(main|✔) % sbt compile                                                                                                main
[info] welcome to sbt 1.9.0 (AdoptOpenJDK Java 1.8.0_292)
[info] loading global plugins from /Users/larsa/.sbt/1.0/plugins
[info] loading settings for project epollcat-build from plugins.sbt ...
[info] loading project definition from /Users/larsa/Code/larsa/scala-native/epollcat/project
[info] loading settings for project root from build.sbt ...
[info] set scmInfo to https://github.com/armanbilge/epollcat
[info] set current project to root (in build file:/Users/larsa/Code/larsa/scala-native/epollcat/)
[info] Executing in batch mode. For better performance use sbt's shell
[info] compiling 19 Scala sources and 1 Java source to /Users/larsa/Code/larsa/scala-native/epollcat/core/target/scala-2.13/classes ...
[error] /Users/larsa/Code/larsa/scala-native/epollcat/core/src/main/scala/epollcat/internal/ch/EpollAsyncServerSocketChannel.scala:129:34: value SO_REUSEPORT is not a member of object java.net.StandardSocketOptions
[error]       case StandardSocketOptions.SO_REUSEPORT =>
[error]                                  ^
[error] /Users/larsa/Code/larsa/scala-native/epollcat/core/src/main/scala/epollcat/internal/ch/EpollAsyncSocketChannel.scala:268:32: value SO_REUSEPORT is not a member of object java.net.StandardSocketOptions
[error]     case StandardSocketOptions.SO_REUSEPORT =>
[error]                                ^
[error] two errors found
[error] (core / Compile / compileIncremental) Compilation failed
[error] Total time: 5 s, completed Jun 25, 2023 10:15:03 AM

I tried downgrading scala-native to 0.4.12 in plugins.sbt just to try against another verision, but it changed nothing. Not sure what to try, I can't see anything special about the SO_REUSEPORT constant in the scala-native source...

larsjaas commented 1 year ago

I changed JAVA_HOME to point to AdoptOpenJDK 15 - then it built...

[info] welcome to sbt 1.9.0 (AdoptOpenJDK Java 15.0.2)
[info] loading global plugins from /Users/larsa/.sbt/1.0/plugins
[info] loading settings for project epollcat-build from plugins.sbt ...
[info] loading project definition from /Users/larsa/Code/larsa/scala-native/epollcat/project
[info] loading settings for project root from build.sbt ...
[info] set scmInfo to https://github.com/armanbilge/epollcat
[info] set current project to root (in build file:/Users/larsa/Code/larsa/scala-native/epollcat/)
[info] Executing in batch mode. For better performance use sbt's shell
[success] Total time: 1 s, completed Jun 25, 2023, 11:51:57 AM
larsjaas commented 1 year ago

I figure it's scala-native that matches the API with the JDK-version, so projects can cross-compile cleanly. So the conclusion is that epollcat is a Java 9+ project, and doesn't support Java 8 which doesn't have SO_REUSEPORT. I guess SO_REUSEADDR is no replacement.

armanbilge commented 1 year ago

Yes, that's right. To build and run tests for epollcat requires a modern JDK. Actually, we are using JDK 17 in CI. This is necessary so that we can support all the latest JDK features.

https://github.com/armanbilge/epollcat/blob/c5c2347bc9c59a90ce68aa5588b0ce91ce6da52f/.github/workflows/ci.yml#L36

However, you can use the published library with JDK 8, you just will not be able to access the newer features.

larsjaas commented 1 year ago

Just had never thought about this before, since scala-native -> "run on the metal without the jvm". But there is value in following language standards...

Just close the issue, my only suggestion is to write a note about it somewhere in the README.