public class JarUtil extends Object
Constructor and Description |
---|
JarUtil() |
Modifier and Type | Method and Description |
---|---|
static int |
extract(File dest,
Map<String,String> nativeLibMap,
JarFile jarFile,
boolean extractNativeLibraries,
boolean extractClassFiles,
boolean extractOtherFiles)
Extract the files of the given jar file.
|
static String |
getJarBasename(String clazzBinName,
ClassLoader cl)
The Class's
com.jogamp.common.GlueGenVersion
URL jar:sub_protocol:/some/path/gluegen-rt.jar!/com/jogamp/common/GlueGenVersion.class
Jar basename gluegen-rt.jar will be returned. |
static String |
getJarBasename(URL classJarURL)
The Class's Jar URL
jar:sub_protocol:/some/path/gluegen-rt.jar!/com/jogamp/common/GlueGenVersion.class
Jar basename gluegen-rt.jar will be returned. |
static URL |
getJarEntryURL(URL jarFileURL,
String jarEntry) |
static JarFile |
getJarFile(String clazzBinName,
ClassLoader cl) |
static JarFile |
getJarFile(URL jarFileUrl) |
static URL |
getJarFileURL(String clazzBinName,
ClassLoader cl)
The Class's
"com.jogamp.common.GlueGenVersion"
URL jar:sub_protocol:/some/path/gluegen-rt.jar!/com/jogamp/common/GlueGenVersion.class"
Jar file URL jar:sub_protocol:/some/path/gluegen-rt.jar!/ will be returned. |
static URL |
getJarFileURL(URL jarSubUrl) |
static URL |
getJarFileURL(URL baseUrl,
String jarFileName) |
static URL |
getJarSubURL(String clazzBinName,
ClassLoader cl)
The Class's
com.jogamp.common.GlueGenVersion
URL jar:sub_protocol:/some/path/gluegen-rt.jar!/com/jogamp/common/GlueGenVersion.class
Jar file's sub URL sub_protocol:/some/path/gluegen-rt.jar will be returned. |
static URL |
getJarSubURL(URL classJarURL)
The Class's Jar URL
jar:sub_protocol:/some/path/gluegen-rt.jar!/com/jogamp/common/GlueGenVersion.class
Jar file's sub URL sub_protocol:/some/path/gluegen-rt.jar will be returned. |
static URL |
getJarURL(String clazzBinName,
ClassLoader cl)
The Class's
"com.jogamp.common.GlueGenVersion"
URL jar:sub_protocol:/some/path/gluegen-rt.jar!/com/jogamp/common/GlueGenVersion.class"
will be returned. |
static Map<String,String> |
getNativeLibNames(JarFile jarFile)
Return a map from native-lib-base-name to entry-name.
|
static URL |
getURLDirname(URL aURL)
The URL's
protocol:/some/path/gluegen-rt.jar
parent dirname URL protocol:/some/path/ will be returned. |
static boolean |
hasJarURL(String clazzBinName,
ClassLoader cl)
Returns
true if the Class's "com.jogamp.common.GlueGenVersion"
is loaded from a JarFile and hence has a Jar URL like
URL jar:sub_protocol:/some/path/gluegen-rt.jar!/com/jogamp/common/GlueGenVersion.class" . |
static void |
validateCertificates(Certificate[] rootCerts,
JarFile jarFile)
Validate the certificates for each native Lib in the jar file.
|
public static boolean hasJarURL(String clazzBinName, ClassLoader cl)
true
if the Class's "com.jogamp.common.GlueGenVersion"
is loaded from a JarFile and hence has a Jar URL like
URL jar:sub_protocol:/some/path/gluegen-rt.jar!/com/jogamp/common/GlueGenVersion.class"
.
sub_protocol may be "file", "http", etc..
clazzBinName
- "com.jogamp.common.GlueGenVersion"cl
- #getJarURL(String, ClassLoader)}
public static URL getJarURL(String clazzBinName, ClassLoader cl) throws IllegalArgumentException, IOException
"com.jogamp.common.GlueGenVersion"
URL jar:sub_protocol:/some/path/gluegen-rt.jar!/com/jogamp/common/GlueGenVersion.class"
will be returned.
sub_protocol may be "file", "http", etc..
clazzBinName
- "com.jogamp.common.GlueGenVersion"cl
- ClassLoader to locate the JarFileIllegalArgumentException
- if the URL doesn't match the expected formatting or null argumentsIOException
- if the class's Jar file could not been found by the ClassLoaderIOUtil#getClassURL(String, ClassLoader)}
public static String getJarBasename(URL classJarURL) throws IllegalArgumentException
jar:sub_protocol:/some/path/gluegen-rt.jar!/com/jogamp/common/GlueGenVersion.class
Jar basename gluegen-rt.jar
will be returned.
sub_protocol may be "file", "http", etc..
classJarURL
- as retrieved w/ getJarURL("com.jogamp.common.GlueGenVersion", cl)
,
i.e. jar:sub_protocol:/some/path/gluegen-rt.jar!/com/jogamp/common/GlueGenVersion.class
gluegen-rt.jar
IllegalArgumentException
- if the URL doesn't match the expected formatting or is nullIOUtil#getClassURL(String, ClassLoader)}
public static String getJarBasename(String clazzBinName, ClassLoader cl) throws IllegalArgumentException, IOException
com.jogamp.common.GlueGenVersion
URL jar:sub_protocol:/some/path/gluegen-rt.jar!/com/jogamp/common/GlueGenVersion.class
Jar basename gluegen-rt.jar
will be returned.
sub_protocol may be "file", "http", etc..
clazzBinName
- com.jogamp.common.GlueGenVersion
cl
- gluegen-rt.jar
IllegalArgumentException
- if the URL doesn't match the expected formattingIOException
- if the class's Jar file could not been found by the ClassLoaderIOUtil#getClassURL(String, ClassLoader)}
public static URL getJarSubURL(URL classJarURL) throws IllegalArgumentException, MalformedURLException
jar:sub_protocol:/some/path/gluegen-rt.jar!/com/jogamp/common/GlueGenVersion.class
Jar file's sub URL sub_protocol:/some/path/gluegen-rt.jar
will be returned.
sub_protocol may be "file", "http", etc..
classJarURL
- as retrieved w/ getJarURL("com.jogamp.common.GlueGenVersion", cl)
,
i.e. jar:sub_protocol:/some/path/gluegen-rt.jar!/com/jogamp/common/GlueGenVersion.class
cl
- sub_protocol:/some/path/gluegen-rt.jar
IllegalArgumentException
- if the URL doesn't match the expected formatting or is nullMalformedURLException
- if the computed URL specifies an unknown protocolIOUtil#getClassURL(String, ClassLoader)}
public static URL getJarSubURL(String clazzBinName, ClassLoader cl) throws IllegalArgumentException, IOException
com.jogamp.common.GlueGenVersion
URL jar:sub_protocol:/some/path/gluegen-rt.jar!/com/jogamp/common/GlueGenVersion.class
Jar file's sub URL sub_protocol:/some/path/gluegen-rt.jar
will be returned.
sub_protocol may be "file", "http", etc..
clazzBinName
- com.jogamp.common.GlueGenVersion
cl
- sub_protocol:/some/path/gluegen-rt.jar
IllegalArgumentException
- if the URL doesn't match the expected formattingIOException
- if the class's Jar file could not been found by the ClassLoaderIOUtil#getClassURL(String, ClassLoader)}
public static URL getJarFileURL(String clazzBinName, ClassLoader cl) throws IllegalArgumentException, IOException
"com.jogamp.common.GlueGenVersion"
URL jar:sub_protocol:/some/path/gluegen-rt.jar!/com/jogamp/common/GlueGenVersion.class"
Jar file URL jar:sub_protocol:/some/path/gluegen-rt.jar!/
will be returned.
sub_protocol may be "file", "http", etc..
clazzBinName
- "com.jogamp.common.GlueGenVersion"cl
- IllegalArgumentException
- if the URL doesn't match the expected formatting or null argumentsIOException
- if the class's Jar file could not been found by the ClassLoaderIOUtil#getClassURL(String, ClassLoader)}
public static URL getURLDirname(URL aURL) throws IllegalArgumentException, MalformedURLException
protocol:/some/path/gluegen-rt.jar
parent dirname URL protocol:/some/path/
will be returned.
protocol may be "file", "http", etc..
aURL
- "protocol:/some/path/gluegen-rt.jar"IllegalArgumentException
- if the URL doesn't match the expected formatting, or is nullMalformedURLException
public static URL getJarFileURL(URL baseUrl, String jarFileName) throws IOException, MalformedURLException
baseUrl
- file:/some/path/jarFileName
- gluegen-rt.jarMalformedURLException
IllegalArgumentException
- null argumentsIOException
public static URL getJarFileURL(URL jarSubUrl) throws MalformedURLException, IllegalArgumentException
jarSubUrl
- file:/some/path/gluegen-rt.jarMalformedURLException
IllegalArgumentException
- null argumentspublic static URL getJarEntryURL(URL jarFileURL, String jarEntry) throws MalformedURLException, IllegalArgumentException
jarFileURL
- jar:file:/some/path/gluegen-rt.jar!/jarEntry
- com/jogamp/common/GlueGenVersion.classMalformedURLException
IllegalArgumentException
- null argumentspublic static JarFile getJarFile(String clazzBinName, ClassLoader cl) throws IOException, IllegalArgumentException
clazzBinName
- com.jogamp.common.util.cache.TempJarCachecl
- domainIOException
- if the class's Jar file could not been found by the ClassLoaderIllegalArgumentException
- null arguments#getJarFileURL(String, ClassLoader)}
public static JarFile getJarFile(URL jarFileUrl) throws IOException, IllegalArgumentException
jarFileURL
- jar:file:/some/path/gluegen-rt.jar!/IllegalArgumentException
- null argumentsIOException
- if the Jar file could not been foundpublic static Map<String,String> getNativeLibNames(JarFile jarFile)
public static final int extract(File dest, Map<String,String> nativeLibMap, JarFile jarFile, boolean extractNativeLibraries, boolean extractClassFiles, boolean extractOtherFiles) throws IOException
If extractNativeLibraries
is true,
native libraries are added to the given nativeLibMap
with the base name to temp file location.
A file is identified as a native library,
if it's name complies with the running platform's native library naming scheme.
Root entries are favored over non root entries in case of naming collisions.
Example on a Unix like machine:
mylib.jar!/sub1/libsour.so -> sour (mapped, unique name) mylib.jar!/sub1/libsweet.so (dropped, root entry favored) mylib.jar!/libsweet.so -> sweet (mapped, root entry favored) mylib.jar!/sweet.dll -> (dropped, not a unix library name)
In order to be compatible with Java Web Start, we need
to extract all root entries from the jar file.
In this case, set all flags to true extractNativeLibraries
.
extractClassFiles
, extractOtherFiles
.
dest
- nativeLibMap
- jarFile
- deepDirectoryTraversal
- extractNativeLibraries
- extractClassFiles
- extractOtherFiles
- IOException
public static final void validateCertificates(Certificate[] rootCerts, JarFile jarFile) throws IOException, SecurityException
Certificate[] rootCerts = Something.class.getProtectionDomain(). getCodeSource().getCertificates();
IOException
SecurityException