Java API: optimize initial capacity for JS object callback