Evaluation and optimization of method calls in java