user1156919
user1156919

Reputation: 21

Javassist, bytecode manipulation

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

Answers (1)

Ernest Friedman-Hill
Ernest Friedman-Hill

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

Related Questions