equal
deleted
inserted
replaced
475 ------------------------------------------------------------------------------------------------ |
475 ------------------------------------------------------------------------------------------------ |
476 |
476 |
477 Note: a loose module is a module that can read all current and future unnamed modules. |
477 Note: a loose module is a module that can read all current and future unnamed modules. |
478 */ |
478 */ |
479 Reflection::VerifyClassAccessResults Reflection::verify_class_access( |
479 Reflection::VerifyClassAccessResults Reflection::verify_class_access( |
480 const Klass* current_class, const Klass* new_class, bool classloader_only) { |
480 const Klass* current_class, const InstanceKlass* new_class, bool classloader_only) { |
481 |
481 |
482 // Verify that current_class can access new_class. If the classloader_only |
482 // Verify that current_class can access new_class. If the classloader_only |
483 // flag is set, we automatically allow any accesses in which current_class |
483 // flag is set, we automatically allow any accesses in which current_class |
484 // doesn't have a classloader. |
484 // doesn't have a classloader. |
485 if ((current_class == NULL) || |
485 if ((current_class == NULL) || |
502 } |
502 } |
503 |
503 |
504 // Find the module entry for current_class, the accessor |
504 // Find the module entry for current_class, the accessor |
505 ModuleEntry* module_from = current_class->module(); |
505 ModuleEntry* module_from = current_class->module(); |
506 // Find the module entry for new_class, the accessee |
506 // Find the module entry for new_class, the accessee |
507 if (new_class->is_objArray_klass()) { |
|
508 new_class = ObjArrayKlass::cast(new_class)->bottom_klass(); |
|
509 } |
|
510 if (new_class->is_typeArray_klass()) { |
|
511 // A TypeArray's defining module is java.base, access to the TypeArray is allowed |
|
512 return ACCESS_OK; |
|
513 } |
|
514 ModuleEntry* module_to = new_class->module(); |
507 ModuleEntry* module_to = new_class->module(); |
515 |
508 |
516 // both in same (possibly unnamed) module |
509 // both in same (possibly unnamed) module |
517 if (module_from == module_to) { |
510 if (module_from == module_to) { |
518 return ACCESS_OK; |
511 return ACCESS_OK; |
565 } |
558 } |
566 |
559 |
567 // Return an error message specific to the specified Klass*'s and result. |
560 // Return an error message specific to the specified Klass*'s and result. |
568 // This function must be called from within a block containing a ResourceMark. |
561 // This function must be called from within a block containing a ResourceMark. |
569 char* Reflection::verify_class_access_msg(const Klass* current_class, |
562 char* Reflection::verify_class_access_msg(const Klass* current_class, |
570 const Klass* new_class, |
563 const InstanceKlass* new_class, |
571 VerifyClassAccessResults result) { |
564 VerifyClassAccessResults result) { |
572 assert(result != ACCESS_OK, "must be failure result"); |
565 assert(result != ACCESS_OK, "must be failure result"); |
573 char * msg = NULL; |
566 char * msg = NULL; |
574 if (result != OTHER_PROBLEM && new_class != NULL && current_class != NULL) { |
567 if (result != OTHER_PROBLEM && new_class != NULL && current_class != NULL) { |
575 // Find the module entry for current_class, the accessor |
568 // Find the module entry for current_class, the accessor |