Source Files vs. Class Files

Apache NetBeans Wiki Index

Note: These pages are being reviewed.

Parsing a file from the source code is time and memory consuming task, compared to simple loading of a class file. So, it is important for all the authors of a code in the IDE to know if their code requires parsing a source file or if it is sufficient to use data from a class file.

Another significant difference between these two approaches is that the Trees are available only if the file has been compiled from the source file. The Elements load from a class file are supposed to be "identical" to elements got by parsing the corresponding source file.

The rule of thumb here is that if you need only classes, their methods, constructors, fields and inner classes and their annotations, loading the data from the class file is sufficient for you. If you need access of the method content (statements), etc., you need to get data by parsing the source code.