fix java issue by avoiding certain types of closures