6706208: (cs) CharsetProvider permission check cleanup
Reviewed-by: chegar, mchung
--- a/jdk/src/share/classes/java/nio/channels/spi/SelectorProvider.java Mon Dec 16 15:05:26 2013 +0000
+++ b/jdk/src/share/classes/java/nio/channels/spi/SelectorProvider.java Mon Dec 16 19:52:55 2013 +0000
@@ -71,6 +71,14 @@
private static final Object lock = new Object();
private static SelectorProvider provider = null;
+ private static Void checkPermission() {
+ SecurityManager sm = System.getSecurityManager();
+ if (sm != null)
+ sm.checkPermission(new RuntimePermission("selectorProvider"));
+ return null;
+ }
+ private SelectorProvider(Void ignore) { }
+
/**
* Initializes a new instance of this class.
*
@@ -79,9 +87,7 @@
* {@link RuntimePermission}<tt>("selectorProvider")</tt>
*/
protected SelectorProvider() {
- SecurityManager sm = System.getSecurityManager();
- if (sm != null)
- sm.checkPermission(new RuntimePermission("selectorProvider"));
+ this(checkPermission());
}
private static boolean loadProviderFromProperty() {
--- a/jdk/src/share/classes/java/nio/charset/spi/CharsetProvider.java Mon Dec 16 15:05:26 2013 +0000
+++ b/jdk/src/share/classes/java/nio/charset/spi/CharsetProvider.java Mon Dec 16 19:52:55 2013 +0000
@@ -71,6 +71,14 @@
public abstract class CharsetProvider {
+ private static Void checkPermission() {
+ SecurityManager sm = System.getSecurityManager();
+ if (sm != null)
+ sm.checkPermission(new RuntimePermission("charsetProvider"));
+ return null;
+ }
+ private CharsetProvider(Void ignore) { }
+
/**
* Initializes a new charset provider.
*
@@ -79,9 +87,7 @@
* {@link RuntimePermission}<tt>("charsetProvider")</tt>
*/
protected CharsetProvider() {
- SecurityManager sm = System.getSecurityManager();
- if (sm != null)
- sm.checkPermission(new RuntimePermission("charsetProvider"));
+ this(checkPermission());
}
/**