ServiceHelper { static Collection<Class<?>> getAllInterfaces(Class<?>[] baseInterfaces) { Set<Class<?>> result = new HashSet<>(); for (Class<?> c : baseInterfaces) { if (!c.equals(Object.class)) { result.add(c); Class<?> ifaces[] = c.getInterfaces(); if (ifaces.length != 0) { result.addAll(getAllInterfaces(ifaces)); } } } return result; }  static Object getService(BundleContext ctx, OsgiName lookupName, String id,
                                    boolean dynamicRebind, Map<String, Object> env, boolean requireProxy); static ServiceReference<?>[] getServiceReferences(BundleContext ctx, String interface1,
                                                          String filter, String serviceName, Map<String, Object> env); static Object getService(BundleContext ctx, ServiceReference<?> ref);  }
@Test public void testGetAllInterfaces() throws Exception { Class<?>[] classes = { B.class, D.class }; Collection<Class<?>> cx = ServiceHelper.getAllInterfaces(classes); assertTrue (cx.contains(A.class)); assertTrue (cx.contains(B.class)); assertTrue (cx.contains(C.class)); assertTrue (cx.contains(D.class)); assertTrue (cx.size() == 4); }