I discovered a new syntax for java 8 reading through the source for a framework I'm attempting to wrangle:
Runtime.getRuntime().addShutdownHook(new Thread(Sirius::stop));
In clojure, I can translate it as:
(.addShutdownHook (Runtime/getRuntime) (Thread. ????))
But I'm not sure what to put for the ???
IFn extends Runnable, so you can just do
#(Sirius/stop)
It is worth noting that
Sirius/stop
Java 8 functional interfaces under the hood work by making anonymous implementations of interfaces with only one method. So
new Thread(Sirius::stop)
is just syntactic sugar for
new Thread(new Runnable {
public void run() {
Sirius.stop();
}
})
If the interface in question isn't Runnable/Callable, you'll have to use the reify macro.