I found this implementation that uses system interceptors, but at least does not require JNA / JNI.
https://gist.github.com/yrro/18dc22513f1001d0ec8d
As you say, systemd uses the sockets referenced by the environment variable (System.getenv ("NOTIFY_SOCKET" in the code), so I would suggest that there might also be a way to use the Java Socket, although I would imagine that it would take a lot of research and / or trial and error.
source share