我试图在基于Java SwingWorker的JRuby中实现我的worker类。我从以下代码开始,这些代码是我从SwingWorker那里借来的
docs
:
class Worker < javax.swing.SwingWorker
def doInBackground
publish 'a'
publish 'b'
publish 'c'
rescue
puts "Error: #{$!}"
end
def process(chunk)
p chunk
end
end
w = Worker.new
w.execute
sleep 1
我希望看到
过程
方法然而,我犯了一个错误:
Error: undefined method `publish' for #<Worker:0x1daa3d0f>
Did you mean? public_send
在macOS上的JRuby 9.3.3.0和9.2.9.0中观察到了这种行为。
jruby 9.2.9.0 (2.5.7) 2019-10-30 458ad3e OpenJDK 64-Bit Server VM 17.0.2+0 on 17.0.2+0 +jit [darwin-aarch64]
jruby 9.3.3.0 (2.6.8) 2022-01-19 b26de1f5c5 OpenJDK 64-Bit Server VM 17.0.2+0 on 17.0.2+0 +jit [darwin-aarch64]
我错过什么了吗?