Fri, 24 Apr 2020 03:58:51 +0100
Merge
vromero@1591 | 1 | /* |
vromero@1591 | 2 | * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. |
vromero@1591 | 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
vromero@1591 | 4 | * |
vromero@1591 | 5 | * This code is free software; you can redistribute it and/or modify it |
vromero@1591 | 6 | * under the terms of the GNU General Public License version 2 only, as |
vromero@1591 | 7 | * published by the Free Software Foundation. |
vromero@1591 | 8 | * |
vromero@1591 | 9 | * This code is distributed in the hope that it will be useful, but WITHOUT |
vromero@1591 | 10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
vromero@1591 | 11 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
vromero@1591 | 12 | * version 2 for more details (a copy is included in the LICENSE file that |
vromero@1591 | 13 | * accompanied this code). |
vromero@1591 | 14 | * |
vromero@1591 | 15 | * You should have received a copy of the GNU General Public License version |
vromero@1591 | 16 | * 2 along with this work; if not, write to the Free Software Foundation, |
vromero@1591 | 17 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
vromero@1591 | 18 | * |
vromero@1591 | 19 | * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
vromero@1591 | 20 | * or visit www.oracle.com if you need additional information or have any |
vromero@1591 | 21 | * questions. |
vromero@1591 | 22 | */ |
vromero@1591 | 23 | |
vromero@1591 | 24 | /* |
vromero@1591 | 25 | * @test |
vromero@1591 | 26 | * @bug 4204897 4256097 4785453 4863609 |
vromero@1591 | 27 | * @summary Test that '.jar' files in -extdirs are found. |
vromero@1591 | 28 | * @library /tools/javac/lib |
vromero@1591 | 29 | * @build ToolBox |
vromero@1591 | 30 | * @run main ExtDirTest |
vromero@1591 | 31 | */ |
vromero@1591 | 32 | |
vromero@1591 | 33 | import java.io.File; |
vromero@1591 | 34 | import java.nio.file.Files; |
vromero@1591 | 35 | import java.nio.file.Paths; |
vromero@1591 | 36 | import java.util.Arrays; |
vromero@1591 | 37 | import java.util.List; |
vromero@1591 | 38 | |
vromero@1591 | 39 | //original test: test/tools/javac/ExtDirs/ExtDirs.sh |
vromero@1591 | 40 | public class ExtDirTest { |
vromero@1591 | 41 | |
vromero@1591 | 42 | private static final String ExtDirTestClass1Src = |
vromero@1591 | 43 | "package pkg1;\n" + |
vromero@1591 | 44 | "\n" + |
vromero@1591 | 45 | "public class ExtDirTestClass1 {}"; |
vromero@1591 | 46 | |
vromero@1591 | 47 | private static final String ExtDirTestClass2Src = |
vromero@1591 | 48 | "package pkg2;\n" + |
vromero@1591 | 49 | "\n" + |
vromero@1591 | 50 | "public class ExtDirTestClass2 {}"; |
vromero@1591 | 51 | |
vromero@1591 | 52 | private static final String ExtDirTest_1Src = |
vromero@1591 | 53 | "import pkg1.*;\n" + |
vromero@1591 | 54 | "\n" + |
vromero@1591 | 55 | "public class ExtDirTest_1 {\n" + |
vromero@1591 | 56 | " ExtDirTestClass1 x;\n" + |
vromero@1591 | 57 | "}"; |
vromero@1591 | 58 | |
vromero@1591 | 59 | private static final String ExtDirTest_2Src = |
vromero@1591 | 60 | "import pkg1.*;\n" + |
vromero@1591 | 61 | "import pkg2.*;\n" + |
vromero@1591 | 62 | "\n" + |
vromero@1591 | 63 | "public class ExtDirTest_2 {\n" + |
vromero@1591 | 64 | " ExtDirTestClass1 x;\n" + |
vromero@1591 | 65 | " ExtDirTestClass2 y;\n" + |
vromero@1591 | 66 | "}"; |
vromero@1591 | 67 | |
vromero@1591 | 68 | private static final String ExtDirTest_3Src = |
vromero@1591 | 69 | "import pkg1.*;\n" + |
vromero@1591 | 70 | "import pkg2.*;\n" + |
vromero@1591 | 71 | "\n" + |
vromero@1591 | 72 | "public class ExtDirTest_3 {\n" + |
vromero@1591 | 73 | " ExtDirTestClass1 x;\n" + |
vromero@1591 | 74 | " ExtDirTestClass2 y;\n" + |
vromero@1591 | 75 | "}"; |
vromero@1591 | 76 | |
vromero@1591 | 77 | private static final String jar1Manifest = |
vromero@1591 | 78 | "Manifest-Version: 1.0\n" + |
vromero@1591 | 79 | "\n" + |
vromero@1591 | 80 | "Name: pkg1/ExtDirTestClass1.class\n" + |
vromero@1591 | 81 | "Digest-Algorithms: SHA MD5 \n" + |
vromero@1591 | 82 | "SHA-Digest: 9HEcO9LJmND3cvOlq/AbUsbD9S0=\n" + |
vromero@1591 | 83 | "MD5-Digest: hffPBwfqcUcnEdNv4PXu1Q==\n" + |
vromero@1591 | 84 | "\n" + |
vromero@1591 | 85 | "Name: pkg1/ExtDirTestClass1.java\n" + |
vromero@1591 | 86 | "Digest-Algorithms: SHA MD5 \n" + |
vromero@1591 | 87 | "SHA-Digest: 2FQVe6w3n2Ma1ACYpe8a988EBU8=\n" + |
vromero@1591 | 88 | "MD5-Digest: /Ivr4zVI9MSM26NmqWtZpQ==\n"; |
vromero@1591 | 89 | |
vromero@1591 | 90 | private static final String jar2Manifest = |
vromero@1591 | 91 | "Manifest-Version: 1.0\n" + |
vromero@1591 | 92 | "\n" + |
vromero@1591 | 93 | "Name: pkg2/ExtDirTestClass2.class\n" + |
vromero@1591 | 94 | "Digest-Algorithms: SHA MD5 \n" + |
vromero@1591 | 95 | "SHA-Digest: elbPaqWf8hjj1+ZkkdW3PGTsilo=\n" + |
vromero@1591 | 96 | "MD5-Digest: 57Nn0e2t1yEQfu/4kSw8yg==\n" + |
vromero@1591 | 97 | "\n" + |
vromero@1591 | 98 | "Name: pkg2/ExtDirTestClass2.java\n" + |
vromero@1591 | 99 | "Digest-Algorithms: SHA MD5 \n" + |
vromero@1591 | 100 | "SHA-Digest: ILJOhwHg5US+yuw1Sc1d+Avu628=\n" + |
vromero@1591 | 101 | "MD5-Digest: j8wnz8wneEcuJ/gjXBBQNA==\n"; |
vromero@1591 | 102 | |
vromero@1591 | 103 | List<String> ouputDirParam = Arrays.asList("-d", "."); |
vromero@1591 | 104 | |
vromero@1591 | 105 | public static void main(String args[]) throws Exception { |
vromero@1591 | 106 | new ExtDirTest().run(); |
vromero@1591 | 107 | } |
vromero@1591 | 108 | |
vromero@1591 | 109 | void run() throws Exception { |
vromero@1591 | 110 | createJars(); |
vromero@1591 | 111 | compileWithExtDirs(); |
vromero@1591 | 112 | } |
vromero@1591 | 113 | |
vromero@1591 | 114 | void createJars() throws Exception { |
vromero@1591 | 115 | sun.tools.jar.Main jarGenerator = |
vromero@1591 | 116 | new sun.tools.jar.Main(System.out, System.err, "jar"); |
vromero@1591 | 117 | |
vromero@1591 | 118 | ToolBox.JavaToolArgs javacParams = |
vromero@1591 | 119 | new ToolBox.JavaToolArgs() |
vromero@1591 | 120 | .setOptions(ouputDirParam) |
vromero@1591 | 121 | .setSources(ExtDirTestClass1Src); |
vromero@1591 | 122 | ToolBox.javac(javacParams); |
vromero@1591 | 123 | |
vromero@1591 | 124 | ToolBox.writeFile(Paths.get("pkg1", "MANIFEST.MF"), jar1Manifest); |
vromero@1591 | 125 | jarGenerator.run(new String[] {"cfm", "pkg1.jar", "pkg1/MANIFEST.MF", |
vromero@1591 | 126 | "pkg1/ExtDirTestClass1.class"}); |
vromero@1591 | 127 | |
vromero@1591 | 128 | javacParams.setSources(ExtDirTestClass2Src); |
vromero@1591 | 129 | ToolBox.javac(javacParams); |
vromero@1591 | 130 | |
vromero@1591 | 131 | ToolBox.writeFile(Paths.get("pkg2", "MANIFEST.MF"), jar2Manifest); |
vromero@1591 | 132 | jarGenerator.run(new String[] {"cfm", "pkg2.jar", "pkg2/MANIFEST.MF", |
vromero@1591 | 133 | "pkg2/ExtDirTestClass2.class"}); |
vromero@1591 | 134 | |
vromero@1591 | 135 | ToolBox.copyFile(Paths.get("ext1", "pkg1.jar"), Paths.get("pkg1.jar")); |
vromero@1591 | 136 | ToolBox.copyFile(Paths.get("ext2", "pkg2.jar"), Paths.get("pkg2.jar")); |
vromero@1591 | 137 | ToolBox.copyFile(Paths.get("ext3", "pkg1.jar"), Paths.get("pkg1.jar")); |
vromero@1591 | 138 | ToolBox.copyFile(Paths.get("ext3", "pkg2.jar"), Paths.get("pkg2.jar")); |
vromero@1591 | 139 | |
vromero@1591 | 140 | Files.delete(Paths.get("pkg1.jar")); |
vromero@1591 | 141 | Files.delete(Paths.get("pkg2.jar")); |
vromero@1591 | 142 | |
vromero@1591 | 143 | Files.delete(Paths.get("pkg1", "ExtDirTestClass1.class")); |
vromero@1591 | 144 | Files.delete(Paths.get("pkg1", "MANIFEST.MF")); |
vromero@1591 | 145 | Files.delete(Paths.get("pkg1")); |
vromero@1591 | 146 | Files.delete(Paths.get("pkg2", "ExtDirTestClass2.class")); |
vromero@1591 | 147 | Files.delete(Paths.get("pkg2", "MANIFEST.MF")); |
vromero@1591 | 148 | Files.delete(Paths.get("pkg2")); |
vromero@1591 | 149 | } |
vromero@1591 | 150 | |
vromero@1591 | 151 | void compileWithExtDirs() throws Exception { |
vromero@1591 | 152 | |
vromero@2173 | 153 | //javac -extdirs ext1 ExtDirTest_1.java |
vromero@1591 | 154 | ToolBox.JavaToolArgs params = |
vromero@1591 | 155 | new ToolBox.JavaToolArgs() |
vromero@1591 | 156 | .setOptions("-d", ".", "-extdirs", "ext1") |
vromero@1591 | 157 | .setSources(ExtDirTest_1Src); |
vromero@1591 | 158 | ToolBox.javac(params); |
vromero@1591 | 159 | |
vromero@2173 | 160 | //javac -extdirs ext1:ext2 ExtDirTest_2.java |
vromero@1591 | 161 | params.setOptions("-d", ".", "-extdirs", "ext1" + File.pathSeparator + "ext2") |
vromero@1591 | 162 | .setSources(ExtDirTest_2Src); |
vromero@1591 | 163 | ToolBox.javac(params); |
vromero@1591 | 164 | |
vromero@2173 | 165 | //javac -extdirs ext3 ExtDirTest_3.java |
vromero@1591 | 166 | params.setOptions("-d", ".", "-extdirs", "ext3") |
vromero@1591 | 167 | .setSources(ExtDirTest_3Src); |
vromero@1591 | 168 | ToolBox.javac(params); |
vromero@1591 | 169 | } |
vromero@1591 | 170 | |
vromero@1591 | 171 | } |