Java Code Examples for java.util.jar.JarFile#runtimeVersion()

The following examples show how to use java.util.jar.JarFile#runtimeVersion() . 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: ModuleReferences.java    From Bytecoder with Apache License 2.0 5 votes vote down vote up
static JarFile newJarFile(Path path) {
    try {
        return new JarFile(new File(path.toString()),
                           true,                       // verify
                           ZipFile.OPEN_READ,
                           JarFile.runtimeVersion());
    } catch (IOException ioe) {
        throw new UncheckedIOException(ioe);
    }
}
 
Example 2
Source File: ModuleReferences.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
static JarFile newJarFile(Path path) {
    try {
        return new JarFile(new File(path.toString()),
                           true,                       // verify
                           ZipFile.OPEN_READ,
                           JarFile.runtimeVersion());
    } catch (IOException ioe) {
        throw new UncheckedIOException(ioe);
    }
}
 
Example 3
Source File: MultiReleaseJarAPI.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
@DataProvider(name = "versions")
public Object[][] createVersionData() throws Exception {
    return new Object[][]{
            {JarFile.baseVersion(), 8},
            {JarFile.runtimeVersion(), Runtime.version().major()},
            {Runtime.version(), Runtime.version().major()},
            {Runtime.Version.parse("7.1"), JarFile.baseVersion().major()},
            {Runtime.Version.parse("9"), 9},
            {Runtime.Version.parse("9.1.5-ea+200"), 9}
    };
}
 
Example 4
Source File: TestVersionedStream.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
@DataProvider
public Object[][] data() {
    return new Object[][] {
        {Runtime.Version.parse("8")},
        {Runtime.Version.parse("9")},
        {Runtime.Version.parse("10")},
        {Runtime.Version.parse("11")},
        {JarFile.baseVersion()},
        {JarFile.runtimeVersion()}
    };
}
 
Example 5
Source File: MRTestBase.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
protected void checkMultiRelease(String jarFile,
                                 boolean expected) throws IOException {
    try (JarFile jf = new JarFile(new File(jarFile), true,
            ZipFile.OPEN_READ, JarFile.runtimeVersion())) {
        assertEquals(jf.isMultiRelease(), expected);
    }
}
 
Example 6
Source File: Basic.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
@Test
public void testCustomManifest() throws Throwable {
    String jarfile = "test.jar";

    compile("test01");

    Path classes = Paths.get("classes");
    Path manifest = Paths.get("Manifest.txt");

    // create
    Files.write(manifest, "Class-Path: MyUtils.jar\n".getBytes());

    jar("cfm", jarfile, manifest.toString(),
            "-C", classes.resolve("base").toString(), ".",
            "--release", "10", "-C", classes.resolve("v10").toString(), ".")
            .shouldHaveExitValue(SUCCESS)
            .shouldBeEmpty();

    try (JarFile jf = new JarFile(new File(jarfile), true,
            ZipFile.OPEN_READ, JarFile.runtimeVersion())) {
        assertTrue(jf.isMultiRelease(), "Not multi-release jar");
        assertEquals(jf.getManifest()
                        .getMainAttributes()
                        .getValue("Class-Path"),
                "MyUtils.jar");
    }

    // update
    Files.write(manifest, "Multi-release: false\n".getBytes());

    jar("ufm", jarfile, manifest.toString(),
            "-C", classes.resolve("base").toString(), ".",
            "--release", "9", "-C", classes.resolve("v10").toString(), ".")
            .shouldHaveExitValue(SUCCESS)
            .shouldContain("WARNING: Duplicate name in Manifest: Multi-release.");

    try (JarFile jf = new JarFile(new File(jarfile), true,
            ZipFile.OPEN_READ, JarFile.runtimeVersion())) {
        assertTrue(jf.isMultiRelease(), "Not multi-release jar");
        assertEquals(jf.getManifest()
                        .getMainAttributes()
                        .getValue("Class-Path"),
                "MyUtils.jar");
    }

    FileUtils.deleteFileIfExistsWithRetry(Paths.get(jarfile));
    FileUtils.deleteFileTreeWithRetry(Paths.get(usr, "classes"));
}
 
Example 7
Source File: ModulePath.java    From Bytecoder with Apache License 2.0 2 votes vote down vote up
/**
 * Returns a ModuleFinder that locates modules on the file system by
 * searching a sequence of directories and/or packaged modules. The modules
 * may be patched by the given ModulePatcher.
 */
public static ModuleFinder of(ModulePatcher patcher, Path... entries) {
    return new ModulePath(JarFile.runtimeVersion(), false, patcher, entries);
}
 
Example 8
Source File: ModulePath.java    From openjdk-jdk9 with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Returns a ModuleFinder that that locates modules on the file system by
 * searching a sequence of directories and/or packaged modules. The modules
 * may be patched by the given ModulePatcher.
 */
public static ModuleFinder of(ModulePatcher patcher, Path... entries) {
    return new ModulePath(JarFile.runtimeVersion(), false, patcher, entries);
}