jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/ReleaseInfoPlugin.java
author alanb
Fri, 07 Apr 2017 08:05:54 +0000
changeset 44545 83b611b88ac8
parent 44359 c6761862ca0b
child 45004 ea3137042a61
permissions -rw-r--r--
8177530: Module system implementation refresh (4/2017) Reviewed-by: mchung, alanb Contributed-by: alan.bateman@oracle.com, mandy.chung@oracle.com
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) 2016, 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.  Oracle designates this
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    10
 *
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    15
 * accompanied this code).
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    16
 *
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    20
 *
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    23
 * questions.
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    24
 */
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    25
package jdk.tools.jlink.internal.plugins;
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    26
39894
cd4f403f9618 8162782: jlink ResourcePool.releaseProperties should be removed
sundar
parents: 39834
diff changeset
    27
import java.io.ByteArrayOutputStream;
36511
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    28
import java.io.FileInputStream;
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    29
import java.io.IOException;
44545
83b611b88ac8 8177530: Module system implementation refresh (4/2017)
alanb
parents: 44359
diff changeset
    30
import java.io.PrintWriter;
39894
cd4f403f9618 8162782: jlink ResourcePool.releaseProperties should be removed
sundar
parents: 39834
diff changeset
    31
import java.io.UncheckedIOException;
cd4f403f9618 8162782: jlink ResourcePool.releaseProperties should be removed
sundar
parents: 39834
diff changeset
    32
import java.lang.module.ModuleDescriptor;
36511
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    33
import java.util.EnumSet;
38320
e24c7029e8ba 8156914: jlink API minor cleanups
sundar
parents: 36511
diff changeset
    34
import java.util.HashMap;
36511
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    35
import java.util.Map;
39894
cd4f403f9618 8162782: jlink ResourcePool.releaseProperties should be removed
sundar
parents: 39834
diff changeset
    36
import java.util.Optional;
38320
e24c7029e8ba 8156914: jlink API minor cleanups
sundar
parents: 36511
diff changeset
    37
import java.util.Properties;
36511
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    38
import java.util.Set;
38320
e24c7029e8ba 8156914: jlink API minor cleanups
sundar
parents: 36511
diff changeset
    39
import java.util.function.Function;
42471
86b1da05a4b0 8168925: MODULES property should be topologically ordered and space-separated list
sundar
parents: 42330
diff changeset
    40
import java.util.stream.Collectors;
86b1da05a4b0 8168925: MODULES property should be topologically ordered and space-separated list
sundar
parents: 42330
diff changeset
    41
import jdk.tools.jlink.internal.ModuleSorter;
36511
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    42
import jdk.tools.jlink.internal.Utils;
39834
53a6fb443c20 8162538: plugin API should avoid read only pool, have module view separated from resource view and have pool builder to modify
sundar
parents: 39321
diff changeset
    43
import jdk.tools.jlink.plugin.ResourcePool;
53a6fb443c20 8162538: plugin API should avoid read only pool, have module view separated from resource view and have pool builder to modify
sundar
parents: 39321
diff changeset
    44
import jdk.tools.jlink.plugin.ResourcePoolBuilder;
39894
cd4f403f9618 8162782: jlink ResourcePool.releaseProperties should be removed
sundar
parents: 39834
diff changeset
    45
import jdk.tools.jlink.plugin.ResourcePoolEntry;
cd4f403f9618 8162782: jlink ResourcePool.releaseProperties should be removed
sundar
parents: 39834
diff changeset
    46
import jdk.tools.jlink.plugin.ResourcePoolModule;
39321
c60f34e8c057 8160641: PostProcessingPlugin and ExecutableImage should not be part of plugin API
sundar
parents: 39308
diff changeset
    47
import jdk.tools.jlink.plugin.Plugin;
36511
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    48
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    49
/**
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    50
 * This plugin adds/deletes information for 'release' file.
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    51
 */
39321
c60f34e8c057 8160641: PostProcessingPlugin and ExecutableImage should not be part of plugin API
sundar
parents: 39308
diff changeset
    52
public final class ReleaseInfoPlugin implements Plugin {
36511
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    53
    // option name
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    54
    public static final String NAME = "release-info";
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    55
    public static final String KEYS = "keys";
38320
e24c7029e8ba 8156914: jlink API minor cleanups
sundar
parents: 36511
diff changeset
    56
    private final Map<String, String> release = new HashMap<>();
36511
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    57
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    58
    @Override
39129
4b2086305b68 8159593: Plugin Set<Category> getType() should return a Category
sundar
parents: 39042
diff changeset
    59
    public Category getType() {
4b2086305b68 8159593: Plugin Set<Category> getType() should return a Category
sundar
parents: 39042
diff changeset
    60
        return Category.METAINFO_ADDER;
36511
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    61
    }
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    62
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    63
    @Override
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    64
    public String getName() {
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    65
        return NAME;
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    66
    }
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    67
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    68
    @Override
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    69
    public String getDescription() {
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    70
        return PluginsResourceBundle.getDescription(NAME);
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    71
    }
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    72
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    73
    @Override
38320
e24c7029e8ba 8156914: jlink API minor cleanups
sundar
parents: 36511
diff changeset
    74
    public Set<State> getState() {
42471
86b1da05a4b0 8168925: MODULES property should be topologically ordered and space-separated list
sundar
parents: 42330
diff changeset
    75
        return EnumSet.of(State.AUTO_ENABLED, State.FUNCTIONAL);
36511
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    76
    }
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    77
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    78
    @Override
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    79
    public boolean hasArguments() {
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    80
        return true;
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    81
    }
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    82
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    83
    @Override
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    84
    public String getArgumentsDescription() {
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    85
        return PluginsResourceBundle.getArgument(NAME);
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    86
    }
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    87
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    88
    @Override
38320
e24c7029e8ba 8156914: jlink API minor cleanups
sundar
parents: 36511
diff changeset
    89
    public void configure(Map<String, String> config) {
e24c7029e8ba 8156914: jlink API minor cleanups
sundar
parents: 36511
diff changeset
    90
        String operation = config.get(NAME);
42471
86b1da05a4b0 8168925: MODULES property should be topologically ordered and space-separated list
sundar
parents: 42330
diff changeset
    91
        if (operation == null) {
86b1da05a4b0 8168925: MODULES property should be topologically ordered and space-separated list
sundar
parents: 42330
diff changeset
    92
            return;
86b1da05a4b0 8168925: MODULES property should be topologically ordered and space-separated list
sundar
parents: 42330
diff changeset
    93
        }
86b1da05a4b0 8168925: MODULES property should be topologically ordered and space-separated list
sundar
parents: 42330
diff changeset
    94
38320
e24c7029e8ba 8156914: jlink API minor cleanups
sundar
parents: 36511
diff changeset
    95
        switch (operation) {
e24c7029e8ba 8156914: jlink API minor cleanups
sundar
parents: 36511
diff changeset
    96
            case "add": {
e24c7029e8ba 8156914: jlink API minor cleanups
sundar
parents: 36511
diff changeset
    97
                // leave it to open-ended! source, java_version, java_full_version
e24c7029e8ba 8156914: jlink API minor cleanups
sundar
parents: 36511
diff changeset
    98
                // can be passed via this option like:
e24c7029e8ba 8156914: jlink API minor cleanups
sundar
parents: 36511
diff changeset
    99
                //
e24c7029e8ba 8156914: jlink API minor cleanups
sundar
parents: 36511
diff changeset
   100
                //     --release-info add:build_type=fastdebug,source=openjdk,java_version=9
e24c7029e8ba 8156914: jlink API minor cleanups
sundar
parents: 36511
diff changeset
   101
                // and put whatever value that was passed in command line.
36511
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   102
44545
83b611b88ac8 8177530: Module system implementation refresh (4/2017)
alanb
parents: 44359
diff changeset
   103
                config.keySet().stream()
83b611b88ac8 8177530: Module system implementation refresh (4/2017)
alanb
parents: 44359
diff changeset
   104
                      .filter(s -> !NAME.equals(s))
83b611b88ac8 8177530: Module system implementation refresh (4/2017)
alanb
parents: 44359
diff changeset
   105
                      .forEach(s -> release.put(s, config.get(s)));
38320
e24c7029e8ba 8156914: jlink API minor cleanups
sundar
parents: 36511
diff changeset
   106
            }
e24c7029e8ba 8156914: jlink API minor cleanups
sundar
parents: 36511
diff changeset
   107
            break;
36511
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   108
38320
e24c7029e8ba 8156914: jlink API minor cleanups
sundar
parents: 36511
diff changeset
   109
            case "del": {
e24c7029e8ba 8156914: jlink API minor cleanups
sundar
parents: 36511
diff changeset
   110
                // --release-info del:keys=openjdk,java_version
39042
52db877f18db 8159206: All jlink or jmod tests failing
jlaskey
parents: 38320
diff changeset
   111
                Utils.parseList(config.get(KEYS)).stream().forEach((k) -> {
38320
e24c7029e8ba 8156914: jlink API minor cleanups
sundar
parents: 36511
diff changeset
   112
                    release.remove(k);
39042
52db877f18db 8159206: All jlink or jmod tests failing
jlaskey
parents: 38320
diff changeset
   113
                });
38320
e24c7029e8ba 8156914: jlink API minor cleanups
sundar
parents: 36511
diff changeset
   114
            }
e24c7029e8ba 8156914: jlink API minor cleanups
sundar
parents: 36511
diff changeset
   115
            break;
36511
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   116
38320
e24c7029e8ba 8156914: jlink API minor cleanups
sundar
parents: 36511
diff changeset
   117
            default: {
e24c7029e8ba 8156914: jlink API minor cleanups
sundar
parents: 36511
diff changeset
   118
                // --release-info <file>
e24c7029e8ba 8156914: jlink API minor cleanups
sundar
parents: 36511
diff changeset
   119
                Properties props = new Properties();
e24c7029e8ba 8156914: jlink API minor cleanups
sundar
parents: 36511
diff changeset
   120
                try (FileInputStream fis = new FileInputStream(operation)) {
e24c7029e8ba 8156914: jlink API minor cleanups
sundar
parents: 36511
diff changeset
   121
                    props.load(fis);
e24c7029e8ba 8156914: jlink API minor cleanups
sundar
parents: 36511
diff changeset
   122
                } catch (IOException exp) {
42330
bd999576b78d 8160359: Improve jlink logging for cases when a plugin throws exception
sundar
parents: 39894
diff changeset
   123
                    throw new UncheckedIOException(exp);
36511
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   124
                }
38320
e24c7029e8ba 8156914: jlink API minor cleanups
sundar
parents: 36511
diff changeset
   125
                props.forEach((k, v) -> release.put(k.toString(), v.toString()));
36511
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   126
            }
38320
e24c7029e8ba 8156914: jlink API minor cleanups
sundar
parents: 36511
diff changeset
   127
            break;
36511
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   128
        }
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   129
    }
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   130
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   131
    @Override
39834
53a6fb443c20 8162538: plugin API should avoid read only pool, have module view separated from resource view and have pool builder to modify
sundar
parents: 39321
diff changeset
   132
    public ResourcePool transform(ResourcePool in, ResourcePoolBuilder out) {
39894
cd4f403f9618 8162782: jlink ResourcePool.releaseProperties should be removed
sundar
parents: 39834
diff changeset
   133
        in.transformAndCopy(Function.identity(), out);
cd4f403f9618 8162782: jlink ResourcePool.releaseProperties should be removed
sundar
parents: 39834
diff changeset
   134
42471
86b1da05a4b0 8168925: MODULES property should be topologically ordered and space-separated list
sundar
parents: 42330
diff changeset
   135
        Optional<ResourcePoolModule> javaBase = in.moduleView().findModule("java.base");
86b1da05a4b0 8168925: MODULES property should be topologically ordered and space-separated list
sundar
parents: 42330
diff changeset
   136
        javaBase.ifPresent(mod -> {
86b1da05a4b0 8168925: MODULES property should be topologically ordered and space-separated list
sundar
parents: 42330
diff changeset
   137
            // fill release information available from transformed "java.base" module!
86b1da05a4b0 8168925: MODULES property should be topologically ordered and space-separated list
sundar
parents: 42330
diff changeset
   138
            ModuleDescriptor desc = mod.descriptor();
86b1da05a4b0 8168925: MODULES property should be topologically ordered and space-separated list
sundar
parents: 42330
diff changeset
   139
            desc.version().ifPresent(s -> release.put("JAVA_VERSION",
86b1da05a4b0 8168925: MODULES property should be topologically ordered and space-separated list
sundar
parents: 42330
diff changeset
   140
                    quote(parseVersion(s.toString()))));
86b1da05a4b0 8168925: MODULES property should be topologically ordered and space-separated list
sundar
parents: 42330
diff changeset
   141
            desc.version().ifPresent(s -> release.put("JAVA_FULL_VERSION",
86b1da05a4b0 8168925: MODULES property should be topologically ordered and space-separated list
sundar
parents: 42330
diff changeset
   142
                    quote(s.toString())));
44359
c6761862ca0b 8174823: Module system implementation refresh (3/2017)
alanb
parents: 42471
diff changeset
   143
c6761862ca0b 8174823: Module system implementation refresh (3/2017)
alanb
parents: 42471
diff changeset
   144
            release.put("OS_NAME", quote(mod.osName()));
c6761862ca0b 8174823: Module system implementation refresh (3/2017)
alanb
parents: 42471
diff changeset
   145
            release.put("OS_ARCH", quote(mod.osArch()));
42471
86b1da05a4b0 8168925: MODULES property should be topologically ordered and space-separated list
sundar
parents: 42330
diff changeset
   146
        });
86b1da05a4b0 8168925: MODULES property should be topologically ordered and space-separated list
sundar
parents: 42330
diff changeset
   147
86b1da05a4b0 8168925: MODULES property should be topologically ordered and space-separated list
sundar
parents: 42330
diff changeset
   148
        // put topological sorted module names separated by space
86b1da05a4b0 8168925: MODULES property should be topologically ordered and space-separated list
sundar
parents: 42330
diff changeset
   149
        release.put("MODULES",  new ModuleSorter(in.moduleView())
44545
83b611b88ac8 8177530: Module system implementation refresh (4/2017)
alanb
parents: 44359
diff changeset
   150
               .sorted().map(ResourcePoolModule::name)
83b611b88ac8 8177530: Module system implementation refresh (4/2017)
alanb
parents: 44359
diff changeset
   151
               .collect(Collectors.joining(" ", "\"", "\"")));
42471
86b1da05a4b0 8168925: MODULES property should be topologically ordered and space-separated list
sundar
parents: 42330
diff changeset
   152
39894
cd4f403f9618 8162782: jlink ResourcePool.releaseProperties should be removed
sundar
parents: 39834
diff changeset
   153
        // create a TOP level ResourcePoolEntry for "release" file.
cd4f403f9618 8162782: jlink ResourcePool.releaseProperties should be removed
sundar
parents: 39834
diff changeset
   154
        out.add(ResourcePoolEntry.create("/java.base/release",
cd4f403f9618 8162782: jlink ResourcePool.releaseProperties should be removed
sundar
parents: 39834
diff changeset
   155
            ResourcePoolEntry.Type.TOP, releaseFileContent()));
cd4f403f9618 8162782: jlink ResourcePool.releaseProperties should be removed
sundar
parents: 39834
diff changeset
   156
        return out.build();
cd4f403f9618 8162782: jlink ResourcePool.releaseProperties should be removed
sundar
parents: 39834
diff changeset
   157
    }
cd4f403f9618 8162782: jlink ResourcePool.releaseProperties should be removed
sundar
parents: 39834
diff changeset
   158
42471
86b1da05a4b0 8168925: MODULES property should be topologically ordered and space-separated list
sundar
parents: 42330
diff changeset
   159
    // Parse version string and return a string that includes only version part
86b1da05a4b0 8168925: MODULES property should be topologically ordered and space-separated list
sundar
parents: 42330
diff changeset
   160
    // leaving "pre", "build" information. See also: java.lang.Runtime.Version.
86b1da05a4b0 8168925: MODULES property should be topologically ordered and space-separated list
sundar
parents: 42330
diff changeset
   161
    private static String parseVersion(String str) {
44545
83b611b88ac8 8177530: Module system implementation refresh (4/2017)
alanb
parents: 44359
diff changeset
   162
        return Runtime.Version.parse(str)
83b611b88ac8 8177530: Module system implementation refresh (4/2017)
alanb
parents: 44359
diff changeset
   163
                      .version()
83b611b88ac8 8177530: Module system implementation refresh (4/2017)
alanb
parents: 44359
diff changeset
   164
                      .stream()
83b611b88ac8 8177530: Module system implementation refresh (4/2017)
alanb
parents: 44359
diff changeset
   165
                      .map(Object::toString)
83b611b88ac8 8177530: Module system implementation refresh (4/2017)
alanb
parents: 44359
diff changeset
   166
                      .collect(Collectors.joining("."));
42471
86b1da05a4b0 8168925: MODULES property should be topologically ordered and space-separated list
sundar
parents: 42330
diff changeset
   167
    }
86b1da05a4b0 8168925: MODULES property should be topologically ordered and space-separated list
sundar
parents: 42330
diff changeset
   168
86b1da05a4b0 8168925: MODULES property should be topologically ordered and space-separated list
sundar
parents: 42330
diff changeset
   169
    private static String quote(String str) {
86b1da05a4b0 8168925: MODULES property should be topologically ordered and space-separated list
sundar
parents: 42330
diff changeset
   170
        return "\"" + str + "\"";
86b1da05a4b0 8168925: MODULES property should be topologically ordered and space-separated list
sundar
parents: 42330
diff changeset
   171
    }
86b1da05a4b0 8168925: MODULES property should be topologically ordered and space-separated list
sundar
parents: 42330
diff changeset
   172
39894
cd4f403f9618 8162782: jlink ResourcePool.releaseProperties should be removed
sundar
parents: 39834
diff changeset
   173
    private byte[] releaseFileContent() {
cd4f403f9618 8162782: jlink ResourcePool.releaseProperties should be removed
sundar
parents: 39834
diff changeset
   174
        ByteArrayOutputStream baos = new ByteArrayOutputStream();
44545
83b611b88ac8 8177530: Module system implementation refresh (4/2017)
alanb
parents: 44359
diff changeset
   175
        try (PrintWriter pw = new PrintWriter(baos)) {
83b611b88ac8 8177530: Module system implementation refresh (4/2017)
alanb
parents: 44359
diff changeset
   176
            release.entrySet().stream()
83b611b88ac8 8177530: Module system implementation refresh (4/2017)
alanb
parents: 44359
diff changeset
   177
                   .sorted(Map.Entry.comparingByKey())
83b611b88ac8 8177530: Module system implementation refresh (4/2017)
alanb
parents: 44359
diff changeset
   178
                   .forEach(e -> pw.format("%s=%s%n", e.getKey(), e.getValue()));
39894
cd4f403f9618 8162782: jlink ResourcePool.releaseProperties should be removed
sundar
parents: 39834
diff changeset
   179
        }
44545
83b611b88ac8 8177530: Module system implementation refresh (4/2017)
alanb
parents: 44359
diff changeset
   180
        return baos.toByteArray();
36511
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   181
    }
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   182
}