Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8483387
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T20:05:21+00:00 2026-06-10T20:05:21+00:00

I am experimenting around with JRuby – generating java from ruby files. I have

  • 0

I am experimenting around with JRuby – generating java from ruby files. I have an abstract class in ruby that implement a Java interface, and child classes extending this. also in ruby.

I’m running into the problem as described on http://jira.codehaus.org/browse/JRUBY-6342 where all the generated java files only extend RubyObject.

I am wondering if anyone else has encountered this and have a workaround? Right now I have used a java_implement interface in each child class as they do not extend the abstract class.

I have included the snippet from JRUBY-6342 describing the problem:

The Java code generated by jrubyc –java does not appear to support Ruby class inheritance. Given the following simple example:

class A
def my_class; self.class.name end
end

class B < A
end

The generated class in B.java inherits from RubyObject rather than A, rendering the B class completely broken in Java.
On a somewhat related note, module inclusion doesn’t seem to work either. A class with include M doesn’t get M’s methods in the generated Java code.

Am I missing something in my understanding of Ruby or JRuby?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T20:05:23+00:00Added an answer on June 10, 2026 at 8:05 pm

    This is still an issue indeed as the jruby compiler still produces RubyObject for the classes.

    The only workaround that I know to this is to use the JRuby ScriptEngine from Java to eval your JRuby code. For example, here is some JRuby code:

    require 'java'
    
    java_import 'javax.swing.JFrame'
    java_import 'javax.swing.JButton'
    
    class MyFrame < JFrame
      def initialize
        super('Test')
        content_pane.add(JButton.new("Hello"))
        pack()
      end
    end
    

    This code can then be called from a Java class like this:

    import javax.swing.JFrame;
    
    import javax.script.*;
    import java.io.*;
    
    public class Main {
        public static void main(String[] args) throws Exception {
    
        ScriptEngineManager manager = new ScriptEngineManager();
            ScriptEngine engine = manager.getEngineByName("jruby");
            Reader reader = new FileReader("myframe.rb");
            engine.eval(reader);
    
            // Instantiate the JRuby class, and cast the result of eval.
            JFrame frame = (JFrame) engine.eval("MyFrame.new");
            frame.setVisible(true);
        }
    }
    

    Here the object returned by eval can be casted into JFrame, just as you would expect. See also this question for that problem.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a website, that is slow-ish. The server responds in around 2 -
I'm rather new to SOA and therefore experimenting around. Currently, the part that creates
so I am new to JSON, and have been experimenting around with some possibilities.
I'm new to Perl and was experimenting around a bit. I have this code:
I'm experimenting with the Doctrine ORM (v1.2) for PHP. I have defined a class
I am experimenting with changing some stylesheets from javascript I have come across a
When experimenting with (embedded) Apache Derby DB, I noticed that a fresh database, with
Been experimenting with the instagram-ruby-gem on and off for a few days - no
I am experimenting with Dart. I have created an on click event like so:
I was experimenting around with XPath, basically I'm trying to load a HTML page

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.