hotspot/src/share/vm/runtime/reflection.cpp
changeset 43471 bfb383279a16
parent 40923 10fe1c28b9f6
child 44520 0553e129e0ec
child 46289 1904e7ec236e
equal deleted inserted replaced
43470:39d4bc6c9989 43471:bfb383279a16
     1 /*
     1 /*
     2  * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved.
     2  * Copyright (c) 1997, 2017, Oracle and/or its affiliates. All rights reserved.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     4  *
     4  *
     5  * This code is free software; you can redistribute it and/or modify it
     5  * This code is free software; you can redistribute it and/or modify it
     6  * under the terms of the GNU General Public License version 2 only, as
     6  * under the terms of the GNU General Public License version 2 only, as
     7  * published by the Free Software Foundation.
     7  * published by the Free Software Foundation.
   532     }
   532     }
   533 
   533 
   534     PackageEntry* package_to = new_class->package();
   534     PackageEntry* package_to = new_class->package();
   535     assert(package_to != NULL, "can not obtain new_class' package");
   535     assert(package_to != NULL, "can not obtain new_class' package");
   536 
   536 
   537     // Once readability is established, if module_to exports T unqualifiedly,
   537     {
   538     // (to all modules), than whether module_from is in the unnamed module
   538       MutexLocker m1(Module_lock);
   539     // or not does not matter, access is allowed.
   539 
   540     if (package_to->is_unqual_exported()) {
   540       // Once readability is established, if module_to exports T unqualifiedly,
   541       return ACCESS_OK;
   541       // (to all modules), than whether module_from is in the unnamed module
   542     }
   542       // or not does not matter, access is allowed.
   543 
   543       if (package_to->is_unqual_exported()) {
   544     // Access is allowed if both 1 & 2 hold:
   544         return ACCESS_OK;
   545     //   1. Readability, module_from can read module_to (established above).
   545       }
   546     //   2. Either module_to exports T to module_from qualifiedly.
   546 
   547     //      or
   547       // Access is allowed if both 1 & 2 hold:
   548     //      module_to exports T to all unnamed modules and module_from is unnamed.
   548       //   1. Readability, module_from can read module_to (established above).
   549     //      or
   549       //   2. Either module_to exports T to module_from qualifiedly.
   550     //      module_to exports T unqualifiedly to all modules (checked above).
   550       //      or
   551     if (!package_to->is_qexported_to(module_from)) {
   551       //      module_to exports T to all unnamed modules and module_from is unnamed.
   552       return TYPE_NOT_EXPORTED;
   552       //      or
       
   553       //      module_to exports T unqualifiedly to all modules (checked above).
       
   554       if (!package_to->is_qexported_to(module_from)) {
       
   555         return TYPE_NOT_EXPORTED;
       
   556       }
   553     }
   557     }
   554     return ACCESS_OK;
   558     return ACCESS_OK;
   555   }
   559   }
   556 
   560 
   557   if (can_relax_access_check_for(current_class, new_class, classloader_only)) {
   561   if (can_relax_access_check_for(current_class, new_class, classloader_only)) {