BundleClassLoader createBCL(final BundleProtectionDomain pd, final String[] cp) { BundleClassLoader bcl = bundle.getBundleData().createClassLoader(BundleLoader.this, pd, cp); // attach existing fragments to classloader BundleFragment[] fragments = bundle.getFragments(); if (fragments != null) for (int i = 0; i < fragments.length; i++) { try { bcl.attachFragment( fragments[i].getBundleData(), fragments[i].getProtectionDomain(), fragments[i].getBundleData().getClassPath()); } catch (BundleException be) { bundle.getFramework().publishFrameworkEvent(FrameworkEvent.ERROR, bundle, be); } } // finish the initialization of the classloader. bcl.initialize(); return bcl; }