178 #endif 179 180 JvmtiThreadState* state = _thread->jvmti_thread_state(); 181 // we are continuing after an event. 182 if (state != NULL) { 183 // Restore the jvmti thread exception state. 184 state->restore_exception_state(_saved_exception_state); 185 } 186 } 187 188 #if 0 189 jobject to_jobject(oop obj) { return obj == NULL? NULL : _hblock->allocate_handle_fast(obj); } 190 #else 191 // we want to use the code above - but that needs the JNIHandle changes - later... 192 // for now, use regular make_local 193 jobject to_jobject(oop obj) { return JNIHandles::make_local(_thread,obj); } 194 #endif 195 196 jclass to_jclass(Klass* klass) { return (klass == NULL ? NULL : (jclass)to_jobject(klass->java_mirror())); } 197 198 jmethodID to_jmethodID(methodHandle method) { return method->jmethod_id(); } 199 200 JNIEnv* jni_env() { return _jni_env; } 201 }; 202 203 class JvmtiThreadEventMark : public JvmtiEventMark { 204 private: 205 jthread _jt; 206 207 public: 208 JvmtiThreadEventMark(JavaThread *thread) : 209 JvmtiEventMark(thread) { 210 _jt = (jthread)(to_jobject(thread->threadObj())); 211 }; 212 jthread jni_thread() { return _jt; } 213 }; 214 215 class JvmtiClassEventMark : public JvmtiThreadEventMark { 216 private: 217 jclass _jc; 218 219 public: 220 JvmtiClassEventMark(JavaThread *thread, Klass* klass) : 221 JvmtiThreadEventMark(thread) { 222 _jc = to_jclass(klass); 223 }; 224 jclass jni_class() { return _jc; } 225 }; 226 227 class JvmtiMethodEventMark : public JvmtiThreadEventMark { 228 private: 229 jmethodID _mid; 230 231 public: 232 JvmtiMethodEventMark(JavaThread *thread, methodHandle method) : 233 JvmtiThreadEventMark(thread), 234 _mid(to_jmethodID(method)) {}; 235 jmethodID jni_methodID() { return _mid; } 236 }; 237 238 class JvmtiLocationEventMark : public JvmtiMethodEventMark { 239 private: 240 jlocation _loc; 241 242 public: 243 JvmtiLocationEventMark(JavaThread *thread, methodHandle method, address location) : 244 JvmtiMethodEventMark(thread, method), 245 _loc(location - method->code_base()) {}; 246 jlocation location() { return _loc; } 247 }; 248 249 class JvmtiExceptionEventMark : public JvmtiLocationEventMark { 250 private: 251 jobject _exc; 252 253 public: 254 JvmtiExceptionEventMark(JavaThread *thread, methodHandle method, address location, Handle exception) : 255 JvmtiLocationEventMark(thread, method, location), 256 _exc(to_jobject(exception())) {}; 257 jobject exception() { return _exc; } 258 }; 259 260 class JvmtiClassFileLoadEventMark : public JvmtiThreadEventMark { 261 private: 262 const char *_class_name; 263 jobject _jloader; 264 jobject _protection_domain; 265 jclass _class_being_redefined; 266 267 public: 268 JvmtiClassFileLoadEventMark(JavaThread *thread, Symbol* name, 269 Handle class_loader, Handle prot_domain, Klass* class_being_redefined) : JvmtiThreadEventMark(thread) { 270 _class_name = name != NULL? name->as_utf8() : NULL; 271 _jloader = (jobject)to_jobject(class_loader()); 272 _protection_domain = (jobject)to_jobject(prot_domain()); 273 if (class_being_redefined == NULL) { 274 _class_being_redefined = NULL; | 178 #endif 179 180 JvmtiThreadState* state = _thread->jvmti_thread_state(); 181 // we are continuing after an event. 182 if (state != NULL) { 183 // Restore the jvmti thread exception state. 184 state->restore_exception_state(_saved_exception_state); 185 } 186 } 187 188 #if 0 189 jobject to_jobject(oop obj) { return obj == NULL? NULL : _hblock->allocate_handle_fast(obj); } 190 #else 191 // we want to use the code above - but that needs the JNIHandle changes - later... 192 // for now, use regular make_local 193 jobject to_jobject(oop obj) { return JNIHandles::make_local(_thread,obj); } 194 #endif 195 196 jclass to_jclass(Klass* klass) { return (klass == NULL ? NULL : (jclass)to_jobject(klass->java_mirror())); } 197 198 jmethodID to_jmethodID(const methodHandle& method) { return method->jmethod_id(); } 199 200 JNIEnv* jni_env() { return _jni_env; } 201 }; 202 203 class JvmtiThreadEventMark : public JvmtiEventMark { 204 private: 205 jthread _jt; 206 207 public: 208 JvmtiThreadEventMark(JavaThread *thread) : 209 JvmtiEventMark(thread) { 210 _jt = (jthread)(to_jobject(thread->threadObj())); 211 }; 212 jthread jni_thread() { return _jt; } 213 }; 214 215 class JvmtiClassEventMark : public JvmtiThreadEventMark { 216 private: 217 jclass _jc; 218 219 public: 220 JvmtiClassEventMark(JavaThread *thread, Klass* klass) : 221 JvmtiThreadEventMark(thread) { 222 _jc = to_jclass(klass); 223 }; 224 jclass jni_class() { return _jc; } 225 }; 226 227 class JvmtiMethodEventMark : public JvmtiThreadEventMark { 228 private: 229 jmethodID _mid; 230 231 public: 232 JvmtiMethodEventMark(JavaThread *thread, const methodHandle& method) : 233 JvmtiThreadEventMark(thread), 234 _mid(to_jmethodID(method)) {}; 235 jmethodID jni_methodID() { return _mid; } 236 }; 237 238 class JvmtiLocationEventMark : public JvmtiMethodEventMark { 239 private: 240 jlocation _loc; 241 242 public: 243 JvmtiLocationEventMark(JavaThread *thread, const methodHandle& method, address location) : 244 JvmtiMethodEventMark(thread, method), 245 _loc(location - method->code_base()) {}; 246 jlocation location() { return _loc; } 247 }; 248 249 class JvmtiExceptionEventMark : public JvmtiLocationEventMark { 250 private: 251 jobject _exc; 252 253 public: 254 JvmtiExceptionEventMark(JavaThread *thread, const methodHandle& method, address location, Handle exception) : 255 JvmtiLocationEventMark(thread, method, location), 256 _exc(to_jobject(exception())) {}; 257 jobject exception() { return _exc; } 258 }; 259 260 class JvmtiClassFileLoadEventMark : public JvmtiThreadEventMark { 261 private: 262 const char *_class_name; 263 jobject _jloader; 264 jobject _protection_domain; 265 jclass _class_being_redefined; 266 267 public: 268 JvmtiClassFileLoadEventMark(JavaThread *thread, Symbol* name, 269 Handle class_loader, Handle prot_domain, Klass* class_being_redefined) : JvmtiThreadEventMark(thread) { 270 _class_name = name != NULL? name->as_utf8() : NULL; 271 _jloader = (jobject)to_jobject(class_loader()); 272 _protection_domain = (jobject)to_jobject(prot_domain()); 273 if (class_being_redefined == NULL) { 274 _class_being_redefined = NULL; |