< prev index next >
src/share/vm/oops/method.cpp
Print this page
@@ -108,10 +108,11 @@
}
// Release Method*. The nmethod will be gone when we get here because
// we've walked the code cache.
void Method::deallocate_contents(ClassLoaderData* loader_data) {
+ clear_jmethod_id(loader_data);
MetadataFactory::free_metadata(loader_data, constMethod());
set_constMethod(NULL);
MetadataFactory::free_metadata(loader_data, method_data());
set_method_data(NULL);
MetadataFactory::free_metadata(loader_data, method_counters());
@@ -1770,10 +1771,20 @@
#ifdef ASSERT
assert(contains(m), "should be a methodID");
#endif // ASSERT
*m = _free_method;
}
+ void clear_method(Method* m) {
+ for (JNIMethodBlock* b = this; b != NULL; b = b->_next) {
+ for (int i = 0; i< number_of_methods; i++) {
+ if (b->_methods[i] == m) {
+ b->_methods[i] = NULL;
+ }
+ }
+ }
+ // not found
+ }
// During class unloading the methods are cleared, which is different
// than freed.
void clear_all_methods() {
for (JNIMethodBlock* b = this; b != NULL; b = b->_next) {
@@ -1842,11 +1853,13 @@
*((Method**)jmid) = new_method;
}
bool Method::is_method_id(jmethodID mid) {
Method* m = resolve_jmethod_id(mid);
- assert(m != NULL, "should be called with non-null method");
+ if (m == NULL) {
+ return false;
+ }
InstanceKlass* ik = m->method_holder();
if (ik == NULL) {
return false;
}
ClassLoaderData* cld = ik->class_loader_data();
@@ -1864,10 +1877,14 @@
return NULL;
}
return o;
};
+void Method::clear_jmethod_id(ClassLoaderData* loader_data) {
+ loader_data->jmethod_ids()->clear_method(this);
+}
+
void Method::set_on_stack(const bool value) {
// Set both the method itself and its constant pool. The constant pool
// on stack means some method referring to it is also on the stack.
constants()->set_on_stack(value);
< prev index next >