Return-Path: Delivered-To: apmail-harmony-dev-archive@www.apache.org Received: (qmail 13333 invoked from network); 6 Jul 2010 20:01:08 -0000 Received: from unknown (HELO mail.apache.org) (140.211.11.3) by 140.211.11.9 with SMTP; 6 Jul 2010 20:01:08 -0000 Received: (qmail 47047 invoked by uid 500); 6 Jul 2010 20:01:08 -0000 Delivered-To: apmail-harmony-dev-archive@harmony.apache.org Received: (qmail 46805 invoked by uid 500); 6 Jul 2010 20:01:07 -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 46796 invoked by uid 99); 6 Jul 2010 20:01:07 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 06 Jul 2010 20:01:07 +0000 X-ASF-Spam-Status: No, hits=-1.6 required=10.0 tests=FREEMAIL_FROM,RCVD_IN_DNSWL_MED,SPF_NEUTRAL,T_TO_NO_BRKTS_FREEMAIL X-Spam-Check-By: apache.org Received-SPF: neutral (nike.apache.org: 194.196.100.165 is neither permitted nor denied by domain of mark.hindess@googlemail.com) Received: from [194.196.100.165] (HELO mtagate5.uk.ibm.com) (194.196.100.165) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 06 Jul 2010 20:00:57 +0000 Received: from d06nrmr1806.portsmouth.uk.ibm.com (d06nrmr1806.portsmouth.uk.ibm.com [9.149.39.193]) by mtagate5.uk.ibm.com (8.13.1/8.13.1) with ESMTP id o66Jwagx027495 for ; Tue, 6 Jul 2010 19:58:36 GMT Received: from d06av04.portsmouth.uk.ibm.com (d06av04.portsmouth.uk.ibm.com [9.149.37.216]) by d06nrmr1806.portsmouth.uk.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id o66JwaTB1589426 for ; Tue, 6 Jul 2010 20:58:36 +0100 Received: from d06av04.portsmouth.uk.ibm.com (loopback [127.0.0.1]) by d06av04.portsmouth.uk.ibm.com (8.12.11.20060308/8.13.3) with ESMTP id o66JwajR012724 for ; Tue, 6 Jul 2010 20:58:36 +0100 Received: from anaheim.local (sig-9-146-231-14.de.ibm.com [9.146.231.14]) by d06av04.portsmouth.uk.ibm.com (8.12.11.20060308/8.12.11) with ESMTP id o66JwZ7R012706 for ; Tue, 6 Jul 2010 20:58:36 +0100 Message-Id: <201007061958.o66JwZ7R012706@d06av04.portsmouth.uk.ibm.com> X-Mailer: exmh version 2.7.2 01/07/2005 (debian 1:2.7.2-18) with nmh-1.3 In-reply-to: <4C333DB6.1000305@gmail.com> References: <20100705030517.1F57223889E5@eris.apache.org> <201007061356.o66Du8Md001843@d06av02.portsmouth.uk.ibm.com> <4C333DB6.1000305@gmail.com> Comments: In-reply-to Tim Ellison message dated "Tue, 06 Jul 2010 15:29:10 +0100." From: Mark Hindess To: dev@harmony.apache.org Subject: Re: svn commit: r960424 - /harmony/enhanced/java/trunk/classlib/modules/luni/src/main/java/java/io/File.java Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Date: Tue, 06 Jul 2010 20:58:27 +0100 X-Virus-Checked: Checked by ClamAV on apache.org In message <4C333DB6.1000305@gmail.com>, Tim Ellison writes: > > On 06/Jul/2010 14:56, Mark Hindess wrote: > > Regis, > > > > This breaks the build for the IBM VME (from developerWorks). Since they > > don't have a sun.misc.Unsafe, so the AtomicInteger can't be resolved. > > > > Any ideas how to fix this? > > > > Also, the luni.jar manifest says: > > > > java.util.concurrent;resolution:=optional, > > > > I wonder when it becomes non-optional. Personally, I'd say breaking > > java.io.File would be enough to make it mandatory. > > :-) > > To save you wondering, the imports are 'optional' when they are only > required by the tests for a module, so the new dependency in this commit > should indeed change concurrent to be a hard requirement for luni. > We use the same manifest file in the Eclipse project (containing the > impl and test together) as we do in the impl JAR, which is why we have > to accommodate the tests in the declarations. Ok. That was what I suspected but then I wondered why the concurrent dependency didn't have " hy_usage=test" like the other optional dependencies. Regards, Mark. > > In message <20100705030517.1F57223889E5@eris.apache.org>, regisxu@apache.org > > writes: > >> Author: regisxu > >> Date: Mon Jul 5 03:05:16 2010 > >> New Revision: 960424 > >> > >> URL: http://svn.apache.org/viewvc?rev=960424&view=rev > >> Log: > >> make File.createTempFile thread-safe to avoid to return the same file mult > ipl > >> e times > >> > >> File.counter could be accessed by multiple threads, so use AtomicInteger t > o m > >> ake > >> sure each thread using different int value to create temp file. > >> > >> Modified: > >> harmony/enhanced/java/trunk/classlib/modules/luni/src/main/java/java/i > o/F > >> ile.java > >> > >> Modified: harmony/enhanced/java/trunk/classlib/modules/luni/src/main/java/ > jav > >> a/io/File.java > >> URL: http://svn.apache.org/viewvc/harmony/enhanced/java/trunk/classlib/mod > ule > >> s/luni/src/main/java/java/io/File.java?rev=960424&r1=960423&r2=960424&view > =di > >> ff > >> ========================================================================== > === > >> = > >> --- harmony/enhanced/java/trunk/classlib/modules/luni/src/main/java/java/i > o/F > >> ile.java (original) > >> +++ harmony/enhanced/java/trunk/classlib/modules/luni/src/main/java/java/i > o/F > >> ile.java Mon Jul 5 03:05:16 2010 > >> @@ -24,6 +24,7 @@ import java.security.AccessController; > >> import java.security.SecureRandom; > >> import java.util.ArrayList; > >> import java.util.List; > >> +import java.util.concurrent.atomic.AtomicInteger; > >> > >> import org.apache.harmony.luni.internal.io.FileCanonPathCache; > >> import org.apache.harmony.luni.util.DeleteOnExit; > >> @@ -79,7 +80,7 @@ public class File implements Serializabl > >> public static final String pathSeparator; > >> > >> /* Temp file counter */ > >> - private static int counter; > >> + private static AtomicInteger counter = new AtomicInteger(0); > >> > >> private static boolean caseSensitive; > >> > >> @@ -1300,13 +1301,13 @@ public class File implements Serializabl > >> } > >> > >> private static File genTempFile(String prefix, String suffix, File di > rec > >> tory) { > >> - if (counter == 0) { > >> + if (counter.get() == 0) { > >> int newInt = new SecureRandom().nextInt(); > >> - counter = ((newInt / 65535) & 0xFFFF) + 0x2710; > >> + counter.compareAndSet(0, ((newInt / 65535) & 0xFFFF) + 0x2710 > ); > >> } > >> StringBuilder newName = new StringBuilder(); > >> newName.append(prefix); > >> - newName.append(counter++); > >> + newName.append(counter.getAndIncrement()); > >> newName.append(suffix); > >> return new File(directory, newName.toString()); > >> } > >> > > > > > > >