changeset 12636:b07ef472634f

8173693: disable post_class_unload() for non JavaThread initiators Reviewed-by: sspitsyn, gthornbr
author dcubed
date Tue, 31 Jan 2017 14:33:36 -0800
parents 8f9d73e44c1a
children 5fdcab5b7979
files src/share/vm/prims/jvmtiExport.cpp
diffstat 1 files changed, 7 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/src/share/vm/prims/jvmtiExport.cpp	Tue Jan 31 20:04:54 2017 +0000
+++ b/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)) {