There is no compiler plugin API. There are at least four things you can do:
1) Write your own compiler for a new language that translates your code into Java code and then passes it to the Java compiler (used for popularity, currently rarely used). Your “compiler” can simply just do simple text conversions, passing most of the code unchanged, so this is a smart way to do something if your changes are small and local.
2) Write your own compiler for a new language that emits Java.class files (now very often done: Groovy, Scala, Clojure all work this way.)
3) Use the "technical bytecode library" to compile .class files, parse them, modify them and either write them to disk or dynamically load and execute them (this is what AspectJ and most profilers are.)
4) Get the source for Sun ^ H ^ H ^ Native Java Java compiler - it is available in OpenJDK - and change it. This is hardcore and probably not the best plan.
Which way you choose, of course, depends on your skills and requirements.
Ernest friedman-hill
source share