### Question:
DnsNameResolver extends NameResolver { @Nullable @VisibleForTesting static ResourceResolverFactory getResourceResolverFactory(ClassLoader loader) { Class<? extends ResourceResolverFactory> jndiClazz; try { jndiClazz = Class.forName("io.grpc.internal.JndiResourceResolverFactory", true, loader) .asSubclass(ResourceResolverFactory.class); } catch (ClassNotFoundException e) { logger.log(Level.FINE, "Unable to find JndiResourceResolverFactory, skipping.", e); return null; } Constructor<? extends ResourceResolverFactory> jndiCtor; try { jndiCtor = jndiClazz.getConstructor(); } catch (Exception e) { logger.log(Level.FINE, "Can't find JndiResourceResolverFactory ctor, skipping.", e); return null; } ResourceResolverFactory rrf; try { rrf = jndiCtor.newInstance(); } catch (Exception e) { logger.log(Level.FINE, "Can't construct JndiResourceResolverFactory, skipping.", e); return null; } if (rrf.unavailabilityCause() != null) { logger.log( Level.FINE, "JndiResourceResolverFactory not available, skipping.", rrf.unavailabilityCause()); } return rrf; } DnsNameResolver(@Nullable String nsAuthority, String name, Attributes params,
      Resource<Executor> executorResource, ProxyDetector proxyDetector,
      Stopwatch stopwatch, boolean isAndroid); @Override final String getServiceAuthority(); @Override final synchronized void start(Listener listener); @Override final synchronized void refresh(); @Override final synchronized void shutdown();  }### Answer:
@Test public void skipMissingJndiResolverResolver() throws Exception { ClassLoader cl = new ClassLoader() { @Override protected Class<?> loadClass(String name, boolean resolve) throws ClassNotFoundException { if ("io.grpc.internal.JndiResourceResolverFactory".equals(name)) { throw new ClassNotFoundException(); } return super.loadClass(name, resolve); } }; ResourceResolverFactory factory = DnsNameResolver.getResourceResolverFactory(cl); assertThat(factory).isNull(); }