Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

Java Java Annotations Writing Your Own Annotation Using Reflection on Our Annotation

Charles-Antoine Francisco
Charles-Antoine Francisco
27,426 Points

DocProcessor is not detecting missing params

So I tried using the DocProcessor.process method on the MathUtils class but it doesn't show messages for missing parameters, even tough there are some missing in the class.

public class DocProcessor {
  public static boolean process(Class clazz) {
    // ...
    // Does the number of items in param descriptions match
    // the number of actual parameters?
    int numMissing = getNumMissingParams(method, doc);
    if (numMissing > 0) {
      String message = "%n\t\t=> Missing %s parameter description(s)";
      System.out.printf(message, numMissing);
  private static int getNumMissingParams(Method method, Doc doc) {
    /* Check if the number of parameter descriptions in the annotation
       is less than the method's parameter count */
    int actualParamCount = method.getParameterCount();
    int annotatedParamCount = doc.params().length;
    // Calculate the number of missing parameter descriptions
    return actualParamCount - annotatedParamCount;