8173693: disable post_class_unload() for non JavaThread initiators
Reviewed-by: sspitsyn, gthornbr
--- 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)) {