|
From: Chris N. <ch...@si...> - 2003-11-17 19:23:41
|
Colin Sampaleanu wrote: > I can actually answer that, to the extent that looking at the existing > code in BcelAttributes and BcelAttributeWriter, I don't see anything at > all in there that you couldn't do with Javassist. I like the idea of Javassist but in practice it seems to result in messy StringBuffer code to build up the Java pseudocode. At some point dealing with the raw bytecodes almost seems easier (but maybe I have been looking at bytecode for too long :-) > As to this is in any way preferable to using an ASM/cglib combination, > that's harder to answer. Javassist would probably be a more direct > replacement on a line by line basis, since it's fundamental approach is > fairly similar; you work with objects representing the bytecode > elements. It definitely runs faster than BCEL, and uses less memory, but > my feeling is that for raw speed and memory usage, ASM's 'visitor' > approach would win out. ASM will always win out unless you need to keep a lot of state while visiting (for things such as code flow analysis), and maybe even then. For your application of just reading and writing an attribute it is definitely the way to go. In CGLIB2 we also have some Ant tasks which should make porting easier. If I have some spare time I may port the BCEL stuff as an example. FYI Hibernate 2.1 will use CGLIB2 which means Spring will need to upgrade at the same time. I can supply you with a patch when you want to do this. Chris |