Java implementation.