private void visitJavaFileToPopulateCache(AccessibleObject methodOrConstructor) {

    InputStream is = null;
    try {
      is = javaFileFinder.openJavaFile(methodOrConstructor);
      if (is != null) {
        // visit .java file using our custom GenericVisitorAdapter
        CompilationUnit cu = JavaParser.parse(is);
        MethodParametersVisitor visitor = new MethodParametersVisitor();
        cu.accept(visitor, cache);
      }
    } catch (Exception e) {
      throw new ParameterNamesNotFoundException(
          "Error while trying to read parameter names from the Java file which contains the declaration of "
              + methodOrConstructor.toString(),
          e);
    } finally {
      if (is != null) {
        try {
          is.close();
        } catch (IOException e) {
          // should never happen
        }
      }
    }
  }
  /*
   * (non-Javadoc)
   *
   * @see com.thoughtworks.paranamer.Paranamer#lookupParameterNames(java.lang.reflect
   * .AccessibleObject, boolean)
   */
  public String[] lookupParameterNames(
      AccessibleObject methodOrConstructor, boolean throwExceptionIfMissing) {

    if (methodOrConstructor == null) {
      throw new NullPointerException("method or constructor to inspect cannot be null");
    }

    String[] result = cache.get(methodOrConstructor);

    if (result == null) {
      visitJavaFileToPopulateCache(methodOrConstructor);
      result = cache.get(methodOrConstructor);
    }

    if (result == null && throwExceptionIfMissing) {
      throw new ParameterNamesNotFoundException(
          "Cannot retrieve parameter names for method " + methodOrConstructor.toString());
    }

    return result;
  }