java_import 已初始化常量
我刚刚开始使用 JRuby,并创建了一个小测试文件:
require 'java'
java_import java.io.File
f = File.new ARGV[0]
当我像这样运行程序时:jruby test.rb file.txt
我收到以下警告:
/Library/Frameworks/JRuby.framework/Versions/1.6.5/lib/ruby/site_ruby/shared/builtin/javasupport/core_ext/object.rb:99 warning: 已初始化常量 File< /code>
f
类实际上是 java File 类,但我仍然收到警告,有什么帮助吗?
通过查看 object.rb,我发现这与以下 JRuby 票证相关: http://jira.codehaus.org/browse/JRUBY-3453
I just started using JRuby and I create a small test file:
require 'java'
java_import java.io.File
f = File.new ARGV[0]
When I run the program like so: jruby test.rb file.txt
I get the following warning:
/Library/Frameworks/JRuby.framework/Versions/1.6.5/lib/ruby/site_ruby/shared/builtin/javasupport/core_ext/object.rb:99 warning: already initialized constant File
The class of f
is in fact the java File class, but I still get the warning, any help??
I found out this is related to the following JRuby ticket by looking in object.rb:
http://jira.codehaus.org/browse/JRUBY-3453
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
对我来说这似乎是一个合理的警告,因为 Ruby 已经有一个 File 类(即常量“File”已经初始化为引用 Ruby File 类)。
我自己可能会跳过导入,只做
应该有效并消除名称冲突的事情。
你也可以做
或
Seems like a reasonable warning to me, since Ruby already has a File class (i.e. the constant "File" was already initialized to refer to the Ruby File class).
Myself, I would probably skip the import and just do
which should work and would eliminate name clashes.
You can also do
or