test/jdk/tools/jlink/JLinkTest.java
author sundar
Fri, 27 Oct 2017 08:21:53 +0530
changeset 47464 36de9c637393
parent 47216 71c04702a3d5
child 48663 b742e0f9ce80
permissions -rw-r--r--
8189777: jlink --module-path default value and automatic addition of $JAVA_HOME/jmods if java.base is missing Reviewed-by: alanb, mchung
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
36511
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
     1
/*
44367
a81c9c6619fb 8174826: jlink support for linking in service provider modules
mchung
parents: 43495
diff changeset
     2
 * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.
36511
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
     4
 *
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
     7
 * published by the Free Software Foundation.
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
     8
 *
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    13
 * accompanied this code).
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    14
 *
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    18
 *
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    21
 * questions.
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    22
 */
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    23
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    24
import java.io.IOException;
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    25
import java.io.PrintWriter;
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    26
import java.io.StringWriter;
39153
26b3cb81aac9 8153238: Improve test/tools/jlink/JLinkTest.java not to hard code the number of plugins
sundar
parents: 37893
diff changeset
    27
import java.lang.module.ModuleDescriptor;
36511
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    28
import java.nio.file.Files;
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    29
import java.nio.file.Path;
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    30
import java.nio.file.Paths;
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    31
import java.util.ArrayList;
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    32
import java.util.Collections;
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    33
import java.util.List;
41484
834b7539ada3 8164689: Retrofit jar, jlink, jmod as a ToolProvider
mchung
parents: 41352
diff changeset
    34
import java.util.spi.ToolProvider;
36511
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    35
import java.util.stream.Stream;
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    36
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    37
import jdk.tools.jlink.plugin.Plugin;
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    38
import jdk.tools.jlink.internal.PluginRepository;
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    39
import tests.Helper;
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    40
import tests.JImageGenerator;
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    41
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    42
/*
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    43
 * @test
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    44
 * @summary Test image creation
47464
36de9c637393 8189777: jlink --module-path default value and automatic addition of $JAVA_HOME/jmods if java.base is missing
sundar
parents: 47216
diff changeset
    45
 * @bug 8189777
36511
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    46
 * @author Jean-Francois Denise
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    47
 * @library ../lib
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    48
 * @modules java.base/jdk.internal.jimage
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    49
 *          jdk.jdeps/com.sun.tools.classfile
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    50
 *          jdk.jlink/jdk.tools.jlink.internal
43185
d75d9ff8d4e7 8171380: Remove all exports from jdk.jlink
chegar
parents: 42697
diff changeset
    51
 *          jdk.jlink/jdk.tools.jlink.plugin
36511
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    52
 *          jdk.jlink/jdk.tools.jimage
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    53
 *          jdk.compiler
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    54
 * @build tests.*
39304
8d9ceb81a46e 8160346: JLinkTest.java should compute exact number of plugins from jdk.jlink module
sundar
parents: 39153
diff changeset
    55
 * @run main/othervm -Xmx1g JLinkTest
36511
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    56
 */
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    57
public class JLinkTest {
41484
834b7539ada3 8164689: Retrofit jar, jlink, jmod as a ToolProvider
mchung
parents: 41352
diff changeset
    58
    static final ToolProvider JLINK_TOOL = ToolProvider.findFirst("jlink")
834b7539ada3 8164689: Retrofit jar, jlink, jmod as a ToolProvider
mchung
parents: 41352
diff changeset
    59
        .orElseThrow(() ->
834b7539ada3 8164689: Retrofit jar, jlink, jmod as a ToolProvider
mchung
parents: 41352
diff changeset
    60
            new RuntimeException("jlink tool not found")
834b7539ada3 8164689: Retrofit jar, jlink, jmod as a ToolProvider
mchung
parents: 41352
diff changeset
    61
        );
834b7539ada3 8164689: Retrofit jar, jlink, jmod as a ToolProvider
mchung
parents: 41352
diff changeset
    62
39153
26b3cb81aac9 8153238: Improve test/tools/jlink/JLinkTest.java not to hard code the number of plugins
sundar
parents: 37893
diff changeset
    63
    // number of built-in plugins from jdk.jlink module
26b3cb81aac9 8153238: Improve test/tools/jlink/JLinkTest.java not to hard code the number of plugins
sundar
parents: 37893
diff changeset
    64
    private static int getNumJlinkPlugins() {
26b3cb81aac9 8153238: Improve test/tools/jlink/JLinkTest.java not to hard code the number of plugins
sundar
parents: 37893
diff changeset
    65
        ModuleDescriptor desc = Plugin.class.getModule().getDescriptor();
42338
a60f280f803c 8169069: Module system implementation refresh (11/2016)
alanb
parents: 41766
diff changeset
    66
        return desc.provides().stream()
a60f280f803c 8169069: Module system implementation refresh (11/2016)
alanb
parents: 41766
diff changeset
    67
                .filter(p -> p.service().equals(Plugin.class.getName()))
a60f280f803c 8169069: Module system implementation refresh (11/2016)
alanb
parents: 41766
diff changeset
    68
                .map(p -> p.providers().size())
a60f280f803c 8169069: Module system implementation refresh (11/2016)
alanb
parents: 41766
diff changeset
    69
                .findAny()
a60f280f803c 8169069: Module system implementation refresh (11/2016)
alanb
parents: 41766
diff changeset
    70
                .orElse(0);
39153
26b3cb81aac9 8153238: Improve test/tools/jlink/JLinkTest.java not to hard code the number of plugins
sundar
parents: 37893
diff changeset
    71
    }
36511
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    72
39304
8d9ceb81a46e 8160346: JLinkTest.java should compute exact number of plugins from jdk.jlink module
sundar
parents: 39153
diff changeset
    73
    private static boolean isOfJLinkModule(Plugin p) {
8d9ceb81a46e 8160346: JLinkTest.java should compute exact number of plugins from jdk.jlink module
sundar
parents: 39153
diff changeset
    74
        return p.getClass().getModule() == Plugin.class.getModule();
8d9ceb81a46e 8160346: JLinkTest.java should compute exact number of plugins from jdk.jlink module
sundar
parents: 39153
diff changeset
    75
    }
8d9ceb81a46e 8160346: JLinkTest.java should compute exact number of plugins from jdk.jlink module
sundar
parents: 39153
diff changeset
    76
36511
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    77
    public static void main(String[] args) throws Exception {
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    78
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    79
        Helper helper = Helper.newHelper();
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    80
        if (helper == null) {
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    81
            System.err.println("Test not run");
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    82
            return;
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    83
        }
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    84
        helper.generateDefaultModules();
39304
8d9ceb81a46e 8160346: JLinkTest.java should compute exact number of plugins from jdk.jlink module
sundar
parents: 39153
diff changeset
    85
        // expected num. of plugins from jdk.jlink module
8d9ceb81a46e 8160346: JLinkTest.java should compute exact number of plugins from jdk.jlink module
sundar
parents: 39153
diff changeset
    86
        int expectedJLinkPlugins = getNumJlinkPlugins();
8d9ceb81a46e 8160346: JLinkTest.java should compute exact number of plugins from jdk.jlink module
sundar
parents: 39153
diff changeset
    87
        int totalPlugins = 0;
36511
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    88
        {
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    89
            // number of built-in plugins
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    90
            List<Plugin> builtInPlugins = new ArrayList<>();
44545
83b611b88ac8 8177530: Module system implementation refresh (4/2017)
alanb
parents: 44367
diff changeset
    91
            builtInPlugins.addAll(PluginRepository.getPlugins(ModuleLayer.boot()));
39304
8d9ceb81a46e 8160346: JLinkTest.java should compute exact number of plugins from jdk.jlink module
sundar
parents: 39153
diff changeset
    92
            totalPlugins = builtInPlugins.size();
8d9ceb81a46e 8160346: JLinkTest.java should compute exact number of plugins from jdk.jlink module
sundar
parents: 39153
diff changeset
    93
            // actual num. of plugins loaded from jdk.jlink module
8d9ceb81a46e 8160346: JLinkTest.java should compute exact number of plugins from jdk.jlink module
sundar
parents: 39153
diff changeset
    94
            int actualJLinkPlugins = 0;
36511
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    95
            for (Plugin p : builtInPlugins) {
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    96
                p.getState();
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    97
                p.getType();
39304
8d9ceb81a46e 8160346: JLinkTest.java should compute exact number of plugins from jdk.jlink module
sundar
parents: 39153
diff changeset
    98
                if (isOfJLinkModule(p)) {
8d9ceb81a46e 8160346: JLinkTest.java should compute exact number of plugins from jdk.jlink module
sundar
parents: 39153
diff changeset
    99
                    actualJLinkPlugins++;
8d9ceb81a46e 8160346: JLinkTest.java should compute exact number of plugins from jdk.jlink module
sundar
parents: 39153
diff changeset
   100
                }
36511
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   101
            }
39304
8d9ceb81a46e 8160346: JLinkTest.java should compute exact number of plugins from jdk.jlink module
sundar
parents: 39153
diff changeset
   102
            if (expectedJLinkPlugins != actualJLinkPlugins) {
8d9ceb81a46e 8160346: JLinkTest.java should compute exact number of plugins from jdk.jlink module
sundar
parents: 39153
diff changeset
   103
                throw new AssertionError("Actual plugins loaded from jdk.jlink: " +
8d9ceb81a46e 8160346: JLinkTest.java should compute exact number of plugins from jdk.jlink module
sundar
parents: 39153
diff changeset
   104
                        actualJLinkPlugins + " which doesn't match expected number : " +
8d9ceb81a46e 8160346: JLinkTest.java should compute exact number of plugins from jdk.jlink module
sundar
parents: 39153
diff changeset
   105
                        expectedJLinkPlugins);
36511
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   106
            }
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   107
        }
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   108
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   109
        {
47464
36de9c637393 8189777: jlink --module-path default value and automatic addition of $JAVA_HOME/jmods if java.base is missing
sundar
parents: 47216
diff changeset
   110
            // No --module-path specified. $JAVA_HOME/jmods should be assumed.
36de9c637393 8189777: jlink --module-path default value and automatic addition of $JAVA_HOME/jmods if java.base is missing
sundar
parents: 47216
diff changeset
   111
            // The following should succeed as it uses only system modules.
36de9c637393 8189777: jlink --module-path default value and automatic addition of $JAVA_HOME/jmods if java.base is missing
sundar
parents: 47216
diff changeset
   112
            String imageDir = "bug818977-no-modulepath";
36de9c637393 8189777: jlink --module-path default value and automatic addition of $JAVA_HOME/jmods if java.base is missing
sundar
parents: 47216
diff changeset
   113
            JImageGenerator.getJLinkTask()
36de9c637393 8189777: jlink --module-path default value and automatic addition of $JAVA_HOME/jmods if java.base is missing
sundar
parents: 47216
diff changeset
   114
                    .output(helper.createNewImageDir(imageDir))
36de9c637393 8189777: jlink --module-path default value and automatic addition of $JAVA_HOME/jmods if java.base is missing
sundar
parents: 47216
diff changeset
   115
                    .addMods("jdk.scripting.nashorn")
36de9c637393 8189777: jlink --module-path default value and automatic addition of $JAVA_HOME/jmods if java.base is missing
sundar
parents: 47216
diff changeset
   116
                    .call().assertSuccess();
36de9c637393 8189777: jlink --module-path default value and automatic addition of $JAVA_HOME/jmods if java.base is missing
sundar
parents: 47216
diff changeset
   117
        }
36de9c637393 8189777: jlink --module-path default value and automatic addition of $JAVA_HOME/jmods if java.base is missing
sundar
parents: 47216
diff changeset
   118
36de9c637393 8189777: jlink --module-path default value and automatic addition of $JAVA_HOME/jmods if java.base is missing
sundar
parents: 47216
diff changeset
   119
        {
36de9c637393 8189777: jlink --module-path default value and automatic addition of $JAVA_HOME/jmods if java.base is missing
sundar
parents: 47216
diff changeset
   120
            // invalid --module-path specified. java.base not found it it.
36de9c637393 8189777: jlink --module-path default value and automatic addition of $JAVA_HOME/jmods if java.base is missing
sundar
parents: 47216
diff changeset
   121
            // $JAVA_HOME/jmods should be added automatically.
36de9c637393 8189777: jlink --module-path default value and automatic addition of $JAVA_HOME/jmods if java.base is missing
sundar
parents: 47216
diff changeset
   122
            // The following should succeed as it uses only system modules.
36de9c637393 8189777: jlink --module-path default value and automatic addition of $JAVA_HOME/jmods if java.base is missing
sundar
parents: 47216
diff changeset
   123
            String imageDir = "bug8189777-invalid-modulepath";
36de9c637393 8189777: jlink --module-path default value and automatic addition of $JAVA_HOME/jmods if java.base is missing
sundar
parents: 47216
diff changeset
   124
            JImageGenerator.getJLinkTask()
36de9c637393 8189777: jlink --module-path default value and automatic addition of $JAVA_HOME/jmods if java.base is missing
sundar
parents: 47216
diff changeset
   125
                    .modulePath("does_not_exist_path")
36de9c637393 8189777: jlink --module-path default value and automatic addition of $JAVA_HOME/jmods if java.base is missing
sundar
parents: 47216
diff changeset
   126
                    .output(helper.createNewImageDir(imageDir))
36de9c637393 8189777: jlink --module-path default value and automatic addition of $JAVA_HOME/jmods if java.base is missing
sundar
parents: 47216
diff changeset
   127
                    .addMods("jdk.scripting.nashorn")
36de9c637393 8189777: jlink --module-path default value and automatic addition of $JAVA_HOME/jmods if java.base is missing
sundar
parents: 47216
diff changeset
   128
                    .call().assertSuccess();
36de9c637393 8189777: jlink --module-path default value and automatic addition of $JAVA_HOME/jmods if java.base is missing
sundar
parents: 47216
diff changeset
   129
        }
36de9c637393 8189777: jlink --module-path default value and automatic addition of $JAVA_HOME/jmods if java.base is missing
sundar
parents: 47216
diff changeset
   130
36de9c637393 8189777: jlink --module-path default value and automatic addition of $JAVA_HOME/jmods if java.base is missing
sundar
parents: 47216
diff changeset
   131
        {
36de9c637393 8189777: jlink --module-path default value and automatic addition of $JAVA_HOME/jmods if java.base is missing
sundar
parents: 47216
diff changeset
   132
            // No --module-path specified. --add-modules ALL-MODULE-PATH specified.
36de9c637393 8189777: jlink --module-path default value and automatic addition of $JAVA_HOME/jmods if java.base is missing
sundar
parents: 47216
diff changeset
   133
            String imageDir = "bug8189777-all-module-path";
36de9c637393 8189777: jlink --module-path default value and automatic addition of $JAVA_HOME/jmods if java.base is missing
sundar
parents: 47216
diff changeset
   134
            JImageGenerator.getJLinkTask()
36de9c637393 8189777: jlink --module-path default value and automatic addition of $JAVA_HOME/jmods if java.base is missing
sundar
parents: 47216
diff changeset
   135
                    .output(helper.createNewImageDir(imageDir))
36de9c637393 8189777: jlink --module-path default value and automatic addition of $JAVA_HOME/jmods if java.base is missing
sundar
parents: 47216
diff changeset
   136
                    .addMods("ALL-MODULE-PATH")
36de9c637393 8189777: jlink --module-path default value and automatic addition of $JAVA_HOME/jmods if java.base is missing
sundar
parents: 47216
diff changeset
   137
                    .call().assertSuccess();
36de9c637393 8189777: jlink --module-path default value and automatic addition of $JAVA_HOME/jmods if java.base is missing
sundar
parents: 47216
diff changeset
   138
        }
36de9c637393 8189777: jlink --module-path default value and automatic addition of $JAVA_HOME/jmods if java.base is missing
sundar
parents: 47216
diff changeset
   139
36de9c637393 8189777: jlink --module-path default value and automatic addition of $JAVA_HOME/jmods if java.base is missing
sundar
parents: 47216
diff changeset
   140
        {
36511
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   141
            String moduleName = "bug8134651";
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   142
            JImageGenerator.getJLinkTask()
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   143
                    .modulePath(helper.defaultModulePath())
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   144
                    .output(helper.createNewImageDir(moduleName))
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   145
                    .addMods("leaf1")
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   146
                    .call().assertSuccess();
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   147
            JImageGenerator.getJLinkTask()
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   148
                    .modulePath(helper.defaultModulePath())
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   149
                    .addMods("leaf1")
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   150
                    .option("--output")
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   151
                    .call().assertFailure("Error: no value given for --output");
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   152
            JImageGenerator.getJLinkTask()
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   153
                    .modulePath("")
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   154
                    .output(helper.createNewImageDir(moduleName))
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   155
                    .addMods("leaf1")
40261
86a49ba76f52 8136930: Simplify use of module-system options by custom launchers
mchung
parents: 40209
diff changeset
   156
                    .call().assertFailure("Error: no value given for --module-path");
47464
36de9c637393 8189777: jlink --module-path default value and automatic addition of $JAVA_HOME/jmods if java.base is missing
sundar
parents: 47216
diff changeset
   157
            // do not include standard module path - should be added automatically
36de9c637393 8189777: jlink --module-path default value and automatic addition of $JAVA_HOME/jmods if java.base is missing
sundar
parents: 47216
diff changeset
   158
            JImageGenerator.getJLinkTask()
36de9c637393 8189777: jlink --module-path default value and automatic addition of $JAVA_HOME/jmods if java.base is missing
sundar
parents: 47216
diff changeset
   159
                    .modulePath(helper.defaultModulePath(false))
36de9c637393 8189777: jlink --module-path default value and automatic addition of $JAVA_HOME/jmods if java.base is missing
sundar
parents: 47216
diff changeset
   160
                    .output(helper.createNewImageDir(moduleName))
36de9c637393 8189777: jlink --module-path default value and automatic addition of $JAVA_HOME/jmods if java.base is missing
sundar
parents: 47216
diff changeset
   161
                    .addMods("leaf1")
36de9c637393 8189777: jlink --module-path default value and automatic addition of $JAVA_HOME/jmods if java.base is missing
sundar
parents: 47216
diff changeset
   162
                    .call().assertSuccess();
36de9c637393 8189777: jlink --module-path default value and automatic addition of $JAVA_HOME/jmods if java.base is missing
sundar
parents: 47216
diff changeset
   163
            // no --module-path. default sys mod path is assumed - but that won't contain 'leaf1' module
36de9c637393 8189777: jlink --module-path default value and automatic addition of $JAVA_HOME/jmods if java.base is missing
sundar
parents: 47216
diff changeset
   164
            JImageGenerator.getJLinkTask()
36de9c637393 8189777: jlink --module-path default value and automatic addition of $JAVA_HOME/jmods if java.base is missing
sundar
parents: 47216
diff changeset
   165
                    .output(helper.createNewImageDir(moduleName))
36de9c637393 8189777: jlink --module-path default value and automatic addition of $JAVA_HOME/jmods if java.base is missing
sundar
parents: 47216
diff changeset
   166
                    .addMods("leaf1")
36de9c637393 8189777: jlink --module-path default value and automatic addition of $JAVA_HOME/jmods if java.base is missing
sundar
parents: 47216
diff changeset
   167
                    .call().assertFailure("Error: Module leaf1 not found");
36511
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   168
        }
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   169
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   170
        {
40209
68e8944f4424 8163382: ResourcePoolManager.findEntry has a bug in startsWith call
sundar
parents: 39321
diff changeset
   171
            String moduleName = "m"; // 8163382
68e8944f4424 8163382: ResourcePoolManager.findEntry has a bug in startsWith call
sundar
parents: 39321
diff changeset
   172
            Path jmod = helper.generateDefaultJModule(moduleName).assertSuccess();
68e8944f4424 8163382: ResourcePoolManager.findEntry has a bug in startsWith call
sundar
parents: 39321
diff changeset
   173
            JImageGenerator.getJLinkTask()
68e8944f4424 8163382: ResourcePoolManager.findEntry has a bug in startsWith call
sundar
parents: 39321
diff changeset
   174
                    .modulePath(helper.defaultModulePath())
68e8944f4424 8163382: ResourcePoolManager.findEntry has a bug in startsWith call
sundar
parents: 39321
diff changeset
   175
                    .output(helper.createNewImageDir(moduleName))
68e8944f4424 8163382: ResourcePoolManager.findEntry has a bug in startsWith call
sundar
parents: 39321
diff changeset
   176
                    .addMods("m")
68e8944f4424 8163382: ResourcePoolManager.findEntry has a bug in startsWith call
sundar
parents: 39321
diff changeset
   177
                    .call().assertSuccess();
68e8944f4424 8163382: ResourcePoolManager.findEntry has a bug in startsWith call
sundar
parents: 39321
diff changeset
   178
            moduleName = "mod";
68e8944f4424 8163382: ResourcePoolManager.findEntry has a bug in startsWith call
sundar
parents: 39321
diff changeset
   179
            jmod = helper.generateDefaultJModule(moduleName).assertSuccess();
68e8944f4424 8163382: ResourcePoolManager.findEntry has a bug in startsWith call
sundar
parents: 39321
diff changeset
   180
            JImageGenerator.getJLinkTask()
68e8944f4424 8163382: ResourcePoolManager.findEntry has a bug in startsWith call
sundar
parents: 39321
diff changeset
   181
                    .modulePath(helper.defaultModulePath())
68e8944f4424 8163382: ResourcePoolManager.findEntry has a bug in startsWith call
sundar
parents: 39321
diff changeset
   182
                    .output(helper.createNewImageDir(moduleName))
68e8944f4424 8163382: ResourcePoolManager.findEntry has a bug in startsWith call
sundar
parents: 39321
diff changeset
   183
                    .addMods("m")
68e8944f4424 8163382: ResourcePoolManager.findEntry has a bug in startsWith call
sundar
parents: 39321
diff changeset
   184
                    .call().assertSuccess();
68e8944f4424 8163382: ResourcePoolManager.findEntry has a bug in startsWith call
sundar
parents: 39321
diff changeset
   185
        }
68e8944f4424 8163382: ResourcePoolManager.findEntry has a bug in startsWith call
sundar
parents: 39321
diff changeset
   186
68e8944f4424 8163382: ResourcePoolManager.findEntry has a bug in startsWith call
sundar
parents: 39321
diff changeset
   187
        {
41212
54a8bb41b174 8165735: jlink incorrectly accepts multiple --module-path and --limit-modules options
sundar
parents: 40261
diff changeset
   188
            String moduleName = "m_8165735"; // JDK-8165735
54a8bb41b174 8165735: jlink incorrectly accepts multiple --module-path and --limit-modules options
sundar
parents: 40261
diff changeset
   189
            helper.generateDefaultJModule(moduleName+"dependency").assertSuccess();
54a8bb41b174 8165735: jlink incorrectly accepts multiple --module-path and --limit-modules options
sundar
parents: 40261
diff changeset
   190
            Path jmod = helper.generateDefaultJModule(moduleName, moduleName+"dependency").assertSuccess();
54a8bb41b174 8165735: jlink incorrectly accepts multiple --module-path and --limit-modules options
sundar
parents: 40261
diff changeset
   191
            JImageGenerator.getJLinkTask()
54a8bb41b174 8165735: jlink incorrectly accepts multiple --module-path and --limit-modules options
sundar
parents: 40261
diff changeset
   192
                    .modulePath(helper.defaultModulePath())
54a8bb41b174 8165735: jlink incorrectly accepts multiple --module-path and --limit-modules options
sundar
parents: 40261
diff changeset
   193
                    .repeatedModulePath(".") // second --module-path overrides the first one
54a8bb41b174 8165735: jlink incorrectly accepts multiple --module-path and --limit-modules options
sundar
parents: 40261
diff changeset
   194
                    .output(helper.createNewImageDir(moduleName))
54a8bb41b174 8165735: jlink incorrectly accepts multiple --module-path and --limit-modules options
sundar
parents: 40261
diff changeset
   195
                    .addMods(moduleName)
54a8bb41b174 8165735: jlink incorrectly accepts multiple --module-path and --limit-modules options
sundar
parents: 40261
diff changeset
   196
                    // second --module-path does not have that module
54a8bb41b174 8165735: jlink incorrectly accepts multiple --module-path and --limit-modules options
sundar
parents: 40261
diff changeset
   197
                    .call().assertFailure("Error: Module m_8165735 not found");
54a8bb41b174 8165735: jlink incorrectly accepts multiple --module-path and --limit-modules options
sundar
parents: 40261
diff changeset
   198
54a8bb41b174 8165735: jlink incorrectly accepts multiple --module-path and --limit-modules options
sundar
parents: 40261
diff changeset
   199
            JImageGenerator.getJLinkTask()
54a8bb41b174 8165735: jlink incorrectly accepts multiple --module-path and --limit-modules options
sundar
parents: 40261
diff changeset
   200
                    .modulePath(".") // first --module-path overridden later
54a8bb41b174 8165735: jlink incorrectly accepts multiple --module-path and --limit-modules options
sundar
parents: 40261
diff changeset
   201
                    .repeatedModulePath(helper.defaultModulePath())
54a8bb41b174 8165735: jlink incorrectly accepts multiple --module-path and --limit-modules options
sundar
parents: 40261
diff changeset
   202
                    .output(helper.createNewImageDir(moduleName))
54a8bb41b174 8165735: jlink incorrectly accepts multiple --module-path and --limit-modules options
sundar
parents: 40261
diff changeset
   203
                    .addMods(moduleName)
54a8bb41b174 8165735: jlink incorrectly accepts multiple --module-path and --limit-modules options
sundar
parents: 40261
diff changeset
   204
                    // second --module-path has that module
54a8bb41b174 8165735: jlink incorrectly accepts multiple --module-path and --limit-modules options
sundar
parents: 40261
diff changeset
   205
                    .call().assertSuccess();
54a8bb41b174 8165735: jlink incorrectly accepts multiple --module-path and --limit-modules options
sundar
parents: 40261
diff changeset
   206
54a8bb41b174 8165735: jlink incorrectly accepts multiple --module-path and --limit-modules options
sundar
parents: 40261
diff changeset
   207
            JImageGenerator.getJLinkTask()
54a8bb41b174 8165735: jlink incorrectly accepts multiple --module-path and --limit-modules options
sundar
parents: 40261
diff changeset
   208
                    .modulePath(helper.defaultModulePath())
54a8bb41b174 8165735: jlink incorrectly accepts multiple --module-path and --limit-modules options
sundar
parents: 40261
diff changeset
   209
                    .output(helper.createNewImageDir(moduleName))
54a8bb41b174 8165735: jlink incorrectly accepts multiple --module-path and --limit-modules options
sundar
parents: 40261
diff changeset
   210
                    .limitMods(moduleName)
54a8bb41b174 8165735: jlink incorrectly accepts multiple --module-path and --limit-modules options
sundar
parents: 40261
diff changeset
   211
                    .repeatedLimitMods("java.base") // second --limit-modules overrides first
54a8bb41b174 8165735: jlink incorrectly accepts multiple --module-path and --limit-modules options
sundar
parents: 40261
diff changeset
   212
                    .addMods(moduleName)
54a8bb41b174 8165735: jlink incorrectly accepts multiple --module-path and --limit-modules options
sundar
parents: 40261
diff changeset
   213
                    .call().assertFailure("Error: Module m_8165735dependency not found, required by m_8165735");
54a8bb41b174 8165735: jlink incorrectly accepts multiple --module-path and --limit-modules options
sundar
parents: 40261
diff changeset
   214
54a8bb41b174 8165735: jlink incorrectly accepts multiple --module-path and --limit-modules options
sundar
parents: 40261
diff changeset
   215
            JImageGenerator.getJLinkTask()
54a8bb41b174 8165735: jlink incorrectly accepts multiple --module-path and --limit-modules options
sundar
parents: 40261
diff changeset
   216
                    .modulePath(helper.defaultModulePath())
54a8bb41b174 8165735: jlink incorrectly accepts multiple --module-path and --limit-modules options
sundar
parents: 40261
diff changeset
   217
                    .output(helper.createNewImageDir(moduleName))
54a8bb41b174 8165735: jlink incorrectly accepts multiple --module-path and --limit-modules options
sundar
parents: 40261
diff changeset
   218
                    .limitMods("java.base")
54a8bb41b174 8165735: jlink incorrectly accepts multiple --module-path and --limit-modules options
sundar
parents: 40261
diff changeset
   219
                    .repeatedLimitMods(moduleName) // second --limit-modules overrides first
54a8bb41b174 8165735: jlink incorrectly accepts multiple --module-path and --limit-modules options
sundar
parents: 40261
diff changeset
   220
                    .addMods(moduleName)
54a8bb41b174 8165735: jlink incorrectly accepts multiple --module-path and --limit-modules options
sundar
parents: 40261
diff changeset
   221
                    .call().assertSuccess();
54a8bb41b174 8165735: jlink incorrectly accepts multiple --module-path and --limit-modules options
sundar
parents: 40261
diff changeset
   222
        }
54a8bb41b174 8165735: jlink incorrectly accepts multiple --module-path and --limit-modules options
sundar
parents: 40261
diff changeset
   223
54a8bb41b174 8165735: jlink incorrectly accepts multiple --module-path and --limit-modules options
sundar
parents: 40261
diff changeset
   224
        {
36511
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   225
            // Help
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   226
            StringWriter writer = new StringWriter();
41484
834b7539ada3 8164689: Retrofit jar, jlink, jmod as a ToolProvider
mchung
parents: 41352
diff changeset
   227
            PrintWriter pw = new PrintWriter(writer);
834b7539ada3 8164689: Retrofit jar, jlink, jmod as a ToolProvider
mchung
parents: 41352
diff changeset
   228
            JLINK_TOOL.run(pw, pw, "--help");
36511
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   229
            String output = writer.toString();
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   230
            if (output.split("\n").length < 10) {
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   231
                System.err.println(output);
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   232
                throw new AssertionError("Help");
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   233
            }
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   234
        }
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   235
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   236
        {
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   237
            // List plugins
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   238
            StringWriter writer = new StringWriter();
41484
834b7539ada3 8164689: Retrofit jar, jlink, jmod as a ToolProvider
mchung
parents: 41352
diff changeset
   239
            PrintWriter pw = new PrintWriter(writer);
834b7539ada3 8164689: Retrofit jar, jlink, jmod as a ToolProvider
mchung
parents: 41352
diff changeset
   240
834b7539ada3 8164689: Retrofit jar, jlink, jmod as a ToolProvider
mchung
parents: 41352
diff changeset
   241
            JLINK_TOOL.run(pw, pw, "--list-plugins");
36511
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   242
            String output = writer.toString();
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   243
            long number = Stream.of(output.split("\\R"))
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   244
                    .filter((s) -> s.matches("Plugin Name:.*"))
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   245
                    .count();
39304
8d9ceb81a46e 8160346: JLinkTest.java should compute exact number of plugins from jdk.jlink module
sundar
parents: 39153
diff changeset
   246
            if (number != totalPlugins) {
36511
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   247
                System.err.println(output);
39304
8d9ceb81a46e 8160346: JLinkTest.java should compute exact number of plugins from jdk.jlink module
sundar
parents: 39153
diff changeset
   248
                throw new AssertionError("Found: " + number + " expected " + totalPlugins);
36511
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   249
            }
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   250
        }
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   251
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   252
        // filter out files and resources + Skip debug + compress
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   253
        {
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   254
            String[] userOptions = {"--compress", "2", "--strip-debug",
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   255
                "--exclude-resources", "*.jcov, */META-INF/*", "--exclude-files",
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   256
                "*" + Helper.getDebugSymbolsExtension()};
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   257
            String moduleName = "excludezipskipdebugcomposite2";
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   258
            helper.generateDefaultJModule(moduleName, "composite2");
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   259
            String[] res = {".jcov", "/META-INF/"};
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   260
            String[] files = {Helper.getDebugSymbolsExtension()};
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   261
            Path imageDir = helper.generateDefaultImage(userOptions, moduleName).assertSuccess();
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   262
            helper.checkImage(imageDir, moduleName, res, files);
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   263
        }
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   264
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   265
        // filter out + Skip debug + compress with filter + sort resources
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   266
        {
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   267
            String[] userOptions2 = {"--compress=2:compress-filter=^/java.base/*",
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   268
                "--strip-debug", "--exclude-resources",
37893
f1cc7d17e66b 8156781: change to jlink has result in test failure
jlaskey
parents: 37779
diff changeset
   269
                "*.jcov, */META-INF/*", "--order-resources",
36511
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   270
                "*/module-info.class,/sortcomposite2/*,*/javax/management/*"};
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   271
            String moduleName = "excludezipfilterskipdebugcomposite2";
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   272
            helper.generateDefaultJModule(moduleName, "composite2");
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   273
            String[] res = {".jcov", "/META-INF/"};
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   274
            Path imageDir = helper.generateDefaultImage(userOptions2, moduleName).assertSuccess();
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   275
            helper.checkImage(imageDir, moduleName, res, null);
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   276
        }
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   277
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   278
        // default compress
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   279
        {
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   280
            testCompress(helper, "compresscmdcomposite2", "--compress", "2");
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   281
        }
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   282
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   283
        {
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   284
            testCompress(helper, "compressfiltercmdcomposite2",
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   285
                    "--compress=2:filter=^/java.base/java/lang/*");
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   286
        }
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   287
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   288
        // compress 0
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   289
        {
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   290
            testCompress(helper, "compress0filtercmdcomposite2",
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   291
                    "--compress=0:filter=^/java.base/java/lang/*");
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   292
        }
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   293
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   294
        // compress 1
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   295
        {
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   296
            testCompress(helper, "compress1filtercmdcomposite2",
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   297
                    "--compress=1:filter=^/java.base/java/lang/*");
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   298
        }
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   299
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   300
        // compress 2
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   301
        {
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   302
            testCompress(helper, "compress2filtercmdcomposite2",
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   303
                    "--compress=2:filter=^/java.base/java/lang/*");
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   304
        }
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   305
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   306
        // invalid compress level
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   307
        {
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   308
            String[] userOptions = {"--compress", "invalid"};
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   309
            String moduleName = "invalidCompressLevel";
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   310
            helper.generateDefaultJModule(moduleName, "composite2");
37779
7c84df693837 8154956: Module system implementation refresh (4/2016)
alanb
parents: 36757
diff changeset
   311
            helper.generateDefaultImage(userOptions, moduleName).assertFailure("Error: Invalid compression level invalid");
36511
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   312
        }
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   313
41766
b5eab76a23a9 8166810: jlink should fail on extra arguments
sundar
parents: 41484
diff changeset
   314
        // orphan argument - JDK-8166810
36511
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   315
        {
41766
b5eab76a23a9 8166810: jlink should fail on extra arguments
sundar
parents: 41484
diff changeset
   316
            String[] userOptions = {"--compress", "2", "foo" };
b5eab76a23a9 8166810: jlink should fail on extra arguments
sundar
parents: 41484
diff changeset
   317
            String moduleName = "orphanarg1";
36511
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   318
            helper.generateDefaultJModule(moduleName, "composite2");
44367
a81c9c6619fb 8174826: jlink support for linking in service provider modules
mchung
parents: 43495
diff changeset
   319
            helper.generateDefaultImage(userOptions, moduleName).assertFailure("Error: invalid argument: foo");
36511
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   320
        }
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   321
41766
b5eab76a23a9 8166810: jlink should fail on extra arguments
sundar
parents: 41484
diff changeset
   322
        // orphan argument - JDK-8166810
b5eab76a23a9 8166810: jlink should fail on extra arguments
sundar
parents: 41484
diff changeset
   323
        {
b5eab76a23a9 8166810: jlink should fail on extra arguments
sundar
parents: 41484
diff changeset
   324
            String[] userOptions = {"--output", "foo", "bar" };
b5eab76a23a9 8166810: jlink should fail on extra arguments
sundar
parents: 41484
diff changeset
   325
            String moduleName = "orphanarg2";
b5eab76a23a9 8166810: jlink should fail on extra arguments
sundar
parents: 41484
diff changeset
   326
            helper.generateDefaultJModule(moduleName, "composite2");
44367
a81c9c6619fb 8174826: jlink support for linking in service provider modules
mchung
parents: 43495
diff changeset
   327
            helper.generateDefaultImage(userOptions, moduleName).assertFailure("Error: invalid argument: bar");
41766
b5eab76a23a9 8166810: jlink should fail on extra arguments
sundar
parents: 41484
diff changeset
   328
        }
43495
8255aabd0e09 8173717: jlink --help fails with missing "plugin.opt.plugin-module-path" key in resource bundle
sundar
parents: 43185
diff changeset
   329
8255aabd0e09 8173717: jlink --help fails with missing "plugin.opt.plugin-module-path" key in resource bundle
sundar
parents: 43185
diff changeset
   330
        // basic check for --help - JDK-8173717
8255aabd0e09 8173717: jlink --help fails with missing "plugin.opt.plugin-module-path" key in resource bundle
sundar
parents: 43185
diff changeset
   331
        {
8255aabd0e09 8173717: jlink --help fails with missing "plugin.opt.plugin-module-path" key in resource bundle
sundar
parents: 43185
diff changeset
   332
            JImageGenerator.getJLinkTask()
8255aabd0e09 8173717: jlink --help fails with missing "plugin.opt.plugin-module-path" key in resource bundle
sundar
parents: 43185
diff changeset
   333
                    .option("--help")
8255aabd0e09 8173717: jlink --help fails with missing "plugin.opt.plugin-module-path" key in resource bundle
sundar
parents: 43185
diff changeset
   334
                    .call().assertSuccess();
8255aabd0e09 8173717: jlink --help fails with missing "plugin.opt.plugin-module-path" key in resource bundle
sundar
parents: 43185
diff changeset
   335
        }
36511
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   336
    }
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   337
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   338
    private static void testCompress(Helper helper, String moduleName, String... userOptions) throws IOException {
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   339
        helper.generateDefaultJModule(moduleName, "composite2");
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   340
        Path imageDir = helper.generateDefaultImage(userOptions, moduleName).assertSuccess();
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   341
        helper.checkImage(imageDir, moduleName, null, null);
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   342
    }
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   343
}