From ea8fc5564e47855c84bc1ea3e0b4feaa1d733b52 Mon Sep 17 00:00:00 2001 From: Yasumasa Suenaga Date: Tue, 2 Jul 2024 21:11:35 +0900 Subject: [PATCH] 8303884: jlink --add-options plugin does not allow GNU style options to be provided --- .../classes/jdk/tools/jlink/internal/TaskHelper.java | 6 ++---- test/jdk/tools/jlink/plugins/AddOptionsPluginTest.java | 8 ++++---- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/TaskHelper.java b/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/TaskHelper.java index 2b4e6ca0a976c..25fb92400af36 100644 --- a/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/TaskHelper.java +++ b/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/TaskHelper.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2024, 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 @@ -545,9 +545,7 @@ public List handleOptions(T task, String[] args) throws BadArgs { } else if (i + 1 < args.length) { param = args[++i]; } - if (param == null || param.isEmpty() - || (param.length() >= 2 && param.charAt(0) == '-' - && param.charAt(1) == '-')) { + if (param == null || param.isEmpty()) { throw new BadArgs("err.missing.arg", name). showUsage(true); } diff --git a/test/jdk/tools/jlink/plugins/AddOptionsPluginTest.java b/test/jdk/tools/jlink/plugins/AddOptionsPluginTest.java index acb2e65fd382f..9b40908654399 100644 --- a/test/jdk/tools/jlink/plugins/AddOptionsPluginTest.java +++ b/test/jdk/tools/jlink/plugins/AddOptionsPluginTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 2024, 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 @@ -44,7 +44,7 @@ public class AddOptionsPluginTest { private static final String PROP = "add.options.plugin.test"; private static final String VALUE = "xyzzy"; - private static final String OPTS = "-D" + PROP + "=" + VALUE; + private static final String OPTS = String.format("--enable-preview -D%s=%s", PROP, VALUE); public static void main(String[] args) throws Throwable { @@ -65,9 +65,9 @@ public static void main(String[] args) throws Throwable { + (System.getProperty("os.name").startsWith("Windows") ? ".exe" : "")); var oa = ProcessTools.executeProcess(launcher.toString(), - "-XshowSettings:properties", "--version"); + "-Xlog:arguments=info", "-XshowSettings:properties", "--version"); oa.stderrShouldMatch("^ +" + PROP + " = " + VALUE + "$"); - + oa.stdoutShouldContain("--enable-preview"); } }