ASM vs JavaAssist

202 views
Skip to first unread message

ted stockwell

unread,
Dec 14, 2012, 1:07:03 PM12/14/12
to kilimthreads
Hi All,

I have spent some time trying to fix this Kilim issue:
https://github.com/kilim/kilim/issues/16
This issue is important to me because I have run into a couple of
other verification problems in Java6 that I have not yet posted
because I have not been able to boil them down to a simple example.
I have also run into some weird classloading issues that I also
suspect are the result of the lack of proper stack map attributes for
instrumented methods (which is what causes the verification problems).
These verification issues have to be fixed before I can continue using
Kilim, and I so totally do not want to give up Kilim :-).
My plan for fixing this issue was to upgrade Kilim to ASM4 and then
have ASM4 automatically generate proper stack maps for instrumented
methods.
If successful, this would fix verification problems in both Java6 and
make Kilim work in Java7.

So far I was able to make Kilim work with ASM4.
In my kilimbuilder project (kilimbuilder.googlecode.com) I have a
version of Kilim upgraded to ASM4 that passes all the Kilim unit tests
(well, all the tests that the current version passes).

However, as far as getting ASM4 to automatically generate proper stack
map frames... I'm pretty sure that is never gonna happen.
I've had a boatload of issues getting ASM4 to automatically generate
stack maps.
So many problems, actually, that I am convinced that ASM4 will never
do it.
And its not just that there are a lot of subtle issues to address when
generating stack maps, some of the problems I've encountered with ASM
are just the result of sloppy coding and bad modeling.
Also, ASM is coded in such a way (with package protected member
variables and such) that it's damn near impossible to code workarounds
for its problems.
I am very disillusioned with ASM and not inclined to try to fix its
issues.

So... that got me looking around and I found Javassist:
http://www.jboss.org/javassist.
Powermock is another project that does bytecode engineering and that
also had these verification problems.
The Javassist team recently fixed the problems and Javassist now
automatically generates proper stack maps.
http://code.google.com/p/powermock/issues/detail?id=355

So... I am considering porting Kilim to Javassist and seeing if
Javassist will be successful at automatically generating stack maps.
And, FINALLY, the point of this post was to ask this group some
questions before I start this next task...
Does anybody on this list have any experience with Javassist?
And if so, what's your opinion of it?
Do you know of any issues with Javassist that might prevent me from
porting Kilim?










Jason Pell

unread,
Dec 14, 2012, 4:14:29 PM12/14/12
to kilimt...@googlegroups.com
Hi,

Any chance you could provide your asm 4 compatible version of kilim
itself? I tried copying your com.googlecode.kilimbuilder.kilim from
the branch before-javassist-refactoring. But I cannot get that to
compile using build.sh?

Ideally a clone of the github repo and then a pull request.

It does not solve your problem, but many users of kilim are eagerly
awaiting java 7 support as java 6 is no longer receiving any oracle
updates come february.

If your changes include deleting lib/asm-all-2.2.3.jar and the ability
to successfully call build.sh and then test.sh with asm 4.x that is a
great outcome.

When I tried to use your code after changing build.sh to use asm-4.1 I
get index out of bounds errors on weaving?

Any ideas?

Ted Stockwell

unread,
Dec 14, 2012, 8:46:32 PM12/14/12
to kilimt...@googlegroups.com

----- Original Message -----
> From: Jason Pell <ja...@pellcorp.com>
> To: kilimt...@googlegroups.com
>
> Any chance you could provide your asm 4 compatible version of kilim
> itself?  I tried copying your com.googlecode.kilimbuilder.kilim from
> the branch before-javassist-refactoring.  But I cannot get that to
> compile using build.sh?


Oh sorry, I didn't think anybody would actually to check it out and try use it :-).
Right now I only build and run it it in Eclipse, and I build everything as Osgi plugins, so its a pretty non-standard build.
I haven't updated the build.sh to properly build it, but I will, that should be easy. 

> It does not solve your problem, but many users of kilim are eagerly

> awaiting java 7 support as java 6 is no longer receiving any oracle
> updates come february.

But like I said, even though it uses ASM4, this new build isn't going to work in Java7 either because it still doesn't produce the correct stack maps for methods.
I have merely made kilim work with ASM4, but I can't get ASM4 to generate code with proper stack frames.

So its a FAIL.


>
> When I tried to use your code after changing build.sh to use asm-4.1 I
> get index out of bounds errors on weaving?
>
> Any ideas?

Yes, the current checked in version configures ASM to automatically generate stack maps and that causes those OutOfBounds errors.
I ran the kilim unit tests BEFORE configuring kilim to generate stack maps.
Then I made the changes to enable the automatic stack map generation and thats when things fell apart.

I've investigated the cause of those errors and determined that I can't fix them without a major investment in learning ASM internals, and I don't wanna go there.
I will check in the changes to turn that off stack maps (change all calls to ClassWriter(ClassWriter.FRAMES) to ClassWriter(0)) and that will make those errors go away, but ASM4 isnt of much value when used that way.

Reply all
Reply to author
Forward
0 new messages