[weld-commits] Weld SVN: r4006 - in core/trunk/impl/src/main/java/org/jboss/weld: util/collections and 1 other directories.

weld-commits at lists.jboss.org weld-commits at lists.jboss.org
Tue Oct 13 11:42:47 EDT 2009


Author: pete.muir at jboss.org
Date: 2009-10-13 11:42:46 -0400 (Tue, 13 Oct 2009)
New Revision: 4006

Modified:
   core/trunk/impl/src/main/java/org/jboss/weld/introspector/jlr/ConstructorSignatureImpl.java
   core/trunk/impl/src/main/java/org/jboss/weld/introspector/jlr/MethodSignatureImpl.java
   core/trunk/impl/src/main/java/org/jboss/weld/util/collections/Arrays2.java
   core/trunk/impl/src/main/java/org/jboss/weld/util/reflection/ParameterizedTypeImpl.java
Log:
Remove jdk6 dep

Modified: core/trunk/impl/src/main/java/org/jboss/weld/introspector/jlr/ConstructorSignatureImpl.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/introspector/jlr/ConstructorSignatureImpl.java	2009-10-13 14:49:39 UTC (rev 4005)
+++ core/trunk/impl/src/main/java/org/jboss/weld/introspector/jlr/ConstructorSignatureImpl.java	2009-10-13 15:42:46 UTC (rev 4006)
@@ -20,6 +20,7 @@
 
 import org.jboss.weld.introspector.ConstructorSignature;
 import org.jboss.weld.introspector.WeldConstructor;
+import org.jboss.weld.util.collections.Arrays2;
 
 public class ConstructorSignatureImpl implements ConstructorSignature
 {
@@ -60,7 +61,7 @@
    
    public String[] getParameterTypes()
    {
-      return Arrays.copyOf(parameterTypes, parameterTypes.length);
+      return Arrays2.copyOf(parameterTypes, parameterTypes.length);
    }
    
 }
\ No newline at end of file

Modified: core/trunk/impl/src/main/java/org/jboss/weld/introspector/jlr/MethodSignatureImpl.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/introspector/jlr/MethodSignatureImpl.java	2009-10-13 14:49:39 UTC (rev 4005)
+++ core/trunk/impl/src/main/java/org/jboss/weld/introspector/jlr/MethodSignatureImpl.java	2009-10-13 15:42:46 UTC (rev 4006)
@@ -21,6 +21,7 @@
 
 import org.jboss.weld.introspector.MethodSignature;
 import org.jboss.weld.introspector.WeldMethod;
+import org.jboss.weld.util.collections.Arrays2;
 
 public class MethodSignatureImpl implements MethodSignature
 {
@@ -81,7 +82,7 @@
    
    public String[] getParameterTypes()
    {
-      return Arrays.copyOf(parameterTypes, parameterTypes.length);
+      return Arrays2.copyOf(parameterTypes, parameterTypes.length);
    }
    
    @Override

Modified: core/trunk/impl/src/main/java/org/jboss/weld/util/collections/Arrays2.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/util/collections/Arrays2.java	2009-10-13 14:49:39 UTC (rev 4005)
+++ core/trunk/impl/src/main/java/org/jboss/weld/util/collections/Arrays2.java	2009-10-13 15:42:46 UTC (rev 4006)
@@ -16,6 +16,7 @@
  */
 package org.jboss.weld.util.collections;
 
+import java.lang.reflect.Array;
 import java.util.Arrays;
 import java.util.HashSet;
 import java.util.Set;
@@ -48,5 +49,59 @@
       }
       return result;
    }
+   
+   // Cloning
+   /**
+    * Copies the specified array, truncating or padding with nulls (if necessary)
+    * so the copy has the specified length.  For all indices that are
+    * valid in both the original array and the copy, the two arrays will
+    * contain identical values.  For any indices that are valid in the
+    * copy but not the original, the copy will contain <tt>null</tt>.
+    * Such indices will exist if and only if the specified length
+    * is greater than that of the original array.
+    * The resulting array is of exactly the same class as the original array.
+    *
+    * @param original the array to be copied
+    * @param newLength the length of the copy to be returned
+    * @return a copy of the original array, truncated or padded with nulls
+    *     to obtain the specified length
+    * @throws NegativeArraySizeException if <tt>newLength</tt> is negative
+    * @throws NullPointerException if <tt>original</tt> is null
+    * @since 1.6
+    */
+   public static <T> T[] copyOf(T[] original, int newLength) {
+       return (T[]) copyOf(original, newLength, original.getClass());
+   }
 
+   /**
+    * Copies the specified array, truncating or padding with nulls (if necessary)
+    * so the copy has the specified length.  For all indices that are
+    * valid in both the original array and the copy, the two arrays will
+    * contain identical values.  For any indices that are valid in the
+    * copy but not the original, the copy will contain <tt>null</tt>.
+    * Such indices will exist if and only if the specified length
+    * is greater than that of the original array.
+    * The resulting array is of the class <tt>newType</tt>.
+    *
+    * @param original the array to be copied
+    * @param newLength the length of the copy to be returned
+    * @param newType the class of the copy to be returned
+    * @return a copy of the original array, truncated or padded with nulls
+    *     to obtain the specified length
+    * @throws NegativeArraySizeException if <tt>newLength</tt> is negative
+    * @throws NullPointerException if <tt>original</tt> is null
+    * @throws ArrayStoreException if an element copied from
+    *     <tt>original</tt> is not of a runtime type that can be stored in
+    *     an array of class <tt>newType</tt>
+    * @since 1.6
+    */
+   public static <T,U> T[] copyOf(U[] original, int newLength, Class<? extends T[]> newType) {
+       T[] copy = ((Object)newType == (Object)Object[].class)
+           ? (T[]) new Object[newLength]
+           : (T[]) Array.newInstance(newType.getComponentType(), newLength);
+       System.arraycopy(original, 0, copy, 0,
+                        Math.min(original.length, newLength));
+       return copy;
+   }
+
 }

Modified: core/trunk/impl/src/main/java/org/jboss/weld/util/reflection/ParameterizedTypeImpl.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/util/reflection/ParameterizedTypeImpl.java	2009-10-13 14:49:39 UTC (rev 4005)
+++ core/trunk/impl/src/main/java/org/jboss/weld/util/reflection/ParameterizedTypeImpl.java	2009-10-13 15:42:46 UTC (rev 4006)
@@ -20,6 +20,8 @@
 import java.lang.reflect.Type;
 import java.util.Arrays;
 
+import org.jboss.weld.util.collections.Arrays2;
+
 public class ParameterizedTypeImpl implements ParameterizedType
 {
    private final Type[] actualTypeArguments;
@@ -28,14 +30,14 @@
 
    public ParameterizedTypeImpl(Type rawType, Type[] actualTypeArguments, Type ownerType)
    {
-      this.actualTypeArguments = Arrays.copyOf(actualTypeArguments, actualTypeArguments.length);
+      this.actualTypeArguments = Arrays2.copyOf(actualTypeArguments, actualTypeArguments.length);
       this.rawType = rawType;
       this.ownerType = ownerType;
    }
 
    public Type[] getActualTypeArguments()
    {
-      return Arrays.copyOf(actualTypeArguments, actualTypeArguments.length);
+      return Arrays2.copyOf(actualTypeArguments, actualTypeArguments.length);
    }
 
    public Type getOwnerType()



More information about the weld-commits mailing list