SLING-9373 remove compile dependency to guava
diff --git a/core/pom.xml b/core/pom.xml
index d20c995..981c265 100644
--- a/core/pom.xml
+++ b/core/pom.xml
@@ -35,12 +35,11 @@
     <dependencies>
 
         <dependency>
-            <groupId>com.google.guava</groupId>
-            <artifactId>guava</artifactId>
-            <version>15.0</version>
+            <groupId>org.apache.commons</groupId>
+            <artifactId>commons-collections4</artifactId>
+            <version>4.1</version>
             <scope>compile</scope>
         </dependency>
-  
         <dependency>
             <groupId>org.apache.commons</groupId>
             <artifactId>commons-lang3</artifactId>
@@ -135,6 +134,12 @@
             <scope>test</scope>
         </dependency>
         <dependency>
+            <groupId>com.google.guava</groupId>
+            <artifactId>guava</artifactId>
+            <version>15.0</version>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
             <groupId>org.apache.sling</groupId>
             <artifactId>org.apache.sling.testing.logging-mock</artifactId>
             <scope>test</scope>
diff --git a/core/src/main/java/org/apache/sling/testing/mock/osgi/MockBundle.java b/core/src/main/java/org/apache/sling/testing/mock/osgi/MockBundle.java
index 89ad673..16d037c 100644
--- a/core/src/main/java/org/apache/sling/testing/mock/osgi/MockBundle.java
+++ b/core/src/main/java/org/apache/sling/testing/mock/osgi/MockBundle.java
@@ -23,6 +23,7 @@
 import java.net.URISyntaxException;
 import java.net.URL;
 import java.security.cert.X509Certificate;
+import java.util.Collections;
 import java.util.Dictionary;
 import java.util.Enumeration;
 import java.util.List;
@@ -35,8 +36,6 @@
 import org.osgi.framework.ServiceReference;
 import org.osgi.framework.Version;
 
-import com.google.common.collect.ImmutableMap;
-
 /**
  * Mock {@link Bundle} implementation.
  */
@@ -46,7 +45,7 @@
 
     private final long bundleId;
     private final BundleContext bundleContext;
-    private Map<String, String> headers = ImmutableMap.<String, String>of();
+    private Map<String, String> headers = Collections.emptyMap();
     private String symbolicName;
     private long lastModified;
 
diff --git a/core/src/main/java/org/apache/sling/testing/mock/osgi/MockBundleContext.java b/core/src/main/java/org/apache/sling/testing/mock/osgi/MockBundleContext.java
index 010c707..e19e739 100644
--- a/core/src/main/java/org/apache/sling/testing/mock/osgi/MockBundleContext.java
+++ b/core/src/main/java/org/apache/sling/testing/mock/osgi/MockBundleContext.java
@@ -21,7 +21,11 @@
 import java.io.File;
 import java.io.IOException;
 import java.io.InputStream;
+import java.nio.file.Files;
+import java.util.ArrayList;
+import java.util.Arrays;
 import java.util.Collection;
+import java.util.Collections;
 import java.util.Comparator;
 import java.util.Dictionary;
 import java.util.List;
@@ -58,9 +62,6 @@
 import org.osgi.service.cm.ConfigurationAdmin;
 import org.osgi.service.component.ComponentConstants;
 
-import com.google.common.collect.ImmutableList;
-import com.google.common.io.Files;
-
 /**
  * Mock {@link BundleContext} implementation.
  */
@@ -311,10 +312,10 @@
     public <S> Collection<ServiceReference<S>> getServiceReferences(Class<S> clazz, String filter) throws InvalidSyntaxException {
         ServiceReference<S>[] result = getServiceReferences(clazz.getName(), filter);
         if (result == null) {
-            return ImmutableList.<ServiceReference<S>>of();
+            return Collections.emptyList();
         }
         else {
-            return ImmutableList.<ServiceReference<S>>copyOf(result);
+            return Arrays.asList(result);
         }
     }
 
@@ -421,7 +422,11 @@
         }
         synchronized (this) {
             if (dataFileBaseDir == null) {
-                dataFileBaseDir = Files.createTempDir();
+                try {
+                    dataFileBaseDir = Files.createTempDirectory("osgi-mock").toFile();
+                } catch (IOException ex) {
+                    throw new RuntimeException("Error creating temp. directory.", ex);
+                }
             }
         }
         if (path.isEmpty()) { 
@@ -437,7 +442,9 @@
      */
     @SuppressWarnings("null")
     public void shutdown() {
-        for (MockServiceRegistration<?> serviceRegistration : ImmutableList.copyOf(registeredServices).reverse()) {
+        List<MockServiceRegistration> reversedRegisteredServices = new ArrayList<>(registeredServices);
+        Collections.reverse(reversedRegisteredServices);
+        for (MockServiceRegistration<?> serviceRegistration : reversedRegisteredServices) {
             try {
                 MockOsgi.deactivate(serviceRegistration.getService(), this, serviceRegistration.getProperties());
             }
diff --git a/core/src/main/java/org/apache/sling/testing/mock/osgi/MockServiceRegistration.java b/core/src/main/java/org/apache/sling/testing/mock/osgi/MockServiceRegistration.java
index eee3074..bc1454a 100644
--- a/core/src/main/java/org/apache/sling/testing/mock/osgi/MockServiceRegistration.java
+++ b/core/src/main/java/org/apache/sling/testing/mock/osgi/MockServiceRegistration.java
@@ -18,6 +18,7 @@
  */
 package org.apache.sling.testing.mock.osgi;
 
+import java.util.Arrays;
 import java.util.Dictionary;
 import java.util.HashSet;
 import java.util.Hashtable;
@@ -33,8 +34,6 @@
 import org.osgi.framework.ServiceReference;
 import org.osgi.framework.ServiceRegistration;
 
-import com.google.common.collect.ImmutableList;
-
 /**
  * Mock {@link ServiceRegistration} implementation.
  */
@@ -53,7 +52,7 @@
     public MockServiceRegistration(final Bundle bundle, final String[] clazzes, final T service,
             final Dictionary<String, Object> properties, MockBundleContext bundleContext) {
         this.serviceId = ++serviceCounter;
-        this.clazzes = new HashSet<String>(ImmutableList.copyOf(clazzes));
+        this.clazzes = new HashSet<String>(Arrays.asList(clazzes));
         
         if (service instanceof ServiceFactory) {
             this.service = ((ServiceFactory<T>)service).getService(bundleContext.getBundle(), this);
diff --git a/core/src/main/java/org/apache/sling/testing/mock/osgi/OsgiMetadataUtil.java b/core/src/main/java/org/apache/sling/testing/mock/osgi/OsgiMetadataUtil.java
index 5a4e4c2..fee6e7b 100644
--- a/core/src/main/java/org/apache/sling/testing/mock/osgi/OsgiMetadataUtil.java
+++ b/core/src/main/java/org/apache/sling/testing/mock/osgi/OsgiMetadataUtil.java
@@ -29,7 +29,8 @@
 import java.util.List;
 import java.util.Map;
 import java.util.Set;
-import java.util.concurrent.ExecutionException;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.ConcurrentMap;
 import java.util.regex.Pattern;
 
 import javax.xml.namespace.NamespaceContext;
@@ -42,6 +43,8 @@
 import javax.xml.xpath.XPathExpressionException;
 import javax.xml.xpath.XPathFactory;
 
+import org.apache.commons.collections4.BidiMap;
+import org.apache.commons.collections4.bidimap.TreeBidiMap;
 import org.apache.commons.lang3.StringUtils;
 import org.apache.felix.framework.FilterImpl;
 import org.osgi.framework.Constants;
@@ -57,12 +60,6 @@
 import org.w3c.dom.NodeList;
 import org.xml.sax.SAXException;
 
-import com.google.common.cache.CacheBuilder;
-import com.google.common.cache.CacheLoader;
-import com.google.common.cache.LoadingCache;
-import com.google.common.collect.BiMap;
-import com.google.common.collect.HashBiMap;
-
 /**
  * Helper methods to parse OSGi metadata.
  */
@@ -84,7 +81,7 @@
 
     private static final XPathFactory XPATH_FACTORY = XPathFactory.newInstance();
 
-    private static final BiMap<String, String> NAMESPACES = HashBiMap.create();
+    private static final BidiMap<String, String> NAMESPACES = new TreeBidiMap<>();
     static {
         NAMESPACES.put("scr", "http://www.osgi.org/xmlns/scr/v1.1.0");
     }
@@ -99,7 +96,7 @@
 
         @Override
         public String getPrefix(String namespaceURI) {
-            return NAMESPACES.inverse().get(namespaceURI);
+            return NAMESPACES.getKey(namespaceURI);
         }
 
         @Override
@@ -113,16 +110,7 @@
      * So we can cache the parsing step if we need them multiple times.
      */
     private static final Map<String,Document> METADATA_DOCUMENT_CACHE = initMetadataDocumentCache();
-    private static final LoadingCache<Class, OsgiMetadata> METADATA_CACHE = CacheBuilder.newBuilder().build(new CacheLoader<Class, OsgiMetadata>() {
-        @Override
-        public OsgiMetadata load(Class clazz) throws Exception {
-            Document metadataDocument = METADATA_DOCUMENT_CACHE.get(cleanupClassName(clazz.getName()));
-            if (metadataDocument != null) {
-                return new OsgiMetadata(clazz, metadataDocument);
-            }
-            return NULL_METADATA;
-        }
-    });
+    private static final ConcurrentMap<Class, OsgiMetadata> METADATA_CACHE = new ConcurrentHashMap<>();
 
     private OsgiMetadataUtil() {
         // static methods only
@@ -135,17 +123,18 @@
      * @return Metadata object or null if no metadata present in classpath
      */
     public static OsgiMetadata getMetadata(Class clazz) {
-        try {
-            OsgiMetadata metadata = METADATA_CACHE.get(clazz);
-            if (metadata == NULL_METADATA) {
-                return null;
+        OsgiMetadata metadata = METADATA_CACHE.computeIfAbsent(clazz, key -> {
+            Document metadataDocument = METADATA_DOCUMENT_CACHE.get(cleanupClassName(key.getName()));
+            if (metadataDocument != null) {
+                return new OsgiMetadata(key, metadataDocument);
             }
-            else {
-                return metadata;
-            }
+            return NULL_METADATA;
+        });
+        if (metadata == NULL_METADATA) {
+            return null;
         }
-        catch (ExecutionException ex) {
-            throw new RuntimeException("Error loading OSGi metadata from loader cache.", ex);
+        else {
+            return metadata;
         }
     }
     
diff --git a/parent/pom.xml b/parent/pom.xml
index f7b3bd4..1961728 100644
--- a/parent/pom.xml
+++ b/parent/pom.xml
@@ -23,7 +23,7 @@
     <parent>
         <groupId>org.apache.sling</groupId>
         <artifactId>sling-bundle-parent</artifactId>
-        <version>36</version>
+        <version>38</version>
         <relativePath />
     </parent>