2007-11-29 18:57:22 +00:00
|
|
|
/*******************************************************************************
|
|
|
|
* Copyright (c) 2002 - 2006 IBM Corporation.
|
|
|
|
* All rights reserved. This program and the accompanying materials
|
|
|
|
* are made available under the terms of the Eclipse Public License v1.0
|
|
|
|
* which accompanies this distribution, and is available at
|
|
|
|
* http://www.eclipse.org/legal/epl-v10.html
|
|
|
|
*
|
|
|
|
* Contributors:
|
|
|
|
* IBM Corporation - initial API and implementation
|
|
|
|
*******************************************************************************/
|
|
|
|
package com.ibm.wala.model.java.lang;
|
|
|
|
|
|
|
|
import com.ibm.wala.annotations.Internal;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @author sfink
|
|
|
|
*/
|
|
|
|
@Internal
|
|
|
|
public class System {
|
|
|
|
|
|
|
|
/**
|
|
|
|
* A simple model of object-array copy
|
|
|
|
*/
|
|
|
|
static void arraycopy(Object src, Object dest) {
|
|
|
|
if (!src.getClass().isArray() || !dest.getClass().isArray()) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2007-12-03 15:42:35 +00:00
|
|
|
if (src instanceof Object[]) {
|
2007-11-29 18:57:22 +00:00
|
|
|
Object[] A = (Object[]) src;
|
|
|
|
Object[] B = (Object[]) dest;
|
|
|
|
for (int i = 0; i < A.length; i++)
|
|
|
|
B[i] = A[i];
|
2007-12-03 15:42:35 +00:00
|
|
|
} else if (src instanceof int[]) {
|
2007-11-29 18:57:22 +00:00
|
|
|
int[] A = (int[]) src;
|
|
|
|
int[] B = (int[]) dest;
|
|
|
|
for (int i = 0; i < A.length; i++)
|
|
|
|
B[i] = A[i];
|
2007-12-03 15:42:35 +00:00
|
|
|
} else if (src instanceof char[]) {
|
2007-11-29 18:57:22 +00:00
|
|
|
char[] A = (char[]) src;
|
|
|
|
char[] B = (char[]) dest;
|
|
|
|
for (int i = 0; i < A.length; i++)
|
|
|
|
B[i] = A[i];
|
2007-12-03 15:42:35 +00:00
|
|
|
} else if (src instanceof short[]) {
|
2007-11-29 18:57:22 +00:00
|
|
|
short[] A = (short[]) src;
|
|
|
|
short[] B = (short[]) dest;
|
|
|
|
for (int i = 0; i < A.length; i++)
|
|
|
|
B[i] = A[i];
|
2007-12-03 15:42:35 +00:00
|
|
|
} else if (src instanceof long[]) {
|
2007-11-29 18:57:22 +00:00
|
|
|
long[] A = (long[]) src;
|
|
|
|
long[] B = (long[]) dest;
|
|
|
|
for (int i = 0; i < A.length; i++)
|
|
|
|
B[i] = A[i];
|
2007-12-03 15:42:35 +00:00
|
|
|
} else if (src instanceof byte[]) {
|
2007-11-29 18:57:22 +00:00
|
|
|
byte[] A = (byte[]) src;
|
|
|
|
byte[] B = (byte[]) dest;
|
|
|
|
for (int i = 0; i < A.length; i++)
|
|
|
|
B[i] = A[i];
|
2007-12-03 15:42:35 +00:00
|
|
|
} else if (src instanceof double[]) {
|
2007-11-29 18:57:22 +00:00
|
|
|
double[] A = (double[]) src;
|
|
|
|
double[] B = (double[]) dest;
|
|
|
|
for (int i = 0; i < A.length; i++)
|
|
|
|
B[i] = A[i];
|
2007-12-03 15:42:35 +00:00
|
|
|
} else if (src instanceof boolean[]) {
|
2007-11-29 18:57:22 +00:00
|
|
|
boolean[] A = (boolean[]) src;
|
|
|
|
boolean[] B = (boolean[]) dest;
|
|
|
|
for (int i = 0; i < A.length; i++)
|
|
|
|
B[i] = A[i];
|
2007-12-03 15:42:35 +00:00
|
|
|
} else if (src instanceof float[]) {
|
2007-11-29 18:57:22 +00:00
|
|
|
float[] A = (float[]) src;
|
|
|
|
float[] B = (float[]) dest;
|
|
|
|
for (int i = 0; i < A.length; i++)
|
|
|
|
B[i] = A[i];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|