- Rava / JavaVM on Ruby (2) (Rava version 0.0.2)
- Rava / JavaVM on Ruby (Rava version 0.0.1)
According to Ko1, Rava is pure Ruby JavaVM and joke software. He said in the article for a Japanese Magazine that Rava could load and interpret a Java class. Rava was not perfect but had basic features, for example:
- interprets most of bytecode
- invokes static/non-static methods
- reads/writes static/non-static fields
- handles exceptions
- runs threads
Also, Ko1 created a prototype of a JIT compiler. He made all of those in a week or so. Ko1 explained that's Ruby.
Here're excerpts from the article about Rava in depth.
- Operand Stack : Rava used Ruby Array to handle Java's operand stack since Ruby Array has enough feature to manage the stack.
- Types and data: Rava mapped Java's primitive types to Ruby's Number or its descendant. Java's reference type was converted into a field and Ruby object that has a reference to the original object. Java's field was mapped to Hash with keys of field names.
- Method invocation : Rava had its method frame as in below. JVM stack was in a single array, which includes operand stack.
[Rava Method Frame]
operand stack --->| | |
stack pointer --->+----------+ |
invoker frame info --->| | | method fame
local variable are --->| | |
frame pointer ---> +----------+ --
invoker method frame --> | |
JRuby interprets Ruby on Java, while Rava interprets Java on Ruby. JRuby's become_java! converts Ruby class into Java bytecode, while Rava's JIT compiler converts Java bytecode into Ruby class. Unlike JRuby, Rava was outdated, which is a big difference; however, exploring Rava code might be fun.