< prev index next >

src/hotspot/share/classfile/modules.cpp

Print this page


  10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12 * version 2 for more details (a copy is included in the LICENSE file that
  13 * accompanied this code).
  14 *
  15 * You should have received a copy of the GNU General Public License version
  16 * 2 along with this work; if not, write to the Free Software Foundation,
  17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18 *
  19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20 * or visit www.oracle.com if you need additional information or have any
  21 * questions.
  22 *
  23 */
  24 
  25 #include "precompiled.hpp"
  26 #include "jvm.h"
  27 #include "classfile/classFileParser.hpp"
  28 #include "classfile/classLoader.hpp"
  29 #include "classfile/classLoaderData.inline.hpp"

  30 #include "classfile/javaAssertions.hpp"
  31 #include "classfile/javaClasses.hpp"
  32 #include "classfile/javaClasses.inline.hpp"
  33 #include "classfile/moduleEntry.hpp"
  34 #include "classfile/modules.hpp"
  35 #include "classfile/packageEntry.hpp"
  36 #include "classfile/stringTable.hpp"
  37 #include "classfile/symbolTable.hpp"
  38 #include "classfile/systemDictionary.hpp"
  39 #include "classfile/vmSymbols.hpp"
  40 #include "logging/log.hpp"
  41 #include "logging/logStream.hpp"

  42 #include "memory/resourceArea.hpp"
  43 #include "runtime/handles.inline.hpp"
  44 #include "runtime/javaCalls.hpp"
  45 #include "runtime/jniHandles.inline.hpp"
  46 #include "utilities/stringUtils.hpp"
  47 #include "utilities/utf8.hpp"
  48 
  49 static bool verify_module_name(const char *module_name, int len) {
  50   assert(module_name != NULL, "invariant");
  51   return (len > 0 && len <= Symbol::max_length());
  52 }
  53 
  54 static bool verify_package_name(const char* package_name, int len) {
  55   assert(package_name != NULL, "Package name derived from non-null jstring can't be NULL");
  56   return (len > 0 && len <= Symbol::max_length() &&
  57     ClassFileParser::verify_unqualified_name(package_name, len,
  58     ClassFileParser::LegalClass));
  59 }
  60 
  61 static char* get_module_name(oop module, int& len, TRAPS) {


 432   LogTarget(Debug, module) lt;
 433   if (lt.is_enabled()) {
 434     LogStream ls(lt);
 435     ls.print("define_module(): creation of module: %s, version: %s, location: %s, ",
 436                  module_name, version_symbol != NULL ? version_symbol->as_C_string() : "NULL",
 437                  location_symbol != NULL ? location_symbol->as_C_string() : "NULL");
 438     loader_data->print_value_on(&ls);
 439     ls.print_cr(", package #: %d", pkg_list->length());
 440     for (int y = 0; y < pkg_list->length(); y++) {
 441       log_trace(module)("define_module(): creation of package %s for module %s",
 442                         (pkg_list->at(y))->as_C_string(), module_name);
 443     }
 444   }
 445 
 446   // If the module is defined to the boot loader and an exploded build is being
 447   // used, prepend <java.home>/modules/modules_name to the system boot class path.
 448   if (h_loader.is_null() && !ClassLoader::has_jrt_entry()) {
 449     ClassLoader::add_to_exploded_build_list(module_symbol, CHECK);
 450   }
 451 }






















 452 
 453 void Modules::set_bootloader_unnamed_module(jobject module, TRAPS) {
 454   ResourceMark rm(THREAD);
 455 
 456   if (module == NULL) {
 457     THROW_MSG(vmSymbols::java_lang_NullPointerException(), "Null module object");
 458   }
 459   Handle module_handle(THREAD, JNIHandles::resolve(module));
 460   if (!java_lang_Module::is_instance(module_handle())) {
 461     THROW_MSG(vmSymbols::java_lang_IllegalArgumentException(),
 462               "module is not an instance of type java.lang.Module");
 463   }
 464 
 465   // Ensure that this is an unnamed module
 466   oop name = java_lang_Module::name(module_handle());
 467   if (name != NULL) {
 468     THROW_MSG(vmSymbols::java_lang_IllegalArgumentException(),
 469               "boot loader's unnamed module's java.lang.Module has a name");
 470   }
 471 




  10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12 * version 2 for more details (a copy is included in the LICENSE file that
  13 * accompanied this code).
  14 *
  15 * You should have received a copy of the GNU General Public License version
  16 * 2 along with this work; if not, write to the Free Software Foundation,
  17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18 *
  19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20 * or visit www.oracle.com if you need additional information or have any
  21 * questions.
  22 *
  23 */
  24 
  25 #include "precompiled.hpp"
  26 #include "jvm.h"
  27 #include "classfile/classFileParser.hpp"
  28 #include "classfile/classLoader.hpp"
  29 #include "classfile/classLoaderData.inline.hpp"
  30 #include "classfile/classLoaderDataShared.hpp"
  31 #include "classfile/javaAssertions.hpp"
  32 #include "classfile/javaClasses.hpp"
  33 #include "classfile/javaClasses.inline.hpp"
  34 #include "classfile/moduleEntry.hpp"
  35 #include "classfile/modules.hpp"
  36 #include "classfile/packageEntry.hpp"
  37 #include "classfile/stringTable.hpp"
  38 #include "classfile/symbolTable.hpp"
  39 #include "classfile/systemDictionary.hpp"
  40 #include "classfile/vmSymbols.hpp"
  41 #include "logging/log.hpp"
  42 #include "logging/logStream.hpp"
  43 #include "memory/metaspaceShared.hpp"
  44 #include "memory/resourceArea.hpp"
  45 #include "runtime/handles.inline.hpp"
  46 #include "runtime/javaCalls.hpp"
  47 #include "runtime/jniHandles.inline.hpp"
  48 #include "utilities/stringUtils.hpp"
  49 #include "utilities/utf8.hpp"
  50 
  51 static bool verify_module_name(const char *module_name, int len) {
  52   assert(module_name != NULL, "invariant");
  53   return (len > 0 && len <= Symbol::max_length());
  54 }
  55 
  56 static bool verify_package_name(const char* package_name, int len) {
  57   assert(package_name != NULL, "Package name derived from non-null jstring can't be NULL");
  58   return (len > 0 && len <= Symbol::max_length() &&
  59     ClassFileParser::verify_unqualified_name(package_name, len,
  60     ClassFileParser::LegalClass));
  61 }
  62 
  63 static char* get_module_name(oop module, int& len, TRAPS) {


 434   LogTarget(Debug, module) lt;
 435   if (lt.is_enabled()) {
 436     LogStream ls(lt);
 437     ls.print("define_module(): creation of module: %s, version: %s, location: %s, ",
 438                  module_name, version_symbol != NULL ? version_symbol->as_C_string() : "NULL",
 439                  location_symbol != NULL ? location_symbol->as_C_string() : "NULL");
 440     loader_data->print_value_on(&ls);
 441     ls.print_cr(", package #: %d", pkg_list->length());
 442     for (int y = 0; y < pkg_list->length(); y++) {
 443       log_trace(module)("define_module(): creation of package %s for module %s",
 444                         (pkg_list->at(y))->as_C_string(), module_name);
 445     }
 446   }
 447 
 448   // If the module is defined to the boot loader and an exploded build is being
 449   // used, prepend <java.home>/modules/modules_name to the system boot class path.
 450   if (h_loader.is_null() && !ClassLoader::has_jrt_entry()) {
 451     ClassLoader::add_to_exploded_build_list(module_symbol, CHECK);
 452   }
 453 }
 454 
 455 #if INCLUDE_CDS_JAVA_HEAP
 456 void Modules::define_archived_modules(jobject platform_loader, jobject system_loader, TRAPS) {
 457   if (platform_loader == NULL) {
 458     THROW_MSG(vmSymbols::java_lang_NullPointerException(), "Null platform loader object");
 459   }
 460 
 461   if (system_loader == NULL) {
 462     THROW_MSG(vmSymbols::java_lang_NullPointerException(), "Null system loader object");
 463   }
 464 
 465   if (UseSharedSpaces && MetaspaceShared::use_full_module_graph()) {
 466     Handle h_platform_loader(THREAD, JNIHandles::resolve_non_null(platform_loader));
 467     ClassLoaderData* platform_loader_data = SystemDictionary::register_loader(h_platform_loader);
 468     ClassLoaderDataShared::restore_java_platform_loader_from_archive(platform_loader_data);
 469 
 470     Handle h_system_loader(THREAD, JNIHandles::resolve_non_null(system_loader));
 471     ClassLoaderData* system_loader_data = SystemDictionary::register_loader(h_system_loader);
 472     ClassLoaderDataShared::restore_java_system_loader_from_archive(system_loader_data);
 473   }
 474 }
 475 #endif
 476 
 477 void Modules::set_bootloader_unnamed_module(jobject module, TRAPS) {
 478   ResourceMark rm(THREAD);
 479 
 480   if (module == NULL) {
 481     THROW_MSG(vmSymbols::java_lang_NullPointerException(), "Null module object");
 482   }
 483   Handle module_handle(THREAD, JNIHandles::resolve(module));
 484   if (!java_lang_Module::is_instance(module_handle())) {
 485     THROW_MSG(vmSymbols::java_lang_IllegalArgumentException(),
 486               "module is not an instance of type java.lang.Module");
 487   }
 488 
 489   // Ensure that this is an unnamed module
 490   oop name = java_lang_Module::name(module_handle());
 491   if (name != NULL) {
 492     THROW_MSG(vmSymbols::java_lang_IllegalArgumentException(),
 493               "boot loader's unnamed module's java.lang.Module has a name");
 494   }
 495 


< prev index next >