You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Audit excluded tests on JRuby and address differences #1123
Several tests still explicitly exclude JRuby and do not run against the Java extension. We should reexamine these and fix as many differences with the C extension as possible.
$ git grep -e "RUBY_ENGINE == [\"']jruby" test
test/json/json_generator_test.rb: if RUBY_ENGINE == "jruby"
test/json/json_minefield_parser_test.rb: if RUBY_ENGINE == 'jruby'
test/json/json_parser_test.rb: unless RUBY_ENGINE == 'jruby'
test/json/json_parser_test.rb: omit "JRuby errors don't contain positions" if RUBY_ENGINE == "jruby"
test/json/json_parser_test.rb: omit "JRuby errors don't contain positions" if RUBY_ENGINE == "jruby"
test/json/json_parser_test.rb: omit "JRuby string decoding errors don't contain positions" if RUBY_ENGINE == "jruby"
test/json/resumable_parser_test.rb: omit "JRuby not supported" if RUBY_ENGINE == "jruby"
Some of these may be valid but most involve changes made to the C extension that were never ported to the Java extension. That last one excludes all of the ResumableParser tests because that entire feature is missing from the Java extension.
See #1122 for one example of a latent bug hidden by these masks.
Another JRuby/Java extension difference from the C extension, in script_safe mode:
isUnsafeScriptTag in java/src/json/ext/StringEncoder.java reads ptrBytes[pos], but its callers in StringEncoder and StringEncoderAsciiOnly use ptrBytes[ptr + pos]. For a substring at a non-zero offset, the Java extension checks the wrong bytes:
JSON.generate(("a" * 100 + "</script>")[100..],script_safe: true)# JRuby: leaves "<" unescaped: "</script>"# C extension: escapes "<" as \u003c: "\\u003c/script>"
The Java helper also reads ptrBytes[pos] after pos++ without a length check, so a string ending in < reads past its end. The C extension checks the length first.
Activity
headius commentedon Nov 4, 2026
Some of these are due to #138.
Call as_json only once for invalid strings in Java and Ruby generators
Run the duplicate key test with a non-String key on JRuby
Run the RFC 8785 number tests on JRuby 10.1.3 and later
[ruby/json] Run the RFC 8785 number tests on JRuby 10.1.3 and later
Java generator: raise TypeError for a String key whose to_s is broken
[ruby/json] Java generator: raise TypeError for a String key whose to…
Call as_json only once for invalid strings in Java and Ruby generators
Run the duplicate key test with a non-String key on JRuby
Java parser: include the position in string decoding errors
wtn commentedon Nov 14, 2026
Another JRuby/Java extension difference from the C extension, in
script_safemode:isUnsafeScriptTaginjava/src/json/ext/StringEncoder.javareadsptrBytes[pos], but its callers inStringEncoderandStringEncoderAsciiOnlyuseptrBytes[ptr + pos]. For a substring at a non-zero offset, the Java extension checks the wrong bytes:The Java helper also reads
ptrBytes[pos]afterpos++without a length check, so a string ending in<reads past its end. The C extension checks the length first.byroot commentedon Nov 15, 2026
Urgh, that
ptr+posis very error prone. Fixed in #1147, but I think we should refactor that code: #1148