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