java class optimize