< prev index next >

src/java.base/unix/classes/sun/nio/ch/DefaultAsynchronousChannelProvider.java

Print this page




  31 /**
  32  * Creates this platform's default asynchronous channel provider
  33  */
  34 
  35 public class DefaultAsynchronousChannelProvider {
  36 
  37     /**
  38      * Prevent instantiation.
  39      */
  40     private DefaultAsynchronousChannelProvider() { }
  41 
  42     @SuppressWarnings("unchecked")
  43     private static AsynchronousChannelProvider createProvider(String cn) {
  44         Class<AsynchronousChannelProvider> c;
  45         try {
  46             c = (Class<AsynchronousChannelProvider>)Class.forName(cn);
  47         } catch (ClassNotFoundException x) {
  48             throw new AssertionError(x);
  49         }
  50         try {
  51             return c.newInstance();


  52         } catch (IllegalAccessException | InstantiationException x) {
  53             throw new AssertionError(x);
  54         }
  55 
  56     }
  57 
  58     /**
  59      * Returns the default AsynchronousChannelProvider.
  60      */
  61     public static AsynchronousChannelProvider create() {
  62         String osname = GetPropertyAction.getProperty("os.name");
  63         if (osname.equals("SunOS"))
  64             return createProvider("sun.nio.ch.SolarisAsynchronousChannelProvider");
  65         if (osname.equals("Linux"))
  66             return createProvider("sun.nio.ch.LinuxAsynchronousChannelProvider");
  67         if (osname.contains("OS X"))
  68             return createProvider("sun.nio.ch.BsdAsynchronousChannelProvider");
  69         if (osname.equals("AIX"))
  70             return createProvider("sun.nio.ch.AixAsynchronousChannelProvider");
  71         throw new InternalError("platform not recognized");


  31 /**
  32  * Creates this platform's default asynchronous channel provider
  33  */
  34 
  35 public class DefaultAsynchronousChannelProvider {
  36 
  37     /**
  38      * Prevent instantiation.
  39      */
  40     private DefaultAsynchronousChannelProvider() { }
  41 
  42     @SuppressWarnings("unchecked")
  43     private static AsynchronousChannelProvider createProvider(String cn) {
  44         Class<AsynchronousChannelProvider> c;
  45         try {
  46             c = (Class<AsynchronousChannelProvider>)Class.forName(cn);
  47         } catch (ClassNotFoundException x) {
  48             throw new AssertionError(x);
  49         }
  50         try {
  51             @SuppressWarnings("deprecation")
  52             AsynchronousChannelProvider result = c.newInstance();
  53             return result;
  54         } catch (IllegalAccessException | InstantiationException x) {
  55             throw new AssertionError(x);
  56         }
  57 
  58     }
  59 
  60     /**
  61      * Returns the default AsynchronousChannelProvider.
  62      */
  63     public static AsynchronousChannelProvider create() {
  64         String osname = GetPropertyAction.getProperty("os.name");
  65         if (osname.equals("SunOS"))
  66             return createProvider("sun.nio.ch.SolarisAsynchronousChannelProvider");
  67         if (osname.equals("Linux"))
  68             return createProvider("sun.nio.ch.LinuxAsynchronousChannelProvider");
  69         if (osname.contains("OS X"))
  70             return createProvider("sun.nio.ch.BsdAsynchronousChannelProvider");
  71         if (osname.equals("AIX"))
  72             return createProvider("sun.nio.ch.AixAsynchronousChannelProvider");
  73         throw new InternalError("platform not recognized");
< prev index next >