sun.misc.JarIndex Java Examples
The following examples show how to use
sun.misc.JarIndex.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: Main.java From hottub with GNU General Public License v2.0 | 6 votes |
/** * Generates class index file for the specified root jar file. */ void genIndex(String rootjar, String[] files) throws IOException { List<String> jars = getJarPath(rootjar); int njars = jars.size(); String[] jarfiles; if (njars == 1 && files != null) { // no class-path attribute defined in rootjar, will // use command line specified list of jars for (int i = 0; i < files.length; i++) { jars.addAll(getJarPath(files[i])); } njars = jars.size(); } jarfiles = jars.toArray(new String[njars]); JarIndex index = new JarIndex(jarfiles); dumpIndex(rootjar, index); }
Example #2
Source File: Main.java From jdk8u60 with GNU General Public License v2.0 | 6 votes |
/** * Generates class index file for the specified root jar file. */ void genIndex(String rootjar, String[] files) throws IOException { List<String> jars = getJarPath(rootjar); int njars = jars.size(); String[] jarfiles; if (njars == 1 && files != null) { // no class-path attribute defined in rootjar, will // use command line specified list of jars for (int i = 0; i < files.length; i++) { jars.addAll(getJarPath(files[i])); } njars = jars.size(); } jarfiles = jars.toArray(new String[njars]); JarIndex index = new JarIndex(jarfiles); dumpIndex(rootjar, index); }
Example #3
Source File: Main.java From jdk8u-jdk with GNU General Public License v2.0 | 6 votes |
/** * Outputs the class index table to the INDEX.LIST file of the * root jar file. */ void dumpIndex(String rootjar, JarIndex index) throws IOException { File jarFile = new File(rootjar); Path jarPath = jarFile.toPath(); Path tmpPath = createTempFileInSameDirectoryAs(jarFile).toPath(); try { if (update(Files.newInputStream(jarPath), Files.newOutputStream(tmpPath), null, index)) { try { Files.move(tmpPath, jarPath, REPLACE_EXISTING); } catch (IOException e) { throw new IOException(getMsg("error.write.file"), e); } } } finally { Files.deleteIfExists(tmpPath); } }
Example #4
Source File: Main.java From jdk8u60 with GNU General Public License v2.0 | 6 votes |
/** * Outputs the class index table to the INDEX.LIST file of the * root jar file. */ void dumpIndex(String rootjar, JarIndex index) throws IOException { File jarFile = new File(rootjar); Path jarPath = jarFile.toPath(); Path tmpPath = createTempFileInSameDirectoryAs(jarFile).toPath(); try { if (update(Files.newInputStream(jarPath), Files.newOutputStream(tmpPath), null, index)) { try { Files.move(tmpPath, jarPath, REPLACE_EXISTING); } catch (IOException e) { throw new IOException(getMsg("error.write.file"), e); } } } finally { Files.deleteIfExists(tmpPath); } }
Example #5
Source File: Main.java From jdk8u_jdk with GNU General Public License v2.0 | 6 votes |
/** * Generates class index file for the specified root jar file. */ void genIndex(String rootjar, String[] files) throws IOException { List<String> jars = getJarPath(rootjar); int njars = jars.size(); String[] jarfiles; if (njars == 1 && files != null) { // no class-path attribute defined in rootjar, will // use command line specified list of jars for (int i = 0; i < files.length; i++) { jars.addAll(getJarPath(files[i])); } njars = jars.size(); } jarfiles = jars.toArray(new String[njars]); JarIndex index = new JarIndex(jarfiles); dumpIndex(rootjar, index); }
Example #6
Source File: Main.java From jdk8u-dev-jdk with GNU General Public License v2.0 | 6 votes |
/** * Generates class index file for the specified root jar file. */ void genIndex(String rootjar, String[] files) throws IOException { List<String> jars = getJarPath(rootjar); int njars = jars.size(); String[] jarfiles; if (njars == 1 && files != null) { // no class-path attribute defined in rootjar, will // use command line specified list of jars for (int i = 0; i < files.length; i++) { jars.addAll(getJarPath(files[i])); } njars = jars.size(); } jarfiles = jars.toArray(new String[njars]); JarIndex index = new JarIndex(jarfiles); dumpIndex(rootjar, index); }
Example #7
Source File: Main.java From TencentKona-8 with GNU General Public License v2.0 | 6 votes |
/** * Generates class index file for the specified root jar file. */ void genIndex(String rootjar, String[] files) throws IOException { List<String> jars = getJarPath(rootjar); int njars = jars.size(); String[] jarfiles; if (njars == 1 && files != null) { // no class-path attribute defined in rootjar, will // use command line specified list of jars for (int i = 0; i < files.length; i++) { jars.addAll(getJarPath(files[i])); } njars = jars.size(); } jarfiles = jars.toArray(new String[njars]); JarIndex index = new JarIndex(jarfiles); dumpIndex(rootjar, index); }
Example #8
Source File: Main.java From TencentKona-8 with GNU General Public License v2.0 | 6 votes |
/** * Outputs the class index table to the INDEX.LIST file of the * root jar file. */ void dumpIndex(String rootjar, JarIndex index) throws IOException { File jarFile = new File(rootjar); Path jarPath = jarFile.toPath(); Path tmpPath = createTempFileInSameDirectoryAs(jarFile).toPath(); try { if (update(Files.newInputStream(jarPath), Files.newOutputStream(tmpPath), null, index)) { try { Files.move(tmpPath, jarPath, REPLACE_EXISTING); } catch (IOException e) { throw new IOException(getMsg("error.write.file"), e); } } } finally { Files.deleteIfExists(tmpPath); } }
Example #9
Source File: Main.java From jdk8u-jdk with GNU General Public License v2.0 | 6 votes |
/** * Generates class index file for the specified root jar file. */ void genIndex(String rootjar, String[] files) throws IOException { List<String> jars = getJarPath(rootjar); int njars = jars.size(); String[] jarfiles; if (njars == 1 && files != null) { // no class-path attribute defined in rootjar, will // use command line specified list of jars for (int i = 0; i < files.length; i++) { jars.addAll(getJarPath(files[i])); } njars = jars.size(); } jarfiles = jars.toArray(new String[njars]); JarIndex index = new JarIndex(jarfiles); dumpIndex(rootjar, index); }
Example #10
Source File: Main.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 6 votes |
/** * Generates class index file for the specified root jar file. */ void genIndex(String rootjar, String[] files) throws IOException { List<String> jars = getJarPath(rootjar); int njars = jars.size(); String[] jarfiles; if (njars == 1 && files != null) { // no class-path attribute defined in rootjar, will // use command line specified list of jars for (int i = 0; i < files.length; i++) { jars.addAll(getJarPath(files[i])); } njars = jars.size(); } jarfiles = jars.toArray(new String[njars]); JarIndex index = new JarIndex(jarfiles); dumpIndex(rootjar, index); }
Example #11
Source File: Main.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 6 votes |
/** * Outputs the class index table to the INDEX.LIST file of the * root jar file. */ void dumpIndex(String rootjar, JarIndex index) throws IOException { File jarFile = new File(rootjar); Path jarPath = jarFile.toPath(); Path tmpPath = createTempFileInSameDirectoryAs(jarFile).toPath(); try { if (update(Files.newInputStream(jarPath), Files.newOutputStream(tmpPath), null, index)) { try { Files.move(tmpPath, jarPath, REPLACE_EXISTING); } catch (IOException e) { throw new IOException(getMsg("error.write.file"), e); } } } finally { Files.deleteIfExists(tmpPath); } }
Example #12
Source File: Main.java From openjdk-8 with GNU General Public License v2.0 | 6 votes |
/** * Generates class index file for the specified root jar file. */ void genIndex(String rootjar, String[] files) throws IOException { List<String> jars = getJarPath(rootjar); int njars = jars.size(); String[] jarfiles; if (njars == 1 && files != null) { // no class-path attribute defined in rootjar, will // use command line specified list of jars for (int i = 0; i < files.length; i++) { jars.addAll(getJarPath(files[i])); } njars = jars.size(); } jarfiles = jars.toArray(new String[njars]); JarIndex index = new JarIndex(jarfiles); dumpIndex(rootjar, index); }
Example #13
Source File: Main.java From openjdk-8-source with GNU General Public License v2.0 | 6 votes |
/** * Outputs the class index table to the INDEX.LIST file of the * root jar file. */ void dumpIndex(String rootjar, JarIndex index) throws IOException { File jarFile = new File(rootjar); Path jarPath = jarFile.toPath(); Path tmpPath = createTempFileInSameDirectoryAs(jarFile).toPath(); try { if (update(Files.newInputStream(jarPath), Files.newOutputStream(tmpPath), null, index)) { try { Files.move(tmpPath, jarPath, REPLACE_EXISTING); } catch (IOException e) { throw new IOException(getMsg("error.write.file"), e); } } } finally { Files.deleteIfExists(tmpPath); } }
Example #14
Source File: Main.java From openjdk-8-source with GNU General Public License v2.0 | 6 votes |
/** * Generates class index file for the specified root jar file. */ void genIndex(String rootjar, String[] files) throws IOException { List<String> jars = getJarPath(rootjar); int njars = jars.size(); String[] jarfiles; if (njars == 1 && files != null) { // no class-path attribute defined in rootjar, will // use command line specified list of jars for (int i = 0; i < files.length; i++) { jars.addAll(getJarPath(files[i])); } njars = jars.size(); } jarfiles = jars.toArray(new String[njars]); JarIndex index = new JarIndex(jarfiles); dumpIndex(rootjar, index); }
Example #15
Source File: Main.java From openjdk-jdk8u with GNU General Public License v2.0 | 6 votes |
/** * Outputs the class index table to the INDEX.LIST file of the * root jar file. */ void dumpIndex(String rootjar, JarIndex index) throws IOException { File jarFile = new File(rootjar); Path jarPath = jarFile.toPath(); Path tmpPath = createTempFileInSameDirectoryAs(jarFile).toPath(); try { if (update(Files.newInputStream(jarPath), Files.newOutputStream(tmpPath), null, index)) { try { Files.move(tmpPath, jarPath, REPLACE_EXISTING); } catch (IOException e) { throw new IOException(getMsg("error.write.file"), e); } } } finally { Files.deleteIfExists(tmpPath); } }
Example #16
Source File: Main.java From openjdk-8 with GNU General Public License v2.0 | 6 votes |
/** * Outputs the class index table to the INDEX.LIST file of the * root jar file. */ void dumpIndex(String rootjar, JarIndex index) throws IOException { File jarFile = new File(rootjar); Path jarPath = jarFile.toPath(); Path tmpPath = createTempFileInSameDirectoryAs(jarFile).toPath(); try { if (update(Files.newInputStream(jarPath), Files.newOutputStream(tmpPath), null, index)) { try { Files.move(tmpPath, jarPath, REPLACE_EXISTING); } catch (IOException e) { throw new IOException(getMsg("error.write.file"), e); } } } finally { Files.deleteIfExists(tmpPath); } }
Example #17
Source File: Main.java From openjdk-jdk8u with GNU General Public License v2.0 | 6 votes |
/** * Generates class index file for the specified root jar file. */ void genIndex(String rootjar, String[] files) throws IOException { List<String> jars = getJarPath(rootjar); int njars = jars.size(); String[] jarfiles; if (njars == 1 && files != null) { // no class-path attribute defined in rootjar, will // use command line specified list of jars for (int i = 0; i < files.length; i++) { jars.addAll(getJarPath(files[i])); } njars = jars.size(); } jarfiles = jars.toArray(new String[njars]); JarIndex index = new JarIndex(jarfiles); dumpIndex(rootjar, index); }
Example #18
Source File: JarInputStream.java From jdk-1.7-annotated with Apache License 2.0 | 5 votes |
/** * Reads the next ZIP file entry and positions the stream at the * beginning of the entry data. If verification has been enabled, * any invalid signature detected while positioning the stream for * the next entry will result in an exception. * @exception ZipException if a ZIP file error has occurred * @exception IOException if an I/O error has occurred * @exception SecurityException if any of the jar file entries * are incorrectly signed. */ public ZipEntry getNextEntry() throws IOException { JarEntry e; if (first == null) { e = (JarEntry)super.getNextEntry(); if (tryManifest) { e = checkManifest(e); tryManifest = false; } } else { e = first; if (first.getName().equalsIgnoreCase(JarIndex.INDEX_NAME)) tryManifest = true; first = null; } if (jv != null && e != null) { // At this point, we might have parsed all the meta-inf // entries and have nothing to verify. If we have // nothing to verify, get rid of the JarVerifier object. if (jv.nothingToVerify() == true) { jv = null; mev = null; } else { jv.beginEntry(e, mev); } } return e; }
Example #19
Source File: JarIndexMergeTest.java From openjdk-8-source with GNU General Public License v2.0 | 5 votes |
public static void main(String[] args) throws Exception { File jar1 = buildJar1(); File jar2 = buildJar2(); JarIndex jarIndex1 = new JarIndex(new String[] { jar1.getAbsolutePath() }); JarIndex jarIndex2 = new JarIndex(new String[] { jar2.getAbsolutePath() }); jarIndex1.merge(jarIndex2, null); assertFileResolved(jarIndex2, "com/test1/resource1.file", jar1.getAbsolutePath()); assertFileResolved(jarIndex2, "com/test2/resource2.file", jar2.getAbsolutePath()); }
Example #20
Source File: JarIndexMergeTest.java From jdk8u-dev-jdk with GNU General Public License v2.0 | 5 votes |
public static void main(String[] args) throws Exception { File jar1 = buildJar1(); File jar2 = buildJar2(); JarIndex jarIndex1 = new JarIndex(new String[] { jar1.getAbsolutePath() }); JarIndex jarIndex2 = new JarIndex(new String[] { jar2.getAbsolutePath() }); jarIndex1.merge(jarIndex2, null); assertFileResolved(jarIndex2, "com/test1/resource1.file", jar1.getAbsolutePath()); assertFileResolved(jarIndex2, "com/test2/resource2.file", jar2.getAbsolutePath()); }
Example #21
Source File: JarInputStream.java From jdk8u-dev-jdk with GNU General Public License v2.0 | 5 votes |
/** * Reads the next ZIP file entry and positions the stream at the * beginning of the entry data. If verification has been enabled, * any invalid signature detected while positioning the stream for * the next entry will result in an exception. * @exception ZipException if a ZIP file error has occurred * @exception IOException if an I/O error has occurred * @exception SecurityException if any of the jar file entries * are incorrectly signed. */ public ZipEntry getNextEntry() throws IOException { JarEntry e; if (first == null) { e = (JarEntry)super.getNextEntry(); if (tryManifest) { e = checkManifest(e); tryManifest = false; } } else { e = first; if (first.getName().equalsIgnoreCase(JarIndex.INDEX_NAME)) tryManifest = true; first = null; } if (jv != null && e != null) { // At this point, we might have parsed all the meta-inf // entries and have nothing to verify. If we have // nothing to verify, get rid of the JarVerifier object. if (jv.nothingToVerify() == true) { jv = null; mev = null; } else { jv.beginEntry(e, mev); } } return e; }
Example #22
Source File: URLClassPath.java From openjdk-8-source with GNU General Public License v2.0 | 5 votes |
JarIndex getIndex() { try { ensureOpen(); } catch (IOException e) { throw new InternalError(e); } return index; }
Example #23
Source File: JarIndexMergeTest.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
static void assertFileResolved(JarIndex jarIndex2, String file, String jarName) { @SuppressWarnings("unchecked") LinkedList<String> jarLists = (LinkedList<String>)jarIndex2.get(file); if (jarLists == null || jarLists.size() == 0 || !jarName.equals(jarLists.get(0))) { throw new RuntimeException( "Unexpected result: the merged index must resolve file: " + file); } }
Example #24
Source File: JarIndexMergeTest.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 5 votes |
static void assertFileResolved(JarIndex jarIndex2, String file, String jarName) { @SuppressWarnings("unchecked") LinkedList<String> jarLists = (LinkedList<String>)jarIndex2.get(file); if (jarLists == null || jarLists.size() == 0 || !jarName.equals(jarLists.get(0))) { throw new RuntimeException( "Unexpected result: the merged index must resolve file: " + file); } }
Example #25
Source File: JarIndexMergeTest.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 5 votes |
public static void main(String[] args) throws Exception { File jar1 = buildJar1(); File jar2 = buildJar2(); JarIndex jarIndex1 = new JarIndex(new String[] { jar1.getAbsolutePath() }); JarIndex jarIndex2 = new JarIndex(new String[] { jar2.getAbsolutePath() }); jarIndex1.merge(jarIndex2, null); assertFileResolved(jarIndex2, "com/test1/resource1.file", jar1.getAbsolutePath()); assertFileResolved(jarIndex2, "com/test2/resource2.file", jar2.getAbsolutePath()); }
Example #26
Source File: Main.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 5 votes |
private void addIndex(JarIndex index, ZipOutputStream zos) throws IOException { ZipEntry e = new ZipEntry(INDEX_NAME); e.setTime(System.currentTimeMillis()); if (flag0) { CRC32OutputStream os = new CRC32OutputStream(); index.write(os); os.updateEntry(e); } zos.putNextEntry(e); index.write(zos); zos.closeEntry(); }
Example #27
Source File: URLClassPath.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 5 votes |
JarIndex getIndex() { try { ensureOpen(); } catch (IOException e) { throw new InternalError(e); } return index; }
Example #28
Source File: Main.java From jdk8u-dev-jdk with GNU General Public License v2.0 | 5 votes |
private void addIndex(JarIndex index, ZipOutputStream zos) throws IOException { ZipEntry e = new ZipEntry(INDEX_NAME); e.setTime(System.currentTimeMillis()); if (flag0) { CRC32OutputStream os = new CRC32OutputStream(); index.write(os); os.updateEntry(e); } zos.putNextEntry(e); index.write(zos); zos.closeEntry(); }
Example #29
Source File: JarIndexMergeTest.java From jdk8u_jdk with GNU General Public License v2.0 | 5 votes |
static void assertFileResolved(JarIndex jarIndex2, String file, String jarName) { @SuppressWarnings("unchecked") LinkedList<String> jarLists = (LinkedList<String>)jarIndex2.get(file); if (jarLists == null || jarLists.size() == 0 || !jarName.equals(jarLists.get(0))) { throw new RuntimeException( "Unexpected result: the merged index must resolve file: " + file); } }
Example #30
Source File: JarIndexMergeTest.java From openjdk-8 with GNU General Public License v2.0 | 5 votes |
static void assertFileResolved(JarIndex jarIndex2, String file, String jarName) { @SuppressWarnings("unchecked") LinkedList<String> jarLists = (LinkedList<String>)jarIndex2.get(file); if (jarLists == null || jarLists.size() == 0 || !jarName.equals(jarLists.get(0))) { throw new RuntimeException( "Unexpected result: the merged index must resolve file: " + file); } }