JRuby 1.6.7 發(fā)布
JRuby 1.6.7 更新版本發(fā)布了,該版修復(fù)了Ruby 1.9 的一些兼容性問(wèn)題,在性能方面也有不少改善,值得關(guān)注的變化有:
- Fix circular require issue in Rubygems introduced by our Maven gem support
- Fix regression in popen* where streams get prematurely closed
- Many 1.9-mode encoding bugs fixed in String, Regexp, StringIO, and YAML
- Win32OLE now works in 1.9-mode
- ffi on Win x64 now knows about basic types :size_t
- Use jzlib to fix a set of issues with out zlib library
- Reduced internal locking based on user reports
- C extensions work on OS X again
- Gems with gemspecs which contain UTF-8 multi-byte chars install in 1.9 mode
完整的列表請(qǐng)看:full list of resolved issues
JRuby是面向Ruby、基于Java虛擬機(jī)(JVM)的一種解釋程序,它結(jié)合了Ruby語(yǔ)言的簡(jiǎn)易性和功能強(qiáng)大的JVM的執(zhí)行機(jī)制,包括與Java庫(kù) 全面集成。Rails徹底加快及簡(jiǎn)化了Web應(yīng)用的開(kāi)發(fā),不過(guò)它讓人覺(jué)得不夠成熟,特別是在高端企業(yè)級(jí)功能方面。另一方面,Java平臺(tái)及其虛擬機(jī)、庫(kù)和 應(yīng)用服務(wù)器的速度、穩(wěn)定性和功能方面卻一直在提升,現(xiàn)在已被公認(rèn)為是開(kāi)發(fā)高端服務(wù)器應(yīng)用的領(lǐng)先平臺(tái)。不過(guò)如果Java平臺(tái)不與Ruby等新興語(yǔ)言聯(lián)系在一 起,就有可能落后于流行趨勢(shì)。
示例代碼:
- require "java"
- include_class "java.util.TreeSet"
- include_class "com.example.CallMe"
- include_class "com.example.ISpeaker"
- puts "Hello from ruby"
- set = TreeSet.new
- set.add "foo"
- set.add "Bar"
- set.add "baz"
- set.each { |v| puts "value: #{v}" }
- cm = CallMe.new
- cm.hello
- $globalCM.hello
- class CallJava
- include ISpeaker
- def initialize
- super
- @count = 0
- end
- def say(msg)
- puts "Ruby saying #{msg}"
- end
- def addOne(from)
- # m.synchronize {
- @count += 1
- puts "Now got #@count from #{from}"
- # }
- end
- end
下載地址:http://jruby.org/download
【編輯推薦】