1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/src/share/classes/com/sun/corba/se/impl/orbutil/ObjectUtility.java Wed Apr 27 01:21:28 2016 +0800 1.3 @@ -0,0 +1,87 @@ 1.4 +/* 1.5 + * Copyright (c) 2002, 2010, Oracle and/or its affiliates. All rights reserved. 1.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 1.7 + * 1.8 + * This code is free software; you can redistribute it and/or modify it 1.9 + * under the terms of the GNU General Public License version 2 only, as 1.10 + * published by the Free Software Foundation. Oracle designates this 1.11 + * particular file as subject to the "Classpath" exception as provided 1.12 + * by Oracle in the LICENSE file that accompanied this code. 1.13 + * 1.14 + * This code is distributed in the hope that it will be useful, but WITHOUT 1.15 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 1.16 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 1.17 + * version 2 for more details (a copy is included in the LICENSE file that 1.18 + * accompanied this code). 1.19 + * 1.20 + * You should have received a copy of the GNU General Public License version 1.21 + * 2 along with this work; if not, write to the Free Software Foundation, 1.22 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 1.23 + * 1.24 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 1.25 + * or visit www.oracle.com if you need additional information or have any 1.26 + * questions. 1.27 + */ 1.28 + 1.29 +package com.sun.corba.se.impl.orbutil; 1.30 + 1.31 +import java.security.PrivilegedAction; 1.32 +import java.security.AccessController; 1.33 +import java.util.ArrayList; 1.34 +import java.util.Arrays; 1.35 +import java.util.Map; 1.36 +import java.util.List; 1.37 +import java.util.ListIterator; 1.38 +import java.util.Set; 1.39 +import java.util.Map.Entry; 1.40 +import java.util.Collection; 1.41 +import java.util.HashMap; 1.42 +import java.util.HashSet; 1.43 +import java.util.Hashtable; 1.44 +import java.util.Iterator; 1.45 +import java.util.Enumeration; 1.46 +import java.util.Properties; 1.47 +import java.util.IdentityHashMap; 1.48 +import java.lang.reflect.Array; 1.49 +import java.lang.reflect.Field; 1.50 +import java.lang.reflect.Method; 1.51 +import java.lang.reflect.Modifier; 1.52 +import java.math.BigInteger ; 1.53 +import java.math.BigDecimal ; 1.54 + 1.55 +public final class ObjectUtility { 1.56 + private ObjectUtility() {} 1.57 + 1.58 + 1.59 + /** If arr1 and arr2 are both arrays of the same component type, 1.60 + * return an array of that component type that consists of the 1.61 + * elements of arr1 followed by the elements of arr2. 1.62 + * Throws IllegalArgumentException otherwise. 1.63 + */ 1.64 + public static Object concatenateArrays( Object arr1, Object arr2 ) 1.65 + { 1.66 + Class comp1 = arr1.getClass().getComponentType() ; 1.67 + Class comp2 = arr2.getClass().getComponentType() ; 1.68 + int len1 = Array.getLength( arr1 ) ; 1.69 + int len2 = Array.getLength( arr2 ) ; 1.70 + 1.71 + if ((comp1 == null) || (comp2 == null)) 1.72 + throw new IllegalStateException( "Arguments must be arrays" ) ; 1.73 + if (!comp1.equals( comp2 )) 1.74 + throw new IllegalStateException( 1.75 + "Arguments must be arrays with the same component type" ) ; 1.76 + 1.77 + Object result = Array.newInstance( comp1, len1 + len2 ) ; 1.78 + 1.79 + int index = 0 ; 1.80 + 1.81 + for (int ctr=0; ctr<len1; ctr++) 1.82 + Array.set( result, index++, Array.get( arr1, ctr ) ) ; 1.83 + 1.84 + for (int ctr=0; ctr<len2; ctr++) 1.85 + Array.set( result, index++, Array.get( arr2, ctr ) ) ; 1.86 + 1.87 + return result ; 1.88 + } 1.89 + 1.90 +}