Copy relevant UnsafeHolder logic so it works across all JRubies.

No issue filed; see ruby-amqp/hot_bunnies#17.