author | jcbeyler |
Tue, 11 Sep 2018 10:12:50 -0700 | |
changeset 51699 | 543a3fb81c4c |
parent 51551 | e409244ce72e |
permissions | -rw-r--r-- |
50260
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
1 |
/* |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
2 |
* Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
4 |
* |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
8 |
* |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
13 |
* accompanied this code). |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
14 |
* |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License version |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
18 |
* |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
21 |
* questions. |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
22 |
*/ |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
23 |
|
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
24 |
#include <stdio.h> |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
25 |
#include <string.h> |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
26 |
#include "jvmti.h" |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
27 |
#include "agent_common.h" |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
28 |
#include "JVMTITools.h" |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
29 |
|
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
30 |
extern "C" { |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
31 |
|
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
32 |
|
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
33 |
#define PASSED 0 |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
34 |
#define STATUS_FAILED 2 |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
35 |
|
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
36 |
static jvmtiEnv *jvmti = NULL; |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
37 |
static jint result = PASSED; |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
38 |
static jboolean printdump = JNI_FALSE; |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
39 |
|
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
40 |
#ifdef STATIC_BUILD |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
41 |
JNIEXPORT jint JNICALL Agent_OnLoad_isarray005(JavaVM *jvm, char *options, void *reserved) { |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
42 |
return Agent_Initialize(jvm, options, reserved); |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
43 |
} |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
44 |
JNIEXPORT jint JNICALL Agent_OnAttach_isarray005(JavaVM *jvm, char *options, void *reserved) { |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
45 |
return Agent_Initialize(jvm, options, reserved); |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
46 |
} |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
47 |
JNIEXPORT jint JNI_OnLoad_isarray005(JavaVM *jvm, char *options, void *reserved) { |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
48 |
return JNI_VERSION_1_8; |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
49 |
} |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
50 |
#endif |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
51 |
jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
52 |
jint res; |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
53 |
|
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
54 |
if (options != NULL && strcmp(options, "printdump") == 0) { |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
55 |
printdump = JNI_TRUE; |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
56 |
} |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
57 |
|
51699
543a3fb81c4c
8210385: Clean up JNI_ENV_ARG and factorize the macros for vmTestbase/jvmti[A-N] tests
jcbeyler
parents:
51551
diff
changeset
|
58 |
res = jvm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1); |
50260
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
59 |
if (res != JNI_OK || jvmti == NULL) { |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
60 |
printf("Wrong result of a valid call to GetEnv!\n"); |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
61 |
return JNI_ERR; |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
62 |
} |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
63 |
|
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
64 |
return JNI_OK; |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
65 |
} |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
66 |
|
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
67 |
char const *jbooleanToString(jboolean flag) { |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
68 |
return ((flag == JNI_TRUE) ? "true" : "false"); |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
69 |
} |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
70 |
|
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
71 |
JNIEXPORT void JNICALL |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
72 |
Java_nsk_jvmti_IsArrayClass_isarray005_check(JNIEnv *env, |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
73 |
jclass cls, jclass clazz, jboolean flag) { |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
74 |
jvmtiError err; |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
75 |
jboolean isArrayClass; |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
76 |
char *sig, *generic; |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
77 |
|
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
78 |
if (jvmti == NULL) { |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
79 |
printf("JVMTI client was not properly loaded!\n"); |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
80 |
result = STATUS_FAILED; |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
81 |
return; |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
82 |
} |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
83 |
|
51551 | 84 |
err = jvmti->GetClassSignature(clazz, &sig, &generic); |
50260
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
85 |
if (err != JVMTI_ERROR_NONE) { |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
86 |
printf("(GetClassSignature) unexpected error: %s (%d)\n", |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
87 |
TranslateError(err), err); |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
88 |
result = STATUS_FAILED; |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
89 |
} |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
90 |
|
51551 | 91 |
err = jvmti->IsArrayClass(clazz, &isArrayClass); |
50260
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
92 |
if (err != JVMTI_ERROR_NONE) { |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
93 |
printf("(IsArrayClass) unexpected error: %s (%d)\n", |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
94 |
TranslateError(err), err); |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
95 |
result = STATUS_FAILED; |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
96 |
} |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
97 |
|
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
98 |
if (printdump == JNI_TRUE) { |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
99 |
printf(">>> %s - %s\n", sig, jbooleanToString(isArrayClass)); |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
100 |
} |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
101 |
|
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
102 |
if (isArrayClass != flag) { |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
103 |
printf("(%s) wrong isArrayClass value: %s, expected: %s\n", |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
104 |
sig, jbooleanToString(isArrayClass), jbooleanToString(flag)); |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
105 |
result = STATUS_FAILED; |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
106 |
} |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
107 |
} |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
108 |
|
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
109 |
JNIEXPORT int JNICALL |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
110 |
Java_nsk_jvmti_IsArrayClass_isarray005_getRes(JNIEnv *env, jclass cls) { |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
111 |
return result; |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
112 |
} |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
113 |
|
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
114 |
} |