< prev index next >

src/hotspot/share/oops/instanceKlass.cpp

Print this page
rev 49275 : [mq]: JDK-8199781.patch


2384   PackageEntry* classpkg1 = this->package();
2385   if (class2->is_objArray_klass()) {
2386     class2 = ObjArrayKlass::cast(class2)->bottom_klass();
2387   }
2388 
2389   oop classloader2;
2390   PackageEntry* classpkg2;
2391   if (class2->is_instance_klass()) {
2392     classloader2 = class2->class_loader();
2393     classpkg2 = class2->package();
2394   } else {
2395     assert(class2->is_typeArray_klass(), "should be type array");
2396     classloader2 = NULL;
2397     classpkg2 = NULL;
2398   }
2399 
2400   // Same package is determined by comparing class loader
2401   // and package entries. Both must be the same. This rule
2402   // applies even to classes that are defined in the unnamed
2403   // package, they still must have the same class loader.
2404   if ((classloader1 == classloader2) && (classpkg1 == classpkg2)) {
2405     return true;
2406   }
2407 
2408   return false;
2409 }
2410 
2411 // return true if this class and other_class are in the same package. Classloader
2412 // and classname information is enough to determine a class's package
2413 bool InstanceKlass::is_same_class_package(oop other_class_loader,
2414                                           const Symbol* other_class_name) const {
2415   if (class_loader() != other_class_loader) {
2416     return false;
2417   }
2418   if (name()->fast_compare(other_class_name) == 0) {
2419      return true;
2420   }
2421 
2422   {
2423     ResourceMark rm;
2424 
2425     bool bad_class_name = false;
2426     const char* other_pkg =
2427       ClassLoader::package_from_name((const char*) other_class_name->as_C_string(), &bad_class_name);
2428     if (bad_class_name) {
2429       return false;
2430     }
2431     // Check that package_from_name() returns NULL, not "", if there is no package.
2432     assert(other_pkg == NULL || strlen(other_pkg) > 0, "package name is empty string");
2433 
2434     const Symbol* const this_package_name =
2435       this->package() != NULL ? this->package()->name() : NULL;




2384   PackageEntry* classpkg1 = this->package();
2385   if (class2->is_objArray_klass()) {
2386     class2 = ObjArrayKlass::cast(class2)->bottom_klass();
2387   }
2388 
2389   oop classloader2;
2390   PackageEntry* classpkg2;
2391   if (class2->is_instance_klass()) {
2392     classloader2 = class2->class_loader();
2393     classpkg2 = class2->package();
2394   } else {
2395     assert(class2->is_typeArray_klass(), "should be type array");
2396     classloader2 = NULL;
2397     classpkg2 = NULL;
2398   }
2399 
2400   // Same package is determined by comparing class loader
2401   // and package entries. Both must be the same. This rule
2402   // applies even to classes that are defined in the unnamed
2403   // package, they still must have the same class loader.
2404   if (oopDesc::equals(classloader1, classloader2) && (classpkg1 == classpkg2)) {
2405     return true;
2406   }
2407 
2408   return false;
2409 }
2410 
2411 // return true if this class and other_class are in the same package. Classloader
2412 // and classname information is enough to determine a class's package
2413 bool InstanceKlass::is_same_class_package(oop other_class_loader,
2414                                           const Symbol* other_class_name) const {
2415   if (!oopDesc::equals(class_loader(), other_class_loader)) {
2416     return false;
2417   }
2418   if (name()->fast_compare(other_class_name) == 0) {
2419      return true;
2420   }
2421 
2422   {
2423     ResourceMark rm;
2424 
2425     bool bad_class_name = false;
2426     const char* other_pkg =
2427       ClassLoader::package_from_name((const char*) other_class_name->as_C_string(), &bad_class_name);
2428     if (bad_class_name) {
2429       return false;
2430     }
2431     // Check that package_from_name() returns NULL, not "", if there is no package.
2432     assert(other_pkg == NULL || strlen(other_pkg) > 0, "package name is empty string");
2433 
2434     const Symbol* const this_package_name =
2435       this->package() != NULL ? this->package()->name() : NULL;


< prev index next >