I want to get methods inside a inner class.
This is what I have done. I have used JarFile class to get all entries inside a Jar. Now for each entry I have made inputstream and get all methods inside class by using ASM ClassReader class.
Now problem is there are inner classes inside a class. I can get list all inner class nodes, but inner class node doesn't contain information of methods inside it.
To get methods inside inner class there are two ways AFAIK. Make inputstream of inner class and pass it to ClassReader class or give the classname of inner class. In second option it is mandatory for inner class to be loaded. But my Jar is not located in my current classpath so I don't know how to load it.
So can someone please tell me is there a way to make inputstream of inner class or to load classes which are outside of current classpath.
You can load classes into a ClassReader
with just a byte[]
, so you just need to read the appropriate .class
file that represents the inner class (whose name you can obtain in visitInnerClass
events) and convert it to byte[]
(example).
As an alternative, you can read the bytes and then load it into a ClassLoader
, then the ClassReader
will be able to load it from there.