Gets the current VersionMonitor base on a Class that will load it's manifest file.
@param clazz Class that will load the manifest MF file
@return A {@link VersionMonitor} pojo with the information.
@throws IOException If Unable to read the Manifest file.
483159
public static VersionMonitor getVersion(Class clazz) throws IOException {
        Manifest manifest = new Manifest();
        manifest.read(clazz.getResourceAsStream(MANIFEST_PATH));
        return getVersion(manifest);
    }
982846
@SuppressWarnings("unchecked")
  private static Method getMethodOrDie(
      final Class clazz, final String name, final Class... params) {
    try {
      return clazz.getMethod(name, params);
    } catch (NoSuchMethodException e) {
      throw new RuntimeException(
        "Generated message class \"" + clazz.getName() +
        "\" missing method \"" + name + "\".", e);
    }
  }
891637
public static synchronized void setLoadFromJar(Class<?> clazz)
    {
        loader = Optional.ofNullable(clazz);
        if (loader.isPresent())
        {
            setSeparator(Constant.SLASH);
        }
        else
        {
            setSeparator(File.separator);
        }
    }
1364896
public static ClassLoader getClassLoader(Class clazz){
        ClassLoader classLoader = clazz.getClassLoader();
        return classLoader==null ? ClassLoader.getSystemClassLoader() : classLoader;
    }
646989
private static String loadVersion(ClassLoader classLoader) throws IOException {
    try {
      Enumeration<URL> resources = classLoader.getResources("META-INF/MANIFEST.MF");

      while (resources.hasMoreElements()) {
        final URL url = resources.nextElement();
        final Manifest manifest = new Manifest(url.openStream());
        final Attributes mainAttributes = manifest.getMainAttributes();
        final String value = mainAttributes.getValue(IMPL_VERSION);

        if (value != null) {
          return value;
        }
      }

    } catch (IOException e) {
      LOG.error("Failed to read manifest", e);
      throw new IOException("Failed to find manifest", e);
    }

    return null;
  }
1306904
public static org.modeshape.jcr.api.Logger getLogger(Class<?> clazz) {
        return new ExtensionLogger(Logger.getLogger(clazz));
    }
970258
public static @CheckForNull <T extends Saveable> T load(@Nonnull Class<T> clazz) throws IOException {
        XmlFile file = getConfigFile(clazz);
        return file.exists() ? clazz.cast(file.read()) : null;
    }
1306189
public static String getVersion(Class<?> aClass, String groupId, String artifactId) {
        String version = null;
        // lets try find the maven property - as the Java API rarely works :)
        InputStream is = null;
        String fileName = "/META-INF/maven/" +
                groupId + "/" + artifactId +
                "/pom.properties";
        // try to load from maven properties first
        try {
            Properties p = new Properties();
            is = aClass.getResourceAsStream(fileName);
            if (is != null) {
                p.load(is);
                version = p.getProperty("version", "");
            }
        } catch (Exception e) {
            // ignore
        } finally {
            if (is != null) {
                IOHelper.close(is, fileName, LOG);
            }
        }
        if (version == null) {
            Package aPackage = aClass.getPackage();
            if (aPackage != null) {
                version = aPackage.getImplementationVersion();
                if (Strings.isBlank(version)) {
                    version = aPackage.getSpecificationVersion();
                }
            }
        }
        if (version == null) {
            Enumeration<URL> resources = null;
            try {
                resources = aClass.getClassLoader().getResources("META-INF/MANIFEST.MF");
            } catch (IOException e) {
                // ignore
            }
            if (resources != null) {
                String expectedBundleName = groupId + "." + artifactId;
                while (resources.hasMoreElements()) {
                    try {
                        Manifest manifest = new Manifest(resources.nextElement().openStream());
                        Attributes attributes = manifest.getMainAttributes();
                        String bundleName = attributes.getValue("Bundle-SymbolicName");
                        if (Objects.equals(expectedBundleName, bundleName)) {
                            version = attributes.getValue("Implementation-Version");
                            if (Strings.isNotBlank(version)) break;
                        }
                    } catch (IOException e) {
                        // ignore
                    }
                }
            }
        }
        return version;
    }
211729
public static Map<String, Method> getClassReadMethods(Class<?> clazz) {
		Map<String, Method> readMethods = classReadMethods.get(clazz);
		if (readMethods == null) {
			cacheReadWriteMethodsAndBoxField(clazz);
			return classReadMethods.get(clazz);
		} else
			return readMethods;
	}
457915
JarFile getBootProxyJarIfCurrent() {
        File dataFile = bundleContext.getDataFile("boot-proxy.jar");
        if (!dataFile.exists()) {
            return null;
        }

        JarFile jarFile = null;
        try {
            jarFile = new JarFile(dataFile);
            Manifest manifest = jarFile.getManifest();
            Attributes attrs = manifest.getMainAttributes();
            String jarVersion = attrs.getValue(MONITORING_VERSION_MANIFEST_HEADER);
            if (!getCurrentVersion().equals(jarVersion)) {
                jarFile.close();
                jarFile = null;
            }
        } catch (Exception e) {
        }

        return jarFile;
    }
429625
protected String getVersion() {

    Manifest manifest = ManifestLoader.loadManifest(getClass());
    String versionNumber = null;
    if (manifest != null) {
      versionNumber = ManifestLoader.getValue(manifest, Attributes.Name.IMPLEMENTATION_VERSION);
      if (versionNumber == null) {
        versionNumber = ManifestLoader.getValue(manifest, Attributes.Name.SPECIFICATION_VERSION);
      }
    }
    if (versionNumber == null) {
      versionNumber = SNAPSHOT;
    }
    return versionNumber;
  }
379967
public static String getVersion() {
    String version = "unknown";
    final URLClassLoader cl = (URLClassLoader)cclass.getClassLoader();
    try {
      final URL url = cl.findResource("META-INF/MANIFEST.MF");
      final Manifest manifest = new Manifest(url.openStream());
      for (Entry<Object,Object> entry : manifest.getMainAttributes().entrySet()) {
        final Attributes.Name key = (Attributes.Name)entry.getKey();
        if(Attributes.Name.IMPLEMENTATION_VERSION.equals(key)) {
          version = (String)entry.getValue();
        }
      }
    } catch (IOException e) {
      logger.error("Unable to determine the product version due to error", e);
    }
    return version;
  }
872438
protected Manifest getJarManifest(String assetId) throws IOException {
        ZipFile repoZip = null;
        Manifest manifest = new Manifest();
        try {
            repoZip = createZipFile();
            ZipEntry entry = createFromRelative(assetId);

            if (null == entry) {
                return null;
            }

            // Input stream to the inner zip
            ZipInputStream zis = new ZipInputStream(repoZip.getInputStream(entry));
            ZipEntry innerEntry = zis.getNextEntry();
            while (null != innerEntry) {
                if ("meta-inf/manifest.mf".equalsIgnoreCase(innerEntry.getName())) {
                    manifest.read(zis);
                    break;
                }
                innerEntry = zis.getNextEntry();
            }
        } finally {
            if (repoZip != null) {
                repoZip.close();
            }
        }
        return manifest;
    }
794025
@SuppressWarnings({"unchecked"})
    public synchronized ClassReflectionIndex getClassIndex(Class clazz) {
        try {
            ClassReflectionIndex index = classes.get(clazz);
            if (index == null) {
                final SecurityManager sm = System.getSecurityManager();
                if (sm == null) {
                    index = new ClassReflectionIndex(clazz, this);
                } else {
                    index = AccessController.doPrivileged((PrivilegedAction<ClassReflectionIndex>) () -> new ClassReflectionIndex(clazz, this));
                }
                classes.put(clazz, index);
            }
            return index;
        } catch (Throwable e) {
            throw ServerLogger.ROOT_LOGGER.errorGettingReflectiveInformation(clazz, clazz.getClassLoader(), e);
        }
    }
70400
public static ClassInfo classInfo(final ClassLoader cl, final Class<?> clasz) {
        return classInfo(cl, clasz.getName());
    }
251649
static Map<String, String> getVersionAttributes(URL url) throws IOException {
        Map<String, String> ret = new LinkedHashMap<>();
        try (InputStream inputStream = url.openStream()) {
            Manifest manifest = new Manifest(inputStream);
            Attributes attributes = manifest.getMainAttributes();
            for (String key : VERSION_ATTRIBUTES) {
                final String value = attributes.getValue(key);
                ret.put(key, value == null ? UNKNOWN_VALUE : value);
            }
        }
        return ret;
    }
1345801
public static Annotation[] jlClassGetDeclaredAnnotations(Class<?> clazz) {
		if (TypeRegistry.nothingReloaded) {
			return clazz.getDeclaredAnnotations();
		}
		ReloadableType rtype = getReloadableTypeIfHasBeenReloaded(clazz);
		if (rtype == null) {
			return clazz.getDeclaredAnnotations();
		}
		CurrentLiveVersion clv = rtype.getLiveVersion();
		return clv.getExecutorClass().getDeclaredAnnotations();
	}