0N/A/*
0N/A * Copyright (c) 1996, 1998, Oracle and/or its affiliates. All rights reserved.
801N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
801N/A *
801N/A * This code is free software; you can redistribute it and/or modify it
0N/A * under the terms of the GNU General Public License version 2 only, as
801N/A * published by the Free Software Foundation. Oracle designates this
5612N/A * particular file as subject to the "Classpath" exception as provided
801N/A * by Oracle in the LICENSE file that accompanied this code.
801N/A *
801N/A * This code is distributed in the hope that it will be useful, but WITHOUT
5512N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
801N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
5612N/A * version 2 for more details (a copy is included in the LICENSE file that
801N/A * accompanied this code).
801N/A *
801N/A * You should have received a copy of the GNU General Public License version
0N/A * 2 along with this work; if not, write to the Free Software Foundation,
5512N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
5512N/A *
5512N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
5512N/A * or visit www.oracle.com if you need additional information or have any
5512N/A * questions.
5512N/A */
5512N/A
5512N/A#include "jni.h"
5512N/A#include "jvm.h"
5512N/A#include "java_lang_reflect_Array.h"
5512N/A
5512N/A/*
5512N/A * Native code for java.lang.reflect.Array.
5512N/A *
5512N/A * TODO: Performance
5512N/A */
5648N/A
5648N/A/*
5648N/A *
5648N/A */
5648N/AJNIEXPORT jint JNICALL
5648N/AJava_java_lang_reflect_Array_getLength(JNIEnv *env, jclass ignore, jobject arr)
5648N/A{
5512N/A return JVM_GetArrayLength(env, arr);
5512N/A}
5512N/A
5512N/A/*
5512N/A *
5512N/A */
5512N/AJNIEXPORT jobject JNICALL
5512N/AJava_java_lang_reflect_Array_get(JNIEnv *env, jclass ignore, jobject arr,
5512N/A jint index)
5512N/A{
5512N/A return JVM_GetArrayElement(env, arr, index);
5512N/A}
5648N/A
5512N/AJNIEXPORT jboolean JNICALL
5512N/AJava_java_lang_reflect_Array_getBoolean(JNIEnv *env, jclass ignore, jobject arr,
5512N/A jint index)
5512N/A{
5512N/A return JVM_GetPrimitiveArrayElement(env, arr, index, JVM_T_BOOLEAN).z;
5512N/A}
5512N/A
5512N/AJNIEXPORT jbyte JNICALL
5512N/AJava_java_lang_reflect_Array_getByte(JNIEnv *env, jclass ignore, jobject arr,
5512N/A jint index)
5512N/A{
5512N/A return JVM_GetPrimitiveArrayElement(env, arr, index, JVM_T_BYTE).b;
5512N/A}
5512N/A
5512N/AJNIEXPORT jchar JNICALL
5512N/AJava_java_lang_reflect_Array_getChar(JNIEnv *env, jclass ignore, jobject arr,
5512N/A jint index)
5512N/A{
5512N/A return JVM_GetPrimitiveArrayElement(env, arr, index, JVM_T_CHAR).c;
5512N/A}
5980N/A
5980N/AJNIEXPORT jshort JNICALL
5980N/AJava_java_lang_reflect_Array_getShort(JNIEnv *env, jclass ignore, jobject arr,
5980N/A jint index)
5980N/A{
5980N/A return JVM_GetPrimitiveArrayElement(env, arr, index, JVM_T_SHORT).s;
5980N/A}
5980N/A
801N/AJNIEXPORT jint JNICALL
801N/AJava_java_lang_reflect_Array_getInt(JNIEnv *env, jclass ignore, jobject arr,
801N/A jint index)
801N/A{
801N/A return JVM_GetPrimitiveArrayElement(env, arr, index, JVM_T_INT).i;
801N/A}
801N/A
801N/AJNIEXPORT jlong JNICALL
801N/AJava_java_lang_reflect_Array_getLong(JNIEnv *env, jclass ignore, jobject arr,
0N/A jint index)
0N/A{
0N/A return JVM_GetPrimitiveArrayElement(env, arr, index, JVM_T_LONG).j;
0N/A}
JNIEXPORT jfloat JNICALL
Java_java_lang_reflect_Array_getFloat(JNIEnv *env, jclass ignore, jobject arr,
jint index)
{
return JVM_GetPrimitiveArrayElement(env, arr, index, JVM_T_FLOAT).f;
}
JNIEXPORT jdouble JNICALL
Java_java_lang_reflect_Array_getDouble(JNIEnv *env, jclass ignore, jobject arr,
jint index)
{
return JVM_GetPrimitiveArrayElement(env, arr, index, JVM_T_DOUBLE).d;
}
/*
*
*/
JNIEXPORT void JNICALL
Java_java_lang_reflect_Array_set(JNIEnv *env, jclass ignore, jobject arr,
jint index, jobject val)
{
JVM_SetArrayElement(env, arr, index, val);
}
JNIEXPORT void JNICALL
Java_java_lang_reflect_Array_setBoolean(JNIEnv *env, jclass ignore,
jobject arr, jint index, jboolean z)
{
jvalue v;
v.z = z;
JVM_SetPrimitiveArrayElement(env, arr, index, v, JVM_T_BOOLEAN);
}
JNIEXPORT void JNICALL
Java_java_lang_reflect_Array_setByte(JNIEnv *env, jclass ignore,
jobject arr, jint index, jbyte b)
{
jvalue v;
v.b = b;
JVM_SetPrimitiveArrayElement(env, arr, index, v, JVM_T_BYTE);
}
JNIEXPORT void JNICALL
Java_java_lang_reflect_Array_setChar(JNIEnv *env, jclass ignore,
jobject arr, jint index, jchar c)
{
jvalue v;
v.c = c;
JVM_SetPrimitiveArrayElement(env, arr, index, v, JVM_T_CHAR);
}
JNIEXPORT void JNICALL
Java_java_lang_reflect_Array_setShort(JNIEnv *env, jclass ignore,
jobject arr, jint index, jshort s)
{
jvalue v;
v.s = s;
JVM_SetPrimitiveArrayElement(env, arr, index, v, JVM_T_SHORT);
}
JNIEXPORT void JNICALL
Java_java_lang_reflect_Array_setInt(JNIEnv *env, jclass ignore,
jobject arr, jint index, jint i)
{
jvalue v;
v.i = i;
JVM_SetPrimitiveArrayElement(env, arr, index, v, JVM_T_INT);
}
JNIEXPORT void JNICALL
Java_java_lang_reflect_Array_setLong(JNIEnv *env, jclass ignore,
jobject arr, jint index, jlong j)
{
jvalue v;
v.j = j;
JVM_SetPrimitiveArrayElement(env, arr, index, v, JVM_T_LONG);
}
JNIEXPORT void JNICALL
Java_java_lang_reflect_Array_setFloat(JNIEnv *env, jclass ignore,
jobject arr, jint index, jfloat f)
{
jvalue v;
v.f = f;
JVM_SetPrimitiveArrayElement(env, arr, index, v, JVM_T_FLOAT);
}
JNIEXPORT void JNICALL
Java_java_lang_reflect_Array_setDouble(JNIEnv *env, jclass ignore,
jobject arr, jint index, jdouble d)
{
jvalue v;
v.d = d;
JVM_SetPrimitiveArrayElement(env, arr, index, v, JVM_T_DOUBLE);
}
/*
*
*/
JNIEXPORT jobject JNICALL
Java_java_lang_reflect_Array_newArray(JNIEnv *env, jclass ignore,
jclass eltClass, jint length)
{
return JVM_NewArray(env, eltClass, length);
}
JNIEXPORT jobject JNICALL
Java_java_lang_reflect_Array_multiNewArray(JNIEnv *env, jclass ignore,
jclass eltClass, jintArray dim)
{
return JVM_NewMultiArray(env, eltClass, dim);
}