Search code examples
javac++javap

In java we can explore a java class, methods by using javap disassembeler. how to do the same in c++?


I'm new to this community so, if I'm violating any t&c of our community by asking this question in wrong section, then I'm sorry. I've been searching answers for the above question for quite a while but none of the results were relevant.

  • I just wanna know that in java we were able to explore a java class methods by using javap, how to do the same in c++ ???
  • Suppose, I wanted to see all the methods of String class in java, I would have used javap by which all its methods, their return type, their number of arguments & their data type etc, are displayed.
  • How to do the same in c++ ???
  • Also is there a command line way to explore what all packages & classes are there in a particular package in java language ???
  • Suppose java** java.awt.* or any such method to know all the packages & classes inside a particular package.

Solution

  • I just wanna know that in java we were able to explore a java class methods by using javap, how to do the same in c++ ???

    You can't really get anything useful. For C++ assemblies, the best you can get is mangled names. Java stores all method signatures of a class in the .class file, so they can be referenced and referred to. But C++ compiles to assembly, and that works with memory addresses and stacks and other lower level stuff.

    Suppose, I wanted to see all the methods of String class in java, I would have used javap by which all its methods, their return type, their number of arguments & their data type etc, are displayed. How to do the same in c++ ???

    Or you could read the documentation for the library. You can do the same with C++ libraries: read the documentation. That's what it's for. Or read through the headers for the library, as every C++ library has those.

    Also is there a command line way to explore what all packages & classes are there in a particular package in java language ???

    For Java, you mentioned javap earlier. There you go :)

    For C++, this really depends on the compiler toolchain you're using. For example, Microsoft Visual C++ has the dumpbin CLI tool, which can provide a great wealth of information. But again, you can only get mangled names, which may or may not reflect the structure of namespaces and classes that the program uses.

    Suppose java** java.awt.* or any such method to know all the packages & classes inside a particular package.

    ...

    Most of this information (methods, classes, namespaces (or packages in Java)) can be learnt about from whatever documentation there is for the library in question. If you want source code, then you either can get it for free (for open-source projects), buy it from the library vendor (for closed-source projects), or just make do with the documentation.