RFR: 8060130: Simplify the synchronization of defining and getting java.lang.Package

Peter Levart peter.levart at gmail.com
Sun Oct 12 10:52:00 UTC 2014

On 10/12/2014 12:40 PM, Peter Levart wrote:
> I also wonder if the lazy loading of Manifest in CachedManifest is 
> necessary. If you look at the only usage of 
> CachedManifest.getManifest() method (in Package.defineSystemPackage()):
>         CachedManifest cachedManifest = createCachedManifest(fn);
>         pkgs.putIfAbsent(name, new Package(name, 
> cachedManifest.getManifest(),
>                 cachedManifest.getURL()));
> ...you can see that getManifest() is called immediately after 
> obtaining the CacheManifest.  So there's no need for lazy loading. 
> Loading the Manifest in CachedManifest constructor would be just fine.

..Ah, you can do that, yes, but then you have to use synchronization in 
createCachedManifest in order to avoid redundant concurrent loading of 
Manifest. And that would be a good thing since then you avoid concurrent 
resolving of fileName -> URL too in one go.


More information about the core-libs-dev mailing list