1864 // Called when the class loader is unloaded to make all methods weak. |
1864 // Called when the class loader is unloaded to make all methods weak. |
1865 void Method::clear_jmethod_ids(ClassLoaderData* loader_data) { |
1865 void Method::clear_jmethod_ids(ClassLoaderData* loader_data) { |
1866 loader_data->jmethod_ids()->clear_all_methods(); |
1866 loader_data->jmethod_ids()->clear_all_methods(); |
1867 } |
1867 } |
1868 |
1868 |
|
1869 bool Method::has_method_vptr(const void* ptr) { |
|
1870 Method m; |
|
1871 // This assumes that the vtbl pointer is the first word of a C++ object. |
|
1872 // This assumption is also in universe.cpp patch_klass_vtble |
|
1873 void* vtbl2 = dereference_vptr((const void*)&m); |
|
1874 void* this_vtbl = dereference_vptr(ptr); |
|
1875 return vtbl2 == this_vtbl; |
|
1876 } |
1869 |
1877 |
1870 // Check that this pointer is valid by checking that the vtbl pointer matches |
1878 // Check that this pointer is valid by checking that the vtbl pointer matches |
1871 bool Method::is_valid_method() const { |
1879 bool Method::is_valid_method() const { |
1872 if (this == NULL) { |
1880 if (this == NULL) { |
1873 return false; |
1881 return false; |
1874 } else if (!is_metaspace_object()) { |
1882 } else if (!is_metaspace_object()) { |
1875 return false; |
1883 return false; |
1876 } else { |
1884 } else { |
1877 Method m; |
1885 return has_method_vptr((const void*)this); |
1878 // This assumes that the vtbl pointer is the first word of a C++ object. |
|
1879 // This assumption is also in universe.cpp patch_klass_vtble |
|
1880 void* vtbl2 = dereference_vptr((void*)&m); |
|
1881 void* this_vtbl = dereference_vptr((void*)this); |
|
1882 return vtbl2 == this_vtbl; |
|
1883 } |
1886 } |
1884 } |
1887 } |
1885 |
1888 |
1886 #ifndef PRODUCT |
1889 #ifndef PRODUCT |
1887 void Method::print_jmethod_ids(ClassLoaderData* loader_data, outputStream* out) { |
1890 void Method::print_jmethod_ids(ClassLoaderData* loader_data, outputStream* out) { |