Return-Path: Delivered-To: apmail-harmony-dev-archive@www.apache.org Received: (qmail 30947 invoked from network); 31 Dec 2008 05:33:03 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 31 Dec 2008 05:33:03 -0000 Received: (qmail 92219 invoked by uid 500); 31 Dec 2008 05:33:01 -0000 Delivered-To: apmail-harmony-dev-archive@harmony.apache.org Received: (qmail 92191 invoked by uid 500); 31 Dec 2008 05:33:01 -0000 Mailing-List: contact dev-help@harmony.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@harmony.apache.org Delivered-To: mailing list dev@harmony.apache.org Received: (qmail 92177 invoked by uid 99); 31 Dec 2008 05:33:01 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 30 Dec 2008 21:33:01 -0800 X-ASF-Spam-Status: No, hits=-0.0 required=10.0 tests=SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of xu.regis@gmail.com designates 74.125.44.155 as permitted sender) Received: from [74.125.44.155] (HELO yx-out-1718.google.com) (74.125.44.155) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 31 Dec 2008 05:32:53 +0000 Received: by yx-out-1718.google.com with SMTP id 36so1959306yxh.0 for ; Tue, 30 Dec 2008 21:32:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from :user-agent:mime-version:to:subject:references:in-reply-to :content-type:content-transfer-encoding; bh=pmDyrp1LvcH25NvOU7OTZ/vApfUpzPaha6M1Zy0GCtg=; b=wnbLkhjjyu+oP/1pjdBmx+4xTaRTAq+MVjdY96CA7C/E2OEWvaDTzpr+DyHELZyf3P tDKnXBBO8iCOq0xbbnepjJwPIhQ9KArvt7tICTT4kOXQ/X0rvHNqnZMD80AKNrZb6bBO Emr3gm9ZfxNOVotQ9rJnKy4v7r1afefHItOoQ= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:user-agent:mime-version:to:subject:references :in-reply-to:content-type:content-transfer-encoding; b=k4i8ZwG3148knQ8TJyzHH2fofNnQ/9nFeoqqHxIF+5ffvdFn02ABsuA6x9DSbKsmbN uv3hfJ1AKpMiUn3MTNOMcUx8QrtTPenY2JMroLfpGPgNTtO4o/a3mQmoL4oln3Tr769m DILNGqyBMxg6CHMk5eoYjVL3FO6BLhPmNW9cM= Received: by 10.100.128.2 with SMTP id a2mr8760513and.93.1230701552286; Tue, 30 Dec 2008 21:32:32 -0800 (PST) Received: from ?9.123.233.47? ([220.248.0.145]) by mx.google.com with ESMTPS id c23sm29084199ana.55.2008.12.30.21.32.25 (version=TLSv1/SSLv3 cipher=RC4-MD5); Tue, 30 Dec 2008 21:32:31 -0800 (PST) Message-ID: <495B03DF.2000502@gmail.com> Date: Wed, 31 Dec 2008 13:32:15 +0800 From: Regis User-Agent: Thunderbird 2.0.0.18 (Windows/20081105) MIME-Version: 1.0 To: dev@harmony.apache.org Subject: Re: [classlib][prefs] default provider of prefs References: <4959F70B.7080504@gmail.com> <3b3f27c60812300737o2940a2dkdd219bd8b04eb9d9@mail.gmail.com> In-Reply-To: <3b3f27c60812300737o2940a2dkdd219bd8b04eb9d9@mail.gmail.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Checked: Checked by ClamAV on apache.org Nathan Beyer wrote: > I doubt there is any significant reason for it other than the default > is based on the OS and the native might have been an easy decision > point. Maybe. > > Moving it to Java code is probably fine - the code just needs to use a > default based on the OS. I try the following patch, all tests are passed, so I think we could move it to java code safely. I used File.pathSeparatorChar to test the platform, is there any better way to do this? Index: modules/luni/src/main/native/luni/shared/luniglob.c ===================================================================== --- modules/luni/src/main/native/luni/shared/luniglob.c +++ modules/luni/src/main/native/luni/shared/luniglob.c @@ -162,21 +162,6 @@ JNI_OnLoad (JavaVM * vm, void *reserved) } } - /* Set default PreferencesFactory implementation */ - (*vmInterface)->GetSystemProperty (vmInterface, "java.util.prefs.PreferencesFactory", &propVal); - if (propVal == NULL) { - propRes = (*vmInterface)->SetSystemProperty (vmInterface, - "java.util.prefs.PreferencesFactory", -#ifdef _WIN32 - "java.util.prefs.RegistryPreferencesFactoryImpl"); -#else - "java.util.prefs.FilePreferencesFactoryImpl"); -#endif - if (VMI_ERROR_NONE != propRes) { - /* goto fail2; */ - } - } - /* Prefer Xalan compiler for better performance, see HARMONY-3209. */ (*vmInterface)->GetSystemProperty (vmInterface, "javax.xml.transform.TransformerFactory", &propVal); if (propVal == NULL) { Index: modules/prefs/src/main/java/java/util/prefs/Preferences.java ===================================================================== --- modules/prefs/src/main/java/java/util/prefs/Preferences.java +++ modules/prefs/src/main/java/java/util/prefs/Preferences.java @@ -16,6 +16,7 @@ package java.util.prefs; +import java.io.File; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; @@ -127,6 +128,13 @@ public abstract class Preferences { return System.getProperty("java.util.prefs.PreferencesFactory"); //$NON-NLS-1$ } }); + if (factoryClassName == null) { + if (File.pathSeparatorChar == '\\') { + factoryClassName = "java.util.prefs.RegistryPreferencesFactoryImpl"; + } else { + factoryClassName = "java.util.prefs.FilePreferencesFactoryImpl"; + } + } try { ClassLoader loader = Thread.currentThread().getContextClassLoader(); if(loader == null){ > -Nathan > > On Tue, Dec 30, 2008 at 4:25 AM, Regis wrote: >> Hi, >> >> The provider of prefs is controlled by the property >> "java.util.prefs.PreferencesFactory" in Harmony, and we also have different >> default values for it on Linux and Windows, but the default values are set >> in luni module at modules/luni/src/main/native/luni/shared/luniglob.c, >> are there any special concerns that we must do it in luni native code? Or is >> it possible set it in prefs module with java code, like this: >> >> if (factoryClassName == null) { >> if (isWindows) { >> factoryClassName = >> "java.util.prefs.RegistryPreferencesFactoryImpl"; >> } else { >> factoryClassName = >> "java.util.prefs.FilePreferencesFactoryImpl"; >> } >> } >> >> I think there must be a way to get current platform at runtime in java. >> >> -- >> Best Regards, >> Regis. >> > -- Best Regards, Regis.