Merge branch 'feature/SLING-7803-nullability'
diff --git a/pom.xml b/pom.xml
index a39da6f..33cd699 100644
--- a/pom.xml
+++ b/pom.xml
@@ -23,7 +23,7 @@
     <parent>
         <groupId>org.apache.sling</groupId>
         <artifactId>sling</artifactId>
-        <version>30</version>
+        <version>34</version>
         <relativePath />
     </parent>
 
@@ -45,6 +45,12 @@
   
         <dependency>
             <groupId>org.osgi</groupId>
+            <artifactId>org.osgi.annotation.versioning</artifactId>
+            <scope>provided</scope>
+        </dependency>
+
+        <dependency>
+            <groupId>org.osgi</groupId>
             <artifactId>osgi.core</artifactId>
             <scope>compile</scope>
         </dependency>
@@ -143,6 +149,13 @@
             </exclusions>
         </dependency>
     
+        <!-- Nullability annotations -->
+        <dependency>
+            <groupId>org.jetbrains</groupId>
+            <artifactId>annotations</artifactId>
+            <scope>provided</scope>
+        </dependency>
+
         <dependency>
             <groupId>org.mockito</groupId>
             <artifactId>mockito-all</artifactId>
@@ -188,7 +201,6 @@
            <plugin>
                 <groupId>org.apache.maven.plugins</groupId>
                 <artifactId>maven-shade-plugin</artifactId>
-                <version>2.4.3</version>
                 <executions>
                     <execution>
                         <phase>package</phase>
diff --git a/src/main/java/org/apache/sling/testing/mock/osgi/ComponentContextBuilder.java b/src/main/java/org/apache/sling/testing/mock/osgi/ComponentContextBuilder.java
index a87ed41..72c7344 100644
--- a/src/main/java/org/apache/sling/testing/mock/osgi/ComponentContextBuilder.java
+++ b/src/main/java/org/apache/sling/testing/mock/osgi/ComponentContextBuilder.java
@@ -22,6 +22,8 @@
 import java.util.Hashtable;
 import java.util.Map;
 
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
 import org.osgi.framework.Bundle;
 import org.osgi.framework.BundleContext;
 import org.osgi.service.component.ComponentContext;
@@ -39,32 +41,32 @@
         // constructor package-scope only
     }
     
-    public ComponentContextBuilder bundleContext(BundleContext bundleContext) {
+    public @NotNull ComponentContextBuilder bundleContext(@NotNull BundleContext bundleContext) {
         this.bundleContext = bundleContext;
         return this;
     }
     
-    public ComponentContextBuilder properties(Dictionary<String, Object> properties) {
+    public @NotNull ComponentContextBuilder properties(@Nullable Dictionary<String, Object> properties) {
         this.properties = properties;
         return this;
     }
     
-    public ComponentContextBuilder properties(Map<String, Object> properties) {
+    public @NotNull ComponentContextBuilder properties(@Nullable Map<String, Object> properties) {
         this.properties = MapUtil.toDictionary(properties);
         return this;
     }
         
-    public ComponentContextBuilder properties(Object... properties) {
+    public @NotNull ComponentContextBuilder properties(@NotNull Object @NotNull ... properties) {
         this.properties = MapUtil.toDictionary(properties);
         return this;
     }
         
-    public ComponentContextBuilder usingBundle(Bundle usingBundle) {
+    public @NotNull ComponentContextBuilder usingBundle(@NotNull Bundle usingBundle) {
         this.usingBundle = usingBundle;
         return this;
     }
     
-    public ComponentContext build() {
+    public @NotNull ComponentContext build() {
         if (bundleContext == null) {
             bundleContext = MockOsgi.newBundleContext();
         }
diff --git a/src/main/java/org/apache/sling/testing/mock/osgi/ManifestScanner.java b/src/main/java/org/apache/sling/testing/mock/osgi/ManifestScanner.java
index 2058e71..5244d26 100644
--- a/src/main/java/org/apache/sling/testing/mock/osgi/ManifestScanner.java
+++ b/src/main/java/org/apache/sling/testing/mock/osgi/ManifestScanner.java
@@ -30,6 +30,7 @@
 import java.util.jar.Manifest;
 
 import org.apache.commons.lang3.StringUtils;
+import org.jetbrains.annotations.NotNull;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -52,7 +53,7 @@
      * @param attributeName Attribute / Bundle header name.
      * @return List of values.
      */
-    public static Collection<String> getValues(final String attributeName) {
+    public static @NotNull Collection<String> getValues(@NotNull final String attributeName) {
         Set<String> values = new LinkedHashSet<String>();
         try {
             Enumeration<URL> resEnum = ManifestScanner.class.getClassLoader().getResources(JarFile.MANIFEST_NAME);
diff --git a/src/main/java/org/apache/sling/testing/mock/osgi/MapUtil.java b/src/main/java/org/apache/sling/testing/mock/osgi/MapUtil.java
index 44aef63..30d1ac2 100644
--- a/src/main/java/org/apache/sling/testing/mock/osgi/MapUtil.java
+++ b/src/main/java/org/apache/sling/testing/mock/osgi/MapUtil.java
@@ -26,6 +26,9 @@
 import java.util.Hashtable;
 import java.util.Map;
 
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+
 /**
  * Map util methods.
  */
@@ -42,7 +45,7 @@
      * @param map Map
      * @return Dictionary
      */
-    public static <T, U> Dictionary<T, U> toDictionary(Map<T, U> map) {
+    public static @Nullable <T, U> Dictionary<T, U> toDictionary(@Nullable Map<T, U> map) {
         if (map == null) {
             return null;
         }
@@ -62,7 +65,7 @@
      * @param dictionary Dictionary
      * @return Map
      */
-    public static <T, U> Map<T, U> toMap(Dictionary<T, U> dictionary) {
+    public static @Nullable <T, U> Map<T, U> toMap(@Nullable Dictionary<T, U> dictionary) {
         if (dictionary == null) {
             return null;
         }
@@ -80,7 +83,7 @@
      * @param args Key/value pairs
      * @return Dictionary
      */
-    public static Dictionary<String, Object> toDictionary(Object... args) {
+    public static @Nullable Dictionary<String, Object> toDictionary(@NotNull Object @NotNull ... args) {
         return toDictionary(toMap(args));
     }
     
@@ -89,8 +92,8 @@
      * @param args Key/value pairs
      * @return Map
      */
-    @SuppressWarnings("unchecked")
-    public static Map<String, Object> toMap(Object... args) {
+    @SuppressWarnings({ "unchecked", "null" })
+    public static @NotNull Map<String, Object> toMap(@NotNull Object @NotNull ... args) {
         if (args == null || args.length == 0) {
             return Collections.emptyMap();
         }
diff --git a/src/main/java/org/apache/sling/testing/mock/osgi/MockBundleContext.java b/src/main/java/org/apache/sling/testing/mock/osgi/MockBundleContext.java
index 07b80d2..a8ec9b7 100644
--- a/src/main/java/org/apache/sling/testing/mock/osgi/MockBundleContext.java
+++ b/src/main/java/org/apache/sling/testing/mock/osgi/MockBundleContext.java
@@ -191,7 +191,7 @@
         notifyServiceListeners(ServiceEvent.UNREGISTERING, registration.getReference());
     }
     
-    @SuppressWarnings("unchecked")
+    @SuppressWarnings({ "unchecked", "null" })
     void restartService(MockServiceRegistration registration) {
         // get current service properties
         Class<?> serviceClass = registration.getService().getClass();
@@ -397,7 +397,7 @@
         // accept method, but ignore it
     }
 
-    @SuppressWarnings("unchecked")
+    @SuppressWarnings({ "unchecked", "null" })
     <S> S locateService(final String name, final ServiceReference<S> reference) {
         for (MockServiceRegistration<?> serviceRegistration : this.registeredServices) {
             if (serviceRegistration.getReference() == reference) {
@@ -439,6 +439,7 @@
     /**
      * Deactivates all bundles registered in this mocked bundle context.
      */
+    @SuppressWarnings("null")
     public void shutdown() {
         for (MockServiceRegistration<?> serviceRegistration : ImmutableList.copyOf(registeredServices).reverse()) {
             try {
diff --git a/src/main/java/org/apache/sling/testing/mock/osgi/MockOsgi.java b/src/main/java/org/apache/sling/testing/mock/osgi/MockOsgi.java
index 4d22717..12766ab 100644
--- a/src/main/java/org/apache/sling/testing/mock/osgi/MockOsgi.java
+++ b/src/main/java/org/apache/sling/testing/mock/osgi/MockOsgi.java
@@ -26,6 +26,8 @@
 import java.util.Dictionary;
 import java.util.Map;
 
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
 import org.osgi.framework.BundleContext;
 import org.osgi.framework.BundleEvent;
 import org.osgi.framework.ServiceReference;
@@ -46,7 +48,7 @@
     /**
      * @return Mocked {@link BundleContext} instance
      */
-    public static BundleContext newBundleContext() {
+    public static @NotNull BundleContext newBundleContext() {
         return new MockBundleContext();
     }
 
@@ -56,14 +58,14 @@
      * @param bundleContext Bundle context
      * @param bundleEvent Bundle event
      */
-    public static void sendBundleEvent(BundleContext bundleContext, BundleEvent bundleEvent) {
+    public static void sendBundleEvent(@NotNull BundleContext bundleContext, @NotNull BundleEvent bundleEvent) {
         ((MockBundleContext) bundleContext).sendBundleEvent(bundleEvent);
     }
 
     /**
      * @return Mocked {@link ComponentContext} instance
      */
-    public static ComponentContext newComponentContext() {
+    public static @NotNull ComponentContext newComponentContext() {
         return componentContext().build();
     }
 
@@ -71,7 +73,7 @@
      * @param properties Properties
      * @return Mocked {@link ComponentContext} instance
      */
-    public static ComponentContext newComponentContext(Dictionary<String, Object> properties) {
+    public static @NotNull ComponentContext newComponentContext(@Nullable Dictionary<String, Object> properties) {
         return componentContext().properties(properties).build();
     }
 
@@ -79,7 +81,7 @@
      * @param properties Properties
      * @return Mocked {@link ComponentContext} instance
      */
-    public static ComponentContext newComponentContext(Map<String, Object> properties) {
+    public static @NotNull ComponentContext newComponentContext(@Nullable Map<String, Object> properties) {
         return componentContext().properties(properties).build();
     }
 
@@ -87,7 +89,7 @@
      * @param properties Properties
      * @return Mocked {@link ComponentContext} instance
      */
-    public static ComponentContext newComponentContext(Object... properties) {
+    public static @NotNull ComponentContext newComponentContext(@NotNull Object @NotNull ... properties) {
         return componentContext().properties(properties).build();
     }
 
@@ -96,8 +98,8 @@
      * @param properties Properties
      * @return Mocked {@link ComponentContext} instance
      */
-    public static ComponentContext newComponentContext(BundleContext bundleContext,
-            Dictionary<String, Object> properties) {
+    public static @NotNull ComponentContext newComponentContext(@NotNull BundleContext bundleContext,
+            @Nullable Dictionary<String, Object> properties) {
         return componentContext().bundleContext(bundleContext).properties(properties).build();
     }
 
@@ -106,8 +108,8 @@
      * @param properties Properties
      * @return Mocked {@link ComponentContext} instance
      */
-    public static ComponentContext newComponentContext(BundleContext bundleContext,
-            Map<String, Object> properties) {
+    public static @NotNull ComponentContext newComponentContext(@NotNull BundleContext bundleContext,
+            @Nullable Map<String, Object> properties) {
         return componentContext().bundleContext(bundleContext).properties(properties).build();
     }
 
@@ -116,15 +118,15 @@
      * @param properties Properties
      * @return Mocked {@link ComponentContext} instance
      */
-    public static ComponentContext newComponentContext(BundleContext bundleContext,
-            Object... properties) {
+    public static @NotNull ComponentContext newComponentContext(@NotNull BundleContext bundleContext,
+            @NotNull Object @NotNull ... properties) {
         return componentContext().bundleContext(bundleContext).properties(properties).build();
     }
 
     /**
      * @return {@link ComponentContextBuilder} to build a mocked {@link ComponentContext}
      */
-    public static ComponentContextBuilder componentContext() {
+    public static @NotNull ComponentContextBuilder componentContext() {
         return new ComponentContextBuilder();
     }
     
@@ -132,7 +134,7 @@
      * @param loggerContext Context class for logging
      * @return Mocked {@link LogService} instance
      */
-    public static LogService newLogService(final Class<?> loggerContext) {
+    public static @NotNull LogService newLogService(@NotNull final Class<?> loggerContext) {
         return new MockLogService(loggerContext);
     }
 
@@ -144,7 +146,7 @@
      * @param bundleContext Bundle context from which services are fetched to inject.
      * @return true if all dependencies could be injected, false if the service has no dependencies.
      */
-    public static boolean injectServices(Object target, BundleContext bundleContext) {
+    public static boolean injectServices(@NotNull Object target, @NotNull BundleContext bundleContext) {
         return MockOsgi.injectServices(target, bundleContext, (Map<String, Object>)null);
     }
 
@@ -157,7 +159,7 @@
      * @param properties Service properties (used to resolve dynamic reference properties)
      * @return true if all dependencies could be injected, false if the service has no dependencies.
      */
-    public static boolean injectServices(Object target, BundleContext bundleContext, Map<String, Object> properties) {
+    public static boolean injectServices(@NotNull Object target, @NotNull BundleContext bundleContext, @Nullable Map<String, Object> properties) {
         return OsgiServiceUtil.injectServices(target, bundleContext, properties);
     }
 
@@ -167,7 +169,7 @@
      * @param bundleContext Bundle context
      * @return true if activation method was called. False if no activate method is defined.
      */
-    public static boolean activate(Object target, BundleContext bundleContext) {
+    public static boolean activate(@NotNull Object target, @NotNull BundleContext bundleContext) {
         return MockOsgi.activate(target, bundleContext, (Dictionary<String, Object>)null);
     }
 
@@ -178,7 +180,7 @@
      * @param properties Properties
      * @return true if activation method was called. False if no activate method is defined.
      */
-    public static boolean activate(Object target, BundleContext bundleContext, Dictionary<String, Object> properties) {
+    public static boolean activate(@NotNull Object target, @NotNull BundleContext bundleContext, @Nullable Dictionary<String, Object> properties) {
         Dictionary<String, Object> mergedProperties = propertiesMergeWithOsgiMetadata(target, getConfigAdmin(bundleContext), properties);
         ComponentContext componentContext = newComponentContext(bundleContext, mergedProperties);
         return OsgiServiceUtil.activateDeactivate(target, componentContext, true);
@@ -191,7 +193,7 @@
      * @param properties Properties
      * @return true if activation method was called. False if no activate method is defined.
      */
-    public static boolean activate(Object target, BundleContext bundleContext, Map<String, Object> properties) {
+    public static boolean activate(@NotNull Object target, @NotNull BundleContext bundleContext, @Nullable Map<String, Object> properties) {
         return activate(target, bundleContext, toDictionary(properties));
     }
 
@@ -202,7 +204,7 @@
      * @param properties Properties
      * @return true if activation method was called. False if no activate method is defined.
      */
-    public static boolean activate(Object target, BundleContext bundleContext, Object... properties) {
+    public static boolean activate(@NotNull Object target, @NotNull BundleContext bundleContext, @NotNull Object @NotNull ... properties) {
         return activate(target, bundleContext, toDictionary(properties));
     }
 
@@ -212,7 +214,7 @@
      * @param bundleContext Bundle context.
      * @return true if deactivation method was called. False if no deactivate method is defined.
      */
-    public static boolean deactivate(Object target, BundleContext bundleContext) {
+    public static boolean deactivate(@NotNull Object target, @NotNull BundleContext bundleContext) {
         return MockOsgi.deactivate(target, bundleContext, (Dictionary<String, Object>)null);
     }
 
@@ -223,7 +225,7 @@
      * @param properties Properties
      * @return true if deactivation method was called. False if no deactivate method is defined.
      */
-    public static boolean deactivate(Object target, BundleContext bundleContext, Dictionary<String, Object> properties) {
+    public static boolean deactivate(@NotNull Object target, @NotNull BundleContext bundleContext, @Nullable Dictionary<String, Object> properties) {
         Dictionary<String, Object> mergedProperties = propertiesMergeWithOsgiMetadata(target, getConfigAdmin(bundleContext), properties);
         ComponentContext componentContext = newComponentContext(bundleContext, mergedProperties);
         return OsgiServiceUtil.activateDeactivate(target, componentContext, false);
@@ -236,7 +238,7 @@
      * @param properties Properties
      * @return true if deactivation method was called. False if no deactivate method is defined.
      */
-    public static boolean deactivate(Object target, BundleContext bundleContext, Map<String, Object> properties) {
+    public static boolean deactivate(@NotNull Object target, @NotNull BundleContext bundleContext, @Nullable Map<String, Object> properties) {
         return deactivate(target, bundleContext, toDictionary(properties));
     }
 
@@ -247,7 +249,7 @@
      * @param properties Properties
      * @return true if deactivation method was called. False if no deactivate method is defined.
      */
-    public static boolean deactivate(Object target, BundleContext bundleContext, Object... properties) {
+    public static boolean deactivate(@NotNull Object target, @NotNull BundleContext bundleContext, @NotNull Object @NotNull ... properties) {
         return deactivate(target, bundleContext, toDictionary(properties));
     }
 
@@ -258,7 +260,7 @@
      * @param properties Properties
      * @return true if modified method was called. False if no modified method is defined.
      */
-    public static boolean modified(Object target, BundleContext bundleContext, Dictionary<String, Object> properties) {
+    public static boolean modified(@NotNull Object target, @NotNull BundleContext bundleContext, @Nullable Dictionary<String, Object> properties) {
         return modified(target, bundleContext, toMap(properties));
     }
 
@@ -269,7 +271,7 @@
      * @param properties Properties
      * @return true if modified method was called. False if no modified method is defined.
      */
-    public static boolean modified(Object target, BundleContext bundleContext, Map<String, Object> properties) {
+    public static boolean modified(@NotNull Object target, @NotNull BundleContext bundleContext, @Nullable Map<String, Object> properties) {
         Map<String, Object> mergedProperties = propertiesMergeWithOsgiMetadata(target, getConfigAdmin(bundleContext), properties);
         ComponentContext componentContext = newComponentContext(bundleContext, mergedProperties);
         return OsgiServiceUtil.modified(target, componentContext, mergedProperties);
@@ -282,7 +284,7 @@
      * @param properties Properties
      * @return true if modified method was called. False if no modified method is defined.
      */
-    public static boolean modified(Object target, BundleContext bundleContext, Object... properties) {
+    public static boolean modified(@NotNull Object target, @NotNull BundleContext bundleContext, @NotNull Object @NotNull ... properties) {
         return modified(target, bundleContext, toDictionary(properties));
     }
     
@@ -292,7 +294,7 @@
      * @param pid PID
      * @param properties Configuration properties
      */
-    public static void setConfigForPid(BundleContext bundleContext, String pid, Map<String,Object> properties) {
+    public static void setConfigForPid(@NotNull BundleContext bundleContext, @NotNull String pid, @Nullable Map<String,Object> properties) {
         setConfigForPid(bundleContext, pid, toDictionary(properties));
     }
     
@@ -302,11 +304,11 @@
      * @param pid PID
      * @param properties Configuration properties
      */
-    public static void setConfigForPid(BundleContext bundleContext, String pid, Object... properties) {
+    public static void setConfigForPid(@NotNull BundleContext bundleContext, @NotNull String pid, @NotNull Object @NotNull ... properties) {
         setConfigForPid(bundleContext, pid, toDictionary(properties));
     }
     
-    private static void setConfigForPid(BundleContext bundleContext, String pid, Dictionary<String, Object> properties) {
+    private static void setConfigForPid(@NotNull BundleContext bundleContext, @NotNull String pid, @Nullable Dictionary<String, Object> properties) {
         ConfigurationAdmin configAdmin = getConfigAdmin(bundleContext);
         if (configAdmin == null) {
             throw new RuntimeException("ConfigurationAdmin service is not registered in bundle context.");
@@ -324,7 +326,7 @@
      * Deactivates all bundles registered in the mocked bundle context.
      * @param bundleContext Bundle context
      */
-    public static void shutdown(BundleContext bundleContext) {
+    public static void shutdown(@NotNull BundleContext bundleContext) {
         ((MockBundleContext)bundleContext).shutdown();
     }
     
@@ -333,7 +335,7 @@
      * @param bundleContext Bundle context
      * @return Configuration admin or null if not registered.
      */
-    private static ConfigurationAdmin getConfigAdmin(BundleContext bundleContext) {
+    private static @Nullable ConfigurationAdmin getConfigAdmin(@NotNull BundleContext bundleContext) {
         ServiceReference<?> ref = bundleContext.getServiceReference(ConfigurationAdmin.class.getName());
         if (ref != null) {
             return (ConfigurationAdmin)bundleContext.getService(ref);
diff --git a/src/main/java/org/apache/sling/testing/mock/osgi/MockServiceRegistration.java b/src/main/java/org/apache/sling/testing/mock/osgi/MockServiceRegistration.java
index 57b8c3b..382b108 100644
--- a/src/main/java/org/apache/sling/testing/mock/osgi/MockServiceRegistration.java
+++ b/src/main/java/org/apache/sling/testing/mock/osgi/MockServiceRegistration.java
@@ -100,7 +100,7 @@
         return clazzes;
     }
 
-    @SuppressWarnings("unchecked")
+    @SuppressWarnings({ "unchecked", "null" })
     T getService() {
         if (this.service instanceof ServiceFactory) {
             ServiceFactory<T> factory = (ServiceFactory<T>)this.service;
@@ -132,6 +132,7 @@
     /**
      * Try to read OSGI-metadata from /OSGI-INF and read all implemented interfaces
      */
+    @SuppressWarnings("null")
     private void readOsgiMetadata() {
         Class<?> serviceClass = service.getClass();
         OsgiMetadata metadata = OsgiMetadataUtil.getMetadata(serviceClass);
@@ -143,6 +144,7 @@
         clazzes.addAll(metadata.getServiceInterfaces());
     }
 
+    @SuppressWarnings("null")
     @Override
     public String toString() {
         return "#" + serviceId + " [" + StringUtils.join(clazzes, ",") + "]: " + service.toString();
diff --git a/src/main/java/org/apache/sling/testing/mock/osgi/NoScrMetadataException.java b/src/main/java/org/apache/sling/testing/mock/osgi/NoScrMetadataException.java
index 0e9114d..8ad80ef 100644
--- a/src/main/java/org/apache/sling/testing/mock/osgi/NoScrMetadataException.java
+++ b/src/main/java/org/apache/sling/testing/mock/osgi/NoScrMetadataException.java
@@ -18,13 +18,15 @@
  */
 package org.apache.sling.testing.mock.osgi;
 
+import org.jetbrains.annotations.NotNull;
+
 /**
  * Is thrown when a OSGi mock method required SCR metadata and this is not found in the classpath.
  */
 public final class NoScrMetadataException extends RuntimeException {
     private static final long serialVersionUID = 1L;
 
-    public NoScrMetadataException(Class<?> type) {
+    public NoScrMetadataException(@NotNull Class<?> type) {
         super("No OSGi SCR metadata found for class " + OsgiMetadataUtil.cleanupClassName(type.getName()));
     }
 
diff --git a/src/main/java/org/apache/sling/testing/mock/osgi/ReferenceViolationException.java b/src/main/java/org/apache/sling/testing/mock/osgi/ReferenceViolationException.java
index 4bfa0f2..049473d 100644
--- a/src/main/java/org/apache/sling/testing/mock/osgi/ReferenceViolationException.java
+++ b/src/main/java/org/apache/sling/testing/mock/osgi/ReferenceViolationException.java
@@ -18,13 +18,15 @@
  */
 package org.apache.sling.testing.mock.osgi;
 
+import org.jetbrains.annotations.NotNull;
+
 /**
  * Is thrown when a OSGi reference injection fails due to violated constraints.
  */
 public final class ReferenceViolationException extends RuntimeException {
     private static final long serialVersionUID = 1L;
 
-    public ReferenceViolationException(String message) {
+    public ReferenceViolationException(@NotNull String message) {
         super(message);
     }
 
diff --git a/src/main/java/org/apache/sling/testing/mock/osgi/context/AbstractContextPlugin.java b/src/main/java/org/apache/sling/testing/mock/osgi/context/AbstractContextPlugin.java
index 5d71c9c..50d20a6 100644
--- a/src/main/java/org/apache/sling/testing/mock/osgi/context/AbstractContextPlugin.java
+++ b/src/main/java/org/apache/sling/testing/mock/osgi/context/AbstractContextPlugin.java
@@ -18,6 +18,7 @@
  */
 package org.apache.sling.testing.mock.osgi.context;
 
+import org.jetbrains.annotations.NotNull;
 import org.osgi.annotation.versioning.ConsumerType;
 
 /**
@@ -28,22 +29,22 @@
 public abstract class AbstractContextPlugin<T extends OsgiContextImpl> implements ContextPlugin<T> {
 
     @Override
-    public void beforeSetUp(T context) throws Exception {
+    public void beforeSetUp(@NotNull T context) throws Exception {
         // can be overridden by subclasses
     }
 
     @Override
-    public void afterSetUp(T context) throws Exception {
+    public void afterSetUp(@NotNull T context) throws Exception {
         // can be overridden by subclasses
     }
 
     @Override
-    public void beforeTearDown(T context) throws Exception {
+    public void beforeTearDown(@NotNull T context) throws Exception {
         // can be overridden by subclasses
     }
 
     @Override
-    public void afterTearDown(T context) throws Exception {
+    public void afterTearDown(@NotNull T context) throws Exception {
         // can be overridden by subclasses
     }
     
diff --git a/src/main/java/org/apache/sling/testing/mock/osgi/context/ContextCallback.java b/src/main/java/org/apache/sling/testing/mock/osgi/context/ContextCallback.java
index aa2ed12..5ff8792 100644
--- a/src/main/java/org/apache/sling/testing/mock/osgi/context/ContextCallback.java
+++ b/src/main/java/org/apache/sling/testing/mock/osgi/context/ContextCallback.java
@@ -18,6 +18,7 @@
  */
 package org.apache.sling.testing.mock.osgi.context;
 
+import org.jetbrains.annotations.NotNull;
 import org.osgi.annotation.versioning.ConsumerType;
 
 /**
@@ -33,6 +34,6 @@
      * @param context OSGi context
      * @throws Exception exception
      */
-    void execute(T context) throws Exception;
+    void execute(@NotNull T context) throws Exception;
 
 }
diff --git a/src/main/java/org/apache/sling/testing/mock/osgi/context/ContextPlugin.java b/src/main/java/org/apache/sling/testing/mock/osgi/context/ContextPlugin.java
index 4fe3616..aa7a290 100644
--- a/src/main/java/org/apache/sling/testing/mock/osgi/context/ContextPlugin.java
+++ b/src/main/java/org/apache/sling/testing/mock/osgi/context/ContextPlugin.java
@@ -18,6 +18,7 @@
  */
 package org.apache.sling.testing.mock.osgi.context;
 
+import org.jetbrains.annotations.NotNull;
 import org.osgi.annotation.versioning.ConsumerType;
 
 /**
@@ -33,27 +34,27 @@
      * @param context OSGi context
      * @throws Exception exception
      */
-    void beforeSetUp(T context) throws Exception;
+    void beforeSetUp(@NotNull T context) throws Exception;
 
     /**
      * Is executed after the built-in setup rules are executed.
      * @param context OSGi context
      * @throws Exception exception
      */
-    void afterSetUp(T context) throws Exception;
+    void afterSetUp(@NotNull T context) throws Exception;
 
     /**
      * Is executed before the built-in teardown rules are executed.
      * @param context OSGi context
      * @throws Exception exception
      */
-    void beforeTearDown(T context) throws Exception;
+    void beforeTearDown(@NotNull T context) throws Exception;
 
     /**
      * Is executed after the built-in teardown rules are executed.
      * @param context OSGi context
      * @throws Exception exception
      */
-    void afterTearDown(T context) throws Exception;
+    void afterTearDown(@NotNull T context) throws Exception;
 
 }
diff --git a/src/main/java/org/apache/sling/testing/mock/osgi/context/ContextPlugins.java b/src/main/java/org/apache/sling/testing/mock/osgi/context/ContextPlugins.java
index 503bf92..d4bd102 100644
--- a/src/main/java/org/apache/sling/testing/mock/osgi/context/ContextPlugins.java
+++ b/src/main/java/org/apache/sling/testing/mock/osgi/context/ContextPlugins.java
@@ -22,6 +22,7 @@
 import java.util.Collection;
 import java.util.List;
 
+import org.jetbrains.annotations.NotNull;
 import org.osgi.annotation.versioning.ProviderType;
 
 /**
@@ -30,7 +31,7 @@
 @ProviderType
 public final class ContextPlugins {
     
-    private List<ContextPlugin<? extends OsgiContextImpl>> plugins = new ArrayList<>();
+    private final @NotNull List<ContextPlugin<? extends OsgiContextImpl>> plugins = new ArrayList<>();
 
     /**
      * Start with empty list.
@@ -44,7 +45,7 @@
      * @param <T> context type
      * @param afterSetUpCallback Allows the application to register an own callback function that is called after the built-in setup rules are executed.
      */
-    public <T extends OsgiContextImpl> ContextPlugins(final ContextCallback<T> afterSetUpCallback) {
+    public <T extends OsgiContextImpl> ContextPlugins(@NotNull final ContextCallback<T> afterSetUpCallback) {
         addAfterSetUpCallback(afterSetUpCallback);
     }
     
@@ -55,7 +56,9 @@
      * @param afterSetUpCallback Allows the application to register an own callback function that is called after the built-in setup rules are executed.
      * @param beforeTearDownCallback Allows the application to register an own callback function that is called before the built-in teardown rules are executed.
      */
-    public <U extends OsgiContextImpl, V extends OsgiContextImpl> ContextPlugins(final ContextCallback<U> afterSetUpCallback, final ContextCallback<V> beforeTearDownCallback) {
+    public <U extends OsgiContextImpl, V extends OsgiContextImpl> ContextPlugins(
+            @NotNull final ContextCallback<U> afterSetUpCallback, 
+            @NotNull final ContextCallback<V> beforeTearDownCallback) {
         addAfterSetUpCallback(afterSetUpCallback);
         addBeforeTearDownCallback(beforeTearDownCallback);
     }
@@ -65,8 +68,9 @@
      * @param <T> context type
      * @param plugin Plugin
      */
+    @SuppressWarnings({ "null", "unused" })
     @SafeVarargs
-    public final <T extends OsgiContextImpl> void addPlugin(ContextPlugin<T>... plugin) {
+    public final <T extends OsgiContextImpl> void addPlugin(@NotNull ContextPlugin<T> @NotNull ... plugin) {
         for (final ContextPlugin<T> item : plugin) {
             if (item == null) {
                 continue;
@@ -80,15 +84,16 @@
      * @param <T> context type
      * @param beforeSetUpCallback Allows the application to register an own callback function that is called before the built-in setup rules are executed.
      */
+    @SuppressWarnings({ "null", "unused" })
     @SafeVarargs
-    public final <T extends OsgiContextImpl> void addBeforeSetUpCallback(final ContextCallback<T>... beforeSetUpCallback) {
+    public final <T extends OsgiContextImpl> void addBeforeSetUpCallback(@NotNull final ContextCallback<T> @NotNull ... beforeSetUpCallback) {
         for (final ContextCallback<T> item : beforeSetUpCallback) {
             if (item == null) {
                 continue;
             }
             plugins.add(new AbstractContextPlugin<T>() {
                 @Override
-                public void beforeSetUp(T context) throws Exception {
+                public void beforeSetUp(@NotNull T context) throws Exception {
                     item.execute(context);
                 }
                 @Override
@@ -104,15 +109,16 @@
      * @param <T> context type
      * @param afterSetUpCallback Allows the application to register an own callback function that is called after the built-in setup rules are executed.
      */
+    @SuppressWarnings({ "null", "unused" })
     @SafeVarargs
-    public final <T extends OsgiContextImpl> void addAfterSetUpCallback(final ContextCallback<T>... afterSetUpCallback) {
+    public final <T extends OsgiContextImpl> void addAfterSetUpCallback(@NotNull final ContextCallback<T> @NotNull ... afterSetUpCallback) {
         for (final ContextCallback<T> item : afterSetUpCallback) {
             if (item == null) {
                 continue;
             }
             plugins.add(new AbstractContextPlugin<T>() {
                 @Override
-                public void afterSetUp(T context) throws Exception {
+                public void afterSetUp(@NotNull T context) throws Exception {
                     item.execute(context);
                 }
                 @Override
@@ -128,15 +134,16 @@
      * @param <T> context type
      * @param beforeTearDownCallback Allows the application to register an own callback function that is called before the built-in teardown rules are executed.
      */
+    @SuppressWarnings({ "null", "unused" })
     @SafeVarargs
-    public final <T extends OsgiContextImpl> void addBeforeTearDownCallback(final ContextCallback<T>... beforeTearDownCallback) {
+    public final <T extends OsgiContextImpl> void addBeforeTearDownCallback(@NotNull final ContextCallback<T> @NotNull ... beforeTearDownCallback) {
         for (final ContextCallback<T> item : beforeTearDownCallback) {
             if (item == null) {
                 continue;
             }
             plugins.add(new AbstractContextPlugin<T>() {
                 @Override
-                public void beforeTearDown(T context) throws Exception {
+                public void beforeTearDown(@NotNull T context) throws Exception {
                     item.execute(context);
                 }
                 @Override
@@ -152,15 +159,16 @@
      * @param <T> context type
      * @param afterTearDownCallback Allows the application to register an own callback function that is after before the built-in teardown rules are executed.
      */
+    @SuppressWarnings({ "null", "unused" })
     @SafeVarargs
-    public final <T extends OsgiContextImpl> void addAfterTearDownCallback(final ContextCallback<T>... afterTearDownCallback) {
+    public final <T extends OsgiContextImpl> void addAfterTearDownCallback(@NotNull final ContextCallback<T> @NotNull ... afterTearDownCallback) {
         for (final ContextCallback<T> item : afterTearDownCallback) {
             if (item == null) {
                 continue;
             }
             plugins.add(new AbstractContextPlugin<T>() {
                 @Override
-                public void afterTearDown(T context) throws Exception {
+                public void afterTearDown(@NotNull T context) throws Exception {
                     item.execute(context);
                 }
                 @Override
@@ -174,7 +182,7 @@
     /**
      * @return All plugins
      */
-    public Collection<ContextPlugin<? extends OsgiContextImpl>> getPlugins() {
+    public @NotNull Collection<ContextPlugin<? extends OsgiContextImpl>> getPlugins() {
         return plugins;
     }
     
@@ -184,7 +192,7 @@
      * @param context Context
      */
     @SuppressWarnings("unchecked")
-    public <T extends OsgiContextImpl> void executeBeforeSetUpCallback(final T context) {
+    public <T extends OsgiContextImpl> void executeBeforeSetUpCallback(@NotNull final T context) {
         for (ContextPlugin plugin : plugins) {
             try {
                 plugin.beforeSetUp(context);
@@ -201,7 +209,7 @@
      * @param context Context
      */
     @SuppressWarnings("unchecked")
-    public <T extends OsgiContextImpl> void executeAfterSetUpCallback(final T context) {
+    public <T extends OsgiContextImpl> void executeAfterSetUpCallback(@NotNull final T context) {
         for (ContextPlugin plugin : plugins) {
             try {
                 plugin.afterSetUp(context);
@@ -218,7 +226,7 @@
      * @param context Context
      */
     @SuppressWarnings("unchecked")
-    public <T extends OsgiContextImpl> void executeBeforeTearDownCallback(final T context) {
+    public <T extends OsgiContextImpl> void executeBeforeTearDownCallback(@NotNull final T context) {
         for (ContextPlugin plugin : plugins) {
             try {
                 plugin.beforeTearDown(context);
@@ -235,7 +243,7 @@
      * @param context Context
      */
     @SuppressWarnings("unchecked")
-    public <T extends OsgiContextImpl> void executeAfterTearDownCallback(final T context) {
+    public <T extends OsgiContextImpl> void executeAfterTearDownCallback(@NotNull final T context) {
         for (ContextPlugin plugin : plugins) {
             try {
                 plugin.afterTearDown(context);
diff --git a/src/main/java/org/apache/sling/testing/mock/osgi/context/OsgiContextImpl.java b/src/main/java/org/apache/sling/testing/mock/osgi/context/OsgiContextImpl.java
index ae9d0b2..c6e7849 100644
--- a/src/main/java/org/apache/sling/testing/mock/osgi/context/OsgiContextImpl.java
+++ b/src/main/java/org/apache/sling/testing/mock/osgi/context/OsgiContextImpl.java
@@ -25,6 +25,8 @@
 import org.apache.sling.testing.mock.osgi.MapUtil;
 import org.apache.sling.testing.mock.osgi.MockEventAdmin;
 import org.apache.sling.testing.mock.osgi.MockOsgi;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
 import org.osgi.annotation.versioning.ConsumerType;
 import org.osgi.framework.BundleContext;
 import org.osgi.framework.InvalidSyntaxException;
@@ -50,6 +52,7 @@
     /**
      * Teardown actions after test method execution
      */
+    @SuppressWarnings("null")
     protected void tearDown() {
         if (componentContext != null) {
             // deactivate all services
@@ -69,7 +72,8 @@
     /**
      * @return OSGi component context
      */
-    public final ComponentContext componentContext() {
+    @SuppressWarnings("null")
+    public final @NotNull ComponentContext componentContext() {
         if (this.componentContext == null) {
             this.componentContext = MockOsgi.newComponentContext();
         }
@@ -79,7 +83,8 @@
     /**
      * @return OSGi Bundle context
      */
-    public final BundleContext bundleContext() {
+    @SuppressWarnings("null")
+    public final @NotNull BundleContext bundleContext() {
         return componentContext().getBundleContext();
     }
 
@@ -89,7 +94,7 @@
      * @param service Service instance
      * @return Registered service instance
      */
-    public final <T> T registerService(final T service) {
+    public final @NotNull <T> T registerService(@NotNull final T service) {
         return registerService(null, service, (Map<String,Object>)null);
     }
 
@@ -100,7 +105,7 @@
      * @param service Service instance
      * @return Registered service instance
      */
-    public final <T> T registerService(final Class<T> serviceClass, final T service) {
+    public final @NotNull <T> T registerService(@Nullable final Class<T> serviceClass, @NotNull final T service) {
         return registerService(serviceClass, service, (Map<String,Object>)null);
     }
 
@@ -112,7 +117,7 @@
      * @param properties Service properties (optional)
      * @return Registered service instance
      */
-    public final <T> T registerService(final Class<T> serviceClass, final T service, final Map<String, Object> properties) {
+    public final @NotNull <T> T registerService(@Nullable final Class<T> serviceClass, @NotNull final T service, @Nullable final Map<String, Object> properties) {
         Dictionary<String, Object> serviceProperties = MapUtil.toDictionary(properties);
         bundleContext().registerService(serviceClass != null ? serviceClass.getName() : null, service, serviceProperties);
         return service;
@@ -126,7 +131,7 @@
      * @param properties Service properties (optional)
      * @return Registered service instance
      */
-    public final <T> T registerService(final Class<T> serviceClass, final T service, final Object... properties) {
+    public final @NotNull <T> T registerService(@Nullable final Class<T> serviceClass, @NotNull final T service, @NotNull final Object @NotNull ... properties) {
         return registerService(serviceClass, service, MapUtil.toMap(properties));
     }
     
@@ -137,7 +142,7 @@
      * @param service Service instance
      * @return Registered service instance
      */
-    public final <T> T registerInjectActivateService(final T service) {
+    public final @NotNull <T> T registerInjectActivateService(@NotNull final T service) {
         return registerInjectActivateService(service, (Map<String,Object>)null);
     }
 
@@ -149,7 +154,7 @@
      * @param properties Service properties (optional)
      * @return Registered service instance
      */
-    public final <T> T registerInjectActivateService(final T service, final Map<String, Object> properties) {
+    public final @NotNull <T> T registerInjectActivateService(@NotNull final T service, @Nullable final Map<String, Object> properties) {
         MockOsgi.injectServices(service, bundleContext(), properties);
         MockOsgi.activate(service, bundleContext(), properties);
         registerService(null, service, properties);
@@ -164,7 +169,7 @@
      * @param properties Service properties (optional)
      * @return Registered service instance
      */
-    public final <T> T registerInjectActivateService(final T service, final Object... properties) {
+    public final @NotNull <T> T registerInjectActivateService(@NotNull final T service, @NotNull final Object @NotNull ... properties) {
         return registerInjectActivateService(service, MapUtil.toMap(properties));
     }
 
@@ -175,7 +180,7 @@
      * @return The service instance, or null if the service is not available.
      */
     @SuppressWarnings("unchecked")
-    public final <ServiceType> ServiceType getService(final Class<ServiceType> serviceType) {
+    public final @Nullable <ServiceType> ServiceType getService(@NotNull final Class<ServiceType> serviceType) {
         ServiceReference serviceReference = bundleContext().getServiceReference(serviceType.getName());
         if (serviceReference != null) {
             return (ServiceType)bundleContext().getService(serviceReference);
@@ -192,8 +197,8 @@
      * @return The services instances or an empty array.
      * @throws RuntimeException If the <code>filter</code> string is not a valid OSGi service filter string.
      */
-    @SuppressWarnings("unchecked")
-    public final <ServiceType> ServiceType[] getServices(final Class<ServiceType> serviceType, final String filter) {
+    @SuppressWarnings({ "unchecked", "null" })
+    public final @NotNull <ServiceType> ServiceType @NotNull [] getServices(@NotNull final Class<ServiceType> serviceType, @Nullable final String filter) {
         try {
             ServiceReference[] serviceReferences = bundleContext().getServiceReferences(serviceType.getName(), filter);
             if (serviceReferences != null) {
diff --git a/src/main/java/org/apache/sling/testing/mock/osgi/context/package-info.java b/src/main/java/org/apache/sling/testing/mock/osgi/context/package-info.java
index 6e57ffd..aa88383 100644
--- a/src/main/java/org/apache/sling/testing/mock/osgi/context/package-info.java
+++ b/src/main/java/org/apache/sling/testing/mock/osgi/context/package-info.java
@@ -19,5 +19,5 @@
 /**
  * OSGi context implementation for unit tests.
  */
-@org.osgi.annotation.versioning.Version("1.2")
+@org.osgi.annotation.versioning.Version("1.2.1")
 package org.apache.sling.testing.mock.osgi.context;
diff --git a/src/main/java/org/apache/sling/testing/mock/osgi/junit/OsgiContext.java b/src/main/java/org/apache/sling/testing/mock/osgi/junit/OsgiContext.java
index 77e8ad5..01ffdc7 100644
--- a/src/main/java/org/apache/sling/testing/mock/osgi/junit/OsgiContext.java
+++ b/src/main/java/org/apache/sling/testing/mock/osgi/junit/OsgiContext.java
@@ -21,6 +21,7 @@
 import org.apache.sling.testing.mock.osgi.context.ContextCallback;
 import org.apache.sling.testing.mock.osgi.context.ContextPlugins;
 import org.apache.sling.testing.mock.osgi.context.OsgiContextImpl;
+import org.jetbrains.annotations.NotNull;
 import org.junit.rules.ExternalResource;
 import org.junit.rules.TestRule;
 import org.junit.runner.Description;
@@ -48,7 +49,7 @@
      * @param <T> context type
      * @param afterSetUpCallback Allows the application to register an own callback function that is called after the built-in setup rules are executed.
      */
-    public <T extends OsgiContextImpl> OsgiContext(final ContextCallback<T> afterSetUpCallback) {
+    public <T extends OsgiContextImpl> OsgiContext(@NotNull final ContextCallback<T> afterSetUpCallback) {
         this(new ContextPlugins(afterSetUpCallback));
     }
 
@@ -59,7 +60,7 @@
      * @param afterSetUpCallback Allows the application to register an own callback function that is called after the built-in setup rules are executed.
      * @param beforeTearDownCallback Allows the application to register an own callback function that is called before the built-in teardown rules are executed.
      */
-    public <U extends OsgiContextImpl, V extends OsgiContextImpl> OsgiContext(final ContextCallback<U> afterSetUpCallback, final ContextCallback<V> beforeTearDownCallback) {
+    public <U extends OsgiContextImpl, V extends OsgiContextImpl> OsgiContext(@NotNull final ContextCallback<U> afterSetUpCallback, @NotNull final ContextCallback<V> beforeTearDownCallback) {
         this(new ContextPlugins(afterSetUpCallback, beforeTearDownCallback));
     }
 
@@ -67,7 +68,7 @@
      * Initialize OSGi context with resource resolver type.
      * @param contextPlugins Context plugins
      */
-    OsgiContext(final ContextPlugins contextPlugins) {
+    OsgiContext(@NotNull final ContextPlugins contextPlugins) {
         this.plugins = contextPlugins;
 
         // wrap {@link ExternalResource} rule executes each test method once
diff --git a/src/main/java/org/apache/sling/testing/mock/osgi/junit/OsgiContextBuilder.java b/src/main/java/org/apache/sling/testing/mock/osgi/junit/OsgiContextBuilder.java
index 9207e40..81bd569 100644
--- a/src/main/java/org/apache/sling/testing/mock/osgi/junit/OsgiContextBuilder.java
+++ b/src/main/java/org/apache/sling/testing/mock/osgi/junit/OsgiContextBuilder.java
@@ -20,6 +20,7 @@
 
 import org.apache.sling.testing.mock.osgi.context.ContextPlugins;
 import org.apache.sling.testing.mock.osgi.context.OsgiContextImpl;
+import org.jetbrains.annotations.NotNull;
 import org.apache.sling.testing.mock.osgi.context.ContextCallback;
 import org.apache.sling.testing.mock.osgi.context.ContextPlugin;
 import org.osgi.annotation.versioning.ProviderType;
@@ -30,7 +31,7 @@
 @ProviderType
 public final class OsgiContextBuilder {
     
-    private final ContextPlugins plugins = new ContextPlugins();
+    private final @NotNull ContextPlugins plugins = new ContextPlugins();
     
     /**
      * Create builder with default resource resolver type.
@@ -43,7 +44,7 @@
      * @return this
      */
     @SafeVarargs
-    public final <T extends OsgiContextImpl> OsgiContextBuilder plugin(ContextPlugin<T>... plugin) {
+    public final @NotNull <T extends OsgiContextImpl> OsgiContextBuilder plugin(@NotNull ContextPlugin<T> @NotNull ... plugin) {
         plugins.addPlugin(plugin);
         return this;
     }
@@ -54,7 +55,7 @@
      * @return this
      */
     @SafeVarargs
-    public final <T extends OsgiContextImpl> OsgiContextBuilder beforeSetUp(ContextCallback<T>... beforeSetUpCallback) {
+    public final @NotNull <T extends OsgiContextImpl> OsgiContextBuilder beforeSetUp(@NotNull ContextCallback<T> @NotNull ... beforeSetUpCallback) {
         plugins.addBeforeSetUpCallback(beforeSetUpCallback);
         return this;
     }
@@ -65,7 +66,7 @@
      * @return this
      */
     @SafeVarargs
-    public final <T extends OsgiContextImpl> OsgiContextBuilder afterSetUp(ContextCallback<T>... afterSetUpCallback) {
+    public final @NotNull <T extends OsgiContextImpl> OsgiContextBuilder afterSetUp(@NotNull ContextCallback<T> @NotNull ... afterSetUpCallback) {
         plugins.addAfterSetUpCallback(afterSetUpCallback);
         return this;
     }
@@ -76,7 +77,7 @@
      * @return this
      */
     @SafeVarargs
-    public final <T extends OsgiContextImpl> OsgiContextBuilder beforeTearDown(ContextCallback<T>... beforeTearDownCallback) {
+    public final @NotNull <T extends OsgiContextImpl> OsgiContextBuilder beforeTearDown(@NotNull ContextCallback<T> @NotNull ... beforeTearDownCallback) {
         plugins.addBeforeTearDownCallback(beforeTearDownCallback);
         return this;
     }
@@ -87,7 +88,7 @@
      * @return this
      */
     @SafeVarargs
-    public final <T extends OsgiContextImpl> OsgiContextBuilder afterTearDown(ContextCallback<T>... afterTearDownCallback) {
+    public final @NotNull <T extends OsgiContextImpl> OsgiContextBuilder afterTearDown(@NotNull ContextCallback<T> @NotNull ... afterTearDownCallback) {
         plugins.addAfterTearDownCallback(afterTearDownCallback);
         return this;
     }
@@ -95,7 +96,7 @@
     /**
      * @return Build {@link OsgiContext} instance.
      */
-    public OsgiContext build() {
+    public @NotNull OsgiContext build() {
         return new OsgiContext(plugins);
     }
     
diff --git a/src/main/java/org/apache/sling/testing/mock/osgi/junit/package-info.java b/src/main/java/org/apache/sling/testing/mock/osgi/junit/package-info.java
index 2295cbc..7f0ca70 100644
--- a/src/main/java/org/apache/sling/testing/mock/osgi/junit/package-info.java
+++ b/src/main/java/org/apache/sling/testing/mock/osgi/junit/package-info.java
@@ -19,5 +19,5 @@
 /**
  * Rule for providing easy access to OSGi context in JUnit tests.
  */
-@org.osgi.annotation.versioning.Version("2.0")
+@org.osgi.annotation.versioning.Version("2.0.1")
 package org.apache.sling.testing.mock.osgi.junit;
diff --git a/src/main/java/org/apache/sling/testing/mock/osgi/package-info.java b/src/main/java/org/apache/sling/testing/mock/osgi/package-info.java
index db6c8d4..6992550 100644
--- a/src/main/java/org/apache/sling/testing/mock/osgi/package-info.java
+++ b/src/main/java/org/apache/sling/testing/mock/osgi/package-info.java
@@ -19,5 +19,5 @@
 /**
  * Mock implementation of selected OSGi APIs.
  */
-@org.osgi.annotation.versioning.Version("3.4")
+@org.osgi.annotation.versioning.Version("3.4.1")
 package org.apache.sling.testing.mock.osgi;
diff --git a/src/test/java/org/apache/sling/testing/mock/osgi/ManifestScannerTest.java b/src/test/java/org/apache/sling/testing/mock/osgi/ManifestScannerTest.java
index 8a536c5..2e04eaa 100644
--- a/src/test/java/org/apache/sling/testing/mock/osgi/ManifestScannerTest.java
+++ b/src/test/java/org/apache/sling/testing/mock/osgi/ManifestScannerTest.java
@@ -25,6 +25,7 @@
 import org.junit.Test;
 import org.osgi.framework.Constants;
 
+@SuppressWarnings("null")
 public class ManifestScannerTest {
 
     /**
diff --git a/src/test/java/org/apache/sling/testing/mock/osgi/MockBundleContextDynamicReferencesOsgiR6Test.java b/src/test/java/org/apache/sling/testing/mock/osgi/MockBundleContextDynamicReferencesOsgiR6Test.java
index fa8a8c4..9de52ce 100644
--- a/src/test/java/org/apache/sling/testing/mock/osgi/MockBundleContextDynamicReferencesOsgiR6Test.java
+++ b/src/test/java/org/apache/sling/testing/mock/osgi/MockBundleContextDynamicReferencesOsgiR6Test.java
@@ -40,6 +40,7 @@
 import com.google.common.collect.ImmutableSet;
 
 @RunWith(MockitoJUnitRunner.class)
+@SuppressWarnings("null")
 public class MockBundleContextDynamicReferencesOsgiR6Test {
 
     private BundleContext bundleContext;
diff --git a/src/test/java/org/apache/sling/testing/mock/osgi/MockBundleContextDynamicReferencesTest.java b/src/test/java/org/apache/sling/testing/mock/osgi/MockBundleContextDynamicReferencesTest.java
index 028da91..4fcd531 100644
--- a/src/test/java/org/apache/sling/testing/mock/osgi/MockBundleContextDynamicReferencesTest.java
+++ b/src/test/java/org/apache/sling/testing/mock/osgi/MockBundleContextDynamicReferencesTest.java
@@ -39,6 +39,7 @@
 import com.google.common.collect.ImmutableSet;
 
 @RunWith(MockitoJUnitRunner.class)
+@SuppressWarnings("null")
 public class MockBundleContextDynamicReferencesTest {
 
     private BundleContext bundleContext;
diff --git a/src/test/java/org/apache/sling/testing/mock/osgi/MockBundleContextStaticGreedyReferencesTest.java b/src/test/java/org/apache/sling/testing/mock/osgi/MockBundleContextStaticGreedyReferencesTest.java
index f707222..a78ad3c 100644
--- a/src/test/java/org/apache/sling/testing/mock/osgi/MockBundleContextStaticGreedyReferencesTest.java
+++ b/src/test/java/org/apache/sling/testing/mock/osgi/MockBundleContextStaticGreedyReferencesTest.java
@@ -40,6 +40,7 @@
 import com.google.common.collect.ImmutableSet;
 
 @RunWith(MockitoJUnitRunner.class)
+@SuppressWarnings("null")
 public class MockBundleContextStaticGreedyReferencesTest {
 
     private BundleContext bundleContext;
diff --git a/src/test/java/org/apache/sling/testing/mock/osgi/MockBundleContextTest.java b/src/test/java/org/apache/sling/testing/mock/osgi/MockBundleContextTest.java
index e031f72..0359040 100644
--- a/src/test/java/org/apache/sling/testing/mock/osgi/MockBundleContextTest.java
+++ b/src/test/java/org/apache/sling/testing/mock/osgi/MockBundleContextTest.java
@@ -53,6 +53,7 @@
 import org.osgi.framework.ServiceRegistration;
 
 @RunWith(MockitoJUnitRunner.class)
+@SuppressWarnings("null")
 public class MockBundleContextTest {
 
     private BundleContext bundleContext;
diff --git a/src/test/java/org/apache/sling/testing/mock/osgi/MockComponentContextTest.java b/src/test/java/org/apache/sling/testing/mock/osgi/MockComponentContextTest.java
index aab327e..7e5ef2b 100644
--- a/src/test/java/org/apache/sling/testing/mock/osgi/MockComponentContextTest.java
+++ b/src/test/java/org/apache/sling/testing/mock/osgi/MockComponentContextTest.java
@@ -33,6 +33,7 @@
 import org.osgi.framework.ServiceReference;
 import org.osgi.service.component.ComponentContext;
 
+@SuppressWarnings("null")
 public class MockComponentContextTest {
 
     private ComponentContext underTest;
diff --git a/src/test/java/org/apache/sling/testing/mock/osgi/MockConfigurationAdminTest.java b/src/test/java/org/apache/sling/testing/mock/osgi/MockConfigurationAdminTest.java
index 187efbd..de663b4 100644
--- a/src/test/java/org/apache/sling/testing/mock/osgi/MockConfigurationAdminTest.java
+++ b/src/test/java/org/apache/sling/testing/mock/osgi/MockConfigurationAdminTest.java
@@ -32,6 +32,7 @@
 
 import com.google.common.collect.ImmutableMap;
 
+@SuppressWarnings("null")
 public class MockConfigurationAdminTest {
     
     private static final String[] TEST_ADAPTABLES = new String[] {
diff --git a/src/test/java/org/apache/sling/testing/mock/osgi/MockEventAdminTest.java b/src/test/java/org/apache/sling/testing/mock/osgi/MockEventAdminTest.java
index 4f46611..e8004d0 100644
--- a/src/test/java/org/apache/sling/testing/mock/osgi/MockEventAdminTest.java
+++ b/src/test/java/org/apache/sling/testing/mock/osgi/MockEventAdminTest.java
@@ -37,6 +37,7 @@
 import com.google.common.collect.ImmutableList;
 import com.google.common.collect.ImmutableMap;
 
+@SuppressWarnings("null")
 public class MockEventAdminTest {
     
     private static final String TOPIC_SAMPLE_1 = "sample/topic1";
diff --git a/src/test/java/org/apache/sling/testing/mock/osgi/MockServiceReferencesSortTest.java b/src/test/java/org/apache/sling/testing/mock/osgi/MockServiceReferencesSortTest.java
index 2c83bcf..d639f66 100644
--- a/src/test/java/org/apache/sling/testing/mock/osgi/MockServiceReferencesSortTest.java
+++ b/src/test/java/org/apache/sling/testing/mock/osgi/MockServiceReferencesSortTest.java
@@ -37,6 +37,7 @@
 /** 
  * Test the service-ranking based sorting of mock service references
  */
+@SuppressWarnings("null")
 public class MockServiceReferencesSortTest {
     
     private BundleContext bundleContext;
diff --git a/src/test/java/org/apache/sling/testing/mock/osgi/OsgiServiceUtilActivateDeactivateTest.java b/src/test/java/org/apache/sling/testing/mock/osgi/OsgiServiceUtilActivateDeactivateTest.java
index 60358a4..bed7b87 100644
--- a/src/test/java/org/apache/sling/testing/mock/osgi/OsgiServiceUtilActivateDeactivateTest.java
+++ b/src/test/java/org/apache/sling/testing/mock/osgi/OsgiServiceUtilActivateDeactivateTest.java
@@ -37,6 +37,7 @@
 /**
  * Test different variants of activate/deactivate methods with varying signatures.
  */
+@SuppressWarnings("null")
 public class OsgiServiceUtilActivateDeactivateTest {
 
     private Map<String,Object> map = ImmutableMap.<String, Object>of("prop1", "value1");
diff --git a/src/test/java/org/apache/sling/testing/mock/osgi/OsgiServiceUtilTest.java b/src/test/java/org/apache/sling/testing/mock/osgi/OsgiServiceUtilTest.java
index 6ae014a..1f5497a 100644
--- a/src/test/java/org/apache/sling/testing/mock/osgi/OsgiServiceUtilTest.java
+++ b/src/test/java/org/apache/sling/testing/mock/osgi/OsgiServiceUtilTest.java
@@ -51,6 +51,7 @@
 
 import com.google.common.collect.ImmutableMap;
 
+@SuppressWarnings("null")
 public class OsgiServiceUtilTest {
 
     private BundleContext bundleContext = MockOsgi.newBundleContext();
diff --git a/src/test/java/org/apache/sling/testing/mock/osgi/context/ContextPluginsTest.java b/src/test/java/org/apache/sling/testing/mock/osgi/context/ContextPluginsTest.java
index cee77f0..1a97478 100644
--- a/src/test/java/org/apache/sling/testing/mock/osgi/context/ContextPluginsTest.java
+++ b/src/test/java/org/apache/sling/testing/mock/osgi/context/ContextPluginsTest.java
@@ -30,7 +30,7 @@
 import org.mockito.runners.MockitoJUnitRunner;
 
 @RunWith(MockitoJUnitRunner.class)
-@SuppressWarnings("unchecked")
+@SuppressWarnings({"unchecked","null"})
 public class ContextPluginsTest {
     
     private OsgiContext context = new OsgiContext();
diff --git a/src/test/java/org/apache/sling/testing/mock/osgi/context/OsgiContextImplTest.java b/src/test/java/org/apache/sling/testing/mock/osgi/context/OsgiContextImplTest.java
index d4bee18..b3e80e1 100644
--- a/src/test/java/org/apache/sling/testing/mock/osgi/context/OsgiContextImplTest.java
+++ b/src/test/java/org/apache/sling/testing/mock/osgi/context/OsgiContextImplTest.java
@@ -40,6 +40,7 @@
 import org.osgi.service.component.annotations.Component;
 import org.osgi.util.tracker.ServiceTracker;
 
+@SuppressWarnings("null")
 public class OsgiContextImplTest {
 
     private OsgiContextImpl context;
diff --git a/src/test/java/org/apache/sling/testing/mock/osgi/junit/OsgiContextTest.java b/src/test/java/org/apache/sling/testing/mock/osgi/junit/OsgiContextTest.java
index 840e951..e374516 100644
--- a/src/test/java/org/apache/sling/testing/mock/osgi/junit/OsgiContextTest.java
+++ b/src/test/java/org/apache/sling/testing/mock/osgi/junit/OsgiContextTest.java
@@ -29,6 +29,7 @@
 import org.mockito.runners.MockitoJUnitRunner;
 
 @RunWith(MockitoJUnitRunner.class)
+@SuppressWarnings("null")
 public class OsgiContextTest {
 
     private final OsgiContextCallback contextBeforeSetup = mock(OsgiContextCallback.class);