code: protected String ensureCanonicalPath(String path) {
          final String basePath;
          String wildCards = null;
          final String file = path.replace('\\', '/');
          if (file.contains("*") || file.contains("?")) {
  
              int pos = getLastFileSeparator(file);
              if (pos < 0) {
                  return file;
              }
              pos += 1;
              basePath = file.substring(0, pos);
              wildCards = file.substring(pos);
          } else {
              basePath = file;
          }
  
          File f = new File(basePath);
          try {
              f = f.getCanonicalFile();
              if (wildCards != null) {
                  f = new File(f, wildCards);
              }
          } catch (IOException ex) {
              LOGGER.warn("Invalid path '{}' was provided.", path);
              LOGGER.debug("Invalid path provided", ex);
          }
          return f.getAbsolutePath().replace('\\', '/');
      }
docs: Takes a path and resolves it to be a canonical &amp; absolute path. The
  caveats are that this method will take an Ant style file selector path
  (../someDir/**\/*.jar) and convert it to an absolute/canonical path (at
  least to the left of the first * or ?).
  
  @param path the path to canonicalize
  @return the canonical path