jdk6: LazyInitialization in java.io.File
Alan Bateman
Alan.Bateman at Sun.COM
Mon Jan 18 20:09:20 UTC 2010
Nico R. wrote:
> Hello!
>
> 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.
>
> Regards
>
Well spotted - that's what we get for having a field and method with the
same name! That code has been replaced in jdk7 so it's not an issue
there. For jdk6 code we should just initialize a field to the property
value (like in jdk7) and the temporaryDirectory method return the value.
-Alan.
More information about the core-libs-dev
mailing list