src/share/vm/runtime/reflection.cpp
Index Unified diffs Context diffs Sdiffs Wdiffs Patch New Old Previous File Next File bug_8058575.hs.3 Sdiff src/share/vm/runtime

src/share/vm/runtime/reflection.cpp

Print this page




 395 
 396   oop result = java_lang_Class::component_mirror(mirror);
 397 #ifdef ASSERT
 398   oop result2 = NULL;
 399   if (ArrayKlass::cast(klass)->dimension() == 1) {
 400     if (klass->is_typeArray_klass()) {
 401       result2 = basic_type_arrayklass_to_mirror(klass, CHECK_NULL);
 402     } else {
 403       result2 = ObjArrayKlass::cast(klass)->element_klass()->java_mirror();
 404     }
 405   } else {
 406     Klass* lower_dim = ArrayKlass::cast(klass)->lower_dimension();
 407     assert(lower_dim->is_array_klass(), "just checking");
 408     result2 = lower_dim->java_mirror();
 409   }
 410   assert(result == result2, "results must be consistent");
 411 #endif //ASSERT
 412   return result;
 413 }
 414 
 415 static bool under_host_klass(const InstanceKlass* ik, const Klass* host_klass) {
 416   DEBUG_ONLY(int inf_loop_check = 1000 * 1000 * 1000);
 417   for (;;) {
 418     const Klass* hc = (const Klass*)ik->host_klass();
 419     if (hc == NULL)        return false;
 420     if (hc == host_klass)  return true;
 421     ik = InstanceKlass::cast(hc);
 422 
 423     // There's no way to make a host class loop short of patching memory.
 424     // Therefore there cannot be a loop here unless there's another bug.
 425     // Still, let's check for it.
 426     assert(--inf_loop_check > 0, "no host_klass loop");
 427   }
 428 }
 429 
 430 static bool can_relax_access_check_for(const Klass* accessor,
 431                                        const Klass* accessee,
 432                                        bool classloader_only) {
 433 
 434   const InstanceKlass* accessor_ik = InstanceKlass::cast(accessor);
 435   const InstanceKlass* accessee_ik = InstanceKlass::cast(accessee);
 436 
 437   // If either is on the other's host_klass chain, access is OK,
 438   // because one is inside the other.
 439   if (under_host_klass(accessor_ik, accessee) ||
 440     under_host_klass(accessee_ik, accessor))
 441     return true;
 442 
 443   if ((RelaxAccessControlCheck &&
 444     accessor_ik->major_version() < Verifier::NO_RELAX_ACCESS_CTRL_CHECK_VERSION &&
 445     accessee_ik->major_version() < Verifier::NO_RELAX_ACCESS_CTRL_CHECK_VERSION) ||
 446     (accessor_ik->major_version() < Verifier::STRICTER_ACCESS_CTRL_CHECK_VERSION &&
 447     accessee_ik->major_version() < Verifier::STRICTER_ACCESS_CTRL_CHECK_VERSION)) {
 448     return classloader_only &&
 449       Verifier::relax_access_for(accessor_ik->class_loader()) &&
 450       accessor_ik->protection_domain() == accessee_ik->protection_domain() &&
 451       accessor_ik->class_loader() == accessee_ik->class_loader();
 452   }
 453 
 454   return false;
 455 }
 456 
 457 /*
 458     Type Accessibility check for public types: Callee Type T is accessible to Caller Type S if:
 459 
 460                         Callee T in             Callee T in package PT,




 395 
 396   oop result = java_lang_Class::component_mirror(mirror);
 397 #ifdef ASSERT
 398   oop result2 = NULL;
 399   if (ArrayKlass::cast(klass)->dimension() == 1) {
 400     if (klass->is_typeArray_klass()) {
 401       result2 = basic_type_arrayklass_to_mirror(klass, CHECK_NULL);
 402     } else {
 403       result2 = ObjArrayKlass::cast(klass)->element_klass()->java_mirror();
 404     }
 405   } else {
 406     Klass* lower_dim = ArrayKlass::cast(klass)->lower_dimension();
 407     assert(lower_dim->is_array_klass(), "just checking");
 408     result2 = lower_dim->java_mirror();
 409   }
 410   assert(result == result2, "results must be consistent");
 411 #endif //ASSERT
 412   return result;
 413 }
 414 
 415 static bool under_host_klass(const InstanceKlass* ik, const InstanceKlass* host_klass) {
 416   DEBUG_ONLY(int inf_loop_check = 1000 * 1000 * 1000);
 417   for (;;) {
 418     const InstanceKlass* hc = ik->host_klass();
 419     if (hc == NULL)        return false;
 420     if (hc == host_klass)  return true;
 421     ik = hc;
 422 
 423     // There's no way to make a host class loop short of patching memory.
 424     // Therefore there cannot be a loop here unless there's another bug.
 425     // Still, let's check for it.
 426     assert(--inf_loop_check > 0, "no host_klass loop");
 427   }
 428 }
 429 
 430 static bool can_relax_access_check_for(const Klass* accessor,
 431                                        const Klass* accessee,
 432                                        bool classloader_only) {
 433 
 434   const InstanceKlass* accessor_ik = InstanceKlass::cast(accessor);
 435   const InstanceKlass* accessee_ik = InstanceKlass::cast(accessee);
 436 
 437   // If either is on the other's host_klass chain, access is OK,
 438   // because one is inside the other.
 439   if (under_host_klass(accessor_ik, accessee_ik) ||
 440     under_host_klass(accessee_ik, accessor_ik))
 441     return true;
 442 
 443   if ((RelaxAccessControlCheck &&
 444     accessor_ik->major_version() < Verifier::NO_RELAX_ACCESS_CTRL_CHECK_VERSION &&
 445     accessee_ik->major_version() < Verifier::NO_RELAX_ACCESS_CTRL_CHECK_VERSION) ||
 446     (accessor_ik->major_version() < Verifier::STRICTER_ACCESS_CTRL_CHECK_VERSION &&
 447     accessee_ik->major_version() < Verifier::STRICTER_ACCESS_CTRL_CHECK_VERSION)) {
 448     return classloader_only &&
 449       Verifier::relax_access_for(accessor_ik->class_loader()) &&
 450       accessor_ik->protection_domain() == accessee_ik->protection_domain() &&
 451       accessor_ik->class_loader() == accessee_ik->class_loader();
 452   }
 453 
 454   return false;
 455 }
 456 
 457 /*
 458     Type Accessibility check for public types: Callee Type T is accessible to Caller Type S if:
 459 
 460                         Callee T in             Callee T in package PT,


src/share/vm/runtime/reflection.cpp
Index Unified diffs Context diffs Sdiffs Wdiffs Patch New Old Previous File Next File