refactor java backend to use more dependency injection

**please review**
why is this assertion commented out?