Skip to content

Cannot sub-class Zlib::GzipWriter and call .wrap #7479

@postmodern

Description

@postmodern
require 'zlib'

class ZlibGzipWriterSubClass < Zlib::GzipWriter
end

string = ZlibGzipWriterSubClass.wrap('')

Environment Information

  • jruby 9.4.0.0 (3.1.0) 2022-11-23 95c0ec159f OpenJDK 64-Bit Server VM 17.0.5+8 on 17.0.5+8 +jit [x86_64-linux]
  • Linux dev 6.0.9-200.fc36.x86_64 #1 SMP PREEMPT_DYNAMIC Wed Nov 16 17:50:45 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux

Expected Behavior

Returns an ZlibGzipWriterSubClass object.

Actual Behavior

org.jruby.dist/org.jruby.ext.zlib.JZlibRubyGzipReader.newInstance(JZlibRubyGzipReader.java:84): class org.jruby.ext.zlib.JZlibRubyGzipWriter cannot be cast to class org.jruby.ext.zlib.JZlibRubyGzipReader (org.jruby.ext.zlib.JZlibRubyGzipWriter and org.jruby.ext.zlib.JZlibRubyGzipReader are in module org.jruby.dist of loader 'app') (Java::JavaLang::ClassCastException)                                                                         
        from org.jruby.dist/org.jruby.ext.zlib.RubyGzipFile.wrap19(RubyGzipFile.java:94)
        from org.jruby.dist/org.jruby.ext.zlib.RubyGzipFile$INVOKER$s$0$1$wrap19.call(RubyGzipFile$INVOKER$s$0$1$wrap19.gen)                                             
        from org.jruby.dist/org.jruby.internal.runtime.methods.DynamicMethod.call(DynamicMethod.java:224)                                                                
        from org.jruby.dist/org.jruby.internal.runtime.methods.DynamicMethod.call(DynamicMethod.java:220)                                                                
        from org.jruby.dist/org.jruby.runtime.callsite.CachingCallSite.cacheAndCall(CachingCallSite.java:372)
	from org.jruby.dist/org.jruby.runtime.callsite.CachingCallSite.call(CachingCallSite.java:175)
	from org.jruby.dist/org.jruby.ir.interpreter.InterpreterEngine.processCall(InterpreterEngine.java:314)
	from org.jruby.dist/org.jruby.ir.interpreter.StartupInterpreterEngine.interpret(StartupInterpreterEngine.java:66)
	from org.jruby.dist/org.jruby.ir.interpreter.Interpreter.INTERPRET_EVAL(Interpreter.java:106)
	from org.jruby.dist/org.jruby.ir.interpreter.Interpreter.evalCommon(Interpreter.java:157)
	from org.jruby.dist/org.jruby.ir.interpreter.Interpreter.evalWithBinding(Interpreter.java:182)
	from org.jruby.dist/org.jruby.RubyKernel.evalCommon(RubyKernel.java:1181)
	from org.jruby.dist/org.jruby.RubyKernel.eval(RubyKernel.java:1143)
	from org.jruby.dist/org.jruby.RubyKernel$INVOKER$s$0$3$eval.call(RubyKernel$INVOKER$s$0$3$eval.gen)
	from org.jruby.dist/org.jruby.runtime.callsite.CachingCallSite.call(CachingCallSite.java:85)
	from org.jruby.dist/org.jruby.ir.instructions.CallBase.interpret(CallBase.java:561)
	... 256 levels...

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions