< prev index next >
src/share/vm/runtime/jniHandles.cpp
Print this page
@@ -126,10 +126,21 @@
void JNIHandles::weak_oops_do(BoolObjectClosure* is_alive, OopClosure* f) {
_weak_global_handles->weak_oops_do(is_alive, f);
}
+void JNIHandles::weak_oops_do(OopClosure* f) {
+ class AlwaysTrueClosure: public BoolObjectClosure {
+ public:
+ bool do_object_b(oop p) { return true; }
+ };
+ static AlwaysTrueClosure always_true;
+
+ weak_oops_do(&always_true, f);
+}
+
+
void JNIHandles::initialize() {
_global_handles = JNIHandleBlock::allocate_block();
_weak_global_handles = JNIHandleBlock::allocate_block();
EXCEPTION_MARK;
// We will never reach the CATCH below since Exceptions::_throw will cause
@@ -183,15 +194,10 @@
long JNIHandles::weak_global_handle_memory_usage() {
return _weak_global_handles->memory_usage();
}
-class AlwaysAliveClosure: public BoolObjectClosure {
-public:
- bool do_object_b(oop obj) { return true; }
-};
-
class CountHandleClosure: public OopClosure {
private:
int _count;
public:
CountHandleClosure(): _count(0) {}
@@ -209,13 +215,12 @@
assert(SafepointSynchronize::is_at_safepoint(), "must be at safepoint");
assert(_global_handles != NULL && _weak_global_handles != NULL,
"JNIHandles not initialized");
CountHandleClosure global_handle_count;
- AlwaysAliveClosure always_alive;
oops_do(&global_handle_count);
- weak_oops_do(&always_alive, &global_handle_count);
+ weak_oops_do(&global_handle_count);
st->print_cr("JNI global references: %d", global_handle_count.count());
st->cr();
st->flush();
}
@@ -228,14 +233,13 @@
virtual void do_oop(narrowOop* root) { ShouldNotReachHere(); }
};
void JNIHandles::verify() {
VerifyHandleClosure verify_handle;
- AlwaysAliveClosure always_alive;
oops_do(&verify_handle);
- weak_oops_do(&always_alive, &verify_handle);
+ weak_oops_do(&verify_handle);
}
void jni_handles_init() {
< prev index next >