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 URL |
getJarEntryURL(URL jarFileURL,
String jarEntry) |
static JarFile |
getJarFile(String clazzBinName,
ClassLoader cl) |
static JarFile |
getJarFile(URL jarFileUrl,
ClassLoader cl) |
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 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 void |
validateCertificates(Certificate[] rootCerts,
JarFile jarFile)
Validate the certificates for each native Lib in the jar file.
|
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
- IllegalArgumentException
- if the URL doesn't match the expected formattingIOException
IOUtil#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
- IllegalArgumentException
- if the URL doesn't match the expected formattingIOException
IOUtil#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 formattingIOException
IOUtil#getClassURL(String, ClassLoader)}
public static URL getURLDirname(URL aURL) throws IllegalArgumentException, IOException
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 formattingIOException
public static URL getJarFileURL(URL baseUrl, String jarFileName) throws IOException
baseUrl
- file:/some/path/jarFileName
- gluegen-rt.jarIOException
public static URL getJarFileURL(URL jarSubUrl) throws IOException
jarSubUrl
- file:/some/path/gluegen-rt.jarIOException
public static URL getJarEntryURL(URL jarFileURL, String jarEntry) throws IOException
jarFileURL
- jar:file:/some/path/gluegen-rt.jar!/jarEntry
- com/jogamp/common/GlueGenVersion.classIOException
public static JarFile getJarFile(String clazzBinName, ClassLoader cl) throws IOException
clazzBinName
- com.jogamp.common.util.cache.TempJarCachecl
- domainIOException
#getJarFileURL(String, ClassLoader)}
public static JarFile getJarFile(URL jarFileUrl, ClassLoader cl) throws IOException
jarFileURL
- jar:file:/some/path/gluegen-rt.jar!/cl
- domainIOException
public 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