changeset 8583:16939858a716

6651256: jstack: DeleteGlobalRef method call doesn't lead to descreasing of global refs count shown by jstack Summary: jni_DeleteGlobalRef does not really release the jni handle, instead, set the handle point to JNIHandles::_deleted_handle which holds an oop instance (java/lang/Object) in Java heap and never be GC'ed. When counting number of global reference, it counts all the handles on the chain list, which includes the already deleted ones. Reviewed-by: zgu, sla, coleenp Contributed-by: yumin.qi@oracle.com
author dbuck
date Mon, 21 Aug 2017 11:34:41 -0400
parents 79d7902dcb95
children ea7502500b78 cff49fc368a3
files src/share/vm/runtime/jniHandles.cpp
diffstat 1 files changed, 5 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/src/share/vm/runtime/jniHandles.cpp	Mon Aug 21 05:20:03 2017 -0400
+++ b/src/share/vm/runtime/jniHandles.cpp	Mon Aug 21 11:34:41 2017 -0400
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1998, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1998, 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
@@ -196,8 +196,10 @@
   int _count;
 public:
   CountHandleClosure(): _count(0) {}
-  virtual void do_oop(oop* unused) {
-    _count++;
+  virtual void do_oop(oop* ooph) {
+    if (*ooph != JNIHandles::deleted_handle()) {
+      _count++;
+    }
   }
   virtual void do_oop(narrowOop* unused) { ShouldNotReachHere(); }
   int count() { return _count; }