diff options
Diffstat (limited to 'bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/loader/BundleLoader.java')
-rw-r--r-- | bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/loader/BundleLoader.java | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/loader/BundleLoader.java b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/loader/BundleLoader.java index 5fcfed8d1..2e7f0e319 100644 --- a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/loader/BundleLoader.java +++ b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/loader/BundleLoader.java @@ -64,6 +64,10 @@ public class BundleLoader extends ModuleLoader { private static final Pattern PACKAGENAME_FILTER = Pattern.compile("\\(osgi.wiring.package\\s*=\\s*([^)]+)\\)"); //$NON-NLS-1$ + // TODO needed instead of using Collections.emptyEnumertion until we no longer support Java 6 + @SuppressWarnings("rawtypes") + private final static Enumeration EMPTY_ENUMERATION = Collections.enumeration(Collections.emptyList()); + private final ModuleWiring wiring; private final EquinoxContainer container; private final Debug debug; @@ -627,7 +631,7 @@ public class BundleLoader extends ModuleLoader { if ((name.length() > 1) && (name.charAt(0) == '/')) /* if name has a leading slash */ name = name.substring(1); /* remove leading slash before search */ String pkgName = getResourcePackageName(name); - Enumeration<URL> result = Collections.enumeration(Collections.<URL> emptyList()); + Enumeration<URL> result = emptyEnumeration(); boolean bootDelegation = false; // follow the OSGi delegation model // First check the parent classloader for system resources, if it is a java resource. @@ -781,9 +785,9 @@ public class BundleLoader extends ModuleLoader { public static <E> Enumeration<E> compoundEnumerations(Enumeration<E> list1, Enumeration<E> list2) { if (list2 == null || !list2.hasMoreElements()) - return list1; + return list1 == null ? BundleLoader.<E> emptyEnumeration() : list1; if (list1 == null || !list1.hasMoreElements()) - return list2; + return list2 == null ? BundleLoader.<E> emptyEnumeration() : list2; List<E> compoundResults = new ArrayList<E>(); while (list1.hasMoreElements()) compoundResults.add(list1.nextElement()); @@ -795,6 +799,11 @@ public class BundleLoader extends ModuleLoader { return Collections.enumeration(compoundResults); } + @SuppressWarnings("unchecked") + private static <E> Enumeration<E> emptyEnumeration() { + return EMPTY_ENUMERATION; + } + /** * Finds a resource local to this bundle. Only the classloader for this bundle is searched. * @param name The name of the resource to find. |