[Java] Fixed a compile error caused in some Java version.