author | rrich |
Tue, 08 Oct 2019 15:30:39 +0200 | |
changeset 58512 | 5185bc8dcbb1 |
permissions | -rw-r--r-- |
58512
5185bc8dcbb1
8230677: Should disable Escape Analysis if JVMTI capability can_get_owned_monitor_info was taken
rrich
parents:
diff
changeset
|
1 |
/* |
5185bc8dcbb1
8230677: Should disable Escape Analysis if JVMTI capability can_get_owned_monitor_info was taken
rrich
parents:
diff
changeset
|
2 |
* Copyright (c) 2019 SAP SE. All rights reserved. |
5185bc8dcbb1
8230677: Should disable Escape Analysis if JVMTI capability can_get_owned_monitor_info was taken
rrich
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
5185bc8dcbb1
8230677: Should disable Escape Analysis if JVMTI capability can_get_owned_monitor_info was taken
rrich
parents:
diff
changeset
|
4 |
* |
5185bc8dcbb1
8230677: Should disable Escape Analysis if JVMTI capability can_get_owned_monitor_info was taken
rrich
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
5185bc8dcbb1
8230677: Should disable Escape Analysis if JVMTI capability can_get_owned_monitor_info was taken
rrich
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
5185bc8dcbb1
8230677: Should disable Escape Analysis if JVMTI capability can_get_owned_monitor_info was taken
rrich
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. |
5185bc8dcbb1
8230677: Should disable Escape Analysis if JVMTI capability can_get_owned_monitor_info was taken
rrich
parents:
diff
changeset
|
8 |
* |
5185bc8dcbb1
8230677: Should disable Escape Analysis if JVMTI capability can_get_owned_monitor_info was taken
rrich
parents:
diff
changeset
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
5185bc8dcbb1
8230677: Should disable Escape Analysis if JVMTI capability can_get_owned_monitor_info was taken
rrich
parents:
diff
changeset
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
5185bc8dcbb1
8230677: Should disable Escape Analysis if JVMTI capability can_get_owned_monitor_info was taken
rrich
parents:
diff
changeset
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
5185bc8dcbb1
8230677: Should disable Escape Analysis if JVMTI capability can_get_owned_monitor_info was taken
rrich
parents:
diff
changeset
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
5185bc8dcbb1
8230677: Should disable Escape Analysis if JVMTI capability can_get_owned_monitor_info was taken
rrich
parents:
diff
changeset
|
13 |
* accompanied this code). |
5185bc8dcbb1
8230677: Should disable Escape Analysis if JVMTI capability can_get_owned_monitor_info was taken
rrich
parents:
diff
changeset
|
14 |
* |
5185bc8dcbb1
8230677: Should disable Escape Analysis if JVMTI capability can_get_owned_monitor_info was taken
rrich
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License version |
5185bc8dcbb1
8230677: Should disable Escape Analysis if JVMTI capability can_get_owned_monitor_info was taken
rrich
parents:
diff
changeset
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
5185bc8dcbb1
8230677: Should disable Escape Analysis if JVMTI capability can_get_owned_monitor_info was taken
rrich
parents:
diff
changeset
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
5185bc8dcbb1
8230677: Should disable Escape Analysis if JVMTI capability can_get_owned_monitor_info was taken
rrich
parents:
diff
changeset
|
18 |
* |
5185bc8dcbb1
8230677: Should disable Escape Analysis if JVMTI capability can_get_owned_monitor_info was taken
rrich
parents:
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
5185bc8dcbb1
8230677: Should disable Escape Analysis if JVMTI capability can_get_owned_monitor_info was taken
rrich
parents:
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
5185bc8dcbb1
8230677: Should disable Escape Analysis if JVMTI capability can_get_owned_monitor_info was taken
rrich
parents:
diff
changeset
|
21 |
* questions. |
5185bc8dcbb1
8230677: Should disable Escape Analysis if JVMTI capability can_get_owned_monitor_info was taken
rrich
parents:
diff
changeset
|
22 |
*/ |
5185bc8dcbb1
8230677: Should disable Escape Analysis if JVMTI capability can_get_owned_monitor_info was taken
rrich
parents:
diff
changeset
|
23 |
|
5185bc8dcbb1
8230677: Should disable Escape Analysis if JVMTI capability can_get_owned_monitor_info was taken
rrich
parents:
diff
changeset
|
24 |
#include <stdio.h> |
5185bc8dcbb1
8230677: Should disable Escape Analysis if JVMTI capability can_get_owned_monitor_info was taken
rrich
parents:
diff
changeset
|
25 |
#include <string.h> |
5185bc8dcbb1
8230677: Should disable Escape Analysis if JVMTI capability can_get_owned_monitor_info was taken
rrich
parents:
diff
changeset
|
26 |
#include "jvmti.h" |
5185bc8dcbb1
8230677: Should disable Escape Analysis if JVMTI capability can_get_owned_monitor_info was taken
rrich
parents:
diff
changeset
|
27 |
#include "jni.h" |
5185bc8dcbb1
8230677: Should disable Escape Analysis if JVMTI capability can_get_owned_monitor_info was taken
rrich
parents:
diff
changeset
|
28 |
|
5185bc8dcbb1
8230677: Should disable Escape Analysis if JVMTI capability can_get_owned_monitor_info was taken
rrich
parents:
diff
changeset
|
29 |
#ifdef __cplusplus |
5185bc8dcbb1
8230677: Should disable Escape Analysis if JVMTI capability can_get_owned_monitor_info was taken
rrich
parents:
diff
changeset
|
30 |
extern "C" { |
5185bc8dcbb1
8230677: Should disable Escape Analysis if JVMTI capability can_get_owned_monitor_info was taken
rrich
parents:
diff
changeset
|
31 |
#endif |
5185bc8dcbb1
8230677: Should disable Escape Analysis if JVMTI capability can_get_owned_monitor_info was taken
rrich
parents:
diff
changeset
|
32 |
|
5185bc8dcbb1
8230677: Should disable Escape Analysis if JVMTI capability can_get_owned_monitor_info was taken
rrich
parents:
diff
changeset
|
33 |
#ifndef JNI_ENV_ARG |
5185bc8dcbb1
8230677: Should disable Escape Analysis if JVMTI capability can_get_owned_monitor_info was taken
rrich
parents:
diff
changeset
|
34 |
|
5185bc8dcbb1
8230677: Should disable Escape Analysis if JVMTI capability can_get_owned_monitor_info was taken
rrich
parents:
diff
changeset
|
35 |
#ifdef __cplusplus |
5185bc8dcbb1
8230677: Should disable Escape Analysis if JVMTI capability can_get_owned_monitor_info was taken
rrich
parents:
diff
changeset
|
36 |
#define JNI_ENV_ARG(x, y) y |
5185bc8dcbb1
8230677: Should disable Escape Analysis if JVMTI capability can_get_owned_monitor_info was taken
rrich
parents:
diff
changeset
|
37 |
#define JNI_ENV_PTR(x) x |
5185bc8dcbb1
8230677: Should disable Escape Analysis if JVMTI capability can_get_owned_monitor_info was taken
rrich
parents:
diff
changeset
|
38 |
#else |
5185bc8dcbb1
8230677: Should disable Escape Analysis if JVMTI capability can_get_owned_monitor_info was taken
rrich
parents:
diff
changeset
|
39 |
#define JNI_ENV_ARG(x,y) x, y |
5185bc8dcbb1
8230677: Should disable Escape Analysis if JVMTI capability can_get_owned_monitor_info was taken
rrich
parents:
diff
changeset
|
40 |
#define JNI_ENV_PTR(x) (*x) |
5185bc8dcbb1
8230677: Should disable Escape Analysis if JVMTI capability can_get_owned_monitor_info was taken
rrich
parents:
diff
changeset
|
41 |
#endif |
5185bc8dcbb1
8230677: Should disable Escape Analysis if JVMTI capability can_get_owned_monitor_info was taken
rrich
parents:
diff
changeset
|
42 |
|
5185bc8dcbb1
8230677: Should disable Escape Analysis if JVMTI capability can_get_owned_monitor_info was taken
rrich
parents:
diff
changeset
|
43 |
#endif |
5185bc8dcbb1
8230677: Should disable Escape Analysis if JVMTI capability can_get_owned_monitor_info was taken
rrich
parents:
diff
changeset
|
44 |
|
5185bc8dcbb1
8230677: Should disable Escape Analysis if JVMTI capability can_get_owned_monitor_info was taken
rrich
parents:
diff
changeset
|
45 |
#define FAILED -1 |
5185bc8dcbb1
8230677: Should disable Escape Analysis if JVMTI capability can_get_owned_monitor_info was taken
rrich
parents:
diff
changeset
|
46 |
|
5185bc8dcbb1
8230677: Should disable Escape Analysis if JVMTI capability can_get_owned_monitor_info was taken
rrich
parents:
diff
changeset
|
47 |
static jvmtiEnv *jvmti; |
5185bc8dcbb1
8230677: Should disable Escape Analysis if JVMTI capability can_get_owned_monitor_info was taken
rrich
parents:
diff
changeset
|
48 |
|
5185bc8dcbb1
8230677: Should disable Escape Analysis if JVMTI capability can_get_owned_monitor_info was taken
rrich
parents:
diff
changeset
|
49 |
static jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved); |
5185bc8dcbb1
8230677: Should disable Escape Analysis if JVMTI capability can_get_owned_monitor_info was taken
rrich
parents:
diff
changeset
|
50 |
|
5185bc8dcbb1
8230677: Should disable Escape Analysis if JVMTI capability can_get_owned_monitor_info was taken
rrich
parents:
diff
changeset
|
51 |
static void ShowErrorMessage(jvmtiEnv *jvmti, jvmtiError errCode, const char *message) { |
5185bc8dcbb1
8230677: Should disable Escape Analysis if JVMTI capability can_get_owned_monitor_info was taken
rrich
parents:
diff
changeset
|
52 |
char *errMsg; |
5185bc8dcbb1
8230677: Should disable Escape Analysis if JVMTI capability can_get_owned_monitor_info was taken
rrich
parents:
diff
changeset
|
53 |
jvmtiError result; |
5185bc8dcbb1
8230677: Should disable Escape Analysis if JVMTI capability can_get_owned_monitor_info was taken
rrich
parents:
diff
changeset
|
54 |
|
5185bc8dcbb1
8230677: Should disable Escape Analysis if JVMTI capability can_get_owned_monitor_info was taken
rrich
parents:
diff
changeset
|
55 |
result = (*jvmti)->GetErrorName(jvmti, errCode, &errMsg); |
5185bc8dcbb1
8230677: Should disable Escape Analysis if JVMTI capability can_get_owned_monitor_info was taken
rrich
parents:
diff
changeset
|
56 |
if (result == JVMTI_ERROR_NONE) { |
5185bc8dcbb1
8230677: Should disable Escape Analysis if JVMTI capability can_get_owned_monitor_info was taken
rrich
parents:
diff
changeset
|
57 |
fprintf(stderr, "%s: %s (%d)\n", message, errMsg, errCode); |
5185bc8dcbb1
8230677: Should disable Escape Analysis if JVMTI capability can_get_owned_monitor_info was taken
rrich
parents:
diff
changeset
|
58 |
(*jvmti)->Deallocate(jvmti, (unsigned char *)errMsg); |
5185bc8dcbb1
8230677: Should disable Escape Analysis if JVMTI capability can_get_owned_monitor_info was taken
rrich
parents:
diff
changeset
|
59 |
} else { |
5185bc8dcbb1
8230677: Should disable Escape Analysis if JVMTI capability can_get_owned_monitor_info was taken
rrich
parents:
diff
changeset
|
60 |
fprintf(stderr, "%s (%d)\n", message, errCode); |
5185bc8dcbb1
8230677: Should disable Escape Analysis if JVMTI capability can_get_owned_monitor_info was taken
rrich
parents:
diff
changeset
|
61 |
} |
5185bc8dcbb1
8230677: Should disable Escape Analysis if JVMTI capability can_get_owned_monitor_info was taken
rrich
parents:
diff
changeset
|
62 |
} |
5185bc8dcbb1
8230677: Should disable Escape Analysis if JVMTI capability can_get_owned_monitor_info was taken
rrich
parents:
diff
changeset
|
63 |
|
5185bc8dcbb1
8230677: Should disable Escape Analysis if JVMTI capability can_get_owned_monitor_info was taken
rrich
parents:
diff
changeset
|
64 |
JNIEXPORT jint JNICALL |
5185bc8dcbb1
8230677: Should disable Escape Analysis if JVMTI capability can_get_owned_monitor_info was taken
rrich
parents:
diff
changeset
|
65 |
Agent_OnLoad(JavaVM *jvm, char *options, void *reserved) { |
5185bc8dcbb1
8230677: Should disable Escape Analysis if JVMTI capability can_get_owned_monitor_info was taken
rrich
parents:
diff
changeset
|
66 |
return Agent_Initialize(jvm, options, reserved); |
5185bc8dcbb1
8230677: Should disable Escape Analysis if JVMTI capability can_get_owned_monitor_info was taken
rrich
parents:
diff
changeset
|
67 |
} |
5185bc8dcbb1
8230677: Should disable Escape Analysis if JVMTI capability can_get_owned_monitor_info was taken
rrich
parents:
diff
changeset
|
68 |
|
5185bc8dcbb1
8230677: Should disable Escape Analysis if JVMTI capability can_get_owned_monitor_info was taken
rrich
parents:
diff
changeset
|
69 |
JNIEXPORT jint JNICALL |
5185bc8dcbb1
8230677: Should disable Escape Analysis if JVMTI capability can_get_owned_monitor_info was taken
rrich
parents:
diff
changeset
|
70 |
Agent_OnAttach(JavaVM *jvm, char *options, void *reserved) { |
5185bc8dcbb1
8230677: Should disable Escape Analysis if JVMTI capability can_get_owned_monitor_info was taken
rrich
parents:
diff
changeset
|
71 |
return Agent_Initialize(jvm, options, reserved); |
5185bc8dcbb1
8230677: Should disable Escape Analysis if JVMTI capability can_get_owned_monitor_info was taken
rrich
parents:
diff
changeset
|
72 |
} |
5185bc8dcbb1
8230677: Should disable Escape Analysis if JVMTI capability can_get_owned_monitor_info was taken
rrich
parents:
diff
changeset
|
73 |
|
5185bc8dcbb1
8230677: Should disable Escape Analysis if JVMTI capability can_get_owned_monitor_info was taken
rrich
parents:
diff
changeset
|
74 |
JNIEXPORT jint JNICALL |
5185bc8dcbb1
8230677: Should disable Escape Analysis if JVMTI capability can_get_owned_monitor_info was taken
rrich
parents:
diff
changeset
|
75 |
JNI_OnLoad(JavaVM *jvm, void *reserved) { |
5185bc8dcbb1
8230677: Should disable Escape Analysis if JVMTI capability can_get_owned_monitor_info was taken
rrich
parents:
diff
changeset
|
76 |
jint res; |
5185bc8dcbb1
8230677: Should disable Escape Analysis if JVMTI capability can_get_owned_monitor_info was taken
rrich
parents:
diff
changeset
|
77 |
JNIEnv *env; |
5185bc8dcbb1
8230677: Should disable Escape Analysis if JVMTI capability can_get_owned_monitor_info was taken
rrich
parents:
diff
changeset
|
78 |
|
5185bc8dcbb1
8230677: Should disable Escape Analysis if JVMTI capability can_get_owned_monitor_info was taken
rrich
parents:
diff
changeset
|
79 |
res = JNI_ENV_PTR(jvm)->GetEnv(JNI_ENV_ARG(jvm, (void **) &env), |
5185bc8dcbb1
8230677: Should disable Escape Analysis if JVMTI capability can_get_owned_monitor_info was taken
rrich
parents:
diff
changeset
|
80 |
JNI_VERSION_9); |
5185bc8dcbb1
8230677: Should disable Escape Analysis if JVMTI capability can_get_owned_monitor_info was taken
rrich
parents:
diff
changeset
|
81 |
if (res != JNI_OK || env == NULL) { |
5185bc8dcbb1
8230677: Should disable Escape Analysis if JVMTI capability can_get_owned_monitor_info was taken
rrich
parents:
diff
changeset
|
82 |
fprintf(stderr, "Error: GetEnv call failed(%d)!\n", res); |
5185bc8dcbb1
8230677: Should disable Escape Analysis if JVMTI capability can_get_owned_monitor_info was taken
rrich
parents:
diff
changeset
|
83 |
return JNI_ERR; |
5185bc8dcbb1
8230677: Should disable Escape Analysis if JVMTI capability can_get_owned_monitor_info was taken
rrich
parents:
diff
changeset
|
84 |
} |
5185bc8dcbb1
8230677: Should disable Escape Analysis if JVMTI capability can_get_owned_monitor_info was taken
rrich
parents:
diff
changeset
|
85 |
|
5185bc8dcbb1
8230677: Should disable Escape Analysis if JVMTI capability can_get_owned_monitor_info was taken
rrich
parents:
diff
changeset
|
86 |
return JNI_VERSION_9; |
5185bc8dcbb1
8230677: Should disable Escape Analysis if JVMTI capability can_get_owned_monitor_info was taken
rrich
parents:
diff
changeset
|
87 |
} |
5185bc8dcbb1
8230677: Should disable Escape Analysis if JVMTI capability can_get_owned_monitor_info was taken
rrich
parents:
diff
changeset
|
88 |
|
5185bc8dcbb1
8230677: Should disable Escape Analysis if JVMTI capability can_get_owned_monitor_info was taken
rrich
parents:
diff
changeset
|
89 |
static |
5185bc8dcbb1
8230677: Should disable Escape Analysis if JVMTI capability can_get_owned_monitor_info was taken
rrich
parents:
diff
changeset
|
90 |
jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { |
5185bc8dcbb1
8230677: Should disable Escape Analysis if JVMTI capability can_get_owned_monitor_info was taken
rrich
parents:
diff
changeset
|
91 |
jint res; |
5185bc8dcbb1
8230677: Should disable Escape Analysis if JVMTI capability can_get_owned_monitor_info was taken
rrich
parents:
diff
changeset
|
92 |
jvmtiError err; |
5185bc8dcbb1
8230677: Should disable Escape Analysis if JVMTI capability can_get_owned_monitor_info was taken
rrich
parents:
diff
changeset
|
93 |
jvmtiCapabilities caps; |
5185bc8dcbb1
8230677: Should disable Escape Analysis if JVMTI capability can_get_owned_monitor_info was taken
rrich
parents:
diff
changeset
|
94 |
|
5185bc8dcbb1
8230677: Should disable Escape Analysis if JVMTI capability can_get_owned_monitor_info was taken
rrich
parents:
diff
changeset
|
95 |
printf("Agent_OnLoad started\n"); |
5185bc8dcbb1
8230677: Should disable Escape Analysis if JVMTI capability can_get_owned_monitor_info was taken
rrich
parents:
diff
changeset
|
96 |
|
5185bc8dcbb1
8230677: Should disable Escape Analysis if JVMTI capability can_get_owned_monitor_info was taken
rrich
parents:
diff
changeset
|
97 |
memset(&caps, 0, sizeof(caps)); |
5185bc8dcbb1
8230677: Should disable Escape Analysis if JVMTI capability can_get_owned_monitor_info was taken
rrich
parents:
diff
changeset
|
98 |
|
5185bc8dcbb1
8230677: Should disable Escape Analysis if JVMTI capability can_get_owned_monitor_info was taken
rrich
parents:
diff
changeset
|
99 |
res = JNI_ENV_PTR(jvm)->GetEnv(JNI_ENV_ARG(jvm, (void **) &jvmti), |
5185bc8dcbb1
8230677: Should disable Escape Analysis if JVMTI capability can_get_owned_monitor_info was taken
rrich
parents:
diff
changeset
|
100 |
JVMTI_VERSION_9); |
5185bc8dcbb1
8230677: Should disable Escape Analysis if JVMTI capability can_get_owned_monitor_info was taken
rrich
parents:
diff
changeset
|
101 |
if (res != JNI_OK || jvmti == NULL) { |
5185bc8dcbb1
8230677: Should disable Escape Analysis if JVMTI capability can_get_owned_monitor_info was taken
rrich
parents:
diff
changeset
|
102 |
fprintf(stderr, "Error: wrong result of a valid call to GetEnv!\n"); |
5185bc8dcbb1
8230677: Should disable Escape Analysis if JVMTI capability can_get_owned_monitor_info was taken
rrich
parents:
diff
changeset
|
103 |
return JNI_ERR; |
5185bc8dcbb1
8230677: Should disable Escape Analysis if JVMTI capability can_get_owned_monitor_info was taken
rrich
parents:
diff
changeset
|
104 |
} |
5185bc8dcbb1
8230677: Should disable Escape Analysis if JVMTI capability can_get_owned_monitor_info was taken
rrich
parents:
diff
changeset
|
105 |
|
5185bc8dcbb1
8230677: Should disable Escape Analysis if JVMTI capability can_get_owned_monitor_info was taken
rrich
parents:
diff
changeset
|
106 |
caps.can_get_owned_monitor_info = 1; |
5185bc8dcbb1
8230677: Should disable Escape Analysis if JVMTI capability can_get_owned_monitor_info was taken
rrich
parents:
diff
changeset
|
107 |
|
5185bc8dcbb1
8230677: Should disable Escape Analysis if JVMTI capability can_get_owned_monitor_info was taken
rrich
parents:
diff
changeset
|
108 |
err = (*jvmti)->AddCapabilities(jvmti, &caps); |
5185bc8dcbb1
8230677: Should disable Escape Analysis if JVMTI capability can_get_owned_monitor_info was taken
rrich
parents:
diff
changeset
|
109 |
if (err != JVMTI_ERROR_NONE) { |
5185bc8dcbb1
8230677: Should disable Escape Analysis if JVMTI capability can_get_owned_monitor_info was taken
rrich
parents:
diff
changeset
|
110 |
ShowErrorMessage(jvmti, err, |
5185bc8dcbb1
8230677: Should disable Escape Analysis if JVMTI capability can_get_owned_monitor_info was taken
rrich
parents:
diff
changeset
|
111 |
"Agent_OnLoad: error in JVMTI AddCapabilities"); |
5185bc8dcbb1
8230677: Should disable Escape Analysis if JVMTI capability can_get_owned_monitor_info was taken
rrich
parents:
diff
changeset
|
112 |
return JNI_ERR; |
5185bc8dcbb1
8230677: Should disable Escape Analysis if JVMTI capability can_get_owned_monitor_info was taken
rrich
parents:
diff
changeset
|
113 |
} |
5185bc8dcbb1
8230677: Should disable Escape Analysis if JVMTI capability can_get_owned_monitor_info was taken
rrich
parents:
diff
changeset
|
114 |
|
5185bc8dcbb1
8230677: Should disable Escape Analysis if JVMTI capability can_get_owned_monitor_info was taken
rrich
parents:
diff
changeset
|
115 |
err = (*jvmti)->GetCapabilities(jvmti, &caps); |
5185bc8dcbb1
8230677: Should disable Escape Analysis if JVMTI capability can_get_owned_monitor_info was taken
rrich
parents:
diff
changeset
|
116 |
if (err != JVMTI_ERROR_NONE) { |
5185bc8dcbb1
8230677: Should disable Escape Analysis if JVMTI capability can_get_owned_monitor_info was taken
rrich
parents:
diff
changeset
|
117 |
ShowErrorMessage(jvmti, err, |
5185bc8dcbb1
8230677: Should disable Escape Analysis if JVMTI capability can_get_owned_monitor_info was taken
rrich
parents:
diff
changeset
|
118 |
"Agent_OnLoad: error in JVMTI GetCapabilities"); |
5185bc8dcbb1
8230677: Should disable Escape Analysis if JVMTI capability can_get_owned_monitor_info was taken
rrich
parents:
diff
changeset
|
119 |
return JNI_ERR; |
5185bc8dcbb1
8230677: Should disable Escape Analysis if JVMTI capability can_get_owned_monitor_info was taken
rrich
parents:
diff
changeset
|
120 |
} |
5185bc8dcbb1
8230677: Should disable Escape Analysis if JVMTI capability can_get_owned_monitor_info was taken
rrich
parents:
diff
changeset
|
121 |
|
5185bc8dcbb1
8230677: Should disable Escape Analysis if JVMTI capability can_get_owned_monitor_info was taken
rrich
parents:
diff
changeset
|
122 |
if (!caps.can_get_owned_monitor_info) { |
5185bc8dcbb1
8230677: Should disable Escape Analysis if JVMTI capability can_get_owned_monitor_info was taken
rrich
parents:
diff
changeset
|
123 |
fprintf(stderr, "Warning: GetOwnedMonitorInfo is not implemented\n"); |
5185bc8dcbb1
8230677: Should disable Escape Analysis if JVMTI capability can_get_owned_monitor_info was taken
rrich
parents:
diff
changeset
|
124 |
return JNI_ERR; |
5185bc8dcbb1
8230677: Should disable Escape Analysis if JVMTI capability can_get_owned_monitor_info was taken
rrich
parents:
diff
changeset
|
125 |
} |
5185bc8dcbb1
8230677: Should disable Escape Analysis if JVMTI capability can_get_owned_monitor_info was taken
rrich
parents:
diff
changeset
|
126 |
|
5185bc8dcbb1
8230677: Should disable Escape Analysis if JVMTI capability can_get_owned_monitor_info was taken
rrich
parents:
diff
changeset
|
127 |
printf("Agent_OnLoad finished\n"); |
5185bc8dcbb1
8230677: Should disable Escape Analysis if JVMTI capability can_get_owned_monitor_info was taken
rrich
parents:
diff
changeset
|
128 |
return JNI_OK; |
5185bc8dcbb1
8230677: Should disable Escape Analysis if JVMTI capability can_get_owned_monitor_info was taken
rrich
parents:
diff
changeset
|
129 |
} |
5185bc8dcbb1
8230677: Should disable Escape Analysis if JVMTI capability can_get_owned_monitor_info was taken
rrich
parents:
diff
changeset
|
130 |
|
5185bc8dcbb1
8230677: Should disable Escape Analysis if JVMTI capability can_get_owned_monitor_info was taken
rrich
parents:
diff
changeset
|
131 |
JNIEXPORT jint JNICALL |
5185bc8dcbb1
8230677: Should disable Escape Analysis if JVMTI capability can_get_owned_monitor_info was taken
rrich
parents:
diff
changeset
|
132 |
Java_GetOwnedMonitorInfoWithEATest_getOwnedMonitorInfo(JNIEnv *env, jclass cls, jobject targetThread, jobjectArray resOwnedMonitors) { |
5185bc8dcbb1
8230677: Should disable Escape Analysis if JVMTI capability can_get_owned_monitor_info was taken
rrich
parents:
diff
changeset
|
133 |
jvmtiError err; |
5185bc8dcbb1
8230677: Should disable Escape Analysis if JVMTI capability can_get_owned_monitor_info was taken
rrich
parents:
diff
changeset
|
134 |
jvmtiThreadInfo threadInfo; |
5185bc8dcbb1
8230677: Should disable Escape Analysis if JVMTI capability can_get_owned_monitor_info was taken
rrich
parents:
diff
changeset
|
135 |
jint monitorCount; |
5185bc8dcbb1
8230677: Should disable Escape Analysis if JVMTI capability can_get_owned_monitor_info was taken
rrich
parents:
diff
changeset
|
136 |
jobject* monitors; |
5185bc8dcbb1
8230677: Should disable Escape Analysis if JVMTI capability can_get_owned_monitor_info was taken
rrich
parents:
diff
changeset
|
137 |
jint idx; |
5185bc8dcbb1
8230677: Should disable Escape Analysis if JVMTI capability can_get_owned_monitor_info was taken
rrich
parents:
diff
changeset
|
138 |
|
5185bc8dcbb1
8230677: Should disable Escape Analysis if JVMTI capability can_get_owned_monitor_info was taken
rrich
parents:
diff
changeset
|
139 |
err = (*jvmti)->GetThreadInfo(jvmti, targetThread, &threadInfo); |
5185bc8dcbb1
8230677: Should disable Escape Analysis if JVMTI capability can_get_owned_monitor_info was taken
rrich
parents:
diff
changeset
|
140 |
if (err != JVMTI_ERROR_NONE) { |
5185bc8dcbb1
8230677: Should disable Escape Analysis if JVMTI capability can_get_owned_monitor_info was taken
rrich
parents:
diff
changeset
|
141 |
ShowErrorMessage(jvmti, err, |
5185bc8dcbb1
8230677: Should disable Escape Analysis if JVMTI capability can_get_owned_monitor_info was taken
rrich
parents:
diff
changeset
|
142 |
"getOwnedMonitorsFor: error in JVMTI GetThreadInfo"); |
5185bc8dcbb1
8230677: Should disable Escape Analysis if JVMTI capability can_get_owned_monitor_info was taken
rrich
parents:
diff
changeset
|
143 |
return FAILED; |
5185bc8dcbb1
8230677: Should disable Escape Analysis if JVMTI capability can_get_owned_monitor_info was taken
rrich
parents:
diff
changeset
|
144 |
} |
5185bc8dcbb1
8230677: Should disable Escape Analysis if JVMTI capability can_get_owned_monitor_info was taken
rrich
parents:
diff
changeset
|
145 |
|
5185bc8dcbb1
8230677: Should disable Escape Analysis if JVMTI capability can_get_owned_monitor_info was taken
rrich
parents:
diff
changeset
|
146 |
err = (*jvmti)->GetOwnedMonitorInfo(jvmti, targetThread, &monitorCount, &monitors); |
5185bc8dcbb1
8230677: Should disable Escape Analysis if JVMTI capability can_get_owned_monitor_info was taken
rrich
parents:
diff
changeset
|
147 |
if (err != JVMTI_ERROR_NONE) { |
5185bc8dcbb1
8230677: Should disable Escape Analysis if JVMTI capability can_get_owned_monitor_info was taken
rrich
parents:
diff
changeset
|
148 |
ShowErrorMessage(jvmti, err, |
5185bc8dcbb1
8230677: Should disable Escape Analysis if JVMTI capability can_get_owned_monitor_info was taken
rrich
parents:
diff
changeset
|
149 |
"getOwnedMonitorsFor: error in JVMTI GetOwnedMonitorInfo"); |
5185bc8dcbb1
8230677: Should disable Escape Analysis if JVMTI capability can_get_owned_monitor_info was taken
rrich
parents:
diff
changeset
|
150 |
return FAILED; |
5185bc8dcbb1
8230677: Should disable Escape Analysis if JVMTI capability can_get_owned_monitor_info was taken
rrich
parents:
diff
changeset
|
151 |
} |
5185bc8dcbb1
8230677: Should disable Escape Analysis if JVMTI capability can_get_owned_monitor_info was taken
rrich
parents:
diff
changeset
|
152 |
|
5185bc8dcbb1
8230677: Should disable Escape Analysis if JVMTI capability can_get_owned_monitor_info was taken
rrich
parents:
diff
changeset
|
153 |
printf("getOwnedMonitorsFor: %s owns %d monitor(s)\n", threadInfo.name, monitorCount); |
5185bc8dcbb1
8230677: Should disable Escape Analysis if JVMTI capability can_get_owned_monitor_info was taken
rrich
parents:
diff
changeset
|
154 |
|
5185bc8dcbb1
8230677: Should disable Escape Analysis if JVMTI capability can_get_owned_monitor_info was taken
rrich
parents:
diff
changeset
|
155 |
for (idx = 0; idx < monitorCount; idx++) { |
5185bc8dcbb1
8230677: Should disable Escape Analysis if JVMTI capability can_get_owned_monitor_info was taken
rrich
parents:
diff
changeset
|
156 |
(*env)->SetObjectArrayElement(env, resOwnedMonitors, idx, monitors[idx]); |
5185bc8dcbb1
8230677: Should disable Escape Analysis if JVMTI capability can_get_owned_monitor_info was taken
rrich
parents:
diff
changeset
|
157 |
} |
5185bc8dcbb1
8230677: Should disable Escape Analysis if JVMTI capability can_get_owned_monitor_info was taken
rrich
parents:
diff
changeset
|
158 |
|
5185bc8dcbb1
8230677: Should disable Escape Analysis if JVMTI capability can_get_owned_monitor_info was taken
rrich
parents:
diff
changeset
|
159 |
(*jvmti)->Deallocate(jvmti, (unsigned char *) monitors); |
5185bc8dcbb1
8230677: Should disable Escape Analysis if JVMTI capability can_get_owned_monitor_info was taken
rrich
parents:
diff
changeset
|
160 |
(*jvmti)->Deallocate(jvmti, (unsigned char *) threadInfo.name); |
5185bc8dcbb1
8230677: Should disable Escape Analysis if JVMTI capability can_get_owned_monitor_info was taken
rrich
parents:
diff
changeset
|
161 |
return monitorCount; |
5185bc8dcbb1
8230677: Should disable Escape Analysis if JVMTI capability can_get_owned_monitor_info was taken
rrich
parents:
diff
changeset
|
162 |
} |
5185bc8dcbb1
8230677: Should disable Escape Analysis if JVMTI capability can_get_owned_monitor_info was taken
rrich
parents:
diff
changeset
|
163 |
|
5185bc8dcbb1
8230677: Should disable Escape Analysis if JVMTI capability can_get_owned_monitor_info was taken
rrich
parents:
diff
changeset
|
164 |
#ifdef __cplusplus |
5185bc8dcbb1
8230677: Should disable Escape Analysis if JVMTI capability can_get_owned_monitor_info was taken
rrich
parents:
diff
changeset
|
165 |
} |
5185bc8dcbb1
8230677: Should disable Escape Analysis if JVMTI capability can_get_owned_monitor_info was taken
rrich
parents:
diff
changeset
|
166 |
#endif |