/* * Copyright (c) 2003, 2022, 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.
*/
/* * @test * @bug 4212732 8293877 * @summary Test handling of the Class-Path attribute in jar file manifests * @library /tools/lib * @build toolbox.ToolBox Util ClassPath * @run main ClassPath
*/
/* * Converted from Class-Path.sh, originally written by Martin Buchholz. * * For the last version of the original, Class-Path.sh, see * https://git.openjdk.org/jdk/blob/jdk-19%2B36/test/langtools/tools/javac/Paths/Class-Path.sh * * This class primarily tests that the Class-Path attribute in jar files * is handled the same way by javac and java. It also has various tests * of the jar tool itself.
*/
/*---------------------------------------------------------------- * Jar file Class-Path expanded only for jars found on user class path
*----------------------------------------------------------------*/
/*---------------------------------------------------------------- * Test new flag -e (application entry point)
*----------------------------------------------------------------*/
// Set an empty classpath to override any inherited setting of CLASSPATH
expectPass(classpath(""), JAVAC, "Hello.java Bye.java");
// test jar creation without manifest //
expectPass(JAR, "cfe Hello.jar Hello Hello.class");
expectPass(JAVA, "-jar Hello.jar");
// test for overriding the manifest during jar creation //
Files.writeString(Path.of("MANIFEST.MF"), "Main-Class: Hello\n", StandardOpenOption.APPEND);
// test for error: " 'e' flag and manifest with the 'Main-Class' // attribute cannot be specified together, during creation
expectFail(JAR, "cmfe MANIFEST.MF Bye.jar Bye Bye.class");
// test for overriding the manifest when updating the jar //
expectPass(JAR, "cfe greetings.jar Hello Hello.class");
expectPass(JAR, "ufe greetings.jar Bye Bye.class");
expectPass(JAVA, "-jar greetings.jar");
// test for error: " 'e' flag and manifest with the 'Main-Class' // attribute cannot be specified together, during update
expectFail(JAR, "umfe MANIFEST.MF greetings.jar Hello");
// test jar update when there are no input files
expectPass(JAR, "ufe Hello.jar Bye");
expectFail(JAVA, "-jar Hello.jar");
expectPass(JAR, "umf MANIFEST.MF Hello.jar");
// test creating jar when the to-be-archived files // do not contain the specified main class, there is no check done // for the presence of the main class, so the test will pass //
expectPass(JAR, "cfe Hello.jar Hello Bye.class");
// Jar creation and update when there is no manifest and inputfiles // specified
expectFail(JAR, "cvf A.jar");
expectFail(JAR, "uvf A.jar");
// error: no such file or directory
expectFail(JAR, "cvf A.jar non-existing.file");
expectFail(JAR, "uvf A.jar non-existing.file");
}
}
Messung V0.5
¤ Dauer der Verarbeitung: 0.12 Sekunden
(vorverarbeitet)
¤
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.