--- old/src/jdk.hotspot.agent/share/classes/module-info.java 2016-07-15 07:00:11.553814745 +0100 +++ new/src/jdk.hotspot.agent/share/classes/module-info.java 2016-07-15 07:00:11.454807980 +0100 @@ -31,7 +31,7 @@ requires jdk.jdi; // RMI needs to serialize types in this package - exports sun.jvm.hotspot.debugger.remote to java.rmi; + exports dynamic sun.jvm.hotspot.debugger.remote to java.rmi; provides com.sun.jdi.connect.Connector with sun.jvm.hotspot.jdi.SACoreAttachingConnector; provides com.sun.jdi.connect.Connector with sun.jvm.hotspot.jdi.SADebugServerAttachingConnector; provides com.sun.jdi.connect.Connector with sun.jvm.hotspot.jdi.SAPIDAttachingConnector; --- old/src/jdk.vm.ci/share/classes/jdk.vm.ci.services/src/jdk/vm/ci/services/Services.java 2016-07-15 07:00:11.924840096 +0100 +++ new/src/jdk.vm.ci/share/classes/jdk.vm.ci.services/src/jdk/vm/ci/services/Services.java 2016-07-15 07:00:11.819832922 +0100 @@ -57,7 +57,7 @@ if (jvmci != requestorModule) { for (String pkg : jvmci.getPackages()) { // Export all JVMCI packages dynamically instead - // of requiring a long list of -XaddExports + // of requiring a long list of --add-exports // options on the JVM command line. if (!jvmci.isExported(pkg, requestorModule)) { jvmci.addExports(pkg, requestorModule); --- old/src/share/vm/classfile/classLoader.cpp 2016-07-15 07:00:12.299865721 +0100 +++ new/src/share/vm/classfile/classLoader.cpp 2016-07-15 07:00:12.195858614 +0100 @@ -140,7 +140,7 @@ PerfCounter* ClassLoader::_isUnsyncloadClass = NULL; PerfCounter* ClassLoader::_load_instance_class_failCounter = NULL; -GrowableArray* ClassLoader::_xpatch_entries = NULL; +GrowableArray* ClassLoader::_patch_mod_entries = NULL; ClassPathEntry* ClassLoader::_first_entry = NULL; ClassPathEntry* ClassLoader::_last_entry = NULL; int ClassLoader::_num_entries = 0; @@ -686,24 +686,24 @@ } #endif -// Construct the array of module/path pairs as specified to -Xpatch +// Construct the array of module/path pairs as specified to --patch-module // for the boot loader to search ahead of the jimage, if the class being -// loaded is defined to a module that has been specified to -Xpatch. -void ClassLoader::setup_xpatch_entries() { +// loaded is defined to a module that has been specified to --patch-module. +void ClassLoader::setup_patch_mod_entries() { Thread* THREAD = Thread::current(); - GrowableArray* xpatch_args = Arguments::get_xpatchprefix(); - int num_of_entries = xpatch_args->length(); + GrowableArray* patch_mod_args = Arguments::get_patch_mod_prefix(); + int num_of_entries = patch_mod_args->length(); - // Set up the boot loader's xpatch_entries list - _xpatch_entries = new (ResourceObj::C_HEAP, mtModule) GrowableArray(num_of_entries, true); + // Set up the boot loader's patch_mod_entries list + _patch_mod_entries = new (ResourceObj::C_HEAP, mtModule) GrowableArray(num_of_entries, true); for (int i = 0; i < num_of_entries; i++) { - const char* module_name = (xpatch_args->at(i))->module_name(); + const char* module_name = (patch_mod_args->at(i))->module_name(); Symbol* const module_sym = SymbolTable::lookup(module_name, (int)strlen(module_name), CHECK); assert(module_sym != NULL, "Failed to obtain Symbol for module name"); ModuleClassPathList* module_cpl = new ModuleClassPathList(module_sym); - char* class_path = (xpatch_args->at(i))->path_string(); + char* class_path = (patch_mod_args->at(i))->path_string(); int len = (int)strlen(class_path); int end = 0; // Iterate over the module's class path entries @@ -733,10 +733,10 @@ } } - // Record the module into the list of -Xpatch entries only if + // Record the module into the list of --patch-module entries only if // valid ClassPathEntrys have been created if (module_cpl->module_first_entry() != NULL) { - _xpatch_entries->push(module_cpl); + _patch_mod_entries->push(module_cpl); } } } @@ -975,12 +975,12 @@ ClassPathEntry* e; tty->print("[bootclasspath= "); - // Print -Xpatch module/path specifications first - if (_xpatch_entries != NULL) { + // Print --patch-module module/path specifications first + if (_patch_mod_entries != NULL) { ResourceMark rm; - int num_of_entries = _xpatch_entries->length(); + int num_of_entries = _patch_mod_entries->length(); for (int i = 0; i < num_of_entries; i++) { - ModuleClassPathList* mpl = _xpatch_entries->at(i); + ModuleClassPathList* mpl = _patch_mod_entries->at(i); tty->print("%s=", mpl->module_name()->as_C_string()); e = mpl->module_first_entry(); while (e != NULL) { @@ -1322,8 +1322,8 @@ ClassPathEntry* e = NULL; // If DumpSharedSpaces is true, boot loader visibility boundaries are set - // to be _first_entry to the end (all path entries). No -Xpatch entries are - // included since CDS and AppCDS are not supported if -Xpatch is specified. + // to be _first_entry to the end (all path entries). No --patch-module entries are + // included since CDS and AppCDS are not supported if --patch-module is specified. // // If search_append_only is true, boot loader visibility boundaries are // set to be _first_append_entry to the end. This includes: @@ -1332,18 +1332,18 @@ // If both DumpSharedSpaces and search_append_only are false, boot loader // visibility boundaries are set to be _first_entry to the entry before // the _first_append_entry. This would include: - // [-Xpatch:=()*]; [exploded build | jimage] + // [--patch-module==()*]; [exploded build | jimage] // // DumpSharedSpaces and search_append_only are mutually exclusive and cannot // be true at the same time. assert(!(DumpSharedSpaces && search_append_only), "DumpSharedSpaces and search_append_only are both true"); - // Load Attempt #1: -Xpatch - // Determine the class' defining module. If it appears in the _xpatch_entries, + // Load Attempt #1: --patch-module + // Determine the class' defining module. If it appears in the _patch_mod_entries, // attempt to load the class from those locations specific to the module. - // Note: The -Xpatch entries are never searched if the boot loader's + // Note: The --patch-module entries are never searched if the boot loader's // visibility boundary is limited to only searching the append entries. - if (_xpatch_entries != NULL && !search_append_only && !DumpSharedSpaces) { + if (_patch_mod_entries != NULL && !search_append_only && !DumpSharedSpaces) { // Find the module in the boot loader's module entry table PackageEntry* pkg_entry = get_package_entry(class_name, ClassLoaderData::the_null_class_loader_data(), THREAD); ModuleEntry* mod_entry = (pkg_entry != NULL) ? pkg_entry->module() : NULL; @@ -1361,12 +1361,12 @@ // The module must be a named module if (mod_entry != NULL && mod_entry->is_named()) { - int num_of_entries = _xpatch_entries->length(); + int num_of_entries = _patch_mod_entries->length(); const Symbol* class_module_name = mod_entry->name(); - // Loop through all the xpatch entries looking for module + // Loop through all the patch_mod entries looking for module for (int i = 0; i < num_of_entries; i++) { - ModuleClassPathList* module_cpl = _xpatch_entries->at(i); + ModuleClassPathList* module_cpl = _patch_mod_entries->at(i); Symbol* module_cpl_name = module_cpl->module_name(); if (module_cpl_name->fast_compare(class_module_name) == 0) { @@ -1376,16 +1376,16 @@ while (e != NULL) { stream = e->open_stream(file_name, CHECK_NULL); // No context.check is required since both CDS - // and AppCDS are turned off if -Xpatch is specified. + // and AppCDS are turned off if --patch-module is specified. if (NULL != stream) { break; } e = e->next(); } - // If the module was located in the xpatch entries, break out + // If the module was located in the patch_mod entries, break out // even if the class was not located successfully from that module's // ClassPathEntry list. There will not be another valid entry for - // that module in the _xpatch_entries array. + // that module in the _patch_mod_entries array. break; } } @@ -1598,11 +1598,11 @@ // Complete the ClassPathEntry setup for the boot loader void classLoader_init2() { - // Setup the list of module/path pairs for -Xpatch processing + // Setup the list of module/path pairs for --patch-module processing // This must be done after the SymbolTable is created in order // to use fast_compare on module names instead of a string compare. - if (Arguments::get_xpatchprefix() != NULL) { - ClassLoader::setup_xpatch_entries(); + if (Arguments::get_patch_mod_prefix() != NULL) { + ClassLoader::setup_patch_mod_entries(); } // Determine if this is an exploded build @@ -1658,7 +1658,7 @@ // Determine if this is an exploded build. When looking for // the jimage file, only search the piece of the boot // loader's boot class path which contains [exploded build | jimage]. - // Do not search the boot loader's xpatch entries or append path. + // Do not search the boot loader's patch-module entries or append path. ClassPathEntry* e = _first_entry; ClassPathEntry* last_e = _first_append_entry; while ((e != NULL) && (e != last_e)) { --- old/src/share/vm/classfile/classLoader.hpp 2016-07-15 07:00:12.708893669 +0100 +++ new/src/share/vm/classfile/classLoader.hpp 2016-07-15 07:00:12.607886767 +0100 @@ -150,7 +150,7 @@ // ModuleClassPathList contains a linked list of ClassPathEntry's // that have been specified for a specific module. Currently, -// the only way to specify a module/path pair is via the -Xpatch +// the only way to specify a module/path pair is via the --patch-module // command line option. class ModuleClassPathList : public CHeapObj { private: @@ -213,8 +213,8 @@ static PerfCounter* _load_instance_class_failCounter; // The boot class path consists of 3 ordered pieces: - // 1. the module/path pairs specified to -Xpatch - // -Xpatch:=()* + // 1. the module/path pairs specified to --patch-module + // --patch-module==()* // 2. the base piece // [exploded build | jimage] // 3. boot loader append path @@ -223,8 +223,8 @@ // The boot loader must obey this order when attempting // to load a class. - // Contains the module/path pairs specified to -Xpatch - static GrowableArray* _xpatch_entries; + // Contains the module/path pairs specified to --patch-module + static GrowableArray* _patch_mod_entries; // Contains the ClassPathEntry instances that include // both the base piece and the boot loader append path. @@ -352,8 +352,8 @@ return _load_instance_class_failCounter; } - // Set up the module/path pairs as specified to -Xpatch - static void setup_xpatch_entries(); + // Set up the module/path pairs as specified to --patch-module. + static void setup_patch_mod_entries(); // Sets _has_jimage to TRUE if "modules" jimage file exists static void set_has_jimage(); --- old/src/share/vm/memory/filemap.cpp 2016-07-15 07:00:13.089919703 +0100 +++ new/src/share/vm/memory/filemap.cpp 2016-07-15 07:00:12.985912597 +0100 @@ -881,8 +881,8 @@ return false; } - if (Arguments::get_xpatchprefix() != NULL) { - FileMapInfo::fail_continue("The shared archive file cannot be used with -Xpatch."); + if (Arguments::get_patch_mod_prefix() != NULL) { + FileMapInfo::fail_continue("The shared archive file cannot be used with --patch-module."); return false; } --- old/src/share/vm/prims/jvmtiEnv.cpp 2016-07-15 07:00:13.465945396 +0100 +++ new/src/share/vm/prims/jvmtiEnv.cpp 2016-07-15 07:00:13.367938700 +0100 @@ -3475,6 +3475,9 @@ jvmtiError err = JVMTI_ERROR_NONE; const char *value; + if (Arguments::is_internal_module_property(property)) { + return JVMTI_ERROR_NOT_AVAILABLE; + } value = Arguments::PropertyList_get_value(Arguments::system_properties(), property); if (value == NULL) { err = JVMTI_ERROR_NOT_AVAILABLE; --- old/src/share/vm/runtime/arguments.cpp 2016-07-15 07:00:13.882973891 +0100 +++ new/src/share/vm/runtime/arguments.cpp 2016-07-15 07:00:13.776966648 +0100 @@ -111,7 +111,7 @@ SystemProperty *Arguments::_java_class_path = NULL; SystemProperty *Arguments::_jdk_boot_class_path_append = NULL; -GrowableArray *Arguments::_xpatchprefix = NULL; +GrowableArray *Arguments::_patch_mod_prefix = NULL; PathString *Arguments::_system_boot_class_path = NULL; char* Arguments::_ext_dirs = NULL; @@ -140,6 +140,83 @@ } } +#define MODULE_PROPERTY_PREFIX "jdk.module" +#define MODULE_PROPERTY_PREFIX_LEN 10 +#define ADDEXPORTS "addexports" +#define ADDEXPORTS_LEN 10 +#define ADDREADS "addreads" +#define ADDREADS_LEN 8 +#define PATCH "patch" +#define PATCH_LEN 5 +#define ADDMODS "addmods" +#define ADDMODS_LEN 7 +#define LIMITMODS "limitmods" +#define LIMITMODS_LEN 9 +#define PATH "path" +#define PATH_LEN 4 +#define UPGRADE_PATH "upgrade.path" +#define UPGRADE_PATH_LEN 12 + +// Return TRUE if option matches property. or matches property.=. +static bool is_matching_numbered_property(const char* option, const char* property, size_t len) { + if (strncmp(option, property, len) == 0) { + // Check for digits. + const char* sptr = option + len; + if (isdigit(*sptr)) { // Make sure next char is a digit. + while (isdigit(*sptr)) { + sptr++; + if (*sptr == '=' || *sptr == '\0') { + return true; + } + } + } + } + return false; +} + +// Return TRUE if option matches property or matches property=. +static bool is_matching_property(const char* option, const char* property, size_t len) { + return (strncmp(option, property, len) == 0) && (option[len] == '=' || option[len] == '\0'); +} + +// Return true if option_end is the name of a module-related java property +// with "-Djdk.module." removed. +static bool is_internal_module_property_end(const char* option_end) { + // For the repeating properties such as (-Djdk.module.patch.0 + // -Djdk.module.patch.1, etc) return true for ".[=]". + if (is_matching_numbered_property(option_end, ADDEXPORTS ".", ADDEXPORTS_LEN + 1) || + is_matching_numbered_property(option_end, ADDREADS ".", ADDREADS_LEN + 1) || + is_matching_numbered_property(option_end, PATCH ".", PATCH_LEN + 1)) { + return true; + } + return (is_matching_property(option_end, ADDMODS, ADDMODS_LEN) || + is_matching_property(option_end, LIMITMODS, LIMITMODS_LEN)); +} + +// Return true if the option is one of the module-related java properties +// that can only be set using the proper module-related option. +static bool is_module_property(const JavaVMOption *option) { + if (strncmp(option->optionString, "-D" MODULE_PROPERTY_PREFIX ".", MODULE_PROPERTY_PREFIX_LEN + 3) == 0) { + const char* option_end = option->optionString + MODULE_PROPERTY_PREFIX_LEN + 3; + return (is_internal_module_property_end(option_end) || + is_matching_property(option_end, PATH, PATH_LEN) || + is_matching_property(option_end, UPGRADE_PATH, UPGRADE_PATH_LEN)); + } + return false; +} + +// Return true if the option is one of the module-related java properties +// that can only be set using the proper module-related option and cannot +// be read by jvmti. +// It's expected that the caller removed the leading "-D" from 'option'. +bool Arguments::is_internal_module_property(const char* option) { + assert((strncmp(option, "-D", 2) != 0), "Unexpected leading -D"); + if (strncmp(option, MODULE_PROPERTY_PREFIX ".", MODULE_PROPERTY_PREFIX_LEN + 1) == 0) { + return is_internal_module_property_end(option + MODULE_PROPERTY_PREFIX_LEN + 1); + } + return false; +} + // Return true if any of the strings in null-terminated array 'names' matches. // If tail_allowed is true, then the tail must begin with a colon; otherwise, // the option must match exactly. @@ -197,7 +274,7 @@ _system_boot_class_path = new PathString(NULL); PropertyList_add(&_system_properties, new SystemProperty("java.vm.specification.name", - "Java Virtual Machine Specification", false)); + "Java Virtual Machine Specification", false)); PropertyList_add(&_system_properties, new SystemProperty("java.vm.version", VM_Version::vm_release(), false)); PropertyList_add(&_system_properties, new SystemProperty("java.vm.name", VM_Version::vm_name(), false)); PropertyList_add(&_system_properties, new SystemProperty("java.vm.info", VM_Version::vm_info_string(), true)); @@ -1199,7 +1276,7 @@ return PropertyList_get_value(system_properties(), key); } -bool Arguments::add_property(const char* prop) { +bool Arguments::add_property(const char* prop, PropertyWriteable writeable, PropertyInternal internal) { const char* eq = strchr(prop, '='); const char* key; const char* value = ""; @@ -1229,7 +1306,9 @@ // private and are processed in process_sun_java_launcher_properties(); // the sun.java.launcher property is passed on to the java application } else if (strcmp(key, "sun.boot.library.path") == 0) { - PropertyList_unique_add(&_system_properties, key, value, true); + // append is true, writable is true, internal is false + PropertyList_unique_add(&_system_properties, key, value, AppendProperty, + WriteableProperty, ExternalProperty); } else { if (strcmp(key, "sun.java.command") == 0) { char *old_java_command = _java_command; @@ -1249,7 +1328,7 @@ } // Create new property and add at the end of the list - PropertyList_unique_add(&_system_properties, key, value); + PropertyList_unique_add(&_system_properties, key, value, AddProperty, writeable, internal); } if (key != prop) { @@ -1261,9 +1340,9 @@ return true; } -// sets or adds a module name to the jdk.launcher.addmods property +// sets or adds a module name to the jdk.module.addmods property bool Arguments::append_to_addmods_property(const char* module_name) { - const char* key = "jdk.launcher.addmods"; + const char* key = "jdk.module.addmods"; const char* old_value = Arguments::get_property(key); size_t buf_len = strlen(key) + strlen(module_name) + 2; if (old_value != NULL) { @@ -1278,7 +1357,7 @@ } else { jio_snprintf(new_value, buf_len, "%s=%s,%s", key, old_value, module_name); } - bool added = add_property(new_value); + bool added = add_property(new_value, UnwriteableProperty, InternalProperty); FreeHeap(new_value); return added; } @@ -1288,14 +1367,14 @@ assert(DumpSharedSpaces, "this function is only used with -Xshare:dump"); const char* unsupported_properties[5] = { "jdk.module.main", "jdk.module.path", - "jdk.upgrade.module.path", - "jdk.launcher.addmods", - "jdk.launcher.limitmods" }; + "jdk.module.upgrade.path", + "jdk.module.addmods", + "jdk.module.limitmods" }; const char* unsupported_options[5] = { "-m", - "-modulepath", - "-upgrademodulepath", - "-addmods", - "-limitmods" }; + "--module-path", + "--upgrade-module-path", + "--add-modules", + "--limit-modules" }; SystemProperty* sp = system_properties(); while (sp != NULL) { for (int i = 0; i < 5; i++) { @@ -1322,7 +1401,7 @@ // Ensure Agent_OnLoad has the correct initial values. // This may not be the final mode; mode may change later in onload phase. PropertyList_unique_add(&_system_properties, "java.vm.info", - VM_Version::vm_info_string(), false); + VM_Version::vm_info_string(), AddProperty, UnwriteableProperty, ExternalProperty); UseInterpreter = true; UseCompiler = true; @@ -2520,6 +2599,41 @@ return false; } +unsigned int addreads_count = 0; +unsigned int addexports_count = 0; +unsigned int patch_mod_count = 0; +const char* add_modules_value = NULL; + +bool Arguments::create_property(const char* prop_name, const char* prop_value, PropertyInternal internal) { + size_t prop_len = strlen(prop_name) + strlen(prop_value) + 2; + char* property = AllocateHeap(prop_len, mtArguments); + int ret = jio_snprintf(property, prop_len, "%s=%s", prop_name, prop_value); + if (ret < 0 || ret >= (int)prop_len) { + FreeHeap(property); + return false; + } + bool added = add_property(property, UnwriteableProperty, internal); + FreeHeap(property); + return added; +} + +bool Arguments::create_numbered_property(const char* prop_base_name, const char* prop_value, unsigned int count) { + // Make sure count is < 1,000. Otherwise, memory allocation will be too small. + if (count < 1000) { + size_t prop_len = strlen(prop_base_name) + strlen(prop_value) + 5; + char* property = AllocateHeap(prop_len, mtArguments); + int ret = jio_snprintf(property, prop_len, "%s.%d=%s", prop_base_name, count, prop_value); + if (ret < 0 || ret >= (int)prop_len) { + FreeHeap(property); + return false; + } + bool added = add_property(property, UnwriteableProperty, InternalProperty); + FreeHeap(property); + return added; + } + return false; +} + Arguments::ArgsRange Arguments::parse_memory_size(const char* s, julong* long_arg, julong min_size) { @@ -2532,7 +2646,7 @@ jint Arguments::parse_vm_init_args(const JavaVMInitArgs *java_tool_options_args, const JavaVMInitArgs *java_options_args, const JavaVMInitArgs *cmd_line_args) { - bool xpatch_javabase = false; + bool patch_mod_javabase = false; // Save default settings for some mode flags Arguments::_AlwaysCompileLoopMethods = AlwaysCompileLoopMethods; @@ -2549,20 +2663,20 @@ // Parse args structure generated from JAVA_TOOL_OPTIONS environment // variable (if present). - jint result = parse_each_vm_init_arg(java_tool_options_args, &xpatch_javabase, Flag::ENVIRON_VAR); + jint result = parse_each_vm_init_arg(java_tool_options_args, &patch_mod_javabase, Flag::ENVIRON_VAR); if (result != JNI_OK) { return result; } // Parse args structure generated from the command line flags. - result = parse_each_vm_init_arg(cmd_line_args, &xpatch_javabase, Flag::COMMAND_LINE); + result = parse_each_vm_init_arg(cmd_line_args, &patch_mod_javabase, Flag::COMMAND_LINE); if (result != JNI_OK) { return result; } // Parse args structure generated from the _JAVA_OPTIONS environment // variable (if present) (mimics classic VM) - result = parse_each_vm_init_arg(java_options_args, &xpatch_javabase, Flag::ENVIRON_VAR); + result = parse_each_vm_init_arg(java_options_args, &patch_mod_javabase, Flag::ENVIRON_VAR); if (result != JNI_OK) { return result; } @@ -2621,7 +2735,35 @@ return false; } -jint Arguments::parse_each_vm_init_arg(const JavaVMInitArgs* args, bool* xpatch_javabase, Flag::Flags origin) { +int Arguments::process_patch_mod_option(const char* patch_mod_tail, bool* patch_mod_javabase) { + // --patch-module==()* + assert(patch_mod_tail != NULL, "Unexpected NULL patch-module value"); + // Find the equal sign between the module name and the path specification + const char* module_equal = strchr(patch_mod_tail, '='); + if (module_equal == NULL) { + jio_fprintf(defaultStream::output_stream(), "Missing '=' in --patch-module specification\n"); + return JNI_ERR; + } else { + // Pick out the module name + size_t module_len = module_equal - patch_mod_tail; + char* module_name = NEW_C_HEAP_ARRAY_RETURN_NULL(char, module_len+1, mtArguments); + if (module_name != NULL) { + memcpy(module_name, patch_mod_tail, module_len); + *(module_name + module_len) = '\0'; + // The path piece begins one past the module_equal sign + add_patch_mod_prefix(module_name, module_equal + 1, patch_mod_javabase); + FREE_C_HEAP_ARRAY(char, module_name); + if (!create_numbered_property("jdk.module.patch", patch_mod_tail, patch_mod_count++)) { + return JNI_ENOMEM; + } + } else { + return JNI_ENOMEM; + } + } + return JNI_OK; +} + +jint Arguments::parse_each_vm_init_arg(const JavaVMInitArgs* args, bool* patch_mod_javabase, Flag::Flags origin) { // For match_option to return remaining or value part of option string const char* tail; @@ -2706,6 +2848,34 @@ #endif // !INCLUDE_JVMTI add_init_library(name, options); } + } else if (match_option(option, "--add-reads=", &tail)) { + if (!create_numbered_property("jdk.module.addreads", tail, addreads_count++)) { + return JNI_ENOMEM; + } + } else if (match_option(option, "--add-exports=", &tail)) { + if (!create_numbered_property("jdk.module.addexports", tail, addexports_count++)) { + return JNI_ENOMEM; + } + } else if (match_option(option, "--add-modules=", &tail)) { + add_modules_value = tail; + } else if (match_option(option, "--limit-modules=", &tail)) { + if (!create_property("jdk.module.limitmods", tail, InternalProperty)) { + return JNI_ENOMEM; + } + } else if (match_option(option, "--module-path=", &tail)) { + if (!create_property("jdk.module.path", tail, ExternalProperty)) { + return JNI_ENOMEM; + } + } else if (match_option(option, "--upgrade-module-path=", &tail)) { + if (!create_property("jdk.module.upgrade.path", tail, ExternalProperty)) { + return JNI_ENOMEM; + } + } else if (match_option(option, "--patch-module=", &tail)) { + // --patch-module==()* + int res = process_patch_mod_option(tail, patch_mod_javabase); + if (res != JNI_OK) { + return res; + } // -agentlib and -agentpath } else if (match_option(option, "-agentlib:", &tail) || (is_absolute_path = match_option(option, "-agentpath:", &tail))) { @@ -2997,6 +3167,11 @@ "-Djava.ext.dirs=%s is not supported. Use -classpath instead.\n", value); return JNI_EINVAL; } + // Silently ignore module related properties. They must be set using the modules + // options. For example: use "--add-modules java.sql", not "-Djdk.module.addmods=java.sql" + if (is_module_property(option)) { + continue; + } if (!add_property(tail)) { return JNI_ENOMEM; @@ -3017,33 +3192,6 @@ return JNI_ERR; #endif } - if (match_option(option, "-Djdk.launcher.patch.", &tail)) { - // -Djdk.launcher.patch.#==()* - // The number, #, specified will be increasing with each -Xpatch - // specified on the command line. - // Pick up module name, following the -D property's equal sign. - const char* property_equal = strchr(tail, '='); - if (property_equal == NULL) { - jio_fprintf(defaultStream::output_stream(), "Missing '=' in -Xpatch specification\n"); - return JNI_ERR; - } else { - // Find the equal sign between the module name and the path specification - const char* module_equal = strchr(property_equal + 1, '='); - if (module_equal == NULL) { - jio_fprintf(defaultStream::output_stream(), "Bad value for -Xpatch, no module name specified\n"); - return JNI_ERR; - } else { - // Pick out the module name, in between the two equal signs - size_t module_len = module_equal - property_equal - 1; - char* module_name = NEW_C_HEAP_ARRAY(char, module_len+1, mtArguments); - memcpy(module_name, property_equal + 1, module_len); - *(module_name + module_len) = '\0'; - // The path piece begins one past the module_equal sign - Arguments::add_xpatchprefix(module_name, module_equal + 1, xpatch_javabase); - FREE_C_HEAP_ARRAY(char, module_name); - } - } - } // -Xint } else if (match_option(option, "-Xint")) { set_mode_flags(_int); @@ -3303,25 +3451,25 @@ return JNI_OK; } -void Arguments::add_xpatchprefix(const char* module_name, const char* path, bool* xpatch_javabase) { - // For java.base check for duplicate -Xpatch options being specified on the command line. +void Arguments::add_patch_mod_prefix(const char* module_name, const char* path, bool* patch_mod_javabase) { + // For java.base check for duplicate --patch-module options being specified on the command line. // This check is only required for java.base, all other duplicate module specifications // will be checked during module system initialization. The module system initialization // will throw an ExceptionInInitializerError if this situation occurs. if (strcmp(module_name, "java.base") == 0) { - if (*xpatch_javabase) { - vm_exit_during_initialization("Cannot specify java.base more than once to -Xpatch"); + if (*patch_mod_javabase) { + vm_exit_during_initialization("Cannot specify java.base more than once to --patch-module"); } else { - *xpatch_javabase = true; + *patch_mod_javabase = true; } } - // Create GrowableArray lazily, only if -Xpatch has been specified - if (_xpatchprefix == NULL) { - _xpatchprefix = new (ResourceObj::C_HEAP, mtArguments) GrowableArray(10, true); + // Create GrowableArray lazily, only if --patch-module has been specified + if (_patch_mod_prefix == NULL) { + _patch_mod_prefix = new (ResourceObj::C_HEAP, mtArguments) GrowableArray(10, true); } - _xpatchprefix->push(new ModuleXPatchPath(module_name, path)); + _patch_mod_prefix->push(new ModulePatchPath(module_name, path)); } // Set property jdk.boot.class.path.append to the contents of the bootclasspath @@ -3458,6 +3606,13 @@ return JNI_ERR; } + // Append the value of the last --add-modules option specified on the command line. + // This needs to be done here, to prevent overwriting possible values written + // to the jdk.module.addmods property by -javaagent and other options. + if (add_modules_value != NULL) { + append_to_addmods_property(add_modules_value); + } + Arguments::set_bootclassloader_append_index(((int)strlen(Arguments::get_sysclasspath()))+1); // This must be done after all arguments have been processed. @@ -3814,9 +3969,9 @@ void Arguments::set_shared_spaces_flags() { if (DumpSharedSpaces) { - if (Arguments::get_xpatchprefix() != NULL) { + if (Arguments::get_patch_mod_prefix() != NULL) { vm_exit_during_initialization( - "Cannot use the following option when dumping the shared archive", "-Xpatch"); + "Cannot use the following option when dumping the shared archive: --patch-module"); } if (RequireSharedSpaces) { @@ -4476,11 +4631,12 @@ } } -void Arguments::PropertyList_add(SystemProperty** plist, const char* k, const char* v) { +void Arguments::PropertyList_add(SystemProperty** plist, const char* k, const char* v, + bool writeable, bool internal) { if (plist == NULL) return; - SystemProperty* new_p = new SystemProperty(k, v, true); + SystemProperty* new_p = new SystemProperty(k, v, writeable, internal); PropertyList_add(plist, new_p); } @@ -4489,7 +4645,9 @@ } // This add maintains unique property key in the list. -void Arguments::PropertyList_unique_add(SystemProperty** plist, const char* k, const char* v, jboolean append) { +void Arguments::PropertyList_unique_add(SystemProperty** plist, const char* k, const char* v, + PropertyAppendable append, PropertyWriteable writeable, + PropertyInternal internal) { if (plist == NULL) return; @@ -4497,16 +4655,16 @@ SystemProperty* prop; for (prop = *plist; prop != NULL; prop = prop->next()) { if (strcmp(k, prop->key()) == 0) { - if (append) { + if (append == AppendProperty) { prop->append_value(v); } else { - prop->set_writeable_value(v); + prop->set_value(v); } return; } } - PropertyList_add(plist, k, v); + PropertyList_add(plist, k, v, writeable == WriteableProperty, internal == InternalProperty); } // Copies src into buf, replacing "%%" with "%" and "%p" with pid --- old/src/share/vm/runtime/arguments.hpp 2016-07-15 07:00:14.355006143 +0100 +++ new/src/share/vm/runtime/arguments.hpp 2016-07-15 07:00:14.250999037 +0100 @@ -43,7 +43,7 @@ // PathString is used as: // - the underlying value for a SystemProperty -// - the path portion of an -Xpatch module/path pair +// - the path portion of an --patch-module module/path pair // - the string that represents the system boot class path, Arguments::_system_boot_class_path. class PathString : public CHeapObj { protected: @@ -107,13 +107,13 @@ } }; -// ModuleXPatchPath records the module/path pair as specified to -Xpatch. -class ModuleXPatchPath : public CHeapObj { +// ModulePatchPath records the module/path pair as specified to --patch-module. +class ModulePatchPath : public CHeapObj { private: char* _module_name; PathString* _path; public: - ModuleXPatchPath(const char* module_name, const char* path) { + ModulePatchPath(const char* module_name, const char* path) { assert(module_name != NULL && path != NULL, "Invalid module name or path value"); size_t len = strlen(module_name) + 1; _module_name = AllocateHeap(len, mtInternal); @@ -121,7 +121,7 @@ _path = new PathString(path); } - ~ModuleXPatchPath() { + ~ModulePatchPath() { if (_module_name != NULL) { FreeHeap(_module_name); _module_name = NULL; @@ -325,6 +325,21 @@ arg_in_range = 0 }; + enum PropertyAppendable { + AppendProperty, + AddProperty + }; + + enum PropertyWriteable { + WriteableProperty, + UnwriteableProperty + }; + + enum PropertyInternal { + InternalProperty, + ExternalProperty + }; + private: // a pointer to the flags file name if it is specified @@ -348,18 +363,18 @@ static SystemProperty *_java_class_path; static SystemProperty *_jdk_boot_class_path_append; - // -Xpatch:module=()* + // --patch-module=module=()* // Each element contains the associated module name, path - // string pair as specified to -Xpatch. - static GrowableArray* _xpatchprefix; + // string pair as specified to --patch-module. + static GrowableArray* _patch_mod_prefix; // The constructed value of the system class path after // argument processing and JVMTI OnLoad additions via // calls to AddToBootstrapClassLoaderSearch. This is the // final form before ClassLoader::setup_bootstrap_search(). - // Note: since -Xpatch is a module name/path pair, the system - // boot class path string no longer contains the "prefix" to - // the boot class path base piece as it did when + // Note: since --patch-module is a module name/path pair, the + // system boot class path string no longer contains the "prefix" + // to the boot class path base piece as it did when // -Xbootclasspath/p was supported. static PathString *_system_boot_class_path; @@ -464,7 +479,13 @@ static vfprintf_hook_t _vfprintf_hook; // System properties - static bool add_property(const char* prop); + static bool add_property(const char* prop, PropertyWriteable writeable=WriteableProperty, + PropertyInternal internal=ExternalProperty); + + static bool create_property(const char* prop_name, const char* prop_value, PropertyInternal internal); + static bool create_numbered_property(const char* prop_base_name, const char* prop_value, unsigned int count); + + static int process_patch_mod_option(const char* patch_mod_tail, bool* patch_mod_javabase); // Miscellaneous system property setter static bool append_to_addmods_property(const char* module_name); @@ -502,7 +523,7 @@ static jint parse_vm_init_args(const JavaVMInitArgs *java_tool_options_args, const JavaVMInitArgs *java_options_args, const JavaVMInitArgs *cmd_line_args); - static jint parse_each_vm_init_arg(const JavaVMInitArgs* args, bool* xpatch_javabase, Flag::Flags origin); + static jint parse_each_vm_init_arg(const JavaVMInitArgs* args, bool* patch_mod_javabase, Flag::Flags origin); static jint finalize_vm_init_args(); static bool is_bad_option(const JavaVMOption* option, jboolean ignore, const char* option_type); @@ -721,16 +742,18 @@ // Property List manipulation static void PropertyList_add(SystemProperty *element); static void PropertyList_add(SystemProperty** plist, SystemProperty *element); - static void PropertyList_add(SystemProperty** plist, const char* k, const char* v); - static void PropertyList_unique_add(SystemProperty** plist, const char* k, const char* v) { - PropertyList_unique_add(plist, k, v, false); - } - static void PropertyList_unique_add(SystemProperty** plist, const char* k, const char* v, jboolean append); + static void PropertyList_add(SystemProperty** plist, const char* k, const char* v, bool writeable, bool internal); + + static void PropertyList_unique_add(SystemProperty** plist, const char* k, const char* v, + PropertyAppendable append, PropertyWriteable writeable, + PropertyInternal internal); static const char* PropertyList_get_value(SystemProperty* plist, const char* key); static int PropertyList_count(SystemProperty* pl); static const char* PropertyList_get_key_at(SystemProperty* pl,int index); static char* PropertyList_get_value_at(SystemProperty* pl,int index); + static bool is_internal_module_property(const char* option); + // Miscellaneous System property value getter and setters. static void set_dll_dir(const char *value) { _sun_boot_library_path->set_value(value); } static void set_java_home(const char *value) { _java_home->set_value(value); } @@ -738,7 +761,7 @@ static void set_ext_dirs(char *value) { _ext_dirs = os::strdup_check_oom(value); } // Set up the underlying pieces of the system boot class path - static void add_xpatchprefix(const char *module_name, const char *path, bool* xpatch_javabase); + static void add_patch_mod_prefix(const char *module_name, const char *path, bool* patch_mod_javabase); static void set_sysclasspath(const char *value) { _system_boot_class_path->set_value(value); set_jdkbootclasspath_append(); @@ -749,7 +772,7 @@ } static void set_jdkbootclasspath_append(); - static GrowableArray* get_xpatchprefix() { return _xpatchprefix; } + static GrowableArray* get_patch_mod_prefix() { return _patch_mod_prefix; } static char* get_sysclasspath() { return _system_boot_class_path->value(); } static char* get_jdk_boot_class_path_append() { return _jdk_boot_class_path_append->value(); } --- old/src/share/vm/runtime/init.cpp 2016-07-15 07:00:14.748032998 +0100 +++ new/src/share/vm/runtime/init.cpp 2016-07-15 07:00:14.646026028 +0100 @@ -117,7 +117,7 @@ if (status != JNI_OK) return status; - classLoader_init2(); // after SymbolTable creation, set up -Xpatch entries + classLoader_init2(); // after SymbolTable creation, set up --patch-module entries CodeCacheExtensions::complete_step(CodeCacheExtensionsSteps::Universe); interpreter_init(); // before any methods loaded CodeCacheExtensions::complete_step(CodeCacheExtensionsSteps::Interpreter); --- old/test/TEST.ROOT 2016-07-15 07:00:15.115058076 +0100 +++ new/test/TEST.ROOT 2016-07-15 07:00:15.015051243 +0100 @@ -53,5 +53,5 @@ # does not need ../../ notation to reach them external.lib.roots = ../../ -# Use new form of -Xpatch +# Use new form of --patch-module useNewXpatch=true --- old/test/compiler/unsafe/UnsafeGetConstantField.java 2016-07-15 07:00:15.486083427 +0100 +++ new/test/compiler/unsafe/UnsafeGetConstantField.java 2016-07-15 07:00:15.384076458 +0100 @@ -40,7 +40,7 @@ * -XX:CompileCommand=dontinline,UnsafeGetConstantField.checkGetAddress() * -XX:CompileCommand=dontinline,*.test* * -XX:+UseUnalignedAccesses - * -XaddReads:java.base=ALL-UNNAMED + * --add-reads=java.base=ALL-UNNAMED * compiler.unsafe.UnsafeGetConstantField * * @run main/bootclasspath/othervm -XX:+UnlockDiagnosticVMOptions @@ -50,7 +50,7 @@ * -XX:CompileCommand=dontinline,*.test* * -XX:CompileCommand=inline,*Unsafe.get* * -XX:-UseUnalignedAccesses - * -XaddReads:java.base=ALL-UNNAMED + * --add-reads=java.base=ALL-UNNAMED * compiler.unsafe.UnsafeGetConstantField */ package compiler.unsafe; --- old/test/gc/arguments/TestMaxMinHeapFreeRatioFlags.java 2016-07-15 07:00:15.866109394 +0100 +++ new/test/gc/arguments/TestMaxMinHeapFreeRatioFlags.java 2016-07-15 07:00:15.765102492 +0100 @@ -88,7 +88,7 @@ (useXmaxf ? "-Xmaxf" + maxRatio / 100.0 : "-XX:MaxHeapFreeRatio=" + maxRatio), "-Xmx" + MAX_HEAP_SIZE, "-Xms" + HEAP_SIZE, - "-XaddExports:java.base/jdk.internal.misc=ALL-UNNAMED", + "--add-exports=java.base/jdk.internal.misc=ALL-UNNAMED", "-XX:NewSize=" + NEW_SIZE, "-XX:MaxNewSize=" + MAX_NEW_SIZE, "-XX:" + (shrinkHeapInSteps ? '+' : '-') + "ShrinkHeapInSteps", @@ -120,7 +120,7 @@ Collections.addAll(vmOptions, (useXminf ? "-Xminf" + minRatio / 100.0 : "-XX:MinHeapFreeRatio=" + minRatio), (useXmaxf ? "-Xmaxf" + maxRatio / 100.0 : "-XX:MaxHeapFreeRatio=" + maxRatio), - "-XaddExports:java.base/jdk.internal.misc=ALL-UNNAMED", + "--add-exports=java.base/jdk.internal.misc=ALL-UNNAMED", "-version" ); ProcessBuilder procBuilder = ProcessTools.createJavaProcessBuilder(vmOptions.toArray(new String[vmOptions.size()])); --- old/test/gc/arguments/TestSurvivorRatioFlag.java 2016-07-15 07:00:16.248135497 +0100 +++ new/test/gc/arguments/TestSurvivorRatioFlag.java 2016-07-15 07:00:16.146128526 +0100 @@ -74,7 +74,7 @@ Collections.addAll(vmOptions, "-Xbootclasspath/a:.", - "-XaddExports:java.base/jdk.internal.misc=ALL-UNNAMED", + "--add-exports=java.base/jdk.internal.misc=ALL-UNNAMED", "-XX:+UnlockDiagnosticVMOptions", "-XX:+WhiteBoxAPI", "-XX:GCLockerEdenExpansionPercent=0", --- old/test/gc/arguments/TestTargetSurvivorRatioFlag.java 2016-07-15 07:00:16.618160779 +0100 +++ new/test/gc/arguments/TestTargetSurvivorRatioFlag.java 2016-07-15 07:00:16.516153810 +0100 @@ -132,7 +132,7 @@ LinkedList vmOptions = new LinkedList<>(options); Collections.addAll(vmOptions, "-Xbootclasspath/a:.", - "-XaddExports:java.base/jdk.internal.misc=ALL-UNNAMED", + "--add-exports=java.base/jdk.internal.misc=ALL-UNNAMED", "-XX:+UnlockDiagnosticVMOptions", "-XX:+WhiteBoxAPI", "-XX:+UseAdaptiveSizePolicy", --- old/test/gc/g1/TestShrinkAuxiliaryData.java 2016-07-15 07:00:16.995186540 +0100 +++ new/test/gc/g1/TestShrinkAuxiliaryData.java 2016-07-15 07:00:16.894179640 +0100 @@ -52,7 +52,7 @@ "-Xlog:gc=debug", "-XX:+UnlockDiagnosticVMOptions", "-XX:+WhiteBoxAPI", - "-XaddExports:java.base/jdk.internal.misc=ALL-UNNAMED", + "--add-exports=java.base/jdk.internal.misc=ALL-UNNAMED", "-Xbootclasspath/a:.", }; --- old/test/runtime/BadObjectClass/BootstrapRedefine.java 2016-07-15 07:00:17.366211892 +0100 +++ new/test/runtime/BadObjectClass/BootstrapRedefine.java 2016-07-15 07:00:17.265204990 +0100 @@ -48,7 +48,7 @@ "-Xmodule:java.base"), "mods/java.base"); - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("-Xpatch:java.base=mods/java.base", "-version"); + ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("--patch-module=java.base=mods/java.base", "-version"); new OutputAnalyzer(pb.start()) .shouldContain("Incompatible definition of java.lang.Object") .shouldHaveExitValue(1); --- old/test/runtime/BootClassAppendProp/BootClassPathAppendProp.java 2016-07-15 07:00:17.726236491 +0100 +++ new/test/runtime/BootClassAppendProp/BootClassPathAppendProp.java 2016-07-15 07:00:17.626229658 +0100 @@ -27,7 +27,7 @@ * @test * @build BootClassPathAppendProp * @run main/othervm -Xbootclasspath/a:/usr/lib -showversion -Xbootclasspath/a:/i/dont/exist BootClassPathAppendProp - * @run main/othervm -Xpatch:/not/here -Xbootclasspath/a:/i/may/exist BootClassPathAppendProp + * @run main/othervm --patch-module=no_module=/not/here -Xbootclasspath/a:/i/may/exist BootClassPathAppendProp * @run main/othervm -Djdk.boot.class.path.append=newdir BootClassPathAppendProp * @run main/othervm BootClassPathAppendProp */ --- old/test/runtime/ErrorHandling/CreateCoredumpOnCrash.java 2016-07-15 07:00:18.095261706 +0100 +++ new/test/runtime/ErrorHandling/CreateCoredumpOnCrash.java 2016-07-15 07:00:17.991254599 +0100 @@ -56,7 +56,7 @@ public static OutputAnalyzer runTest(String option) throws Exception { return new OutputAnalyzer( ProcessTools.createJavaProcessBuilder( - "-Xmx64m", "-XX:-TransmitErrorReport", "-XaddExports:java.base/jdk.internal.misc=ALL-UNNAMED", option, Crasher.class.getName()) + "-Xmx64m", "-XX:-TransmitErrorReport", "--add-exports=java.base/jdk.internal.misc=ALL-UNNAMED", option, Crasher.class.getName()) .start()); } } --- old/test/runtime/SharedArchiveFile/BootAppendTests.java 2016-07-15 07:00:18.464286920 +0100 +++ new/test/runtime/SharedArchiveFile/BootAppendTests.java 2016-07-15 07:00:18.360279814 +0100 @@ -160,10 +160,10 @@ // Test #3: If a class on -Xbootclasspath/a is from a package defined in boot modules, // the class can be loaded from -Xbootclasspath/a when the module is excluded - // using -limitmods. Verify the behavior is the same at runtime when CDS is - // enabled. + // using --limit-modules. Verify the behavior is the same at runtime when CDS + // is enabled. // - // The java.desktop module is excluded using -limitmods at runtime, + // The java.desktop module is excluded using --limit-modules at runtime, // javax.sound.sampled.MyClass is archived from -Xbootclasspath/a. It can be // loaded from the archive at runtime. public static void testBootAppendExcludedModuleClass() throws Exception { @@ -174,7 +174,7 @@ "-XX:+TraceClassLoading", "-cp", appJar, "-Xbootclasspath/a:" + bootAppendJar, - "-limitmods", "java.base", + "--limit-modules=java.base", "-Xshare:" + mode, APP_CLASS, BOOT_APPEND_MODULE_CLASS_NAME); @@ -191,8 +191,8 @@ // Test #4: If a class on -Xbootclasspath/a has the same fully qualified // name as a class defined in boot modules, the class is loaded // from -Xbootclasspath/a when the boot module is excluded using - // -limitmods. Verify the behavior is the same at runtime when CDS is - // enabled. + // --limit-modules. Verify the behavior is the same at runtime + // when CDS is enabled. // // The org.omg.CORBA.Context is a boot module class. The class // on -Xbootclasspath/a that has the same fully-qualified name @@ -206,7 +206,7 @@ "-XX:+TraceClassLoading", "-cp", appJar, "-Xbootclasspath/a:" + bootAppendJar, - "-limitmods", "java.base", + "--limit-modules=java.base", "-Xshare:" + mode, APP_CLASS, BOOT_APPEND_DUPLICATE_MODULE_CLASS_NAME); --- old/test/runtime/SharedArchiveFile/SASymbolTableTest.java 2016-07-15 07:00:18.821311315 +0100 +++ new/test/runtime/SharedArchiveFile/SASymbolTableTest.java 2016-07-15 07:00:18.724304687 +0100 @@ -86,10 +86,10 @@ long pid = p.getPid(); System.out.println("Attaching agent " + pid); ProcessBuilder tool = ProcessTools.createJavaProcessBuilder( - "-XaddExports:jdk.hotspot.agent/sun.jvm.hotspot.oops=ALL-UNNAMED", - "-XaddExports:jdk.hotspot.agent/sun.jvm.hotspot.memory=ALL-UNNAMED", - "-XaddExports:jdk.hotspot.agent/sun.jvm.hotspot.runtime=ALL-UNNAMED", - "-XaddExports:jdk.hotspot.agent/sun.jvm.hotspot.tools=ALL-UNNAMED", + "--add-exports=jdk.hotspot.agent/sun.jvm.hotspot.oops=ALL-UNNAMED", + "--add-exports=jdk.hotspot.agent/sun.jvm.hotspot.memory=ALL-UNNAMED", + "--add-exports=jdk.hotspot.agent/sun.jvm.hotspot.runtime=ALL-UNNAMED", + "--add-exports=jdk.hotspot.agent/sun.jvm.hotspot.tools=ALL-UNNAMED", "SASymbolTableTestAgent", Long.toString(pid)); OutputAnalyzer output = ProcessTools.executeProcess(tool); --- old/test/runtime/Unsafe/RangeCheck.java 2016-07-15 07:00:19.178335710 +0100 +++ new/test/runtime/Unsafe/RangeCheck.java 2016-07-15 07:00:19.076328740 +0100 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -44,7 +44,7 @@ ProcessBuilder pb = ProcessTools.createJavaProcessBuilder( true, "-Xmx32m", - "-XaddExports:java.base/jdk.internal.misc=ALL-UNNAMED", + "--add-exports=java.base/jdk.internal.misc=ALL-UNNAMED", "-XX:-TransmitErrorReport", "-XX:-CreateCoredumpOnCrash", "-XX:-InlineUnsafeOps", // The compiler intrinsics doesn't have the assert --- old/test/runtime/getSysPackage/GetSysPkgTest.java 2016-07-15 07:00:19.550361129 +0100 +++ new/test/runtime/getSysPackage/GetSysPkgTest.java 2016-07-15 07:00:19.448354160 +0100 @@ -98,7 +98,7 @@ ClassFileInstaller.writeClassToDisk("GetSysPkg_package/GetSysClass", klassbuf); ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("-Xbootclasspath/a:bl_dir", - "-XaddExports:java.base/jdk.internal.loader=ALL-UNNAMED", "-cp", "." + File.pathSeparator + + "--add-exports=java.base/jdk.internal.loader=ALL-UNNAMED", "-cp", "." + File.pathSeparator + System.getProperty("test.classes"), "GetSysPkgTest", "do_tests"); OutputAnalyzer output = new OutputAnalyzer(pb.start()); output.shouldHaveExitValue(0); --- old/test/runtime/modules/Visibility/XbootcpNoVisibility.java 2016-07-15 07:00:19.921386480 +0100 +++ new/test/runtime/modules/Visibility/XbootcpNoVisibility.java 2016-07-15 07:00:19.817379374 +0100 @@ -50,7 +50,7 @@ // Try loading a class within a named package in a module which has been defined // to the boot loader. In this situation, the class should only be attempted // to be loaded from the boot loader's module path which consists of: - // [-Xpatch]; exploded build | "modules" jimage + // [--patch-module]; exploded build | "modules" jimage // // Since the class is located on the boot loader's append path via // -Xbootclasspath/a specification, it should not be found. --- old/test/runtime/modules/java.base/java/lang/reflect/ModuleHelper.java 2016-07-15 07:00:20.287411490 +0100 +++ new/test/runtime/modules/java.base/java/lang/reflect/ModuleHelper.java 2016-07-15 07:00:20.186404589 +0100 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -27,7 +27,7 @@ /** * A helper class intended to be injected into java.lang.reflect using the - * java -Xpatch option. The helper class provides access to package private + * java --patch-module option. The helper class provides access to package private * methods in java.lang.reflect.Module. */ --- old/test/serviceability/sa/jmap-hprof/JMapHProfLargeHeapTest.java 2016-07-15 07:00:20.655436637 +0100 +++ new/test/serviceability/sa/jmap-hprof/JMapHProfLargeHeapTest.java 2016-07-15 07:00:20.554429735 +0100 @@ -84,7 +84,7 @@ String expectedFormat) throws Exception, IOException, InterruptedException, FileNotFoundException { ProcessBuilder procBuilder = ProcessTools.createJavaProcessBuilder( - "-XaddExports:java.management/sun.management=ALL-UNNAMED", vmArgs, "JMapHProfLargeHeapProc", String.valueOf(heapSize)); + "--add-exports=java.management/sun.management=ALL-UNNAMED", vmArgs, "JMapHProfLargeHeapProc", String.valueOf(heapSize)); procBuilder.redirectError(ProcessBuilder.Redirect.INHERIT); Process largeHeapProc = procBuilder.start(); --- old/test/testlibrary/jittester/Makefile 2016-07-15 07:00:21.017461373 +0100 +++ new/test/testlibrary/jittester/Makefile 2016-07-15 07:00:20.917454540 +0100 @@ -1,5 +1,5 @@ # -# Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved. # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. # # This code is free software; you can redistribute it and/or modify it @@ -95,10 +95,10 @@ @echo 'Main-Class: jdk.test.lib.jittester.Automatic' >> $(MANIFEST) compile_testlib: INIT - $(JAVAC) -XDignore.symbol.file -XaddExports:java.base/jdk.internal.misc=ALL-UNNAMED -XaddExports:java.base/jdk.internal.org.objectweb.asm=ALL-UNNAMED -Xlint $(TESTLIBRARY_SRC_FILES) -d $(CLASSES_DIR) + $(JAVAC) -XDignore.symbol.file --add-exports=java.base/jdk.internal.misc=ALL-UNNAMED --add-exports=java.base/jdk.internal.org.objectweb.asm=ALL-UNNAMED -Xlint $(TESTLIBRARY_SRC_FILES) -d $(CLASSES_DIR) COMPILE: INIT filelist compile_testlib - $(JAVAC) -cp $(CLASSES_DIR) -XDignore.symbol.file -XaddExports:java.base/jdk.internal.misc=ALL-UNNAMED -XaddExports:java.base/jdk.internal.org.objectweb.asm=ALL-UNNAMED -Xlint -sourcepath $(SRC_DIR) -d $(CLASSES_DIR) @filelist + $(JAVAC) -cp $(CLASSES_DIR) -XDignore.symbol.file --add-exports=java.base/jdk.internal.misc=ALL-UNNAMED --add-exports=java.base/jdk.internal.org.objectweb.asm=ALL-UNNAMED -Xlint -sourcepath $(SRC_DIR) -d $(CLASSES_DIR) @filelist filelist: $(SRC_FILES) @rm -f $@ @@ -109,7 +109,7 @@ $(shell if [ ! -d $(CLASSES_DIR) ]; then mkdir -p $(CLASSES_DIR); fi) install: clean_testbase testgroup testroot copytestlibrary JAR cleantmp - $(JAVA) -XaddExports:java.base/jdk.internal.org.objectweb.asm=ALL-UNNAMED -ea -jar $(DIST_JAR) $(APPLICATION_ARGS) + $(JAVA) --add-exports=java.base/jdk.internal.org.objectweb.asm=ALL-UNNAMED -ea -jar $(DIST_JAR) $(APPLICATION_ARGS) clean_testbase: @rm -rf $(TESTBASE_DIR) --- /dev/null 2016-02-05 17:55:23.637999981 +0000 +++ new/test/runtime/modules/IgnoreModulePropertiesTest.java 2016-07-15 07:00:21.284479617 +0100 @@ -0,0 +1,75 @@ +/* + * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 8136930 + * @summary Test that the VM ignores explicitly specified module internal properties. + * @modules java.base/jdk.internal.misc + * @library /testlibrary + */ + +import jdk.test.lib.*; + +// Test that the VM ignores module related properties such as "jdk.module.addmods" +// and jdk.module.addreads.0" that can only be set using module options. +public class IgnoreModulePropertiesTest { + + // Test that the specified property and its value are ignored. If the VM accepted + // the property and value then an exception would be thrown because the value is + // bogus for that property. But, since the property is ignored no exception is + // thrown. + public static void testProperty(String prop, String value) throws Exception { + ProcessBuilder pb = ProcessTools.createJavaProcessBuilder( + "-D" + prop + "=" + value, "-version"); + OutputAnalyzer output = new OutputAnalyzer(pb.start()); + output.shouldContain("java version "); + output.shouldHaveExitValue(0); + + // Ensure that the property and its value aren't available. + if (System.getProperty(prop) != null) { + throw new RuntimeException( + "Unexpected non-null value for property " + prop); + } + } + + // For options of the form "option=value", check that an exception gets thrown for + // the illegal value and then check that its corresponding property is handled + // correctly. + public static void testOption(String option, String value, + String prop, String result) throws Exception { + ProcessBuilder pb = ProcessTools.createJavaProcessBuilder( + option + "=" + value, "-version"); + OutputAnalyzer output = new OutputAnalyzer(pb.start()); + output.shouldContain(result); + testProperty(prop, value); + } + + public static void main(String[] args) throws Exception { + testOption("--add-modules", "java.sqlx", "jdk.module.addmods", "java.lang.module.ResolutionException"); + testOption("--limit-modules", "java.sqlx", "jdk.module.limitmods", "java.lang.module.ResolutionException"); + testOption("--add-reads", "xyzz=yyzd", "jdk.module.addreads.0", "java.lang.RuntimeException"); + testOption("--add-exports", "java.base/xyzz=yyzd", "jdk.module.addexports.0", "java.lang.RuntimeException"); + testOption("--patch-module", "=d", "jdk.module.patch.0", "IllegalArgumentException"); + } +} --- /dev/null 2016-02-05 17:55:23.637999981 +0000 +++ new/test/runtime/modules/ModuleOptionsTest.java 2016-07-15 07:00:21.624502850 +0100 @@ -0,0 +1,54 @@ +/* + * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 8136930 + * @summary Test that the VM only recognizes the last specified --add-modules + * and --list-modules options + * @modules java.base/jdk.internal.misc + * @library /testlibrary + */ + +import jdk.test.lib.*; + +// Test that the VM behaves correctly when processing module related options. +public class ModuleOptionsTest { + + public static void main(String[] args) throws Exception { + + // Test that last --add-modules is the only one recognized. No exception + // should be thrown. + ProcessBuilder pb = ProcessTools.createJavaProcessBuilder( + "--add-modules=i_dont_exist", "--add-modules=java.base", "-version"); + OutputAnalyzer output = new OutputAnalyzer(pb.start()); + output.shouldHaveExitValue(0); + + // Test that last --limit-modules is the only one recognized. No exception + // should be thrown. + pb = ProcessTools.createJavaProcessBuilder( + "--limit-modules=i_dont_exist", "--limit-modules=java.base", "-version"); + output = new OutputAnalyzer(pb.start()); + output.shouldHaveExitValue(0); + } +} --- old/test/runtime/modules/Xpatch/BasicJarBuilder.java 2016-07-15 07:00:22.141538178 +0100 +++ /dev/null 2016-02-05 17:55:23.637999981 +0000 @@ -1,96 +0,0 @@ -/* - * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -/* - * @summary Simple jar builder - * Input: jarName className1 className2 ... - * do not specify extensions, just the names - * E.g. prot_domain ProtDomainA ProtDomainB - * Output: A jar containing compiled classes, placed in a test classes folder - */ - -import jdk.test.lib.*; - -import java.io.File; -import java.util.ArrayList; -import sun.tools.jar.Main; - -// Using JarBuilder requires that all to-be-jarred classes should be placed -// in the current working directory, aka "." -public class BasicJarBuilder { - private static final String classDir = System.getProperty("test.classes"); - - public static void build(boolean classesInWorkDir, String jarName, - String ...classNames) throws Exception { - - if (classesInWorkDir) { - createSimpleJar(".", classDir + File.separator + jarName + ".jar", classNames); - } else { - build(jarName, classNames); - } - } - - public static void build(String jarName, String ...classNames) throws Exception { - createSimpleJar(classDir, classDir + File.separator + jarName + ".jar", - classNames); - } - - private static void createSimpleJar(String jarclassDir, String jarName, - String[] classNames) throws Exception { - ArrayList args = new ArrayList(); - args.add("cf"); - args.add(jarName); - addClassArgs(args, jarclassDir, classNames); - createJar(args); - } - - private static void addClassArgs(ArrayList args, String jarclassDir, - String[] classNames) { - - for (String name : classNames) { - args.add("-C"); - args.add(jarclassDir); - args.add(name + ".class"); - } - } - - private static void createJar(ArrayList args) { - Main jarTool = new Main(System.out, System.err, "jar"); - if (!jarTool.run(args.toArray(new String[1]))) { - throw new RuntimeException("jar operation failed"); - } - } - - // Get full path to the test jar - public static String getTestJar(String jar) { - File dir = new File(System.getProperty("test.classes", ".")); - File jarFile = new File(dir, jar); - if (!jarFile.exists()) { - throw new RuntimeException("Cannot find " + jarFile.getPath()); - } - if (!jarFile.isFile()) { - throw new RuntimeException("Not a regular file: " + jarFile.getPath()); - } - return jarFile.getPath(); - } -} --- /dev/null 2016-02-05 17:55:23.637999981 +0000 +++ new/test/runtime/modules/PatchModule/BasicJarBuilder.java 2016-07-15 07:00:21.966526220 +0100 @@ -0,0 +1,96 @@ +/* + * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @summary Simple jar builder + * Input: jarName className1 className2 ... + * do not specify extensions, just the names + * E.g. prot_domain ProtDomainA ProtDomainB + * Output: A jar containing compiled classes, placed in a test classes folder + */ + +import jdk.test.lib.*; + +import java.io.File; +import java.util.ArrayList; +import sun.tools.jar.Main; + +// Using JarBuilder requires that all to-be-jarred classes should be placed +// in the current working directory, aka "." +public class BasicJarBuilder { + private static final String classDir = System.getProperty("test.classes"); + + public static void build(boolean classesInWorkDir, String jarName, + String ...classNames) throws Exception { + + if (classesInWorkDir) { + createSimpleJar(".", classDir + File.separator + jarName + ".jar", classNames); + } else { + build(jarName, classNames); + } + } + + public static void build(String jarName, String ...classNames) throws Exception { + createSimpleJar(classDir, classDir + File.separator + jarName + ".jar", + classNames); + } + + private static void createSimpleJar(String jarclassDir, String jarName, + String[] classNames) throws Exception { + ArrayList args = new ArrayList(); + args.add("cf"); + args.add(jarName); + addClassArgs(args, jarclassDir, classNames); + createJar(args); + } + + private static void addClassArgs(ArrayList args, String jarclassDir, + String[] classNames) { + + for (String name : classNames) { + args.add("-C"); + args.add(jarclassDir); + args.add(name + ".class"); + } + } + + private static void createJar(ArrayList args) { + Main jarTool = new Main(System.out, System.err, "jar"); + if (!jarTool.run(args.toArray(new String[1]))) { + throw new RuntimeException("jar operation failed"); + } + } + + // Get full path to the test jar + public static String getTestJar(String jar) { + File dir = new File(System.getProperty("test.classes", ".")); + File jarFile = new File(dir, jar); + if (!jarFile.exists()) { + throw new RuntimeException("Cannot find " + jarFile.getPath()); + } + if (!jarFile.isFile()) { + throw new RuntimeException("Not a regular file: " + jarFile.getPath()); + } + return jarFile.getPath(); + } +} --- old/test/runtime/modules/Xpatch/Xpatch2Dirs.java 2016-07-15 07:00:22.459559908 +0100 +++ /dev/null 2016-02-05 17:55:23.637999981 +0000 @@ -1,70 +0,0 @@ -/* - * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -/* - * @test - * @summary Make sure -Xpatch works with multiple directories. - * @modules java.base/jdk.internal.misc - * @library /testlibrary - * @compile Xpatch2DirsMain.java - * @run main Xpatch2Dirs - */ - -import jdk.test.lib.*; -import java.io.File; - -public class Xpatch2Dirs { - - public static void main(String[] args) throws Exception { - String source1 = "package javax.naming.spi; " + - "public class NamingManager { " + - " static { " + - " System.out.println(\"I pass one!\"); " + - " } " + - "}"; - String source2 = "package java.beans; " + - "public class Encoder { " + - " static { " + - " System.out.println(\"I pass two!\"); " + - " } " + - "}"; - - ClassFileInstaller.writeClassToDisk("javax/naming/spi/NamingManager", - InMemoryJavaCompiler.compile("javax.naming.spi.NamingManager", source1, "-Xmodule:java.naming"), - "mods/java.naming"); - - ClassFileInstaller.writeClassToDisk("java/beans/Encoder", - InMemoryJavaCompiler.compile("java.beans.Encoder", source2, "-Xmodule:java.desktop"), - "mods2/java.desktop"); - - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder( - "-Xpatch:java.naming=mods/java.naming", - "-Xpatch:java.desktop=mods2/java.desktop", - "Xpatch2DirsMain", "javax.naming.spi.NamingManager", "java.beans.Encoder"); - - OutputAnalyzer oa = new OutputAnalyzer(pb.start()); - oa.shouldContain("I pass one!"); - oa.shouldContain("I pass two!"); - oa.shouldHaveExitValue(0); - } -} --- /dev/null 2016-02-05 17:55:23.637999981 +0000 +++ new/test/runtime/modules/PatchModule/PatchModule2Dirs.java 2016-07-15 07:00:22.279547608 +0100 @@ -0,0 +1,70 @@ +/* + * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @summary Make sure --patch-module works with multiple directories. + * @modules java.base/jdk.internal.misc + * @library /testlibrary + * @compile PatchModule2DirsMain.java + * @run main PatchModule2Dirs + */ + +import jdk.test.lib.*; +import java.io.File; + +public class PatchModule2Dirs { + + public static void main(String[] args) throws Exception { + String source1 = "package javax.naming.spi; " + + "public class NamingManager { " + + " static { " + + " System.out.println(\"I pass one!\"); " + + " } " + + "}"; + String source2 = "package java.beans; " + + "public class Encoder { " + + " static { " + + " System.out.println(\"I pass two!\"); " + + " } " + + "}"; + + ClassFileInstaller.writeClassToDisk("javax/naming/spi/NamingManager", + InMemoryJavaCompiler.compile("javax.naming.spi.NamingManager", source1, "-Xmodule:java.naming"), + "mods/java.naming"); + + ClassFileInstaller.writeClassToDisk("java/beans/Encoder", + InMemoryJavaCompiler.compile("java.beans.Encoder", source2, "-Xmodule:java.desktop"), + "mods2/java.desktop"); + + ProcessBuilder pb = ProcessTools.createJavaProcessBuilder( + "--patch-module=java.naming=mods/java.naming", + "--patch-module=java.desktop=mods2/java.desktop", + "PatchModule2DirsMain", "javax.naming.spi.NamingManager", "java.beans.Encoder"); + + OutputAnalyzer oa = new OutputAnalyzer(pb.start()); + oa.shouldContain("I pass one!"); + oa.shouldContain("I pass two!"); + oa.shouldHaveExitValue(0); + } +} --- old/test/runtime/modules/Xpatch/Xpatch2DirsMain.java 2016-07-15 07:00:22.909590657 +0100 +++ /dev/null 2016-02-05 17:55:23.637999981 +0000 @@ -1,31 +0,0 @@ -/* - * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -// This loads the class affected by the -Xpatch option. For the test to pass -// it must load both classes from the -Xpatch directory, not the jimage file. -public class Xpatch2DirsMain { - public static void main(String[] args) throws Exception { - Class.forName(args[0]); - Class.forName(args[1]); - } -} --- /dev/null 2016-02-05 17:55:23.637999981 +0000 +++ new/test/runtime/modules/PatchModule/PatchModule2DirsMain.java 2016-07-15 07:00:22.734578699 +0100 @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +// This loads the class affected by the --patch-module option. For the test to pass +// it must load both classes from the --patch-module directory, not the jimage file. +public class PatchModule2DirsMain { + public static void main(String[] args) throws Exception { + Class.forName(args[0]); + Class.forName(args[1]); + } +} --- old/test/runtime/modules/XpatchCDS.java 2016-07-15 07:00:23.359621407 +0100 +++ /dev/null 2016-02-05 17:55:23.637999981 +0000 @@ -1,62 +0,0 @@ -/* - * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -/* - * @test - * @library /testlibrary - * @modules java.base/jdk.internal.misc - * @run main XpatchCDS - */ - -import java.io.File; -import jdk.test.lib.*; - -public class XpatchCDS { - - public static void main(String args[]) throws Throwable { - System.out.println("Test that -Xpatch and -Xshare:dump are incompatibable"); - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("-Xpatch:java.naming=mods/java.naming", "-Xshare:dump"); - OutputAnalyzer output = new OutputAnalyzer(pb.start()); - output.shouldContain("Cannot use the following option when dumping the shared archive: -Xpatch"); - - System.out.println("Test that -Xpatch and -Xshare:on are incompatibable"); - String filename = "Xpatch.jsa"; - pb = ProcessTools.createJavaProcessBuilder( - "-XX:+UnlockDiagnosticVMOptions", - "-XX:SharedArchiveFile=" + filename, - "-Xshare:dump"); - output = new OutputAnalyzer(pb.start()); - output.shouldContain("ro space:"); // Make sure archive got created. - - pb = ProcessTools.createJavaProcessBuilder( - "-XX:+UnlockDiagnosticVMOptions", - "-XX:SharedArchiveFile=" + filename, - "-Xshare:on", - "-Xpatch:java.naming=mods/java.naming", - "-version"); - output = new OutputAnalyzer(pb.start()); - output.shouldContain("The shared archive file cannot be used with -Xpatch"); - - output.shouldHaveExitValue(1); - } -} --- /dev/null 2016-02-05 17:55:23.637999981 +0000 +++ new/test/runtime/modules/PatchModule/PatchModuleCDS.java 2016-07-15 07:00:23.179609107 +0100 @@ -0,0 +1,62 @@ +/* + * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @library /testlibrary + * @modules java.base/jdk.internal.misc + * @run main PatchModuleCDS + */ + +import java.io.File; +import jdk.test.lib.*; + +public class PatchModuleCDS { + + public static void main(String args[]) throws Throwable { + System.out.println("Test that --patch-module and -Xshare:dump are incompatibable"); + ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("--patch-module=java.naming=mods/java.naming", "-Xshare:dump"); + OutputAnalyzer output = new OutputAnalyzer(pb.start()); + output.shouldContain("Cannot use the following option when dumping the shared archive: --patch-module"); + + System.out.println("Test that --patch-module and -Xshare:on are incompatibable"); + String filename = "patch_module.jsa"; + pb = ProcessTools.createJavaProcessBuilder( + "-XX:+UnlockDiagnosticVMOptions", + "-XX:SharedArchiveFile=" + filename, + "-Xshare:dump"); + output = new OutputAnalyzer(pb.start()); + output.shouldContain("ro space:"); // Make sure archive got created. + + pb = ProcessTools.createJavaProcessBuilder( + "-XX:+UnlockDiagnosticVMOptions", + "-XX:SharedArchiveFile=" + filename, + "-Xshare:on", + "--patch-module=java.naming=mods/java.naming", + "-version"); + output = new OutputAnalyzer(pb.start()); + output.shouldContain("The shared archive file cannot be used with --patch-module"); + + output.shouldHaveExitValue(1); + } +} --- old/test/runtime/modules/Xpatch/XpatchDupJavaBase.java 2016-07-15 07:00:23.808652088 +0100 +++ /dev/null 2016-02-05 17:55:23.637999981 +0000 @@ -1,46 +0,0 @@ -/* - * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -/* - * @test - * @summary VM exit initialization results if java.base is specificed more than once to Xpatch. - * @modules java.base/jdk.internal.misc - * @library /testlibrary - */ - -import jdk.test.lib.*; - -public class XpatchDupJavaBase { - // The VM should exit initialization if java.base is specified - // more than once to -Xpatch. - public static void main(String args[]) throws Exception { - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder( - "-Xpatch:java.base=javabase_dir", - "-Xpatch:java.base=javabase_dir", - "-version"); - OutputAnalyzer output = new OutputAnalyzer(pb.start()); - output.shouldContain("Cannot specify java.base more than once to -Xpatch"); - output.shouldHaveExitValue(1); - } -} - --- /dev/null 2016-02-05 17:55:23.637999981 +0000 +++ new/test/runtime/modules/PatchModule/PatchModuleDupJavaBase.java 2016-07-15 07:00:23.630639925 +0100 @@ -0,0 +1,46 @@ +/* + * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @summary VM exit initialization results if java.base is specificed more than once to --patch-module. + * @modules java.base/jdk.internal.misc + * @library /testlibrary + */ + +import jdk.test.lib.*; + +public class PatchModuleDupJavaBase { + // The VM should exit initialization if java.base is specified + // more than once to --patch-module. + public static void main(String args[]) throws Exception { + ProcessBuilder pb = ProcessTools.createJavaProcessBuilder( + "--patch-module=java.base=javabase_dir", + "--patch-module=java.base=javabase_dir", + "-version"); + OutputAnalyzer output = new OutputAnalyzer(pb.start()); + output.shouldContain("Cannot specify java.base more than once to --patch-module"); + output.shouldHaveExitValue(1); + } +} + --- old/test/runtime/modules/Xpatch/XpatchDupModule.java 2016-07-15 07:00:24.250682291 +0100 +++ /dev/null 2016-02-05 17:55:23.637999981 +0000 @@ -1,48 +0,0 @@ -/* - * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -/* - * @test - * @summary Module system initialization exception results if a module is specificed twice to Xpatch. - * @modules java.base/jdk.internal.misc - * @library /testlibrary - */ - -import jdk.test.lib.*; - -public class XpatchDupModule { - - // The module system initialization should generate an ExceptionInInitializerError - // if -Xpatch is specified with the same module more than once. - - public static void main(String args[]) throws Exception { - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder( - "-Xpatch:module1=module1_dir", - "-Xpatch:module1=module1_dir", - "-version"); - OutputAnalyzer output = new OutputAnalyzer(pb.start()); - output.shouldContain("java.lang.ExceptionInInitializerError"); - output.shouldHaveExitValue(1); - } -} - --- /dev/null 2016-02-05 17:55:23.637999981 +0000 +++ new/test/runtime/modules/PatchModule/PatchModuleDupModule.java 2016-07-15 07:00:24.077670469 +0100 @@ -0,0 +1,47 @@ +/* + * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @summary Module system initialization exception results if a module is specificed twice to --patch-module. + * @modules java.base/jdk.internal.misc + * @library /testlibrary + */ + +import jdk.test.lib.*; + +public class PatchModuleDupModule { + + // The module system initialization should generate an ExceptionInInitializerError + // if --patch-module is specified with the same module more than once. + + public static void main(String args[]) throws Exception { + ProcessBuilder pb = ProcessTools.createJavaProcessBuilder( + "--patch-module=module1=module1_dir", + "--patch-module=module1=module1_dir", + "-version"); + OutputAnalyzer output = new OutputAnalyzer(pb.start()); + output.shouldContain("java.lang.ExceptionInInitializerError"); + output.shouldHaveExitValue(1); + } +} --- old/test/runtime/modules/Xpatch/XpatchJavaBase.java 2016-07-15 07:00:24.695712699 +0100 +++ /dev/null 2016-02-05 17:55:23.637999981 +0000 @@ -1,57 +0,0 @@ -/* - * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -/* - * @test - * @bug 8130399 - * @summary Make sure -Xpatch works for java.base. - * @modules java.base/jdk.internal.misc - * @library /testlibrary - * @compile XpatchMain.java - * @run main XpatchJavaBase - */ - -import jdk.test.lib.*; - -public class XpatchJavaBase { - - public static void main(String[] args) throws Exception { - String source = "package java.lang; " + - "public class NewClass { " + - " static { " + - " System.out.println(\"I pass!\"); " + - " } " + - "}"; - - ClassFileInstaller.writeClassToDisk("java/lang/NewClass", - InMemoryJavaCompiler.compile("java.lang.NewClass", source, "-Xmodule:java.base"), - "mods/java.base"); - - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("-Xpatch:java.base=mods/java.base", - "XpatchMain", "java.lang.NewClass"); - - new OutputAnalyzer(pb.start()) - .shouldContain("I pass!") - .shouldHaveExitValue(0); - } -} --- /dev/null 2016-02-05 17:55:23.637999981 +0000 +++ new/test/runtime/modules/PatchModule/PatchModuleJavaBase.java 2016-07-15 07:00:24.517700535 +0100 @@ -0,0 +1,57 @@ +/* + * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 8130399 + * @summary Make sure --patch-module works for java.base. + * @modules java.base/jdk.internal.misc + * @library /testlibrary + * @compile PatchModuleMain.java + * @run main PatchModuleJavaBase + */ + +import jdk.test.lib.*; + +public class PatchModuleJavaBase { + + public static void main(String[] args) throws Exception { + String source = "package java.lang; " + + "public class NewClass { " + + " static { " + + " System.out.println(\"I pass!\"); " + + " } " + + "}"; + + ClassFileInstaller.writeClassToDisk("java/lang/NewClass", + InMemoryJavaCompiler.compile("java.lang.NewClass", source, "-Xmodule:java.base"), + "mods/java.base"); + + ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("--patch-module=java.base=mods/java.base", + "PatchModuleMain", "java.lang.NewClass"); + + new OutputAnalyzer(pb.start()) + .shouldContain("I pass!") + .shouldHaveExitValue(0); + } +} --- old/test/runtime/modules/Xpatch/XpatchMain.java 2016-07-15 07:00:25.143743311 +0100 +++ /dev/null 2016-02-05 17:55:23.637999981 +0000 @@ -1,30 +0,0 @@ -/* - * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -// This loads the class affected by the -Xpatch option. For the test to pass -// it must load the class from the -Xpatch directory, not the jimage file. -public class XpatchMain { - public static void main(String[] args) throws Exception { - Class.forName(args[0]); - } -} --- /dev/null 2016-02-05 17:55:23.637999981 +0000 +++ new/test/runtime/modules/PatchModule/PatchModuleMain.java 2016-07-15 07:00:24.967731285 +0100 @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +// This loads the class affected by the --patch-module option. For the test to pass +// it must load the class from the --patch-module directory, not the jimage file. +public class PatchModuleMain { + public static void main(String[] args) throws Exception { + Class.forName(args[0]); + } +} --- old/test/runtime/modules/Xpatch/XpatchTest.java 2016-07-15 07:00:25.592773993 +0100 +++ /dev/null 2016-02-05 17:55:23.637999981 +0000 @@ -1,57 +0,0 @@ -/* - * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -/* - * @test - * @bug 8130399 - * @summary Make sure -Xpatch works for modules besides java.base. - * @modules java.base/jdk.internal.misc - * @library /testlibrary - * @compile XpatchMain.java - * @run main XpatchTest - */ - -import jdk.test.lib.*; - -public class XpatchTest { - - public static void main(String[] args) throws Exception { - String source = "package javax.naming.spi; " + - "public class NamingManager { " + - " static { " + - " System.out.println(\"I pass!\"); " + - " } " + - "}"; - - ClassFileInstaller.writeClassToDisk("javax/naming/spi/NamingManager", - InMemoryJavaCompiler.compile("javax.naming.spi.NamingManager", source, "-Xmodule:java.naming"), - "mods/java.naming"); - - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("-Xpatch:java.naming=mods/java.naming", - "XpatchMain", "javax.naming.spi.NamingManager"); - - new OutputAnalyzer(pb.start()) - .shouldContain("I pass!") - .shouldHaveExitValue(0); - } -} --- /dev/null 2016-02-05 17:55:23.637999981 +0000 +++ new/test/runtime/modules/PatchModule/PatchModuleTest.java 2016-07-15 07:00:25.415761898 +0100 @@ -0,0 +1,57 @@ +/* + * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 8130399 + * @summary Make sure --patch-module works for modules besides java.base. + * @modules java.base/jdk.internal.misc + * @library /testlibrary + * @compile PatchModuleMain.java + * @run main PatchModuleTest + */ + +import jdk.test.lib.*; + +public class PatchModuleTest { + + public static void main(String[] args) throws Exception { + String source = "package javax.naming.spi; " + + "public class NamingManager { " + + " static { " + + " System.out.println(\"I pass!\"); " + + " } " + + "}"; + + ClassFileInstaller.writeClassToDisk("javax/naming/spi/NamingManager", + InMemoryJavaCompiler.compile("javax.naming.spi.NamingManager", source, "-Xmodule:java.naming"), + "mods/java.naming"); + + ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("--patch-module=java.naming=mods/java.naming", + "PatchModuleMain", "javax.naming.spi.NamingManager"); + + new OutputAnalyzer(pb.start()) + .shouldContain("I pass!") + .shouldHaveExitValue(0); + } +} --- old/test/runtime/modules/Xpatch/XpatchTestJar.java 2016-07-15 07:00:26.041804674 +0100 +++ /dev/null 2016-02-05 17:55:23.637999981 +0000 @@ -1,83 +0,0 @@ -/* - * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -/* - * @test - * @summary Make sure -Xpatch works when a jar file is specified for a module - * @library /testlibrary - * @modules java.base/jdk.internal.misc - * jdk.jartool/sun.tools.jar - * @build BasicJarBuilder - * @compile XpatchMain.java - * @run main XpatchTestJar - */ - -import jdk.test.lib.*; - -public class XpatchTestJar { - private static String moduleJar; - - public static void main(String[] args) throws Exception { - - // Create a class file in the module java.naming. This class file - // will be put in the javanaming.jar file. - String source = "package javax.naming.spi; " + - "public class NamingManager { " + - " static { " + - " System.out.println(\"I pass!\"); " + - " } " + - "}"; - - ClassFileInstaller.writeClassToDisk("javax/naming/spi/NamingManager", - InMemoryJavaCompiler.compile("javax.naming.spi.NamingManager", source, "-Xmodule:java.naming"), - System.getProperty("test.classes")); - - // Build the jar file that will be used for the module "java.naming". - BasicJarBuilder.build("javanaming", "javax/naming/spi/NamingManager"); - moduleJar = BasicJarBuilder.getTestJar("javanaming.jar"); - - // Just to make sure we are not fooled by the class file being on the - // class path where all the test classes are stored, write the NamingManager.class - // file out again with output that does not contain what OutputAnalyzer - // expects. This will provide confidence that the contents of the class - // is truly coming from the jar file and not the class file. - source = "package javax.naming.spi; " + - "public class NamingManager { " + - " static { " + - " System.out.println(\"Fail!\"); " + - " } " + - "}"; - - ClassFileInstaller.writeClassToDisk("javax/naming/spi/NamingManager", - InMemoryJavaCompiler.compile("javax.naming.spi.NamingManager", source, "-Xmodule:java.naming"), - System.getProperty("test.classes")); - - // Supply -Xpatch with the name of the jar file for the module java.naming. - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("-Xpatch:java.naming=" + moduleJar, - "XpatchMain", "javax.naming.spi.NamingManager"); - - new OutputAnalyzer(pb.start()) - .shouldContain("I pass!") - .shouldHaveExitValue(0); - } -} --- /dev/null 2016-02-05 17:55:23.637999981 +0000 +++ new/test/runtime/modules/PatchModule/PatchModuleTestJar.java 2016-07-15 07:00:25.867792784 +0100 @@ -0,0 +1,83 @@ +/* + * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @summary Make sure --patch-module works when a jar file is specified for a module + * @library /testlibrary + * @modules java.base/jdk.internal.misc + * jdk.jartool/sun.tools.jar + * @build BasicJarBuilder + * @compile PatchModuleMain.java + * @run main PatchModuleTestJar + */ + +import jdk.test.lib.*; + +public class PatchModuleTestJar { + private static String moduleJar; + + public static void main(String[] args) throws Exception { + + // Create a class file in the module java.naming. This class file + // will be put in the javanaming.jar file. + String source = "package javax.naming.spi; " + + "public class NamingManager { " + + " static { " + + " System.out.println(\"I pass!\"); " + + " } " + + "}"; + + ClassFileInstaller.writeClassToDisk("javax/naming/spi/NamingManager", + InMemoryJavaCompiler.compile("javax.naming.spi.NamingManager", source, "-Xmodule:java.naming"), + System.getProperty("test.classes")); + + // Build the jar file that will be used for the module "java.naming". + BasicJarBuilder.build("javanaming", "javax/naming/spi/NamingManager"); + moduleJar = BasicJarBuilder.getTestJar("javanaming.jar"); + + // Just to make sure we are not fooled by the class file being on the + // class path where all the test classes are stored, write the NamingManager.class + // file out again with output that does not contain what OutputAnalyzer + // expects. This will provide confidence that the contents of the class + // is truly coming from the jar file and not the class file. + source = "package javax.naming.spi; " + + "public class NamingManager { " + + " static { " + + " System.out.println(\"Fail!\"); " + + " } " + + "}"; + + ClassFileInstaller.writeClassToDisk("javax/naming/spi/NamingManager", + InMemoryJavaCompiler.compile("javax.naming.spi.NamingManager", source, "-Xmodule:java.naming"), + System.getProperty("test.classes")); + + // Supply --patch-module with the name of the jar file for the module java.naming. + ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("--patch-module=java.naming=" + moduleJar, + "PatchModuleMain", "javax.naming.spi.NamingManager"); + + new OutputAnalyzer(pb.start()) + .shouldContain("I pass!") + .shouldHaveExitValue(0); + } +} --- old/test/runtime/modules/Xpatch/XpatchTestJarDir.java 2016-07-15 07:00:26.473834193 +0100 +++ /dev/null 2016-02-05 17:55:23.637999981 +0000 @@ -1,105 +0,0 @@ -/* - * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -/* - * @test - * @summary Make sure -Xpatch works when a jar file and a directory is specified for a module - * @library /testlibrary - * @modules java.base/jdk.internal.misc - * jdk.jartool/sun.tools.jar - * @build BasicJarBuilder - * @compile Xpatch2DirsMain.java - * @run main XpatchTestJarDir - */ - -import java.io.File; -import java.nio.file.Files; -import jdk.test.lib.*; - -public class XpatchTestJarDir { - private static String moduleJar; - - public static void main(String[] args) throws Exception { - - // Create a class file in the module java.naming. This class file - // will be put in the javanaming.jar file. - String source = "package javax.naming.spi; " + - "public class NamingManager1 { " + - " static { " + - " System.out.println(\"I pass one!\"); " + - " } " + - "}"; - - ClassFileInstaller.writeClassToDisk("javax/naming/spi/NamingManager1", - InMemoryJavaCompiler.compile("javax.naming.spi.NamingManager1", source, "-Xmodule:java.naming"), - System.getProperty("test.classes")); - - // Build the jar file that will be used for the module "java.naming". - BasicJarBuilder.build("javanaming", "javax/naming/spi/NamingManager1"); - moduleJar = BasicJarBuilder.getTestJar("javanaming.jar"); - - // Just to make sure we are not fooled by the class file being on the - // class path where all the test classes are stored, write the NamingManager.class - // file out again with output that does not contain what OutputAnalyzer - // expects. This will provide confidence that the contents of the class - // is truly coming from the jar file and not the class file. - source = "package javax.naming.spi; " + - "public class NamingManager1 { " + - " static { " + - " System.out.println(\"Fail!\"); " + - " } " + - "}"; - - ClassFileInstaller.writeClassToDisk("javax/naming/spi/NamingManager1", - InMemoryJavaCompiler.compile("javax.naming.spi.NamingManager1", source, "-Xmodule:java.naming"), - System.getProperty("test.classes")); - - // Create a second class file in the module java.naming. This class file - // will be put in the mods/java.naming directory. - source = "package javax.naming.spi; " + - "public class NamingManager2 { " + - " static { " + - " System.out.println(\"I pass two!\"); " + - " } " + - "}"; - - ClassFileInstaller.writeClassToDisk("javax/naming/spi/NamingManager2", - InMemoryJavaCompiler.compile("javax.naming.spi.NamingManager2", source, "-Xmodule:java.naming"), - (System.getProperty("test.classes") + "/mods/java.naming")); - - - // Supply -Xpatch with the name of the jar file for the module java.naming. - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("-Xpatch:java.naming=" + - moduleJar + - File.pathSeparator + - System.getProperty("test.classes") + "/mods/java.naming", - "Xpatch2DirsMain", - "javax.naming.spi.NamingManager1", - "javax.naming.spi.NamingManager2"); - - new OutputAnalyzer(pb.start()) - .shouldContain("I pass one!") - .shouldContain("I pass two!") - .shouldHaveExitValue(0); - } -} --- /dev/null 2016-02-05 17:55:23.637999981 +0000 +++ new/test/runtime/modules/PatchModule/PatchModuleTestJarDir.java 2016-07-15 07:00:26.302822509 +0100 @@ -0,0 +1,105 @@ +/* + * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @summary Make sure --patch-module works when a jar file and a directory is specified for a module + * @library /testlibrary + * @modules java.base/jdk.internal.misc + * jdk.jartool/sun.tools.jar + * @build BasicJarBuilder + * @compile PatchModule2DirsMain.java + * @run main PatchModuleTestJarDir + */ + +import java.io.File; +import java.nio.file.Files; +import jdk.test.lib.*; + +public class PatchModuleTestJarDir { + private static String moduleJar; + + public static void main(String[] args) throws Exception { + + // Create a class file in the module java.naming. This class file + // will be put in the javanaming.jar file. + String source = "package javax.naming.spi; " + + "public class NamingManager1 { " + + " static { " + + " System.out.println(\"I pass one!\"); " + + " } " + + "}"; + + ClassFileInstaller.writeClassToDisk("javax/naming/spi/NamingManager1", + InMemoryJavaCompiler.compile("javax.naming.spi.NamingManager1", source, "-Xmodule:java.naming"), + System.getProperty("test.classes")); + + // Build the jar file that will be used for the module "java.naming". + BasicJarBuilder.build("javanaming", "javax/naming/spi/NamingManager1"); + moduleJar = BasicJarBuilder.getTestJar("javanaming.jar"); + + // Just to make sure we are not fooled by the class file being on the + // class path where all the test classes are stored, write the NamingManager.class + // file out again with output that does not contain what OutputAnalyzer + // expects. This will provide confidence that the contents of the class + // is truly coming from the jar file and not the class file. + source = "package javax.naming.spi; " + + "public class NamingManager1 { " + + " static { " + + " System.out.println(\"Fail!\"); " + + " } " + + "}"; + + ClassFileInstaller.writeClassToDisk("javax/naming/spi/NamingManager1", + InMemoryJavaCompiler.compile("javax.naming.spi.NamingManager1", source, "-Xmodule:java.naming"), + System.getProperty("test.classes")); + + // Create a second class file in the module java.naming. This class file + // will be put in the mods/java.naming directory. + source = "package javax.naming.spi; " + + "public class NamingManager2 { " + + " static { " + + " System.out.println(\"I pass two!\"); " + + " } " + + "}"; + + ClassFileInstaller.writeClassToDisk("javax/naming/spi/NamingManager2", + InMemoryJavaCompiler.compile("javax.naming.spi.NamingManager2", source, "-Xmodule:java.naming"), + (System.getProperty("test.classes") + "/mods/java.naming")); + + + // Supply --patch-module with the name of the jar file for the module java.naming. + ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("--patch-module=java.naming=" + + moduleJar + + File.pathSeparator + + System.getProperty("test.classes") + "/mods/java.naming", + "PatchModule2DirsMain", + "javax.naming.spi.NamingManager1", + "javax.naming.spi.NamingManager2"); + + new OutputAnalyzer(pb.start()) + .shouldContain("I pass one!") + .shouldContain("I pass two!") + .shouldHaveExitValue(0); + } +} --- old/test/runtime/modules/Xpatch/XpatchTraceCL.java 2016-07-15 07:00:26.918864601 +0100 +++ /dev/null 2016-02-05 17:55:23.637999981 +0000 @@ -1,83 +0,0 @@ -/* - * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -/* - * @test - * @bug 8069469 - * @summary Make sure -Xlog:classload=info works properly with "modules" jimage, - -Xpatch, and with -Xbootclasspath/a - * @modules java.base/jdk.internal.misc - * @library /testlibrary - * @compile XpatchMain.java - * @run main XpatchTraceCL - */ - -import java.io.File; -import jdk.test.lib.*; - -public class XpatchTraceCL { - - public static void main(String[] args) throws Exception { - String source = "package javax.naming.spi; " + - "public class NamingManager { " + - " static { " + - " System.out.println(\"I pass!\"); " + - " } " + - "}"; - - // Test -Xlog:classload=info output for -Xpatch - ClassFileInstaller.writeClassToDisk("javax/naming/spi/NamingManager", - InMemoryJavaCompiler.compile("javax.naming.spi.NamingManager", source, "-Xmodule:java.naming"), - "mods/java.naming"); - - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("-Xpatch:java.naming=mods/java.naming", - "-Xlog:class+load=info", "XpatchMain", "javax.naming.spi.NamingManager"); - - OutputAnalyzer output = new OutputAnalyzer(pb.start()); - // "modules" jimage case. - output.shouldContain("[class,load] java.lang.Thread source: jrt:/java.base"); - // -Xpatch case. - output.shouldContain("[class,load] javax.naming.spi.NamingManager source: mods/java.naming"); - // -cp case. - output.shouldContain("[class,load] XpatchMain source: file"); - - // Test -Xlog:classload=info output for -Xbootclasspath/a - source = "package XpatchTraceCL_pkg; " + - "public class ItIsI { " + - " static { " + - " System.out.println(\"I also pass!\"); " + - " } " + - "}"; - - ClassFileInstaller.writeClassToDisk("XpatchTraceCL_pkg/ItIsI", - InMemoryJavaCompiler.compile("XpatchTraceCL_pkg.ItIsI", source), - "xbcp"); - - pb = ProcessTools.createJavaProcessBuilder("-Xbootclasspath/a:xbcp", - "-Xlog:class+load=info", "XpatchMain", "XpatchTraceCL_pkg.ItIsI"); - output = new OutputAnalyzer(pb.start()); - // -Xbootclasspath/a case. - output.shouldContain("[class,load] XpatchTraceCL_pkg.ItIsI source: xbcp"); - output.shouldHaveExitValue(0); - } -} --- /dev/null 2016-02-05 17:55:23.637999981 +0000 +++ new/test/runtime/modules/PatchModule/PatchModuleTraceCL.java 2016-07-15 07:00:26.745852780 +0100 @@ -0,0 +1,83 @@ +/* + * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 8069469 + * @summary Make sure -Xlog:classload=info works properly with "modules" jimage, + --patch-module, and with -Xbootclasspath/a + * @modules java.base/jdk.internal.misc + * @library /testlibrary + * @compile PatchModuleMain.java + * @run main PatchModuleTraceCL + */ + +import java.io.File; +import jdk.test.lib.*; + +public class PatchModuleTraceCL { + + public static void main(String[] args) throws Exception { + String source = "package javax.naming.spi; " + + "public class NamingManager { " + + " static { " + + " System.out.println(\"I pass!\"); " + + " } " + + "}"; + + // Test -Xlog:classload=info output for --patch-module + ClassFileInstaller.writeClassToDisk("javax/naming/spi/NamingManager", + InMemoryJavaCompiler.compile("javax.naming.spi.NamingManager", source, "-Xmodule:java.naming"), + "mods/java.naming"); + + ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("--patch-module=java.naming=mods/java.naming", + "-Xlog:class+load=info", "PatchModuleMain", "javax.naming.spi.NamingManager"); + + OutputAnalyzer output = new OutputAnalyzer(pb.start()); + // "modules" jimage case. + output.shouldContain("[class,load] java.lang.Thread source: jrt:/java.base"); + // --patch-module case. + output.shouldContain("[class,load] javax.naming.spi.NamingManager source: mods/java.naming"); + // -cp case. + output.shouldContain("[class,load] PatchModuleMain source: file"); + + // Test -Xlog:classload=info output for -Xbootclasspath/a + source = "package PatchModuleTraceCL_pkg; " + + "public class ItIsI { " + + " static { " + + " System.out.println(\"I also pass!\"); " + + " } " + + "}"; + + ClassFileInstaller.writeClassToDisk("PatchModuleTraceCL_pkg/ItIsI", + InMemoryJavaCompiler.compile("PatchModuleTraceCL_pkg.ItIsI", source), + "xbcp"); + + pb = ProcessTools.createJavaProcessBuilder("-Xbootclasspath/a:xbcp", + "-Xlog:class+load=info", "PatchModuleMain", "PatchModuleTraceCL_pkg.ItIsI"); + output = new OutputAnalyzer(pb.start()); + // -Xbootclasspath/a case. + output.shouldContain("[class,load] PatchModuleTraceCL_pkg.ItIsI source: xbcp"); + output.shouldHaveExitValue(0); + } +} --- old/test/runtime/modules/Visibility/XpatchVisibility.java 2016-07-15 07:00:27.360894804 +0100 +++ /dev/null 2016-02-05 17:55:23.637999981 +0000 @@ -1,91 +0,0 @@ -/* - * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -/* - * @test - * @summary Ensure that a newly introduced java.base package placed within the -Xpatch directory - * is considered part of the boot loader's visibility boundary - * @requires !(os.family == "windows") - * @library /testlibrary - * @modules java.base/jdk.internal.misc - * java.management - * @run main/othervm XpatchVisibility - */ - -import java.io.File; -import java.nio.file.Files; -import java.nio.file.Paths; - -import jdk.test.lib.*; - -public class XpatchVisibility { - - public static void main(String[] args) throws Throwable { - - String Vis2_B_src = - "package p2;" + - "public class Vis2_B {" + - " public void m() {" + - " System.out.println(\"In B's m()\");" + - " }" + - "}"; - - String Vis2_A_src = - "import p2.*;" + - "public class Vis2_A {" + - " public static void main(String args[]) throws Exception {" + - // Try loading a class within a newly introduced java.base - // package. Make sure the class can be found via -Xpatch. - " try {" + - " p2.Vis2_B b = new p2.Vis2_B();" + - " if (b.getClass().getClassLoader() != null) {" + - " throw new RuntimeException(\"XpatchVisibility FAILED - class B " + - "should be loaded by boot class loader\\n\");" + - " }" + - " b.m();" + - " } catch (Throwable e) {" + - " throw new RuntimeException(\"XpatchVisibility FAILED - test " + - "should not throw an error or exception\\n\");" + - " }" + - " System.out.println(\"XpatchVisibility PASSED\\n\");" + - " }" + - "}"; - - ClassFileInstaller.writeClassToDisk("p2/Vis2_B", - InMemoryJavaCompiler.compile("p2.Vis2_B", Vis2_B_src), System.getProperty("test.classes")); - ClassFileInstaller.writeClassToDisk("p2/Vis2_B", "mods2/java.base"); - - ClassFileInstaller.writeClassToDisk("Vis2_A", - InMemoryJavaCompiler.compile("Vis2_A", Vis2_A_src), System.getProperty("test.classes")); - - // Make sure the classes are actually being loaded from mods2 - Files.delete(Paths.get(System.getProperty("test.classes") + File.separator + - "p2" + File.separator + "Vis2_B.class")); - - new OutputAnalyzer(ProcessTools.createJavaProcessBuilder( - "-Xpatch:java.base=mods2/java.base", - "-XaddExports:java.base/p2=ALL-UNNAMED", - "Vis2_A") - .start()).shouldHaveExitValue(0); - } -} --- /dev/null 2016-02-05 17:55:23.637999981 +0000 +++ new/test/runtime/modules/Visibility/PatchModuleVisibility.java 2016-07-15 07:00:27.187882983 +0100 @@ -0,0 +1,91 @@ +/* + * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @summary Ensure that a newly introduced java.base package placed within the --patch-module + * directory is considered part of the boot loader's visibility boundary + * @requires !(os.family == "windows") + * @library /testlibrary + * @modules java.base/jdk.internal.misc + * java.management + * @run main/othervm PatchModuleVisibility + */ + +import java.io.File; +import java.nio.file.Files; +import java.nio.file.Paths; + +import jdk.test.lib.*; + +public class PatchModuleVisibility { + + public static void main(String[] args) throws Throwable { + + String Vis2_B_src = + "package p2;" + + "public class Vis2_B {" + + " public void m() {" + + " System.out.println(\"In B's m()\");" + + " }" + + "}"; + + String Vis2_A_src = + "import p2.*;" + + "public class Vis2_A {" + + " public static void main(String args[]) throws Exception {" + + // Try loading a class within a newly introduced java.base + // package. Make sure the class can be found via --patch-module. + " try {" + + " p2.Vis2_B b = new p2.Vis2_B();" + + " if (b.getClass().getClassLoader() != null) {" + + " throw new RuntimeException(\"PatchModuleVisibility FAILED - class B " + + "should be loaded by boot class loader\\n\");" + + " }" + + " b.m();" + + " } catch (Throwable e) {" + + " throw new RuntimeException(\"PatchModuleVisibility FAILED - test " + + "should not throw an error or exception\\n\");" + + " }" + + " System.out.println(\"PatchModuleVisibility PASSED\\n\");" + + " }" + + "}"; + + ClassFileInstaller.writeClassToDisk("p2/Vis2_B", + InMemoryJavaCompiler.compile("p2.Vis2_B", Vis2_B_src), System.getProperty("test.classes")); + ClassFileInstaller.writeClassToDisk("p2/Vis2_B", "mods2/java.base"); + + ClassFileInstaller.writeClassToDisk("Vis2_A", + InMemoryJavaCompiler.compile("Vis2_A", Vis2_A_src), System.getProperty("test.classes")); + + // Make sure the classes are actually being loaded from mods2 + Files.delete(Paths.get(System.getProperty("test.classes") + File.separator + + "p2" + File.separator + "Vis2_B.class")); + + new OutputAnalyzer(ProcessTools.createJavaProcessBuilder( + "--patch-module=java.base=mods2/java.base", + "--add-exports=java.base/p2=ALL-UNNAMED", + "Vis2_A") + .start()).shouldHaveExitValue(0); + } +}