diff options
2 files changed, 55 insertions, 16 deletions
diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/bundle/AbstractBundle.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/bundle/AbstractBundle.java index 13111b433c..a61c00f2be 100644 --- a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/bundle/AbstractBundle.java +++ b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/bundle/AbstractBundle.java @@ -385,14 +385,33 @@ public abstract class AbstractBundle implements OMBundle, OMBundle.DebugSupport, int end = path.length() - CLASS_EXTENSION.length(); String className = path.substring(start, end).replace('/', '.'); - try + for (;;) { - ClassLoader classLoader = getAccessor().getClassLoader(); - return classLoader.loadClass(className); - } - catch (ClassNotFoundException ex) - { - //$FALL-THROUGH$ + try + { + ClassLoader classLoader = getAccessor().getClassLoader(); + Class<?> c = classLoader.loadClass(className); + if (c != null) + { + return c; + } + } + catch (NoClassDefFoundError ex) + { + //$FALL-THROUGH$ + } + catch (ClassNotFoundException ex) + { + //$FALL-THROUGH$ + } + + int dot = className.indexOf('.'); + if (dot == -1) + { + break; + } + + className = className.substring(dot + 1); } } diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/om/OSGiBundle.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/om/OSGiBundle.java index 8090a07251..5c965fa0e1 100644 --- a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/om/OSGiBundle.java +++ b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/om/OSGiBundle.java @@ -25,6 +25,8 @@ import java.io.IOException; import java.net.URL; import java.util.Enumeration; import java.util.Iterator; +import java.util.LinkedList; +import java.util.Queue; /** * @author Eike Stepper @@ -64,26 +66,44 @@ public class OSGiBundle extends AbstractBundle public Iterator<Class<?>> getClasses() { - final Bundle bundle = getBundleContext().getBundle(); + final Queue<String> folders = new LinkedList<String>(); + folders.offer("/"); return new AbstractIterator<Class<?>>() { - private Enumeration<String> entryPaths = bundle.getEntryPaths("/"); + private Enumeration<String> entryPaths; @Override protected Object computeNextElement() { - while (entryPaths.hasMoreElements()) + for (;;) { - String entryPath = entryPaths.nextElement(); - Class<?> c = getClassFromBundle(entryPath); - if (c != null) + while (entryPaths != null && entryPaths.hasMoreElements()) { - return c; + String entryPath = entryPaths.nextElement(); + if (entryPath.endsWith("/")) + { + folders.offer(entryPath); + } + else + { + Class<?> c = getClassFromBundle(entryPath); + if (c != null) + { + return c; + } + } } - } - return END_OF_DATA; + String folder = folders.poll(); + if (folder == null) + { + return END_OF_DATA; + } + + Bundle bundle = getBundleContext().getBundle(); + entryPaths = bundle.getEntryPaths(folder); + } } }; } |