diff --git a/test/ProblemList.txt b/test/ProblemList.txt --- a/test/ProblemList.txt +++ b/test/ProblemList.txt @@ -256,7 +256,8 @@ # jdk_tools # Tests take too long, on sparcs see 7143279 -tools/pack200/CommandLineTests.java solaris-all,macosx-all +# also see 8059906 +tools/pack200/CommandLineTests.java tools/pack200/Pack200Test.java solaris-all,macosx-all # 8007410 diff --git a/test/tools/pack200/CommandLineTests.java b/test/tools/pack200/CommandLineTests.java --- a/test/tools/pack200/CommandLineTests.java +++ b/test/tools/pack200/CommandLineTests.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2014, 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 @@ -24,6 +24,7 @@ /* * @test CommandLineTests.sh * @bug 6521334 6965836 6965836 + * @ignore 8059906 * @compile -XDignore.symbol.file CommandLineTests.java Pack200Test.java * @run main/timeout=1200 CommandLineTests * @summary An ad hoc test to verify the behavior of pack200/unpack200 CLIs, diff --git a/test/tools/pack200/Pack200Props.java b/test/tools/pack200/Pack200Props.java --- a/test/tools/pack200/Pack200Props.java +++ b/test/tools/pack200/Pack200Props.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2010, 2014, 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 @@ -54,9 +54,9 @@ Utils.cleanup(); } - static void verifySegmentLimit(File outFile) { + static void verifySegmentLimit(File outFile) throws IOException { File sdkHome = Utils.JavaSDK; - File testJar = new File(new File(sdkHome, "lib"), "tools.jar"); + File testJar = Utils.createRtJar(); System.out.println("using pack200: " + Utils.getPack200Cmd()); diff --git a/test/tools/pack200/Pack200Test.java b/test/tools/pack200/Pack200Test.java --- a/test/tools/pack200/Pack200Test.java +++ b/test/tools/pack200/Pack200Test.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2014, 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 @@ -126,8 +126,7 @@ public static void main(String[] args) throws IOException { // select the jars carefully, adding more jars will increase the // testing time, especially for jprt. - jarList.add(Utils.locateJar("tools.jar")); - jarList.add(Utils.locateJar("rt.jar")); + jarList.add(Utils.createRtJar()); jarList.add(Utils.locateJar("golden.jar")); System.out.println(jarList); doPackUnpack(); diff --git a/test/tools/pack200/T7007157.java b/test/tools/pack200/T7007157.java --- a/test/tools/pack200/T7007157.java +++ b/test/tools/pack200/T7007157.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2010, 2014, 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 @@ -38,7 +38,8 @@ public static void main(String... args) throws IOException { File sdkHome = Utils.JavaSDK; - File testJar = new File(new File(sdkHome, "lib"), "tools.jar"); + File testJar = new File("test.jar"); + Utils.jar("cvf", testJar.getName(), Utils.TEST_CLS_DIR.getAbsolutePath()); JarFile jarFile = new JarFile(testJar); File packFile = new File("foo.pack"); Pack200.Packer packer = Pack200.newPacker(); diff --git a/test/tools/pack200/Utils.java b/test/tools/pack200/Utils.java --- a/test/tools/pack200/Utils.java +++ b/test/tools/pack200/Utils.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2014, 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 @@ -54,8 +54,7 @@ */ /* - * This class contains all the commonly used utilities used by various tests - * in this directory. + * This class contains the commonly used utilities. */ class Utils { static final String JavaHome = System.getProperty("test.java", @@ -131,8 +130,7 @@ List cmds = new ArrayList(); cmds.add(getJavaCmd()); cmds.add("-cp"); - cmds.add(Utils.locateJar("tools.jar") + - System.getProperty("path.separator") + VerifierJar.getName()); + cmds.add(VerifierJar.getName()); cmds.add("sun.tools.pack.verify.Main"); cmds.add(reference.getAbsolutePath()); cmds.add(specimen.getAbsolutePath()); @@ -146,8 +144,7 @@ List cmds = new ArrayList(); cmds.add(getJavaCmd()); cmds.add("-cp"); - cmds.add(Utils.locateJar("tools.jar") - + System.getProperty("path.separator") + VerifierJar.getName()); + cmds.add(VerifierJar.getName()); cmds.add("sun.tools.pack.verify.Main"); cmds.add(reference.getName()); cmds.add(specimen.getName()); @@ -337,17 +334,21 @@ } static void compiler(String... javacCmds) { - if (com.sun.tools.javac.Main.compile(javacCmds) != 0) { - throw new RuntimeException("compilation failed"); + List cmdList = new ArrayList<>(); + cmdList.add(getJavacCmd()); + for (String x : javacCmds) { + cmdList.add(x); } + runExec(cmdList); } static void jar(String... jargs) { - sun.tools.jar.Main jarTool = - new sun.tools.jar.Main(System.out, System.err, "jartool"); - if (!jarTool.run(jargs)) { - throw new RuntimeException("jar command failed"); + List cmdList = new ArrayList<>(); + cmdList.add(getJarCmd()); + for (String x : jargs) { + cmdList.add(x); } + runExec(cmdList); } static void testWithRepack(File inFile, String... repackOpts) throws IOException { @@ -522,6 +523,18 @@ return getAjavaCmd("java"); } + static String getJavacCmd() { + return getAjavaCmd("javac"); + } + + static String getJarCmd() { + return getAjavaCmd("jar"); + } + + static String getJimageCmd() { + return getAjavaCmd("jimage"); + } + static String getAjavaCmd(String cmdStr) { File binDir = new File(JavaHome, "bin"); File unpack200File = IsWindows @@ -536,6 +549,31 @@ return cmd; } + static File createRtJar() throws IOException { + File LibDir = new File(JavaHome, "lib"); + File ModuleDir = new File(LibDir, "modules"); + File BootModules = new File(ModuleDir, "bootmodules.jimage"); + List cmdList = new ArrayList<>(); + cmdList.add(getJimageCmd()); + cmdList.add("expand"); + cmdList.add(BootModules.getAbsolutePath()); + cmdList.add("--dir"); + cmdList.add("out"); + runExec(cmdList); + + File rtJar = new File("rt.jar"); + cmdList.clear(); + cmdList.add(getJarCmd()); + cmdList.add("cvf"); + cmdList.add(rtJar.getName()); + cmdList.add("-C"); + cmdList.add("out"); + cmdList.add("."); + runExec(cmdList); + + recursiveDelete(new File("out")); + return rtJar; + } private static List locaterCache = null; // search the source dir and jdk dir for requested file and returns // the first location it finds.