<html><body><div style="font-family: arial, helvetica, sans-serif; font-size: 12pt; color: #000000"><div><br></div><div><br></div><hr id="zwchr" data-marker="__DIVIDER__"><div data-marker="__HEADERS__"><blockquote style="border-left:2px solid #1010FF;margin-left:5px;padding-left:5px;color:#000;font-weight:normal;font-style:normal;text-decoration:none;font-family:Helvetica,Arial,sans-serif;font-size:12pt;"><b>From: </b>"Glavo" <zjx001202@gmail.com><br><b>To: </b>"core-libs-dev" <core-libs-dev@openjdk.org><br><b>Sent: </b>Thursday, January 26, 2023 1:35:06 PM<br><b>Subject: </b>[Proposal] Make toLowerCase and toUpperCase based on Locale.ROOT by default<br></blockquote></div><div data-marker="__QUOTED_TEXT__"><blockquote style="border-left:2px solid #1010FF;margin-left:5px;padding-left:5px;color:#000;font-weight:normal;font-style:normal;text-decoration:none;font-family:Helvetica,Arial,sans-serif;font-size:12pt;"><div dir="ltr"><div>At present, the no-parameter toLowerCase and toUpperCase methods of String are based on the default locale.<br><br><div>I checked all the uses of this method in OpenJDK, and found that most of the use cases are suspicious, and even there are some hidden bugs.<br></div><div>For example, I just found that jdk.incubator.vector.LaneType will trigger assertion failure on Turkish locale, and opened a PR for this problem:<br></div><br><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px"><div><a href="https://github.com/openjdk/panama-vector/pull/210" target="_blank">https://github.com/openjdk/panama-vector/pull/210</a><br data-mce-bogus="1"></div><br></blockquote>In addition to such obvious problems, some use cases behave suspiciously after calling Locale.setDefault.<br><div>I am investigating these problems and preparing to open a PR to solve these hidden bugs.<br></div><br><div>In all the third-party libraries I have used, I have never seen the correct use of these two methods.<br></div><div>Although the behavior of modifying API methods is destructive, I think it is worthwhile to consider whether to modify its behavior for such a suspicious method.<br></div><div>If users need locale-sensitive case conversion, it may be better to explicitly use Locale.getDefault().<br></div><div>Using Locale.ROOT as the default value also helps to keep the behavior of these two methods consistent with equalsIgnoreCase, Character.toLowerCase/toUpperCase and other methods.<br></div><br><div>This is my rough idea. I hope to get your suggestions.</div></div></div></blockquote><div><br></div><div>yes, it's a very very common bug, IntelliJ already warns when toLowerCase()/toUpperCase() is used without a Locale.<br data-mce-bogus="1"></div><div>I think the logical nest step is more to deprecate toLowerCase()/toUpperCase() than to change their implementation.<br data-mce-bogus="1"></div><div><br></div><div>regards,<br data-mce-bogus="1"></div><div>RĂ©mi<br data-mce-bogus="1"></div><div><br data-mce-bogus="1"></div></div></div></body></html>