Skip to content

Commit 397abf8

Browse files
Revert excessive changes of JDK-8308349 patch irrelevant to JDK-8364564
1 parent 0c0300e commit 397abf8

File tree

10 files changed

+35
-157
lines changed

10 files changed

+35
-157
lines changed

src/jdk.jpackage/linux/classes/jdk/jpackage/internal/DesktopIntegration.java

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@
4646
import javax.xml.stream.XMLStreamException;
4747
import javax.xml.stream.XMLStreamWriter;
4848
import jdk.jpackage.internal.model.FileAssociation;
49-
import jdk.jpackage.internal.model.LauncherShortcut;
5049
import jdk.jpackage.internal.model.LinuxLauncher;
5150
import jdk.jpackage.internal.model.LinuxPackage;
5251
import jdk.jpackage.internal.model.Package;
@@ -238,26 +237,6 @@ private Map<String, String> createDataForDesktopFile() {
238237
data.put("DEPLOY_BUNDLE_CATEGORY", pkg.menuGroupName());
239238
data.put("APPLICATION_LAUNCHER", Enquoter.forPropertyValues().applyTo(
240239
installedLayout.launchersDirectory().resolve(launcher.executableNameWithSuffix()).toString()));
241-
data.put("STARTUP_DIRECTORY", launcher.shortcut()
242-
.flatMap(LauncherShortcut::startupDirectory)
243-
.map(startupDirectory -> {
244-
switch (startupDirectory) {
245-
case DEFAULT -> {
246-
return (Path)null;
247-
}
248-
case APP_DIR -> {
249-
return installedLayout.appDirectory();
250-
}
251-
case INSTALL_DIR -> {
252-
return installedLayout.launchersDirectory();
253-
}
254-
default -> {
255-
throw new AssertionError();
256-
}
257-
}
258-
}).map(str -> {
259-
return "Path=" + str;
260-
}).orElse(null));
261240

262241
return data;
263242
}

src/jdk.jpackage/linux/classes/jdk/jpackage/internal/LinuxFromParams.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,8 +109,12 @@ private static LinuxPackage createLinuxDebPackage(
109109
static final BundlerParamInfo<LinuxPackage> DEB_PACKAGE = createPackageBundlerParam(
110110
LinuxFromParams::createLinuxDebPackage);
111111

112-
private static final BundlerParamInfo<String> LINUX_SHORTCUT_HINT = createStringBundlerParam(
113-
Arguments.CLIOptions.LINUX_SHORTCUT_HINT.getId());
112+
private static final BundlerParamInfo<Boolean> LINUX_SHORTCUT_HINT = new BundlerParamInfo<>(
113+
Arguments.CLIOptions.LINUX_SHORTCUT_HINT.getId(),
114+
Boolean.class,
115+
params -> false,
116+
(s, p) -> (s == null || "null".equalsIgnoreCase(s)) ? false : Boolean.valueOf(s)
117+
);
114118

115119
private static final BundlerParamInfo<String> LINUX_CATEGORY = createStringBundlerParam(
116120
Arguments.CLIOptions.LINUX_CATEGORY.getId());

src/jdk.jpackage/linux/classes/jdk/jpackage/internal/resources/template.desktop

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
Name=APPLICATION_NAME
33
Comment=APPLICATION_DESCRIPTION
44
Exec=APPLICATION_LAUNCHER
5-
STARTUP_DIRECTORY
65
Icon=APPLICATION_ICON
76
Terminal=false
87
Type=Application

src/jdk.jpackage/share/classes/jdk/jpackage/internal/Arguments.java

Lines changed: 11 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@
3737
import java.util.HashMap;
3838
import java.util.List;
3939
import java.util.Map;
40-
import java.util.Objects;
4140
import java.util.Optional;
4241
import java.util.Properties;
4342
import java.util.ResourceBundle;
@@ -349,13 +348,16 @@ public enum CLIOptions {
349348

350349
WIN_UPDATE_URL ("win-update-url", OptionCategories.PLATFORM_WIN),
351350

352-
WIN_MENU_HINT ("win-menu", OptionCategories.PLATFORM_WIN,
353-
createArgumentWithOptionalValueAction("win-menu")),
351+
WIN_MENU_HINT ("win-menu", OptionCategories.PLATFORM_WIN, () -> {
352+
setOptionValue("win-menu", true);
353+
}),
354354

355355
WIN_MENU_GROUP ("win-menu-group", OptionCategories.PLATFORM_WIN),
356356

357-
WIN_SHORTCUT_HINT ("win-shortcut", OptionCategories.PLATFORM_WIN,
358-
createArgumentWithOptionalValueAction("win-shortcut")),
357+
WIN_SHORTCUT_HINT ("win-shortcut",
358+
OptionCategories.PLATFORM_WIN, () -> {
359+
setOptionValue("win-shortcut", true);
360+
}),
359361

360362
WIN_SHORTCUT_PROMPT ("win-shortcut-prompt",
361363
OptionCategories.PLATFORM_WIN, () -> {
@@ -394,8 +396,10 @@ public enum CLIOptions {
394396
LINUX_PACKAGE_DEPENDENCIES ("linux-package-deps",
395397
OptionCategories.PLATFORM_LINUX),
396398

397-
LINUX_SHORTCUT_HINT ("linux-shortcut", OptionCategories.PLATFORM_LINUX,
398-
createArgumentWithOptionalValueAction("linux-shortcut")),
399+
LINUX_SHORTCUT_HINT ("linux-shortcut",
400+
OptionCategories.PLATFORM_LINUX, () -> {
401+
setOptionValue("linux-shortcut", true);
402+
}),
399403

400404
LINUX_MENU_GROUP ("linux-menu-group", OptionCategories.PLATFORM_LINUX);
401405

@@ -474,27 +478,9 @@ private static void nextArg() {
474478
context().pos++;
475479
}
476480

477-
private static void prevArg() {
478-
Objects.checkIndex(context().pos, context().argList.size());
479-
context().pos--;
480-
}
481-
482481
private static boolean hasNextArg() {
483482
return context().pos < context().argList.size();
484483
}
485-
486-
private static Runnable createArgumentWithOptionalValueAction(String option) {
487-
Objects.requireNonNull(option);
488-
return () -> {
489-
var value = popArg();
490-
if (value.startsWith("-")) {
491-
prevArg();
492-
setOptionValue(option, true);
493-
} else {
494-
setOptionValue(option, value);
495-
}
496-
};
497-
}
498484
}
499485

500486
enum OptionCategories {

src/jdk.jpackage/share/classes/jdk/jpackage/internal/FromParams.java

Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,6 @@
5252
import static jdk.jpackage.internal.StandardBundlerParam.VERSION;
5353
import static jdk.jpackage.internal.StandardBundlerParam.hasPredefinedAppImage;
5454
import static jdk.jpackage.internal.StandardBundlerParam.isRuntimeInstaller;
55-
import static jdk.jpackage.internal.util.function.ThrowingFunction.toFunction;
5655

5756
import java.io.IOException;
5857
import java.nio.file.Path;
@@ -172,31 +171,29 @@ static Optional<jdk.jpackage.internal.model.Package> getCurrentPackage(Map<Strin
172171
}
173172

174173
static Optional<LauncherShortcut> findLauncherShortcut(
175-
BundlerParamInfo<String> shortcutParam,
174+
BundlerParamInfo<Boolean> shortcutParam,
176175
Map<String, ? super Object> mainParams,
177176
Map<String, ? super Object> launcherParams) {
178177

179-
Optional<String> launcherValue;
178+
Optional<Boolean> launcherValue;
180179
if (launcherParams == mainParams) {
181180
// The main launcher
182181
launcherValue = Optional.empty();
183182
} else {
184183
launcherValue = shortcutParam.findIn(launcherParams);
185184
}
186185

187-
return launcherValue.map(ParsedLauncherShortcutStartupDirectory::parseForAddLauncher).or(() -> {
188-
return Optional.ofNullable(mainParams.get(shortcutParam.getID())).map(toFunction(value -> {
189-
if (value instanceof Boolean) {
190-
return new ParsedLauncherShortcutStartupDirectory(LauncherShortcutStartupDirectory.DEFAULT);
191-
} else {
192-
try {
193-
return ParsedLauncherShortcutStartupDirectory.parseForMainLauncher((String)value);
194-
} catch (IllegalArgumentException ex) {
195-
throw I18N.buildConfigException("error.invalid-option-value", value, "--" + shortcutParam.getID()).create();
196-
}
197-
}
198-
}));
199-
}).map(ParsedLauncherShortcutStartupDirectory::value).map(LauncherShortcut::new);
186+
return launcherValue.map(withShortcut -> {
187+
if (withShortcut) {
188+
return Optional.of(LauncherShortcutStartupDirectory.DEFAULT);
189+
} else {
190+
return Optional.<LauncherShortcutStartupDirectory>empty();
191+
}
192+
}).or(() -> {
193+
return shortcutParam.findIn(mainParams).map(_ -> {
194+
return Optional.of(LauncherShortcutStartupDirectory.DEFAULT);
195+
});
196+
}).map(LauncherShortcut::new);
200197
}
201198

202199
private static ApplicationLaunchers createLaunchers(

src/jdk.jpackage/share/classes/jdk/jpackage/internal/ParsedLauncherShortcutStartupDirectory.java

Lines changed: 0 additions & 70 deletions
This file was deleted.

src/jdk.jpackage/share/classes/jdk/jpackage/internal/model/LauncherShortcutStartupDirectory.java

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -36,24 +36,12 @@ public enum LauncherShortcutStartupDirectory {
3636
* Platform-specific default value.
3737
* <p>
3838
* On Windows, it indicates that the startup directory should be the package's
39-
* installation directory. I.e. same as {@link #INSTALL_DIR}.
39+
* installation directory.
4040
* <p>
4141
* On Linux, it indicates that a shortcut doesn't have the startup directory
4242
* configured explicitly.
4343
*/
44-
DEFAULT("true"),
45-
46-
/**
47-
* The 'app' directory in the installed application app image. This is the
48-
* directory that is referenced with {@link ApplicationLayout#appDirectory()}
49-
* method.
50-
*/
51-
APP_DIR("app-dir"),
52-
53-
/**
54-
* The installation directory of the package.
55-
*/
56-
INSTALL_DIR("install-dir");
44+
DEFAULT("true");
5745

5846
LauncherShortcutStartupDirectory(String stringValue) {
5947
this.stringValue = Objects.requireNonNull(stringValue);

src/jdk.jpackage/share/classes/jdk/jpackage/internal/resources/MainResources.properties

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,8 +82,6 @@ error.invalid-app-image=Error: app-image dir "{0}" generated by another jpackage
8282

8383
error.invalid-install-dir=Invalid installation directory "{0}"
8484

85-
error.invalid-option-value=Invalid value "{0}" of option {1}
86-
8785
MSG_BundlerFailed=Error: Bundler "{1}" ({0}) failed to produce a package
8886
MSG_BundlerConfigException=Bundler {0} skipped because of a configuration problem: {1} \n\
8987
Advice to fix: {2}

src/jdk.jpackage/windows/classes/jdk/jpackage/internal/WinFromParams.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,10 +105,10 @@ private static WinMsiPackage createWinMsiPackage(Map<String, ? super Object> par
105105
static final BundlerParamInfo<WinMsiPackage> MSI_PACKAGE = createPackageBundlerParam(
106106
WinFromParams::createWinMsiPackage);
107107

108-
private static final BundlerParamInfo<String> WIN_MENU_HINT = createStringBundlerParam(
108+
private static final BundlerParamInfo<Boolean> WIN_MENU_HINT = createBooleanBundlerParam(
109109
Arguments.CLIOptions.WIN_MENU_HINT.getId());
110110

111-
private static final BundlerParamInfo<String> WIN_SHORTCUT_HINT = createStringBundlerParam(
111+
private static final BundlerParamInfo<Boolean> WIN_SHORTCUT_HINT = createBooleanBundlerParam(
112112
Arguments.CLIOptions.WIN_SHORTCUT_HINT.getId());
113113

114114
public static final BundlerParamInfo<Boolean> CONSOLE_HINT = createBooleanBundlerParam(

src/jdk.jpackage/windows/classes/jdk/jpackage/internal/WixAppImageFragmentBuilder.java

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -471,12 +471,9 @@ private void addShortcutComponentGroup(XMLStreamWriter xml) throws
471471
if (folder.isRequestedFor(launcher)) {
472472
var workDirectory = folder.shortcut(launcher).startupDirectory().map(v -> {
473473
switch (v) {
474-
case DEFAULT, INSTALL_DIR -> {
474+
case DEFAULT -> {
475475
return INSTALLDIR;
476476
}
477-
case APP_DIR -> {
478-
return installedAppImage.appDirectory();
479-
}
480477
default -> {
481478
throw new AssertionError();
482479
}

0 commit comments

Comments
 (0)