Path: blob/master/test/jdk/tools/jlink/JLinkReproducible2Test.java
41144 views
/*1* Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation.7*8* This code is distributed in the hope that it will be useful, but WITHOUT9* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or10* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License11* version 2 for more details (a copy is included in the LICENSE file that12* accompanied this code).13*14* You should have received a copy of the GNU General Public License version15* 2 along with this work; if not, write to the Free Software Foundation,16* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.17*18* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA19* or visit www.oracle.com if you need additional information or have any20* questions.21*/2223import java.nio.file.Files;24import java.nio.file.Path;25import java.nio.file.Paths;26import java.util.spi.ToolProvider;2728/*29* @test30* @summary Make sure that jimages are consistent when created by jlink.31* @bug 824160232* @modules jdk.jlink33* java.se34* jdk.management35* jdk.unsupported36* jdk.charsets37* @run main JLinkReproducible2Test38*/39public class JLinkReproducible2Test {40static final ToolProvider JLINK_TOOL = ToolProvider.findFirst("jlink")41.orElseThrow(() ->42new RuntimeException("jlink tool not found")43);4445public static void main(String[] args) throws Exception {46Path image1 = Paths.get("./image1");47Path image2 = Paths.get("./image2");4849JLINK_TOOL.run(System.out, System.err, "--add-modules", "java.se", "--output", image1.toString());50JLINK_TOOL.run(System.out, System.err, "--add-modules", "java.se", "--output", image2.toString());5152if (Files.mismatch(image1.resolve("lib").resolve("modules"), image2.resolve("lib").resolve("modules")) != -1L) {53throw new RuntimeException("jlink producing inconsistent result");54}5556Path image3 = Paths.get("./image3");57Path image4 = Paths.get("./image4");5859JLINK_TOOL.run(System.out, System.err, "--add-modules", "java.base,jdk.management,jdk.unsupported,jdk.charsets", "--output", image3.toString());60JLINK_TOOL.run(System.out, System.err, "--add-modules", "java.base,jdk.management,jdk.unsupported,jdk.charsets", "--output", image4.toString());6162if (Files.mismatch(image3.resolve("lib").resolve("modules"), image4.resolve("lib").resolve("modules")) != -1L) {63throw new RuntimeException("jlink producing inconsistent result with multiple named modules");64}65}66}676869