I wrote simple agent:
JNIEXPORT jint JNICALL Agent_OnLoad(JavaVM *vm, char *options, void *reserved) {
printf("Agent start");
}
And simple client:
public class Agent {
//java -agentpath:/path_to_lib Agent
public static void main(String[] args) throws InterruptedException {
System.out.println("Main");
}}
And if I run program I will see the output below:
Main
Agent start
Why method main invoke before Agent_OnLoad?