Method newArray.

@param componentType
@param length
@return T[]
428670
@SuppressWarnings("unchecked")
    public static <T> T newArray(final Class<?> componentType, final int length) {
        //        if (length == 0) {
        //            final Object result = CLASS_EMPTY_ARRAY.get(componentType);
        //
        //            if (result != null) {
        //                return (T) result;
        //            }
        //        }

        return (T) Array.newInstance(componentType, length);
    }
834082
private Object newArray(Object obj, XmlParser.Node node) throws NoSuchMethodException,
            ClassNotFoundException, InvocationTargetException, IllegalAccessException
    {
        // Get the type
        Class aClass = java.lang.Object.class;
        String type = node.getAttribute("type");
        String id = node.getAttribute("id");
        if (type != null)
        {
            aClass = TypeUtil.fromName(type);
            if (aClass == null)
            {
                if ("String".equals(type))
                    aClass = java.lang.String.class;
                else if ("URL".equals(type))
                    aClass = java.net.URL.class;
                else if ("InetAddress".equals(type))
                    aClass = java.net.InetAddress.class;
                else if ("InetAddrPort".equals(type))
                    aClass = org.browsermob.proxy.jetty.util.InetAddrPort.class;
                else
                    aClass = Loader.loadClass(XmlConfiguration.class, type);
            }
        }

        Object array = Array.newInstance(aClass, node.size());
        if (id != null) _idMap.put(id, obj);

        for (int i = 0; i < node.size(); i++)
        {
            Object o = node.get(i);
            if (o instanceof String) continue;
            XmlParser.Node item = (XmlParser.Node) o;
            if (!item.getTag().equals("Item")) throw new IllegalStateException("Not an Item");
            id = item.getAttribute("id");
            Object v = value(obj, item);
            if (v != null) Array.set(array, i, v);
            if (id != null) _idMap.put(id, v);
        }

        return array;
    }
518706
public static <T, C> ObjectArrayTypeInfo<T, C> getInfoFor(Type type, TypeInformation<C> componentInfo) {
		
		// generic array type e.g. for Tuples
		if (type instanceof GenericArrayType) {
			GenericArrayType genericArray = (GenericArrayType) type;
			return new ObjectArrayTypeInfo<T, C>(type, genericArray.getGenericComponentType(), componentInfo);
		}
		// for tuples without generics (e.g. generated by the TypeInformation parser)
		else if (type instanceof Class<?> && ((Class<?>) type).isArray() && Tuple.class.isAssignableFrom(((Class<?>) type).getComponentType())
				&& type != Tuple.class) {
			return new ObjectArrayTypeInfo<T, C>(type, ((Class<?>) type).getComponentType(), componentInfo);
		}
		return getInfoFor(type);
	}
49422
public static <T> T[] toArray(Iterator<T> iterator, Class<T> componentType) {
		return toArray(CollectionUtil.newArrayList(iterator), componentType);
	}
1305397
@SuppressWarnings("unchecked")
    public static <T> T[] copyOf(T[] array, int length) {
        T[] newArray = (T[]) Array.newInstance(array.getClass().getComponentType(), length);
        System.arraycopy(array, 0, newArray, 0, Math.min(length, array.length));
        return newArray;
    }
623421
public static int[] toArray(IntTuple t)
    {
        int d = t.getSize();
        int result[] = new int[d];
        for (int i=0; i<d; i++)
        {
            result[i] = t.get(i);
        }
        return result;
    }
478630
public void addNewArray(String name, TypeMirror type, int size) throws IOException
    {
        if (type.getKind() != TypeKind.ARRAY)
        {
            throw new IllegalArgumentException(type+" is not array");
        }
        ArrayType at = (ArrayType) type;
        addVariable(name, at);
        newarray(type, size);
        if (!Typ.isPrimitive(at.getComponentType()))
        {
            checkcast(at);
        }
        tstore(name);
    }
419542
@Override
    public UIComponent createComponent(ValueExpression componentExpression,
                                       FacesContext context,
                                       String componentType)
          throws FacesException {
        return getWrapped().createComponent(componentExpression, context, componentType);
    }
555700
public static String[] toArrayElement(String s) {
    return (s == null || s.length() == 0) ? new String[0] : new String[]{s};
  }
440024
@SuppressWarnings("unchecked")
	public final <C extends T> ComponentList<C> getComponents(final String name) {
        final ComponentList<C> components = new ComponentList<C>();
        for (final T c : this) {
            if (c.getName().equals(name)) {
                components.add((C) c);
            }
        }
        return components;
    }
1034550
public int[] readIntArray(int length) throws IOException {
        int arr[] = new int[length];
        for (int i = 0; i < length; i++) {
            arr[i] = readInt();
        }
        return arr;
    }
976883
@Nonnull
  @ReturnsMutableCopy
  public static <ELEMENTTYPE> ELEMENTTYPE [] newArraySameType (@Nonnull final ELEMENTTYPE [] aArray,
                                                               @Nonnegative final int nSize)
  {
    return newArray (getComponentType (aArray), nSize);
  }
1163238
public void addAll( T[] array , int first , int length ) {
		if( length <= 0 )
			return;

		Element<T> a = requestNew();
		a.object = array[first];

		if( this.first == null ) {
			this.first = a;
		} else if( last != null ) {
			last.next = a;
			a.previous = last;
		}

		for (int i = 1; i < length; i++) {
			Element<T> b = requestNew();
			b.object =  array[first+i];

			a.next = b;
			b.previous = a;
			a = b;
		}

		last = a;
		size += length;
	}
667796
public int[] toComponents()
  {
    int[] ver = new int[_components.length];
    
    // Note an array copy is required in order to ensure that this class is immutable.
    System.arraycopy(_components, 0, ver, 0, _components.length);
    
    return ver;
  }
933419
@SuppressWarnings("unchecked")
	<T extends Component> T getComponent (ComponentType componentType) {
		int componentTypeIndex = componentType.getIndex();

		if (componentTypeIndex < components.getCapacity()) {
			return (T)components.get(componentType.getIndex());
		} else {
			return null;
		}
	}
768613
function List(length) {
        if (arguments.length === 0) {
            length = 0;
        }

        // in this case we create a list with a given length
        if (arguments.length <= 1 && typeof length === 'number') {
            if (this instanceof List) {
                this.length = length;
            }
            else {
                return new List(length);
            }
        }
        else {
            //here we create a list with initial values
            if (!(this instanceof List)) {
                return List.fromArray(arrSlice(arguments));
            }
            else {
                for (var i = 0, l = arguments.length ; i < l ; i++) {
                    this[i] = arguments[i];
                }
                this.length = arguments.length;
            }
        }
    }
860184
public void newarray(TypeMirror type, int count) throws IOException
    {
        if (type.getKind() != TypeKind.ARRAY)
        {
            throw new IllegalArgumentException(type+" is not array");
        }
        ArrayType at = (ArrayType) type;
        iconst(count);
        TypeMirror ct = at.getComponentType();
        switch (ct.getKind())
        {
            case BOOLEAN:
                newarray(T_BOOLEAN);
                break;
            case CHAR:
                newarray(T_CHAR);
                break;
            case FLOAT:
                newarray(T_FLOAT);
                break;
            case DOUBLE:
                newarray(T_DOUBLE);
                break;
            case BYTE:
                newarray(T_BYTE);
                break;
            case SHORT:
                newarray(T_SHORT);
                break;
            case INT:
                newarray(T_INT);
                break;
            case LONG:
                newarray(T_LONG);
                break;
            case DECLARED:
            {
                DeclaredType dt = (DeclaredType) ct;
                int index = subClass.resolveClassIndex((TypeElement)dt.asElement());
                anewarray(index);
            }
                break;
            default:
                throw new IllegalArgumentException(type+" not supported");
        }
    }