8173693: disable post_class_unload() for non JavaThread initiators
authordcubed
Tue, 31 Jan 2017 14:33:36 -0800
changeset 43679 0e60946764a6
parent 43678 9026c0acb7c2
child 43681 b810b7f4fdeb
8173693: disable post_class_unload() for non JavaThread initiators Reviewed-by: sspitsyn, gthornbr
hotspot/src/share/vm/prims/jvmtiExport.cpp
--- a/hotspot/src/share/vm/prims/jvmtiExport.cpp	Tue Jan 31 20:04:54 2017 +0000
+++ b/hotspot/src/share/vm/prims/jvmtiExport.cpp	Tue Jan 31 14:33:36 2017 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -1230,8 +1230,12 @@
     assert(thread->is_VM_thread(), "wrong thread");
 
     // get JavaThread for whom we are proxy
-    JavaThread *real_thread =
-        (JavaThread *)((VMThread *)thread)->vm_operation()->calling_thread();
+    Thread *calling_thread = ((VMThread *)thread)->vm_operation()->calling_thread();
+    if (!calling_thread->is_Java_thread()) {
+      // cannot post an event to a non-JavaThread
+      return;
+    }
+    JavaThread *real_thread = (JavaThread *)calling_thread;
 
     JvmtiEnvIterator it;
     for (JvmtiEnv* env = it.first(); env != NULL; env = it.next(env)) {