Port restartable collector from C to Java