premain
Premain is a special entry point used by Java agents in the Java Instrumentation API. When a Java agent is packaged as a JAR and started with the -javaagent option, the JVM loads the agent before the application code and invokes the agent's premain method. This early execution allows the agent to instrument bytecode during class loading or to install transformers that modify classes as they are loaded.
Required manifest and signatures: The agent JAR must declare the Premain-Class attribute in its manifest, pointing
Instrumentation and usage: The premain method receives an Instrumentation instance, which can be used to register
Relation to agentmain: premain runs at startup, before the application’s main method. In contrast, agentmain is