<div dir="ltr">The reason why I want to modify their behavior is that a large number of programs have misused this method.<div>By modifying the behavior, we can fix them without modifying their  source code.<br></div><div><br></div><div>However, it may be a better choice to mark it as deprecated. </div><div>After deprecating them, we can provide new API  methods that use Locale.ROOT by default as a substitute.<br></div><div>Kotlin is using methods called lowercase() and uppercase() for this purpose, which I think can be used for reference.<br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Thu, Jan 26, 2023 at 9:36 PM Remi Forax <<a href="mailto:forax@univ-mlv.fr" target="_blank">forax@univ-mlv.fr</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div><div style="font-family:arial,helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)"><div><br></div><div><br></div><hr id="m_6038009635261837999m_2076067875287364145zwchr"><div><blockquote style="border-left:2px solid rgb(16,16,255);margin-left:5px;padding-left:5px;color:rgb(0,0,0);font-weight:normal;font-style:normal;text-decoration:none;font-family:Helvetica,Arial,sans-serif;font-size:12pt"><b>From: </b>"Glavo" <<a href="mailto:zjx001202@gmail.com" target="_blank">zjx001202@gmail.com</a>><br><b>To: </b>"core-libs-dev" <<a href="mailto:core-libs-dev@openjdk.org" target="_blank">core-libs-dev@openjdk.org</a>><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><blockquote style="border-left:2px solid rgb(16,16,255);margin-left:5px;padding-left:5px;color:rgb(0,0,0);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></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></div><div>I think the logical nest step is more to deprecate toLowerCase()/toUpperCase() than to change their implementation.<br></div><div><br></div><div>regards,<br></div><div>Rémi<br></div><div><br></div></div></div></div></blockquote></div>