In message <4c333db6.1000...@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.1f5722388...@eris.apache.org>, regi...@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()); > >> } > >> > > > > > > >