Merge pull request #111 from amergey/trunk-with-additional-namespace

ARIES-1995 ability to force waiting for custom namespace handlers
diff --git a/jndi/jndi-core/src/main/java/org/apache/aries/jndi/ObjectFactoryHelper.java b/jndi/jndi-core/src/main/java/org/apache/aries/jndi/ObjectFactoryHelper.java
index 9f82ddf..9146640 100644
--- a/jndi/jndi-core/src/main/java/org/apache/aries/jndi/ObjectFactoryHelper.java
+++ b/jndi/jndi-core/src/main/java/org/apache/aries/jndi/ObjectFactoryHelper.java
@@ -27,13 +27,13 @@
 import javax.naming.spi.DirObjectFactory;
 import javax.naming.spi.ObjectFactory;
 import javax.naming.spi.ObjectFactoryBuilder;
-import java.security.AccessController;
-import java.security.PrivilegedAction;
 import java.util.Enumeration;
 import java.util.Hashtable;
 import java.util.logging.Level;
 import java.util.logging.Logger;
 
+import static org.osgi.service.jndi.JNDIConstants.JNDI_URLSCHEME;
+
 public class ObjectFactoryHelper implements ObjectFactory {
 
     private static final Logger logger = Logger.getLogger(ObjectFactoryHelper.class.getName());
@@ -120,13 +120,15 @@
             if (canCallObjectFactory(obj, ref)) {
                 ObjectFactory factory = Activator.getService(callerContext, ref);
                 if (factory != null) {
-                    Object result = getObjectFromFactory(obj, name, nameCtx, environment, attrs, factory);
-                    // if the result comes back and is not null and not the reference
-                    // object then we should return the result, so break out of the
-                    // loop we are in.
-                    if (result != null && result != obj) {
-                        return result;
-                    }
+                    try {
+                        Object result = getObjectFromFactory(obj, name, nameCtx, environment, attrs, factory);
+                        // if the result comes back and is not null and not the reference
+                        // object then we should return the result, so break out of the
+                        // loop we are in.
+                        if (result != null && result != obj) {
+                            return result;
+                        }
+                    } catch (Exception ignored) {} // only care about factories that CAN transform this object
                 }
             }
         }
@@ -136,7 +138,13 @@
     private boolean canCallObjectFactory(Object obj, ServiceReference ref) {
         if (obj instanceof Reference) return true;
         Object prop = ref.getProperty("aries.object.factory.requires.reference");
-        return (prop == null) || !(prop instanceof Boolean) || !(Boolean) prop;
+        // if the ObjectFactory needs a reference, then give up straight away
+        if (Boolean.TRUE.equals(prop)) return false;
+        // ObjectFactory services with an osgi.jndi.url.scheme property are only for converting URLs
+        if (ref.getProperty(JNDI_URLSCHEME) != null) return false;
+        // TODO: ObjectFactory services registered with their implementation class names are for References that specify the ObjectFactory class
+        // We've eliminated all other possibilities, so this factory IS callable.
+        return true;
     }
 
     private Object getObjectInstanceUsingClassName(Object reference,
diff --git a/jndi/jndi-core/src/main/java/org/apache/aries/jndi/startup/Activator.java b/jndi/jndi-core/src/main/java/org/apache/aries/jndi/startup/Activator.java
index bda5f69..4d195ee 100644
--- a/jndi/jndi-core/src/main/java/org/apache/aries/jndi/startup/Activator.java
+++ b/jndi/jndi-core/src/main/java/org/apache/aries/jndi/startup/Activator.java
@@ -148,14 +148,14 @@
         icfBuilders = new CachingServiceTracker<>(trackerBundleContext, InitialContextFactoryBuilder.class);
         urlObjectFactoryFinders = new CachingServiceTracker<>(trackerBundleContext, URLObjectFactoryFinder.class);
 
-        if (!disableBuilder(context)) {
+        if (!isPropertyEnabled(context, DISABLE_BUILDER)) {
             try {
                 OSGiInitialContextFactoryBuilder builder = new OSGiInitialContextFactoryBuilder();
                 try {
                     NamingManager.setInitialContextFactoryBuilder(builder);
                 } catch (IllegalStateException e) {
                     // use reflection to force the builder to be used
-                    if (forceBuilder(context)) {
+                    if (isPropertyEnabled(context, FORCE_BUILDER)) {
                         originalICFBuilder = swapStaticField(InitialContextFactoryBuilder.class, builder);
                     }
                 }
@@ -178,7 +178,7 @@
                     NamingManager.setObjectFactoryBuilder(builder);
                 } catch (IllegalStateException e) {
                     // use reflection to force the builder to be used
-                    if (forceBuilder(context)) {
+                    if (isPropertyEnabled(context, FORCE_BUILDER)) {
                         originalOFBuilder = swapStaticField(ObjectFactoryBuilder.class, builder);
                     }
                 }
@@ -196,21 +196,10 @@
             }
         }
 
-        context.registerService(JNDIProviderAdmin.class.getName(),
-                new ProviderAdminServiceFactory(context),
-                null);
-
-        context.registerService(InitialContextFactoryBuilder.class.getName(),
-                new JREInitialContextFactoryBuilder(),
-                null);
-
-        context.registerService(JNDIContextManager.class.getName(),
-                new ContextManagerServiceFactory(),
-                null);
-
-        context.registerService(AugmenterInvoker.class.getName(),
-                augmenterInvoker = new AugmenterInvokerImpl(context),
-                null);
+        context.registerService(JNDIProviderAdmin.class.getName(), new ProviderAdminServiceFactory(context), null);
+        context.registerService(InitialContextFactoryBuilder.class.getName(), new JREInitialContextFactoryBuilder(), null);
+        context.registerService(JNDIContextManager.class.getName(), new ContextManagerServiceFactory(), null);
+        context.registerService(AugmenterInvoker.class.getName(), augmenterInvoker = new AugmenterInvokerImpl(context), null);
     }
 
     public void stop(BundleContext context) {
@@ -235,22 +224,16 @@
         instance = null;
     }
 
-    private boolean forceBuilder(BundleContext context) {
-        String forceBuilderProp = context.getProperty(FORCE_BUILDER);
-        if (forceBuilderProp != null) {
-            return !"false".equals(forceBuilderProp) && !"no".equals(forceBuilderProp);
-        }
-        BundleRevision revision = context.getBundle().adapt(BundleRevision.class);
-        return !(revision.getDeclaredCapabilities(FORCE_BUILDER).isEmpty());
-    }
-
-    private boolean disableBuilder(BundleContext context) {
-        String disableBuilder = context.getProperty(DISABLE_BUILDER);
-        if (disableBuilder != null) {
-            return !"false".equals(disableBuilder) && !"no".equals(disableBuilder);
-        }
-        BundleRevision revision = context.getBundle().adapt(BundleRevision.class);
-        return !(revision.getDeclaredCapabilities(DISABLE_BUILDER).isEmpty());
+    private boolean isPropertyEnabled(BundleContext context, String key) {
+        String value = context.getProperty(key);
+        if ("false".equals(value)) return false;
+        if ("no".equals(value)) return false;
+        if (null != value) return true;
+        Object revision = context.getBundle().adapt(BundleRevision.class);
+        // in a unit test adapt() may return an incompatible object
+        if (!!! (revision instanceof BundleRevision)) return false;
+        final BundleRevision bundleRevision = (BundleRevision) revision;
+        return bundleRevision.getDeclaredCapabilities(key).size() > 0;
     }
 
     private String getClassName(Class<?> expectedType) {
diff --git a/jndi/jndi-core/src/test/java/org/apache/aries/jndi/ObjectFactoryTest.java b/jndi/jndi-core/src/test/java/org/apache/aries/jndi/ObjectFactoryTest.java
index 378a4bf..f2aae06 100644
--- a/jndi/jndi-core/src/test/java/org/apache/aries/jndi/ObjectFactoryTest.java
+++ b/jndi/jndi-core/src/test/java/org/apache/aries/jndi/ObjectFactoryTest.java
@@ -198,6 +198,19 @@
         env.remove(Context.OBJECT_FACTORIES);
     }
 
+    @Test
+    public void testObjectFactoryThatThrowsIsIgnored() throws Exception {
+        final ObjectFactory factory = Skeleton.newMock(ObjectFactory.class);
+        bc.registerService(ObjectFactory.class.getName(), factory, null);
+        final Skeleton skeleton = Skeleton.getSkeleton(factory);
+        final MethodCall getObjectInstance = new MethodCall(ObjectFactory.class, "getObjectInstance", Object.class, Name.class, Context.class, Hashtable.class);
+        skeleton.setThrows(getObjectInstance, new Exception());
+        Object original = new Object(){};
+        Object processed = NamingManager.getObjectInstance(original, null, null, env);
+        skeleton.assertCalled(getObjectInstance);
+        assertEquals("The original object should be returned despite the object factory throwing an exception", original, processed);
+    }
+
     public static class DummyObjectFactory implements ObjectFactory {
 
         public Object getObjectInstance(Object obj, Name name, Context nameCtx,
@@ -206,5 +219,4 @@
             return new String("pass");
         }
     }
-
 }
\ No newline at end of file
diff --git a/jndi/jndi-url/pom.xml b/jndi/jndi-url/pom.xml
index a8baca3..7a316bd 100644
--- a/jndi/jndi-url/pom.xml
+++ b/jndi/jndi-url/pom.xml
@@ -63,8 +63,8 @@
         </aries.osgi.import.service>
         <lastReleaseVersion>1.0.0</lastReleaseVersion>
 
-        <jndi-api.version>1.1.0</jndi-api.version>
-        <jndi-core.version>1.0.0</jndi-core.version>
+        <jndi-api.version>1.1.1-SNAPSHOT</jndi-api.version>
+        <jndi-core.version>1.1.0-SNAPSHOT</jndi-core.version>
     </properties>
 
     <profiles>
diff --git a/jndi/parent/pom.xml b/jndi/parent/pom.xml
index 39408b8..2634b60 100644
--- a/jndi/parent/pom.xml
+++ b/jndi/parent/pom.xml
@@ -47,7 +47,7 @@
     <properties>
         <jndi-api.dev-version>1.1.1-SNAPSHOT</jndi-api.dev-version>
         <jndi-core.dev-version>1.1.0-SNAPSHOT</jndi-core.dev-version>
-        <jndi-bundle.dev-version>1.0.1-SNAPSHOT</jndi-bundle.dev-version>
+        <jndi-bundle.dev-version>1.1.0-SNAPSHOT</jndi-bundle.dev-version>
         <jndi-url.dev-version>1.1.1-SNAPSHOT</jndi-url.dev-version>
         <jndi-rmi.dev-version>1.0.1-SNAPSHOT</jndi-rmi.dev-version>
         <jndi-url-itest-web.dev-version>1.0.1-SNAPSHOT</jndi-url-itest-web.dev-version>
@@ -108,7 +108,7 @@
             <dependency>
                 <groupId>org.apache.aries.testsupport</groupId>
                 <artifactId>org.apache.aries.testsupport.unit</artifactId>
-                <version>1.0.0</version>
+                <version>2.0.0-SNAPSHOT</version>
                 <scope>test</scope>
                 <exclusions>
                     <exclusion>
diff --git a/proxy/proxy-impl/pom.xml b/proxy/proxy-impl/pom.xml
index 79805cf..9b6d223 100644
--- a/proxy/proxy-impl/pom.xml
+++ b/proxy/proxy-impl/pom.xml
@@ -32,7 +32,7 @@
     <artifactId>org.apache.aries.proxy</artifactId>
     <packaging>bundle</packaging>
     <name>Apache Aries Proxy Service</name>
-    <version>1.1.8-SNAPSHOT</version>
+    <version>1.1.9-SNAPSHOT</version>
     <description>
         This bundle contains the proxy service implementation for Apache Aries
     </description>
diff --git a/proxy/proxy-impl/src/main/java/org/apache/aries/proxy/impl/ProxyUtils.java b/proxy/proxy-impl/src/main/java/org/apache/aries/proxy/impl/ProxyUtils.java
index 0babe4e..355629f 100644
--- a/proxy/proxy-impl/src/main/java/org/apache/aries/proxy/impl/ProxyUtils.java
+++ b/proxy/proxy-impl/src/main/java/org/apache/aries/proxy/impl/ProxyUtils.java
@@ -39,6 +39,10 @@
       //In order to avoid an inconsistent stack error the version of the woven byte code needs to match
       //the level of byte codes in the original class
       switch(JAVA_CLASS_VERSION) {
+        case Opcodes.V15:
+          LOGGER.debug("Weaving to Java 15");
+          weavingJavaVersion = Opcodes.V15;
+          break;
         case Opcodes.V14:
           LOGGER.debug("Weaving to Java 14");
           weavingJavaVersion = Opcodes.V14;
diff --git a/proxy/proxy-itests/pom.xml b/proxy/proxy-itests/pom.xml
index 319ef4d..0fdcaac 100644
--- a/proxy/proxy-itests/pom.xml
+++ b/proxy/proxy-itests/pom.xml
@@ -69,7 +69,7 @@
             <groupId>org.apache.aries.proxy</groupId>
             <artifactId>org.apache.aries.proxy</artifactId>
             <scope>test</scope>
-            <version>1.1.7-SNAPSHOT</version>
+            <version>1.1.8-SNAPSHOT</version>
         </dependency>
 
         <!-- pax exam -->
diff --git a/spi-fly/pom.xml b/spi-fly/pom.xml
index 8bdcd6c..73fef80 100644
--- a/spi-fly/pom.xml
+++ b/spi-fly/pom.xml
@@ -31,7 +31,7 @@
     <groupId>org.apache.aries.spifly</groupId>
     <artifactId>spifly</artifactId>
     <name>Apache Aries SPI Fly</name>
-    <version>1.3.1-SNAPSHOT</version>
+    <version>1.3.3-SNAPSHOT</version>
     <packaging>pom</packaging>
     <description>
         SPI support for OSGi
diff --git a/spi-fly/spi-fly-core/pom.xml b/spi-fly/spi-fly-core/pom.xml
index 156fbd3..1362f07 100644
--- a/spi-fly/spi-fly-core/pom.xml
+++ b/spi-fly/spi-fly-core/pom.xml
@@ -30,7 +30,7 @@
 
     <groupId>org.apache.aries.spifly</groupId>
     <artifactId>org.apache.aries.spifly.core-internal</artifactId>
-    <version>1.3.1-SNAPSHOT</version>
+    <version>1.3.3-SNAPSHOT</version>
     <packaging>jar</packaging>
     <name>Apache Aries SPI Fly Core (internal module)</name>
     <description>
@@ -47,8 +47,7 @@
     </scm>
 
     <properties>
-        <maven.bundle.plugin.version>4.2.0</maven.bundle.plugin.version>
-        <bnd.version>5.0.1</bnd.version>
+        <bnd.version>5.1.2</bnd.version>
     </properties>
 
     <dependencies>
diff --git a/spi-fly/spi-fly-core/src/main/java/org/apache/aries/spifly/BaseActivator.java b/spi-fly/spi-fly-core/src/main/java/org/apache/aries/spifly/BaseActivator.java
index 071f6b9..3b65715 100644
--- a/spi-fly/spi-fly-core/src/main/java/org/apache/aries/spifly/BaseActivator.java
+++ b/spi-fly/spi-fly-core/src/main/java/org/apache/aries/spifly/BaseActivator.java
@@ -91,7 +91,7 @@
             ).map(Parameters::new);
         }
         catch (Throwable t) {
-            logger.log(Level.SEVERE, t.getMessage(), t);
+            log(Level.FINE, t.getMessage(), t);
         }
 
         providerBundleTracker = new BundleTracker(context,
@@ -239,7 +239,9 @@
     }
 
     public void log(Level level, String message, Throwable th) {
-        logger.log(level, message, th);
+        if (logger.isLoggable(level)) {
+            logger.log(level, message, th);
+        }
     }
 
     public Set<WeavingData> getWeavingData(Bundle b) {
diff --git a/spi-fly/spi-fly-core/src/main/java/org/apache/aries/spifly/ProviderBundleTrackerCustomizer.java b/spi-fly/spi-fly-core/src/main/java/org/apache/aries/spifly/ProviderBundleTrackerCustomizer.java
index 5de77f3..178ec99 100644
--- a/spi-fly/spi-fly-core/src/main/java/org/apache/aries/spifly/ProviderBundleTrackerCustomizer.java
+++ b/spi-fly/spi-fly-core/src/main/java/org/apache/aries/spifly/ProviderBundleTrackerCustomizer.java
@@ -92,7 +92,7 @@
             try {

                 providedServices = readServiceLoaderMediatorCapabilityMetadata(bundle, customAttributes);

             } catch (InvalidSyntaxException e) {

-                log(Level.SEVERE, "Unable to read capabilities from bundle " + bundle, e);

+                log(Level.FINE, "Unable to read capabilities from bundle " + bundle, e);

             }

         }

 

@@ -121,7 +121,7 @@
                     + bundle.getSymbolicName());

             return null;

         } else {

-            log(Level.INFO, "Examining bundle for SPI provider: "

+            log(Level.FINE, "Examining bundle for SPI provider: "

                     + bundle.getSymbolicName());

         }

 

@@ -141,7 +141,7 @@
 

             try {

                 final Class<?> cls = bundle.loadClass(details.instanceType);

-                log(Level.INFO, "Loaded SPI provider: " + cls);

+                log(Level.FINE, "Loaded SPI provider: " + cls);

 

                 if (details.properties != null) {

                     ServiceRegistration reg = null;

@@ -157,7 +157,7 @@
                             reg = bundle.getBundleContext().registerService(

                                     details.serviceType, instance, details.properties);

                         } else {

-                            log(Level.INFO, "Bundle " + bundle + " does not have the permission to register services of type: " + details.serviceType);

+                            log(Level.FINE, "Bundle " + bundle + " does not have the permission to register services of type: " + details.serviceType);

                         }

                     } else {

                         reg = bundle.getBundleContext().registerService(

@@ -166,14 +166,14 @@
 

                     if (reg != null) {

                         registrations.add(reg);

-                        log(Level.INFO, "Registered service: " + reg);

+                        log(Level.FINE, "Registered service: " + reg);

                     }

                 }

 

                 activator.registerProviderBundle(details.serviceType, bundle, details.properties);

                 log(Level.INFO, "Registered provider " + details.instanceType + " of service " + details.serviceType + " in bundle " + bundle.getSymbolicName());

             } catch (Exception e) {

-                log(Level.WARNING,

+                log(Level.FINE,

                     "Could not load provider " + details.instanceType + " of service " + details.serviceType, e);

             }

         }

@@ -185,7 +185,7 @@
         List<ServiceDetails> serviceDetails = new ArrayList<>();

 

         for (URL serviceFileURL : serviceFileURLs) {

-            log(Level.INFO, "Found SPI resource: " + serviceFileURL);

+            log(Level.FINE, "Found SPI resource: " + serviceFileURL);

 

             try {

                 BufferedReader reader = new BufferedReader(

@@ -233,12 +233,12 @@
 

                         serviceDetails.add(new ServiceDetails(registrationClassName, className, properties));

                     } catch (Exception e) {

-                        log(Level.WARNING,

+                        log(Level.FINE,

                                 "Could not load SPI implementation referred from " + serviceFileURL, e);

                     }

                 }

             } catch (IOException e) {

-                log(Level.WARNING, "Could not read SPI metadata from " + serviceFileURL, e);

+                log(Level.FINE, "Could not read SPI metadata from " + serviceFileURL, e);

             }

         }

 

@@ -434,15 +434,14 @@
                 }

             }

         } catch (IOException e) {

-            log(Level.SEVERE, "Problem opening embedded jar file: " + url, e);

+            log(Level.FINE, "Problem opening embedded jar file: " + url, e);

         }

         return urls;

     }

 

     @Override

     public void modifiedBundle(Bundle bundle, BundleEvent event, Object registrations) {

-        removedBundle(bundle, event, registrations);

-        addingBundle(bundle, event);

+        // implementation is unnecessary for this use case

     }

 

     @Override

@@ -454,8 +453,16 @@
             return;

 

         for (ServiceRegistration reg : (List<ServiceRegistration>) registrations) {

-            reg.unregister();

-            log(Level.INFO, "Unregistered: " + reg);

+            try {

+                reg.unregister();

+                log(Level.FINE, "Unregistered: " + reg);

+            } catch (IllegalStateException ise) {

+                // Ignore the exception but do not remove the try/catch.

+                // There are some bundle context races on cleanup which

+                // are safe to ignore but unsafe not to perform our own

+                // cleanup. In an ideal world ServiceRegistration.unregister()

+                // would have been idempotent and never throw an exception.

+            }

         }

     }

 

diff --git a/spi-fly/spi-fly-core/src/main/java/org/apache/aries/spifly/Util.java b/spi-fly/spi-fly-core/src/main/java/org/apache/aries/spifly/Util.java
index 603dd60..1bed947 100644
--- a/spi-fly/spi-fly-core/src/main/java/org/apache/aries/spifly/Util.java
+++ b/spi-fly/spi-fly-core/src/main/java/org/apache/aries/spifly/Util.java
@@ -87,7 +87,7 @@
         );

 

         if (!(bundleLoader instanceof BundleReference)) {

-            BaseActivator.activator.log(Level.WARNING, "Classloader of consuming bundle doesn't implement BundleReference: " + bundleLoader);

+            BaseActivator.activator.log(Level.FINE, "Classloader of consuming bundle doesn't implement BundleReference: " + bundleLoader);

             return ServiceLoader.load(service);

         }

 

@@ -140,7 +140,7 @@
         );

 

         if (!(bundleLoader instanceof BundleReference)) {

-            BaseActivator.activator.log(Level.WARNING, "Classloader of consuming bundle doesn't implement BundleReference: " + bundleLoader);

+            BaseActivator.activator.log(Level.FINE, "Classloader of consuming bundle doesn't implement BundleReference: " + bundleLoader);

             return ServiceLoader.load(service, specifiedClassLoader);

         }

 

@@ -165,7 +165,7 @@
 

         final ClassLoader cl = findContextClassloader(br.getBundle(), cls, method, clsArg);

         if (cl != null) {

-            BaseActivator.activator.log(Level.INFO, "Temporarily setting Thread Context Classloader to: " + cl);

+            BaseActivator.activator.log(Level.FINE, "Temporarily setting Thread Context Classloader to: " + cl);

             AccessController.doPrivileged(new PrivilegedAction<Void>() {

                 @Override

                 public Void run() {

@@ -174,7 +174,7 @@
                 }

             });

         } else {

-            BaseActivator.activator.log(Level.WARNING, "No classloader found for " + cls + ":" + method + "(" + clsArg + ")");

+            BaseActivator.activator.log(Level.FINE, "No classloader found for " + cls + ":" + method + "(" + clsArg + ")");

         }

     }

 

@@ -194,7 +194,7 @@
                     sm.checkPermission(new ServicePermission(requestedClass, ServicePermission.GET));

                 } catch (AccessControlException ace) {

                     // access denied

-                    activator.log(Level.INFO, "No permission to obtain service of type: " + requestedClass);

+                    activator.log(Level.FINE, "No permission to obtain service of type: " + requestedClass);

                     return null;

                 }

             }

@@ -320,7 +320,7 @@
         }

 

         if (!(bundleLoader instanceof BundleReference)) {

-            BaseActivator.activator.log(Level.WARNING, "Classloader of consuming bundle doesn't implement BundleReference: " + bundleLoader);

+            BaseActivator.activator.log(Level.FINE, "Classloader of consuming bundle doesn't implement BundleReference: " + bundleLoader);

             return null;

         }

 

@@ -347,7 +347,7 @@
                     jis.close();

             }

         } catch (IOException e) {

-            BaseActivator.activator.log(Level.SEVERE, "Problem loading class from embedded jar file: " + url +

+            BaseActivator.activator.log(Level.FINE, "Problem loading class from embedded jar file: " + url +

                 " in bundle " + b.getSymbolicName(), e);

         }

         return null;

diff --git a/spi-fly/spi-fly-dynamic-bundle/pom.xml b/spi-fly/spi-fly-dynamic-bundle/pom.xml
index c78cda8..2a91eeb 100644
--- a/spi-fly/spi-fly-dynamic-bundle/pom.xml
+++ b/spi-fly/spi-fly-dynamic-bundle/pom.xml
@@ -30,8 +30,7 @@
 
     <groupId>org.apache.aries.spifly</groupId>
     <artifactId>org.apache.aries.spifly.dynamic.bundle</artifactId>
-    <version>1.3.1-SNAPSHOT</version>
-    <packaging>bundle</packaging>
+    <version>1.3.3-SNAPSHOT</version>
     <name>Apache Aries SPI Fly Dynamic Weaving Bundle</name>
     <description>
         This bundle contains an extender that facilitates the use
@@ -47,9 +46,8 @@
     </scm>
 
     <properties>
-        <asm.version>8.0.1</asm.version>
-        <maven.bundle.plugin.version>4.2.0</maven.bundle.plugin.version>
-        <bnd.version>5.0.1</bnd.version>
+        <asm.version>9.0</asm.version>
+        <bnd.version>5.1.2</bnd.version>
     </properties>
 
     <dependencies>
@@ -126,59 +124,48 @@
     <build>
         <plugins>
             <plugin>
-                <groupId>org.apache.felix</groupId>
-                <artifactId>maven-bundle-plugin</artifactId>
-                <version>${maven.bundle.plugin.version}</version>
+                <groupId>biz.aQute.bnd</groupId>
+                <artifactId>bnd-maven-plugin</artifactId>
+                <version>${bnd.version}</version>
                 <configuration>
-                    <instructions>
-                        <Bundle-Activator>org.apache.aries.spifly.dynamic.DynamicWeavingActivator</Bundle-Activator>
-                        <Import-Package>
-                            !org.slf4j,
-                            *
-                        </Import-Package>
-                        <Export-Package>
-                            org.apache.aries.spifly*;version=${project.version}
-                        </Export-Package>
-                        <Private-Package>
-                            org.apache.aries.spifly.dynamic
-                        </Private-Package>
-                        <_conditionalpackage>
-                            aQute.bnd.header,
-                            aQute.bnd.stream,
-                            aQute.bnd.version,
-                            aQute.bnd.version.maven,
-                            aQute.lib.collections,
-                            aQute.lib.date,
-                            aQute.lib.exceptions,
-                            aQute.lib.io,
-                            aQute.lib.stringrover,
-                            aQute.lib.strings,
-                            aQute.libg.generics,
-                            aQute.libg.glob,
-                            aQute.libg.qtokens,
-                            aQute.service.reporter,
-                            org.apache.aries.spifly.*
-                        </_conditionalpackage>
-                        <_includeresource>
-                            META-INF/LICENSE=LICENSE,
-                            META-INF/NOTICE=NOTICE,
-                        </_includeresource>
-                        <Provide-Capability>
-                            osgi.extender;osgi.extender=osgi.serviceloader.registrar;version:Version=1.0,
-                            osgi.extender;osgi.extender=osgi.serviceloader.processor;version:Version=1.0;uses:="org.apache.aries.spifly"
-                        </Provide-Capability>
-                        <_fixupmessages>
-                            Export org.apache.aries.spifly,  has 1,  private references
-                        </_fixupmessages>
-                    </instructions>
+                    <bnd><![CDATA[
+                    Bundle-Activator: org.apache.aries.spifly.dynamic.DynamicWeavingActivator
+                    Export-Package: org.apache.aries.spifly.*;version=${project.version}
+                    -conditionalpackage: \
+                        aQute.bnd.header,\
+                        aQute.bnd.stream,\
+                        aQute.bnd.version,\
+                        aQute.bnd.version.maven,\
+                        aQute.lib.collections,\
+                        aQute.lib.date,\
+                        aQute.lib.exceptions,\
+                        aQute.lib.hex,\
+                        aQute.lib.io,\
+                        aQute.lib.stringrover,\
+                        aQute.lib.strings,\
+                        aQute.libg.generics,\
+                        aQute.libg.glob,\
+                        aQute.libg.qtokens,\
+                        aQute.service.reporter,\
+                        org.apache.aries.spifly.dynamic,\
+                        org.apache.aries.spifly.weaver
+                    -includeresource: \
+                        META-INF/LICENSE=LICENSE,\
+                        META-INF/NOTICE=NOTICE
+                    Provide-Capability: \
+                        osgi.extender;osgi.extender=osgi.serviceloader.registrar;version:Version=1.0,\
+                        osgi.extender;osgi.extender=osgi.serviceloader.processor;version:Version=1.0;uses:="org.apache.aries.spifly"
+                    -fixupmessages: \
+                        "Export org.apache.aries.spifly,  has 1,  private references"
+                    ]]></bnd>
                 </configuration>
-                <dependencies>
-                    <dependency>
-                        <groupId>biz.aQute.bnd</groupId>
-                        <artifactId>biz.aQute.bndlib</artifactId>
-                        <version>${bnd.version}</version>
-                    </dependency>
-                </dependencies>
+                <executions>
+                    <execution>
+                        <goals>
+                            <goal>bnd-process</goal>
+                        </goals>
+                    </execution>
+                </executions>
             </plugin>
             <plugin>
                 <groupId>biz.aQute.bnd</groupId>
@@ -211,6 +198,10 @@
                     <bndruns>
                         <bndrun>resolve.bndrun</bndrun>
                     </bndruns>
+                    <bundles>
+                        <bundle>target/${project.build.finalName}.jar</bundle>
+                    </bundles>
+                    <writeOnChanges>false</writeOnChanges>
                 </configuration>
                 <executions>
                     <execution>
@@ -229,6 +220,15 @@
                     <skip>true</skip>
                 </configuration>
             </plugin>
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-jar-plugin</artifactId>
+                <configuration>
+                    <archive>
+                        <manifestFile>${project.build.outputDirectory}/META-INF/MANIFEST.MF</manifestFile>
+                    </archive>
+                </configuration>
+            </plugin>
         </plugins>
     </build>
 
diff --git a/spi-fly/spi-fly-dynamic-bundle/resolve.bndrun b/spi-fly/spi-fly-dynamic-bundle/resolve.bndrun
index 154e97f..938bb24 100644
--- a/spi-fly/spi-fly-dynamic-bundle/resolve.bndrun
+++ b/spi-fly/spi-fly-dynamic-bundle/resolve.bndrun
@@ -10,15 +10,4 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
--standalone: true
--resolve.effective: resolve, active
--runee: JavaSE-1.8
 -runfw: org.apache.felix.framework
--runrequires: osgi.identity;filter:='(osgi.identity=${project.artifactId})'
--runbundles: \
-	org.apache.aries.spifly.dynamic.bundle;version='[1.3.0,1.3.1)',\
-	org.objectweb.asm;version='[8.0.1,8.0.2)',\
-	org.objectweb.asm.commons;version='[8.0.1,8.0.2)',\
-	org.objectweb.asm.tree;version='[8.0.1,8.0.2)',\
-	org.objectweb.asm.tree.analysis;version='[8.0.1,8.0.2)',\
-	org.objectweb.asm.util;version='[8.0.1,8.0.2)'
diff --git a/spi-fly/spi-fly-dynamic-framework-extension/pom.xml b/spi-fly/spi-fly-dynamic-framework-extension/pom.xml
index 6bbca6a..ef0796f 100644
--- a/spi-fly/spi-fly-dynamic-framework-extension/pom.xml
+++ b/spi-fly/spi-fly-dynamic-framework-extension/pom.xml
@@ -30,8 +30,7 @@
 
     <groupId>org.apache.aries.spifly</groupId>
     <artifactId>org.apache.aries.spifly.dynamic.framework.extension</artifactId>
-    <version>1.3.1-SNAPSHOT</version>
-    <packaging>bundle</packaging>
+    <version>1.3.3-SNAPSHOT</version>
     <name>Apache Aries SPI Fly Dynamic Weaving Framework Extension</name>
     <description>
         This framework extension fragment contains an extender that facilitates
@@ -47,9 +46,8 @@
     </scm>
 
     <properties>
-        <asm.version>8.0.1</asm.version>
-        <maven.bundle.plugin.version>4.2.0</maven.bundle.plugin.version>
-        <bnd.version>5.0.1</bnd.version>
+        <asm.version>9.0</asm.version>
+        <bnd.version>5.1.2</bnd.version>
     </properties>
 
     <dependencies>
@@ -118,66 +116,56 @@
     <build>
         <plugins>
             <plugin>
-                <groupId>org.apache.felix</groupId>
-                <artifactId>maven-bundle-plugin</artifactId>
-                <version>${maven.bundle.plugin.version}</version>
+                <groupId>biz.aQute.bnd</groupId>
+                <artifactId>bnd-maven-plugin</artifactId>
+                <version>${bnd.version}</version>
                 <configuration>
-                    <instructions>
-                        <Fragment-Host>system.bundle;extension:=framework</Fragment-Host>
-                        <ExtensionBundle-Activator>org.apache.aries.spifly.dynamic.DynamicWeavingActivator</ExtensionBundle-Activator>
-                        <Import-Package>
-                            !org.slf4j,
-                            *
-                        </Import-Package>
-                        <Export-Package>
-                            org.apache.aries.spifly;version=${project.version}
-                        </Export-Package>
-                        <Private-Package>
-                            org.apache.aries.spifly.*;-split-package:=first
-                        </Private-Package>
-                        <_conditionalpackage>
-                            aQute.bnd.header,
-                            aQute.bnd.stream,
-                            aQute.bnd.version,
-                            aQute.bnd.version.maven,
-                            aQute.lib.collections,
-                            aQute.lib.date,
-                            aQute.lib.exceptions,
-                            aQute.lib.io,
-                            aQute.lib.stringrover,
-                            aQute.lib.strings,
-                            aQute.libg.generics,
-                            aQute.libg.glob,
-                            aQute.libg.qtokens,
-                            aQute.service.reporter,
-                            org.objectweb.asm,
-                            org.objectweb.asm.commons,
-                            org.objectweb.asm.signature,
-                            org.objectweb.asm.tree,
-                            org.objectweb.asm.tree.analysis,
-                            org.objectweb.asm.util
-                        </_conditionalpackage>
-                        <_includeresource>
-                            META-INF/LICENSE=LICENSE,
-                            META-INF/NOTICE=NOTICE,
-                        </_includeresource>
-                        <Provide-Capability>
-                            osgi.extender;osgi.extender=osgi.serviceloader.registrar;version:Version=1.0,
-                            osgi.extender;osgi.extender=osgi.serviceloader.processor;version:Version=1.0;uses:="org.apache.aries.spifly"
-                        </Provide-Capability>
-                        <_fixupmessages>
-                            Host system.bundle=extension:=framework,
-                            Export org.apache.aries.spifly,  has 1,  private references
-                        </_fixupmessages>
-                    </instructions>
+                    <bnd><![CDATA[
+                    Fragment-Host: system.bundle;extension:=framework
+                    ExtensionBundle-Activator: org.apache.aries.spifly.dynamic.DynamicWeavingActivator
+                    Export-Package: org.apache.aries.spifly;version=${project.version}
+                    Private-Package: \
+                        org.apache.aries.spifly.dynamic,\
+                        org.apache.aries.spifly.weaver
+                    -conditionalpackage: \
+                        aQute.bnd.header,\
+                        aQute.bnd.stream,\
+                        aQute.bnd.version,\
+                        aQute.bnd.version.maven,\
+                        aQute.lib.collections,\
+                        aQute.lib.date,\
+                        aQute.lib.exceptions,\
+                        aQute.lib.io,\
+                        aQute.lib.stringrover,\
+                        aQute.lib.strings,\
+                        aQute.libg.generics,\
+                        aQute.libg.glob,\
+                        aQute.libg.qtokens,\
+                        aQute.service.reporter,\
+                        org.objectweb.asm,\
+                        org.objectweb.asm.commons,\
+                        org.objectweb.asm.signature,\
+                        org.objectweb.asm.tree,\
+                        org.objectweb.asm.tree.analysis,\
+                        org.objectweb.asm.util
+                    -includeresource: \
+                        META-INF/LICENSE=LICENSE,\
+                        META-INF/NOTICE=NOTICE
+                    Provide-Capability: \
+                        osgi.extender;osgi.extender=osgi.serviceloader.registrar;version:Version=1.0,\
+                        osgi.extender;osgi.extender=osgi.serviceloader.processor;version:Version=1.0;uses:="org.apache.aries.spifly"
+                    -fixupmessages: \
+                        "Host system.bundle=extension:=framework",\
+                        "Export org.apache.aries.spifly,  has 1,  private references"
+                    ]]></bnd>
                 </configuration>
-                <dependencies>
-                    <dependency>
-                        <groupId>biz.aQute.bnd</groupId>
-                        <artifactId>biz.aQute.bndlib</artifactId>
-                        <version>${bnd.version}</version>
-                    </dependency>
-                </dependencies>
+                <executions>
+                    <execution>
+                        <goals>
+                            <goal>bnd-process</goal>
+                        </goals>
+                    </execution>
+                </executions>
             </plugin>
             <plugin>
                 <groupId>biz.aQute.bnd</groupId>
@@ -210,6 +198,10 @@
                     <bndruns>
                         <bndrun>resolve.bndrun</bndrun>
                     </bndruns>
+                    <bundles>
+                        <bundle>target/${project.build.finalName}.jar</bundle>
+                    </bundles>
+                    <writeOnChanges>false</writeOnChanges>
                 </configuration>
                 <executions>
                     <execution>
@@ -228,6 +220,15 @@
                     <skip>true</skip>
                 </configuration>
             </plugin>
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-jar-plugin</artifactId>
+                <configuration>
+                    <archive>
+                        <manifestFile>${project.build.outputDirectory}/META-INF/MANIFEST.MF</manifestFile>
+                    </archive>
+                </configuration>
+            </plugin>
         </plugins>
     </build>
 
diff --git a/spi-fly/spi-fly-dynamic-framework-extension/resolve.bndrun b/spi-fly/spi-fly-dynamic-framework-extension/resolve.bndrun
index 4a7b3c0..938bb24 100644
--- a/spi-fly/spi-fly-dynamic-framework-extension/resolve.bndrun
+++ b/spi-fly/spi-fly-dynamic-framework-extension/resolve.bndrun
@@ -10,9 +10,4 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
--standalone: true
--resolve.effective: resolve, active
--runee: JavaSE-1.8
 -runfw: org.apache.felix.framework
--runrequires: osgi.identity;filter:='(osgi.identity=${project.artifactId})'
--runbundles: org.apache.aries.spifly.dynamic.framework.extension;version='[1.3.0,1.3.1)'
diff --git a/spi-fly/spi-fly-static-bundle/pom.xml b/spi-fly/spi-fly-static-bundle/pom.xml
index 0954bc0..c7b7a4a 100644
--- a/spi-fly/spi-fly-static-bundle/pom.xml
+++ b/spi-fly/spi-fly-static-bundle/pom.xml
@@ -30,8 +30,7 @@
 
     <groupId>org.apache.aries.spifly</groupId>
     <artifactId>org.apache.aries.spifly.static.bundle</artifactId>
-    <version>1.3.1-SNAPSHOT</version>
-    <packaging>bundle</packaging>
+    <version>1.3.3-SNAPSHOT</version>
     <name>Apache Aries SPI Fly Static Weaving Bundle</name>
     <description>
         This bundle contains support classes used at runtime by bundles
@@ -47,8 +46,7 @@
     </scm>
 
     <properties>
-        <maven.bundle.plugin.version>4.2.0</maven.bundle.plugin.version>
-        <bnd.version>5.0.1</bnd.version>
+        <bnd.version>5.1.2</bnd.version>
     </properties>
 
     <dependencies>
@@ -88,56 +86,47 @@
     <build>
         <plugins>
             <plugin>
-                <groupId>org.apache.felix</groupId>
-                <artifactId>maven-bundle-plugin</artifactId>
-                <version>${maven.bundle.plugin.version}</version>
+                <groupId>biz.aQute.bnd</groupId>
+                <artifactId>bnd-maven-plugin</artifactId>
+                <version>${bnd.version}</version>
                 <configuration>
-                    <instructions>
-                        <Import-Package>
-                            !org.slf4j,
-                            *
-                        </Import-Package>
-                        <Export-Package>
-                            org.apache.aries.spifly.*;version=${project.version}
-                        </Export-Package>
-                        <Private-Package>
-                            org.apache.aries.spifly.staticbundle
-                        </Private-Package>
-                        <_conditionalpackage>
-                            aQute.bnd.header,
-                            aQute.bnd.stream,
-                            aQute.bnd.version,
-                            aQute.bnd.version.maven,
-                            aQute.lib.collections,
-                            aQute.lib.date,
-                            aQute.lib.exceptions,
-                            aQute.lib.io,
-                            aQute.lib.stringrover,
-                            aQute.lib.strings,
-                            aQute.libg.generics,
-                            aQute.libg.glob,
-                            aQute.libg.qtokens,
-                            aQute.service.reporter
-                        </_conditionalpackage>
-                        <_includeresource>
-                            @biz.aQute.bndlib-[0-9.]*.jar!/aQute/bnd/osgi/Instruction*.class,
-                            META-INF/LICENSE=LICENSE,
-                            META-INF/NOTICE=NOTICE,
-                        </_includeresource>
-                        <Bundle-Activator>org.apache.aries.spifly.staticbundle.StaticWeavingActivator</Bundle-Activator>
-                        <Provide-Capability>
-                            osgi.extender;osgi.extender=osgi.serviceloader.registrar;version:Version=1.0
-                        </Provide-Capability>
-                        <_fixupmessages>Export org.apache.aries.spifly,  has 1,  private references</_fixupmessages>
-                    </instructions>
+                    <bnd><![CDATA[
+                    Bundle-Activator: org.apache.aries.spifly.staticbundle.StaticWeavingActivator
+                    Export-Package: \
+                        org.apache.aries.spifly.*;version=${project.version}
+                    -conditionalpackage: \
+                        aQute.bnd.header,\
+                        aQute.bnd.stream,\
+                        aQute.bnd.version,\
+                        aQute.bnd.version.maven,\
+                        aQute.lib.collections,\
+                        aQute.lib.date,\
+                        aQute.lib.exceptions,\
+                        aQute.lib.hex,\
+                        aQute.lib.io,\
+                        aQute.lib.stringrover,\
+                        aQute.lib.strings,\
+                        aQute.libg.generics,\
+                        aQute.libg.glob,\
+                        aQute.libg.qtokens,\
+                        aQute.service.reporter,\
+                        org.apache.aries.spifly.staticbundle
+                    -includeresource: \
+                        @biz.aQute.bndlib-[0-9.]*.jar!/aQute/bnd/osgi/Instruction*.class,\
+                        META-INF/LICENSE=LICENSE,\
+                        META-INF/NOTICE=NOTICE
+                    Provide-Capability: \
+                        osgi.extender;osgi.extender=osgi.serviceloader.registrar;version:Version=1.0
+                    -fixupmessages: Export org.apache.aries.spifly,  has 1,  private references
+                    ]]></bnd>
                 </configuration>
-                <dependencies>
-                    <dependency>
-                        <groupId>biz.aQute.bnd</groupId>
-                        <artifactId>biz.aQute.bndlib</artifactId>
-                        <version>${bnd.version}</version>
-                    </dependency>
-                </dependencies>
+                <executions>
+                    <execution>
+                        <goals>
+                            <goal>bnd-process</goal>
+                        </goals>
+                    </execution>
+                </executions>
             </plugin>
             <plugin>
                 <groupId>biz.aQute.bnd</groupId>
@@ -170,6 +159,10 @@
                     <bndruns>
                         <bndrun>resolve.bndrun</bndrun>
                     </bndruns>
+                    <bundles>
+                        <bundle>target/${project.build.finalName}.jar</bundle>
+                    </bundles>
+                    <writeOnChanges>false</writeOnChanges>
                 </configuration>
                 <executions>
                     <execution>
@@ -188,6 +181,15 @@
                     <skip>true</skip>
                 </configuration>
             </plugin>
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-jar-plugin</artifactId>
+                <configuration>
+                    <archive>
+                        <manifestFile>${project.build.outputDirectory}/META-INF/MANIFEST.MF</manifestFile>
+                    </archive>
+                </configuration>
+            </plugin>
         </plugins>
     </build>
 
diff --git a/spi-fly/spi-fly-static-bundle/resolve.bndrun b/spi-fly/spi-fly-static-bundle/resolve.bndrun
index 3917f05..938bb24 100644
--- a/spi-fly/spi-fly-static-bundle/resolve.bndrun
+++ b/spi-fly/spi-fly-static-bundle/resolve.bndrun
@@ -10,9 +10,4 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
--standalone: true
--resolve.effective: resolve, active
--runee: JavaSE-1.8
 -runfw: org.apache.felix.framework
--runrequires: osgi.identity;filter:='(osgi.identity=${project.artifactId})'
--runbundles: org.apache.aries.spifly.static.bundle;version='[1.3.0,1.3.1)'
diff --git a/spi-fly/spi-fly-static-tool/pom.xml b/spi-fly/spi-fly-static-tool/pom.xml
index 6bcb4bf..c477602 100644
--- a/spi-fly/spi-fly-static-tool/pom.xml
+++ b/spi-fly/spi-fly-static-tool/pom.xml
@@ -30,7 +30,7 @@
 
     <groupId>org.apache.aries.spifly</groupId>
     <artifactId>org.apache.aries.spifly.static.tool</artifactId>
-    <version>1.3.1-SNAPSHOT</version>
+    <version>1.3.3-SNAPSHOT</version>
     <packaging>jar</packaging>
     <name>Apache Aries SPI Fly Static Weaving Tool</name>
     <description>
@@ -44,11 +44,6 @@
         <tag>HEAD</tag>
     </scm>
 
-    <properties>
-        <maven.bundle.plugin.version>4.2.0</maven.bundle.plugin.version>
-        <bnd.version>5.0.1</bnd.version>
-    </properties>
-
     <dependencies>
         <dependency>
             <groupId>org.apache.aries.spifly</groupId>
@@ -70,11 +65,6 @@
             <artifactId>junit</artifactId>
             <scope>test</scope>
         </dependency>
-        <dependency>
-            <groupId>org.slf4j</groupId>
-            <artifactId>slf4j-simple</artifactId>
-            <scope>test</scope>
-        </dependency>
     </dependencies>
 
     <build>
diff --git a/spi-fly/spi-fly-weaver/pom.xml b/spi-fly/spi-fly-weaver/pom.xml
index 52502ee..07460a3 100644
--- a/spi-fly/spi-fly-weaver/pom.xml
+++ b/spi-fly/spi-fly-weaver/pom.xml
@@ -30,7 +30,7 @@
 
     <groupId>org.apache.aries.spifly</groupId>
     <artifactId>org.apache.aries.spifly.weaver-internal</artifactId>
-    <version>1.3.1-SNAPSHOT</version>
+    <version>1.3.3-SNAPSHOT</version>
     <packaging>jar</packaging>
     <name>Apache Aries SPI Fly Weaver (internal module)</name>
 
@@ -42,9 +42,7 @@
     </scm>
 
     <properties>
-        <asm.version>8.0.1</asm.version>
-        <maven.bundle.plugin.version>4.2.0</maven.bundle.plugin.version>
-        <bnd.version>5.0.1</bnd.version>
+        <asm.version>9.0</asm.version>
     </properties>
 
     <dependencies>
diff --git a/testsupport/testsupport-unit/src/main/java/org/apache/aries/mocks/BundleContextMock.java b/testsupport/testsupport-unit/src/main/java/org/apache/aries/mocks/BundleContextMock.java
index 1c5f5aa..c6955b7 100644
--- a/testsupport/testsupport-unit/src/main/java/org/apache/aries/mocks/BundleContextMock.java
+++ b/testsupport/testsupport-unit/src/main/java/org/apache/aries/mocks/BundleContextMock.java
@@ -724,11 +724,7 @@
      * This allows tests to emulate different properties being set on the
      * context, helpful for the feature pack launcher/kernel relationship
      */
-    else if (System.getProperty(name) != null){
-      return System.getProperty(name);
-    }
-    
-    return "";
+    return System.getProperty(name);
   }
   
   /**