// updates a valid multi-release jar with a new public class in // versioned section and fails
@Test publicvoid test1() { // successful build of multi-release jar int rc = jar("-cf mmr.jar -C classes . --release 9 -C mr9 p/Hi.class"); Assert.assertEquals(rc, 0);
// failed build because of new public class
rc = jar("-uf mmr.jar --release 9 -C mr9 p/internal/Bar.class"); Assert.assertEquals(rc, 1);
String s = new String(errbytes.toByteArray()); Assert.assertTrue(Message.NOT_FOUND_IN_BASE_ENTRY.match(s, "p/internal/Bar.class"));
}
// updates a valid multi-release jar with a module-info class and new // concealed public class in versioned section and succeeds
@Test publicvoid test2() { // successful build of multi-release jar int rc = jar("-cf mmr.jar -C classes . --release 9 -C mr9 p/Hi.class"); Assert.assertEquals(rc, 0);
// successful build because of module-info and new public class
rc = jar("-uf mmr.jar module-info.class --release 9 -C mr9 p/internal/Bar.class"); Assert.assertEquals(rc, 0);
String s = new String(errbytes.toByteArray()); Assert.assertTrue(Message.NEW_CONCEALED_PACKAGE_WARNING.match(s, "p/internal/Bar.class"));
// jar tool fails building mmr.jar because of new public class
@Test publicvoid test3() { int rc = jar("-cf mmr.jar -C classes . --release 9 -C mr9 ."); Assert.assertEquals(rc, 1);
String s = new String(errbytes.toByteArray()); Assert.assertTrue(Message.NOT_FOUND_IN_BASE_ENTRY.match(s, "p/internal/Bar.class"));
}
// jar tool succeeds building mmr.jar because of concealed package
@Test publicvoid test4() { int rc = jar("-cf mmr.jar module-info.class -C classes . " + "--release 9 module-info.class -C mr9 ."); Assert.assertEquals(rc, 0);
String s = new String(errbytes.toByteArray()); Assert.assertTrue(Message.NEW_CONCEALED_PACKAGE_WARNING.match(s, "p/internal/Bar.class"));
// jar tool does two updates, no exported packages, all concealed. // Along with various --describe-module variants
@Test publicvoid test5() throws IOException { // compile the mr10 directory
Path source = testsrc.resolve("src").resolve("mr10");
Path destination = Paths.get("mr10");
javac(source, destination);
// create a directory for this tests special files
Files.createDirectory(Paths.get("test5"));
// create an empty module-info.java
String hi = "module hi {" + linesep + "}" + linesep;
Path modinfo = Paths.get("test5", "module-info.java");
Files.write(modinfo, hi.getBytes());
// and compile it
javac(modinfo, Paths.get("test5"));
for (String release : new String[] {"9" , "10", "100", "1000"}) {
jar("-d --file mr.jar --release " + release);
actual = lines(outbytes); Assert.assertEquals(actual, expected);
}
}
// root and versioned module-info entries have different main-class, version // attributes
@Test publicvoid test6() throws IOException { // create a directory for this tests special files
Files.createDirectory(Paths.get("test6"));
Files.createDirectory(Paths.get("test6-v9"));
Assert.assertTrue(Message.CONTAINS_DIFFERENT_VERSION.match( new String(errbytes.toByteArray()), "META-INF/versions/9/module-info.class"));
}
// versioned mmr without root module-info.class
@Test publicvoid test7() throws IOException { // create a directory for this tests special files
Files.createDirectory(Paths.get("test7"));
Files.createDirectory(Paths.get("test7-v9"));
Files.createDirectory(Paths.get("test7-v10"));
staticenum Message {
CONTAINS_DIFFERENT_MAINCLASS( ": module-info.class in a versioned directory contains different \"main-class\""
),
CONTAINS_DIFFERENT_VERSION( ": module-info.class in a versioned directory contains different \"version\""
),
NOT_FOUND_IN_BASE_ENTRY( ", contains a new public class not found in base entries"
),
NEW_CONCEALED_PACKAGE_WARNING( " is a public class" + " in a concealed package, placing this jar on the class path will result" + " in incompatible public interfaces"
);
final String msg;
Message(String msg) { this.msg = msg;
}
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 und die Messung sind noch experimentell.