code: Map<String, String> getLibraryVersion(Class<?> classLoadedWithURLClassLoader, Set<String> libraryNames) {
          ClassLoader cl = classLoadedWithURLClassLoader.getClassLoader();
          Map<String, String> libraryVersionMapping = new HashMap<String, String>();
  
          if (cl instanceof URLClassLoader) {
              @SuppressWarnings("resource")
              URLClassLoader uCl = (URLClassLoader) cl;
              URL urls[] = uCl.getURLs();
  
              for (URL url : urls) {
                  String fullNameWithVersion = url.toString().substring(url.toString().lastIndexOf('/'));
                  if (fullNameWithVersion.length() > 4) { // all entries we attempt to parse must end in ".jar"
                      String nameWithVersion = fullNameWithVersion.substring(1, fullNameWithVersion.length() - 4);
                      int idx = findVersionStartIndex(nameWithVersion);
                      if (idx > 0) {
                          String name = nameWithVersion.substring(0, idx - 1);
                          if (libraryNames.contains(name)) {
                              libraryVersionMapping.put(name, nameWithVersion.substring(idx));
                          }
                      }
                  }
              }
          }
  
          return libraryVersionMapping;
      }
docs: Get library version by iterating through the classloader jar list and obtain the name from the jar filename.
  This will not open the library jar files.
  <p>
  This function assumes the conventional jar naming format and relies on the dash character to separate the
  name of the jar from the version. For example, foo-bar-baz-1.0.12-CANDIDATE.
  
  @param libraryNames unique list of library names, i.e. "dyno-core"
  @param classLoadedWithURLClassLoader For this to work, must have a URL based classloader
  This has been tested to be the case in Tomcat (WebAppClassLoader) and basic J2SE classloader
  @return the version of the library (everything between library name, dash, and .jar)