Search code examples
javajavaceclipse-jdt

com.sun.tools.javac.jvm.ClassWriter equivalent in JDT compiler


What the class responsible for writing class file for the JDTCompiler? The class(es) equivalent to javac's com.sun.tools.javac.jvm.ClassWriter?

Thank you


Solution

  • To close the loop also here let me quote my answer from the JDT Forum:

    I don't know about com.sun.tools.javac.jvm.ClassWriter, but here are some pointers to class file writing in JDT:

    Main protocol is org.eclipse.jdt.internal.compiler.ICompilerRequestor: called when compilation is done for one type. There are several implementations depending on the compilation mode, e.g., during batch compilation org.eclipse.jdt.internal.compiler.batch.BatchCompilerRequestor is used which calls back into org.eclipse.jdt.internal.compiler.batch.Main.outputClassFiles(CompilationResult). Within the IDE other requestors are used, just look at the type hierarchy of ICompilerRequestor.

    Note that the above assumes, we already have the bytes, only need to write them to file. If instead you are looking for the class that assembles the byte array, have a look at org.eclipse.jdt.internal.compiler.codegen.CodeStream.