The Artima Developer Community
Sponsored Link

Ruby Buzz Forum
Ruby/Java integration

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
Mauricio Fernández

Posts: 47
Nickname: batsman
Registered: Aug, 2003

Mauricio Fernández is an electrical engineering student
Ruby/Java integration Posted: Aug 22, 2003 5:38 PM
Reply to this message Reply

This post originated from an RSS feed registered with Ruby Buzz by Mauricio Fernández.
Original Post: Ruby/Java integration
Feed Title: fail unless class << self; self end
Feed URL: http://www.thekode.net/blog/Tech/Ruby/syndication.rss
Feed Description: Ruby babblings.
Latest Ruby Buzz Posts
Latest Ruby Buzz Posts by Mauricio Fernández
Latest Posts From fail unless class << self; self end

Advertisement
It’s been some time (around 3 weeks and a half now) since I started to hack rjni. At first I didn’t think about what integration does really mean: I was just implementing (quite in a hurry) an idea that popped out during Euruko 03. So I just provided a simple means to use JNI from Ruby and a (IMHO neat) mapping of Java to Ruby concepts: static methods become class singleton methods, accessors are created for attributes, etc.

I’ve been thinking of expanding the scope of rjni to cope with the following issues:

  • type-safety: as of now, you can crash the interpreter by using JNI with wrong parameters. This could be prevented but
    1. there’s a performance hit
    2. that’s what you get for using low-level APIs instead of "magical reflection"
  • signal handling: Ruby’s threading model uses signals to simulate threads (green threads). What are the implications when linking to the JVM?
  • sub-classing Java classes in Ruby and using them from Ruby: already possible, but not clean enough as there’s a couple things to consider:
    1. method overloading in Java complicates things on the Ruby side
    2. Java attributes don’t become instance variables (you have to go through accessors, even inside instance methods)
  • using Ruby from Java? Involves mapping Ruby’s C API through JNI
  • then it becomes possible to subclass Java classes in Ruby and use them in Java…
  • threads: Ruby’s interpreter is not thread safe; this will be a problem if using Ruby from Java becomes possible

The signal handling issue is especially problematic since that’s quite tricky and possibly system- and JVM-dependent. Threads could prove to be difficult to get right, too.

If you see how to solve these problems (or want to have some fun doing so :-) contact me at <batsman dot geo at yahoo dot com>.

Read: Ruby/Java integration

Topic: Design by Contract and Unit Testing Previous Topic   Next Topic Topic: Scripting Languages for Building

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use