diff options
author | Tom Tromey <tromey@gcc.gnu.org> | 1999-04-07 14:42:40 +0000 |
---|---|---|
committer | Tom Tromey <tromey@gcc.gnu.org> | 1999-04-07 14:42:40 +0000 |
commit | ee9dd3721be68b9fa63dea9aa5a1d86e66958cde (patch) | |
tree | d96801a16fdf03a5682ef98730fe333a46eef944 /libjava/java/lang/reflect/Array.java | |
parent | 140fa895c6b859f827fc4437b91775a82cd105fb (diff) | |
download | gcc-ee9dd3721be68b9fa63dea9aa5a1d86e66958cde.zip gcc-ee9dd3721be68b9fa63dea9aa5a1d86e66958cde.tar.gz gcc-ee9dd3721be68b9fa63dea9aa5a1d86e66958cde.tar.bz2 |
Initial revision
From-SVN: r26263
Diffstat (limited to 'libjava/java/lang/reflect/Array.java')
-rw-r--r-- | libjava/java/lang/reflect/Array.java | 78 |
1 files changed, 78 insertions, 0 deletions
diff --git a/libjava/java/lang/reflect/Array.java b/libjava/java/lang/reflect/Array.java new file mode 100644 index 0000000..398f80d --- /dev/null +++ b/libjava/java/lang/reflect/Array.java @@ -0,0 +1,78 @@ +// FileDescriptor.java - Open file or device + +/* Copyright (C) 1999 Cygnus Solutions + + This file is part of libgcj. + +This software is copyrighted work licensed under the terms of the +Libgcj License. Please consult the file "LIBGCJ_LICENSE" for +details. */ + +package java.lang.reflect; + +/** + * @author Per Bothner <bothner@cygnus.com> + * @date january 12, 1999 + */ + +/* Written using "Java Class Libraries", 2nd edition, ISBN 0-201-31002-3. + * Status: Believe complete and correct. + */ + +public final class Array +{ + Array () { } + + public static native Object newInstance(Class componentType, int length); + public static native Object newInstance(Class elementType, int[] dimensions); + public static native int getLength (Object array); + + public static native Object get (Object array, int index); + public static native char getChar (Object array, int index); + public static native byte getByte (Object array, int index); + public static native short getShort (Object array, int index); + public static native int getInt (Object array, int index); + public static native long getLong (Object array, int index); + public static native float getFloat (Object array, int index); + public static native double getDouble (Object array, int index); + public static native boolean getBoolean (Object array, int index); + + private static native Class getElementType (Object array, int index); + + private static native void set (Object array, int index, + Object value, Class elType); + + public static void set (Object array, int index, Object value) + { + Class elType = getElementType(array, index); + if (! elType.isPrimitive()) + set(array, index, value, elType); + else if (value instanceof Byte) + setByte(array, index, ((Byte) value).byteValue()); + else if (value instanceof Short) + setShort (array, index, ((Short) value).shortValue()); + else if (value instanceof Integer) + setInt(array, index, ((Integer) value).intValue()); + else if (value instanceof Long) + setLong(array, index, ((Long) value).longValue()); + else if (value instanceof Float) + setFloat(array, index, ((Float) value).floatValue()); + else if (value instanceof Double) + setDouble(array, index, ((Double) value).doubleValue()); + else if (value instanceof Character) + setChar(array, index, ((Character) value).charValue()); + else if (value instanceof Boolean) + setBoolean(array, index, ((Boolean) value).booleanValue()); + else + throw new IllegalArgumentException(); + } + + public static native void setByte (Object array, int index, byte value); + public static native void setShort (Object array, int index, short value); + public static native void setInt (Object array, int index, int value); + public static native void setLong (Object array, int index, long value); + public static native void setFloat (Object array, int index, float value); + public static native void setDouble (Object array, int index, double value); + public static native void setChar (Object array, int index, char value); + public static native void setBoolean(Object array, int index, boolean value); +} |