Edit: Updated version of the script here.
Here’s a nifty little Groovy script to write out the ASM code to generate a given Java class.
#!/usr/bin/env groovy import org.objectweb.asm.util.ASMifierClassVisitor as V import org.objectweb.asm.ClassReader as R @Grab(group='asm', module='asm-all', version='[3.3,)') private class JustHereForGrab {} new R(new File(this.args[0]).newInputStream()).accept(new V(new PrintWriter(System.out)), 0)
You will have to update your ~/.groovy/grapeConfig.xml file to point to a repo with ASM in it. I’ve posted my grapeConfig.xml at http://repo.smokejumperit.com/grapeConfig.xml.
Comments
- November 5, 2010, Guillaume Laforge wrote: You could use a @GrabResolver, no? Why modify grapeConfig?
- November 5, 2010, Robert Fischer wrote: 1) I didn't know about GrabResolver 2) Even if I did, it keeps configuration all in one place
This post was by Robert Fischer, written on November 5, 2010.
Comment on this post: http://enfranchisedmind.com/blog/posts/groovy-shell-script-asm-to-java/#respond
Public Permalink: http://enfranchisedmind.com/blog/posts/groovy-shell-script-asm-to-java/

This article was a post on the EnfranchisedMind blog. EnfranchisedMind Blog by Robert Fischer, Brian Hurt, and Other Authors is licensed under a Creative Commons Attribution-Share Alike 3.0 United States License.
