-
Notifications
You must be signed in to change notification settings - Fork 858
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Request] Android ByteCode generation support #211
Comments
Maybe you could try to use optimization level |
Rhino does only work on android with optimization level set to -1, so this is already set. here is the logcat of a simple test script for JavaAdapter: java.lang.UnsupportedOperationException: can't load this type of class file |
Yes -- Rhino generates "regular" Java bytecode, so yes, if you want to be On Mon, Jun 29, 2015 at 11:53 AM, F43nd1r [email protected] wrote:
Greg Brail | apigee https://apigee.com/ | twitter @gbrail |
I am just wondering why everything else - even implementing interfaces - works, but the JavaAdapter doesn't.... |
The JavaAdapter also generates bytecode to do its job. It uses the same ClassFileWriter as the regular code generation, so that generates bytecode that's compatible with Java and apparently not with Dalvik. So depending on how different the bytecodes are, we'd have to create a new ClassFileWriter for different VMs. |
I found a very interesting project: Dexmaker (https://github.com/crittercism/dexmaker). I tried to replace the current classfilewriter with a wrapper around the dexmaker. My problem is now: dexmakers methods operate on a higher level than those of classfilewriter. For example i can't implement add(int theOpCode), because dexmaker always expects some kind of target (e.g. a local variable). Is there a better point to plug this in? Or is it just plain stupid to try it because it won't fit? Any other comments? |
OK, so I got my own project working on android with optimization in use by provididng custom class loading. For anyone who is interested - https://github.com/F43nd1r/rhino-android. It seems to work pretty good, altough I haven't tested it a lot. |
Glad to hear it! We've had a number of questions about running on Android, so if you ever On Thu, Jan 14, 2016 at 1:16 PM, F43nd1r [email protected] wrote:
Greg Brail | apigee https://apigee.com/ | twitter @gbrail |
I am currently working on running all the java tests on an android device. While most run fine, I don't understand some of the errors:
What do those mean?
How can this be resolved? |
FYI here is a sample application showcasing how to use rhino on android, as you asked for. |
reopen for awareness. |
i am having problem with android kitkat and big js files around 500kb |
Hi, |
My project is running, altough according to some bug reports, it has problems in certain situations. The solution is not optimal, because it adds another compile step (someone with enough knowledge of both jvm and art bytecode could probably cut one compile step). Feel free to try the project - https://github.com/F43nd1r/rhino-android |
As I already mentioned in #282 (comment), Byte Buddy supports both Java and Android byte code generation - thus it could be a good option for |
@F43nd1r , I managed to in-build your project with a custom rhino, that not only does the runtime compile classloading, it also changed the classloader profile to aggressive. Normally, if you request a package from the Mozilla Packages object, it caches the request, if the first request is a 404, adding to the classpath won't help. I built a URL classloader and injected it into the ContextFactory class as the default class loader for makeContext (single-instance). The classloader also keeps track of all package requests, so i can know what packages and classes have been loaded by the script runtime, (maybe even put a security or debug wrapper in there). My url classloader is not (directly) designed to be used by your ContextFactory (means: foreign+code+compatible:interface-synchronization-hard-limit). Your method works fine with that, as far as I know. Good work by the way. I've managed to cut all the dalvik code, plus your project down to ~28KB. Your code is AUTO injected into the mozilla Context at line 474 using a custom system detection routine i built. |
@mozilla, seems you could make it easy for android users to use your code, if you put the instrumentation to use his ContextFactory, when available in the Context as done here at line 474. Then an archive such as the nano-archive i have built, could automagically load for the android users with the simple addition of some class files to their own classpath. Ideally, you would make that an api, for seamless context factory integration, perhaps using
|
@F43nd1r , one more thing [okay two more], that nano archive, basically traces the Dalvik API route of your project. you can use that route, plus the sources to construct your own android debugging layer... The route in place is factory code. It would also be nice if your project used the System.getProperty trick to setup the cache loader since you can't touch the android context which provides that api, from outside of the android api. This is crucial because each android-application has its own cache directory, and any autoloading would need a correct cache directory, for Certifiable Android Platform Integration [and make sure you wipe the property after loading, telling the user this will happen for security]. |
This is also very useful information for anyone Implementing an ART Just-In-Time (JIT) Compiler, such as Faendir's project. It details how to configure the platform for debugging and other tricks of the trade. |
Rhino works fine on Android with one big drawback: JavaAdapter can't be used, because it relies on Java bytecode, while android runs Dalvik bytecode.
Has anyone ever tried to create a version which removes this drawback in any way?
If not, can somebody do this or point me in a direction where I could start with this?
The text was updated successfully, but these errors were encountered: