# HG changeset patch # User minqi # Date 1390498832 28800 # Node ID ab67ce0bfae21592dc5ed95969df5ce89c47ad3c # Parent ce3b1e29425a90d21f3457424d5670ae06bb207c 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 diff -r ce3b1e29425a -r ab67ce0bfae2 src/share/vm/runtime/jniHandles.cpp --- a/src/share/vm/runtime/jniHandles.cpp Mon Jan 20 09:56:47 2014 +0000 +++ b/src/share/vm/runtime/jniHandles.cpp Thu Jan 23 09:40:32 2014 -0800 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2014, 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 @@ -195,8 +195,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; }