--- old/test/tools/jlink/bindservices/BindServices.java 2017-04-11 22:42:57.000000000 +0300 +++ new/test/tools/jlink/bindservices/BindServices.java 2017-04-11 22:42:56.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-11 22:42:57.000000000 +0300 +++ new/test/tools/jlink/bindservices/SuggestProviders.java 2017-04-11 22:42:57.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 + public void noOneUsesProvider() throws Throwable { + if (!hasJmods()) return; + + List output = + JLink.run("--module-path", MODULE_PATH, + "--add-modules", "m4", + "--suggest-providers", + "p4.S").output(); + + System.out.println(output); + List expected = List.of( + "module m4 provides p4.S, not used by any observable module" + ); + + assertTrue(output.containsAll(expected)); + } + + @Test + public void nonObservableModule() throws Throwable { + if (!hasJmods()) return; + + List output = + JLink.runWithNonZeroExitCode( + "--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(() -> @@ -183,6 +238,13 @@ return jlink; } + static JLink runWithNonZeroExitCode(String... options) { + JLink jlink = new JLink(); + assertNotEquals(jlink.execute(options), 0, + "Exit code should be not 0"); + return jlink; + } + final List output = new ArrayList<>(); private int execute(String... options) { System.out.println("jlink " + --- /dev/null 2017-04-11 22:42:58.000000000 +0300 +++ new/test/tools/jlink/bindservices/src/m4/module-info.java 2017-04-11 22:42:58.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.S with p4.Impl; +} --- /dev/null 2017-04-11 22:42:58.000000000 +0300 +++ new/test/tools/jlink/bindservices/src/m4/p4/Impl.java 2017-04-11 22:42:58.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 implements S { + public void run() { + } +} --- /dev/null 2017-04-11 22:42:59.000000000 +0300 +++ new/test/tools/jlink/bindservices/src/m4/p4/S.java 2017-04-11 22:42:59.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. + */ + +package p4; + +public interface S { + void run(); +}