77 private static AsynchronousChannelProvider load() { 78 return AccessController 79 .doPrivileged(new PrivilegedAction<>() { 80 public AsynchronousChannelProvider run() { 81 AsynchronousChannelProvider p; 82 p = loadProviderFromProperty(); 83 if (p != null) 84 return p; 85 p = loadProviderAsService(); 86 if (p != null) 87 return p; 88 return sun.nio.ch.DefaultAsynchronousChannelProvider.create(); 89 }}); 90 } 91 92 private static AsynchronousChannelProvider loadProviderFromProperty() { 93 String cn = System.getProperty("java.nio.channels.spi.AsynchronousChannelProvider"); 94 if (cn == null) 95 return null; 96 try { 97 Class<?> c = Class.forName(cn, true, 98 ClassLoader.getSystemClassLoader()); 99 return (AsynchronousChannelProvider)c.newInstance(); 100 } catch (ClassNotFoundException x) { 101 throw new ServiceConfigurationError(null, x); 102 } catch (IllegalAccessException x) { 103 throw new ServiceConfigurationError(null, x); 104 } catch (InstantiationException x) { 105 throw new ServiceConfigurationError(null, x); 106 } catch (SecurityException x) { 107 throw new ServiceConfigurationError(null, x); 108 } 109 } 110 111 private static AsynchronousChannelProvider loadProviderAsService() { 112 ServiceLoader<AsynchronousChannelProvider> sl = 113 ServiceLoader.load(AsynchronousChannelProvider.class, 114 ClassLoader.getSystemClassLoader()); 115 Iterator<AsynchronousChannelProvider> i = sl.iterator(); 116 for (;;) { 117 try { 118 return (i.hasNext()) ? i.next() : null; 119 } catch (ServiceConfigurationError sce) { | 77 private static AsynchronousChannelProvider load() { 78 return AccessController 79 .doPrivileged(new PrivilegedAction<>() { 80 public AsynchronousChannelProvider run() { 81 AsynchronousChannelProvider p; 82 p = loadProviderFromProperty(); 83 if (p != null) 84 return p; 85 p = loadProviderAsService(); 86 if (p != null) 87 return p; 88 return sun.nio.ch.DefaultAsynchronousChannelProvider.create(); 89 }}); 90 } 91 92 private static AsynchronousChannelProvider loadProviderFromProperty() { 93 String cn = System.getProperty("java.nio.channels.spi.AsynchronousChannelProvider"); 94 if (cn == null) 95 return null; 96 try { 97 @SuppressWarnings("deprecation") 98 Object tmp = Class.forName(cn, true, 99 ClassLoader.getSystemClassLoader()).newInstance(); 100 return (AsynchronousChannelProvider)tmp; 101 } catch (ClassNotFoundException x) { 102 throw new ServiceConfigurationError(null, x); 103 } catch (IllegalAccessException x) { 104 throw new ServiceConfigurationError(null, x); 105 } catch (InstantiationException x) { 106 throw new ServiceConfigurationError(null, x); 107 } catch (SecurityException x) { 108 throw new ServiceConfigurationError(null, x); 109 } 110 } 111 112 private static AsynchronousChannelProvider loadProviderAsService() { 113 ServiceLoader<AsynchronousChannelProvider> sl = 114 ServiceLoader.load(AsynchronousChannelProvider.class, 115 ClassLoader.getSystemClassLoader()); 116 Iterator<AsynchronousChannelProvider> i = sl.iterator(); 117 for (;;) { 118 try { 119 return (i.hasNext()) ? i.next() : null; 120 } catch (ServiceConfigurationError sce) { |