robfletcher/betamax — pull request #147 by igrayson (2014-09-13 03:57:23+00:00)
Title: Jruby

JRuby support.

* Encourage YAML to use the type description configured by YamlTapeLoader#getYaml().
Specifically, SnakeYAML's loadAs(reader, type) overrides root element tag
in preference to 'type', if provided. See BaseConstructor#getSingletonData().

* This breaks in JRuby because of some JRuby/SnakeYAML messiness:
(1) the "overridden" root element tag will not perfectly match the tag found
in the serialized YAML. One is constructed with YamlTape.class, the other with "!tape".
(2) because they do not perfectly match, SnakeYAML prefers the overridde tag
(the one constructed with YamlTape.class).
(3) Tags constructed with Class objects only retain the class name (a String).
(4) SnakeYAML uses Class.forName() to dereference this String...
(5) ... which will fail in JRuby, because JRuby includes SnakeYAML in the bootstrap
classpath and has no access to betamax classes.

* Without this 'overridden' tag, it uses the type description mapping configured in
YamlTapeLoader#getYaml(), which contains a hard reference to YamlTape.class.

* Preserve existing exception behavior when loading VALID yaml which is not a YamlTape.