JDK-8029800 : Flags.java uses String.toLowerCase without specifying Locale
  • Type: Bug
  • Component: tools
  • Sub-Component: javac
  • Affected Version: 8
  • Priority: P4
  • Status: Closed
  • Resolution: Fixed
  • Submitted: 2013-12-09
  • Updated: 2014-08-05
  • Resolved: 2013-12-17
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 8 JDK 9
8u20Fixed 9 b01Fixed
Related Reports
Relates :  
Relates :  
Description
The constructor of com.sun.tools.javac.code.Flags.Flag uses toLowerCase without specifying locale, which may lead to problems when Flag.PUBLIC is converted to lower case on (e.g.) Turkish locale and then used.

This leads to the following problem. Consider this source code:
---
public class LocaleTest { }
---

Run javac as:
---
$ javac -J-Duser.region=TR -J-Duser.language=tr -printsource -d target LocaleTest.java
---

The outcome will be:
---
publ\u0131c class LocaleTest {
    
    publ\u0131c LocaleTest() {
        super();
    }
}
---

Which is unexpected, expected is:
---
public class LocaleTest {
    
    public LocaleTest() {
        super();
    }
}
---
Comments
Looking into this, String.toLowerCase without a parameter is used relatively often in langtools (~40 times). Some of these may be benign, some may have effects observable by the user. I intend to investigate (possibly preventing use of toLowerCase in langtools altogether).
09-12-2013

note -printsource is an undocumented debugging flag
09-12-2013

Raised priority to P4, knowing this will be deferred for JDK 8. This should be fixed soon in 9 and backported to 8u, 7u.
09-12-2013