ModuleDescriptor#toString(Set<>, String) may produce unexpected results.
Andrej Golovnin
andrej.golovnin at gmail.com
Tue Dec 12 07:20:56 UTC 2017
Hi all,
the ModuleDescriptor#toString(Set<>, String) method uses
String#toLowerCase() in the line 2607 without specifying a locale. And
this may lead to unexpected results when you start the JVM for example
with the Turkish locale. This can be fixed by using
String#toLowerCase(Locale) with Locale.ROOT as the argument.
The suggested change is attached as diff.
Best regards,
Andrej Golovnin
-------------- next part --------------
diff --git a/src/java.base/share/classes/java/lang/module/ModuleDescriptor.java b/src/java.base/share/classes/java/lang/module/ModuleDescriptor.java
--- a/src/java.base/share/classes/java/lang/module/ModuleDescriptor.java
+++ b/src/java.base/share/classes/java/lang/module/ModuleDescriptor.java
@@ -39,6 +39,7 @@
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
+import java.util.Locale;
import java.util.Map;
import java.util.Objects;
import java.util.Optional;
@@ -2603,7 +2604,7 @@
* Returns a string containing the given set of modifiers and label.
*/
private static <M> String toString(Set<M> mods, String what) {
- return (Stream.concat(mods.stream().map(e -> e.toString().toLowerCase()),
+ return (Stream.concat(mods.stream().map(e -> e.toString().toLowerCase(Locale.ROOT)),
Stream.of(what)))
.collect(Collectors.joining(" "));
}
More information about the jigsaw-dev
mailing list