--- old/test/tools/jlink/bindservices/BindServices.java 2017-04-10 22:26:59.000000000 +0300 +++ new/test/tools/jlink/bindservices/BindServices.java 2017-04-10 22:26:59.000000000 +0300 @@ -148,6 +148,23 @@ testImage(dir, "m1", "m2", "m3"); } + @Test + public void testVerboseAndNoBindServices() throws Throwable { + if (!hasJmods()) return; + + Path dir = Paths.get("verboseNoBind"); + + List output = + JLink.run("--output", dir.toString(), + "--module-path", MODULE_PATH, + "--verbose", + "--add-modules", "m1").output(); + + assertTrue(output.contains("module m1 provides p1.S, used by m1")); + + testImage(dir, "m1"); + } + /* * Tests the given ${java.home} to only contain the specified modules */ --- old/test/tools/jlink/bindservices/SuggestProviders.java 2017-04-10 22:27:00.000000000 +0300 +++ new/test/tools/jlink/bindservices/SuggestProviders.java 2017-04-10 22:27:00.000000000 +0300 @@ -60,7 +60,7 @@ File.pathSeparator + MODS_DIR.toString(); // the names of the modules in this test - private static String[] modules = new String[] {"m1", "m2", "m3"}; + private static String[] modules = new String[] {"m1", "m2", "m3", "m4"}; private static boolean hasJmods() { @@ -171,6 +171,61 @@ } + @Test + public void suggestTypeNotRealProvider() throws Throwable { + if (!hasJmods()) return; + + List output = + JLink.run("--module-path", MODULE_PATH, + "--add-modules", "m1", + "--suggest-providers", + "java.util.List").output(); + + System.out.println(output); + List expected = List.of( + "Services specified in --suggest-providers not used: java.util.List" + ); + + assertTrue(output.containsAll(expected)); + } + +// @Test @ignore JDK-8178405 + public void noOneUsesProvider() throws Throwable { + if (!hasJmods()) return; + + List output = + JLink.run("--module-path", MODULE_PATH, + "--add-modules", "m4", + "--suggest-providers", + "p4.Impl").output(); + + System.out.println(output); + List expected = List.of( + "Services specified in --suggest-providers not used: p4.Impl" + ); + + assertTrue(output.containsAll(expected)); + } + +// @Test @ignore JDK-8178404 + public void nonObservableModule() throws Throwable { + if (!hasJmods()) return; + + List output = + JLink.run(false, + "--module-path", MODULE_PATH, + "--add-modules", "nonExistentModule", + "--suggest-providers", + "java.nio.charset.spi.CharsetProvider").output(); + + System.out.println(output); + List expected = List.of( + "Error: Module nonExistentModule not found" + ); + + assertTrue(output.containsAll(expected)); + } + static class JLink { static final ToolProvider JLINK_TOOL = ToolProvider.findFirst("jlink") .orElseThrow(() -> @@ -178,8 +233,19 @@ ); static JLink run(String... options) { + return run(true, options); + } + + static JLink run(boolean expectSuccess, String... options) { JLink jlink = new JLink(); - assertTrue(jlink.execute(options) == 0); + if (expectSuccess){ + assertEquals(jlink.execute(options), 0 , + "Jlink failed."); + } + else { + assertNotEquals(jlink.execute(options), 0, + "Jlink succeeded. Expect to fail."); + } return jlink; } --- /dev/null 2017-04-10 22:27:00.000000000 +0300 +++ new/test/tools/jlink/bindservices/src/m4/module-info.java 2017-04-10 22:27:00.000000000 +0300 @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +module m4 { + requires m1; + exports p4; + provides p4.Impl with p4.Impl; +} --- /dev/null 2017-04-10 22:27:01.000000000 +0300 +++ new/test/tools/jlink/bindservices/src/m4/p4/Impl.java 2017-04-10 22:27:01.000000000 +0300 @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package p4; + +public class Impl { + public void run() { + } +}