/* * Copyright (c) 2016, 2019, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions.
*/
Map<String, String[]> names = Map.of( "version/Main.class", new String[]{"base", "version", "Main.class"},
"version/Version.class", new String[]{"base", "version", "Version.class"},
"META-INF/versions/9/version/Version.class", new String[]{"v9", "version", "Version.class"}
);
compare(jarfile, names);
// write the v9 version/Version.class entry in base and the v10 // version/Version.class entry in versions/9 section
jarTool("uf", jarfile, "-C", classes.resolve("v9").toString(), "version", "--release", "9", "-C", classes.resolve("v10").toString(), ".")
.shouldHaveExitValue(SUCCESS);
checkMultiRelease(jarfile, true);
names = Map.of( "version/Main.class", new String[]{"base", "version", "Main.class"},
"version/Version.class", new String[]{"v9", "version", "Version.class"},
"META-INF/versions/9/version/Version.class", new String[]{"v10", "version", "Version.class"}
);
@Test // META-INF/versions/9 contains an extra package private class -- this is okay publicvoid test06() throws Throwable {
String jarfile = "test.jar";
compile("test01"); //use same data as test01
Path classes = Paths.get("classes");
// add the new v9 class
Path source = Paths.get(src, "data", "test06", "v9", "version");
javac(classes.resolve("v9"), source.resolve("Extra.java"));
@Test // META-INF/versions/9 contains an identical class to base entry class // this is okay but produces warning publicvoid test07() throws Throwable {
String jarfile = "test.jar";
compile("test01"); //use same data as test01
Path classes = Paths.get("classes");
// add the new v9 class
Path source = Paths.get(src, "data", "test01", "base", "version");
javac(classes.resolve("v9"), source.resolve("Version.java"));
jarTool("cf", jarfile, "-C", classes.resolve("base").toString(), ".", "--release", "9", "-C", classes.resolve("v9").toString(), ".")
.shouldHaveExitValue(SUCCESS)
.shouldContain("contains a class that")
.shouldContain("is identical");
@Test // META-INF/versions/9 contains an identical class to previous version entry class // this is okay but produces warning publicvoid identicalClassToPreviousVersion() throws Throwable {
String jarfile = "test.jar";
@Test // assure that basic nested classes are acceptable publicvoid test10() throws Throwable {
String jarfile = "test.jar";
compile("test01"); //use same data as test01
Path classes = Paths.get("classes");
// add a base class with a nested class
Path source = Paths.get(src, "data", "test10", "base", "version");
javac(classes.resolve("base"), source.resolve("Nested.java"));
// add a versioned class with a nested class
source = Paths.get(src, "data", "test10", "v9", "version");
javac(classes.resolve("v9"), source.resolve("Nested.java"));
@Test // a base entry contains a nested class that doesn't have a matching top level class publicvoid test11() throws Throwable {
String jarfile = "test.jar";
compile("test01"); //use same data as test01
Path classes = Paths.get("classes");
// add a base class with a nested class
Path source = Paths.get(src, "data", "test10", "base", "version");
javac(classes.resolve("base"), source.resolve("Nested.java"));
// remove the top level class, thus isolating the nested class
Files.delete(classes.resolve("base").resolve("version").resolve("Nested.class"));
// add a versioned class with a nested class
source = Paths.get(src, "data", "test10", "v9", "version");
javac(classes.resolve("v9"), source.resolve("Nested.java"));
/* "META-INF/versions/9/version/Nested$nested.class" is really NOT isolated assertTrue(output.size() == 4); assertTrue(output.size() == 3); assertTrue(output.get(0).contains("an isolated nested class"), output.get(0)); assertTrue(output.get(1).contains("contains a new public class"), output.get(1)); assertTrue(output.get(2).contains("an isolated nested class"), output.get(2)); assertTrue(output.get(3).contains("invalid multi-release jar file"), output.get(3)); assertTrue(output.get(2).contains("invalid multi-release jar file"), output.get(2));
*/
assertTrue(output.size() == 3);
assertTrue(output.get(0).contains("an isolated nested class"),
output.get(0));
assertTrue(output.get(1).contains("contains a new public class"),
output.get(1));
assertTrue(output.get(2).contains("invalid multi-release jar file"),
output.get(2));
@Test // a versioned entry contains a nested class that doesn't have a matching top level class publicvoid test12() throws Throwable {
String jarfile = "test.jar";
compile("test01"); //use same data as test01
Path classes = Paths.get("classes");
// add a base class with a nested class
Path source = Paths.get(src, "data", "test10", "base", "version");
javac(classes.resolve("base"), source.resolve("Nested.java"));
// add a versioned class with a nested class
source = Paths.get(src, "data", "test10", "v9", "version");
javac(classes.resolve("v9"), source.resolve("Nested.java"));
// remove the top level class, thus isolating the nested class
Files.delete(classes.resolve("v9").resolve("version").resolve("Nested.class"));
@Test // assure the nested-nested classes are acceptable publicvoid test13() throws Throwable {
String jarfile = "test.jar";
compile("test01"); //use same data as test01
Path classes = Paths.get("classes");
// add a base class with a nested and nested-nested class
Path source = Paths.get(src, "data", "test13", "base", "version");
javac(classes.resolve("base"), source.resolve("Nested.java"));
// add a versioned class with a nested and nested-nested class
source = Paths.get(src, "data", "test13", "v10", "version");
javac(classes.resolve("v10"), source.resolve("Nested.java"));
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung ist noch experimentell.