JDK-8234402: revert change that stopped providing JPackageToolProvider
Reviewed-by: asemenyuk, almatvee, kcr
--- a/src/jdk.incubator.jpackage/share/classes/jdk/incubator/jpackage/ToolProviderFactory.java Tue Nov 19 18:45:08 2019 -0500
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,69 +0,0 @@
-/*
- * Copyright (c) 2019, 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
- * published by the Free Software Foundation. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * 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 jdk.incubator.jpackage;
-
-import jdk.incubator.jpackage.internal.JPackageToolProvider;
-import java.io.PrintWriter;
-import java.util.Optional;
-import java.util.spi.ToolProvider;
-
-/**
- * A factory class to obtain a {@linkplain ToolProvider tool provider}
- * for the incubating {@code jpackage} tool.
- *
- * It is planned to implement {@code jpackage} tool as a service provider
- * to {@link ToolProvider} in a future release at which point
- * {@link ToolProvider#findFirst} can be used to look up jpackage tool.
- *
- * @since 14
- */
-
-public class ToolProviderFactory {
-
- private static ToolProvider provider = new JPackageToolProvider();
-
- // Prevent creating an instance of this class
- private ToolProviderFactory() {
- }
-
- /**
- * Returns an {@link Optional} containing the {@code ToolProvider}
- * if the given toolname is "jpackage". Returns an empty
- * {@code Optional} if the given toolname is not "jpackage".
- *
- * @param toolname {@code String} name of tool to look for.
- * @return an {@link Optional} containing the {@code ToolPovider}
- *
- * @since 14
- */
- public static Optional<ToolProvider> findFirst(String toolName) {
- if ("jpackage".equals(toolName)) {
- return Optional.of(provider);
- } else {
- return Optional.empty();
- }
- }
-
-}
--- a/src/jdk.incubator.jpackage/share/classes/module-info.java Tue Nov 19 18:45:08 2019 -0500
+++ b/src/jdk.incubator.jpackage/share/classes/module-info.java Wed Nov 20 10:17:37 2019 -0500
@@ -28,6 +28,20 @@
*
* <p>jpackage is a tool for generating self-contained application bundles.
*
+ * <p> This module provides the equivalent of command-line access to <em>jpackage</em>
+ * via the {@link java.util.spi.ToolProvider ToolProvider} SPI.
+ * Instances of the tool can be obtained by calling
+ * {@link java.util.spi.ToolProvider#findFirst ToolProvider.findFirst}
+ * or the {@link java.util.ServiceLoader service loader} with the name
+ * {@code "jpackage"}.
+ *
+ * @implNote The {@code jpackage} tool is not thread-safe. An application
+ * should not call either of the
+ * {@link java.util.spi.ToolProvider ToolProvider} {@code run} methods
+ * concurrently, even with separate {@code "jpackage"} {@code ToolProvider}
+ * instances, or undefined behavior may result.
+ *
+ *
* @moduleGraph
* @since 14
*/
@@ -43,14 +57,6 @@
provides jdk.incubator.jpackage.internal.Bundlers with
jdk.incubator.jpackage.internal.BasicBundlers;
-/*
- * while jpackage is incubating, do not provide ToolProvider directly, but
- * instead export jdk.incubator.jpackage.ToolProviderFactory
- *
- * provides java.util.spi.ToolProvider
- * with jdk.incubator.jpackage.internal.JPackageToolProvider;
- */
- exports jdk.incubator.jpackage;
-
-
+ provides java.util.spi.ToolProvider
+ with jdk.incubator.jpackage.internal.JPackageToolProvider;
}
--- a/test/jdk/tools/jpackage/helpers/JPackageHelper.java Tue Nov 19 18:45:08 2019 -0500
+++ b/test/jdk/tools/jpackage/helpers/JPackageHelper.java Wed Nov 20 10:17:37 2019 -0500
@@ -38,7 +38,6 @@
import java.util.stream.Stream;
import java.util.spi.ToolProvider;
-import jdk.incubator.jpackage.ToolProviderFactory;
public class JPackageHelper {
@@ -114,7 +113,7 @@
}
static final ToolProvider JPACKAGE_TOOL =
- ToolProviderFactory.findFirst("jpackage").orElseThrow(
+ ToolProvider.findFirst("jpackage").orElseThrow(
() -> new RuntimeException("jpackage tool not found"));
public static int execute(File out, String... command) throws Exception {
--- a/test/jdk/tools/jpackage/helpers/jdk/jpackage/test/JavaTool.java Tue Nov 19 18:45:08 2019 -0500
+++ b/test/jdk/tools/jpackage/helpers/jdk/jpackage/test/JavaTool.java Wed Nov 20 10:17:37 2019 -0500
@@ -27,7 +27,6 @@
import java.nio.file.Path;
import java.util.spi.ToolProvider;
-import jdk.incubator.jpackage.ToolProviderFactory;
public enum JavaTool {
JAVA("java"), JAVAC("javac"), JPACKAGE("jpackage"), JAR("jar"), JLINK("jlink");
@@ -47,12 +46,7 @@
}
public ToolProvider asToolProvider() {
- if (this == JPACKAGE) {
- return ToolProviderFactory.findFirst("jpackage").orElseThrow(
- () -> new RuntimeException("jpackage tool not found"));
- } else {
- return ToolProvider.findFirst(name).orElse(null);
- }
+ return ToolProvider.findFirst(name).orElse(null);
}
Path relativePathInJavaHome() {