--- old/src/jdk/nashorn/internal/objects/NativeString.java 2013-05-27 18:52:57.407618456 +0530 +++ new/src/jdk/nashorn/internal/objects/NativeString.java 2013-05-27 18:52:57.235617594 +0530 @@ -38,6 +38,7 @@ import java.util.Arrays; import java.util.LinkedList; import java.util.List; +import java.util.Locale; import jdk.internal.dynalink.CallSiteDescriptor; import jdk.internal.dynalink.linker.GuardedInvocation; import jdk.internal.dynalink.linker.LinkRequest; @@ -997,7 +998,7 @@ */ @Function(attributes = Attribute.NOT_ENUMERABLE) public static Object toLowerCase(final Object self) { - return checkObjectToString(self).toLowerCase(); + return checkObjectToString(self).toLowerCase(Locale.ROOT); } /** @@ -1017,7 +1018,7 @@ */ @Function(attributes = Attribute.NOT_ENUMERABLE) public static Object toUpperCase(final Object self) { - return checkObjectToString(self).toUpperCase(); + return checkObjectToString(self).toUpperCase(Locale.ROOT); } /** --- old/src/jdk/nashorn/internal/runtime/ScriptEnvironment.java 2013-05-27 18:52:57.891620839 +0530 +++ new/src/jdk/nashorn/internal/runtime/ScriptEnvironment.java 2013-05-27 18:52:57.819620489 +0530 @@ -262,14 +262,19 @@ } this._callsite_flags = callSiteFlags; - final Option option = options.get("timezone"); - if (option != null) { - this._timezone = (TimeZone)option.getValue(); + final Option timezoneOption = options.get("timezone"); + if (timezoneOption != null) { + this._timezone = (TimeZone)timezoneOption.getValue(); } else { this._timezone = TimeZone.getDefault(); } - this._locale = Locale.getDefault(); + final Option localeOption = options.get("locale"); + if (localeOption != null) { + this._locale = (Locale)localeOption.getValue(); + } else { + this._locale = Locale.getDefault(); + } } /** --- old/src/jdk/nashorn/internal/runtime/options/OptionTemplate.java 2013-05-27 18:52:58.219622474 +0530 +++ new/src/jdk/nashorn/internal/runtime/options/OptionTemplate.java 2013-05-27 18:52:58.143622095 +0530 @@ -152,6 +152,9 @@ case "timezone": this.defaultValue = TimeZone.getDefault().getID(); break; + case "locale": + this.defaultValue = Locale.getDefault().toLanguageTag(); + break; default: break; } --- old/src/jdk/nashorn/internal/runtime/options/Options.java 2013-05-27 18:52:58.539624071 +0530 +++ new/src/jdk/nashorn/internal/runtime/options/Options.java 2013-05-27 18:52:58.455623644 +0530 @@ -499,6 +499,8 @@ case "timezone": // default value "TimeZone.getDefault()" return new Option<>(TimeZone.getTimeZone(value)); + case "locale": + return new Option<>(Locale.forLanguageTag(value)); case "keyvalues": return new KeyValueOption(value); case "log": --- old/src/jdk/nashorn/internal/runtime/resources/Options.properties 2013-05-27 18:52:58.859625647 +0530 +++ new/src/jdk/nashorn/internal/runtime/resources/Options.properties 2013-05-27 18:52:58.767625193 +0530 @@ -332,6 +332,15 @@ type=TimeZone \ } +nashorn.option.locale = { \ + name="--locale", \ + short_name="-l", \ + is_undocumented=true, \ + params="", \ + desc="Set Locale for script execution.", \ + type=Locale \ +} + nashorn.option.trace.callsites = { \ name="--trace-callsites", \ short_name="-tcs", \ --- /dev/null 2013-05-27 13:18:41.313334813 +0530 +++ new/test/script/basic/JDK-8015352.js 2013-05-27 18:52:59.095626818 +0530 @@ -0,0 +1,46 @@ +/* + * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/** + * JDK-8015352: "i".toUpperCase() => currently returns "İ", but should be "I" (with Turkish locale) + * + * @test + * @option --locale=tr-TR + * @run + */ + +if ("i".toUpperCase() != "I") { + fail("'i'.toUpperCase() is not 'I'"); +} + +if ("i".toUpperCase() == "i".toLocaleUpperCase()) { + fail("'i'.toUpperCase() == 'i'.toLocaleUpperCase()"); +} + +if ("I".toLowerCase() != "i") { + fail("'I'.toLowerCase() is not 'i'"); +} + +if ("I".toLowerCase() == "I".toLocaleLowerCase()) { + fail("'i'.toLowerCase() == 'i'.toLocaleLowerCase()"); +}