516412 - Code cleanup before migrating to Equinox 1.10.2

Change-Id: I28bb50456861d2a1ef7bc0214c015e4600b6e84d
diff --git a/kernel/org.eclipse.virgo.kernel.equinox.extensions/src/main/java/org/eclipse/virgo/kernel/equinox/extensions/ExtendedEquinoxLauncher.java b/kernel/org.eclipse.virgo.kernel.equinox.extensions/src/main/java/org/eclipse/virgo/kernel/equinox/extensions/ExtendedEquinoxLauncher.java
index 1376c50..ff2ed58 100644
--- a/kernel/org.eclipse.virgo.kernel.equinox.extensions/src/main/java/org/eclipse/virgo/kernel/equinox/extensions/ExtendedEquinoxLauncher.java
+++ b/kernel/org.eclipse.virgo.kernel.equinox.extensions/src/main/java/org/eclipse/virgo/kernel/equinox/extensions/ExtendedEquinoxLauncher.java
@@ -25,8 +25,6 @@
 import org.osgi.framework.launch.Framework;
 
 
-/**
- */
 public final class ExtendedEquinoxLauncher {
 
     private static final String PROP_CONTEXT_BOOTDELEGATION = "osgi.context.bootdelegation";
@@ -61,10 +59,10 @@
     }
 
     private static Map<String, String> populateConfiguration(EquinoxLauncherConfiguration config) {
-        Map<String, String> configuration = new HashMap<String, String>();
-        configuration.putAll(config.getFrameworkProperties());
+        Map<String, String> configuration = new HashMap<>(config.getFrameworkProperties());
 
-        mergeListProperty(configuration, HookRegistry.PROP_HOOK_CONFIGURATORS_INCLUDE, ExtensionsHookConfigurator.class.getName());
+        configuration.merge(HookRegistry.PROP_HOOK_CONFIGURATORS_INCLUDE,
+                ExtensionsHookConfigurator.class.getName(), (a, b) -> a + "," + b);
 
         configuration.put(PROP_OSGI_PARENT_CLASSLOADER, "fwk");
         configuration.put(PROP_CONTEXT_BOOTDELEGATION, "false");
@@ -78,13 +76,5 @@
         configuration.put(PROP_OSGI_CLEAN, Boolean.toString(config.isClean()));
         return configuration;
     }
-    
-    private static void mergeListProperty(Map<String, String> properties, String key, String value) {
-        String existingValue = properties.get(key);
-        if (existingValue != null) {
-            properties.put(key, existingValue + "," + value);
-        } else {
-            properties.put(key, value);
-        }
-    }
+
 }
diff --git a/kernel/org.eclipse.virgo.kernel.equinox.extensions/src/main/java/org/eclipse/virgo/kernel/equinox/extensions/hooks/ClassLoaderCreator.java b/kernel/org.eclipse.virgo.kernel.equinox.extensions/src/main/java/org/eclipse/virgo/kernel/equinox/extensions/hooks/ClassLoaderCreator.java
index 21913ab..74c4c7f 100644
--- a/kernel/org.eclipse.virgo.kernel.equinox.extensions/src/main/java/org/eclipse/virgo/kernel/equinox/extensions/hooks/ClassLoaderCreator.java
+++ b/kernel/org.eclipse.virgo.kernel.equinox.extensions/src/main/java/org/eclipse/virgo/kernel/equinox/extensions/hooks/ClassLoaderCreator.java
@@ -28,5 +28,5 @@
  */
 public interface ClassLoaderCreator {
 
-    public BaseClassLoader createClassLoader(ClassLoader parent, ClassLoaderDelegate delegate, BundleProtectionDomain domain, BaseData data, String[] bundleclasspath);
+    BaseClassLoader createClassLoader(ClassLoader parent, ClassLoaderDelegate delegate, BundleProtectionDomain domain, BaseData data, String[] bundleclasspath);
 }
diff --git a/kernel/org.eclipse.virgo.kernel.equinox.extensions/src/test/java/org/eclipse/virgo/kernel/equinox/extensions/hooks/PluggableClassLoadingHookTests.java b/kernel/org.eclipse.virgo.kernel.equinox.extensions/src/test/java/org/eclipse/virgo/kernel/equinox/extensions/hooks/PluggableClassLoadingHookTests.java
index 76e7b5e..4f49ec4 100644
--- a/kernel/org.eclipse.virgo.kernel.equinox.extensions/src/test/java/org/eclipse/virgo/kernel/equinox/extensions/hooks/PluggableClassLoadingHookTests.java
+++ b/kernel/org.eclipse.virgo.kernel.equinox.extensions/src/test/java/org/eclipse/virgo/kernel/equinox/extensions/hooks/PluggableClassLoadingHookTests.java
@@ -26,8 +26,6 @@
 import org.eclipse.osgi.launch.Equinox;
 import org.eclipse.virgo.kernel.equinox.extensions.EquinoxLauncherConfiguration;
 import org.eclipse.virgo.kernel.equinox.extensions.ExtendedEquinoxLauncher;
-import org.eclipse.virgo.kernel.equinox.extensions.hooks.ClassLoaderCreator;
-import org.eclipse.virgo.kernel.equinox.extensions.hooks.PluggableClassLoadingHook;
 import org.junit.After;
 import org.junit.Before;
 import org.junit.Test;
@@ -36,8 +34,6 @@
 import org.osgi.framework.BundleException;
 
 
-/**
- */
 public class PluggableClassLoadingHookTests {
 
     private Equinox osgi;
@@ -63,7 +59,7 @@
 
     @Test
     public void testAddClassLoaderCreator() throws Exception {
-        final List<BaseData> baseDatas = new ArrayList<BaseData>();
+        final List<BaseData> baseDatas = new ArrayList<>();
         
         ClassLoaderCreator creator = new ClassLoaderCreator() {
 
@@ -72,7 +68,7 @@
                 baseDatas.add(data);
                 return null;
             }
-            
+
         };
         
         PluggableClassLoadingHook.getInstance().setClassLoaderCreator(creator);
diff --git a/kernel/org.eclipse.virgo.kernel.userregion/src/main/java/org/eclipse/virgo/kernel/userregion/internal/Activator.java b/kernel/org.eclipse.virgo.kernel.userregion/src/main/java/org/eclipse/virgo/kernel/userregion/internal/Activator.java
index d7fe18b..66c688a 100644
--- a/kernel/org.eclipse.virgo.kernel.userregion/src/main/java/org/eclipse/virgo/kernel/userregion/internal/Activator.java
+++ b/kernel/org.eclipse.virgo.kernel.userregion/src/main/java/org/eclipse/virgo/kernel/userregion/internal/Activator.java
@@ -131,7 +131,7 @@
 
         scheduleRegistrationOfServiceScopingRegistryHooks(context, eventLogger);
 
-        Dictionary<String, Object> properties = new Hashtable<String, Object>();
+        Dictionary<String, Object> properties = new Hashtable<>();
         properties.put(Constants.SERVICE_RANKING, Integer.MIN_VALUE);
         this.registrationTracker.track(context.registerService(ModuleContextAccessor.class.getName(), new EmptyModuleContextAccessor(), properties));
 
@@ -145,8 +145,6 @@
     /**
      * This method gets the kernel and user regions configurations from the kernel region and publishes them in the
      * configuration admin in the user region.
-     * 
-     * @throws Exception
      */
     private void publishConfigurations(BundleContext context) throws Exception {
         ConfigurationExporter configurationExporter = getPotentiallyDelayedService(context, ConfigurationExporter.class);
@@ -219,7 +217,7 @@
     private void scheduleInitialArtifactDeployerCreation(BundleContext context, EventLogger eventLogger) {
         KernelStartedAwaiter startedAwaiter = new KernelStartedAwaiter();
 
-        Dictionary<String, String> properties = new Hashtable<String, String>();
+        Dictionary<String, String> properties = new Hashtable<>();
         properties.put(EventConstants.EVENT_TOPIC, "org/eclipse/virgo/kernel/*");
         this.registrationTracker.track(context.registerService(EventHandler.class.getName(), startedAwaiter, properties));
 
@@ -237,7 +235,7 @@
     /**
      * {@inheritDoc}
      */
-    public void stop(BundleContext context) throws Exception {
+    public void stop(BundleContext context) {
         this.registrationTracker.unregisterAll();
         
         if (this.consoleConfigurationConvertor != null) {
@@ -266,7 +264,7 @@
 
         private final ServiceRegistrationTracker registrationTracker;
 
-        public ServiceScopingHookRegisteringRunnable(BundleContext context, ServiceRegistrationTracker registrationTracker, EventLogger eventLogger) {
+        ServiceScopingHookRegisteringRunnable(BundleContext context, ServiceRegistrationTracker registrationTracker, EventLogger eventLogger) {
             this.context = context;
             this.registrationTracker = registrationTracker;
             this.eventLogger = eventLogger;
@@ -305,8 +303,8 @@
 
         private final ServiceRegistrationTracker registrationTracker;
 
-        public InitialArtifactDeployerCreatingRunnable(BundleContext context, EventLogger eventLogger,
-            ServiceRegistrationTracker registrationTracker, KernelStartedAwaiter startAwaiter) {
+        InitialArtifactDeployerCreatingRunnable(BundleContext context, EventLogger eventLogger,
+                                                ServiceRegistrationTracker registrationTracker, KernelStartedAwaiter startAwaiter) {
             this.context = context;
             this.eventLogger = eventLogger;
             this.startAwaiter = startAwaiter;
@@ -329,7 +327,7 @@
                 InitialArtifactDeployer initialArtifactDeployer = new InitialArtifactDeployer(this.startAwaiter, deployer,
                     artifactConfiguration.get(PROPERTY_USER_REGION_ARTIFACTS), artifactConfiguration.get(PROPERTY_USER_REGION_COMMANDLINE_ARTIFACTS),
                     uriNormaliser, eventAdmin, eventLogger, shutdown);
-                Dictionary<String, String> properties = new Hashtable<String, String>();
+                Dictionary<String, String> properties = new Hashtable<>();
                 properties.put(EventConstants.EVENT_TOPIC, "org/eclipse/virgo/kernel/*");
                 this.registrationTracker.track(context.registerService(EventHandler.class.getName(), initialArtifactDeployer, properties));
 
@@ -347,8 +345,7 @@
             ConfigurationAdmin configAdmin = OsgiFrameworkUtils.getService(this.context, ConfigurationAdmin.class).getService();
             try {
                 Configuration config = configAdmin.getConfiguration(USER_REGION_CONFIGURATION_PID, null);
-                Dictionary<String, Object> properties = (Dictionary<String, Object>) config.getProperties();
-                return properties;
+                return config.getProperties();
             } catch (IOException ioe) {
                 throw new RuntimeException("Failed to read region artifact configuration", ioe);
             }
diff --git a/kernel/org.eclipse.virgo.kernel.userregion/src/main/java/org/eclipse/virgo/kernel/userregion/internal/equinox/EquinoxOsgiFramework.java b/kernel/org.eclipse.virgo.kernel.userregion/src/main/java/org/eclipse/virgo/kernel/userregion/internal/equinox/EquinoxOsgiFramework.java
index 06efd76..bcdafbc 100644
--- a/kernel/org.eclipse.virgo.kernel.userregion/src/main/java/org/eclipse/virgo/kernel/userregion/internal/equinox/EquinoxOsgiFramework.java
+++ b/kernel/org.eclipse.virgo.kernel.userregion/src/main/java/org/eclipse/virgo/kernel/userregion/internal/equinox/EquinoxOsgiFramework.java
@@ -68,7 +68,7 @@
      */
     public void refresh(Bundle bundle) throws BundleException {
         ClassLoader cl = getBundleClassLoader(bundle);
-        List<Bundle> refreshBundles = new ArrayList<Bundle>();
+        List<Bundle> refreshBundles = new ArrayList<>();
         if (cl instanceof KernelBundleClassLoader) {
             KernelBundleClassLoader pbcl = (KernelBundleClassLoader) cl;
             if (pbcl.isInstrumented()) {
@@ -83,7 +83,7 @@
         }
         bundle.update();
         refreshBundles.add(bundle);
-        Bundle[] toRefresh = refreshBundles.toArray(new Bundle[refreshBundles.size()]);
+        Bundle[] toRefresh = refreshBundles.toArray(new Bundle[0]);
         getPackageAdmin().refreshPackages(toRefresh);
     }
 
@@ -118,7 +118,7 @@
         BundleContext bundleContext = getBundleContext();
         ServiceReference<PlatformAdmin> serviceRef = bundleContext.getServiceReference(PlatformAdmin.class);
         try {
-            PlatformAdmin serverAdmin = (PlatformAdmin) bundleContext.getService(serviceRef);
+            PlatformAdmin serverAdmin = bundleContext.getService(serviceRef);
             return EquinoxUtils.getDirectDependencies(bundle, bundleContext, serverAdmin, includeFragments);
         } finally {
             bundleContext.ungetService(serviceRef);
@@ -158,7 +158,7 @@
         }
     }
 
-    private String getAbsoluteUriString(File location) throws BundleException {
+    private String getAbsoluteUriString(File location) {
         return FILE_SCHEME + location.getAbsolutePath();
     }
 }
diff --git a/kernel/org.eclipse.virgo.kernel.userregion/src/main/java/org/eclipse/virgo/kernel/userregion/internal/equinox/EquinoxUtils.java b/kernel/org.eclipse.virgo.kernel.userregion/src/main/java/org/eclipse/virgo/kernel/userregion/internal/equinox/EquinoxUtils.java
index 1bc62f2..138fd21 100644
--- a/kernel/org.eclipse.virgo.kernel.userregion/src/main/java/org/eclipse/virgo/kernel/userregion/internal/equinox/EquinoxUtils.java
+++ b/kernel/org.eclipse.virgo.kernel.userregion/src/main/java/org/eclipse/virgo/kernel/userregion/internal/equinox/EquinoxUtils.java
@@ -100,7 +100,7 @@
 
         ExportPackageDescription[] exportPackageDescriptions = serverAdmin.getStateHelper().getVisiblePackages(state.getBundle(bundle.getBundleId()));
 
-        Set<Bundle> dependencies = new HashSet<Bundle>();
+        Set<Bundle> dependencies = new HashSet<>();
 
         for (ExportPackageDescription exportPackageDescription : exportPackageDescriptions) {
             BundleDescription bundleDescription = exportPackageDescription.getExporter();
@@ -122,16 +122,7 @@
             }
         }
 
-        return dependencies.toArray(new Bundle[dependencies.size()]);
+        return dependencies.toArray(new Bundle[0]);
     }
 
-    /**
-     * Queries whether the supplied {@link Bundle} is the system bundle.
-     * 
-     * @param bundle the <code>Bundle</code>.
-     * @return <code>true</code> if <code>bundle</code> is the system bundle, otherwise <code>false</code>.
-     */
-    public static boolean isSystemBundle(Bundle bundle) {
-        return bundle != null && bundle.getBundleId() == 0;
-    }
 }
diff --git a/kernel/org.eclipse.virgo.kernel.userregion/src/main/java/org/eclipse/virgo/kernel/userregion/internal/equinox/KernelBundleClassLoader.java b/kernel/org.eclipse.virgo.kernel.userregion/src/main/java/org/eclipse/virgo/kernel/userregion/internal/equinox/KernelBundleClassLoader.java
index 3273473..86d3a42 100644
--- a/kernel/org.eclipse.virgo.kernel.userregion/src/main/java/org/eclipse/virgo/kernel/userregion/internal/equinox/KernelBundleClassLoader.java
+++ b/kernel/org.eclipse.virgo.kernel.userregion/src/main/java/org/eclipse/virgo/kernel/userregion/internal/equinox/KernelBundleClassLoader.java
@@ -40,6 +40,7 @@
 import org.eclipse.osgi.framework.adaptor.ClassLoaderDelegate;
 import org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader;
 import org.eclipse.osgi.service.resolver.PlatformAdmin;
+import org.eclipse.virgo.util.osgi.BundleUtils;
 import org.osgi.framework.Bundle;
 import org.osgi.framework.BundleContext;
 import org.slf4j.Logger;
@@ -77,7 +78,7 @@
 
     private static final Logger LOGGER = LoggerFactory.getLogger(KernelBundleClassLoader.class);
 
-    private final List<ClassFileTransformer> classFileTransformers = new CopyOnWriteArrayList<ClassFileTransformer>();
+    private final List<ClassFileTransformer> classFileTransformers = new CopyOnWriteArrayList<>();
 
     private final String[] instrumentedPackages;
 
@@ -85,7 +86,7 @@
 
     private final String bundleScope;
 
-    private final Set<Class<Driver>> loadedDriverClasses = new HashSet<Class<Driver>>();
+    private final Set<Class<Driver>> loadedDriverClasses = new HashSet<>();
 
     private final Object monitor = new Object();
 
@@ -129,10 +130,6 @@
         }
     }
 
-    /**
-     * @param bundle
-     * @return
-     */
     private ClassLoader getBundleClassLoader(Bundle bundle) {
         return EquinoxUtils.getBundleClassLoader(bundle);
     }
@@ -171,7 +168,7 @@
      * Finds the explicit list of packages to include in instrumentation (if specified).
      */
     private String[] findInstrumentedPackages(Bundle bundle) {
-        String headerValue = (String) bundle.getHeaders().get(HEADER_INSTRUMENT_PACKAGE);
+        String headerValue = bundle.getHeaders().get(HEADER_INSTRUMENT_PACKAGE);
         if (headerValue == null || headerValue.length() == 0) {
             return new String[0];
         } else {
@@ -185,7 +182,7 @@
     }
 
     private boolean propagateInstrumentationTo(Bundle bundle) {
-        return !EquinoxUtils.isSystemBundle(bundle) && this.bundleScope != null && this.bundleScope.equals(OsgiFrameworkUtils.getScopeName(bundle));
+        return !BundleUtils.isSystemBundle(bundle) && this.bundleScope != null && this.bundleScope.equals(OsgiFrameworkUtils.getScopeName(bundle));
     }
 
     private boolean shouldInstrument(String className) {
@@ -256,9 +253,6 @@
         }
     }
 
-    /**
-     * @param definedClass
-     */
     @SuppressWarnings("unchecked")
     private void storeClassIfDriver(Class<?> candidateClass) {
         if (Driver.class.isAssignableFrom(candidateClass)) {
@@ -276,7 +270,7 @@
     private void clearJdbcDrivers() {
         Set<Class<Driver>> localLoadedDriverClasses;
         synchronized (this.monitor) {
-            localLoadedDriverClasses = new HashSet<Class<Driver>>(this.loadedDriverClasses);
+            localLoadedDriverClasses = new HashSet<>(this.loadedDriverClasses);
         }
 
         synchronized (DriverManager.class) {
@@ -308,7 +302,7 @@
                     CopyOnWriteArrayList<?> registeredDrivers = (CopyOnWriteArrayList<?>) registeredDriversField.get(null);
 
                     Iterator<?> driverElements = registeredDrivers.iterator();
-                    List<Object> driverElementsToRemove = new ArrayList<Object>();
+                    List<Object> driverElementsToRemove = new ArrayList<>();
 
                     while (driverElements.hasNext()) {
                         Object driverObj = driverElements.next();
@@ -339,8 +333,7 @@
         Bundle bundle = this.manager.getBaseData().getBundle();
         BundleContext systemBundleContext = getBundleContext();
         PlatformAdmin serverAdmin = getPlatformAdmin();
-        Bundle[] deps = EquinoxUtils.getDirectDependencies(bundle, systemBundleContext, serverAdmin, includeDependenciesFragments);
-        return deps;
+        return EquinoxUtils.getDirectDependencies(bundle, systemBundleContext, serverAdmin, includeDependenciesFragments);
     }
 
     /**
@@ -372,13 +365,10 @@
      */
     final class ThrowAwayClassLoader extends ClassLoader {
 
-        private final ConcurrentMap<String, Class<?>> loadedClasses = new ConcurrentHashMap<String, Class<?>>();
+        private final ConcurrentMap<String, Class<?>> loadedClasses = new ConcurrentHashMap<>();
 
         private final ClasspathManager manager;
 
-        /**
-         * @param manager
-         */
         private ThrowAwayClassLoader(ClasspathManager manager) {
             this.manager = manager;
         }
diff --git a/kernel/org.eclipse.virgo.kernel.userregion/src/main/java/org/eclipse/virgo/kernel/userregion/internal/equinox/TransformedManifestProvidingBundleFileWrapper.java b/kernel/org.eclipse.virgo.kernel.userregion/src/main/java/org/eclipse/virgo/kernel/userregion/internal/equinox/TransformedManifestProvidingBundleFileWrapper.java
index 0e67900..5c4c264 100644
--- a/kernel/org.eclipse.virgo.kernel.userregion/src/main/java/org/eclipse/virgo/kernel/userregion/internal/equinox/TransformedManifestProvidingBundleFileWrapper.java
+++ b/kernel/org.eclipse.virgo.kernel.userregion/src/main/java/org/eclipse/virgo/kernel/userregion/internal/equinox/TransformedManifestProvidingBundleFileWrapper.java
@@ -75,7 +75,7 @@
 
         @Override
         public Stack<ManifestTransformer> initialValue() {
-            return new Stack<ManifestTransformer>();
+            return new Stack<>();
         }
     }
 
@@ -259,7 +259,7 @@
          * {@inheritDoc}
          */
         @Override
-        public InputStream getInputStream() throws IOException {                  
+        public InputStream getInputStream() {
             return new ByteArrayInputStream(this.manifestBytes); 
         }
 
diff --git a/kernel/org.eclipse.virgo.kernel.userregion/src/main/java/org/eclipse/virgo/kernel/userregion/internal/importexpansion/ImportExpansionHandler.java b/kernel/org.eclipse.virgo.kernel.userregion/src/main/java/org/eclipse/virgo/kernel/userregion/internal/importexpansion/ImportExpansionHandler.java
index 20c9ec3..97fad30 100644
--- a/kernel/org.eclipse.virgo.kernel.userregion/src/main/java/org/eclipse/virgo/kernel/userregion/internal/importexpansion/ImportExpansionHandler.java
+++ b/kernel/org.eclipse.virgo.kernel.userregion/src/main/java/org/eclipse/virgo/kernel/userregion/internal/importexpansion/ImportExpansionHandler.java
@@ -19,7 +19,6 @@
 import java.util.Map;
 import java.util.Set;
 
-import org.eclipse.osgi.framework.internal.core.BundleRepository;
 import org.osgi.framework.Bundle;
 import org.osgi.framework.BundleContext;
 import org.osgi.framework.Version;
@@ -224,7 +223,7 @@
 
     /**
      * Get a {@link TrackedPackageImports} instance representing the package imports that correspond to the given bundle
-     * import. The imported bundle is looked up in the given {@link BundleRepository} and, if it is not found,
+     * import. The imported bundle is looked up and, if it is not found,
      * {@link UnableToSatisfyBundleDependenciesException} is thrown. If the bundle import is to be promoted, then the
      * result is also merged into the given <code>TrackedPackageImports</code> instance representing the package imports
      * to be promoted.
@@ -351,7 +350,7 @@
 
     /**
      * Get a {@link TrackedPackageImports} instance representing the package imports that correspond to the given
-     * library imports. Each imported library is looked up in the given {@link BundleRepository} and, if it is not
+     * library imports. Each imported library is looked up and, if it is not
      * found, {@link UnableToSatisfyBundleDependenciesException} is thrown. If any package imports are to be promoted,
      * then the result is also merged into the given <code>TrackedPackageImports</code> instance representing the
      * package imports to be promoted.
diff --git a/kernel/org.eclipse.virgo.kernel.userregion/src/main/java/org/eclipse/virgo/kernel/userregion/internal/quasi/StandardQuasiBundle.java b/kernel/org.eclipse.virgo.kernel.userregion/src/main/java/org/eclipse/virgo/kernel/userregion/internal/quasi/StandardQuasiBundle.java
index 7dc435b..6565767 100644
--- a/kernel/org.eclipse.virgo.kernel.userregion/src/main/java/org/eclipse/virgo/kernel/userregion/internal/quasi/StandardQuasiBundle.java
+++ b/kernel/org.eclipse.virgo.kernel.userregion/src/main/java/org/eclipse/virgo/kernel/userregion/internal/quasi/StandardQuasiBundle.java
@@ -69,7 +69,7 @@
      * Constructs an unresolved, uncommitted {@link QuasiBundle} with the given {@link BundleDescription}.
      * 
      * @param bundleDescription the <code>BundleDescription</code> for this <code>QuasiBundle</code>
-     * @param bundleManifest
+     * @param bundleManifest the <code>BundleManifest</code> for this <code>QuasiBundle</code>
      * @param region the <code>Region</code> this bundle belongs to
      */
     public StandardQuasiBundle(BundleDescription bundleDescription, BundleManifest bundleManifest, Region region) {
@@ -213,12 +213,9 @@
 
     /**
      * Utility method to wrap a list of {@link BundleDescription} in QuasiBundle.
-     * 
-     * @param bundleDescriptions
-     * @return
      */
     private List<QuasiBundle> wrapBundleDescriptions(BundleDescription[] bundleDescriptions) {
-        List<QuasiBundle> quasiBundles = new ArrayList<QuasiBundle>();
+        List<QuasiBundle> quasiBundles = new ArrayList<>();
         for (BundleDescription bundleDescription : bundleDescriptions) {
 			Region bundleRegion = this.region.getRegionDigraph().getRegion(bundleDescription.getBundleId());
 			quasiBundles.add(new StandardQuasiBundle(bundleDescription, null, bundleRegion));
@@ -228,12 +225,9 @@
 
     /**
      * Utility method to wrap a list of {@link BundleDescription} in QuasiBundle.
-     * 
-     * @param bundleDescriptions
-     * @return
      */
     private List<QuasiRequiredBundle> wrapBundleSpecificationsAsRequiredBundles(BundleSpecification[] bundleDescriptions) {
-        List<QuasiRequiredBundle> quasiRequiredBundles = new ArrayList<QuasiRequiredBundle>();
+        List<QuasiRequiredBundle> quasiRequiredBundles = new ArrayList<>();
         for (BundleSpecification bundleSpecification : bundleDescriptions) {
             quasiRequiredBundles.add(new StandardQuasiRequiredBundle(bundleSpecification, this));
         }
@@ -242,13 +236,9 @@
 
     /**
      * Utility method to wrap a list of {@link BundleDescription} in {@link QuasiExportPackage}.
-     * 
-     * @param exportPackageDescriptions
-     * @param quasiBundle
-     * @return
      */
     private List<QuasiExportPackage> wrapExportPackageDescriptions(ExportPackageDescription[] exportPackageDescriptions) {
-        List<QuasiExportPackage> quasiExportPackages = new ArrayList<QuasiExportPackage>();
+        List<QuasiExportPackage> quasiExportPackages = new ArrayList<>();
         for (ExportPackageDescription exportPackageDescription : exportPackageDescriptions) {
             quasiExportPackages.add(new StandardQuasiExportPackage(exportPackageDescription, this));
         }
@@ -257,12 +247,9 @@
 
     /**
      * Utility method to wrap a list of {@link BundleDescription} in {@link QuasiImportPackage}.
-     * 
-     * @param bundleDescriptions
-     * @return
      */
     private List<QuasiImportPackage> wrapImportPackageSpecifications(ImportPackageSpecification[] importPackageSpecifications) {
-        List<QuasiImportPackage> quasiImportPackages = new ArrayList<QuasiImportPackage>();
+        List<QuasiImportPackage> quasiImportPackages = new ArrayList<>();
         for (ImportPackageSpecification importPackageSpecification : importPackageSpecifications) {
             quasiImportPackages.add(new StandardQuasiImportPackage(importPackageSpecification, this));
         }
diff --git a/kernel/org.eclipse.virgo.kernel.userregion/src/main/java/org/eclipse/virgo/kernel/userregion/internal/quasi/StandardQuasiFrameworkFactory.java b/kernel/org.eclipse.virgo.kernel.userregion/src/main/java/org/eclipse/virgo/kernel/userregion/internal/quasi/StandardQuasiFrameworkFactory.java
index 92ccc2d..58aa2ee 100644
--- a/kernel/org.eclipse.virgo.kernel.userregion/src/main/java/org/eclipse/virgo/kernel/userregion/internal/quasi/StandardQuasiFrameworkFactory.java
+++ b/kernel/org.eclipse.virgo.kernel.userregion/src/main/java/org/eclipse/virgo/kernel/userregion/internal/quasi/StandardQuasiFrameworkFactory.java
@@ -17,7 +17,6 @@
 import java.io.FileInputStream;
 import java.io.IOException;
 import java.io.InputStream;
-import java.util.zip.ZipException;
 
 import org.eclipse.equinox.region.RegionDigraph;
 import org.eclipse.equinox.region.RegionDigraphPersistence;
@@ -92,7 +91,7 @@
      * {@inheritDoc}
      */
     @Override
-    public QuasiFramework create(File dumpDirName) throws ZipException, IOException {
+    public QuasiFramework create(File dumpDirName) throws IOException {
         return create(this.dumpExtractor.getStateDump(dumpDirName), this.dumpExtractor.getRegionDigraphDump(dumpDirName));
     }
 
@@ -105,11 +104,8 @@
         RegionDigraphPersistence regionDigraphPersistence = this.regionDigraph.getRegionDigraphPersistence();
         RegionDigraph digraph;
         try {
-            InputStream input = new FileInputStream(regionDigraphDump);
-            try {
+            try (InputStream input = new FileInputStream(regionDigraphDump)) {
                 digraph = regionDigraphPersistence.load(input);
-            } finally {
-                input.close();
             }
         } catch (Exception e) {
             throw new RuntimeException("Unable to read region digraph dump", e);
@@ -142,7 +138,7 @@
     }
 
     private State readStateDump(File outdir) {
-        State state = null;
+        State state;
 
         try {
             StateObjectFactory sof = this.platformAdmin.getFactory();
diff --git a/kernel/org.eclipse.virgo.kernel.userregion/src/test/java/org/eclipse/virgo/kernel/userregion/internal/equinox/AbstractOsgiFrameworkLaunchingTests.java b/kernel/org.eclipse.virgo.kernel.userregion/src/test/java/org/eclipse/virgo/kernel/userregion/internal/equinox/AbstractOsgiFrameworkLaunchingTests.java
index d563988..f57d655 100644
--- a/kernel/org.eclipse.virgo.kernel.userregion/src/test/java/org/eclipse/virgo/kernel/userregion/internal/equinox/AbstractOsgiFrameworkLaunchingTests.java
+++ b/kernel/org.eclipse.virgo.kernel.userregion/src/test/java/org/eclipse/virgo/kernel/userregion/internal/equinox/AbstractOsgiFrameworkLaunchingTests.java
@@ -64,9 +64,9 @@
 
     protected EquinoxOsgiFramework framework;
 
-    protected PlatformAdmin platformAdmin;
+    PlatformAdmin platformAdmin;
 
-    protected Repository repository;
+    Repository repository;
 
     private RepositoryBundleActivator repositoryBundleActivator;
 
@@ -82,9 +82,7 @@
 
     private Equinox equinox;
 
-    protected QuasiFramework quasiFramework;
-
-    private ThreadLocal<Region> threadLocal;
+    QuasiFramework quasiFramework;
 
     @Before
     public void setUp() throws Exception {
@@ -120,8 +118,8 @@
 
         };
 
-        this.threadLocal = new ThreadLocal<Region>();
-        RegionDigraph regionDigraph = new StandardRegionDigraph(this.bundleContext, this.threadLocal);
+        ThreadLocal<Region> threadLocal = new ThreadLocal<>();
+        RegionDigraph regionDigraph = new StandardRegionDigraph(this.bundleContext, threadLocal);
 
         Region userRegion = regionDigraph.createRegion("org.eclipse.virgo.region.user");
         userRegion.addBundle(this.bundleContext.getBundle());
@@ -144,7 +142,7 @@
             repositoryProperties.load(properties);
         }
 
-        Set<ArtifactBridge> artifactBridges = new HashSet<ArtifactBridge>();
+        Set<ArtifactBridge> artifactBridges = new HashSet<>();
         artifactBridges.add(new BundleBridge(new StubHashGenerator()));
         artifactBridges.add(new LibraryBridge(new StubHashGenerator()));
 
@@ -155,10 +153,10 @@
         repositoryRegistration = bundleContext.registerService(Repository.class, repository, null);
 
         ServiceReference<PlatformAdmin> platformAdminServiceReference = bundleContext.getServiceReference(PlatformAdmin.class);
-        this.platformAdmin = (PlatformAdmin) bundleContext.getService(platformAdminServiceReference);
+        this.platformAdmin = bundleContext.getService(platformAdminServiceReference);
 
         ServiceReference<PackageAdmin> packageAdminServiceReference = bundleContext.getServiceReference(PackageAdmin.class);
-        PackageAdmin packageAdmin = (PackageAdmin) bundleContext.getService(packageAdminServiceReference);
+        PackageAdmin packageAdmin = bundleContext.getService(packageAdminServiceReference);
 
         ImportExpander importExpander = createImportExpander(packageAdmin);
         TransformedManifestProvidingBundleFileWrapper bundleFileWrapper = new TransformedManifestProvidingBundleFileWrapper(importExpander);
@@ -184,7 +182,7 @@
     }
 
     private ImportExpander createImportExpander(PackageAdmin packageAdmin) {
-        Set<String> packagesExportedBySystemBundle = new HashSet<String>(30);
+        Set<String> packagesExportedBySystemBundle = new HashSet<>(30);
         ExportedPackage[] exportedPackages = packageAdmin.getExportedPackages(bundleContext.getBundle(0));
 
         for (ExportedPackage exportedPackage : exportedPackages) {
diff --git a/kernel/org.eclipse.virgo.kernel.userregion/src/test/java/org/eclipse/virgo/kernel/userregion/internal/equinox/BundleInstallationTests.java b/kernel/org.eclipse.virgo.kernel.userregion/src/test/java/org/eclipse/virgo/kernel/userregion/internal/equinox/BundleInstallationTests.java
index 180fe88..706fae5 100644
--- a/kernel/org.eclipse.virgo.kernel.userregion/src/test/java/org/eclipse/virgo/kernel/userregion/internal/equinox/BundleInstallationTests.java
+++ b/kernel/org.eclipse.virgo.kernel.userregion/src/test/java/org/eclipse/virgo/kernel/userregion/internal/equinox/BundleInstallationTests.java
@@ -29,8 +29,6 @@
 import org.eclipse.virgo.util.osgi.manifest.VersionRange;
 import org.eclipse.virgo.util.osgi.manifest.BundleManifestFactory;
 
-/**
- */
 public class BundleInstallationTests extends AbstractOsgiFrameworkLaunchingTests {
 
     @Override
diff --git a/kernel/org.eclipse.virgo.kernel.userregion/src/test/java/org/eclipse/virgo/kernel/userregion/internal/equinox/EquinoxOsgiFrameworkTests.java b/kernel/org.eclipse.virgo.kernel.userregion/src/test/java/org/eclipse/virgo/kernel/userregion/internal/equinox/EquinoxOsgiFrameworkTests.java
index ec40191..5250416 100644
--- a/kernel/org.eclipse.virgo.kernel.userregion/src/test/java/org/eclipse/virgo/kernel/userregion/internal/equinox/EquinoxOsgiFrameworkTests.java
+++ b/kernel/org.eclipse.virgo.kernel.userregion/src/test/java/org/eclipse/virgo/kernel/userregion/internal/equinox/EquinoxOsgiFrameworkTests.java
@@ -17,7 +17,6 @@
 
 import java.io.File;
 import java.lang.instrument.ClassFileTransformer;
-import java.lang.instrument.IllegalClassFormatException;
 import java.security.ProtectionDomain;
 import java.util.concurrent.atomic.AtomicInteger;
 
@@ -26,11 +25,7 @@
 import org.osgi.framework.BundleException;
 import org.eclipse.virgo.kernel.osgi.framework.BundleClassLoaderUnavailableException;
 import org.eclipse.virgo.kernel.osgi.framework.InstrumentableClassLoader;
-import org.eclipse.virgo.kernel.userregion.internal.equinox.EquinoxOsgiFramework;
-import org.eclipse.virgo.kernel.userregion.internal.equinox.KernelBundleClassLoader;
 
-/**
- */
 public class EquinoxOsgiFrameworkTests extends AbstractOsgiFrameworkLaunchingTests {
 
     @Override
@@ -39,7 +34,7 @@
     }
 
     @Test
-    public void testStartAndStop() throws Exception {
+    public void testStartAndStop() {
         assertNotNull(this.framework.getBundleContext());
         assertEquals(Bundle.ACTIVE, this.framework.getBundleContext().getBundle().getState());
     }
@@ -80,7 +75,7 @@
         icl.addClassFileTransformer(new ClassFileTransformer() {
 
             public byte[] transform(ClassLoader loader, String className, Class<?> classBeingRedefined, ProtectionDomain protectionDomain,
-                byte[] classfileBuffer) throws IllegalClassFormatException {
+                byte[] classfileBuffer) {
                 count.incrementAndGet();
                 return null;
             }
@@ -90,11 +85,6 @@
         assertEquals(1, count.get());
     }
 
-    /**
-     * @param osgi
-     * @return
-     * @throws BundleException
-     */
     private Bundle installSpringCore(EquinoxOsgiFramework osgi) throws BundleException {
         osgi.getBundleContext().installBundle("file:///" + new File(System.getProperty("user.home")
             + "/.gradle/caches/modules-2/files-2.1/org.eclipse.virgo.mirrored/org.apache.commons.logging/1.2.0/"
diff --git a/kernel/org.eclipse.virgo.kernel.userregion/src/test/java/org/eclipse/virgo/kernel/userregion/internal/equinox/KernelBundleClassLoaderTests.java b/kernel/org.eclipse.virgo.kernel.userregion/src/test/java/org/eclipse/virgo/kernel/userregion/internal/equinox/KernelBundleClassLoaderTests.java
index c6fcffb..eb347b7 100644
--- a/kernel/org.eclipse.virgo.kernel.userregion/src/test/java/org/eclipse/virgo/kernel/userregion/internal/equinox/KernelBundleClassLoaderTests.java
+++ b/kernel/org.eclipse.virgo.kernel.userregion/src/test/java/org/eclipse/virgo/kernel/userregion/internal/equinox/KernelBundleClassLoaderTests.java
@@ -24,11 +24,6 @@
 import org.osgi.framework.Bundle;
 import org.osgi.framework.BundleException;
 
-import org.eclipse.virgo.kernel.osgi.framework.UnableToSatisfyDependenciesException;
-
-/**
- *
- */
 public class KernelBundleClassLoaderTests extends AbstractOsgiFrameworkLaunchingTests {
 
     private Bundle dependant;
@@ -40,8 +35,6 @@
 
 	/**
 	 * Test method for {@link org.eclipse.virgo.kernel.userregion.internal.equinox.KernelBundleClassLoader#getResources(java.lang.String)}.
-	 * @throws UnableToSatisfyDependenciesException 
-	 * @throws Exception 
 	 */
 	@Test
 	public void testGetResourcesStringFromBundle() throws Exception {
@@ -55,11 +48,9 @@
 
 	/**
 	 * Test method for {@link org.eclipse.virgo.kernel.userregion.internal.equinox.KernelBundleClassLoader#getResource(java.lang.String)}.
-	 * @throws UnableToSatisfyDependenciesException 
-	 * @throws Exception 
 	 */
 	@Test
-	public void testGetResourceStringFromBundle() throws Exception {
+	public void testGetResourceStringFromBundle() {
         URL resource = this.dependant.getResource("/META-INF/GET_ME");
 
         assertNotNull(resource);
@@ -68,8 +59,6 @@
 
 	/**
 	 * Test method for {@link org.eclipse.virgo.kernel.userregion.internal.equinox.KernelBundleClassLoader#getResources(java.lang.String)}.
-	 * @throws UnableToSatisfyDependenciesException 
-	 * @throws Exception 
 	 */
 	@Test
 	public void testGetResourcesStringFromBundleClassLoader() throws Exception {
@@ -85,11 +74,9 @@
 
 	/**
 	 * Test method for {@link org.eclipse.virgo.kernel.userregion.internal.equinox.KernelBundleClassLoader#getResource(java.lang.String)}.
-	 * @throws UnableToSatisfyDependenciesException 
-	 * @throws Exception 
 	 */
 	@Test
-	public void testGetResourceStringFromBundleClassLoader() throws Exception {
+	public void testGetResourceStringFromBundleClassLoader() {
         ClassLoader loader = this.framework.getBundleClassLoader(this.dependant);
         URL resource = loader.getResource("/META-INF/GET_ME");
 
diff --git a/kernel/org.eclipse.virgo.kernel.userregion/src/test/java/org/eclipse/virgo/kernel/userregion/internal/equinox/UsesAnalyserTests.java b/kernel/org.eclipse.virgo.kernel.userregion/src/test/java/org/eclipse/virgo/kernel/userregion/internal/equinox/UsesAnalyserTests.java
index 047ae0e..fd6955c 100644
--- a/kernel/org.eclipse.virgo.kernel.userregion/src/test/java/org/eclipse/virgo/kernel/userregion/internal/equinox/UsesAnalyserTests.java
+++ b/kernel/org.eclipse.virgo.kernel.userregion/src/test/java/org/eclipse/virgo/kernel/userregion/internal/equinox/UsesAnalyserTests.java
@@ -19,7 +19,6 @@
 import org.eclipse.osgi.internal.baseadaptor.StateManager;
 import org.eclipse.osgi.service.resolver.ResolverError;
 import org.eclipse.osgi.service.resolver.State;
-import org.eclipse.virgo.kernel.userregion.internal.equinox.UsesAnalyser;
 import org.eclipse.virgo.kernel.userregion.internal.equinox.UsesAnalyser.AnalysedUsesConflict;
 import org.junit.Test;
 import org.osgi.framework.Bundle;
@@ -48,7 +47,7 @@
 
         try {
             p.start();
-        } catch (BundleException ex) {
+        } catch (BundleException ignored) {
         }
 
         State systemState = ((StateManager) this.platformAdmin).getSystemState();
@@ -85,7 +84,7 @@
         install("install/bundles/r2");
         try {
             p.start();
-        } catch (BundleException ex) {
+        } catch (BundleException ignored) {
         }
 
         State systemState = ((StateManager) this.platformAdmin).getSystemState();
@@ -144,7 +143,7 @@
         assertEquals(new Version("0.0.0"), usesConflicts[0].getConflictingPackage().getVersion());
     }
 
-    private static final void printUsesConflicts(AnalysedUsesConflict[] usesConflicts) {
+    private static void printUsesConflicts(AnalysedUsesConflict[] usesConflicts) {
         int count = 0;
         for (AnalysedUsesConflict a : usesConflicts) {
             System.out.println("AnalysedUsesConflict element " + (count++));
diff --git a/kernel/org.eclipse.virgo.kernel.userregion/src/test/java/org/eclipse/virgo/kernel/userregion/internal/importexpansion/ImportExpansionHandlerTests.java b/kernel/org.eclipse.virgo.kernel.userregion/src/test/java/org/eclipse/virgo/kernel/userregion/internal/importexpansion/ImportExpansionHandlerTests.java
index d441220..b76d4f6 100644
--- a/kernel/org.eclipse.virgo.kernel.userregion/src/test/java/org/eclipse/virgo/kernel/userregion/internal/importexpansion/ImportExpansionHandlerTests.java
+++ b/kernel/org.eclipse.virgo.kernel.userregion/src/test/java/org/eclipse/virgo/kernel/userregion/internal/importexpansion/ImportExpansionHandlerTests.java
@@ -56,8 +56,6 @@
 import org.junit.Test;
 import org.osgi.framework.Version;
 
-/**
- */
 public class ImportExpansionHandlerTests {
 
     private StubRepository repository = new StubRepository();
diff --git a/kernel/org.eclipse.virgo.kernel.userregionfactory/src/main/java/org/eclipse/virgo/kernel/userregionfactory/PackageImportWildcardExpander.java b/kernel/org.eclipse.virgo.kernel.userregionfactory/src/main/java/org/eclipse/virgo/kernel/userregionfactory/PackageImportWildcardExpander.java
index 2a6ff4b..f2ed61a 100644
--- a/kernel/org.eclipse.virgo.kernel.userregionfactory/src/main/java/org/eclipse/virgo/kernel/userregionfactory/PackageImportWildcardExpander.java
+++ b/kernel/org.eclipse.virgo.kernel.userregionfactory/src/main/java/org/eclipse/virgo/kernel/userregionfactory/PackageImportWildcardExpander.java
@@ -40,7 +40,6 @@
  * Thread safe.
  * 
  */
-@SuppressWarnings("deprecation")
 final class PackageImportWildcardExpander {
 
     private static final String wildcard = "*";
@@ -52,11 +51,11 @@
     }
 
     private static String[] getExportedPackageNames(BundleContext bundleContext) {
-        Set<String> exportedPackageNames = new HashSet<String>();
+        Set<String> exportedPackageNames = new HashSet<>();
         for (ExportedPackage exportedPackage : getExportedPackages(bundleContext)) {
             exportedPackageNames.add(exportedPackage.getName());
         }
-        return exportedPackageNames.toArray(new String[exportedPackageNames.size()]);
+        return exportedPackageNames.toArray(new String[0]);
     }
 
     private static ExportedPackage[] getExportedPackages(BundleContext bundleContext) {
@@ -71,13 +70,13 @@
         return exportedPackages;
     }
 
-    private static String expandWildcards(String userRegionImportsProperty, String[] exportedPackageNamess, EventLogger eventLogger) {
+    private static String expandWildcards(String userRegionImportsProperty, String[] exportedPackageNames, EventLogger eventLogger) {
         DynamicImportPackage dynamicImportPackage = representImportsAsDynamicImports(userRegionImportsProperty, eventLogger);
-        return expandWildcards(dynamicImportPackage, exportedPackageNamess, eventLogger);
+        return expandWildcards(dynamicImportPackage, exportedPackageNames, eventLogger);
     }
 
     private static DynamicImportPackage representImportsAsDynamicImports(String userRegionImportsProperty, EventLogger eventLogger) {
-        Dictionary<String, String> headers = new Hashtable<String, String>();
+        Dictionary<String, String> headers = new Hashtable<>();
         headers.put("DynamicImport-Package", userRegionImportsProperty);
 
         BundleManifest manifest = BundleManifestFactory.createBundleManifest(headers, new UserRegionFactoryParserLogger(eventLogger));
@@ -85,7 +84,7 @@
     }
 
     private static String expandWildcards(DynamicImportPackage dynamicImportPackage, String[] exportedPackageNames, EventLogger eventLogger) {
-        StringBuffer expandedPackages = new StringBuffer();
+        StringBuilder expandedPackages = new StringBuilder();
         boolean first = true;
         List<DynamicallyImportedPackage> dynamicallyImportedPackages = dynamicImportPackage.getDynamicallyImportedPackages();
         for (DynamicallyImportedPackage dynamicallyImportedPackage : dynamicallyImportedPackages) {
@@ -115,7 +114,7 @@
     }
 
     private static List<String> expandWildcard(String wildcardedPackageName, String[] exportedPackageNames, EventLogger eventLogger) {
-        List<String> expansions = new ArrayList<String>();
+        List<String> expansions = new ArrayList<>();
 
         String prefix = wildcardedPackageName.substring(0, wildcardedPackageName.length() - 1);
         for (String exportedPackage : exportedPackageNames) {
diff --git a/kernel/org.eclipse.virgo.kernel.userregionfactory/src/test/java/org/eclipse/virgo/kernel/userregionfactory/PackageImportWildcardExpanderTests.java b/kernel/org.eclipse.virgo.kernel.userregionfactory/src/test/java/org/eclipse/virgo/kernel/userregionfactory/PackageImportWildcardExpanderTests.java
index 732f2c2..b7f58c9 100644
--- a/kernel/org.eclipse.virgo.kernel.userregionfactory/src/test/java/org/eclipse/virgo/kernel/userregionfactory/PackageImportWildcardExpanderTests.java
+++ b/kernel/org.eclipse.virgo.kernel.userregionfactory/src/test/java/org/eclipse/virgo/kernel/userregionfactory/PackageImportWildcardExpanderTests.java
@@ -25,9 +25,6 @@
 import org.eclipse.virgo.medic.eventlog.EventLogger;
 import org.eclipse.virgo.test.stubs.framework.StubBundleContext;
 
-/**
- */
-@SuppressWarnings("deprecation")
 public class PackageImportWildcardExpanderTests {
 
     private StubBundleContext stubBundleContext;
@@ -39,7 +36,7 @@
     private ExportedPackage[] exportedPackages;
 
     @Before
-    public void setUp() throws Exception {
+    public void setUp() {
         this.stubBundleContext = new StubBundleContext();
 
         this.mockEventLogger = createMock(EventLogger.class);
diff --git a/kernel/org.eclipse.virgo.shell.command/src/main/java/org/eclipse/virgo/shell/osgicommand/helper/ClassLoadingHelper.java b/kernel/org.eclipse.virgo.shell.command/src/main/java/org/eclipse/virgo/shell/osgicommand/helper/ClassLoadingHelper.java
index d18af58..07fc82c 100755
--- a/kernel/org.eclipse.virgo.shell.command/src/main/java/org/eclipse/virgo/shell/osgicommand/helper/ClassLoadingHelper.java
+++ b/kernel/org.eclipse.virgo.shell.command/src/main/java/org/eclipse/virgo/shell/osgicommand/helper/ClassLoadingHelper.java
@@ -25,7 +25,6 @@
 /**

  * Helper for class loading supporting commands

  */

-@SuppressWarnings("deprecation")

 public class ClassLoadingHelper {

 

     /**

@@ -60,7 +59,7 @@
      */

     public static Map<Bundle, Bundle> getBundlesLoadingClass(BundleContext bundleContext, String className) {

         Bundle[] bundles = bundleContext.getBundles();

-        HashMap<Bundle, Bundle> foundBundles = new HashMap<Bundle, Bundle>();

+        HashMap<Bundle, Bundle> foundBundles = new HashMap<>();

         for (Bundle bundle : bundles) {

             Bundle originBundle = getOriginBundleOfClass(className, bundleContext, bundle);

             if (originBundle != null) {

@@ -79,7 +78,7 @@
      * @param loadingBundle Bundle instance to load class from

      * @return originating {@link Bundle} or null if it cannot be loaded by <code>testBundle</code>

      */

-    public static Bundle getOriginBundleOfClass(String className, BundleContext bundleContext, Bundle loadingBundle) {

+    private static Bundle getOriginBundleOfClass(String className, BundleContext bundleContext, Bundle loadingBundle) {

         Class<?> clasz = tryToLoadClass(className, loadingBundle);

         Bundle originBundle = null;

         if (clasz != null) {

@@ -117,7 +116,7 @@
      * @param resourcePath Path to the resource

      * @return Class name

      */

-    public static String convertToClassName(String resourcePath) {

+    static String convertToClassName(String resourcePath) {

         if (resourcePath == null)

             return null;

 

@@ -163,7 +162,7 @@
      * @throws IllegalArgumentException if there is no bundle with such name/id

      */

     public static Map<Bundle, Bundle> getBundlesLoadingClass(BundleContext bundleContext, String className, String bundle) throws IllegalArgumentException {

-        HashMap<Bundle, Bundle> result = new HashMap<Bundle, Bundle>();

+        HashMap<Bundle, Bundle> result = new HashMap<>();

         long id = Long.MIN_VALUE;

         try {

             id = Long.parseLong(bundle);

@@ -206,12 +205,12 @@
      * @return Map between the bundle (key) and the URL(s) of the resources (value)

      */

     public static Map<Bundle, List<String>> getBundlesContainingResource(BundleContext bundleContext, String resourcePattern) {

-        Map<Bundle, List<String>> result = new HashMap<Bundle, List<String>>();

+        Map<Bundle, List<String>> result = new HashMap<>();

 

         Bundle[] bundles = bundleContext.getBundles();

         for (Bundle bundle : bundles) {

             List<String> entries = findEntries(bundle, resourcePattern);

-            if (entries != null && entries.size() != 0) {

+            if (entries.size() != 0) {

                 result.put(bundle, entries);

             }

         }

@@ -227,7 +226,7 @@
      * @return List with found entries

      */

     private static List<String> findEntries(Bundle bundle, String resourcePattern) {

-        HashSet<String> urls = new HashSet<String>();

+        HashSet<String> urls = new HashSet<>();

 

         int index = resourcePattern.lastIndexOf("/");

         if (index != -1) {

@@ -243,7 +242,7 @@
 

         // Search the root of the bundle for entity matching the specified pattern

         addURLs(urls, bundle.findEntries("/", resourcePattern, true), null);

-        return new ArrayList<String>(urls);

+        return new ArrayList<>(urls);

     }

 

     /**

diff --git a/kernel/org.eclipse.virgo.shell.command/src/test/java/org/eclipse/virgo/shell/osgicommand/helper/ClassLoadingHelperTests.java b/kernel/org.eclipse.virgo.shell.command/src/test/java/org/eclipse/virgo/shell/osgicommand/helper/ClassLoadingHelperTests.java
index f12c318..b95efc9 100755
--- a/kernel/org.eclipse.virgo.shell.command/src/test/java/org/eclipse/virgo/shell/osgicommand/helper/ClassLoadingHelperTests.java
+++ b/kernel/org.eclipse.virgo.shell.command/src/test/java/org/eclipse/virgo/shell/osgicommand/helper/ClassLoadingHelperTests.java
@@ -24,10 +24,6 @@
 import static org.easymock.EasyMock.*;

 import static org.junit.Assert.*;

 

-/**

- * Class for unit testing {@link ClassLoadingHelper}

- */

-@SuppressWarnings("deprecation")

 public class ClassLoadingHelperTests {

 

     private static final long BUNDLE_ID = 1234;

@@ -42,7 +38,7 @@
 

     @SuppressWarnings({ "unchecked" })

     @Test

-    public void testIsMissingPackageExported() throws Exception {

+    public void testIsMissingPackageExported() {

         PlatformAdmin platformAdmin = createMock(PlatformAdmin.class);

         ServiceReference<PlatformAdmin> platformAdminServiceReference = createMock(ServiceReference.class);

         Bundle bundle = createMock(Bundle.class);

@@ -67,7 +63,7 @@
 

     @SuppressWarnings({ "unchecked" })

     @Test

-    public void testIsExistingPackageExported() throws Exception {

+    public void testIsExistingPackageExported() {

         PlatformAdmin platformAdmin = createMock(PlatformAdmin.class);

         ServiceReference<PlatformAdmin> platformAdminServiceReference = createMock(ServiceReference.class);

         Bundle bundle = createMock(Bundle.class);

@@ -106,7 +102,7 @@
     }

 

     @Test

-    public void testTryToLoadMissingBundle() throws Exception {

+    public void testTryToLoadMissingBundle() {

         assertNull("Class [" + CLASS_NAME + "] found, while no bundle is specified", ClassLoadingHelper.tryToLoadClass(CLASS_NAME, null));

     }

 

@@ -147,8 +143,8 @@
 

         replay(bundle, bundleContext);

 

-        assertTrue("The bundle [" + BUNDLE_SYMBOLIC_NAME + "] should NOT be able to load class [" + CLASS_NAME + "]",

-            ClassLoadingHelper.getBundlesLoadingClass(bundleContext, CLASS_NAME).size() == 0);

+        assertEquals("The bundle [" + BUNDLE_SYMBOLIC_NAME + "] should NOT be able to load class [" + CLASS_NAME + "]",

+                0, ClassLoadingHelper.getBundlesLoadingClass(bundleContext, CLASS_NAME).size());

 

         verify(bundle, bundleContext);

     }

@@ -186,8 +182,8 @@
 

         replay(bundle, bundleContext, packageAdmin, packageAdminServiceReference);

 

-        assertTrue("No bundle should be able to load class [" + CLASS_NAME + "]",

-            ClassLoadingHelper.getBundlesLoadingClass(bundleContext, CLASS_NAME, BUNDLE_SYMBOLIC_NAME).size() == 0);

+        assertEquals("No bundle should be able to load class [" + CLASS_NAME + "]",

+                0, ClassLoadingHelper.getBundlesLoadingClass(bundleContext, CLASS_NAME, BUNDLE_SYMBOLIC_NAME).size());

 

         verify(bundle, bundleContext, packageAdmin, packageAdminServiceReference);

     }

@@ -233,14 +229,14 @@
     }

 

     @Test

-    public void testConvertToClassName() throws Exception {

+    public void testConvertToClassName() {

         assertEquals("Path to resource [" + CLASS_NAME_PATH + "] not converted properly", CLASS_NAME,

             ClassLoadingHelper.convertToClassName(CLASS_NAME_PATH));

         assertEquals("Path to resource [" + CLASS_NAME + "] not converted properly", CLASS_NAME, ClassLoadingHelper.convertToClassName(CLASS_NAME));

     }

 

     @Test

-    public void testConvertToResourcePath() throws Exception {

+    public void testConvertToResourcePath() {

         assertEquals("Class name [" + CLASS_NAME + "] not converted properly", CLASS_NAME_PATH, ClassLoadingHelper.convertToResourcePath(CLASS_NAME));

         assertEquals("Class name [" + CLASS_NAME_PATH + "] not converted properly", CLASS_NAME_PATH,

             ClassLoadingHelper.convertToResourcePath(CLASS_NAME_PATH));

diff --git a/nano/org.eclipse.virgo.nano.deployer/src/main/java/org/eclipse/virgo/nano/deployer/internal/StandardApplicationDeployer.java b/nano/org.eclipse.virgo.nano.deployer/src/main/java/org/eclipse/virgo/nano/deployer/internal/StandardApplicationDeployer.java
index b7334e3..51d233a 100644
--- a/nano/org.eclipse.virgo.nano.deployer/src/main/java/org/eclipse/virgo/nano/deployer/internal/StandardApplicationDeployer.java
+++ b/nano/org.eclipse.virgo.nano.deployer/src/main/java/org/eclipse/virgo/nano/deployer/internal/StandardApplicationDeployer.java
@@ -26,7 +26,6 @@
 import org.eclipse.virgo.nano.deployer.SimpleDeployer;
 import org.eclipse.virgo.nano.deployer.api.core.ApplicationDeployer;
 import org.eclipse.virgo.nano.deployer.api.core.DeployerConfiguration;
-import org.eclipse.virgo.nano.deployer.api.core.DeploymentException;
 import org.eclipse.virgo.nano.deployer.api.core.DeploymentIdentity;
 import org.eclipse.virgo.nano.deployer.api.core.DeploymentOptions;
 import org.eclipse.virgo.nano.deployer.support.HotDeployerEnabler;
@@ -48,7 +47,7 @@
 
     private PackageAdmin packageAdmin;
 
-    private final List<SimpleDeployer> simpleDeployers = new ArrayList<SimpleDeployer>();
+    private final List<SimpleDeployer> simpleDeployers = new ArrayList<>();
 
     private final Logger logger = LoggerFactory.getLogger(this.getClass());
 
@@ -62,7 +61,7 @@
 
     private EventAdmin eventAdmin;
 
-    public void activate(ComponentContext context) throws Exception {
+    public void activate(ComponentContext context) {
         this.bundleContext = context.getBundleContext();
         this.defaultDeployer = new BundleDeployer(context.getBundleContext(), this.packageAdmin, this.eventLogger);
         this.simpleDeployers.add(this.defaultDeployer);
@@ -74,7 +73,7 @@
         // Deployer deployerMBean = new StandardDeployer(appDeployer);
     }
 
-    public void deactivate(ComponentContext context) throws Exception {
+    public void deactivate(ComponentContext context) {
         if (this.hotDeployerEnabler != null) {
             this.hotDeployerEnabler.stopHotDeployer();
         }
@@ -90,7 +89,7 @@
     }
 
     @Override
-    public DeploymentIdentity deploy(URI uri) throws DeploymentException {
+    public DeploymentIdentity deploy(URI uri) {
         boolean isThereSuitableDeployer = false;
         for (SimpleDeployer deployer : this.simpleDeployers) {
             if (deployer.canServeFileType(getFileTypeFromUri(uri))) {
@@ -113,7 +112,7 @@
     }
 
     @Override
-    public DeploymentIdentity[] bulkDeploy(List<URI> uris, DeploymentOptions options) throws DeploymentException {
+    public DeploymentIdentity[] bulkDeploy(List<URI> uris, DeploymentOptions options) {
         if (uris != null && !uris.isEmpty()) {
             installDeployables(uris);
             startDeployables(uris);
@@ -125,7 +124,7 @@
     }
 
     private DeploymentIdentity[] getDeploymentIdentities(List<URI> uris) {
-        List<DeploymentIdentity> accumulatedDIs = new ArrayList<DeploymentIdentity>();
+        List<DeploymentIdentity> accumulatedDIs = new ArrayList<>();
         for (URI uri : uris) {
             DeploymentIdentity di = getDeploymentIdentity(uri);
             if (di != null) {
@@ -136,11 +135,11 @@
     }
 
     @Override
-    public void undeploy(DeploymentIdentity deploymentIdentity) throws DeploymentException {
+    public void undeploy(DeploymentIdentity deploymentIdentity) {
         if (this.bundleContext != null) {
             String symbolicName = deploymentIdentity.getSymbolicName();
             String version = deploymentIdentity.getVersion();
-            List<Bundle> existingBundles = new ArrayList<Bundle>();
+            List<Bundle> existingBundles = new ArrayList<>();
 
             for (Bundle bundle : this.bundleContext.getBundles()) {
                 if (bundle.getSymbolicName().equals(symbolicName) && bundle.getVersion().toString().equals(version)) {
@@ -149,7 +148,7 @@
             }
             if (existingBundles.size() > 1) {
                 this.logger.warn("Multiple bundles matching the marked for uninstall symbolicName-version pair. List of all matches: "
-                    + Arrays.toString(existingBundles.toArray(new Bundle[existingBundles.size()])));
+                    + Arrays.toString(existingBundles.toArray(new Bundle[0])));
                 this.logger.warn("Uninstalling the last-installed matching bundle " + existingBundles.get(existingBundles.size() - 1).toString());
             }
             boolean isThereSuitableDeployer = false;
@@ -191,52 +190,52 @@
     }
 
     @Override
-    public DeploymentIdentity deploy(URI uri, DeploymentOptions options) throws DeploymentException {
+    public DeploymentIdentity deploy(URI uri, DeploymentOptions options) {
         return this.deploy(uri);
     }
 
     @Override
-    public DeploymentIdentity deploy(String type, String name, Version version) throws DeploymentException {
+    public DeploymentIdentity deploy(String type, String name, Version version) {
         throw new UnsupportedOperationException("Not supported in Virgo Nano.");
     }
 
     @Override
-    public DeploymentIdentity deploy(String type, String name, Version version, DeploymentOptions options) throws DeploymentException {
+    public DeploymentIdentity deploy(String type, String name, Version version, DeploymentOptions options) {
         throw new UnsupportedOperationException("Not supported in Virgo Nano.");
     }
 
     @Override
-    public void undeploy(String applicationSymbolicName, String version) throws DeploymentException {
+    public void undeploy(String applicationSymbolicName, String version) {
         throw new UnsupportedOperationException("Not supported in Virgo Nano.");
     }
 
     @Override
-    public DeploymentIdentity install(URI uri, DeploymentOptions options) throws DeploymentException {
+    public DeploymentIdentity install(URI uri, DeploymentOptions options) {
         throw new UnsupportedOperationException("Not supported in Virgo Nano.");
     }
 
     @Override
-    public DeploymentIdentity install(URI uri) throws DeploymentException {
+    public DeploymentIdentity install(URI uri) {
         throw new UnsupportedOperationException("Not supported in Virgo Nano.");
     }
 
     @Override
-    public void undeploy(String type, String name, String version) throws DeploymentException {
+    public void undeploy(String type, String name, String version) {
         throw new UnsupportedOperationException("Not supported in Virgo Nano.");
     }
 
     @Override
-    public void undeploy(DeploymentIdentity deploymentIdentity, boolean deleted) throws DeploymentException {
+    public void undeploy(DeploymentIdentity deploymentIdentity, boolean deleted) {
         throw new UnsupportedOperationException("Not supported in Virgo Nano.");
     }
 
     @Override
-    public DeploymentIdentity refresh(URI uri, String symbolicName) throws DeploymentException {
+    public DeploymentIdentity refresh(URI uri, String symbolicName) {
         throw new UnsupportedOperationException("Not supported in Virgo Nano.");
     }
 
     @Override
-    public void refreshBundle(String bundleSymbolicName, String bundleVersion) throws DeploymentException {
+    public void refreshBundle(String bundleSymbolicName, String bundleVersion) {
         throw new UnsupportedOperationException("Not supported in Virgo Nano.");
     }
 
@@ -286,7 +285,7 @@
     }
 
     private void handleUnsupportedFileType(URI uri) {
-        List<String> acceptedTypes = new ArrayList<String>();
+        List<String> acceptedTypes = new ArrayList<>();
         for (SimpleDeployer deployer : this.simpleDeployers) {
             acceptedTypes.addAll(deployer.getAcceptedFileTypes());
         }
diff --git a/test/org.eclipse.virgo.test.stubs/src/main/java/org/eclipse/virgo/test/stubs/framework/StubBundleContext.java b/test/org.eclipse.virgo.test.stubs/src/main/java/org/eclipse/virgo/test/stubs/framework/StubBundleContext.java
index 237e0c9..ccfba55 100644
--- a/test/org.eclipse.virgo.test.stubs/src/main/java/org/eclipse/virgo/test/stubs/framework/StubBundleContext.java
+++ b/test/org.eclipse.virgo.test.stubs/src/main/java/org/eclipse/virgo/test/stubs/framework/StubBundleContext.java
@@ -16,17 +16,10 @@
 
 import java.io.File;
 import java.io.InputStream;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.Dictionary;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
+import java.util.*;
 
 import org.osgi.framework.Bundle;
 import org.osgi.framework.BundleContext;
-import org.osgi.framework.BundleException;
 import org.osgi.framework.BundleListener;
 import org.osgi.framework.Constants;
 import org.osgi.framework.Filter;
@@ -55,39 +48,39 @@
 
     private final Object bundleMonitor = new Object();
 
-    private final List<BundleListener> bundleListeners = new ArrayList<BundleListener>();
+    private final List<BundleListener> bundleListeners = new ArrayList<>();
 
     private final Object bundleListenersMonitor = new Object();
 
-    private final List<FrameworkListener> frameworkListeners = new ArrayList<FrameworkListener>();
+    private final List<FrameworkListener> frameworkListeners = new ArrayList<>();
 
     private final Object frameworkListenersMonitor = new Object();
 
-    private final List<ServiceListener> serviceListeners = new ArrayList<ServiceListener>();
+    private final List<ServiceListener> serviceListeners = new ArrayList<>();
 
     private final Object serviceListenersMonitor = new Object();
 
-    private volatile long installedBundleId = Long.valueOf(2);
+    private volatile long installedBundleId = 2L;
 
-    private final Map<Long, StubBundle> installedBundles = new HashMap<Long, StubBundle>();
+    private final Map<Long, StubBundle> installedBundles = new HashMap<>();
 
     private final Object installedBundlesMonitor = new Object();
 
-    private final List<StubServiceRegistration<Object>> serviceRegistrations = new ArrayList<StubServiceRegistration<Object>>();
+    private final List<StubServiceRegistration<Object>> serviceRegistrations = new ArrayList<>();
 
-    private final Map<StubServiceReference<Object>, Object> services = new HashMap<StubServiceReference<Object>, Object>();
+    private final Map<StubServiceReference<Object>, Object> services = new HashMap<>();
 
     private final Object servicesMonitor = new Object();
 
-    private final Map<String, File> dataFiles = new HashMap<String, File>();
+    private final Map<String, File> dataFiles = new HashMap<>();
 
     private final Object dataFilesMonitor = new Object();
 
-    private final Map<String, String> properties = new HashMap<String, String>();
+    private final Map<String, String> properties = new HashMap<>();
 
     private final Object propertiesMonitor = new Object();
 
-    private final Map<String, Filter> filters = new HashMap<String, Filter>();
+    private final Map<String, Filter> filters = new HashMap<>();
 
     private final Object filtersMonitor = new Object();
 
@@ -130,17 +123,13 @@
      * {@inheritDoc}
      */
     public void addServiceListener(ServiceListener listener) {
-        try {
-            addServiceListener(listener, null);
-        } catch (InvalidSyntaxException e) {
-            // In theory this exception can never be thrown
-        }
+        addServiceListener(listener, null);
     }
 
     /**
      * {@inheritDoc}
      */
-    public void addServiceListener(ServiceListener listener, String filter) throws InvalidSyntaxException {
+    public void addServiceListener(ServiceListener listener, String filter) {
         synchronized (this.serviceListenersMonitor) {
             this.serviceListeners.add(listener);
         }
@@ -219,7 +208,7 @@
      */
     public Bundle[] getBundles() {
         synchronized (this.installedBundlesMonitor) {
-            return this.installedBundles.values().toArray(new Bundle[this.installedBundles.values().size()]);
+            return this.installedBundles.values().toArray(new Bundle[0]);
         }
     }
 
@@ -325,7 +314,7 @@
      */
     public ServiceReference<?>[] getServiceReferences(String clazz, String filter) throws InvalidSyntaxException {
         synchronized (this.servicesMonitor) {
-            List<ServiceReference<?>> candidateReferences = new ArrayList<ServiceReference<?>>();
+            List<ServiceReference<?>> candidateReferences = new ArrayList<>();
 
             Filter f = getFilter(filter);
             for (ServiceReference<?> serviceReference : this.services.keySet()) {
@@ -338,7 +327,7 @@
             if (candidateReferences.isEmpty()) {
                 return null;
             } else {
-                return candidateReferences.toArray(new ServiceReference[candidateReferences.size()]);
+                return candidateReferences.toArray(new ServiceReference[0]);
             }
         }
     }
@@ -368,7 +357,7 @@
     /**
      * {@inheritDoc}
      */
-    public Bundle installBundle(String location) throws BundleException {
+    public Bundle installBundle(String location) {
         StubBundle bundle = new StubBundle(this.installedBundleId++, location, Version.emptyVersion, location);
         bundle.setState(Bundle.INSTALLED);
         return bundle;
@@ -377,7 +366,7 @@
     /**
      * {@inheritDoc}
      */
-    public Bundle installBundle(String location, InputStream input) throws BundleException {
+    public Bundle installBundle(String location, InputStream input) {
         return installBundle(location);
     }
 
@@ -397,13 +386,13 @@
     }
 
     private StubServiceRegistration<Object> createServiceRegistration(String[] clazzes, Dictionary<String, ?> properties) {
-        StubServiceRegistration<Object> serviceRegistration = new StubServiceRegistration<Object>(this, clazzes);
+        StubServiceRegistration<Object> serviceRegistration = new StubServiceRegistration<>(this, clazzes);
         serviceRegistration.setProperties(properties);
         return serviceRegistration;
     }
 
     private <S> StubServiceReference<S> createServiceReference(String[] clazzes, Object service, StubServiceRegistration<S> serviceRegistration) {
-        StubServiceReference<S> serviceReference = new StubServiceReference<S>(serviceRegistration);
+        StubServiceReference<S> serviceReference = new StubServiceReference<>(serviceRegistration);
         serviceRegistration.setServiceReference(serviceReference);
         return serviceReference;
     }
@@ -544,12 +533,10 @@
      */
     @SuppressWarnings("unchecked")
     public <S> Collection<ServiceReference<S>> getServiceReferences(Class<S> clazz, String filter) throws InvalidSyntaxException {
-        Collection<ServiceReference<S>> references = new ArrayList<ServiceReference<S>>();
+        Collection<ServiceReference<S>> references = new ArrayList<>();
         ServiceReference<S>[] matchingReferences = (ServiceReference<S>[]) getServiceReferences(clazz.getName(), filter);
         if (matchingReferences != null) {
-            for (ServiceReference<S> reference : matchingReferences) {
-                references.add(reference);
-            }
+            Collections.addAll(references, matchingReferences);
         }
         return references;
     }
diff --git a/test/org.eclipse.virgo.test.stubs/src/test/java/org/eclipse/virgo/test/stubs/framework/StubBundleContextTests.java b/test/org.eclipse.virgo.test.stubs/src/test/java/org/eclipse/virgo/test/stubs/framework/StubBundleContextTests.java
index c00bef5..b1ea728 100644
--- a/test/org.eclipse.virgo.test.stubs/src/test/java/org/eclipse/virgo/test/stubs/framework/StubBundleContextTests.java
+++ b/test/org.eclipse.virgo.test.stubs/src/test/java/org/eclipse/virgo/test/stubs/framework/StubBundleContextTests.java
@@ -19,7 +19,6 @@
 import static org.junit.Assert.assertTrue;
 
 import java.io.File;
-import java.io.IOException;
 import java.io.InputStream;
 import java.util.ArrayList;
 import java.util.Dictionary;
@@ -30,7 +29,6 @@
 import org.junit.Test;
 import org.osgi.framework.Bundle;
 import org.osgi.framework.BundleEvent;
-import org.osgi.framework.BundleException;
 import org.osgi.framework.BundleListener;
 import org.osgi.framework.FrameworkEvent;
 import org.osgi.framework.FrameworkListener;
@@ -121,7 +119,7 @@
     }
 
     @Test
-    public void installBundle() throws BundleException {
+    public void installBundle() {
         TestBundleListener listener = new TestBundleListener();
         this.bundleContext.addBundleListener(listener);
         Bundle bundle = this.bundleContext.installBundle("/");
@@ -136,7 +134,7 @@
     }
 
     @Test
-    public void installBundleInputStream() throws BundleException {
+    public void installBundleInputStream() {
         TestBundleListener listener = new TestBundleListener();
         this.bundleContext.addBundleListener(listener);
         Bundle bundle = this.bundleContext.installBundle("/", new TestInputStream());
@@ -194,7 +192,7 @@
 
     @Test
     public void registerServiceArray() {
-        Dictionary<String, String> properties = new Hashtable<String, String>();
+        Dictionary<String, String> properties = new Hashtable<>();
         properties.put("testKey", "testValue");
         ServiceRegistration<?> serviceRegistration = this.bundleContext.registerService(
             new String[] { Object.class.getName(), Exception.class.getName() }, new Object(), properties);
@@ -236,8 +234,8 @@
 
     @Test
     public void ungetService() {
-        StubServiceRegistration<Object> serviceRegistration = new StubServiceRegistration<Object>(this.bundleContext);
-        StubServiceReference<Object> serviceReference = new StubServiceReference<Object>(serviceRegistration);
+        StubServiceRegistration<Object> serviceRegistration = new StubServiceRegistration<>(this.bundleContext);
+        StubServiceReference<Object> serviceReference = new StubServiceReference<>(serviceRegistration);
         assertTrue(this.bundleContext.ungetService(serviceReference));
         serviceRegistration.unregister();
         assertFalse(this.bundleContext.ungetService(serviceReference));
@@ -286,18 +284,18 @@
     }
 
     @Test
-    public void getServiceReferenceNoValues() throws InvalidSyntaxException {
+    public void getServiceReferenceNoValues() {
         assertNull(this.bundleContext.getServiceReference((String)null));
     }
 
     @Test
-    public void getServiceReferenceOneValue() throws InvalidSyntaxException {
+    public void getServiceReferenceOneValue() {
         this.bundleContext.registerService(Object.class.getName(), new Object(), null);
         assertNotNull(this.bundleContext.getServiceReference((String)null));
     }
 
     @Test
-    public void getServiceReferenceOneValueTyped() throws InvalidSyntaxException {
+    public void getServiceReferenceOneValueTyped() {
         this.bundleContext.registerService(Object.class.getName(), new Object(), null);
         assertNotNull(this.bundleContext.getServiceReference(Object.class));
     }
@@ -310,7 +308,7 @@
     }
 
     @Test
-    public void getServiceReferenceTwoValues() throws InvalidSyntaxException {
+    public void getServiceReferenceTwoValues() {
         this.bundleContext.registerService(Object.class.getName(), new Object(), null);
         this.bundleContext.registerService(Object.class.getName(), new Object(), null);
         assertNotNull(this.bundleContext.getServiceReference((String)null));
@@ -320,7 +318,7 @@
 
         private boolean called = false;
 
-        private List<BundleEvent> events = new ArrayList<BundleEvent>();
+        private List<BundleEvent> events = new ArrayList<>();
 
         public void bundleChanged(BundleEvent event) {
             this.called = true;
@@ -332,7 +330,7 @@
         }
 
         public BundleEvent[] getEvents() {
-            return events.toArray(new BundleEvent[events.size()]);
+            return events.toArray(new BundleEvent[0]);
         }
 
     }
@@ -356,7 +354,7 @@
     private static class TestInputStream extends InputStream {
 
         @Override
-        public int read() throws IOException {
+        public int read() {
             throw new UnsupportedOperationException();
         }
 
diff --git a/util/org.eclipse.virgo.util.osgi/src/main/java/org/eclipse/virgo/util/osgi/BundleUtils.java b/util/org.eclipse.virgo.util.osgi/src/main/java/org/eclipse/virgo/util/osgi/BundleUtils.java
index eca1487..4a4e766 100644
--- a/util/org.eclipse.virgo.util.osgi/src/main/java/org/eclipse/virgo/util/osgi/BundleUtils.java
+++ b/util/org.eclipse.virgo.util.osgi/src/main/java/org/eclipse/virgo/util/osgi/BundleUtils.java
@@ -37,4 +37,13 @@
         return rev != null && (rev.getTypes() & TYPE_FRAGMENT)!= 0;
     }
 
+    /**
+     * Queries whether the supplied {@link Bundle} is the system bundle.
+     *
+     * @param bundle the <code>Bundle</code>.
+     * @return <code>true</code> if <code>bundle</code> is the system bundle, otherwise <code>false</code>.
+     */
+    public static boolean isSystemBundle(Bundle bundle) {
+        return bundle != null && bundle.getBundleId() == 0;
+    }
 }
diff --git a/util/org.eclipse.virgo.util.osgi/src/test/java/org/eclipse/virgo/util/osgi/StubBundleContext.java b/util/org.eclipse.virgo.util.osgi/src/test/java/org/eclipse/virgo/util/osgi/StubBundleContext.java
index db5e94b..fd42a17 100644
--- a/util/org.eclipse.virgo.util.osgi/src/test/java/org/eclipse/virgo/util/osgi/StubBundleContext.java
+++ b/util/org.eclipse.virgo.util.osgi/src/test/java/org/eclipse/virgo/util/osgi/StubBundleContext.java
@@ -19,11 +19,9 @@
 
 import org.osgi.framework.Bundle;
 import org.osgi.framework.BundleContext;
-import org.osgi.framework.BundleException;
 import org.osgi.framework.BundleListener;
 import org.osgi.framework.Filter;
 import org.osgi.framework.FrameworkListener;
-import org.osgi.framework.InvalidSyntaxException;
 import org.osgi.framework.ServiceListener;
 import org.osgi.framework.ServiceReference;
 import org.osgi.framework.ServiceRegistration;
@@ -63,14 +61,14 @@
     /**
      * {@inheritDoc}
      */
-    public void addServiceListener(ServiceListener arg0, String arg1) throws InvalidSyntaxException {
+    public void addServiceListener(ServiceListener arg0, String arg1) {
         // System.out.println("4");
     }
 
     /**
      * {@inheritDoc}
      */
-    public Filter createFilter(String arg0) throws InvalidSyntaxException {
+    public Filter createFilter(String arg0) {
         // System.out.println("5");
         return new Filter() {
 
@@ -96,7 +94,7 @@
     /**
      * {@inheritDoc}
      */
-    public ServiceReference<?>[] getAllServiceReferences(String arg0, String arg1) throws InvalidSyntaxException {
+    public ServiceReference<?>[] getAllServiceReferences(String arg0, String arg1) {
         // System.out.println("6");
         return null;
     }
@@ -161,7 +159,7 @@
     /**
      * {@inheritDoc}
      */
-    public ServiceReference<?>[] getServiceReferences(String arg0, String arg1) throws InvalidSyntaxException {
+    public ServiceReference<?>[] getServiceReferences(String arg0, String arg1) {
         // System.out.println("14");
         ServiceReference<?>[] refs = new ServiceReference[1];
         refs[0] = new ServiceReference<ServiceObject>() {
@@ -197,7 +195,7 @@
     /**
      * {@inheritDoc}
      */
-    public Bundle installBundle(String arg0) throws BundleException {
+    public Bundle installBundle(String arg0) {
         // System.out.println("15");
         return null;
     }
@@ -205,7 +203,7 @@
     /**
      * {@inheritDoc}
      */
-    public Bundle installBundle(String arg0, InputStream arg1) throws BundleException {
+    public Bundle installBundle(String arg0, InputStream arg1) {
         // System.out.println("16");
         return null;
     }
@@ -272,7 +270,7 @@
     /**
      * {@inheritDoc}
      */
-    public <S> Collection<ServiceReference<S>> getServiceReferences(Class<S> clazz, String filter) throws InvalidSyntaxException {
+    public <S> Collection<ServiceReference<S>> getServiceReferences(Class<S> clazz, String filter) {
         return null;
     }
 
diff --git a/web/org.eclipse.virgo.web.enterprise.persistence.openejb.classloading.hook/src/main/java/org/eclipse/virgo/web/enterprise/persistence/openejb/classloading/hook/AppLoaderClasspathExtenderClassLoadingHook.java b/web/org.eclipse.virgo.web.enterprise.persistence.openejb.classloading.hook/src/main/java/org/eclipse/virgo/web/enterprise/persistence/openejb/classloading/hook/AppLoaderClasspathExtenderClassLoadingHook.java
index 1aeb3f6..44e01e0 100755
--- a/web/org.eclipse.virgo.web.enterprise.persistence.openejb.classloading.hook/src/main/java/org/eclipse/virgo/web/enterprise/persistence/openejb/classloading/hook/AppLoaderClasspathExtenderClassLoadingHook.java
+++ b/web/org.eclipse.virgo.web.enterprise.persistence.openejb.classloading.hook/src/main/java/org/eclipse/virgo/web/enterprise/persistence/openejb/classloading/hook/AppLoaderClasspathExtenderClassLoadingHook.java
@@ -12,7 +12,6 @@
 package org.eclipse.virgo.web.enterprise.persistence.openejb.classloading.hook;

 

 import java.io.File;

-import java.io.FilenameFilter;

 import java.security.ProtectionDomain;

 import java.util.ArrayList;

 import java.util.logging.Level;

@@ -105,17 +104,9 @@
 			throw new ClasspathExtenderClassLoadingHookException("lib/persistence folder is missing");

 		}

 		

-		String[] libs = persistenceLibDir.list(new FilenameFilter() {	

-			@Override

-			public boolean accept(File dir, String name) {

-				if (name.startsWith(PERSISTENCE_INTEGRATION_JAR)) {

-					return true;

-				}

-				return false;

-			}

-		});

+		String[] libs = persistenceLibDir.list((dir, name) -> name.startsWith(PERSISTENCE_INTEGRATION_JAR));

 		

-		if (libs.length == 0) {

+		if (libs == null || libs.length == 0) {

 			throw new ClasspathExtenderClassLoadingHookException("No file with name starting with [" + PERSISTENCE_INTEGRATION_JAR + "] was found in lib/persistence folder");

 		}

 		

diff --git a/web/org.eclipse.virgo.web.enterprise.persistence.openejb.classloading.hook/src/test/java/org/eclipse/virgo/web/enterprise/persistence/openejb/classloading/hook/AppLoaderClasspathExtenderClassLoadingHookTests.java b/web/org.eclipse.virgo.web.enterprise.persistence.openejb.classloading.hook/src/test/java/org/eclipse/virgo/web/enterprise/persistence/openejb/classloading/hook/AppLoaderClasspathExtenderClassLoadingHookTests.java
index 82fbe35..c23c36c 100755
--- a/web/org.eclipse.virgo.web.enterprise.persistence.openejb.classloading.hook/src/test/java/org/eclipse/virgo/web/enterprise/persistence/openejb/classloading/hook/AppLoaderClasspathExtenderClassLoadingHookTests.java
+++ b/web/org.eclipse.virgo.web.enterprise.persistence.openejb.classloading.hook/src/test/java/org/eclipse/virgo/web/enterprise/persistence/openejb/classloading/hook/AppLoaderClasspathExtenderClassLoadingHookTests.java
@@ -93,17 +93,17 @@
     @Test

     public void testAddClassPathEntryPositive() throws IOException {

         File jpaIntegrationFile = prepare();

-        ArrayList<ClasspathEntry> cpEntries = new ArrayList<ClasspathEntry>();

+        ArrayList<ClasspathEntry> cpEntries = new ArrayList<>();

         BaseClassLoader classloader = EasyMock.createMock(BaseClassLoader.class);

         BaseDataStub data = new BaseDataStub(0, null);

-        Dictionary<String, String> manifest = new Hashtable<String, String>();

+        Dictionary<String, String> manifest = new Hashtable<>();

         manifest.put(WEB_CONTEXTPATH_HEADER, TESTAPP);

         data.setManifest(manifest);

         ClasspathManager classpathmanager = new ClasspathManagerStub(data, new String[] {}, classloader);

         AppLoaderClasspathExtenderClassLoadingHook hook = new AppLoaderClasspathExtenderClassLoadingHook();

         boolean result = hook.addClassPathEntry(cpEntries, "", classpathmanager, data, new ProtectionDomain(null, null));

         Assert.assertTrue("Classpath entry should be added successfully but it is not", result);

-        Assert.assertTrue("There should be added only one classapth entry, but they are " + cpEntries.size(), cpEntries.size() == 1);

+        Assert.assertEquals("There should be added only one classapth entry, but they are " + cpEntries.size(), 1, cpEntries.size());

         ClasspathEntry entry = cpEntries.get(0);

         String classpath = ((BundleFileStub) entry.getBundleFile()).getClassPath();

         Assert.assertEquals("Classpath entry created with wrong path: ", jpaIntegrationFile.getAbsolutePath(), classpath);

@@ -111,10 +111,10 @@
 

     @Test

     public void testAddClassPathEntryNegativeNotAppBundle() {

-        ArrayList<ClasspathEntry> cpEntries = new ArrayList<ClasspathEntry>();

+        ArrayList<ClasspathEntry> cpEntries = new ArrayList<>();

         BaseClassLoader classloader = EasyMock.createMock(BaseClassLoader.class);

         BaseDataStub data = new BaseDataStub(0, null);

-        Dictionary<String, String> manifest = new Hashtable<String, String>();

+        Dictionary<String, String> manifest = new Hashtable<>();

         data.setManifest(manifest);

         ClasspathManager classpathmanager = new ClasspathManagerStub(data, new String[] {}, classloader);

         AppLoaderClasspathExtenderClassLoadingHook hook = new AppLoaderClasspathExtenderClassLoadingHook();

@@ -124,10 +124,10 @@
 

     @Test

     public void testAddClassPathEntryNegativeAlreadyAdded() {

-        ArrayList<ClasspathEntry> cpEntries = new ArrayList<ClasspathEntry>();

+        ArrayList<ClasspathEntry> cpEntries = new ArrayList<>();

         BaseClassLoader classloader = EasyMock.createMock(BaseClassLoader.class);

         BaseDataStub data = new BaseDataStub(0, null);

-        Dictionary<String, String> manifest = new Hashtable<String, String>();

+        Dictionary<String, String> manifest = new Hashtable<>();

         data.setManifest(manifest);

         ClasspathManager classpathmanager = new ClasspathManagerStub(data, new String[] {}, classloader);

         File libDir = new File(new File("."), LIB_DIR);

@@ -142,10 +142,10 @@
 

     @Test

     public void testAddClassPathEntryNegativeExceptionThrown() {

-        ArrayList<ClasspathEntry> cpEntries = new ArrayList<ClasspathEntry>();

+        ArrayList<ClasspathEntry> cpEntries = new ArrayList<>();

         BaseClassLoader classloader = EasyMock.createMock(BaseClassLoader.class);

         BaseDataStub data = new BaseDataStub(0, null);

-        Dictionary<String, String> manifest = new Hashtable<String, String>();

+        Dictionary<String, String> manifest = new Hashtable<>();

         manifest.put(WEB_CONTEXTPATH_HEADER, TESTAPP);

         data.setManifest(manifest);

         ClasspathManager classpathmanager = new ClasspathManagerStub(data, new String[] {}, classloader);

@@ -181,7 +181,7 @@
     }

 

     private boolean checkForFile(String filename) {

-        ArrayList<ClasspathEntry> cpEntries = new ArrayList<ClasspathEntry>();

+        ArrayList<ClasspathEntry> cpEntries = new ArrayList<>();

         File libDir = new File(new File("."), LIB_DIR);

         File libPersistenceDir = new File(libDir, PERSISTENCE_DIR);

         String classpath = new File(libPersistenceDir, filename).getAbsolutePath();

@@ -211,7 +211,7 @@
 

     private boolean checkForApp(String contextpathHeaderValue, boolean shouldThrowException) {

         BaseDataStub baseData = new BaseDataStub(0, null);

-        Dictionary<String, String> manifest = new Hashtable<String, String>();

+        Dictionary<String, String> manifest = new Hashtable<>();

         if (contextpathHeaderValue != null) {

             manifest.put(WEB_CONTEXTPATH_HEADER, contextpathHeaderValue);

         }

@@ -310,7 +310,7 @@
         File jpaIntegrationFile = prepare();

         BaseClassLoader classloader = EasyMock.createMock(BaseClassLoader.class);

         BaseDataStub data = new BaseDataStub(0, null);

-        Dictionary<String, String> manifest = new Hashtable<String, String>();

+        Dictionary<String, String> manifest = new Hashtable<>();

         manifest.put(WEB_CONTEXTPATH_HEADER, TESTAPP);

         data.setManifest(manifest);

         ClasspathManager classpathmanager = new ClasspathManagerStub(data, new String[] {}, classloader);

@@ -330,7 +330,7 @@
         prepare();

         BaseClassLoader classloader = EasyMock.createMock(BaseClassLoader.class);

         BaseDataStub data = new BaseDataStub(0, null);

-        Dictionary<String, String> manifest = new Hashtable<String, String>();

+        Dictionary<String, String> manifest = new Hashtable<>();

         manifest.put(WEB_CONTEXTPATH_HEADER, TESTAPP);

         data.setManifest(manifest);

         ClasspathManagerStub classpathmanager = new ClasspathManagerStub(data, new String[] {}, classloader);

diff --git a/web/org.eclipse.virgo.web.enterprise.services.accessor/src/main/java/org/eclipse/virgo/web/enterprise/services/accessor/ClassLoaderJarScanner.java b/web/org.eclipse.virgo.web.enterprise.services.accessor/src/main/java/org/eclipse/virgo/web/enterprise/services/accessor/ClassLoaderJarScanner.java
index 809b02f..b239d55 100755
--- a/web/org.eclipse.virgo.web.enterprise.services.accessor/src/main/java/org/eclipse/virgo/web/enterprise/services/accessor/ClassLoaderJarScanner.java
+++ b/web/org.eclipse.virgo.web.enterprise.services.accessor/src/main/java/org/eclipse/virgo/web/enterprise/services/accessor/ClassLoaderJarScanner.java
@@ -13,12 +13,10 @@
 

 import java.io.File;

 import java.io.IOException;

-import java.net.JarURLConnection;

 import java.net.MalformedURLException;

 import java.net.URI;

 import java.net.URISyntaxException;

 import java.net.URL;

-import java.net.URLConnection;

 import java.util.HashSet;

 import java.util.Set;

 

@@ -50,7 +48,7 @@
     

     public static final String SKIP_BUNDLES_PROPERTY = "gemini.web.scan.BundleDependenciesJarScanned.bundlesToSkip";

 

-    private final Set<Bundle> bundles = new HashSet<Bundle>();

+    private final Set<Bundle> bundles = new HashSet<>();

     

     private Logger logger = LoggerFactory.getLogger(ClassLoaderJarScanner.class);

 

@@ -58,12 +56,7 @@
 

     public ClassLoaderJarScanner(Set<Bundle> bundles) {

     	this.bundles.addAll(bundles);

-    	this.jarScanFilter = new JarScanFilter() {

-  		    @Override

- 		    public boolean check(JarScanType jarScanType, String bundleSymbolicName) {

-  	 	        return true;

-    	    }

-    	};

+    	this.jarScanFilter = (jarScanType, bundleSymbolicName) -> true;

     }

 

     @Override

diff --git a/web/org.eclipse.virgo.web.enterprise.services.accessor/src/test/java/org/eclipse/virgo/web/enterprise/services/accessor/WebAppBundleClassloaderCustomizerTest.java b/web/org.eclipse.virgo.web.enterprise.services.accessor/src/test/java/org/eclipse/virgo/web/enterprise/services/accessor/WebAppBundleClassloaderCustomizerTest.java
index 73dfb85..259b3d8 100755
--- a/web/org.eclipse.virgo.web.enterprise.services.accessor/src/test/java/org/eclipse/virgo/web/enterprise/services/accessor/WebAppBundleClassloaderCustomizerTest.java
+++ b/web/org.eclipse.virgo.web.enterprise.services.accessor/src/test/java/org/eclipse/virgo/web/enterprise/services/accessor/WebAppBundleClassloaderCustomizerTest.java
@@ -17,6 +17,7 @@
 import static org.easymock.EasyMock.isA;

 import static org.easymock.EasyMock.replay;

 import static org.easymock.EasyMock.verify;

+import static org.junit.Assert.assertEquals;

 import static org.junit.Assert.assertTrue;

 

 import java.lang.reflect.Field;

@@ -34,7 +35,6 @@
 import org.osgi.framework.BundleContext;

 import org.osgi.framework.SynchronousBundleListener;

 import org.osgi.framework.wiring.BundleRevision;

-import org.osgi.framework.wiring.BundleWire;

 import org.osgi.framework.wiring.BundleWiring;

 import org.osgi.service.component.ComponentContext;

 

@@ -52,9 +52,9 @@
         BundleRevision bundleRevision = createMock(BundleRevision.class);

         BundleWiring bundleWiring = createMock(BundleWiring.class);

 

-        Dictionary<String, String> apiHeaders = new Hashtable<String, String>();

+        Dictionary<String, String> apiHeaders = new Hashtable<>();

         apiHeaders.put(WebAppBundleTrackerCustomizer.HEADER_EXPOSED_CONTENT_TYPE, WebAppBundleTrackerCustomizer.HEADER_EXPOSED_CONTENT_TYPE_API_VALUE);

-        Dictionary<String, String> implHeaders = new Hashtable<String, String>();

+        Dictionary<String, String> implHeaders = new Hashtable<>();

         implHeaders.put(WebAppBundleTrackerCustomizer.HEADER_EXPOSED_CONTENT_TYPE,

             WebAppBundleTrackerCustomizer.HEADER_EXPOSED_CONTENT_TYPE_IMPL_VALUE);

 

@@ -74,8 +74,8 @@
 

         expect(webBundle.adapt(BundleRevision.class)).andReturn(bundleRevision);

         expect(bundleRevision.getWiring()).andReturn(bundleWiring);

-        expect(bundleWiring.getRequiredWires(BundleRevision.PACKAGE_NAMESPACE)).andReturn(new ArrayList<BundleWire>());

-        expect(bundleWiring.getRequiredWires(BundleRevision.BUNDLE_NAMESPACE)).andReturn(new ArrayList<BundleWire>());

+        expect(bundleWiring.getRequiredWires(BundleRevision.PACKAGE_NAMESPACE)).andReturn(new ArrayList<>());

+        expect(bundleWiring.getRequiredWires(BundleRevision.BUNDLE_NAMESPACE)).andReturn(new ArrayList<>());

 

         replay(ctx, bundleContext, apiBundle, implBundle, webBundle, bundleRevision, bundleWiring);

 

@@ -93,7 +93,7 @@
         assertTrue(webAppBundleClassloaderCustomizer.getWebAppBundleClassLoaderDelegateHook().getImplBundles().contains(implBundle));

         assertTrue(((List<ClassLoaderDelegateHook>) field.get(PluggableDelegatingClassLoaderDelegateHook.getInstance())).contains(webAppBundleClassloaderCustomizer.getWebAppBundleClassLoaderDelegateHook()));

 

-        assertTrue(webAppBundleClassloaderCustomizer.extendClassLoaderChain(webBundle).length == 0);

+        assertEquals(0, webAppBundleClassloaderCustomizer.extendClassLoaderChain(webBundle).length);

         assertTrue(webAppBundleClassloaderCustomizer.getWebAppBundleTrackerCustomizer().getExposeAdditionalApiBundles().isEmpty());

         assertTrue(((Map<Bundle, Set<String>>) field2.get(webAppBundleClassloaderCustomizer.getWebAppBundleClassLoaderDelegateHook())).containsKey(webBundle));

 

diff --git a/web/org.eclipse.virgo.web.war.deployer/src/main/java/org/eclipse/virgo/web/war/deployer/WARDeployer.java b/web/org.eclipse.virgo.web.war.deployer/src/main/java/org/eclipse/virgo/web/war/deployer/WARDeployer.java
index 02b1970..4620b37 100644
--- a/web/org.eclipse.virgo.web.war.deployer/src/main/java/org/eclipse/virgo/web/war/deployer/WARDeployer.java
+++ b/web/org.eclipse.virgo.web.war.deployer/src/main/java/org/eclipse/virgo/web/war/deployer/WARDeployer.java
@@ -150,7 +150,7 @@
 
     private File kernelHomeFile;
     
-    private Map<String, String> wabStates = new ConcurrentHashMap<String, String>();
+    private Map<String, String> wabStates = new ConcurrentHashMap<>();
     
     public WARDeployer() {
         warDeployerInternalInit(null);
@@ -301,14 +301,12 @@
             // we need to decode the path before delete or a /webapps entry might leak
             FileSystemUtils.deleteRecursively(new File(warDir.getAbsolutePath()));
             this.eventLogger.log(WARDeployerLogEvents.NANO_UNINSTALLED, bundle.getSymbolicName(), bundle.getVersion());
-            wabStates.remove((String) bundle.getSymbolicName());
+            wabStates.remove(bundle.getSymbolicName());
         } catch (BundleException e) {
             this.eventLogger.log(WARDeployerLogEvents.NANO_UNDEPLOY_ERROR, e, bundle.getSymbolicName(), bundle.getVersion());
             StatusFileModificator.createStatusFile(warName, this.pickupDir, StatusFileModificator.OP_UNDEPLOY, STATUS_ERROR, -1, -1);
             return STATUS_ERROR;
-        } catch (IOException e) {
-            this.eventLogger.log(WARDeployerLogEvents.NANO_PERSIST_ERROR, e, bundle.getSymbolicName(), bundle.getVersion());
-        } catch (URISyntaxException e) {
+        } catch (IOException | URISyntaxException e) {
             this.eventLogger.log(WARDeployerLogEvents.NANO_PERSIST_ERROR, e, bundle.getSymbolicName(), bundle.getVersion());
         }
 
@@ -372,7 +370,7 @@
         if (bundle != null) {
             try {
             	boolean isLegalState = checkWabState(bundle, isOfflineUpdated);
-            	if (isLegalState == false) {
+            	if (!isLegalState) {
             		this.eventLogger.log(WARDeployerLogEvents.NANO_UPDATE_STATE_ERROR, bundle.getSymbolicName(), bundle.getVersion());
             		StatusFileModificator.createStatusFile(warName, this.pickupDir, StatusFileModificator.OP_DEPLOY, STATUS_ERROR, bundleId, lastModified);
                     return STATUS_ERROR;
@@ -487,7 +485,7 @@
         return isWritable;
     }
 
-    private final void transformUnpackedManifest(File srcFile, String warName) throws IOException {
+    private void transformUnpackedManifest(File srcFile, String warName) throws IOException {
         if (srcFile == null) {
             throw new NullPointerException("Source file is null.");
         }
@@ -530,7 +528,7 @@
     }
 
     private InstallationOptions prepareInstallationOptions(boolean strictWABHeaders, String warName, BundleManifest manifest) {
-        Map<String, String> map = new HashMap<String, String>();
+        Map<String, String> map = new HashMap<>();
         String webContextPathHeader = manifest.getHeader(HEADER_WEB_CONTEXT_PATH);
         if (webContextPathHeader == null || webContextPathHeader.trim().length() == 0) {
             if (warName.equals(ROOT_WAR_NAME)) {
@@ -546,7 +544,7 @@
         return installationOptions;
     }
 
-    private final Manifest toManifest(Dictionary<String, String> headers) {
+    private Manifest toManifest(Dictionary<String, String> headers) {
         Manifest manifest = new Manifest();
         Attributes attributes = manifest.getMainAttributes();
         Enumeration<String> names = headers.keys();
@@ -606,7 +604,7 @@
 
     @Override
     public List<String> getAcceptedFileTypes() {
-        List<String> types = new ArrayList<String>();
+        List<String> types = new ArrayList<>();
         types.add(WAR);
         return types;
     }
@@ -649,7 +647,7 @@
     }
     
     private void registerWebContainerEventsHandler(BundleContext bundleContext) {
-    	Dictionary<String, Object> props = new Hashtable<String, Object>();
+    	Dictionary<String, Object> props = new Hashtable<>();
     	props.put(EventConstants.EVENT_TOPIC, new String[] {EVENT_TOPIC_DEPLOYING, EVENT_TOPIC_DEPLOYED, EVENT_TOPIC_UNDEPLOYING, EVENT_TOPIC_UNDEPLOYED, EVENT_TOPIC_FAILED});
     	bundleContext.registerService(EventHandler.class, new WebContainerEventsHandler(), props);
     }
@@ -658,7 +656,7 @@
         boolean strictWABHeaders = true;
         String wabHeadersPropertyValue = null;
         if (this.kernelConfig.getProperty(PROPERTY_WAB_HEADERS) != null) {
-            wabHeadersPropertyValue = this.kernelConfig.getProperty(PROPERTY_WAB_HEADERS).toString();
+            wabHeadersPropertyValue = this.kernelConfig.getProperty(PROPERTY_WAB_HEADERS);
         }
         if (wabHeadersPropertyValue != null) {
             if (PROPERTY_VALUE_WAB_HEADERS_DEFAULTED.equals(wabHeadersPropertyValue)) {