Java API: fix crash on releasing global object at JSObjectRelease. Add docs, refactoring, fix indentation