jdk6: LazyInitialization in java.io.File

Tom Hawtin Thomas.Hawtin at Sun.COM
Mon Jan 18 20:07:27 UTC 2010


Nico R. wrote:

> In java.io.File.createTempFile(String,String,File) (see
> <URL:http://hg.openjdk.java.net/jdk6/jdk6/jdk/file/ea5036d799e5/src/share/classes/java/io/File.java>),
> line 1797 says:
> 
>         String tmpDir = LazyInitialization.temporaryDirectory();
> 
> LazyInitialization, line 1683, has
> 
>     static final String temporaryDirectory = temporaryDirectory();
> 
> 
> Shouldn’t the createTempFile method read from the /field/ in
> LazyInitialization instead of calling the /method/? If I got this
> correctly, the brackets in line 1797 should be removed.

Well spotted. Prior to the CR 6721753[1] fix File.getTempDir hand-coded 
lazy initialisation of tmpdir. It shouldn't make an enormous amount of 
difference: updates to the system property currently change the temp 
directory used; the performance degredation should be trivial.

I guess Alan will sort it.

Tom

[1] http://sunsolve.sun.com/search/document.do?assetkey=1-66-244986-1



More information about the core-libs-dev mailing list