Reputation: 21
I am trying to find the class initializer in a java class file. I can find the method okay, but if main is not found in the class file, then I want it to find the class initializer and inject the code there.
How do I find a class's initializer using Javassist?
Upvotes: 2
Views: 386
Reputation: 81684
The class initializer blocks for a class are compiled into a method named <clinit>
. The angle brackets are part of the name, so it's inaccessible to Java code, but it's more or less a normal static method.
Upvotes: 5