Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.Sign up
org.jruby.ext.pathname.RubyPathname class doesn't properly support instance_variable_set method #1460
I found this nasty behaviour of Pathname object (rel. 1.7.5 and up)
this happens because the java implementation of Pathname (class org.jruby.ext.pathname.RubyPathname) stores the path value used by all its methods into a private field and only synchronizes it with @path instance var at initialization time.
Since @path is never used internally, changing its value has no effect on object behaviour. A byproduct of this is that YAML deserialization always fails.
Probably unintentional (the commit is 6d5ddac by @headius).
BTW, making YAML use the proper constructor would be good anyway, I am starting to feel
I had a peek at the MRI implementation, it uses a ruby ivar.
the only way of keeping the ivar synchronized that I can think of is to define a private setter for path which also sets the ruby ivar and never access path directly elsewhere in the code, but it is obviously error prone and very similar to directly using a ruby ivar.