Android + JRuby?

Hey Mr. Nutter…
Any idea if JRuby will work on Android???
Sure would be cool to have a Ruby angle on phone software, even
though there is no Android phone yet…

John J. wrote:

Hey Mr. Nutter…
Any idea if JRuby will work on Android???
Sure would be cool to have a Ruby angle on phone software, even though
there is no Android phone yet…

Unless it has Java support, probably not…though there are medium an
large scale Java phones that probably could be made to run JRuby. We’re
definitely interested in the possibilities :slight_smile:

Anyone know more about Android and whether it could run Ruby in some
form?

  • Charlie

On Nov 5, 2007, at 7:25 PM, Charles Oliver N. wrote:

Anyone know more about Android and whether it could run Ruby in
some form?

  • Charlie

From what I could gather, it does have Java support or is at least
written in Java.
Being supposedly open (we’ll find out next week I guess…) this
could be an interesting in …

On Nov 5, 7:44 pm, John J. [email protected]
wrote:
[…]

Being supposedly open (we’ll find out next week I guess…) this
could be an interesting in …

:slight_smile:

However, the performance would probably not be up to par?

-Thufir

On Nov 12, 2007, at 1:58 PM, Shajith wrote:

this means that anything that compiles to normal Java bytecode is good
to go. Can you confirm?

Shajith

As I suspected, the project actually e-mailed me back about it last
Friday night, with a hint, hint, nudge, nudge about it and look at
things Monday. Sure enough, there it is.
So looks like Java is moving into the embedded world now.
Now the only clincher is seeing this thing hit the market, which it
most likely will.
The Japanese handset makers involved are all desperate to stay in
their domestic market and stop reinventing the wheel every six months…
I’m thinking Ruby phone via JRuby…

On 11/6/07, Charles Oliver N. [email protected] wrote:

Unless it has Java support, probably not…

The Android SDK was just announced, and it the application layer is in
Java!
Details here: http://code.google.com/android/index.html

The VM seems to require transformation of Java byte code to a
different format (dex) through a provided tool. It’s not clear whether
this means that anything that compiles to normal Java bytecode is good
to go. Can you confirm?

Shajith

Hey Mr. Nutter…
Any idea if JRuby will work on Android???
Sure would be cool to have a Ruby angle on phone software, even
though there is no Android phone yet…

But the Neo1973 is real, and so is the Ruby port:
http://chmeee.dyndns.org/om/ruby/feed/

Bye,
Kero.

John J. wrote:

Hey Mr. Nutter…
Any idea if JRuby will work on Android???
Sure would be cool to have a Ruby angle on phone software, even though
there is no Android phone yet…

From a cursory glance at the SDK, I’d say…yes!

I’m not sure yet if everything we need is there, but it would be
considerably easier to bring JRuby up on Android than on Java ME. Most
of the packages I expected to be missing are present…so I think
there’s a good chance it could be made to run.

  • Charlie

On Nov 13, 2007 6:41 PM, [email protected] wrote:

considerably easier to bring JRuby up on Android than on Java ME. Most
of the packages I expected to be missing are present…so I think
there’s a good chance it could be made to run.

A simple test: adding jruby-complete.jar onto the dex call in build.xml:

 [exec] ...while processing org/jruby/parser/DefaultRubyParser.class
 [exec] 1 error; aborting

And copying the entire JRuby source into the Android project.
(Removed BSFExample.java and demo since java.awt and javax.swing did
not exist.):

compile:
[javac] Compiling 621 source files to
/nas/projects/cameron/public/android_sdk_linux_m3-rc20a/JRubyTest/bin/classes
[javac]
/nas/projects/cameron/public/android_sdk_linux_m3-rc20a/JRubyTest/src/org/jruby/javasupport/JavaClass.java:38:
package java.beans does not exist
[javac] import java.beans.BeanInfo;
[javac] ^
[javac]
/nas/projects/cameron/public/android_sdk_linux_m3-rc20a/JRubyTest/src/org/jruby/javasupport/JavaClass.java:39:
package java.beans does not exist
[javac] import java.beans.IntrospectionException;
[javac] ^
[javac]
/nas/projects/cameron/public/android_sdk_linux_m3-rc20a/JRubyTest/src/org/jruby/javasupport/JavaClass.java:40:
package java.beans does not exist
[javac] import java.beans.Introspector;
[javac] ^
[javac]
/nas/projects/cameron/public/android_sdk_linux_m3-rc20a/JRubyTest/src/org/jruby/javasupport/JavaClass.java:41:
package java.beans does not exist
[javac] import java.beans.PropertyDescriptor;
[javac] ^
[javac]
/nas/projects/cameron/public/android_sdk_linux_m3-rc20a/JRubyTest/src/org/jruby/javasupport/bsf/JRubyEngine.java:64:
cannot access java.beans.PropertyChangeListener
[javac] class file for java.beans.PropertyChangeListener not found
[javac] public class JRubyEngine extends BSFEngineImpl {
[javac] ^
[javac]
/nas/projects/cameron/public/android_sdk_linux_m3-rc20a/JRubyTest/src/org/jruby/javasupport/JavaClass.java:969:
cannot find symbol
[javac] symbol : class BeanInfo
[javac] location: class org.jruby.javasupport.JavaClass
[javac] BeanInfo info;
[javac] ^
[javac]
/nas/projects/cameron/public/android_sdk_linux_m3-rc20a/JRubyTest/src/org/jruby/javasupport/JavaClass.java:972:
cannot find symbol
[javac] symbol : variable Introspector
[javac] location: class org.jruby.javasupport.JavaClass
[javac] info = Introspector.getBeanInfo(javaClass());
[javac] ^
[javac]
/nas/projects/cameron/public/android_sdk_linux_m3-rc20a/JRubyTest/src/org/jruby/javasupport/JavaClass.java:973:
cannot find symbol
[javac] symbol : class IntrospectionException
[javac] location: class org.jruby.javasupport.JavaClass
[javac] } catch (IntrospectionException e) {
[javac] ^
[javac]
/nas/projects/cameron/public/android_sdk_linux_m3-rc20a/JRubyTest/src/org/jruby/javasupport/JavaClass.java:977:
cannot find symbol
[javac] symbol : class PropertyDescriptor
[javac] location: class org.jruby.javasupport.JavaClass
[javac] PropertyDescriptor[] descriptors =
info.getPropertyDescriptors();
[javac] ^
[javac]
/nas/projects/cameron/public/android_sdk_linux_m3-rc20a/JRubyTest/src/org/jvyamlb/RepresenterImpl.java:393:
warning: non-varargs call of varargs method with inexact argument type
for last parameter;
[javac] cast to java.lang.Object for a varargs call
[javac] cast to java.lang.Object[] for a non-varargs call and to
suppress this warning
[javac] values.put(pname,
ems[i].invoke(data,null));
[javac]
^
[javac]
/nas/projects/cameron/public/android_sdk_linux_m3-rc20a/JRubyTest/src/org/jruby/javasupport/bsf/JRubyEngine.java:130:
cannot find symbol
[javac] symbol : variable super
[javac] location: class org.jruby.javasupport.bsf.JRubyEngine
[javac] super.initialize(manager, language,
someDeclaredBeans);
[javac] ^
[javac]
/nas/projects/cameron/public/android_sdk_linux_m3-rc20a/JRubyTest/src/org/jruby/javasupport/bsf/JRubyEngine.java:141:
cannot find symbol
[javac] symbol : variable this
[javac] location: class org.jruby.javasupport.bsf.JRubyEngine
[javac]
runtime.getGlobalVariables().defineReadonly(“$bsf”, new
FunctionsGlobalVariable(runtime, new BSFFunctions(manager, this)));
[javac]
^
[javac]
/nas/projects/cameron/public/android_sdk_linux_m3-rc20a/JRubyTest/src/org/jruby/javasupport/bsf/JRubyEngine.java:234:
cannot find symbol
[javac] symbol : variable super
[javac] location: class org.jruby.javasupport.bsf.JRubyEngine
[javac] super.terminate();
[javac] ^
[javac] Note: Some input files use unchecked or unsafe operations.
[javac] Note: Recompile with -Xlint:unchecked for details.
[javac] 12 errors
[javac] 1 warning

BUILD FAILED

Oh, this was JRuby-1.0.2 in both cases.

[email protected] wrote:

of the packages I expected to be missing are present…so I think
[exec] at

Looks like a bug in Android SDK. It’s deep into Google’s code from
something of ours that shouldn’t be doing anything too weird…

  • Charlie

On Nov 13, 2007 3:38 PM, Charles Oliver N. [email protected]
wrote:

of the packages I expected to be missing are present…so I think
there’s a good chance it could be made to run.

A simple test: adding jruby-complete.jar onto the dex call in build.xml:

dex:

 [exec] UNEXPECTED TOP-LEVEL EXCEPTION:
 [exec] com.google.util.ExceptionWithContext: address not yet known
 [exec]    at

com.google.util.ExceptionWithContext.withContext(ExceptionWithContext.java:46)
[exec] at
com.google.dex.cf.CfTranslator.processMethods(CfTranslator.java:375)
[exec] at
com.google.dex.cf.CfTranslator.translate0(CfTranslator.java:153)
[exec] at
com.google.dex.cf.CfTranslator.translate(CfTranslator.java:117)
[exec] at
com.google.command.dexer.Main.processClass(Main.java:362)
[exec] at
com.google.command.dexer.Main.processFileBytes(Main.java:346)
[exec] at
com.google.command.dexer.Main.processArchive(Main.java:311)
[exec] at
com.google.command.dexer.Main.processOne(Main.java:233)
[exec] at
com.google.command.dexer.Main.processAllFiles(Main.java:169)
[exec] at com.google.command.dexer.Main.run(Main.java:126)
[exec] at com.google.command.dexer.Main.main(Main.java:107)
[exec] at com.google.command.Main.main(Main.java:51)
[exec] Caused by: java.lang.RuntimeException: address not yet known
[exec] at
com.google.dex.code.DalvInsn.getAddress(DalvInsn.java:162)
[exec] at
com.google.dex.code.TargetInsn.getTargetOffset(TargetInsn.java:110)
[exec] at
com.google.dex.code.form.Form20t.branchFits(Form20t.java:67)
[exec] at
com.google.dex.code.OutputCollector.fixBranches(OutputCollector.java:429)
[exec] at
com.google.dex.code.OutputCollector.assignAddressesAndFixBranches(OutputCollector.java:382)
[exec] at
com.google.dex.code.OutputCollector.finishProcessingAndGetList(OutputCollector.java:117)
[exec] at
com.google.dex.code.RopTranslator.translateAndGetResult(RopTranslator.java:204)
[exec] at
com.google.dex.code.RopTranslator.translate(RopTranslator.java:98)
[exec] at
com.google.dex.cf.CfTranslator.processMethods(CfTranslator.java:346)
[exec] …10 more
[exec] …while processing ()V
[exec] …while processing org/jruby/parser/DefaultRubyParser.class

 [exec] 1 error; aborting