mak*_*nai 2 ruby warnings jruby
我在JRuby下使用ruby-mysql库并获得以下警告:
/mysql/protocol.rb:530 warning: GC.disable does nothing on JRuby
有没有办法让JRuby停止抱怨这个?
你有几个选择.
首先,您可以使用-W0
将禁用所有警告的选项来运行程序.这可能不是你想要的.
然而,应用-W0
相同的设置$VERBOSE
来nil
-所以我们可以简单地做,围绕我们想要禁止警告的代码.这是第二个也是更可取的选择.
def suppress_all_warnings
old_verbose = $VERBOSE
begin
$VERBOSE = nil
yield if block_given?
ensure
# always re-set to old value, even if block raises an exception
$VERBOSE = old_verbose
end
end
puts "Starting"
MyConst = 1
MyConst = 2
suppress_all_warnings do
GC.disable
end
puts "Done"
Run Code Online (Sandbox Code Playgroud)
使用JRuby 1.5.0运行此命令会正确警告我重新初始化的常量并正确地抑制GC.disable
警告.
归档时间: |
|
查看次数: |
708 次 |
最近记录: |