230 } |
230 } |
231 |
231 |
232 // ------------------------------------------------------------------ |
232 // ------------------------------------------------------------------ |
233 // ciInstanceKlass::uses_default_loader |
233 // ciInstanceKlass::uses_default_loader |
234 bool ciInstanceKlass::uses_default_loader() { |
234 bool ciInstanceKlass::uses_default_loader() { |
235 VM_ENTRY_MARK; |
235 // Note: We do not need to resolve the handle or enter the VM |
236 return loader() == NULL; |
236 // in order to test null-ness. |
|
237 return _loader == NULL; |
|
238 } |
|
239 |
|
240 // ------------------------------------------------------------------ |
|
241 // ciInstanceKlass::is_in_package |
|
242 // |
|
243 // Is this klass in the given package? |
|
244 bool ciInstanceKlass::is_in_package(const char* packagename, int len) { |
|
245 // To avoid class loader mischief, this test always rejects application classes. |
|
246 if (!uses_default_loader()) |
|
247 return false; |
|
248 GUARDED_VM_ENTRY( |
|
249 return is_in_package_impl(packagename, len); |
|
250 ) |
|
251 } |
|
252 |
|
253 bool ciInstanceKlass::is_in_package_impl(const char* packagename, int len) { |
|
254 ASSERT_IN_VM; |
|
255 |
|
256 // If packagename contains trailing '/' exclude it from the |
|
257 // prefix-test since we test for it explicitly. |
|
258 if (packagename[len - 1] == '/') |
|
259 len--; |
|
260 |
|
261 if (!name()->starts_with(packagename, len)) |
|
262 return false; |
|
263 |
|
264 // Test if the class name is something like "java/lang". |
|
265 if ((len + 1) > name()->utf8_length()) |
|
266 return false; |
|
267 |
|
268 // Test for trailing '/' |
|
269 if ((char) name()->byte_at(len) != '/') |
|
270 return false; |
|
271 |
|
272 // Make sure it's not actually in a subpackage: |
|
273 if (name()->index_of_at(len+1, "/", 1) >= 0) |
|
274 return false; |
|
275 |
|
276 return true; |
237 } |
277 } |
238 |
278 |
239 // ------------------------------------------------------------------ |
279 // ------------------------------------------------------------------ |
240 // ciInstanceKlass::print_impl |
280 // ciInstanceKlass::print_impl |
241 // |
281 // |