Repository navigation
Java parser: call #encode dynamically when converting the source - #1124
Open
sampokuokkanen wants to merge 1 commit into
Open
sampokuokkanen wants to merge 1 commit into
sampokuokkanen wants to merge 1 commit into
Conversation
convertEncoding called RubyString#encode directly from Java, so a String subclass overriding #encode was ignored on JRuby. parser.c uses rb_funcall followed by StringValue, so do the same: dispatch through callMethod and convert the result with convertToString, which also turns a non-String return value into a TypeError instead of a ClassCastException. This lets the JRuby-guarded part of test_adversary_encode run everywhere.
Contributor
Author
|
@headius |
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
On JRuby,
convertEncodingcalledRubyString#encodedirectly from Java, so a String subclass overriding#encodewas ignored.parser.cusesrb_funcallandStringValue. This does the same withcallMethodandconvertToString, so a non-String return value now raisesTypeErrorrather than aClassCastException.UTF-8 and binary sources don't go through this path. The part of
test_adversary_encodethat was skipped on JRuby now runs there: it fails without this change, and the full suite passes on JRuby 10.1.2.I benchmarked small and medium US-ASCII and UTF-16LE documents against the old jar and couldn't see a difference beyond noise.