Add workaround for limitation of callbacks in javacpp.

Practically only one callback can be used.