hotspot/src/share/vm/classfile/modules.cpp
changeset 46632 cef226af6c02
parent 46560 388aa8d67c80
parent 45628 ea212c4584d7
child 46701 f559541c0daa
--- a/hotspot/src/share/vm/classfile/modules.cpp	Wed Jul 05 11:03:19 2017 -0700
+++ b/hotspot/src/share/vm/classfile/modules.cpp	Wed Jul 05 18:14:48 2017 -0700
@@ -680,74 +680,6 @@
   return NULL;
 }
 
-void Modules::add_module_package(jobject module, const char* package_name, TRAPS) {
-  ResourceMark rm(THREAD);
-
-  if (module == NULL) {
-    THROW_MSG(vmSymbols::java_lang_NullPointerException(),
-              "module is null");
-  }
-  if (package_name == NULL) {
-    THROW_MSG(vmSymbols::java_lang_NullPointerException(),
-              "package is null");
-  }
-  ModuleEntry* module_entry = get_module_entry(module, CHECK);
-  if (module_entry == NULL) {
-    THROW_MSG(vmSymbols::java_lang_IllegalArgumentException(),
-              "module is invalid");
-  }
-  if (!module_entry->is_named()) {
-    THROW_MSG(vmSymbols::java_lang_IllegalArgumentException(),
-              "module cannot be an unnamed module");
-  }
-  if (!verify_package_name(package_name)) {
-    THROW_MSG(vmSymbols::java_lang_IllegalArgumentException(),
-              err_msg("Invalid package name: %s", package_name));
-  }
-
-  ClassLoaderData *loader_data = module_entry->loader_data();
-
-  // Only modules defined to either the boot or platform class loader, can define a "java/" package.
-  if (!loader_data->is_the_null_class_loader_data() &&
-      !loader_data->is_platform_class_loader_data() &&
-      (strncmp(package_name, JAVAPKG, JAVAPKG_LEN) == 0 &&
-        (package_name[JAVAPKG_LEN] == '/' || package_name[JAVAPKG_LEN] == '\0'))) {
-    const char* class_loader_name = SystemDictionary::loader_name(loader_data);
-    size_t pkg_len = strlen(package_name);
-    char* pkg_name = NEW_RESOURCE_ARRAY_IN_THREAD(THREAD, char, pkg_len);
-    strncpy(pkg_name, package_name, pkg_len);
-    StringUtils::replace_no_expand(pkg_name, "/", ".");
-    const char* msg_text1 = "Class loader (instance of): ";
-    const char* msg_text2 = " tried to define prohibited package name: ";
-    size_t len = strlen(msg_text1) + strlen(class_loader_name) + strlen(msg_text2) + pkg_len + 1;
-    char* message = NEW_RESOURCE_ARRAY_IN_THREAD(THREAD, char, len);
-    jio_snprintf(message, len, "%s%s%s%s", msg_text1, class_loader_name, msg_text2, pkg_name);
-    THROW_MSG(vmSymbols::java_lang_IllegalArgumentException(), message);
-  }
-
-  log_debug(module)("add_module_package(): Adding package %s to module %s",
-                    package_name, module_entry->name()->as_C_string());
-
-  TempNewSymbol pkg_symbol = SymbolTable::new_symbol(package_name, CHECK);
-  PackageEntryTable* package_table = loader_data->packages();
-  assert(package_table != NULL, "Missing package_table");
-
-  PackageEntry* existing_pkg = NULL;
-  {
-    MutexLocker ml(Module_lock, THREAD);
-
-    // Check that the package does not exist in the class loader's package table.
-    existing_pkg = package_table->lookup_only(pkg_symbol);
-    if (existing_pkg == NULL) {
-      PackageEntry* pkg = package_table->locked_create_entry_or_null(pkg_symbol, module_entry);
-      assert(pkg != NULL, "Unable to create a module's package entry");
-    }
-  }
-  if (existing_pkg != NULL) {
-    throw_dup_pkg_exception(module_entry->name()->as_C_string(), existing_pkg, CHECK);
-  }
-}
-
 // Export package in module to all unnamed modules.
 void Modules::add_module_exports_to_all_unnamed(jobject module, const char* package_name, TRAPS) {
   if (module == NULL) {