test/jdk/tools/jlink/JLinkPluginsTest.java
author phh
Sat, 30 Nov 2019 14:33:05 -0800
changeset 59330 5b96c12f909d
parent 50060 06d5b1f66553
permissions -rw-r--r--
8234541: C1 emits an empty message when it inlines successfully Summary: Use "inline" as the message when successfull Reviewed-by: thartmann, mdoerr Contributed-by: navy.xliu@gmail.com
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
36511
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
     1
/*
48663
b742e0f9ce80 8161348: Several tools/jlink tests failed in "-Xcomp" mode due to time out
anazarov
parents: 47216
diff changeset
     2
 * Copyright (c) 2015, 2018, 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.nio.file.Files;
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    26
import java.nio.file.Path;
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    27
import java.nio.file.Paths;
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    28
import java.util.Collections;
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    29
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    30
import tests.Helper;
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    31
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    32
/*
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    33
 * @test
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    34
 * @summary Test image creation
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    35
 * @author Jean-Francois Denise
48663
b742e0f9ce80 8161348: Several tools/jlink tests failed in "-Xcomp" mode due to time out
anazarov
parents: 47216
diff changeset
    36
 * @requires (vm.compMode != "Xcomp" & os.maxMemory >= 2g)
36511
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    37
 * @library ../lib
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    38
 * @modules java.base/jdk.internal.jimage
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    39
 *          jdk.jdeps/com.sun.tools.classfile
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    40
 *          jdk.jlink/jdk.tools.jlink.internal
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    41
 *          jdk.jlink/jdk.tools.jmod
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    42
 *          jdk.jlink/jdk.tools.jimage
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    43
 *          jdk.compiler
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    44
 * @build tests.*
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    45
 * @run main/othervm -verbose:gc -Xmx1g JLinkPluginsTest
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    46
 */
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    47
public class JLinkPluginsTest {
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    48
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    49
    private static String createProperties(String fileName, String content) throws IOException {
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    50
        Path p = Paths.get(fileName);
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    51
        Files.write(p, Collections.singletonList(content));
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    52
        return p.toAbsolutePath().toString();
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    53
    }
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    54
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    55
    public static void main(String[] args) throws Exception {
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    56
        Helper helper = Helper.newHelper();
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    57
        if (helper == null) {
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    58
            System.err.println("Test not run");
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    59
            return;
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    60
        }
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    61
        helper.generateDefaultModules();
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    62
        {
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    63
            // Skip debug
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    64
            String[] userOptions = {"--strip-debug"};
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    65
            String moduleName = "skipdebugcomposite";
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    66
            helper.generateDefaultJModule(moduleName, "composite2");
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    67
            Path imageDir = helper.generateDefaultImage(userOptions, moduleName).assertSuccess();
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    68
            helper.checkImage(imageDir, moduleName, null, null);
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    69
        }
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    70
        {
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    71
            // Filter out files
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    72
            String[] userOptions = {"--exclude-resources", "*.jcov, */META-INF/*"};
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    73
            String moduleName = "excludecomposite";
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    74
            helper.generateDefaultJModule(moduleName, "composite2");
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    75
            String[] res = {".jcov", "/META-INF/"};
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    76
            Path imageDir = helper.generateDefaultImage(userOptions, moduleName).assertSuccess();
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    77
            helper.checkImage(imageDir, moduleName, res, null);
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    78
        }
39635
07c4b195280d 8161067: jlink: Enable plugins to use the module pool for class lookup
jlaskey
parents: 36511
diff changeset
    79
        {
41831
2dd91b18195b 8160063: Provide a means to disable a plugin via the command line
sundar
parents: 39635
diff changeset
    80
            // disable generate jli classes - JDK-8160063
2dd91b18195b 8160063: Provide a means to disable a plugin via the command line
sundar
parents: 39635
diff changeset
    81
            String[] userOptions = {"--disable-plugin", "generate-jli-classes"};
2dd91b18195b 8160063: Provide a means to disable a plugin via the command line
sundar
parents: 39635
diff changeset
    82
            String moduleName = "jlidisabled";
2dd91b18195b 8160063: Provide a means to disable a plugin via the command line
sundar
parents: 39635
diff changeset
    83
            helper.generateDefaultJModule(moduleName, "composite2");
2dd91b18195b 8160063: Provide a means to disable a plugin via the command line
sundar
parents: 39635
diff changeset
    84
            Path imageDir = helper.generateDefaultImage(userOptions, moduleName).assertSuccess();
2dd91b18195b 8160063: Provide a means to disable a plugin via the command line
sundar
parents: 39635
diff changeset
    85
            helper.checkImage(imageDir, moduleName, null, null);
2dd91b18195b 8160063: Provide a means to disable a plugin via the command line
sundar
parents: 39635
diff changeset
    86
        }
2dd91b18195b 8160063: Provide a means to disable a plugin via the command line
sundar
parents: 39635
diff changeset
    87
        {
2dd91b18195b 8160063: Provide a means to disable a plugin via the command line
sundar
parents: 39635
diff changeset
    88
            // disable invalid plugin - JDK-8160063
2dd91b18195b 8160063: Provide a means to disable a plugin via the command line
sundar
parents: 39635
diff changeset
    89
            String[] userOptions = {"--disable-plugin", "non-existent-plugin"};
2dd91b18195b 8160063: Provide a means to disable a plugin via the command line
sundar
parents: 39635
diff changeset
    90
            String moduleName = "invaliddisabled";
2dd91b18195b 8160063: Provide a means to disable a plugin via the command line
sundar
parents: 39635
diff changeset
    91
            helper.generateDefaultJModule(moduleName, "composite2");
2dd91b18195b 8160063: Provide a means to disable a plugin via the command line
sundar
parents: 39635
diff changeset
    92
            helper.generateDefaultImage(userOptions, moduleName).
2dd91b18195b 8160063: Provide a means to disable a plugin via the command line
sundar
parents: 39635
diff changeset
    93
                assertFailure("Error: No such plugin: non-existent-plugin");
2dd91b18195b 8160063: Provide a means to disable a plugin via the command line
sundar
parents: 39635
diff changeset
    94
        }
36511
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    95
    }
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    96
}