author | goetz |
Tue, 29 Jan 2019 08:43:33 +0100 | |
changeset 53533 | bce458ffed11 |
permissions | -rw-r--r-- |
53533
bce458ffed11
8217628: Verbose ArrayIndexOutOfBoundsException message also in JNI calls.
goetz
parents:
diff
changeset
|
1 |
/* |
bce458ffed11
8217628: Verbose ArrayIndexOutOfBoundsException message also in JNI calls.
goetz
parents:
diff
changeset
|
2 |
* Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved. |
bce458ffed11
8217628: Verbose ArrayIndexOutOfBoundsException message also in JNI calls.
goetz
parents:
diff
changeset
|
3 |
* Copyright (c) 2019 SAP SE. All rights reserved. |
bce458ffed11
8217628: Verbose ArrayIndexOutOfBoundsException message also in JNI calls.
goetz
parents:
diff
changeset
|
4 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
bce458ffed11
8217628: Verbose ArrayIndexOutOfBoundsException message also in JNI calls.
goetz
parents:
diff
changeset
|
5 |
* |
bce458ffed11
8217628: Verbose ArrayIndexOutOfBoundsException message also in JNI calls.
goetz
parents:
diff
changeset
|
6 |
* This code is free software; you can redistribute it and/or modify it |
bce458ffed11
8217628: Verbose ArrayIndexOutOfBoundsException message also in JNI calls.
goetz
parents:
diff
changeset
|
7 |
* under the terms of the GNU General Public License version 2 only, as |
bce458ffed11
8217628: Verbose ArrayIndexOutOfBoundsException message also in JNI calls.
goetz
parents:
diff
changeset
|
8 |
* published by the Free Software Foundation. |
bce458ffed11
8217628: Verbose ArrayIndexOutOfBoundsException message also in JNI calls.
goetz
parents:
diff
changeset
|
9 |
* |
bce458ffed11
8217628: Verbose ArrayIndexOutOfBoundsException message also in JNI calls.
goetz
parents:
diff
changeset
|
10 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
bce458ffed11
8217628: Verbose ArrayIndexOutOfBoundsException message also in JNI calls.
goetz
parents:
diff
changeset
|
11 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
bce458ffed11
8217628: Verbose ArrayIndexOutOfBoundsException message also in JNI calls.
goetz
parents:
diff
changeset
|
12 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
bce458ffed11
8217628: Verbose ArrayIndexOutOfBoundsException message also in JNI calls.
goetz
parents:
diff
changeset
|
13 |
* version 2 for more details (a copy is included in the LICENSE file that |
bce458ffed11
8217628: Verbose ArrayIndexOutOfBoundsException message also in JNI calls.
goetz
parents:
diff
changeset
|
14 |
* accompanied this code). |
bce458ffed11
8217628: Verbose ArrayIndexOutOfBoundsException message also in JNI calls.
goetz
parents:
diff
changeset
|
15 |
* |
bce458ffed11
8217628: Verbose ArrayIndexOutOfBoundsException message also in JNI calls.
goetz
parents:
diff
changeset
|
16 |
* You should have received a copy of the GNU General Public License version |
bce458ffed11
8217628: Verbose ArrayIndexOutOfBoundsException message also in JNI calls.
goetz
parents:
diff
changeset
|
17 |
* 2 along with this work; if not, write to the Free Software Foundation, |
bce458ffed11
8217628: Verbose ArrayIndexOutOfBoundsException message also in JNI calls.
goetz
parents:
diff
changeset
|
18 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
bce458ffed11
8217628: Verbose ArrayIndexOutOfBoundsException message also in JNI calls.
goetz
parents:
diff
changeset
|
19 |
* |
bce458ffed11
8217628: Verbose ArrayIndexOutOfBoundsException message also in JNI calls.
goetz
parents:
diff
changeset
|
20 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
bce458ffed11
8217628: Verbose ArrayIndexOutOfBoundsException message also in JNI calls.
goetz
parents:
diff
changeset
|
21 |
* or visit www.oracle.com if you need additional information or have any |
bce458ffed11
8217628: Verbose ArrayIndexOutOfBoundsException message also in JNI calls.
goetz
parents:
diff
changeset
|
22 |
* questions. |
bce458ffed11
8217628: Verbose ArrayIndexOutOfBoundsException message also in JNI calls.
goetz
parents:
diff
changeset
|
23 |
*/ |
bce458ffed11
8217628: Verbose ArrayIndexOutOfBoundsException message also in JNI calls.
goetz
parents:
diff
changeset
|
24 |
|
bce458ffed11
8217628: Verbose ArrayIndexOutOfBoundsException message also in JNI calls.
goetz
parents:
diff
changeset
|
25 |
#include <jni.h> |
bce458ffed11
8217628: Verbose ArrayIndexOutOfBoundsException message also in JNI calls.
goetz
parents:
diff
changeset
|
26 |
|
bce458ffed11
8217628: Verbose ArrayIndexOutOfBoundsException message also in JNI calls.
goetz
parents:
diff
changeset
|
27 |
JNIEXPORT void JNICALL |
bce458ffed11
8217628: Verbose ArrayIndexOutOfBoundsException message also in JNI calls.
goetz
parents:
diff
changeset
|
28 |
Java_ArrayIndexOutOfBoundsExceptionTest_doNativeArrayStore(JNIEnv *env, jclass klass, |
bce458ffed11
8217628: Verbose ArrayIndexOutOfBoundsException message also in JNI calls.
goetz
parents:
diff
changeset
|
29 |
jobjectArray array, jobject element, jint index) { |
bce458ffed11
8217628: Verbose ArrayIndexOutOfBoundsException message also in JNI calls.
goetz
parents:
diff
changeset
|
30 |
(*env)->SetObjectArrayElement(env, array, index, element); |
bce458ffed11
8217628: Verbose ArrayIndexOutOfBoundsException message also in JNI calls.
goetz
parents:
diff
changeset
|
31 |
} |
bce458ffed11
8217628: Verbose ArrayIndexOutOfBoundsException message also in JNI calls.
goetz
parents:
diff
changeset
|
32 |
|
bce458ffed11
8217628: Verbose ArrayIndexOutOfBoundsException message also in JNI calls.
goetz
parents:
diff
changeset
|
33 |
JNIEXPORT jobject JNICALL |
bce458ffed11
8217628: Verbose ArrayIndexOutOfBoundsException message also in JNI calls.
goetz
parents:
diff
changeset
|
34 |
Java_ArrayIndexOutOfBoundsExceptionTest_doNativeArrayLoad(JNIEnv *env, jclass klass, |
bce458ffed11
8217628: Verbose ArrayIndexOutOfBoundsException message also in JNI calls.
goetz
parents:
diff
changeset
|
35 |
jobjectArray array, jint index) { |
bce458ffed11
8217628: Verbose ArrayIndexOutOfBoundsException message also in JNI calls.
goetz
parents:
diff
changeset
|
36 |
return (*env)->GetObjectArrayElement(env, array, index); |
bce458ffed11
8217628: Verbose ArrayIndexOutOfBoundsException message also in JNI calls.
goetz
parents:
diff
changeset
|
37 |
} |
bce458ffed11
8217628: Verbose ArrayIndexOutOfBoundsException message also in JNI calls.
goetz
parents:
diff
changeset
|
38 |
|
bce458ffed11
8217628: Verbose ArrayIndexOutOfBoundsException message also in JNI calls.
goetz
parents:
diff
changeset
|
39 |
|
bce458ffed11
8217628: Verbose ArrayIndexOutOfBoundsException message also in JNI calls.
goetz
parents:
diff
changeset
|
40 |
#define REGIONACCESS(ElementType,NameType) \ |
bce458ffed11
8217628: Verbose ArrayIndexOutOfBoundsException message also in JNI calls.
goetz
parents:
diff
changeset
|
41 |
JNIEXPORT void JNICALL \ |
bce458ffed11
8217628: Verbose ArrayIndexOutOfBoundsException message also in JNI calls.
goetz
parents:
diff
changeset
|
42 |
Java_ArrayIndexOutOfBoundsExceptionTest_doNative##NameType##ArrayRegionLoad(JNIEnv *env, jclass klass, \ |
bce458ffed11
8217628: Verbose ArrayIndexOutOfBoundsException message also in JNI calls.
goetz
parents:
diff
changeset
|
43 |
ElementType##Array array, jint start, jint len) { \ |
bce458ffed11
8217628: Verbose ArrayIndexOutOfBoundsException message also in JNI calls.
goetz
parents:
diff
changeset
|
44 |
ElementType clone[100]; \ |
bce458ffed11
8217628: Verbose ArrayIndexOutOfBoundsException message also in JNI calls.
goetz
parents:
diff
changeset
|
45 |
(*env)->Get##NameType##ArrayRegion(env, array, start, len, clone); \ |
bce458ffed11
8217628: Verbose ArrayIndexOutOfBoundsException message also in JNI calls.
goetz
parents:
diff
changeset
|
46 |
} \ |
bce458ffed11
8217628: Verbose ArrayIndexOutOfBoundsException message also in JNI calls.
goetz
parents:
diff
changeset
|
47 |
JNIEXPORT void JNICALL \ |
bce458ffed11
8217628: Verbose ArrayIndexOutOfBoundsException message also in JNI calls.
goetz
parents:
diff
changeset
|
48 |
Java_ArrayIndexOutOfBoundsExceptionTest_doNative##NameType##ArrayRegionStore(JNIEnv *env, jclass klass, \ |
bce458ffed11
8217628: Verbose ArrayIndexOutOfBoundsException message also in JNI calls.
goetz
parents:
diff
changeset
|
49 |
ElementType##Array array, jint start, jint len) { \ |
bce458ffed11
8217628: Verbose ArrayIndexOutOfBoundsException message also in JNI calls.
goetz
parents:
diff
changeset
|
50 |
ElementType content[100]; \ |
bce458ffed11
8217628: Verbose ArrayIndexOutOfBoundsException message also in JNI calls.
goetz
parents:
diff
changeset
|
51 |
(*env)->Set##NameType##ArrayRegion(env, array, start, len, content); \ |
bce458ffed11
8217628: Verbose ArrayIndexOutOfBoundsException message also in JNI calls.
goetz
parents:
diff
changeset
|
52 |
} |
bce458ffed11
8217628: Verbose ArrayIndexOutOfBoundsException message also in JNI calls.
goetz
parents:
diff
changeset
|
53 |
|
bce458ffed11
8217628: Verbose ArrayIndexOutOfBoundsException message also in JNI calls.
goetz
parents:
diff
changeset
|
54 |
REGIONACCESS(jboolean, Boolean) |
bce458ffed11
8217628: Verbose ArrayIndexOutOfBoundsException message also in JNI calls.
goetz
parents:
diff
changeset
|
55 |
REGIONACCESS(jbyte, Byte) |
bce458ffed11
8217628: Verbose ArrayIndexOutOfBoundsException message also in JNI calls.
goetz
parents:
diff
changeset
|
56 |
REGIONACCESS(jshort, Short) |
bce458ffed11
8217628: Verbose ArrayIndexOutOfBoundsException message also in JNI calls.
goetz
parents:
diff
changeset
|
57 |
REGIONACCESS(jchar, Char) |
bce458ffed11
8217628: Verbose ArrayIndexOutOfBoundsException message also in JNI calls.
goetz
parents:
diff
changeset
|
58 |
REGIONACCESS(jint, Int) |
bce458ffed11
8217628: Verbose ArrayIndexOutOfBoundsException message also in JNI calls.
goetz
parents:
diff
changeset
|
59 |
REGIONACCESS(jlong, Long) |
bce458ffed11
8217628: Verbose ArrayIndexOutOfBoundsException message also in JNI calls.
goetz
parents:
diff
changeset
|
60 |
REGIONACCESS(jfloat, Float) |
bce458ffed11
8217628: Verbose ArrayIndexOutOfBoundsException message also in JNI calls.
goetz
parents:
diff
changeset
|
61 |
REGIONACCESS(jdouble, Double) |