Reputation: 219
Anybody knows how to load .class content to humman-readable format in memory? I'm should write program which will manipulate with info from this file
Upvotes: 0
Views: 230
Reputation: 62874
You can dissasemble the .class file by using the javap tool.
javap MyClass
Suppose we have a simple class :
public class Test {
public void test() {...}
}
Invoking javap Test
from the command-line will print:
public class Test {
public Test();
public void test();
}
Then you can store this info in a data structure and if you want to dynamically construct object/invoke methods, you can use Reflection.
Upvotes: 1
Reputation: 4716
If you are simply looking for the declaration of methods names and arguments, fields, extended types, etc. then you should use Java reflection and introspection features.
If you want to access the byte code of compiled methods, then have a look at the asm or Apache bcel libraries.
Upvotes: 2