Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Zlib.inflate causes java.lang.ClassCastException #5234

Closed
jeremyevans opened this issue Jun 30, 2018 · 0 comments
Closed

Zlib.inflate causes java.lang.ClassCastException #5234

jeremyevans opened this issue Jun 30, 2018 · 0 comments

Comments

@jeremyevans
Copy link
Contributor

Environment

This happens on both Windows and OpenBSD, so is unlikely to be operating system specific:

jruby 9.2.0.0 (2.5.0) 2018-05-24 81156a8 Java HotSpot(TM) 64-Bit Server VM 25.131-b11 on 1.8.0_131-b11 +jit [mswin32-x86_64]
jruby 9.2.0.0 (2.5.0) 2018-05-24 81156a8 OpenJDK 64-Bit Server VM 25.144-b01 on 1.8.0_144-b01 +jit [OpenBSD-x86_64]

Expected Behavior

Zlib.inflate should work the same as Zlib::Inflate.inflate

CRuby 2.0 - 2.6:

$ ruby -vr zlib -e "p Zlib.inflate(Zlib.deflate('1'*1000)).length"
ruby 2.0.0p648 (2015-12-16 revision 53162) [x86_64-openbsd]
1000
$ ruby -vr zlib -e "p Zlib.inflate(Zlib.deflate('1'*1000)).length"
ruby 2.6.0preview2 (2018-05-31 trunk 63539) [x86_64-openbsd]
1000

Actual Behavior

$ jruby -vr zlib -e "p Zlib.inflate(Zlib.deflate('1'*1000)).length"
jruby 9.2.0.0 (2.5.0) 2018-05-24 81156a8 OpenJDK 64-Bit Server VM 25.144-b01 on 1.8.0_144-b01 +jit [OpenBSD-x86_64]
Unhandled Java exception: java.lang.ClassCastException: org.jruby.RubyModule cannot be cast to org.jruby.RubyClass
java.lang.ClassCastException: org.jruby.RubyModule cannot be cast to org.jruby.RubyClass
             s_inflate at org/jruby/ext/zlib/JZlibInflate.java:66
               inflate at org/jruby/ext/zlib/RubyZlib.java:232
                  call at org/jruby/ext/zlib/RubyZlib$INVOKER$s$1$0$inflate.gen:-1
          cacheAndCall at org/jruby/runtime/callsite/CachingCallSite.java:344
                  call at org/jruby/runtime/callsite/CachingCallSite.java:170
  invokeOther3:inflate at -e:1
                <main> at -e:1
   invokeWithArguments at java/lang/invoke/MethodHandle.java:627
                  load at org/jruby/ir/Compiler.java:94
             runScript at org/jruby/Ruby.java:852
           runNormally at org/jruby/Ruby.java:771
           runNormally at org/jruby/Ruby.java:789
           runFromMain at org/jruby/Ruby.java:601
         doRunFromMain at org/jruby/Main.java:415
           internalRun at org/jruby/Main.java:307
                   run at org/jruby/Main.java:234
                  main at org/jruby/Main.java:206

Zlib.inflate is supposed to be available since Ruby 2.0, but JRuby 9.2 is the first JRuby version that added support for it. Interestingly, Zlib.deflate works fine, maybe because support was added to ruby earlier (in 1.9.3).

@kares kares added the beginner label Jul 2, 2018
ahorek added a commit to ahorek/jruby that referenced this issue Jul 4, 2018
This was referenced Jul 4, 2018
@kares kares closed this as completed in a54741f Jul 6, 2018
kares pushed a commit that referenced this issue Jul 6, 2018
@kares kares added this to the JRuby 9.1.18.0 milestone Jul 6, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants