felix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gno...@apache.org
Subject svn commit: r1690734 - in /felix/trunk/resolver: ./ src/main/java/org/apache/felix/resolver/ src/main/java/org/apache/felix/resolver/util/
Date Mon, 13 Jul 2015 15:19:58 GMT
Author: gnodet
Date: Mon Jul 13 15:19:58 2015
New Revision: 1690734

URL: http://svn.apache.org/r1690734
Log:
[FELIX-4942] Upgrade to latest felix parent, fix jdk 5 compatibility issues

Modified:
    felix/trunk/resolver/pom.xml
    felix/trunk/resolver/src/main/java/org/apache/felix/resolver/ResolverImpl.java
    felix/trunk/resolver/src/main/java/org/apache/felix/resolver/util/ArrayMap.java
    felix/trunk/resolver/src/main/java/org/apache/felix/resolver/util/CopyOnWriteList.java
    felix/trunk/resolver/src/main/java/org/apache/felix/resolver/util/CopyOnWriteSet.java

Modified: felix/trunk/resolver/pom.xml
URL: http://svn.apache.org/viewvc/felix/trunk/resolver/pom.xml?rev=1690734&r1=1690733&r2=1690734&view=diff
==============================================================================
--- felix/trunk/resolver/pom.xml (original)
+++ felix/trunk/resolver/pom.xml Mon Jul 13 15:19:58 2015
@@ -20,7 +20,7 @@
   <parent>
     <groupId>org.apache.felix</groupId>
     <artifactId>felix-parent</artifactId>
-    <version>2.1</version>
+    <version>3</version>
     <relativePath>../pom/pom.xml</relativePath>
   </parent>
   <modelVersion>4.0.0</modelVersion>
@@ -55,24 +55,20 @@
       <scope>test</scope>
     </dependency>
   </dependencies>
+  <properties>
+    <felix.java.version>5</felix.java.version>
+  </properties>
   <build>
     <plugins>
       <plugin>
-        <groupId>org.apache.maven.plugins</groupId>
-        <artifactId>maven-compiler-plugin</artifactId>
-        <configuration>
-          <target>1.5</target>
-          <source>1.5</source>
-        </configuration>
-      </plugin>
-      <plugin>
         <groupId>org.apache.felix</groupId>
         <artifactId>maven-bundle-plugin</artifactId>
-        <version>2.3.7</version>
+        <version>2.5.4</version>
         <extensions>true</extensions>
         <configuration>
           <instructions>
             <_sources>true</_sources>
+            <_sourcepath>${build.sourceDirectory}</_sourcepath>
             <Bundle-SymbolicName>${pom.artifactId}</Bundle-SymbolicName>
             <Bundle-Activator>
               org.apache.felix.resolver.Activator

Modified: felix/trunk/resolver/src/main/java/org/apache/felix/resolver/ResolverImpl.java
URL: http://svn.apache.org/viewvc/felix/trunk/resolver/src/main/java/org/apache/felix/resolver/ResolverImpl.java?rev=1690734&r1=1690733&r2=1690734&view=diff
==============================================================================
--- felix/trunk/resolver/src/main/java/org/apache/felix/resolver/ResolverImpl.java (original)
+++ felix/trunk/resolver/src/main/java/org/apache/felix/resolver/ResolverImpl.java Mon Jul
13 15:19:58 2015
@@ -1002,7 +1002,7 @@ public class ResolverImpl implements Res
 //            else
             {
                 String s = candSourceCap.getDirectives().get(Namespace.CAPABILITY_USES_DIRECTIVE);
-                if (s != null && !s.isEmpty())
+                if (s != null && s.length() > 0)
                 {
                     // Parse these uses directive.
                     uses = session.getUsesCache().get(s);
@@ -1710,7 +1710,7 @@ public class ResolverImpl implements Res
                 // uses constraints so they are included for consistency
                 // checking.
                 String uses = sourceCap.getDirectives().get(Namespace.CAPABILITY_USES_DIRECTIVE);
-                if ((uses != null) && !uses.isEmpty())
+                if ((uses != null) && uses.length() > 0)
                 {
                     sources.put(sourceCap, Collections.singleton(sourceCap));
                 }

Modified: felix/trunk/resolver/src/main/java/org/apache/felix/resolver/util/ArrayMap.java
URL: http://svn.apache.org/viewvc/felix/trunk/resolver/src/main/java/org/apache/felix/resolver/util/ArrayMap.java?rev=1690734&r1=1690733&r2=1690734&view=diff
==============================================================================
--- felix/trunk/resolver/src/main/java/org/apache/felix/resolver/util/ArrayMap.java (original)
+++ felix/trunk/resolver/src/main/java/org/apache/felix/resolver/util/ArrayMap.java Mon Jul
13 15:19:58 2015
@@ -19,7 +19,6 @@
 package org.apache.felix.resolver.util;
 
 import java.util.*;
-import java.util.function.Function;
 
 @SuppressWarnings("NullableProblems")
 public class ArrayMap<K, V> extends AbstractMap<K, V> {
@@ -92,23 +91,6 @@ public class ArrayMap<K, V> extends Abst
         throw new UnsupportedOperationException();
     }
 
-    @SuppressWarnings("unchecked")
-    public V computeIfAbsent(K key, Function<? super K, ? extends V> mappingFunction)
{
-        for (int i = 0, l = size << 1; i < l; i += 2) {
-            if (key.equals(table[i])) {
-                return (V) table[i + 1];
-            }
-        }
-        if (size << 1 == table.length) {
-            Object[] n = new Object[table.length << 1];
-            System.arraycopy(table, 0, n, 0, table.length);
-            table = n;
-        }
-        int i = size++ << 1;
-        table[i++] = key;
-        return (V) (table[i] = mappingFunction.apply(key));
-    }
-
     @Override
     public Collection<V> values() {
         if (values == null) {

Modified: felix/trunk/resolver/src/main/java/org/apache/felix/resolver/util/CopyOnWriteList.java
URL: http://svn.apache.org/viewvc/felix/trunk/resolver/src/main/java/org/apache/felix/resolver/util/CopyOnWriteList.java?rev=1690734&r1=1690733&r2=1690734&view=diff
==============================================================================
--- felix/trunk/resolver/src/main/java/org/apache/felix/resolver/util/CopyOnWriteList.java
(original)
+++ felix/trunk/resolver/src/main/java/org/apache/felix/resolver/util/CopyOnWriteList.java
Mon Jul 13 15:19:58 2015
@@ -18,6 +18,7 @@
  */
 package org.apache.felix.resolver.util;
 
+import java.lang.reflect.Array;
 import java.util.Arrays;
 import java.util.Collection;
 import java.util.Iterator;
@@ -52,7 +53,7 @@ public class CopyOnWriteList<E> implemen
 
     @SuppressWarnings("unchecked")
     public E set(int index, E element) {
-        data = Arrays.copyOf(data, data.length);
+        data = CopyOnWriteSet.copyOf(data, data.length);
         E prev = (E) data[index];
         data[index] = element;
         return prev;
@@ -123,7 +124,7 @@ public class CopyOnWriteList<E> implemen
         int size = data.length;
         if (a.length < size)
             // Make a new array of a's runtime type, but my contents:
-            return (T[]) Arrays.copyOf(data, size, a.getClass());
+            return (T[]) CopyOnWriteSet.copyOf(data, size, a.getClass());
         System.arraycopy(data, 0, a, 0, size);
         if (a.length > size)
             a[size] = null;
@@ -191,7 +192,7 @@ public class CopyOnWriteList<E> implemen
             }
         }
         if (modified) {
-            data = Arrays.copyOf(d, idx);
+            data = CopyOnWriteSet.copyOf(d, idx);
         }
         return modified;
     }

Modified: felix/trunk/resolver/src/main/java/org/apache/felix/resolver/util/CopyOnWriteSet.java
URL: http://svn.apache.org/viewvc/felix/trunk/resolver/src/main/java/org/apache/felix/resolver/util/CopyOnWriteSet.java?rev=1690734&r1=1690733&r2=1690734&view=diff
==============================================================================
--- felix/trunk/resolver/src/main/java/org/apache/felix/resolver/util/CopyOnWriteSet.java
(original)
+++ felix/trunk/resolver/src/main/java/org/apache/felix/resolver/util/CopyOnWriteSet.java
Mon Jul 13 15:19:58 2015
@@ -18,6 +18,7 @@
  */
 package org.apache.felix.resolver.util;
 
+import java.lang.reflect.Array;
 import java.util.AbstractSet;
 import java.util.Arrays;
 import java.util.Collection;
@@ -102,7 +103,7 @@ public class CopyOnWriteSet<E> implement
         int size = data.length;
         if (a.length < size)
             // Make a new array of a's runtime type, but my contents:
-            return (T[]) Arrays.copyOf(data, size, a.getClass());
+            return (T[]) copyOf(data, size, a.getClass());
         System.arraycopy(data, 0, a, 0, size);
         if (a.length > size)
             a[size] = null;
@@ -211,7 +212,7 @@ public class CopyOnWriteSet<E> implement
                 cs[added++] = e;
         }
         if (added > 0) {
-            Object[] newElements = Arrays.copyOf(elements, len + added);
+            Object[] newElements = copyOf(elements, len + added);
             System.arraycopy(cs, 0, newElements, len, added);
             data = newElements;
             return true;
@@ -231,4 +232,20 @@ public class CopyOnWriteSet<E> implement
         throw new UnsupportedOperationException();
     }
 
+    @SuppressWarnings("unchecked")
+    public static <T> T[] copyOf(T[] original, int newLength) {
+        return (T[]) copyOf(original, newLength, original.getClass());
+    }
+
+    @SuppressWarnings("unchecked")
+    public static <T,U> T[] copyOf(U[] original, int newLength, Class<? extends
T[]> newType) {
+        T[] copy;
+        if ((Object) newType == Object[].class) {
+            copy = (T[]) new Object[newLength];
+        } else {
+            copy = (T[]) Array.newInstance(newType.getComponentType(), newLength);
+        }
+        System.arraycopy(original, 0, copy, 0, Math.min(original.length, newLength));
+        return copy;
+    }
 }



Mime
View raw message