public void test_0() throws Exception { new ServiceLoader(); }
public void test_error() throws Exception { Field field = ServiceLoader.class.getDeclaredField("loadedUrls"); field.setAccessible(true); Set<String> loadedUrls = (Set<String>) field.get(null); Thread.currentThread().setContextClassLoader(new MyClassLoader(new ClassCastException())); JSON.toJSONString(new A()); loadedUrls.clear(); Thread.currentThread().setContextClassLoader(new MyClassLoader(new IOException())); JSON.toJSONString(new B()); loadedUrls.clear(); Thread.currentThread().setContextClassLoader(new EmptyClassLoader()); JSON.toJSONString(new C()); loadedUrls.clear(); Thread.currentThread().setContextClassLoader(new ErrorClassLoader()); JSON.toJSONString(new D()); loadedUrls.clear(); Thread.currentThread().setContextClassLoader(ctxLoader); JSON.toJSONString(new E()); }