author | lana |
Thu, 23 Feb 2017 17:30:12 +0000 | |
changeset 44011 | 5eea3031ae7b |
parent 41292 | 08bd6740b8e3 |
permissions | -rw-r--r-- |
41292
08bd6740b8e3
8150758: [TESTBUG] need jvmti tests for module aware agents
ddmitriev
parents:
diff
changeset
|
1 |
/* |
08bd6740b8e3
8150758: [TESTBUG] need jvmti tests for module aware agents
ddmitriev
parents:
diff
changeset
|
2 |
* Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. |
08bd6740b8e3
8150758: [TESTBUG] need jvmti tests for module aware agents
ddmitriev
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
08bd6740b8e3
8150758: [TESTBUG] need jvmti tests for module aware agents
ddmitriev
parents:
diff
changeset
|
4 |
* |
08bd6740b8e3
8150758: [TESTBUG] need jvmti tests for module aware agents
ddmitriev
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
08bd6740b8e3
8150758: [TESTBUG] need jvmti tests for module aware agents
ddmitriev
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
08bd6740b8e3
8150758: [TESTBUG] need jvmti tests for module aware agents
ddmitriev
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. |
08bd6740b8e3
8150758: [TESTBUG] need jvmti tests for module aware agents
ddmitriev
parents:
diff
changeset
|
8 |
* |
08bd6740b8e3
8150758: [TESTBUG] need jvmti tests for module aware agents
ddmitriev
parents:
diff
changeset
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
08bd6740b8e3
8150758: [TESTBUG] need jvmti tests for module aware agents
ddmitriev
parents:
diff
changeset
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
08bd6740b8e3
8150758: [TESTBUG] need jvmti tests for module aware agents
ddmitriev
parents:
diff
changeset
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
08bd6740b8e3
8150758: [TESTBUG] need jvmti tests for module aware agents
ddmitriev
parents:
diff
changeset
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
08bd6740b8e3
8150758: [TESTBUG] need jvmti tests for module aware agents
ddmitriev
parents:
diff
changeset
|
13 |
* accompanied this code). |
08bd6740b8e3
8150758: [TESTBUG] need jvmti tests for module aware agents
ddmitriev
parents:
diff
changeset
|
14 |
* |
08bd6740b8e3
8150758: [TESTBUG] need jvmti tests for module aware agents
ddmitriev
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License version |
08bd6740b8e3
8150758: [TESTBUG] need jvmti tests for module aware agents
ddmitriev
parents:
diff
changeset
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
08bd6740b8e3
8150758: [TESTBUG] need jvmti tests for module aware agents
ddmitriev
parents:
diff
changeset
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
08bd6740b8e3
8150758: [TESTBUG] need jvmti tests for module aware agents
ddmitriev
parents:
diff
changeset
|
18 |
* |
08bd6740b8e3
8150758: [TESTBUG] need jvmti tests for module aware agents
ddmitriev
parents:
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
08bd6740b8e3
8150758: [TESTBUG] need jvmti tests for module aware agents
ddmitriev
parents:
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
08bd6740b8e3
8150758: [TESTBUG] need jvmti tests for module aware agents
ddmitriev
parents:
diff
changeset
|
21 |
* questions. |
08bd6740b8e3
8150758: [TESTBUG] need jvmti tests for module aware agents
ddmitriev
parents:
diff
changeset
|
22 |
*/ |
08bd6740b8e3
8150758: [TESTBUG] need jvmti tests for module aware agents
ddmitriev
parents:
diff
changeset
|
23 |
|
08bd6740b8e3
8150758: [TESTBUG] need jvmti tests for module aware agents
ddmitriev
parents:
diff
changeset
|
24 |
#include <stdio.h> |
08bd6740b8e3
8150758: [TESTBUG] need jvmti tests for module aware agents
ddmitriev
parents:
diff
changeset
|
25 |
#include <string.h> |
08bd6740b8e3
8150758: [TESTBUG] need jvmti tests for module aware agents
ddmitriev
parents:
diff
changeset
|
26 |
#include "jvmti.h" |
08bd6740b8e3
8150758: [TESTBUG] need jvmti tests for module aware agents
ddmitriev
parents:
diff
changeset
|
27 |
|
08bd6740b8e3
8150758: [TESTBUG] need jvmti tests for module aware agents
ddmitriev
parents:
diff
changeset
|
28 |
#ifdef __cplusplus |
08bd6740b8e3
8150758: [TESTBUG] need jvmti tests for module aware agents
ddmitriev
parents:
diff
changeset
|
29 |
extern "C" { |
08bd6740b8e3
8150758: [TESTBUG] need jvmti tests for module aware agents
ddmitriev
parents:
diff
changeset
|
30 |
#endif |
08bd6740b8e3
8150758: [TESTBUG] need jvmti tests for module aware agents
ddmitriev
parents:
diff
changeset
|
31 |
|
08bd6740b8e3
8150758: [TESTBUG] need jvmti tests for module aware agents
ddmitriev
parents:
diff
changeset
|
32 |
#ifndef JNI_ENV_ARG |
08bd6740b8e3
8150758: [TESTBUG] need jvmti tests for module aware agents
ddmitriev
parents:
diff
changeset
|
33 |
|
08bd6740b8e3
8150758: [TESTBUG] need jvmti tests for module aware agents
ddmitriev
parents:
diff
changeset
|
34 |
#ifdef __cplusplus |
08bd6740b8e3
8150758: [TESTBUG] need jvmti tests for module aware agents
ddmitriev
parents:
diff
changeset
|
35 |
#define JNI_ENV_ARG(x, y) y |
08bd6740b8e3
8150758: [TESTBUG] need jvmti tests for module aware agents
ddmitriev
parents:
diff
changeset
|
36 |
#define JNI_ENV_PTR(x) x |
08bd6740b8e3
8150758: [TESTBUG] need jvmti tests for module aware agents
ddmitriev
parents:
diff
changeset
|
37 |
#else |
08bd6740b8e3
8150758: [TESTBUG] need jvmti tests for module aware agents
ddmitriev
parents:
diff
changeset
|
38 |
#define JNI_ENV_ARG(x,y) x, y |
08bd6740b8e3
8150758: [TESTBUG] need jvmti tests for module aware agents
ddmitriev
parents:
diff
changeset
|
39 |
#define JNI_ENV_PTR(x) (*x) |
08bd6740b8e3
8150758: [TESTBUG] need jvmti tests for module aware agents
ddmitriev
parents:
diff
changeset
|
40 |
#endif |
08bd6740b8e3
8150758: [TESTBUG] need jvmti tests for module aware agents
ddmitriev
parents:
diff
changeset
|
41 |
|
08bd6740b8e3
8150758: [TESTBUG] need jvmti tests for module aware agents
ddmitriev
parents:
diff
changeset
|
42 |
#endif |
08bd6740b8e3
8150758: [TESTBUG] need jvmti tests for module aware agents
ddmitriev
parents:
diff
changeset
|
43 |
|
08bd6740b8e3
8150758: [TESTBUG] need jvmti tests for module aware agents
ddmitriev
parents:
diff
changeset
|
44 |
#define TranslateError(err) "JVMTI error" |
08bd6740b8e3
8150758: [TESTBUG] need jvmti tests for module aware agents
ddmitriev
parents:
diff
changeset
|
45 |
|
08bd6740b8e3
8150758: [TESTBUG] need jvmti tests for module aware agents
ddmitriev
parents:
diff
changeset
|
46 |
#define PASSED 0 |
08bd6740b8e3
8150758: [TESTBUG] need jvmti tests for module aware agents
ddmitriev
parents:
diff
changeset
|
47 |
#define FAILED 2 |
08bd6740b8e3
8150758: [TESTBUG] need jvmti tests for module aware agents
ddmitriev
parents:
diff
changeset
|
48 |
|
08bd6740b8e3
8150758: [TESTBUG] need jvmti tests for module aware agents
ddmitriev
parents:
diff
changeset
|
49 |
static const char *EXC_CNAME = "java/lang/Exception"; |
08bd6740b8e3
8150758: [TESTBUG] need jvmti tests for module aware agents
ddmitriev
parents:
diff
changeset
|
50 |
|
08bd6740b8e3
8150758: [TESTBUG] need jvmti tests for module aware agents
ddmitriev
parents:
diff
changeset
|
51 |
static jvmtiEnv *jvmti = NULL; |
08bd6740b8e3
8150758: [TESTBUG] need jvmti tests for module aware agents
ddmitriev
parents:
diff
changeset
|
52 |
static jint result = PASSED; |
08bd6740b8e3
8150758: [TESTBUG] need jvmti tests for module aware agents
ddmitriev
parents:
diff
changeset
|
53 |
static jboolean printdump = JNI_FALSE; |
08bd6740b8e3
8150758: [TESTBUG] need jvmti tests for module aware agents
ddmitriev
parents:
diff
changeset
|
54 |
|
08bd6740b8e3
8150758: [TESTBUG] need jvmti tests for module aware agents
ddmitriev
parents:
diff
changeset
|
55 |
static int thread_start_events_vm_start = 0; |
08bd6740b8e3
8150758: [TESTBUG] need jvmti tests for module aware agents
ddmitriev
parents:
diff
changeset
|
56 |
|
08bd6740b8e3
8150758: [TESTBUG] need jvmti tests for module aware agents
ddmitriev
parents:
diff
changeset
|
57 |
static jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved); |
08bd6740b8e3
8150758: [TESTBUG] need jvmti tests for module aware agents
ddmitriev
parents:
diff
changeset
|
58 |
|
08bd6740b8e3
8150758: [TESTBUG] need jvmti tests for module aware agents
ddmitriev
parents:
diff
changeset
|
59 |
JNIEXPORT |
08bd6740b8e3
8150758: [TESTBUG] need jvmti tests for module aware agents
ddmitriev
parents:
diff
changeset
|
60 |
jint JNICALL Agent_OnLoad(JavaVM *jvm, char *options, void *reserved) { |
08bd6740b8e3
8150758: [TESTBUG] need jvmti tests for module aware agents
ddmitriev
parents:
diff
changeset
|
61 |
return Agent_Initialize(jvm, options, reserved); |
08bd6740b8e3
8150758: [TESTBUG] need jvmti tests for module aware agents
ddmitriev
parents:
diff
changeset
|
62 |
} |
08bd6740b8e3
8150758: [TESTBUG] need jvmti tests for module aware agents
ddmitriev
parents:
diff
changeset
|
63 |
|
08bd6740b8e3
8150758: [TESTBUG] need jvmti tests for module aware agents
ddmitriev
parents:
diff
changeset
|
64 |
JNIEXPORT |
08bd6740b8e3
8150758: [TESTBUG] need jvmti tests for module aware agents
ddmitriev
parents:
diff
changeset
|
65 |
jint JNICALL Agent_OnAttach(JavaVM *jvm, char *options, void *reserved) { |
08bd6740b8e3
8150758: [TESTBUG] need jvmti tests for module aware agents
ddmitriev
parents:
diff
changeset
|
66 |
return Agent_Initialize(jvm, options, reserved); |
08bd6740b8e3
8150758: [TESTBUG] need jvmti tests for module aware agents
ddmitriev
parents:
diff
changeset
|
67 |
} |
08bd6740b8e3
8150758: [TESTBUG] need jvmti tests for module aware agents
ddmitriev
parents:
diff
changeset
|
68 |
|
08bd6740b8e3
8150758: [TESTBUG] need jvmti tests for module aware agents
ddmitriev
parents:
diff
changeset
|
69 |
JNIEXPORT |
08bd6740b8e3
8150758: [TESTBUG] need jvmti tests for module aware agents
ddmitriev
parents:
diff
changeset
|
70 |
jint JNICALL JNI_OnLoad(JavaVM *jvm, void *reserved) { |
08bd6740b8e3
8150758: [TESTBUG] need jvmti tests for module aware agents
ddmitriev
parents:
diff
changeset
|
71 |
return JNI_VERSION_9; |
08bd6740b8e3
8150758: [TESTBUG] need jvmti tests for module aware agents
ddmitriev
parents:
diff
changeset
|
72 |
} |
08bd6740b8e3
8150758: [TESTBUG] need jvmti tests for module aware agents
ddmitriev
parents:
diff
changeset
|
73 |
|
08bd6740b8e3
8150758: [TESTBUG] need jvmti tests for module aware agents
ddmitriev
parents:
diff
changeset
|
74 |
static |
08bd6740b8e3
8150758: [TESTBUG] need jvmti tests for module aware agents
ddmitriev
parents:
diff
changeset
|
75 |
jint throw_exc(JNIEnv *env, char *msg) { |
08bd6740b8e3
8150758: [TESTBUG] need jvmti tests for module aware agents
ddmitriev
parents:
diff
changeset
|
76 |
jclass exc_class = JNI_ENV_PTR(env)->FindClass(JNI_ENV_ARG(env, EXC_CNAME)); |
08bd6740b8e3
8150758: [TESTBUG] need jvmti tests for module aware agents
ddmitriev
parents:
diff
changeset
|
77 |
|
08bd6740b8e3
8150758: [TESTBUG] need jvmti tests for module aware agents
ddmitriev
parents:
diff
changeset
|
78 |
if (exc_class == NULL) { |
08bd6740b8e3
8150758: [TESTBUG] need jvmti tests for module aware agents
ddmitriev
parents:
diff
changeset
|
79 |
printf("throw_exc: Error in FindClass(env, %s)\n", EXC_CNAME); |
08bd6740b8e3
8150758: [TESTBUG] need jvmti tests for module aware agents
ddmitriev
parents:
diff
changeset
|
80 |
return -1; |
08bd6740b8e3
8150758: [TESTBUG] need jvmti tests for module aware agents
ddmitriev
parents:
diff
changeset
|
81 |
} |
08bd6740b8e3
8150758: [TESTBUG] need jvmti tests for module aware agents
ddmitriev
parents:
diff
changeset
|
82 |
return JNI_ENV_PTR(env)->ThrowNew(JNI_ENV_ARG(env, exc_class), msg); |
08bd6740b8e3
8150758: [TESTBUG] need jvmti tests for module aware agents
ddmitriev
parents:
diff
changeset
|
83 |
} |
08bd6740b8e3
8150758: [TESTBUG] need jvmti tests for module aware agents
ddmitriev
parents:
diff
changeset
|
84 |
|
08bd6740b8e3
8150758: [TESTBUG] need jvmti tests for module aware agents
ddmitriev
parents:
diff
changeset
|
85 |
|
08bd6740b8e3
8150758: [TESTBUG] need jvmti tests for module aware agents
ddmitriev
parents:
diff
changeset
|
86 |
void JNICALL Callback_ThreadStart(jvmtiEnv *jvmti_env, JNIEnv *env, jthread thread) { |
08bd6740b8e3
8150758: [TESTBUG] need jvmti tests for module aware agents
ddmitriev
parents:
diff
changeset
|
87 |
jvmtiError err; |
08bd6740b8e3
8150758: [TESTBUG] need jvmti tests for module aware agents
ddmitriev
parents:
diff
changeset
|
88 |
jvmtiPhase phase; |
08bd6740b8e3
8150758: [TESTBUG] need jvmti tests for module aware agents
ddmitriev
parents:
diff
changeset
|
89 |
|
08bd6740b8e3
8150758: [TESTBUG] need jvmti tests for module aware agents
ddmitriev
parents:
diff
changeset
|
90 |
err = (*jvmti)->GetPhase(jvmti_env,&phase); |
08bd6740b8e3
8150758: [TESTBUG] need jvmti tests for module aware agents
ddmitriev
parents:
diff
changeset
|
91 |
if (err != JVMTI_ERROR_NONE) { |
08bd6740b8e3
8150758: [TESTBUG] need jvmti tests for module aware agents
ddmitriev
parents:
diff
changeset
|
92 |
printf("ThreadStart event: GetPhase error: %s (%d)\n", TranslateError(err), err); |
08bd6740b8e3
8150758: [TESTBUG] need jvmti tests for module aware agents
ddmitriev
parents:
diff
changeset
|
93 |
result = FAILED; |
08bd6740b8e3
8150758: [TESTBUG] need jvmti tests for module aware agents
ddmitriev
parents:
diff
changeset
|
94 |
return; |
08bd6740b8e3
8150758: [TESTBUG] need jvmti tests for module aware agents
ddmitriev
parents:
diff
changeset
|
95 |
} |
08bd6740b8e3
8150758: [TESTBUG] need jvmti tests for module aware agents
ddmitriev
parents:
diff
changeset
|
96 |
|
08bd6740b8e3
8150758: [TESTBUG] need jvmti tests for module aware agents
ddmitriev
parents:
diff
changeset
|
97 |
if (phase == JVMTI_PHASE_START) { |
08bd6740b8e3
8150758: [TESTBUG] need jvmti tests for module aware agents
ddmitriev
parents:
diff
changeset
|
98 |
thread_start_events_vm_start++; |
08bd6740b8e3
8150758: [TESTBUG] need jvmti tests for module aware agents
ddmitriev
parents:
diff
changeset
|
99 |
} |
08bd6740b8e3
8150758: [TESTBUG] need jvmti tests for module aware agents
ddmitriev
parents:
diff
changeset
|
100 |
|
08bd6740b8e3
8150758: [TESTBUG] need jvmti tests for module aware agents
ddmitriev
parents:
diff
changeset
|
101 |
if (printdump == JNI_TRUE) { |
08bd6740b8e3
8150758: [TESTBUG] need jvmti tests for module aware agents
ddmitriev
parents:
diff
changeset
|
102 |
printf(">>> ThreadStart event: phase(%d)\n", phase); |
08bd6740b8e3
8150758: [TESTBUG] need jvmti tests for module aware agents
ddmitriev
parents:
diff
changeset
|
103 |
} |
08bd6740b8e3
8150758: [TESTBUG] need jvmti tests for module aware agents
ddmitriev
parents:
diff
changeset
|
104 |
} |
08bd6740b8e3
8150758: [TESTBUG] need jvmti tests for module aware agents
ddmitriev
parents:
diff
changeset
|
105 |
|
08bd6740b8e3
8150758: [TESTBUG] need jvmti tests for module aware agents
ddmitriev
parents:
diff
changeset
|
106 |
static |
08bd6740b8e3
8150758: [TESTBUG] need jvmti tests for module aware agents
ddmitriev
parents:
diff
changeset
|
107 |
jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { |
08bd6740b8e3
8150758: [TESTBUG] need jvmti tests for module aware agents
ddmitriev
parents:
diff
changeset
|
108 |
jint res, size; |
08bd6740b8e3
8150758: [TESTBUG] need jvmti tests for module aware agents
ddmitriev
parents:
diff
changeset
|
109 |
jvmtiCapabilities caps; |
08bd6740b8e3
8150758: [TESTBUG] need jvmti tests for module aware agents
ddmitriev
parents:
diff
changeset
|
110 |
jvmtiEventCallbacks callbacks; |
08bd6740b8e3
8150758: [TESTBUG] need jvmti tests for module aware agents
ddmitriev
parents:
diff
changeset
|
111 |
jvmtiError err; |
08bd6740b8e3
8150758: [TESTBUG] need jvmti tests for module aware agents
ddmitriev
parents:
diff
changeset
|
112 |
|
08bd6740b8e3
8150758: [TESTBUG] need jvmti tests for module aware agents
ddmitriev
parents:
diff
changeset
|
113 |
if (options != NULL && strcmp(options, "printdump") == 0) { |
08bd6740b8e3
8150758: [TESTBUG] need jvmti tests for module aware agents
ddmitriev
parents:
diff
changeset
|
114 |
printdump = JNI_TRUE; |
08bd6740b8e3
8150758: [TESTBUG] need jvmti tests for module aware agents
ddmitriev
parents:
diff
changeset
|
115 |
} |
08bd6740b8e3
8150758: [TESTBUG] need jvmti tests for module aware agents
ddmitriev
parents:
diff
changeset
|
116 |
|
08bd6740b8e3
8150758: [TESTBUG] need jvmti tests for module aware agents
ddmitriev
parents:
diff
changeset
|
117 |
res = JNI_ENV_PTR(jvm)->GetEnv(JNI_ENV_ARG(jvm, (void **) &jvmti), |
08bd6740b8e3
8150758: [TESTBUG] need jvmti tests for module aware agents
ddmitriev
parents:
diff
changeset
|
118 |
JVMTI_VERSION_9); |
08bd6740b8e3
8150758: [TESTBUG] need jvmti tests for module aware agents
ddmitriev
parents:
diff
changeset
|
119 |
if (res != JNI_OK || jvmti == NULL) { |
08bd6740b8e3
8150758: [TESTBUG] need jvmti tests for module aware agents
ddmitriev
parents:
diff
changeset
|
120 |
printf(" Error: wrong result of a valid call to GetEnv!\n"); |
08bd6740b8e3
8150758: [TESTBUG] need jvmti tests for module aware agents
ddmitriev
parents:
diff
changeset
|
121 |
return JNI_ERR; |
08bd6740b8e3
8150758: [TESTBUG] need jvmti tests for module aware agents
ddmitriev
parents:
diff
changeset
|
122 |
} |
08bd6740b8e3
8150758: [TESTBUG] need jvmti tests for module aware agents
ddmitriev
parents:
diff
changeset
|
123 |
|
08bd6740b8e3
8150758: [TESTBUG] need jvmti tests for module aware agents
ddmitriev
parents:
diff
changeset
|
124 |
printf("Enabling following capability: can_generate_early_vmstart\n"); |
08bd6740b8e3
8150758: [TESTBUG] need jvmti tests for module aware agents
ddmitriev
parents:
diff
changeset
|
125 |
memset(&caps, 0, sizeof(caps)); |
08bd6740b8e3
8150758: [TESTBUG] need jvmti tests for module aware agents
ddmitriev
parents:
diff
changeset
|
126 |
caps.can_generate_early_vmstart = 1; |
08bd6740b8e3
8150758: [TESTBUG] need jvmti tests for module aware agents
ddmitriev
parents:
diff
changeset
|
127 |
|
08bd6740b8e3
8150758: [TESTBUG] need jvmti tests for module aware agents
ddmitriev
parents:
diff
changeset
|
128 |
err = (*jvmti)->AddCapabilities(jvmti, &caps); |
08bd6740b8e3
8150758: [TESTBUG] need jvmti tests for module aware agents
ddmitriev
parents:
diff
changeset
|
129 |
if (err != JVMTI_ERROR_NONE) { |
08bd6740b8e3
8150758: [TESTBUG] need jvmti tests for module aware agents
ddmitriev
parents:
diff
changeset
|
130 |
printf(" Error in AddCapabilites: %s (%d)\n", TranslateError(err), err); |
08bd6740b8e3
8150758: [TESTBUG] need jvmti tests for module aware agents
ddmitriev
parents:
diff
changeset
|
131 |
return JNI_ERR; |
08bd6740b8e3
8150758: [TESTBUG] need jvmti tests for module aware agents
ddmitriev
parents:
diff
changeset
|
132 |
} |
08bd6740b8e3
8150758: [TESTBUG] need jvmti tests for module aware agents
ddmitriev
parents:
diff
changeset
|
133 |
|
08bd6740b8e3
8150758: [TESTBUG] need jvmti tests for module aware agents
ddmitriev
parents:
diff
changeset
|
134 |
size = (jint)sizeof(callbacks); |
08bd6740b8e3
8150758: [TESTBUG] need jvmti tests for module aware agents
ddmitriev
parents:
diff
changeset
|
135 |
|
08bd6740b8e3
8150758: [TESTBUG] need jvmti tests for module aware agents
ddmitriev
parents:
diff
changeset
|
136 |
memset(&callbacks, 0, sizeof(callbacks)); |
08bd6740b8e3
8150758: [TESTBUG] need jvmti tests for module aware agents
ddmitriev
parents:
diff
changeset
|
137 |
callbacks.ThreadStart = Callback_ThreadStart; |
08bd6740b8e3
8150758: [TESTBUG] need jvmti tests for module aware agents
ddmitriev
parents:
diff
changeset
|
138 |
|
08bd6740b8e3
8150758: [TESTBUG] need jvmti tests for module aware agents
ddmitriev
parents:
diff
changeset
|
139 |
err = (*jvmti)->SetEventCallbacks(jvmti, &callbacks, size); |
08bd6740b8e3
8150758: [TESTBUG] need jvmti tests for module aware agents
ddmitriev
parents:
diff
changeset
|
140 |
if (err != JVMTI_ERROR_NONE) { |
08bd6740b8e3
8150758: [TESTBUG] need jvmti tests for module aware agents
ddmitriev
parents:
diff
changeset
|
141 |
printf(" Error in SetEventCallbacks: %s (%d)\n", TranslateError(err), err); |
08bd6740b8e3
8150758: [TESTBUG] need jvmti tests for module aware agents
ddmitriev
parents:
diff
changeset
|
142 |
return JNI_ERR; |
08bd6740b8e3
8150758: [TESTBUG] need jvmti tests for module aware agents
ddmitriev
parents:
diff
changeset
|
143 |
} |
08bd6740b8e3
8150758: [TESTBUG] need jvmti tests for module aware agents
ddmitriev
parents:
diff
changeset
|
144 |
|
08bd6740b8e3
8150758: [TESTBUG] need jvmti tests for module aware agents
ddmitriev
parents:
diff
changeset
|
145 |
err = (*jvmti)->SetEventNotificationMode(jvmti, JVMTI_ENABLE, JVMTI_EVENT_THREAD_START, NULL); |
08bd6740b8e3
8150758: [TESTBUG] need jvmti tests for module aware agents
ddmitriev
parents:
diff
changeset
|
146 |
if (err != JVMTI_ERROR_NONE) { |
08bd6740b8e3
8150758: [TESTBUG] need jvmti tests for module aware agents
ddmitriev
parents:
diff
changeset
|
147 |
printf(" Error in SetEventNotificationMode: %s (%d)\n", TranslateError(err), err); |
08bd6740b8e3
8150758: [TESTBUG] need jvmti tests for module aware agents
ddmitriev
parents:
diff
changeset
|
148 |
return JNI_ERR; |
08bd6740b8e3
8150758: [TESTBUG] need jvmti tests for module aware agents
ddmitriev
parents:
diff
changeset
|
149 |
} |
08bd6740b8e3
8150758: [TESTBUG] need jvmti tests for module aware agents
ddmitriev
parents:
diff
changeset
|
150 |
|
08bd6740b8e3
8150758: [TESTBUG] need jvmti tests for module aware agents
ddmitriev
parents:
diff
changeset
|
151 |
return JNI_OK; |
08bd6740b8e3
8150758: [TESTBUG] need jvmti tests for module aware agents
ddmitriev
parents:
diff
changeset
|
152 |
} |
08bd6740b8e3
8150758: [TESTBUG] need jvmti tests for module aware agents
ddmitriev
parents:
diff
changeset
|
153 |
|
08bd6740b8e3
8150758: [TESTBUG] need jvmti tests for module aware agents
ddmitriev
parents:
diff
changeset
|
154 |
JNIEXPORT jint JNICALL |
08bd6740b8e3
8150758: [TESTBUG] need jvmti tests for module aware agents
ddmitriev
parents:
diff
changeset
|
155 |
Java_MAAThreadStart_check(JNIEnv *env, jclass cls) { |
08bd6740b8e3
8150758: [TESTBUG] need jvmti tests for module aware agents
ddmitriev
parents:
diff
changeset
|
156 |
jobject loader = NULL; |
08bd6740b8e3
8150758: [TESTBUG] need jvmti tests for module aware agents
ddmitriev
parents:
diff
changeset
|
157 |
|
08bd6740b8e3
8150758: [TESTBUG] need jvmti tests for module aware agents
ddmitriev
parents:
diff
changeset
|
158 |
if (jvmti == NULL) { |
08bd6740b8e3
8150758: [TESTBUG] need jvmti tests for module aware agents
ddmitriev
parents:
diff
changeset
|
159 |
throw_exc(env, "JVMTI client was not properly loaded!\n"); |
08bd6740b8e3
8150758: [TESTBUG] need jvmti tests for module aware agents
ddmitriev
parents:
diff
changeset
|
160 |
return FAILED; |
08bd6740b8e3
8150758: [TESTBUG] need jvmti tests for module aware agents
ddmitriev
parents:
diff
changeset
|
161 |
} |
08bd6740b8e3
8150758: [TESTBUG] need jvmti tests for module aware agents
ddmitriev
parents:
diff
changeset
|
162 |
|
08bd6740b8e3
8150758: [TESTBUG] need jvmti tests for module aware agents
ddmitriev
parents:
diff
changeset
|
163 |
/* |
08bd6740b8e3
8150758: [TESTBUG] need jvmti tests for module aware agents
ddmitriev
parents:
diff
changeset
|
164 |
* Expecting that ThreadStart events are sent during VM Start phase when |
08bd6740b8e3
8150758: [TESTBUG] need jvmti tests for module aware agents
ddmitriev
parents:
diff
changeset
|
165 |
* can_generate_early_vmstart capability is enabled. |
08bd6740b8e3
8150758: [TESTBUG] need jvmti tests for module aware agents
ddmitriev
parents:
diff
changeset
|
166 |
*/ |
08bd6740b8e3
8150758: [TESTBUG] need jvmti tests for module aware agents
ddmitriev
parents:
diff
changeset
|
167 |
if (thread_start_events_vm_start == 0) { |
08bd6740b8e3
8150758: [TESTBUG] need jvmti tests for module aware agents
ddmitriev
parents:
diff
changeset
|
168 |
throw_exc(env, "Didn't get ThreadStart events in VM early start phase!\n"); |
08bd6740b8e3
8150758: [TESTBUG] need jvmti tests for module aware agents
ddmitriev
parents:
diff
changeset
|
169 |
return FAILED; |
08bd6740b8e3
8150758: [TESTBUG] need jvmti tests for module aware agents
ddmitriev
parents:
diff
changeset
|
170 |
} |
08bd6740b8e3
8150758: [TESTBUG] need jvmti tests for module aware agents
ddmitriev
parents:
diff
changeset
|
171 |
|
08bd6740b8e3
8150758: [TESTBUG] need jvmti tests for module aware agents
ddmitriev
parents:
diff
changeset
|
172 |
return result; |
08bd6740b8e3
8150758: [TESTBUG] need jvmti tests for module aware agents
ddmitriev
parents:
diff
changeset
|
173 |
} |
08bd6740b8e3
8150758: [TESTBUG] need jvmti tests for module aware agents
ddmitriev
parents:
diff
changeset
|
174 |
|
08bd6740b8e3
8150758: [TESTBUG] need jvmti tests for module aware agents
ddmitriev
parents:
diff
changeset
|
175 |
#ifdef __cplusplus |
08bd6740b8e3
8150758: [TESTBUG] need jvmti tests for module aware agents
ddmitriev
parents:
diff
changeset
|
176 |
} |
08bd6740b8e3
8150758: [TESTBUG] need jvmti tests for module aware agents
ddmitriev
parents:
diff
changeset
|
177 |
#endif |