src/share/classes/java/lang/Package.java

Print this page
rev 3509 : 7021209: convert lang, math, util to use try-with-resources
Reviewed-by: XXX


 559                 // Convert to "."-separated package name
 560                 name = name.substring(0, name.length() - 1).replace('/', '.');
 561                 Package pkg;
 562                 Manifest man = mans.get(fn);
 563                 if (man != null) {
 564                     pkg = new Package(name, man, url, null);
 565                 } else {
 566                     pkg = new Package(name, null, null, null,
 567                                       null, null, null, null, null);
 568                 }
 569                 pkgs.put(name, pkg);
 570                 return pkg;
 571             }
 572         });
 573     }
 574 
 575     /*
 576      * Returns the Manifest for the specified JAR file name.
 577      */
 578     private static Manifest loadManifest(String fn) {
 579         try {
 580             FileInputStream fis = new FileInputStream(fn);
 581             JarInputStream jis = new JarInputStream(fis, false);
 582             Manifest man = jis.getManifest();
 583             jis.close();
 584             return man;
 585         } catch (IOException e) {
 586             return null;
 587         }
 588     }
 589 
 590     // The map of loaded system packages
 591     private static Map<String, Package> pkgs = new HashMap<>(31);
 592 
 593     // Maps each directory or zip file name to its corresponding url
 594     private static Map<String, URL> urls = new HashMap<>(10);
 595 
 596     // Maps each code source url for a jar file to its manifest
 597     private static Map<String, Manifest> mans = new HashMap<>(10);
 598 
 599     private static native String getSystemPackage0(String name);
 600     private static native String[] getSystemPackages0();
 601 
 602     /*
 603      * Private storage for the package name and attributes.
 604      */


 559                 // Convert to "."-separated package name
 560                 name = name.substring(0, name.length() - 1).replace('/', '.');
 561                 Package pkg;
 562                 Manifest man = mans.get(fn);
 563                 if (man != null) {
 564                     pkg = new Package(name, man, url, null);
 565                 } else {
 566                     pkg = new Package(name, null, null, null,
 567                                       null, null, null, null, null);
 568                 }
 569                 pkgs.put(name, pkg);
 570                 return pkg;
 571             }
 572         });
 573     }
 574 
 575     /*
 576      * Returns the Manifest for the specified JAR file name.
 577      */
 578     private static Manifest loadManifest(String fn) {
 579         try (FileInputStream fis = new FileInputStream(fn);
 580              JarInputStream jis = new JarInputStream(fis, false))
 581         {
 582             return jis.getManifest();


 583         } catch (IOException e) {
 584             return null;
 585         }
 586     }
 587 
 588     // The map of loaded system packages
 589     private static Map<String, Package> pkgs = new HashMap<>(31);
 590 
 591     // Maps each directory or zip file name to its corresponding url
 592     private static Map<String, URL> urls = new HashMap<>(10);
 593 
 594     // Maps each code source url for a jar file to its manifest
 595     private static Map<String, Manifest> mans = new HashMap<>(10);
 596 
 597     private static native String getSystemPackage0(String name);
 598     private static native String[] getSystemPackages0();
 599 
 600     /*
 601      * Private storage for the package name and attributes.
 602      */