Lesson 10: Add Java Source Code to the Model
As you learnt in previous lessons, we are always importing Java byte code files into the model. The byte code can be
located in loose byte code (.class
) files or in Java archive (.jar
, .zip
or
.jmod
) files.
In this lesson we are going to add Java source (.java
) files to the picture. Let's state a very
important point first: Java source files are absolutely optional. You do not need Java source files to generate proxy
types and they can only be used to enhance the quality of the generated proxy types. Java source files are useful for
two reasons:
- We can parse Java source files so we can generate proxy methods with properly named arguments rather than arg1, arg2, etc.
- We can parse Java source files so we can generate API documentation from the Javadoc comments in the source code.
Obviously, both are good reasons. The presence of source code can improve the usefulness of the generated code quite dramatically. Clearly though, the code generator cannot turn dirt into gold: if there are no (or useless) Javadoc comments in the source code and the method argument names are mostly misleading or meaningless, adding sources to the model will not have any positive impact.