1 Reply Latest reply on Feb 21, 2010 10:51 PM by megalodon

    Javassist and compile-time code instrumentation

    ngounou

      Is it possible to use javassist to insrument code at compile-time with jdk6 annotation processing?

      My need is that I have to use a thread synchronisation api in my business code, and to do that I would like to use annotation

      (in my business code) to indicate where to add specific behaviour defined in my api (annotation driven development).

      It is possible to do that at runtime with java agent or runtime reflection but at compile-time, it is faster.

        • 1. Re: Javassist and compile-time code instrumentation

          Just my 2 cents:

          As far as I know, Javassist has methods to read only compiled class files. Its not an optimal solution but if you can comile your code and later on specify the parts for annotation, you can read the class files, process them using javassist and re write them back. That way there'd be no additional steps during runtime.