C ++: system call back ()

I need help with an external program call from C ++ code.

I need to repeatedly call javap.exe(from the JDK package) from my program (possibly more than 100), but the call system("javap.exe some_parameters")is extremely slow. It works so well for one set of parameters, but repeated calls are system()unacceptable. I think that only because of the costs of accessing the hard drive and running the application (but I'm not sure).

What can I do to improve performance? Can I "save javap.exeto RAM" and call it "directly". Or maybe someone knows how I can get a description of the description and methods of a java class without javap.exe?

+3
source share
2 answers

Java VM , , , . , javap Java-. Java, , javap, , . (... , ? Javap , ...)

+6

system() , , , - . , (), .

, fork() exec*(), , . :

void replace_system(const char *command)
{
    pid_t child = fork();
    if (child < 0) {
        perror("fork:");
        return;
    }

    if (child) {
        /* this is the parent, wait for the child to finish */
        while (waitpid(child, &status, options) <= 0);
        return;
    }

    /* this is the new process */
    exec*(...);
    perror("failed to start the child");
    exit(-1);
}

exec *, , . , , . exec *, ( , ).

, - , . , ; stdout, , , . popen(), .

-1

All Articles