Upgrade to Pro — share decks privately, control downloads, hide ads and more …

JRuby hacking guide

JRuby hacking guide

My talk about JRuby internals at Euruko 2011.

David Calavera

May 28, 2011
Tweet

More Decks by David Calavera

Other Decks in Technology

Transcript

  1. jruby-1.6.2 :003 > raise ArgumentError.new ArgumentError: ArgumentError from (irb):3:in `evaluate'

    from org/jruby/RubyKernel.java:1088:in `e from /Users/david/.rvm/rubies/jruby-1.6.2 irb.rb:158:in `eval_input' from /Users/david/.rvm/rubies/jruby-1.6.2 irb.rb:271:in `signal_status' from /Users/david/.rvm/rubies/jruby-1.6.2 irb.rb:155:in `eval_input' from org/jruby/RubyKernel.java:1419:in `l from org/jruby/RubyKernel.java:1191:in `c from /Users/david/.rvm/rubies/jruby-1.6.2 irb.rb:154:in `eval_input' from /Users/david/.rvm/rubies/jruby-1.6.2
  2. jruby-1.6.2 :001 > raise ArgumentError.new ArgumentError: ArgumentError from (irb):1:in `evaluate'

    from org/jruby/RubyKernel.java:1088:in `e from /Users/david/.rvm/rubies/jruby-1.6.2 irb.rb:158:in `eval_input' from /Users/david/.rvm/rubies/jruby-1.6.2 irb.rb:271:in `signal_status' from /Users/david/.rvm/rubies/jruby-1.6.2 irb.rb:155:in `eval_input' from org/jruby/RubyKernel.java:1419:in `l from org/jruby/RubyKernel.java:1191:in `c from /Users/david/.rvm/rubies/jruby-1.6.2 irb.rb:154:in `eval_input' from /Users/david/.rvm/rubies/jruby-1.6.2
  3. jruby-1.6.2 :001 > raise ArgumentError.new ArgumentError: ArgumentError from (irb):1:in `evaluate'

    from org/jruby/RubyKernel.java:1088:in `e from /Users/david/.rvm/rubies/jruby-1.6.2 irb.rb:158:in `eval_input' from /Users/david/.rvm/rubies/jruby-1.6.2 irb.rb:271:in `signal_status' from /Users/david/.rvm/rubies/jruby-1.6.2 irb.rb:155:in `eval_input' from org/jruby/RubyKernel.java:1419:in `l from org/jruby/RubyKernel.java:1191:in `c from /Users/david/.rvm/rubies/jruby-1.6.2 irb.rb:154:in `eval_input' from /Users/david/.rvm/rubies/jruby-1.6.2
  4. Rspec describe "glob file path" do it "lists contents of

    a file" do dir = Dir.new(@local_file_path) dir.entries.should include("junit.jar") end end
  5. RubySpec describe "Dir.entries" do ... it "returns an Array of

    filenames in an existing directory including dotfiles" do ...
  6. ruby code static VALUE dir_entries(int argc, VALUE *argv, VALUE io)

    { VALUE dir; dir = dir_open_dir(argc, argv); return rb_ensure(rb_Array, dir, dir_close, dir); }
  7. Ruby class $ vi src/org/jruby/RubyDir.java @JRubyClass(name = "Dir", include =

    "Enumerable") public class RubyDir extends RubyObject {
  8. Ruby class $ vi src/org/jruby/RubyDir.java @JRubyClass(name = "Dir", include =

    "Enumerable") public class RubyDir extends RubyObject {
  9. Ruby class $ vi src/org/jruby/RubyDir.java @JRubyClass(name = "Dir", include =

    "Enumerable") public class RubyDir extends RubyObject {
  10. Ruby class $ vi src/org/jruby/RubyDir.java @JRubyClass(name = "Dir", include =

    "Enumerable") public class RubyDir extends RubyObject {
  11. Ruby class $ vi src/org/jruby/RubyDir.java @JRubyClass(name = "Dir", include =

    "Enumerable") public class RubyDir extends RubyObject {
  12. Ruby method @JRubyMethod(name = "mkdir", required = 1, optional =

    1, meta = true, compat = RUBY1_8) public static IRubyObject mkdir(IRubyObject recv, IRubyObject[] args) {
  13. Ruby method @JRubyMethod(name = "mkdir", required = 1, optional =

    1, meta = true, compat = RUBY1_8) public static IRubyObject mkdir(IRubyObject recv, IRubyObject[] args) {
  14. Ruby method @JRubyMethod(name = "mkdir", required = 1, optional =

    1, meta = true, compat = RUBY1_8) public static IRubyObject mkdir(IRubyObject recv, IRubyObject[] args) {
  15. Ruby method @JRubyMethod(name = "mkdir", required = 1, optional =

    1, meta = true, compat = RUBY1_8) public static IRubyObject mkdir(IRubyObject recv, IRubyObject[] args) {
  16. Ruby method @JRubyMethod(name = "mkdir", required = 1, optional =

    1, meta = true, compat = RUBY1_8) public static IRubyObject mkdir(IRubyObject recv, IRubyObject[] args) {
  17. Ruby method @JRubyMethod(name = "mkdir", required = 1, optional =

    1, meta = true, compat = RUBY1_8) public static IRubyObject mkdir(IRubyObject recv, IRubyObject[] args) {
  18. Ruby method @JRubyMethod(name = "mkdir", required = 1, optional =

    1, meta = true, compat = RUBY1_8) public static IRubyObject mkdir(IRubyObject recv, IRubyObject[] args) {
  19. Ruby method @JRubyMethod(name = "mkdir", required = 1, optional =

    1, meta = true, compat = RUBY1_8) public static IRubyObject mkdir(IRubyObject recv, IRubyObject[] args) {
  20. Ruby method @JRubyMethod(name = "mkdir", required = 1, optional =

    1, meta = true, compat = RUBY1_8) public static IRubyObject mkdir(IRubyObject recv, IRubyObject[] args) {
  21. Ruby method @JRubyMethod(name = "mkdir", required = 1, optional =

    1, meta = true, compat = RUBY1_8) public static IRubyObject mkdir(IRubyObject recv, IRubyObject[] args) {
  22. Ruby module @JRubyMethod(name = {"kind_of?", "is_a?"}, required = 1) public

    static RubyBoolean kind_of_p (ThreadContext context, IRubyObject recv, IRubyObject type) {
  23. Ruby module @JRubyMethod(name = {"kind_of?", "is_a?"}, required = 1) public

    static RubyBoolean kind_of_p (ThreadContext context, IRubyObject recv, IRubyObject type) {
  24. Ruby module @JRubyMethod(name = {"kind_of?", "is_a?"}, required = 1) public

    static RubyBoolean kind_of_p (ThreadContext context, IRubyObject recv, IRubyObject type) {