This is problematic. Any pure Java regex solution will have to compromise because to correctly assess the question "are we between parentheses?" requires us (in the worst case, depending on your input) to handle nested parentheses, text within strings or comments that should not be modified and possibly other edge conditions.
Keeping that in mind, a simplistic solution that works on your example at least (and that assumes that it doesn't have to handle nested parentheses, comments or strings, and that it doesn't have to check whether the parentheses actually belong to a function definition), could be
String result = subject.replaceAll("\\s+(?=[^()]*\\))", "");
This matches and replaces whitespace iff the next parenthesis after it is a closing parenthesis.