Extended class clones and duplicates become unmarshable #4340

Closed
gdeoliveira opened this Issue Nov 27, 2016 · 2 comments

Projects

None yet

2 participants

@gdeoliveira

Environment

Running inside 9-alpine docker container.

jruby 9.1.6.0 (2.3.1) 2016-11-09 0150a76 OpenJDK 64-Bit Server VM 25.111-b14 on 1.8.0_111-internal-alpine-r0-b14 +jit [linux-x86_64]
Linux dfcfcfee1b70 4.4.0-47-generic #68-Ubuntu SMP Wed Oct 26 19:39:52 UTC 2016 x86_64 Linux

This issue may be related to #4339.

Expected Behavior (MRI 2.3.1)

Extension = Module.new
Klass = Class.new { extend Extension }
Clone = Klass.clone
Dup = Klass.dup

Marshal.dump(Clone)
#=> "\x04\bc\nClone"

Marshal.dump(Dup)
#=> "\x04\bc\bDup"

Actual Behavior

Extension = Module.new
Klass = Class.new { extend Extension }
Clone = Klass.clone
Dup = Klass.dup

Marshal.dump(Clone)
TypeError: can't dump anonymous class #<Class:0x5656be13>
	from org/jruby/RubyMarshal.java:102:in `dump'
	from (irb):5:in `<eval>'
	from org/jruby/RubyKernel.java:998:in `eval'
	from org/jruby/RubyKernel.java:1299:in `loop'
	from org/jruby/RubyKernel.java:1118:in `catch'
	from org/jruby/RubyKernel.java:1118:in `catch'
	from /opt/jruby/bin/irb:13:in `<main>'

Marshal.dump(Dup)
TypeError: can't dump anonymous class #<Class:0x14cd1699>
	from org/jruby/RubyMarshal.java:102:in `dump'
	from (irb):6:in `<eval>'
	from org/jruby/RubyKernel.java:998:in `eval'
	from org/jruby/RubyKernel.java:1299:in `loop'
	from org/jruby/RubyKernel.java:1118:in `catch'
	from org/jruby/RubyKernel.java:1118:in `catch'
	from /opt/jruby/bin/irb:13:in `<main>'
@headius
Member
headius commented Nov 29, 2016

Looks like a problem with the class-name-setting behavior of constants. Confirmed it fails on JRuby master, and it does not fail if the extend call is omitted.

@gdeoliveira
gdeoliveira commented Nov 29, 2016 edited

The same problem seems to be present in the 1.7 version of JRuby according to the failing tests I'm getting here.

@headius headius closed this in 2661806 Nov 29, 2016
@headius headius added this to the JRuby 9.1.7.0 milestone Nov 29, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment