Added a simple check to detect and work around a bug in J9 (FELIX-416)
git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@592553 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/framework/src/main/java/org/apache/felix/framework/Felix.java b/framework/src/main/java/org/apache/felix/framework/Felix.java
index bc366ff..e6505ec 100644
--- a/framework/src/main/java/org/apache/felix/framework/Felix.java
+++ b/framework/src/main/java/org/apache/felix/framework/Felix.java
@@ -219,7 +219,7 @@
// Initialize member variables.
m_configMutableMap = (configMutableMap == null)
? new StringMap(false) : configMutableMap;
- m_configMap = Collections.unmodifiableMap(m_configMutableMap);
+ m_configMap = createUnmodifiableMap(m_configMutableMap);
m_activatorList = activatorList;
// Create logger with appropriate log level. Even though the
@@ -271,6 +271,26 @@
m_factory.createModule("0", m_extensionManager));
}
+ private Map createUnmodifiableMap(Map mutableMap)
+ {
+ Map result = Collections.unmodifiableMap(mutableMap);
+
+ // Work around a bug in certain version of J9 where a call to
+ // Collections.unmodifiableMap().keySet().iterator() throws
+ // a NoClassDefFoundError. We try to detect this and return
+ // the given mutableMap instead.
+ try
+ {
+ result.keySet().iterator();
+ }
+ catch (NoClassDefFoundError ex)
+ {
+ return mutableMap;
+ }
+
+ return result;
+ }
+
//
// System Bundle methods.
//