2638 // If the class isn't a ResourceBundle subclass, throw a
2639 // ClassCastException.
2640 if (ResourceBundle.class.isAssignableFrom(bundleClass)) {
2641 bundle = bundleClass.newInstance();
2642 } else {
2643 throw new ClassCastException(bundleClass.getName()
2644 + " cannot be cast to ResourceBundle");
2645 }
2646 } catch (ClassNotFoundException e) {
2647 }
2648 } else if (format.equals("java.properties")) {
2649 final String resourceName = toResourceName0(bundleName, "properties");
2650 if (resourceName == null) {
2651 return bundle;
2652 }
2653 final ClassLoader classLoader = loader;
2654 final boolean reloadFlag = reload;
2655 InputStream stream = null;
2656 try {
2657 stream = AccessController.doPrivileged(
2658 new PrivilegedExceptionAction<InputStream>() {
2659 public InputStream run() throws IOException {
2660 InputStream is = null;
2661 if (reloadFlag) {
2662 URL url = classLoader.getResource(resourceName);
2663 if (url != null) {
2664 URLConnection connection = url.openConnection();
2665 if (connection != null) {
2666 // Disable caches to get fresh data for
2667 // reloading.
2668 connection.setUseCaches(false);
2669 is = connection.getInputStream();
2670 }
2671 }
2672 } else {
2673 is = classLoader.getResourceAsStream(resourceName);
2674 }
2675 return is;
2676 }
2677 });
2678 } catch (PrivilegedActionException e) {
|
2638 // If the class isn't a ResourceBundle subclass, throw a
2639 // ClassCastException.
2640 if (ResourceBundle.class.isAssignableFrom(bundleClass)) {
2641 bundle = bundleClass.newInstance();
2642 } else {
2643 throw new ClassCastException(bundleClass.getName()
2644 + " cannot be cast to ResourceBundle");
2645 }
2646 } catch (ClassNotFoundException e) {
2647 }
2648 } else if (format.equals("java.properties")) {
2649 final String resourceName = toResourceName0(bundleName, "properties");
2650 if (resourceName == null) {
2651 return bundle;
2652 }
2653 final ClassLoader classLoader = loader;
2654 final boolean reloadFlag = reload;
2655 InputStream stream = null;
2656 try {
2657 stream = AccessController.doPrivileged(
2658 new PrivilegedExceptionAction<>() {
2659 public InputStream run() throws IOException {
2660 InputStream is = null;
2661 if (reloadFlag) {
2662 URL url = classLoader.getResource(resourceName);
2663 if (url != null) {
2664 URLConnection connection = url.openConnection();
2665 if (connection != null) {
2666 // Disable caches to get fresh data for
2667 // reloading.
2668 connection.setUseCaches(false);
2669 is = connection.getInputStream();
2670 }
2671 }
2672 } else {
2673 is = classLoader.getResourceAsStream(resourceName);
2674 }
2675 return is;
2676 }
2677 });
2678 } catch (PrivilegedActionException e) {
|