Java + C++ refactor