Posted by mranga
on December 11, 2003 at 9:33 AM PST
bytecode re-writing - an evil under-utilized technique?
I recently started a project on java.net which allows untrusted users to upload classes to a SIP service platform (for customizing call control in a SIP network). In doing so I played around quite a bit with bytecode re-writing using the bcel library. I was quite surprised at the type of run-time customizations that this simple technique allows. Using this technique and by the simple expedient of standarizing the interface to a SIP stack, we were able to build a customized sandbox environment to allow untrusted users to upload code to a SIP Server. ( visit http://jain-sip-appserver.dev.java.net to take a look if you are interested).
By using this technique one can enable things like Mobile Software Agents and other strange abstractions by building customized sandbox environments and hooks into existing code to make sure it does not mis-behave on your machine. ( There have been a few mobile agents that enabled thread mobility using this technique. )
As for the technique itself, it is considered by software engineers to be evil of course but then it works and is pretty cool and I suspect it is under-utilized. Indeed I find the most compelling things about java are things like introspection, Interfaces, customized classloading and the ability to do things like bytecode re-writing. I can live without object orientation (although I like it) and garbage collection (although I like that too). On the other hand I learned to tighten nuts before I learned to write code. Perhaps that changes one's perception