Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetClassModifiers/getclmdf005/getclmdf005.cpp
40955 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
#define ACC_PUBLIC 0x0001
37
#define ACC_PRIVATE 0x0002
38
#define ACC_PROTECTED 0x0004
39
#define ACC_FINAL 0x0010
40
#define ACC_INTERFACE 0x0200
41
42
static jvmtiEnv *jvmti = NULL;
43
static jint result = PASSED;
44
static jboolean printdump = JNI_FALSE;
45
46
#ifdef STATIC_BUILD
47
JNIEXPORT jint JNICALL Agent_OnLoad_getclmdf005(JavaVM *jvm, char *options, void *reserved) {
48
return Agent_Initialize(jvm, options, reserved);
49
}
50
JNIEXPORT jint JNICALL Agent_OnAttach_getclmdf005(JavaVM *jvm, char *options, void *reserved) {
51
return Agent_Initialize(jvm, options, reserved);
52
}
53
JNIEXPORT jint JNI_OnLoad_getclmdf005(JavaVM *jvm, char *options, void *reserved) {
54
return JNI_VERSION_1_8;
55
}
56
#endif
57
jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) {
58
jint res;
59
60
if (options != NULL && strcmp(options, "printdump") == 0) {
61
printdump = JNI_TRUE;
62
}
63
64
res = jvm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1);
65
if (res != JNI_OK || jvmti == NULL) {
66
printf("Wrong result of a valid call to GetEnv!\n");
67
return JNI_ERR;
68
}
69
70
return JNI_OK;
71
}
72
73
JNIEXPORT void JNICALL
74
Java_nsk_jvmti_GetClassModifiers_getclmdf005_check(JNIEnv *env, jclass cls, jint i, jclass clazz) {
75
jvmtiError err;
76
jint modifiers;
77
78
if (jvmti == NULL) {
79
printf("JVMTI client was not properly loaded!\n");
80
result = STATUS_FAILED;
81
return;
82
}
83
84
err = jvmti->GetClassModifiers(clazz, &modifiers);
85
if (err != JVMTI_ERROR_NONE) {
86
printf("(GetClassModifiers#%d) unexpected error: %s (%d)\n",
87
i, TranslateError(err), err);
88
result = STATUS_FAILED;
89
return;
90
}
91
92
if (printdump == JNI_TRUE) {
93
printf(">>> %d: 0x%0x\n", i, modifiers);
94
}
95
96
if ((modifiers & ACC_PUBLIC) == 0) {
97
printf("(%d) ACC_PUBLIC bit should be set\n", i);
98
result = STATUS_FAILED;
99
}
100
101
if ((modifiers & ACC_FINAL) == 0) {
102
printf("(%d) ACC_FINAL bit should be set\n", i);
103
result = STATUS_FAILED;
104
}
105
106
if ((modifiers & ACC_INTERFACE) != 0) {
107
printf("(%d) ACC_INTERFACE bit should be clear\n", i);
108
result = STATUS_FAILED;
109
}
110
111
if ((modifiers & ACC_PROTECTED) != 0) {
112
printf("(%d) ACC_PROTECTED bit should be clear\n", i);
113
result = STATUS_FAILED;
114
}
115
116
if ((modifiers & ACC_PRIVATE) != 0) {
117
printf("(%d) ACC_PRIVATE bit should be clear\n", i);
118
result = STATUS_FAILED;
119
}
120
}
121
122
JNIEXPORT int JNICALL Java_nsk_jvmti_GetClassModifiers_getclmdf005_getRes(JNIEnv *env, jclass cls) {
123
return result;
124
}
125
126
}
127
128