当前位置: 首页>>代码示例>>Java>>正文


Java JarIndex类代码示例

本文整理汇总了Java中sun.misc.JarIndex的典型用法代码示例。如果您正苦于以下问题:Java JarIndex类的具体用法?Java JarIndex怎么用?Java JarIndex使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


JarIndex类属于sun.misc包,在下文中一共展示了JarIndex类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: genIndex

import sun.misc.JarIndex; //导入依赖的package包/类
/**
 * 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);
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:21,代码来源:Main.java

示例2: dumpIndex

import sun.misc.JarIndex; //导入依赖的package包/类
/**
 * 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);
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:23,代码来源:Main.java

示例3: getNextEntry

import sun.misc.JarIndex; //导入依赖的package包/类
/**
 * 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;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:38,代码来源:JarInputStream.java

示例4: getIndex

import sun.misc.JarIndex; //导入依赖的package包/类
JarIndex getIndex() {
    try {
        ensureOpen();
    } catch (IOException e) {
        throw new InternalError(e);
    }
    return index;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:9,代码来源:URLClassPath.java

示例5: addIndex

import sun.misc.JarIndex; //导入依赖的package包/类
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();
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:15,代码来源:Main.java

示例6: main

import sun.misc.JarIndex; //导入依赖的package包/类
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());
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:15,代码来源:JarIndexMergeTest.java

示例7: assertFileResolved

import sun.misc.JarIndex; //导入依赖的package包/类
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);
    }
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:12,代码来源:JarIndexMergeTest.java


注:本文中的sun.misc.JarIndex类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。