annotate src/share/vm/prims/jvmtiExtensions.cpp @ 7588:f9eb431c3efe

8006005: Fix constant pool index validation and alignment trap for method parameter reflection Summary: This patch addresses an alignment trap due to the storage format of method parameters data in constMethod. It also adds code to validate constant pool indexes for method parameters data. Reviewed-by: jrose, dholmes Contributed-by: eric.mccorkle@oracle.com
author coleenp
date Mon, 14 Jan 2013 11:01:39 -0500
parents b9a9ed0f8eeb
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1 /*
6842
b9a9ed0f8eeb 7197424: update copyright year to match last edit in jdk8 hotspot repository
mikael
parents: 6197
diff changeset
2 * Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved.
0
a61af66fc99e Initial load
duke
parents:
diff changeset
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
a61af66fc99e Initial load
duke
parents:
diff changeset
4 *
a61af66fc99e Initial load
duke
parents:
diff changeset
5 * This code is free software; you can redistribute it and/or modify it
a61af66fc99e Initial load
duke
parents:
diff changeset
6 * under the terms of the GNU General Public License version 2 only, as
a61af66fc99e Initial load
duke
parents:
diff changeset
7 * published by the Free Software Foundation.
a61af66fc99e Initial load
duke
parents:
diff changeset
8 *
a61af66fc99e Initial load
duke
parents:
diff changeset
9 * This code is distributed in the hope that it will be useful, but WITHOUT
a61af66fc99e Initial load
duke
parents:
diff changeset
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
a61af66fc99e Initial load
duke
parents:
diff changeset
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
a61af66fc99e Initial load
duke
parents:
diff changeset
12 * version 2 for more details (a copy is included in the LICENSE file that
a61af66fc99e Initial load
duke
parents:
diff changeset
13 * accompanied this code).
a61af66fc99e Initial load
duke
parents:
diff changeset
14 *
a61af66fc99e Initial load
duke
parents:
diff changeset
15 * You should have received a copy of the GNU General Public License version
a61af66fc99e Initial load
duke
parents:
diff changeset
16 * 2 along with this work; if not, write to the Free Software Foundation,
a61af66fc99e Initial load
duke
parents:
diff changeset
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
a61af66fc99e Initial load
duke
parents:
diff changeset
18 *
1552
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 0
diff changeset
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 0
diff changeset
20 * or visit www.oracle.com if you need additional information or have any
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 0
diff changeset
21 * questions.
0
a61af66fc99e Initial load
duke
parents:
diff changeset
22 *
a61af66fc99e Initial load
duke
parents:
diff changeset
23 */
a61af66fc99e Initial load
duke
parents:
diff changeset
24
1972
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
25 #include "precompiled.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
26 #include "prims/jvmtiExport.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
27 #include "prims/jvmtiExtensions.hpp"
0
a61af66fc99e Initial load
duke
parents:
diff changeset
28
a61af66fc99e Initial load
duke
parents:
diff changeset
29 // the list of extension functions
a61af66fc99e Initial load
duke
parents:
diff changeset
30 GrowableArray<jvmtiExtensionFunctionInfo*>* JvmtiExtensions::_ext_functions;
a61af66fc99e Initial load
duke
parents:
diff changeset
31
a61af66fc99e Initial load
duke
parents:
diff changeset
32 // the list of extension events
a61af66fc99e Initial load
duke
parents:
diff changeset
33 GrowableArray<jvmtiExtensionEventInfo*>* JvmtiExtensions::_ext_events;
a61af66fc99e Initial load
duke
parents:
diff changeset
34
a61af66fc99e Initial load
duke
parents:
diff changeset
35
a61af66fc99e Initial load
duke
parents:
diff changeset
36 // extension function
a61af66fc99e Initial load
duke
parents:
diff changeset
37 static jvmtiError JNICALL IsClassUnloadingEnabled(const jvmtiEnv* env, jboolean* enabled, ...) {
a61af66fc99e Initial load
duke
parents:
diff changeset
38 if (enabled == NULL) {
a61af66fc99e Initial load
duke
parents:
diff changeset
39 return JVMTI_ERROR_NULL_POINTER;
a61af66fc99e Initial load
duke
parents:
diff changeset
40 }
a61af66fc99e Initial load
duke
parents:
diff changeset
41 *enabled = (jboolean)ClassUnloading;
a61af66fc99e Initial load
duke
parents:
diff changeset
42 return JVMTI_ERROR_NONE;
a61af66fc99e Initial load
duke
parents:
diff changeset
43 }
a61af66fc99e Initial load
duke
parents:
diff changeset
44
a61af66fc99e Initial load
duke
parents:
diff changeset
45 // register extension functions and events. In this implementation we
a61af66fc99e Initial load
duke
parents:
diff changeset
46 // have a single extension function (to prove the API) that tests if class
a61af66fc99e Initial load
duke
parents:
diff changeset
47 // unloading is enabled or disabled. We also have a single extension event
a61af66fc99e Initial load
duke
parents:
diff changeset
48 // EXT_EVENT_CLASS_UNLOAD which is used to provide the JVMDI_EVENT_CLASS_UNLOAD
a61af66fc99e Initial load
duke
parents:
diff changeset
49 // event. The function and the event are registered here.
a61af66fc99e Initial load
duke
parents:
diff changeset
50 //
a61af66fc99e Initial load
duke
parents:
diff changeset
51 void JvmtiExtensions::register_extensions() {
6197
d2a62e0f25eb 6995781: Native Memory Tracking (Phase 1)
zgu
parents: 1972
diff changeset
52 _ext_functions = new (ResourceObj::C_HEAP, mtInternal) GrowableArray<jvmtiExtensionFunctionInfo*>(1,true);
d2a62e0f25eb 6995781: Native Memory Tracking (Phase 1)
zgu
parents: 1972
diff changeset
53 _ext_events = new (ResourceObj::C_HEAP, mtInternal) GrowableArray<jvmtiExtensionEventInfo*>(1,true);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
54
a61af66fc99e Initial load
duke
parents:
diff changeset
55 // register our extension function
a61af66fc99e Initial load
duke
parents:
diff changeset
56 static jvmtiParamInfo func_params[] = {
a61af66fc99e Initial load
duke
parents:
diff changeset
57 { (char*)"IsClassUnloadingEnabled", JVMTI_KIND_OUT, JVMTI_TYPE_JBOOLEAN, JNI_FALSE }
a61af66fc99e Initial load
duke
parents:
diff changeset
58 };
a61af66fc99e Initial load
duke
parents:
diff changeset
59 static jvmtiExtensionFunctionInfo ext_func = {
a61af66fc99e Initial load
duke
parents:
diff changeset
60 (jvmtiExtensionFunction)IsClassUnloadingEnabled,
a61af66fc99e Initial load
duke
parents:
diff changeset
61 (char*)"com.sun.hotspot.functions.IsClassUnloadingEnabled",
a61af66fc99e Initial load
duke
parents:
diff changeset
62 (char*)"Tell if class unloading is enabled (-noclassgc)",
a61af66fc99e Initial load
duke
parents:
diff changeset
63 sizeof(func_params)/sizeof(func_params[0]),
a61af66fc99e Initial load
duke
parents:
diff changeset
64 func_params,
a61af66fc99e Initial load
duke
parents:
diff changeset
65 0, // no non-universal errors
a61af66fc99e Initial load
duke
parents:
diff changeset
66 NULL
a61af66fc99e Initial load
duke
parents:
diff changeset
67 };
a61af66fc99e Initial load
duke
parents:
diff changeset
68 _ext_functions->append(&ext_func);
a61af66fc99e Initial load
duke
parents:
diff changeset
69
a61af66fc99e Initial load
duke
parents:
diff changeset
70 // register our extension event
a61af66fc99e Initial load
duke
parents:
diff changeset
71
a61af66fc99e Initial load
duke
parents:
diff changeset
72 static jvmtiParamInfo event_params[] = {
a61af66fc99e Initial load
duke
parents:
diff changeset
73 { (char*)"JNI Environment", JVMTI_KIND_IN, JVMTI_TYPE_JNIENV, JNI_FALSE },
a61af66fc99e Initial load
duke
parents:
diff changeset
74 { (char*)"Thread", JVMTI_KIND_IN, JVMTI_TYPE_JTHREAD, JNI_FALSE },
a61af66fc99e Initial load
duke
parents:
diff changeset
75 { (char*)"Class", JVMTI_KIND_IN, JVMTI_TYPE_JCLASS, JNI_FALSE }
a61af66fc99e Initial load
duke
parents:
diff changeset
76 };
a61af66fc99e Initial load
duke
parents:
diff changeset
77 static jvmtiExtensionEventInfo ext_event = {
a61af66fc99e Initial load
duke
parents:
diff changeset
78 EXT_EVENT_CLASS_UNLOAD,
a61af66fc99e Initial load
duke
parents:
diff changeset
79 (char*)"com.sun.hotspot.events.ClassUnload",
a61af66fc99e Initial load
duke
parents:
diff changeset
80 (char*)"CLASS_UNLOAD event",
a61af66fc99e Initial load
duke
parents:
diff changeset
81 sizeof(event_params)/sizeof(event_params[0]),
a61af66fc99e Initial load
duke
parents:
diff changeset
82 event_params
a61af66fc99e Initial load
duke
parents:
diff changeset
83 };
a61af66fc99e Initial load
duke
parents:
diff changeset
84 _ext_events->append(&ext_event);
a61af66fc99e Initial load
duke
parents:
diff changeset
85 }
a61af66fc99e Initial load
duke
parents:
diff changeset
86
a61af66fc99e Initial load
duke
parents:
diff changeset
87
a61af66fc99e Initial load
duke
parents:
diff changeset
88 // return the list of extension functions
a61af66fc99e Initial load
duke
parents:
diff changeset
89
a61af66fc99e Initial load
duke
parents:
diff changeset
90 jvmtiError JvmtiExtensions::get_functions(JvmtiEnv* env,
a61af66fc99e Initial load
duke
parents:
diff changeset
91 jint* extension_count_ptr,
a61af66fc99e Initial load
duke
parents:
diff changeset
92 jvmtiExtensionFunctionInfo** extensions)
a61af66fc99e Initial load
duke
parents:
diff changeset
93 {
a61af66fc99e Initial load
duke
parents:
diff changeset
94 guarantee(_ext_functions != NULL, "registration not done");
a61af66fc99e Initial load
duke
parents:
diff changeset
95
a61af66fc99e Initial load
duke
parents:
diff changeset
96 ResourceTracker rt(env);
a61af66fc99e Initial load
duke
parents:
diff changeset
97
a61af66fc99e Initial load
duke
parents:
diff changeset
98 jvmtiExtensionFunctionInfo* ext_funcs;
a61af66fc99e Initial load
duke
parents:
diff changeset
99 jvmtiError err = rt.allocate(_ext_functions->length() *
a61af66fc99e Initial load
duke
parents:
diff changeset
100 sizeof(jvmtiExtensionFunctionInfo),
a61af66fc99e Initial load
duke
parents:
diff changeset
101 (unsigned char**)&ext_funcs);
a61af66fc99e Initial load
duke
parents:
diff changeset
102 if (err != JVMTI_ERROR_NONE) {
a61af66fc99e Initial load
duke
parents:
diff changeset
103 return err;
a61af66fc99e Initial load
duke
parents:
diff changeset
104 }
a61af66fc99e Initial load
duke
parents:
diff changeset
105
a61af66fc99e Initial load
duke
parents:
diff changeset
106 for (int i=0; i<_ext_functions->length(); i++ ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
107 ext_funcs[i].func = _ext_functions->at(i)->func;
a61af66fc99e Initial load
duke
parents:
diff changeset
108
a61af66fc99e Initial load
duke
parents:
diff changeset
109 char *id = _ext_functions->at(i)->id;
a61af66fc99e Initial load
duke
parents:
diff changeset
110 err = rt.allocate(strlen(id)+1, (unsigned char**)&(ext_funcs[i].id));
a61af66fc99e Initial load
duke
parents:
diff changeset
111 if (err != JVMTI_ERROR_NONE) {
a61af66fc99e Initial load
duke
parents:
diff changeset
112 return err;
a61af66fc99e Initial load
duke
parents:
diff changeset
113 }
a61af66fc99e Initial load
duke
parents:
diff changeset
114 strcpy(ext_funcs[i].id, id);
a61af66fc99e Initial load
duke
parents:
diff changeset
115
a61af66fc99e Initial load
duke
parents:
diff changeset
116 char *desc = _ext_functions->at(i)->short_description;
a61af66fc99e Initial load
duke
parents:
diff changeset
117 err = rt.allocate(strlen(desc)+1,
a61af66fc99e Initial load
duke
parents:
diff changeset
118 (unsigned char**)&(ext_funcs[i].short_description));
a61af66fc99e Initial load
duke
parents:
diff changeset
119 if (err != JVMTI_ERROR_NONE) {
a61af66fc99e Initial load
duke
parents:
diff changeset
120 return err;
a61af66fc99e Initial load
duke
parents:
diff changeset
121 }
a61af66fc99e Initial load
duke
parents:
diff changeset
122 strcpy(ext_funcs[i].short_description, desc);
a61af66fc99e Initial load
duke
parents:
diff changeset
123
a61af66fc99e Initial load
duke
parents:
diff changeset
124 // params
a61af66fc99e Initial load
duke
parents:
diff changeset
125
a61af66fc99e Initial load
duke
parents:
diff changeset
126 jint param_count = _ext_functions->at(i)->param_count;
a61af66fc99e Initial load
duke
parents:
diff changeset
127
a61af66fc99e Initial load
duke
parents:
diff changeset
128 ext_funcs[i].param_count = param_count;
a61af66fc99e Initial load
duke
parents:
diff changeset
129 if (param_count == 0) {
a61af66fc99e Initial load
duke
parents:
diff changeset
130 ext_funcs[i].params = NULL;
a61af66fc99e Initial load
duke
parents:
diff changeset
131 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
132 err = rt.allocate(param_count*sizeof(jvmtiParamInfo),
a61af66fc99e Initial load
duke
parents:
diff changeset
133 (unsigned char**)&(ext_funcs[i].params));
a61af66fc99e Initial load
duke
parents:
diff changeset
134 if (err != JVMTI_ERROR_NONE) {
a61af66fc99e Initial load
duke
parents:
diff changeset
135 return err;
a61af66fc99e Initial load
duke
parents:
diff changeset
136 }
a61af66fc99e Initial load
duke
parents:
diff changeset
137 jvmtiParamInfo* src_params = _ext_functions->at(i)->params;
a61af66fc99e Initial load
duke
parents:
diff changeset
138 jvmtiParamInfo* dst_params = ext_funcs[i].params;
a61af66fc99e Initial load
duke
parents:
diff changeset
139
a61af66fc99e Initial load
duke
parents:
diff changeset
140 for (int j=0; j<param_count; j++) {
a61af66fc99e Initial load
duke
parents:
diff changeset
141 err = rt.allocate(strlen(src_params[j].name)+1,
a61af66fc99e Initial load
duke
parents:
diff changeset
142 (unsigned char**)&(dst_params[j].name));
a61af66fc99e Initial load
duke
parents:
diff changeset
143 if (err != JVMTI_ERROR_NONE) {
a61af66fc99e Initial load
duke
parents:
diff changeset
144 return err;
a61af66fc99e Initial load
duke
parents:
diff changeset
145 }
a61af66fc99e Initial load
duke
parents:
diff changeset
146 strcpy(dst_params[j].name, src_params[j].name);
a61af66fc99e Initial load
duke
parents:
diff changeset
147
a61af66fc99e Initial load
duke
parents:
diff changeset
148 dst_params[j].kind = src_params[j].kind;
a61af66fc99e Initial load
duke
parents:
diff changeset
149 dst_params[j].base_type = src_params[j].base_type;
a61af66fc99e Initial load
duke
parents:
diff changeset
150 dst_params[j].null_ok = src_params[j].null_ok;
a61af66fc99e Initial load
duke
parents:
diff changeset
151 }
a61af66fc99e Initial load
duke
parents:
diff changeset
152 }
a61af66fc99e Initial load
duke
parents:
diff changeset
153
a61af66fc99e Initial load
duke
parents:
diff changeset
154 // errors
a61af66fc99e Initial load
duke
parents:
diff changeset
155
a61af66fc99e Initial load
duke
parents:
diff changeset
156 jint error_count = _ext_functions->at(i)->error_count;
a61af66fc99e Initial load
duke
parents:
diff changeset
157 ext_funcs[i].error_count = error_count;
a61af66fc99e Initial load
duke
parents:
diff changeset
158 if (error_count == 0) {
a61af66fc99e Initial load
duke
parents:
diff changeset
159 ext_funcs[i].errors = NULL;
a61af66fc99e Initial load
duke
parents:
diff changeset
160 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
161 err = rt.allocate(error_count*sizeof(jvmtiError),
a61af66fc99e Initial load
duke
parents:
diff changeset
162 (unsigned char**)&(ext_funcs[i].errors));
a61af66fc99e Initial load
duke
parents:
diff changeset
163 if (err != JVMTI_ERROR_NONE) {
a61af66fc99e Initial load
duke
parents:
diff changeset
164 return err;
a61af66fc99e Initial load
duke
parents:
diff changeset
165 }
a61af66fc99e Initial load
duke
parents:
diff changeset
166 memcpy(ext_funcs[i].errors, _ext_functions->at(i)->errors,
a61af66fc99e Initial load
duke
parents:
diff changeset
167 error_count*sizeof(jvmtiError));
a61af66fc99e Initial load
duke
parents:
diff changeset
168 }
a61af66fc99e Initial load
duke
parents:
diff changeset
169 }
a61af66fc99e Initial load
duke
parents:
diff changeset
170
a61af66fc99e Initial load
duke
parents:
diff changeset
171 *extension_count_ptr = _ext_functions->length();
a61af66fc99e Initial load
duke
parents:
diff changeset
172 *extensions = ext_funcs;
a61af66fc99e Initial load
duke
parents:
diff changeset
173 return JVMTI_ERROR_NONE;
a61af66fc99e Initial load
duke
parents:
diff changeset
174 }
a61af66fc99e Initial load
duke
parents:
diff changeset
175
a61af66fc99e Initial load
duke
parents:
diff changeset
176
a61af66fc99e Initial load
duke
parents:
diff changeset
177 // return the list of extension events
a61af66fc99e Initial load
duke
parents:
diff changeset
178
a61af66fc99e Initial load
duke
parents:
diff changeset
179 jvmtiError JvmtiExtensions::get_events(JvmtiEnv* env,
a61af66fc99e Initial load
duke
parents:
diff changeset
180 jint* extension_count_ptr,
a61af66fc99e Initial load
duke
parents:
diff changeset
181 jvmtiExtensionEventInfo** extensions)
a61af66fc99e Initial load
duke
parents:
diff changeset
182 {
a61af66fc99e Initial load
duke
parents:
diff changeset
183 guarantee(_ext_events != NULL, "registration not done");
a61af66fc99e Initial load
duke
parents:
diff changeset
184
a61af66fc99e Initial load
duke
parents:
diff changeset
185 ResourceTracker rt(env);
a61af66fc99e Initial load
duke
parents:
diff changeset
186
a61af66fc99e Initial load
duke
parents:
diff changeset
187 jvmtiExtensionEventInfo* ext_events;
a61af66fc99e Initial load
duke
parents:
diff changeset
188 jvmtiError err = rt.allocate(_ext_events->length() * sizeof(jvmtiExtensionEventInfo),
a61af66fc99e Initial load
duke
parents:
diff changeset
189 (unsigned char**)&ext_events);
a61af66fc99e Initial load
duke
parents:
diff changeset
190 if (err != JVMTI_ERROR_NONE) {
a61af66fc99e Initial load
duke
parents:
diff changeset
191 return err;
a61af66fc99e Initial load
duke
parents:
diff changeset
192 }
a61af66fc99e Initial load
duke
parents:
diff changeset
193
a61af66fc99e Initial load
duke
parents:
diff changeset
194 for (int i=0; i<_ext_events->length(); i++ ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
195 ext_events[i].extension_event_index = _ext_events->at(i)->extension_event_index;
a61af66fc99e Initial load
duke
parents:
diff changeset
196
a61af66fc99e Initial load
duke
parents:
diff changeset
197 char *id = _ext_events->at(i)->id;
a61af66fc99e Initial load
duke
parents:
diff changeset
198 err = rt.allocate(strlen(id)+1, (unsigned char**)&(ext_events[i].id));
a61af66fc99e Initial load
duke
parents:
diff changeset
199 if (err != JVMTI_ERROR_NONE) {
a61af66fc99e Initial load
duke
parents:
diff changeset
200 return err;
a61af66fc99e Initial load
duke
parents:
diff changeset
201 }
a61af66fc99e Initial load
duke
parents:
diff changeset
202 strcpy(ext_events[i].id, id);
a61af66fc99e Initial load
duke
parents:
diff changeset
203
a61af66fc99e Initial load
duke
parents:
diff changeset
204 char *desc = _ext_events->at(i)->short_description;
a61af66fc99e Initial load
duke
parents:
diff changeset
205 err = rt.allocate(strlen(desc)+1,
a61af66fc99e Initial load
duke
parents:
diff changeset
206 (unsigned char**)&(ext_events[i].short_description));
a61af66fc99e Initial load
duke
parents:
diff changeset
207 if (err != JVMTI_ERROR_NONE) {
a61af66fc99e Initial load
duke
parents:
diff changeset
208 return err;
a61af66fc99e Initial load
duke
parents:
diff changeset
209 }
a61af66fc99e Initial load
duke
parents:
diff changeset
210 strcpy(ext_events[i].short_description, desc);
a61af66fc99e Initial load
duke
parents:
diff changeset
211
a61af66fc99e Initial load
duke
parents:
diff changeset
212 // params
a61af66fc99e Initial load
duke
parents:
diff changeset
213
a61af66fc99e Initial load
duke
parents:
diff changeset
214 jint param_count = _ext_events->at(i)->param_count;
a61af66fc99e Initial load
duke
parents:
diff changeset
215
a61af66fc99e Initial load
duke
parents:
diff changeset
216 ext_events[i].param_count = param_count;
a61af66fc99e Initial load
duke
parents:
diff changeset
217 if (param_count == 0) {
a61af66fc99e Initial load
duke
parents:
diff changeset
218 ext_events[i].params = NULL;
a61af66fc99e Initial load
duke
parents:
diff changeset
219 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
220 err = rt.allocate(param_count*sizeof(jvmtiParamInfo),
a61af66fc99e Initial load
duke
parents:
diff changeset
221 (unsigned char**)&(ext_events[i].params));
a61af66fc99e Initial load
duke
parents:
diff changeset
222 if (err != JVMTI_ERROR_NONE) {
a61af66fc99e Initial load
duke
parents:
diff changeset
223 return err;
a61af66fc99e Initial load
duke
parents:
diff changeset
224 }
a61af66fc99e Initial load
duke
parents:
diff changeset
225 jvmtiParamInfo* src_params = _ext_events->at(i)->params;
a61af66fc99e Initial load
duke
parents:
diff changeset
226 jvmtiParamInfo* dst_params = ext_events[i].params;
a61af66fc99e Initial load
duke
parents:
diff changeset
227
a61af66fc99e Initial load
duke
parents:
diff changeset
228 for (int j=0; j<param_count; j++) {
a61af66fc99e Initial load
duke
parents:
diff changeset
229 err = rt.allocate(strlen(src_params[j].name)+1,
a61af66fc99e Initial load
duke
parents:
diff changeset
230 (unsigned char**)&(dst_params[j].name));
a61af66fc99e Initial load
duke
parents:
diff changeset
231 if (err != JVMTI_ERROR_NONE) {
a61af66fc99e Initial load
duke
parents:
diff changeset
232 return err;
a61af66fc99e Initial load
duke
parents:
diff changeset
233 }
a61af66fc99e Initial load
duke
parents:
diff changeset
234 strcpy(dst_params[j].name, src_params[j].name);
a61af66fc99e Initial load
duke
parents:
diff changeset
235
a61af66fc99e Initial load
duke
parents:
diff changeset
236 dst_params[j].kind = src_params[j].kind;
a61af66fc99e Initial load
duke
parents:
diff changeset
237 dst_params[j].base_type = src_params[j].base_type;
a61af66fc99e Initial load
duke
parents:
diff changeset
238 dst_params[j].null_ok = src_params[j].null_ok;
a61af66fc99e Initial load
duke
parents:
diff changeset
239 }
a61af66fc99e Initial load
duke
parents:
diff changeset
240 }
a61af66fc99e Initial load
duke
parents:
diff changeset
241 }
a61af66fc99e Initial load
duke
parents:
diff changeset
242
a61af66fc99e Initial load
duke
parents:
diff changeset
243 *extension_count_ptr = _ext_events->length();
a61af66fc99e Initial load
duke
parents:
diff changeset
244 *extensions = ext_events;
a61af66fc99e Initial load
duke
parents:
diff changeset
245 return JVMTI_ERROR_NONE;
a61af66fc99e Initial load
duke
parents:
diff changeset
246 }
a61af66fc99e Initial load
duke
parents:
diff changeset
247
a61af66fc99e Initial load
duke
parents:
diff changeset
248 // set callback for an extension event and enable/disable it.
a61af66fc99e Initial load
duke
parents:
diff changeset
249
a61af66fc99e Initial load
duke
parents:
diff changeset
250 jvmtiError JvmtiExtensions::set_event_callback(JvmtiEnv* env,
a61af66fc99e Initial load
duke
parents:
diff changeset
251 jint extension_event_index,
a61af66fc99e Initial load
duke
parents:
diff changeset
252 jvmtiExtensionEvent callback)
a61af66fc99e Initial load
duke
parents:
diff changeset
253 {
a61af66fc99e Initial load
duke
parents:
diff changeset
254 guarantee(_ext_events != NULL, "registration not done");
a61af66fc99e Initial load
duke
parents:
diff changeset
255
a61af66fc99e Initial load
duke
parents:
diff changeset
256 jvmtiExtensionEventInfo* event = NULL;
a61af66fc99e Initial load
duke
parents:
diff changeset
257
a61af66fc99e Initial load
duke
parents:
diff changeset
258 // if there are extension events registered then validate that the
a61af66fc99e Initial load
duke
parents:
diff changeset
259 // extension_event_index matches one of the registered events.
a61af66fc99e Initial load
duke
parents:
diff changeset
260 if (_ext_events != NULL) {
a61af66fc99e Initial load
duke
parents:
diff changeset
261 for (int i=0; i<_ext_events->length(); i++ ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
262 if (_ext_events->at(i)->extension_event_index == extension_event_index) {
a61af66fc99e Initial load
duke
parents:
diff changeset
263 event = _ext_events->at(i);
a61af66fc99e Initial load
duke
parents:
diff changeset
264 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
265 }
a61af66fc99e Initial load
duke
parents:
diff changeset
266 }
a61af66fc99e Initial load
duke
parents:
diff changeset
267 }
a61af66fc99e Initial load
duke
parents:
diff changeset
268
a61af66fc99e Initial load
duke
parents:
diff changeset
269 // invalid event index
a61af66fc99e Initial load
duke
parents:
diff changeset
270 if (event == NULL) {
a61af66fc99e Initial load
duke
parents:
diff changeset
271 return JVMTI_ERROR_ILLEGAL_ARGUMENT;
a61af66fc99e Initial load
duke
parents:
diff changeset
272 }
a61af66fc99e Initial load
duke
parents:
diff changeset
273
a61af66fc99e Initial load
duke
parents:
diff changeset
274 JvmtiEventController::set_extension_event_callback(env, extension_event_index,
a61af66fc99e Initial load
duke
parents:
diff changeset
275 callback);
a61af66fc99e Initial load
duke
parents:
diff changeset
276
a61af66fc99e Initial load
duke
parents:
diff changeset
277 return JVMTI_ERROR_NONE;
a61af66fc99e Initial load
duke
parents:
diff changeset
278 }