hotspot/src/share/vm/runtime/reflection.cpp
changeset 40923 10fe1c28b9f6
parent 40856 3378947a95e6
child 43471 bfb383279a16
child 46262 83280d968b96
equal deleted inserted replaced
40922:d9f1eaf18f9a 40923:10fe1c28b9f6
   410   assert(result == result2, "results must be consistent");
   410   assert(result == result2, "results must be consistent");
   411 #endif //ASSERT
   411 #endif //ASSERT
   412   return result;
   412   return result;
   413 }
   413 }
   414 
   414 
   415 static bool under_host_klass(const InstanceKlass* ik, const Klass* host_klass) {
   415 static bool under_host_klass(const InstanceKlass* ik, const InstanceKlass* host_klass) {
   416   DEBUG_ONLY(int inf_loop_check = 1000 * 1000 * 1000);
   416   DEBUG_ONLY(int inf_loop_check = 1000 * 1000 * 1000);
   417   for (;;) {
   417   for (;;) {
   418     const Klass* hc = (const Klass*)ik->host_klass();
   418     const InstanceKlass* hc = ik->host_klass();
   419     if (hc == NULL)        return false;
   419     if (hc == NULL)        return false;
   420     if (hc == host_klass)  return true;
   420     if (hc == host_klass)  return true;
   421     ik = InstanceKlass::cast(hc);
   421     ik = hc;
   422 
   422 
   423     // There's no way to make a host class loop short of patching memory.
   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.
   424     // Therefore there cannot be a loop here unless there's another bug.
   425     // Still, let's check for it.
   425     // Still, let's check for it.
   426     assert(--inf_loop_check > 0, "no host_klass loop");
   426     assert(--inf_loop_check > 0, "no host_klass loop");
   434   const InstanceKlass* accessor_ik = InstanceKlass::cast(accessor);
   434   const InstanceKlass* accessor_ik = InstanceKlass::cast(accessor);
   435   const InstanceKlass* accessee_ik = InstanceKlass::cast(accessee);
   435   const InstanceKlass* accessee_ik = InstanceKlass::cast(accessee);
   436 
   436 
   437   // If either is on the other's host_klass chain, access is OK,
   437   // If either is on the other's host_klass chain, access is OK,
   438   // because one is inside the other.
   438   // because one is inside the other.
   439   if (under_host_klass(accessor_ik, accessee) ||
   439   if (under_host_klass(accessor_ik, accessee_ik) ||
   440     under_host_klass(accessee_ik, accessor))
   440     under_host_klass(accessee_ik, accessor_ik))
   441     return true;
   441     return true;
   442 
   442 
   443   if ((RelaxAccessControlCheck &&
   443   if ((RelaxAccessControlCheck &&
   444     accessor_ik->major_version() < Verifier::NO_RELAX_ACCESS_CTRL_CHECK_VERSION &&
   444     accessor_ik->major_version() < Verifier::NO_RELAX_ACCESS_CTRL_CHECK_VERSION &&
   445     accessee_ik->major_version() < Verifier::NO_RELAX_ACCESS_CTRL_CHECK_VERSION) ||
   445     accessee_ik->major_version() < Verifier::NO_RELAX_ACCESS_CTRL_CHECK_VERSION) ||