1 /* 2 * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * This code is free software; you can redistribute it and/or modify it 6 * under the terms of the GNU General Public License version 2 only, as 7 * published by the Free Software Foundation. 8 * 9 * This code is distributed in the hope that it will be useful, but WITHOUT 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 12 * version 2 for more details (a copy is included in the LICENSE file that 13 * accompanied this code). 14 * 15 * You should have received a copy of the GNU General Public License version 16 * 2 along with this work; if not, write to the Free Software Foundation, 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 18 * 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 20 * or visit www.oracle.com if you need additional information or have any 21 * questions. 22 */ 23 24 /** 25 * @test 26 * @bug 8186334 27 * @library /test/lib 28 * @build jdk.test.lib.util.JarBuilder 29 * @run testng JarBacktickManifest 30 * @summary Make sure scanning manifest doesn't throw AIOOBE on certain strings 31 * containing backticks. 32 */ 33 34 import java.io.File; 35 import java.io.IOException; 36 import java.nio.file.Files; 37 import java.util.jar.JarFile; 38 39 import jdk.test.lib.util.JarBuilder; 40 41 import org.testng.Assert; 42 import org.testng.annotations.AfterClass; 43 import org.testng.annotations.BeforeClass; 44 import org.testng.annotations.Test; 45 46 public class JarBacktickManifest { 47 48 public static final String VERIFY_MANIFEST_JAR = "verifyManifest.jar"; 49 50 @BeforeClass 51 public void initialize() throws Exception { 52 JarBuilder jb = new JarBuilder(VERIFY_MANIFEST_JAR); 53 jb.addAttribute("Test", " Class-`Path` "); 54 jb.addAttribute("Test2", " Multi-`Release "); 55 jb.build(); 56 } 57 58 @Test 59 public void test() throws Exception { 60 try (JarFile jf = new JarFile(VERIFY_MANIFEST_JAR)) { // do not set runtime versioning 61 Assert.assertFalse(jf.isMultiRelease(), "Shouldn't be multi-release"); 62 } 63 } 64 65 @AfterClass 66 public void close() throws IOException { 67 Files.delete(new File(VERIFY_MANIFEST_JAR).toPath()); 68 } 69 }