< prev index next >

src/hotspot/share/oops/method.cpp

Print this page




2101       cld->set_jmethod_ids(new JNIMethodBlock());
2102     }
2103     // jmethodID is a pointer to Method*
2104     return (jmethodID)cld->jmethod_ids()->add_method(m);
2105   }
2106 }
2107 
2108 // Mark a jmethodID as free.  This is called when there is a data race in
2109 // InstanceKlass while creating the jmethodID cache.
2110 void Method::destroy_jmethod_id(ClassLoaderData* loader_data, jmethodID m) {
2111   ClassLoaderData* cld = loader_data;
2112   Method** ptr = (Method**)m;
2113   assert(cld->jmethod_ids() != NULL, "should have method handles");
2114   cld->jmethod_ids()->destroy_method(ptr);
2115 }
2116 
2117 void Method::change_method_associated_with_jmethod_id(jmethodID jmid, Method* new_method) {
2118   // Can't assert the method_holder is the same because the new method has the
2119   // scratch method holder.
2120   assert(resolve_jmethod_id(jmid)->method_holder()->class_loader()
2121            == new_method->method_holder()->class_loader(),

2122          "changing to a different class loader");
2123   // Just change the method in place, jmethodID pointer doesn't change.
2124   *((Method**)jmid) = new_method;
2125 }
2126 
2127 bool Method::is_method_id(jmethodID mid) {
2128   Method* m = resolve_jmethod_id(mid);
2129   assert(m != NULL, "should be called with non-null method");
2130   InstanceKlass* ik = m->method_holder();
2131   ClassLoaderData* cld = ik->class_loader_data();
2132   if (cld->jmethod_ids() == NULL) return false;
2133   return (cld->jmethod_ids()->contains((Method**)mid));
2134 }
2135 
2136 Method* Method::checked_resolve_jmethod_id(jmethodID mid) {
2137   if (mid == NULL) return NULL;
2138   Method* o = resolve_jmethod_id(mid);
2139   if (o == NULL || o == JNIMethodBlock::_free_method || !((Metadata*)o)->is_method()) {
2140     return NULL;
2141   }




2101       cld->set_jmethod_ids(new JNIMethodBlock());
2102     }
2103     // jmethodID is a pointer to Method*
2104     return (jmethodID)cld->jmethod_ids()->add_method(m);
2105   }
2106 }
2107 
2108 // Mark a jmethodID as free.  This is called when there is a data race in
2109 // InstanceKlass while creating the jmethodID cache.
2110 void Method::destroy_jmethod_id(ClassLoaderData* loader_data, jmethodID m) {
2111   ClassLoaderData* cld = loader_data;
2112   Method** ptr = (Method**)m;
2113   assert(cld->jmethod_ids() != NULL, "should have method handles");
2114   cld->jmethod_ids()->destroy_method(ptr);
2115 }
2116 
2117 void Method::change_method_associated_with_jmethod_id(jmethodID jmid, Method* new_method) {
2118   // Can't assert the method_holder is the same because the new method has the
2119   // scratch method holder.
2120   assert(resolve_jmethod_id(jmid)->method_holder()->class_loader()
2121            == new_method->method_holder()->class_loader() ||
2122            new_method->method_holder()->class_loader() == NULL, // allow Unsafe substitution
2123          "changing to a different class loader");
2124   // Just change the method in place, jmethodID pointer doesn't change.
2125   *((Method**)jmid) = new_method;
2126 }
2127 
2128 bool Method::is_method_id(jmethodID mid) {
2129   Method* m = resolve_jmethod_id(mid);
2130   assert(m != NULL, "should be called with non-null method");
2131   InstanceKlass* ik = m->method_holder();
2132   ClassLoaderData* cld = ik->class_loader_data();
2133   if (cld->jmethod_ids() == NULL) return false;
2134   return (cld->jmethod_ids()->contains((Method**)mid));
2135 }
2136 
2137 Method* Method::checked_resolve_jmethod_id(jmethodID mid) {
2138   if (mid == NULL) return NULL;
2139   Method* o = resolve_jmethod_id(mid);
2140   if (o == NULL || o == JNIMethodBlock::_free_method || !((Metadata*)o)->is_method()) {
2141     return NULL;
2142   }


< prev index next >