[jboss-user] [Javassist] - Saving proxy classes and using them in Android

Eric H do-not-reply at jboss.com
Tue Mar 30 02:53:19 EDT 2010


Eric H [http://community.jboss.org/people/EricJava] replied to the discussion

"Saving proxy classes and using them in Android"

To view the discussion, visit: http://community.jboss.org/message/534561#534561

--------------------------------------------------------------
I answer my own question.

It looks like Javassist isn't the right tool for this.  It needs to mess with classloaders, an area where Android is quite different from standard Java.  Also it has more flexibility.  The class can be final, doesn't need a no-args constructor, etc.

I got it done with ASM.  ASM was perfect for this.  It lets me modify the class itself, rather than creating a proxy for it.  That's (slightly) better for performance, and also makes it very easy to use them with the rest of the Android packaging tools.

The hard part about ASM were two things:

* It's a bit of an API to deal with.
* The new code I insert had to be Java assembly

But there's a trick that made it easier to get the assembly code.  There's a ASMifier tool that generates ASM API calls to generate a given class file.  So you just write the code you want, run ASMifier on it, and cut and paste the assembly generator calls.  But doing anything more than small amounts of code would be a big pain IMO.

Anyway, both are impressive tools, but ASM was the right one for this job.

--------------------------------------------------------------

Reply to this message by going to Community
[http://community.jboss.org/message/534561#534561]

Start a new discussion in Javassist at Community
[http://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2062]

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/jboss-user/attachments/20100330/b9c75c29/attachment.html 


More information about the jboss-user mailing list