@Override public boolean loadLibrary(String libname, boolean ignoreError, ClassLoader cl) { try { for (Entry<String, String> nativeEntry : platformNativeIndex.entrySet()) { if (nativeEntry.getKey().contains(libname)) { if (log.isDebugEnabled()) { log.debug( "Loading mapped entry: [{}] [{}] [{}]", libname, nativeEntry.getKey(), nativeEntry.getValue()); } File nativeLibCopy = extractJarEntry( nativeEntry.getValue(), nativeEntry.getKey(), System.getProperty(JAVA_TMP_DIR), String.format("%s.jni", libname)); System.load(nativeLibCopy.getAbsolutePath()); return true; } } } catch (Exception e) { log.error("Unable to load native library [{}] - {}", libname, e); } if (log.isDebugEnabled()) { log.debug("No mapped library match for [{}]", libname); } return false; }
public GLBootstrap() throws Exception { System.setProperty("jogamp.gluegen.UseTempJarCache", "false"); log.info( "Initializing native JOGL jar dependencies for platform [{}]. Temp jar cache disabled.", PlatformPropsImpl.os_and_arch); String nativeJarName = String.format("%s-%s", NATIVES, PlatformPropsImpl.os_and_arch); String[] classpathEntries = System.getProperty(JAVA_CLASSPATH).split(System.getProperty(JAVA_SEPARATOR)); for (String jarPath : classpathEntries) { if (jarPath.contains(nativeJarName)) { if (log.isDebugEnabled()) { log.debug("Applicable platform jar: [{}]", jarPath); } JarFile jf = new JarFile(jarPath); try { Enumeration<JarEntry> jarEntries = jf.entries(); while (jarEntries.hasMoreElements()) { JarEntry je = jarEntries.nextElement(); if (!je.isDirectory() && !je.getName().contains(JAVA_META_INF)) { if (log.isDebugEnabled()) { log.debug("Mapping jar entry [{}] -> [{}]", je.getName(), jarPath); } if (log.isDebugEnabled() && platformNativeIndex.containsKey(je.getName())) { log.debug("Duplicate jar entry: [{}]", je.getName()); log.debug("Mapped at: [{}]", platformNativeIndex.get(je.getName())); log.debug("Also at: [{}]", jarPath); } platformNativeIndex.put(je.getName(), jarPath); } } } finally { closeJar(jf); } } } }
private String readVersionFromManifest(Class<?> api) throws IOException { String className = api.getSimpleName() + ".class"; URL resource = api.getResource(className); log.trace("get resource for {} -> {} -> {}", new Object[] {className, pathOf(api), resource}); if (resource == null) return null; String version = null; String classPath = resource.toString(); if (classPath.startsWith("jar:")) version = version(classPath.substring(0, classPath.lastIndexOf("!") + 1)); if (version == null && classPath.endsWith(pathOf(api) + ".class")) version = version(classPath.substring(0, classPath.length() - pathOf(api).length() - 7)); if (version == null && classPath.contains("/WEB-INF/")) version = version(classPath.substring(0, classPath.lastIndexOf("/WEB-INF/"))); log.debug("version {} for {} from {}.", version, api, classPath); return version; }