private static Platform findPlatform(){
  try {
    try {
      Class.forName("com.android.org.conscrypt.OpenSSLSocketImpl");
    }
 catch (    ClassNotFoundException e) {
      Class.forName("org.apache.harmony.xnet.provider.jsse.OpenSSLSocketImpl");
    }
    OptionalMethod<Socket> setUseSessionTickets=new OptionalMethod<>(null,"setUseSessionTickets",boolean.class);
    OptionalMethod<Socket> setHostname=new OptionalMethod<>(null,"setHostname",String.class);
    Method trafficStatsTagSocket=null;
    Method trafficStatsUntagSocket=null;
    OptionalMethod<Socket> getAlpnSelectedProtocol=null;
    OptionalMethod<Socket> setAlpnProtocols=null;
    try {
      Class<?> trafficStats=Class.forName("android.net.TrafficStats");
      trafficStatsTagSocket=trafficStats.getMethod("tagSocket",Socket.class);
      trafficStatsUntagSocket=trafficStats.getMethod("untagSocket",Socket.class);
      try {
        Class.forName("android.net.Network");
        getAlpnSelectedProtocol=new OptionalMethod<>(byte[].class,"getAlpnSelectedProtocol");
        setAlpnProtocols=new OptionalMethod<>(null,"setAlpnProtocols",byte[].class);
      }
 catch (      ClassNotFoundException ignored) {
      }
    }
 catch (    ClassNotFoundException|NoSuchMethodException ignored) {
    }
    return new Android(setUseSessionTickets,setHostname,trafficStatsTagSocket,trafficStatsUntagSocket,getAlpnSelectedProtocol,setAlpnProtocols);
  }
 catch (  ClassNotFoundException ignored) {
  }
  try {
    String negoClassName="org.eclipse.jetty.alpn.ALPN";
    Class<?> negoClass=Class.forName(negoClassName);
    Class<?> providerClass=Class.forName(negoClassName + "$Provider");
    Class<?> clientProviderClass=Class.forName(negoClassName + "$ClientProvider");
    Class<?> serverProviderClass=Class.forName(negoClassName + "$ServerProvider");
    Method putMethod=negoClass.getMethod("put",SSLSocket.class,providerClass);
    Method getMethod=negoClass.getMethod("get",SSLSocket.class);
    Method removeMethod=negoClass.getMethod("remove",SSLSocket.class);
    return new JdkWithJettyBootPlatform(putMethod,getMethod,removeMethod,clientProviderClass,serverProviderClass);
  }
 catch (  ClassNotFoundException|NoSuchMethodException ignored) {
  }
  return new Platform();
}

private static Platform findPlatform ( ) { try { try { Class . forName ( "com.android.org.conscrypt.OpenSSLSocketImpl" ) ; } catch ( ClassNotFoundException e ) { Class . forName ( "org.apache.harmony.xnet.provider.jsse.OpenSSLSocketImpl" ) ; } OptionalMethod < Socket > setUseSessionTickets = new OptionalMethod < > ( null , "setUseSessionTickets" , boolean . class ) ; OptionalMethod < Socket > setHostname = new OptionalMethod < > ( null , "setHostname" , String . class ) ; Method trafficStatsTagSocket = null ; Method trafficStatsUntagSocket = null ; OptionalMethod < Socket > getAlpnSelectedProtocol = null ; OptionalMethod < Socket > setAlpnProtocols = null ; try { Class < ? > trafficStats = Class . forName ( "android.net.TrafficStats" ) ; trafficStatsTagSocket = trafficStats . getMethod ( "tagSocket" , Socket . class ) ; trafficStatsUntagSocket = trafficStats . getMethod ( "untagSocket" , Socket . class ) ; try { Class . forName ( "android.net.Network" ) ; getAlpnSelectedProtocol = new OptionalMethod < > ( byte [ ] . class , "getAlpnSelectedProtocol" ) ; setAlpnProtocols = new OptionalMethod < > ( null , "setAlpnProtocols" , byte [ ] . class ) ; } catch ( ClassNotFoundException ignored ) { } } catch ( ClassNotFoundException | NoSuchMethodException ignored ) { } return new Android ( setUseSessionTickets , setHostname , trafficStatsTagSocket , trafficStatsUntagSocket , getAlpnSelectedProtocol , setAlpnProtocols ) ; } catch ( ClassNotFoundException ignored ) { } try { String negoClassName = "org.eclipse.jetty.alpn.ALPN" ; Class < ? > negoClass = Class . forName ( negoClassName ) ; Class < ? > providerClass = Class . forName ( negoClassName + "$Provider" ) ; Class < ? > clientProviderClass = Class . forName ( negoClassName + "$ClientProvider" ) ; Class < ? > serverProviderClass = Class . forName ( negoClassName + "$ServerProvider" ) ; Method putMethod = negoClass . getMethod ( "put" , SSLSocket . class , providerClass ) ; Method getMethod = negoClass . getMethod ( "get" , SSLSocket . class ) ; Method removeMethod = negoClass . getMethod ( "remove" , SSLSocket . class ) ; return new JdkWithJettyBootPlatform ( putMethod , getMethod , removeMethod , clientProviderClass , serverProviderClass ) ; } catch ( ClassNotFoundException | NoSuchMethodException ignored ) { } return new Platform ( ) ; }
attempt to match the host runtime to a capable platform implementation .
