1

I'm currently involved in development of an Android framework that would make it possible to delegate a method invocation to a server (with a JVM running), which will execute the method and return a result, so it would operate in a quite similar fashion to well-known Java RMI. Our team also have a plan to implement a dynamic code loading, so that you will be able to execute Android class's methods on the server even if it doesn't know that class implementation yet (it would download the definition of an object's class first).

Accordingly, I'm trying to figure out what would be the best way to export Android class to the server at run-time. The main problem is that Dalvik operates on *.dex files that have different structure and are differently handled than *.class files executed by a typical JVM.

So far, we've been thinking about specifying that dx tool should keep certain *.class files when compiling source code. There is such an option as --keep-classes, but it preserves classes globally, while we won't need *.class file for every single class. Also, there is no way to manage dx tool options from the ADT Eclipse, as far as I know.

What approach would be best for us to follow in your opinion?

falconepl
  • 398
  • 1
  • 3
  • 15
  • 1
    Perhaps you could use a custom build step to build the files of interest to standard-java class files, and include those as assets in the Android build (so that it will treat them as data, rather than as code to be further converted to dex) – Chris Stratton Apr 11 '13 at 19:22
  • Surely it will be easier to deploy new code directly to the server rather than via the clients? The codebase feature is usually used the other way around, to deliver server-side code to clients, to overcome the client deployment problem. – user207421 Apr 12 '13 at 00:57
  • @ChrisStratton: Sounds like a plan, but I'm still looking for some solution that would be more programmatical, so that an Android application developer doesn't need to fiddle with build settings to make things work. – falconepl Apr 12 '13 at 13:16
  • @EJP: Actually, that's our idea. Let's say that somebody would like to give their Android application a boost and delegate computationally expensive calculations to a server. Such a developer might not be interested in setting up own server though - it may be provided by someone else. – falconepl Apr 12 '13 at 13:29
  • So you're building a system whereby your customers can upload executable code to servers provided by third parties. Sounds like a good way to make yourselves very unpopular. Have you thought through the security requirements and implications? – user207421 Apr 12 '13 at 22:32

1 Answers1

0

What if instead, you passed a script to the server? Java can run scripts at runtime, with support for python, ruby, javascript, etc.

See here: Calling Python from Java through scripting engine (jython)?

and here: http://www.ibm.com/developerworks/java/library/j-javascripting1/

You would still need a bit of work to figure out how to pass the results back.

Community
  • 1
  • 1
Jamie
  • 1,786
  • 1
  • 16
  • 20
  • It is not clear to me how we could make use of scripting in our solution. What such a script should actually contain? – falconepl Apr 11 '13 at 19:31