< prev index next >

src/java.base/share/classes/jdk/internal/module/ModulePatcher.java

Print this page
rev 14279 : [mq]: 8140281-deprecation-optional.get


 257             this.mref = mref;
 258             this.delegateCodeSourceURL = codeSourceURL(mref);
 259         }
 260 
 261         /**
 262          * Closes all resource finders.
 263          */
 264         private static void closeAll(List<ResourceFinder> finders) {
 265             for (ResourceFinder finder : finders) {
 266                 try { finder.close(); } catch (IOException ioe) { }
 267             }
 268         }
 269 
 270         /**
 271          * Returns the code source URL for the given module.
 272          */
 273         private static URL codeSourceURL(ModuleReference mref) {
 274             try {
 275                 Optional<URI> ouri = mref.location();
 276                 if (ouri.isPresent())
 277                     return ouri.get().toURL();
 278             } catch (MalformedURLException e) { }
 279             return null;
 280         }
 281 
 282         /**
 283          * Returns the ModuleReader to delegate to when the resource is not
 284          * found in a patch location.
 285          */
 286         private ModuleReader delegate() throws IOException {
 287             ModuleReader r = delegate;
 288             if (r == null) {
 289                 synchronized (this) {
 290                     r = delegate;
 291                     if (r == null) {
 292                         delegate = r = mref.open();
 293                     }
 294                 }
 295             }
 296             return r;
 297         }




 257             this.mref = mref;
 258             this.delegateCodeSourceURL = codeSourceURL(mref);
 259         }
 260 
 261         /**
 262          * Closes all resource finders.
 263          */
 264         private static void closeAll(List<ResourceFinder> finders) {
 265             for (ResourceFinder finder : finders) {
 266                 try { finder.close(); } catch (IOException ioe) { }
 267             }
 268         }
 269 
 270         /**
 271          * Returns the code source URL for the given module.
 272          */
 273         private static URL codeSourceURL(ModuleReference mref) {
 274             try {
 275                 Optional<URI> ouri = mref.location();
 276                 if (ouri.isPresent())
 277                     return ouri.getWhenPresent().toURL();
 278             } catch (MalformedURLException e) { }
 279             return null;
 280         }
 281 
 282         /**
 283          * Returns the ModuleReader to delegate to when the resource is not
 284          * found in a patch location.
 285          */
 286         private ModuleReader delegate() throws IOException {
 287             ModuleReader r = delegate;
 288             if (r == null) {
 289                 synchronized (this) {
 290                     r = delegate;
 291                     if (r == null) {
 292                         delegate = r = mref.open();
 293                     }
 294                 }
 295             }
 296             return r;
 297         }


< prev index next >