←Older revision | Revision as of 18:04, 6 April 2010 | ||
Line 26: | Line 26: | ||
[[User:AndreiBadea|AndreiBadea]] 15:46, 17 October 2008 (UTC) | [[User:AndreiBadea|AndreiBadea]] 15:46, 17 October 2008 (UTC) | ||
+ | ----- | ||
Even the test which initializes the variable in both branches may not work as the JLS declares that the optimization can reduce reachability of the variable compared to naive reachebility. In your case retValue is not used so it can be gced right after factory call. To prevent it you have to synchronize such a block of code with finilizer. Nice article about this problem is on the Jeremy Manson's blog here: http://jeremymanson.blogspot.com/2010/01/garbage-collection-references.html | Even the test which initializes the variable in both branches may not work as the JLS declares that the optimization can reduce reachability of the variable compared to naive reachebility. In your case retValue is not used so it can be gced right after factory call. To prevent it you have to synchronize such a block of code with finilizer. Nice article about this problem is on the Jeremy Manson's blog here: http://jeremymanson.blogspot.com/2010/01/garbage-collection-references.html | ||
+ | |||
+ | [[User:Tomas.Zezula|Tomas.Zezula]] 20:02, 06 April 2010 (CET) |