Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetClassStatus/getclstat007/getclstat007.cpp
40952 views
1
/*
2
* Copyright (c) 2004, 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
40
#ifdef STATIC_BUILD
41
JNIEXPORT jint JNICALL Agent_OnLoad_getclstat007(JavaVM *jvm, char *options, void *reserved) {
42
return Agent_Initialize(jvm, options, reserved);
43
}
44
JNIEXPORT jint JNICALL Agent_OnAttach_getclstat007(JavaVM *jvm, char *options, void *reserved) {
45
return Agent_Initialize(jvm, options, reserved);
46
}
47
JNIEXPORT jint JNI_OnLoad_getclstat007(JavaVM *jvm, char *options, void *reserved) {
48
return JNI_VERSION_1_8;
49
}
50
#endif
51
jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) {
52
jint res;
53
54
if (options != NULL && strcmp(options, "printdump") == 0) {
55
printdump = JNI_TRUE;
56
}
57
58
res = jvm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1);
59
if (res != JNI_OK || jvmti == NULL) {
60
printf("Wrong result of a valid call to GetEnv!\n");
61
return JNI_ERR;
62
}
63
64
return JNI_OK;
65
}
66
67
JNIEXPORT void JNICALL
68
Java_nsk_jvmti_GetClassStatus_getclstat007_check(JNIEnv *env, jclass cls,
69
jint i, jclass klass, jboolean is_array) {
70
jvmtiError err;
71
jint status;
72
73
if (jvmti == NULL) {
74
printf("JVMTI client was not properly loaded!\n");
75
result = STATUS_FAILED;
76
return;
77
}
78
79
err = jvmti->GetClassStatus(klass, &status);
80
if (err != JVMTI_ERROR_NONE) {
81
printf("(GetClassStatus#%d) unexpected error: %s (%d)\n",
82
i, TranslateError(err), err);
83
result = STATUS_FAILED;
84
return;
85
}
86
87
if (printdump == JNI_TRUE) {
88
printf(">>> %d: 0x%0x\n", i, status);
89
}
90
91
if (i == 0) {
92
if ((status & JVMTI_CLASS_STATUS_VERIFIED) == 0) {
93
printf("(%d) JVMTI_CLASS_STATUS_VERIFIED bit should be set\n", i);
94
result = STATUS_FAILED;
95
}
96
if ((status & JVMTI_CLASS_STATUS_PREPARED) == 0) {
97
printf("(%d) JVMTI_CLASS_STATUS_PREPARED bit should be set\n", i);
98
result = STATUS_FAILED;
99
}
100
if ((status & JVMTI_CLASS_STATUS_INITIALIZED) == 0) {
101
printf("(%d) JVMTI_CLASS_STATUS_INITIALIZED bit should be set\n", i);
102
result = STATUS_FAILED;
103
}
104
if ((status & JVMTI_CLASS_STATUS_ERROR) != 0) {
105
printf("(%d) JVMTI_CLASS_STATUS_ERROR bit should be clear\n", i);
106
result = STATUS_FAILED;
107
}
108
if ((status & JVMTI_CLASS_STATUS_ARRAY) != 0) {
109
printf("(%d) JVMTI_CLASS_STATUS_ARRAY bit should be clear\n", i);
110
result = STATUS_FAILED;
111
}
112
if ((status & JVMTI_CLASS_STATUS_PRIMITIVE) != 0) {
113
printf("(%d) JVMTI_CLASS_STATUS_PRIMITIVEbit should be clear\n", i);
114
result = STATUS_FAILED;
115
}
116
} else if (is_array == JNI_TRUE) {
117
if ((status & JVMTI_CLASS_STATUS_ARRAY) == 0) {
118
printf("(%d) JVMTI_CLASS_STATUS_ARRAY bit should be set\n", i);
119
result = STATUS_FAILED;
120
}
121
if ((status & (~JVMTI_CLASS_STATUS_ARRAY)) != 0) {
122
printf("(%d) not JVMTI_CLASS_STATUS_ARRAY bits should be clear: 0x%0x\n",
123
i, status);
124
result = STATUS_FAILED;
125
}
126
} else {
127
if ((status & JVMTI_CLASS_STATUS_PRIMITIVE) == 0) {
128
printf("(%d) JVMTI_CLASS_STATUS_PRIMITIVE bit should be set\n", i);
129
result = STATUS_FAILED;
130
}
131
if ((status & (~JVMTI_CLASS_STATUS_PRIMITIVE)) != 0) {
132
printf("(%d) not JVMTI_CLASS_STATUS_PRIMITIVE bits should be clear: 0x%0x\n",
133
i, status);
134
result = STATUS_FAILED;
135
}
136
}
137
}
138
139
JNIEXPORT int JNICALL
140
Java_nsk_jvmti_GetClassStatus_getclstat007_getRes(JNIEnv *env, jclass cls) {
141
return result;
142
}
143
144
}
145
146