swap yield with instance_exec to workaround issue in JRuby