jdk/test/tools/jlink/plugins/PluginOrderTest.java
author sundar
Mon, 16 May 2016 14:47:27 +0530
changeset 38320 e24c7029e8ba
parent 36511 9d0388c6b336
child 39129 4b2086305b68
permissions -rw-r--r--
8156914: jlink API minor cleanups Reviewed-by: mchung
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
36511
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
     1
/*
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
     2
 * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
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
 /*
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    25
 * @test
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    26
 * @summary Test order of plugins
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    27
 * @author Jean-Francois Denise
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    28
 * @library ../../lib
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    29
 * @modules java.base/jdk.internal.jimage
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    30
 *          jdk.jdeps/com.sun.tools.classfile
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    31
 *          jdk.jlink/jdk.tools.jlink.internal
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    32
 *          jdk.jlink/jdk.tools.jmod
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    33
 *          jdk.jlink/jdk.tools.jimage
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    34
 *          jdk.compiler
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    35
 * @build tests.*
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    36
 * @run main/othervm PluginOrderTest
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    37
 */
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    38
import java.util.ArrayList;
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    39
import java.util.Collections;
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    40
import java.util.HashSet;
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    41
import java.util.List;
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    42
import java.util.Map;
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    43
import java.util.Set;
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    44
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    45
import jdk.tools.jlink.internal.PluginOrderingGraph;
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    46
import jdk.tools.jlink.plugin.Plugin;
38320
e24c7029e8ba 8156914: jlink API minor cleanups
sundar
parents: 36511
diff changeset
    47
import jdk.tools.jlink.plugin.Plugin.Category;
e24c7029e8ba 8156914: jlink API minor cleanups
sundar
parents: 36511
diff changeset
    48
import jdk.tools.jlink.plugin.ModulePool;
36511
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    49
import jdk.tools.jlink.plugin.TransformerPlugin;
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    50
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    51
public class PluginOrderTest {
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    52
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    53
    public static void main(String[] args) throws Exception {
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    54
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    55
        validGraph0();
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    56
        validGraph1();
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    57
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    58
        boolean failed = false;
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    59
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    60
        try {
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    61
            withCycles0();
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    62
            failed = true;
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    63
        } catch (Exception ex) {
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    64
            //ok
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    65
            System.err.println(ex.getMessage());
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    66
        }
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    67
        if (failed) {
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    68
            throw new Exception("Should have failed");
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
        try {
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    72
            withCycles1();
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    73
            failed = true;
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    74
        } catch (Exception ex) {
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    75
            //ok
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    76
            System.err.println(ex.getMessage());
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    77
        }
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    78
        if (failed) {
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    79
            throw new Exception("Should have failed");
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    80
        }
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    81
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    82
        try {
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    83
            withCycles2();
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    84
            failed = true;
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    85
        } catch (Exception ex) {
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    86
            //ok
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    87
            System.err.println(ex.getMessage());
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    88
        }
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    89
        if (failed) {
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    90
            throw new Exception("Should have failed");
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    91
        }
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    92
    }
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    93
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    94
    private static void validGraph0() throws Exception {
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    95
        Set<String> set = new HashSet<>();
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    96
        set.add("plug2");
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    97
        List<Plugin> plugins = new ArrayList<>();
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    98
        plugins.add(new Plug("plug2", Collections.emptySet(), Collections.emptySet(),
38320
e24c7029e8ba 8156914: jlink API minor cleanups
sundar
parents: 36511
diff changeset
    99
                Category.TRANSFORMER));
e24c7029e8ba 8156914: jlink API minor cleanups
sundar
parents: 36511
diff changeset
   100
        plugins.add(new Plug("plug1", set, Collections.emptySet(), Category.TRANSFORMER));
36511
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   101
        List<Plugin> ordered = PluginOrderingGraph.sort(plugins);
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   102
        if (ordered.get(0) != plugins.get(1) || ordered.get(1) != plugins.get(0)) {
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   103
            throw new Exception("Invalid sorting");
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   104
        }
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   105
    }
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   106
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   107
    private static void validGraph1() {
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   108
        Set<String> lst1 = new HashSet<>();
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   109
        lst1.add("plug2");
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   110
        lst1.add("plug3");
38320
e24c7029e8ba 8156914: jlink API minor cleanups
sundar
parents: 36511
diff changeset
   111
        Plugin p1 = new Plug("plug1", lst1, Collections.emptySet(), Category.TRANSFORMER);
36511
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   112
38320
e24c7029e8ba 8156914: jlink API minor cleanups
sundar
parents: 36511
diff changeset
   113
        Plugin p2 = new Plug("plug2", Collections.emptySet(), Collections.emptySet(), Category.TRANSFORMER);
36511
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   114
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   115
        Set<String> lst3 = new HashSet<>();
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   116
        lst3.add("plug4");
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   117
        lst3.add("plug6");
38320
e24c7029e8ba 8156914: jlink API minor cleanups
sundar
parents: 36511
diff changeset
   118
        Plugin p3 = new Plug("plug3", lst3, Collections.emptySet(), Category.TRANSFORMER);
36511
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   119
38320
e24c7029e8ba 8156914: jlink API minor cleanups
sundar
parents: 36511
diff changeset
   120
        Plugin p4 = new Plug("plug4", Collections.emptySet(), Collections.emptySet(), Category.TRANSFORMER);
36511
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   121
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   122
        Set<String> lst5 = new HashSet<>();
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   123
        lst5.add("plug3");
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   124
        lst5.add("plug1");
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   125
        lst5.add("plug2");
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   126
        lst5.add("plug6");
38320
e24c7029e8ba 8156914: jlink API minor cleanups
sundar
parents: 36511
diff changeset
   127
        Plugin p5 = new Plug("plug5", lst5, Collections.emptySet(), Category.TRANSFORMER);
36511
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   128
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   129
        Set<String> lst6 = new HashSet<>();
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   130
        lst6.add("plug4");
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   131
        lst6.add("plug2");
38320
e24c7029e8ba 8156914: jlink API minor cleanups
sundar
parents: 36511
diff changeset
   132
        Plugin p6 = new Plug("plug6", lst6, Collections.emptySet(), Category.TRANSFORMER);
36511
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   133
38320
e24c7029e8ba 8156914: jlink API minor cleanups
sundar
parents: 36511
diff changeset
   134
        Plugin p7 = new Plug("plug7", Collections.emptySet(), Collections.emptySet(), Category.TRANSFORMER);
36511
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   135
38320
e24c7029e8ba 8156914: jlink API minor cleanups
sundar
parents: 36511
diff changeset
   136
        Plugin p8 = new Plug("plug8", Collections.emptySet(), Collections.emptySet(), Category.TRANSFORMER);
36511
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   137
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   138
        List<Plugin> plugins = new ArrayList<>();
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   139
        plugins.add(p1);
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   140
        plugins.add(p2);
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   141
        plugins.add(p3);
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   142
        plugins.add(p4);
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   143
        plugins.add(p5);
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   144
        plugins.add(p6);
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   145
        plugins.add(p7);
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   146
        plugins.add(p8);
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   147
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   148
        PluginOrderingGraph.sort(plugins);
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   149
    }
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   150
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   151
    private static void withCycles0() throws Exception {
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   152
        Set<String> set2 = new HashSet<>();
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   153
        set2.add("plug1");
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   154
        List<Plugin> plugins = new ArrayList<>();
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   155
        plugins.add(new Plug("plug2", set2, Collections.emptySet(),
38320
e24c7029e8ba 8156914: jlink API minor cleanups
sundar
parents: 36511
diff changeset
   156
                Category.TRANSFORMER));
36511
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   157
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   158
        Set<String> set1 = new HashSet<>();
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   159
        set1.add("plug2");
38320
e24c7029e8ba 8156914: jlink API minor cleanups
sundar
parents: 36511
diff changeset
   160
        plugins.add(new Plug("plug1", set1, Collections.emptySet(), Category.TRANSFORMER));
36511
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   161
        PluginOrderingGraph.sort(plugins);
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   162
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   163
    }
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   164
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   165
    private static void withCycles2() {
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   166
        Set<String> lst1 = new HashSet<>();
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   167
        lst1.add("plug2");
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   168
        lst1.add("plug3");
38320
e24c7029e8ba 8156914: jlink API minor cleanups
sundar
parents: 36511
diff changeset
   169
        Plugin p1 = new Plug("plug1", lst1, Collections.emptySet(), Category.TRANSFORMER);
36511
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   170
38320
e24c7029e8ba 8156914: jlink API minor cleanups
sundar
parents: 36511
diff changeset
   171
        Plugin p2 = new Plug("plug2", Collections.emptySet(), Collections.emptySet(), Category.TRANSFORMER);
36511
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   172
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   173
        Set<String> lst3 = new HashSet<>();
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   174
        lst3.add("plug4");
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   175
        lst3.add("plug6");
38320
e24c7029e8ba 8156914: jlink API minor cleanups
sundar
parents: 36511
diff changeset
   176
        Plugin p3 = new Plug("plug3", lst3, Collections.emptySet(), Category.TRANSFORMER);
36511
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   177
38320
e24c7029e8ba 8156914: jlink API minor cleanups
sundar
parents: 36511
diff changeset
   178
        Plugin p4 = new Plug("plug4", Collections.emptySet(), Collections.emptySet(), Category.TRANSFORMER);
36511
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   179
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   180
        Set<String> lst5 = new HashSet<>();
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   181
        lst5.add("plug3");
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   182
        lst5.add("plug1");
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   183
        lst5.add("plug2");
38320
e24c7029e8ba 8156914: jlink API minor cleanups
sundar
parents: 36511
diff changeset
   184
        Plugin p5 = new Plug("plug5", lst5, Collections.emptySet(), Category.TRANSFORMER);
36511
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   185
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   186
        Set<String> lst6 = new HashSet<>();
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   187
        lst6.add("plug4");
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   188
        lst6.add("plug1");
38320
e24c7029e8ba 8156914: jlink API minor cleanups
sundar
parents: 36511
diff changeset
   189
        Plugin p6 = new Plug("plug6", lst6, Collections.emptySet(), Category.TRANSFORMER);
36511
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   190
38320
e24c7029e8ba 8156914: jlink API minor cleanups
sundar
parents: 36511
diff changeset
   191
        Plugin p7 = new Plug("plug7", Collections.emptySet(), Collections.emptySet(), Category.TRANSFORMER);
36511
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   192
38320
e24c7029e8ba 8156914: jlink API minor cleanups
sundar
parents: 36511
diff changeset
   193
        Plugin p8 = new Plug("plug8", Collections.emptySet(), Collections.emptySet(), Category.TRANSFORMER);
36511
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   194
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   195
        List<Plugin> plugins = new ArrayList<>();
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   196
        plugins.add(p1);
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   197
        plugins.add(p2);
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   198
        plugins.add(p3);
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   199
        plugins.add(p4);
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   200
        plugins.add(p5);
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   201
        plugins.add(p6);
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   202
        plugins.add(p7);
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   203
        plugins.add(p8);
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   204
        PluginOrderingGraph.sort(plugins);
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   205
    }
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   206
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   207
    private static void withCycles1() {
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   208
        Set<String> lst1 = new HashSet<>();
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   209
        lst1.add("plug2");
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   210
        lst1.add("plug3");
38320
e24c7029e8ba 8156914: jlink API minor cleanups
sundar
parents: 36511
diff changeset
   211
        Plugin p = new Plug("plug1", lst1, Collections.emptySet(), Category.TRANSFORMER);
e24c7029e8ba 8156914: jlink API minor cleanups
sundar
parents: 36511
diff changeset
   212
        Plugin p2 = new Plug("plug2", Collections.emptySet(), Collections.emptySet(), Category.TRANSFORMER);
36511
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   213
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   214
        Set<String> lst3 = new HashSet<>();
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   215
        lst3.add("plug2");
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   216
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   217
        Set<String> lst4 = new HashSet<>();
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   218
        lst4.add("plug1");
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   219
38320
e24c7029e8ba 8156914: jlink API minor cleanups
sundar
parents: 36511
diff changeset
   220
        Plugin p3 = new Plug("plug3", lst4, lst3, Category.TRANSFORMER);
36511
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   221
        List<Plugin> plugins = new ArrayList<>();
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   222
        plugins.add(p);
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   223
        plugins.add(p2);
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   224
        plugins.add(p3);
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   225
        PluginOrderingGraph.sort(plugins);
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   226
    }
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   227
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   228
    private static class Plug implements TransformerPlugin {
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   229
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   230
        private final Set<String> isBefore;
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   231
        private final Set<String> isAfter;
38320
e24c7029e8ba 8156914: jlink API minor cleanups
sundar
parents: 36511
diff changeset
   232
        private final Category category;
36511
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   233
        private final String name;
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   234
38320
e24c7029e8ba 8156914: jlink API minor cleanups
sundar
parents: 36511
diff changeset
   235
        private Plug(String name, Set<String> isBefore, Set<String> isAfter, Category category) {
36511
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   236
            this.name = name;
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   237
            this.isBefore = isBefore;
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   238
            this.isAfter = isAfter;
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   239
            this.category = category;
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   240
        }
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   241
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   242
        @Override
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   243
        public Set<String> isAfter() {
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   244
            return isAfter;
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   245
        }
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   246
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   247
        @Override
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   248
        public Set<String> isBefore() {
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   249
            return isBefore;
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
        @Override
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   253
        public String toString() {
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   254
            return name;
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   255
        }
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   256
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   257
        @Override
38320
e24c7029e8ba 8156914: jlink API minor cleanups
sundar
parents: 36511
diff changeset
   258
        public void visit(ModulePool in, ModulePool out) {
36511
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   259
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   260
        }
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   261
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   262
        @Override
38320
e24c7029e8ba 8156914: jlink API minor cleanups
sundar
parents: 36511
diff changeset
   263
        public Set<Category> getType() {
36511
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   264
            return Collections.singleton(category);
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   265
        }
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   266
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   267
        @Override
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   268
        public String getName() {
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   269
            return name;
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   270
        }
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   271
    }
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   272
}