--- a/src/jdk.jpackage/share/native/libapplauncher/JavaVirtualMachine.cpp Wed Jul 03 17:46:04 2019 -0400
+++ b/src/jdk.jpackage/share/native/libapplauncher/JavaVirtualMachine.cpp Sun Jul 07 19:40:48 2019 -0400
@@ -84,15 +84,30 @@
}
void JavaOptions::AppendValues(OrderedMap<TString, TString> Values) {
- std::vector<TString> orderedKeys = Values.GetKeys();
+ if (Values.GetAllowDuplicates()) {
+ for (int i = 0; i < (int)Values.Count(); i++) {
+ TString name, value;
+
+ bool bResult = Values.GetKey(i, name);
+ bResult &= Values.GetValue(i, value);
- for (std::vector<TString>::const_iterator iterator = orderedKeys.begin();
- iterator != orderedKeys.end(); iterator++) {
- TString name = *iterator;
- TString value;
+ if (bResult) {
+ AppendValue(name, value);
+ }
+ }
+ } else { // In case we asked to add values from OrderedMap with allow
+ // duplicates set to false. Not used now, but should avoid possible
+ // bugs.
+ std::vector<TString> orderedKeys = Values.GetKeys();
- if (Values.GetValue(name, value) == true) {
- AppendValue(name, value);
+ for (std::vector<TString>::const_iterator iterator = orderedKeys.begin();
+ iterator != orderedKeys.end(); iterator++) {
+ TString name = *iterator;
+ TString value;
+
+ if (Values.GetValue(name, value) == true) {
+ AppendValue(name, value);
+ }
}
}
}
--- a/src/jdk.jpackage/share/native/libapplauncher/OrderedMap.h Wed Jul 03 17:46:04 2019 -0400
+++ b/src/jdk.jpackage/share/native/libapplauncher/OrderedMap.h Sun Jul 07 19:40:48 2019 -0400
@@ -89,6 +89,7 @@
OrderedMap(const OrderedMap<key_type, mapped_type> &Value) {
Append(Value);
+ FAllowDuplicates = Value.GetAllowDuplicates();
}
~OrderedMap() {
@@ -99,6 +100,10 @@
FAllowDuplicates = Value;
}
+ bool GetAllowDuplicates() const {
+ return FAllowDuplicates;
+ }
+
iterator begin() {
return FList.begin();
}
@@ -214,6 +219,32 @@
return result;
}
+ bool GetKey(int index, key_type &Value) {
+ if (index < 0 || index >= (int)FList.size()) {
+ return false;
+ }
+ container_type *item = FList.at(index);
+ if (item != NULL) {
+ Value = item->first;
+ return true;
+ }
+
+ return false;
+ }
+
+ bool GetValue(int index, mapped_type &Value) {
+ if (index < 0 || index >= (int)FList.size()) {
+ return false;
+ }
+ container_type *item = FList.at(index);
+ if (item != NULL) {
+ Value = item->second;
+ return true;
+ }
+
+ return false;
+ }
+
mapped_type &operator[](key_type Key) {
container_type* item = FMap[Key];
assert(item != NULL);
@@ -227,6 +258,7 @@
OrderedMap& operator= (OrderedMap &Value) {
Clear();
+ FAllowDuplicates = Value.GetAllowDuplicates();
Append(Value);
return *this;
}
--- a/src/jdk.jpackage/share/native/libapplauncher/Package.cpp Wed Jul 03 17:46:04 2019 -0400
+++ b/src/jdk.jpackage/share/native/libapplauncher/Package.cpp Sun Jul 07 19:40:48 2019 -0400
@@ -58,6 +58,9 @@
FBootFields = new PackageBootFields();
FDebugging = dsNone;
+ // Allow duplicates for Java options, so we can have multiple --add-exports
+ // or similar args.
+ FBootFields->FJavaOptions.SetAllowDuplicates(true);
FBootFields->FPackageRootDirectory = platform.GetPackageRootDirectory();
FBootFields->FPackageAppDirectory = platform.GetPackageAppDirectory();
FBootFields->FPackageLauncherDirectory =
--- a/test/jdk/tools/jpackage/share/JavaOptionsEqualsTest.java Wed Jul 03 17:46:04 2019 -0400
+++ b/test/jdk/tools/jpackage/share/JavaOptionsEqualsTest.java Sun Jul 07 19:40:48 2019 -0400
@@ -40,6 +40,12 @@
private static final String OUTPUT = "output";
+ private static final String WARNING_1
+ = "WARNING: Unknown module: me.mymodule.foo";
+
+ private static final String WARNING_2
+ = "WARNING: Unknown module: other.mod.bar";
+
private static final String[] CMD = {
"--input", "input",
"--description", "the two options below should cause two app execution "
@@ -70,6 +76,9 @@
}
String output = Files.readString(outfile.toPath());
+ System.out.println("App output:");
+ System.out.print(output);
+
String[] result = JPackageHelper.splitAndFilter(output);
if (result.length != 4) {
throw new AssertionError(
@@ -77,16 +86,17 @@
+ " - output: " + output);
}
- if (!result[0].startsWith("WARNING: Unknown module: me.mymodule.foo")){
- throw new AssertionError("Unexpected result[0]: " + result[0]);
+ String nextWarning = WARNING_1;
+ if (!result[0].startsWith(nextWarning)){
+ nextWarning = WARNING_2;
+ if (!result[0].startsWith(WARNING_2)){
+ throw new AssertionError("Unexpected result[0]: " + result[0]);
+ } else {
+ nextWarning = WARNING_1;
+ }
}
- if (result[1].equals(result[0])) {
- System.err.println("--- This is known bug JDK-8224486, remove this "
- + "if/else block when JDK-8224486 is fixed");
- } else
-
- if (!result[1].startsWith("WARNING: Unknown module: other.mod.bar")) {
+ if (!result[1].startsWith(nextWarning)) {
throw new AssertionError("Unexpected result[1]: " + result[1]);
}