-
-
Notifications
You must be signed in to change notification settings - Fork 942
Description
Environment
JRuby 9.0.5.0 (and likely 9.1.0.0)
Expected Behavior
When a class or instance variable has multibyte characters, it needs to marshal that name as though it were an encoded symbol. Basically, where we currently dump a "plain" bytes version of the identifer, we need to dump it with the "encoding instance variable" logic used for proper symbols. This way we can reconstitute the original name and match it up properly on the load side.
Actual Behavior
In actuality, we are stripping the multibyte nature of those names, and they come out mangled on the other side.
Given this script (based on MRI TestMarshal#test_unloadable_userdef:
class Foo
def bar
c = eval "
class X\u{23F0 23F3} < Time
class << self
undef _load
end
self
end"
o = c.new
p Marshal.load(Marshal.dump(o))
end
end
Foo.new.barWe currently get the following marshaled output (note the mangled name of the class):
"\x04\bIu:\rFoo::X??\rn\x06\x1D\x80P.\x04\xE7\b:\rsubmicro\"\x06\x00:\voffseti\xFE\xA0\xAB:\tzoneI\"\bCST\x06:\x06ET"
I attempted to fix this by actually creating symbols for these elements, but there's something missing on the loading side. Here's my patch: https://gist.github.com/headius/99779f55add2d007ca42
The marshaled output looks better:
"\x04\bIuI:\x11Foo::X\xE2\x8F\xB0\xE2\x8F\xB3\x06:\x06ET\rn\x06\x1D\x80=\xF5-\xC5\a:\voffseti\xFE\xA0\xAB:\tzoneI\"\bCST\x06;\x06F"
But I still get an error from the full script above:
ArgumentError: undefined class/module Foo::X��
load at org/jruby/RubyMarshal.java:145
bar at -e:1
<top> at -e:1
We are not reconstituting the string properly, it seems.
Since this is not a regression or new behavior, I'm going to exclude the related CRuby 2.3 tests for now.