jdk

Форк
0
/
ModulesSymLink.java 
78 строк · 2.9 Кб
1
/*
2
 * Copyright (c) 2019, Google Inc. 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
 * @summary Test with symbolic linked lib/modules
27
 * @bug 8220095
28
 * @requires os.family == "linux" | os.family == "mac"
29
 * @requires vm.flagless
30
 * @library /test/lib
31
 * @modules java.management
32
 *          jdk.jlink
33
 * @run driver ModulesSymLink
34
 */
35

36
import java.io.File;
37
import java.nio.file.Files;
38
import java.nio.file.Path;
39
import java.nio.file.Paths;
40
import jdk.test.lib.process.ProcessTools;
41
import jdk.test.lib.process.OutputAnalyzer;
42

43
public class ModulesSymLink {
44
    static String java_home;
45
    static String test_jdk;
46

47
    public static void main(String[] args) throws Throwable {
48
        java_home = System.getProperty("java.home");
49
        test_jdk = System.getProperty("user.dir") + File.separator +
50
                   "modulessymlink_jdk" + Long.toString(System.currentTimeMillis());
51

52
        constructTestJDK();
53

54
        ProcessBuilder pb = new ProcessBuilder(
55
            test_jdk + File.separator + "bin" + File.separator + "java",
56
            "-version");
57
        OutputAnalyzer out = new OutputAnalyzer(pb.start());
58
        out.shouldHaveExitValue(0);
59
    }
60

61
    // 1) Create a test JDK binary (jlink is used to help simplify the process,
62
    //    alternatively a test JDK could be copied from JAVA_HOME.)
63
    // 2) Rename the test JDK's lib/modules to lib/0.
64
    // 3) Then create a link to lib/0 as lib/modules.
65
    static void constructTestJDK() throws Throwable {
66
        Path jlink = Paths.get(java_home, "bin", "jlink");
67
        System.out.println("Jlink = " + jlink);
68
        OutputAnalyzer out = ProcessTools.executeProcess(jlink.toString(),
69
                  "--output", test_jdk,
70
                  "--add-modules", "java.base");
71
        out.shouldHaveExitValue(0);
72

73
        Path modules = Paths.get(test_jdk, "lib", "modules");
74
        Path renamed_modules = Paths.get(test_jdk, "lib", "0");
75
        Files.move(modules, renamed_modules);
76
        Files.createSymbolicLink(modules, renamed_modules);
77
    }
78
}
79

Использование cookies

Мы используем файлы cookie в соответствии с Политикой конфиденциальности и Политикой использования cookies.

Нажимая кнопку «Принимаю», Вы даете АО «СберТех» согласие на обработку Ваших персональных данных в целях совершенствования нашего веб-сайта и Сервиса GitVerse, а также повышения удобства их использования.

Запретить использование cookies Вы можете самостоятельно в настройках Вашего браузера.