/** *Teststhatifajarfilehasamanifestwithainvalidpathvaluefor{@codeClass-Path}attribute, *thenparsingsuchajarfilethrough{@linkFSInfo#getJarClassPath(Path)}doesn'tthrowanyother *exceptionotherthan{@linkIOException} * *@throwsException
*/
@Test publicvoid testInvalidClassPath() throws Exception { final String invalidOSPath = System.getProperty("os.name").toLowerCase(Locale.ENGLISH).contains("windows")
? "C:\\*" : "foo\u0000bar"; final Path jarFile = Files.createTempFile(null, ".jar");
jarFile.toFile().deleteOnExit(); final Manifest mf = new Manifest();
mf.getMainAttributes().putValue("Manifest-Version", "1.0"); // add Class-Path which points to an invalid path
System.out.println("Intentionally using an invalid Class-Path entry " + invalidOSPath + " in manifest");
mf.getMainAttributes().putValue("Class-Path", invalidOSPath + " " + "/some/other-random/path");
// create a jar file with the manifest try (final JarOutputStream jar = new JarOutputStream(Files.newOutputStream(jarFile), mf)) {
} final FSInfo fsInfo = FSInfo.instance(new Context()); try {
fsInfo.getJarClassPath(jarFile); // we don't rely on fsInfo.getJarClassPath to throw an exception for invalid // paths. Hence no Assert.fail(...) call here. But if it does throw some exception, // then that exception should always be a IOException.
} catch (IOException ioe) { // expected
System.out.println("(As expected) FSInfo.getJarClassPath threw an IOException - " + ioe.getMessage());
}
}
}
Messung V0.5 in Prozent
¤ Dauer der Verarbeitung: 0.13 Sekunden
(vorverarbeitet am 2026-06-10)
¤
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.