JavaHT SourceFilesVsClassFiles

Source Files vs. Class Files

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.

Not logged in. Log in, Register

By use of this website, you agree to the NetBeans Policies and Terms of Use. © 2012, Oracle Corporation and/or its affiliates. Sponsored by Oracle logo