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 4408526 6854795 27 * @modules jdk.jartool/sun.tools.jar 28 * @summary Index the non-meta files in META-INF, such as META-INF/services. 29 */ 30 31 import java.io.*; 32 import java.util.Arrays; 33 import java.util.jar.*; 34 import sun.tools.jar.Main; 35 import java.util.zip.ZipFile; 36 37 public class MetaInf { 38 39 static String jarName = "a.jar"; 40 static String INDEX = "META-INF/INDEX.LIST"; 41 static String SERVICES = "META-INF/services"; 42 static String contents = 43 System.getProperty("test.src") + File.separatorChar + "jarcontents"; 44 45 static void run(String ... args) { 46 if (! new Main(System.out, System.err, "jar").run(args)) 47 throw new Error("jar failed: args=" + Arrays.toString(args)); 48 } 49 50 static void copy(File from, File to) throws IOException { 51 FileInputStream in = new FileInputStream(from); 52 FileOutputStream out = new FileOutputStream(to); 53 try { 54 byte[] buf = new byte[8192]; 55 int n; 56 while ((n = in.read(buf)) != -1) 57 out.write(buf, 0, n); 58 } finally { 59 in.close(); 60 out.close(); 61 } 62 } 63 64 static boolean contains(File jarFile, String entryName) 65 throws IOException { 66 ZipFile zf = new ZipFile(jarFile); | 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 4408526 6854795 27 * @modules jdk.jartool 28 * @summary Index the non-meta files in META-INF, such as META-INF/services. 29 */ 30 31 import java.io.*; 32 import java.util.Arrays; 33 import java.util.jar.*; 34 import java.util.spi.ToolProvider; 35 import java.util.zip.ZipFile; 36 37 public class MetaInf { 38 static final ToolProvider JAR_TOOL = ToolProvider.findFirst("jar").get(); 39 40 static String jarName = "a.jar"; 41 static String INDEX = "META-INF/INDEX.LIST"; 42 static String SERVICES = "META-INF/services"; 43 static String contents = 44 System.getProperty("test.src") + File.separatorChar + "jarcontents"; 45 46 static void run(String ... args) { 47 if (JAR_TOOL.run(System.out, System.err, args) != 0) 48 throw new Error("jar failed: args=" + Arrays.toString(args)); 49 } 50 51 static void copy(File from, File to) throws IOException { 52 FileInputStream in = new FileInputStream(from); 53 FileOutputStream out = new FileOutputStream(to); 54 try { 55 byte[] buf = new byte[8192]; 56 int n; 57 while ((n = in.read(buf)) != -1) 58 out.write(buf, 0, n); 59 } finally { 60 in.close(); 61 out.close(); 62 } 63 } 64 65 static boolean contains(File jarFile, String entryName) 66 throws IOException { 67 ZipFile zf = new ZipFile(jarFile); |