Re: ASM for Reflection
Eugene Kuleshov <[email protected]>
| Newsgroups | gmane.comp.java.objectweb.asm |
|---|---|
| Message-ID | <CADFjdoV6LEAEf7M0O-eCtoC1301rSVurgSPvK7Ca-79WL7h9MQ@mail.gmail.com> |
You can look at AspectWerkz's ClassInfo implementation regards, Eugene On Sun, Jul 10, 2011 at 3:35 PM, theUser BL <[email protected]> wrote: > > Hi! > > Is it possibly after all that ASM can be used for Reflection without Java Reflection? > > I have already written it on the BCEL Mailinglist: > http://www.mail-archive.com/[email protected]/msg06723.html > http://www.mail-archive.com/[email protected]/msg06725.html > > I want to see Methods and Fileds of an Class. But it can possible, that the cass isn't in my classpath. Or that I want to use for compilation a different version then that, what the compiler itself use. > Is that with ASM possible? > > For showing Methods with ASM I have currently found this one in the web: > http://osdir.com/ml/java.objectweb.asm/2008-04/msg00048.html > > I have changed it a little bit to this one: > > import org.objectweb.asm.*; > import org.objectweb.asm.tree.*; > import java.util.*; > import java.io.*; > > public class ShowIt { > > public static void main(String[] args) { > try { > ClassNode cn = new ClassNode(); > ClassReader cr = new ClassReader("java.util.HashMap"); > cr.accept(cn, 0); > System.out.println(cn.access); > System.out.println(cn.name); > System.out.println(cn.outerClass); > System.out.println(cn.outerMethod); > System.out.println(cn.outerMethodDesc); > System.out.println(cn.signature); > System.out.println(cn.sourceDebug); > System.out.println(cn.sourceFile); > System.out.println(cn.superName); > System.out.println(cn.version); > > System.out.println("--------------"); > > for (Iterator i = cn.methods.iterator(); i.hasNext(); ) { > MethodNode mn = (MethodNode) i.next(); > System.out.println(mn.name + " - " + mn.desc); > } > } catch (IOException e) { > System.out.println(e); > } > } > > } > > > The output is very different to that of Javap. So I have to write myself methods, which gives back how many arguments a reflected method have and so on. > But if I doing it, then the compiler will be slower, too, and the performance advantage of ASM to BCEL isn't no longer so great. > > And as I mentioned, I am not sure, if it then do not using Java Reflaction as base. > > Greatings > theuserbl > > > > -- > You receive this message as a subscriber of the [email protected] mailing list. > To unsubscribe: mailto:[email protected] > For general help: mailto:[email protected]?subject=help > OW2 mailing lists service home page: http://www.ow2.org/wws > >
message-footer.txt
(text/plain, 238 B)
-- You receive this message as a subscriber of the [email protected] mailing list. To unsubscribe: mailto:[email protected] For general help: mailto:[email protected]?subject=help OW2 mailing lists service home page: http://www.ow2.org/wws