Fix more Java SDK build edge cases (#69628)