There's a problem with shallowDup in ByteList:
$ jruby -rjava -e "import org.jruby.util.ByteList; b = ByteList.new(5); b.append('foo'.to_java_bytes); p b.length; p b.shallowDup.length"
This is the actual cause of the problem reported in JRUBY-3511.
I've committed a fix for this, but it needs a ByteList release.
Tom did a bytelist release for RC1.