Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetClassSignature/getclsig004/getclsig004.cpp
40952 views
1
/*
2
* Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved.
3
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4
*
5
* This code is free software; you can redistribute it and/or modify it
6
* under the terms of the GNU General Public License version 2 only, as
7
* published by the Free Software Foundation.
8
*
9
* This code is distributed in the hope that it will be useful, but WITHOUT
10
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12
* version 2 for more details (a copy is included in the LICENSE file that
13
* accompanied this code).
14
*
15
* You should have received a copy of the GNU General Public License version
16
* 2 along with this work; if not, write to the Free Software Foundation,
17
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18
*
19
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20
* or visit www.oracle.com if you need additional information or have any
21
* questions.
22
*/
23
24
#include <stdio.h>
25
#include <string.h>
26
#include "jvmti.h"
27
#include "agent_common.h"
28
#include "JVMTITools.h"
29
30
extern "C" {
31
32
33
#define PASSED 0
34
#define STATUS_FAILED 2
35
36
static jvmtiEnv *jvmti = NULL;
37
static jint result = PASSED;
38
static jboolean printdump = JNI_FALSE;
39
static const char *sigs[] = {
40
"B",
41
"C",
42
"D",
43
"F",
44
"I",
45
"J",
46
"Ljava/lang/Object;",
47
"S",
48
"V",
49
"Z"
50
};
51
52
#ifdef STATIC_BUILD
53
JNIEXPORT jint JNICALL Agent_OnLoad_getclsig004(JavaVM *jvm, char *options, void *reserved) {
54
return Agent_Initialize(jvm, options, reserved);
55
}
56
JNIEXPORT jint JNICALL Agent_OnAttach_getclsig004(JavaVM *jvm, char *options, void *reserved) {
57
return Agent_Initialize(jvm, options, reserved);
58
}
59
JNIEXPORT jint JNI_OnLoad_getclsig004(JavaVM *jvm, char *options, void *reserved) {
60
return JNI_VERSION_1_8;
61
}
62
#endif
63
jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) {
64
jint res;
65
66
if (options != NULL && strcmp(options, "printdump") == 0) {
67
printdump = JNI_TRUE;
68
}
69
70
res = jvm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1);
71
if (res != JNI_OK || jvmti == NULL) {
72
printf("Wrong result of a valid call to GetEnv!\n");
73
return JNI_ERR;
74
}
75
76
return JNI_OK;
77
}
78
79
JNIEXPORT void JNICALL
80
Java_nsk_jvmti_GetClassSignature_getclsig004_check(JNIEnv *env,
81
jclass cls, jint i, jclass clazz) {
82
jvmtiError err;
83
char *sig, *generic;
84
85
if (jvmti == NULL) {
86
printf("JVMTI client was not properly loaded!\n");
87
result = STATUS_FAILED;
88
return;
89
}
90
91
err = jvmti->GetClassSignature(clazz, &sig, &generic);
92
if (err != JVMTI_ERROR_NONE) {
93
printf("(GetClassSignature#%d) unexpected error: %s (%d)\n",
94
i, TranslateError(err), err);
95
result = STATUS_FAILED;
96
return;
97
}
98
99
if (printdump == JNI_TRUE) {
100
printf(">>> %d: %s\n", i, sig);
101
}
102
103
if (strcmp(sig, sigs[i]) != 0) {
104
printf("(%d) wrong sig: \"%s\", expected: \"%s\"\n", i, sig, sigs[i]);
105
result = STATUS_FAILED;
106
}
107
}
108
109
JNIEXPORT int JNICALL
110
Java_nsk_jvmti_GetClassSignature_getclsig004_getRes(JNIEnv *env, jclass cls) {
111
return result;
112
}
113
114
}
115
116