--- old/src/share/vm/classfile/classLoader.cpp 2017-03-23 14:05:04.022147603 -0400 +++ new/src/share/vm/classfile/classLoader.cpp 2017-03-23 14:05:03.522147582 -0400 @@ -1720,7 +1720,8 @@ { MutexLocker ml(Module_lock, THREAD); - ModuleEntry* jb_module = null_cld_modules->locked_create_entry_or_null(Handle(NULL), vmSymbols::java_base(), NULL, NULL, null_cld); + ModuleEntry* jb_module = null_cld_modules->locked_create_entry_or_null(Handle(NULL), + false, vmSymbols::java_base(), NULL, NULL, null_cld); if (jb_module == NULL) { vm_exit_during_initialization("Unable to create ModuleEntry for " JAVA_BASE_NAME); } --- old/src/share/vm/classfile/moduleEntry.cpp 2017-03-23 14:05:05.594147668 -0400 +++ new/src/share/vm/classfile/moduleEntry.cpp 2017-03-23 14:05:05.086147647 -0400 @@ -166,6 +166,12 @@ } } +// Set whether the module is open, i.e. all its packages are unqualifiedly exported +void ModuleEntry::set_is_open(bool is_open) { + assert_lock_strong(Module_lock); + _is_open = is_open; +} + bool ModuleEntry::has_reads() const { assert_locked_or_safepoint(Module_lock); return ((_reads != NULL) && !_reads->is_empty()); @@ -269,12 +275,12 @@ // For the boot loader, the java.lang.reflect.Module for the unnamed module // is not known until a call to JVM_SetBootLoaderUnnamedModule is made. At // this point initially create the ModuleEntry for the unnamed module. - _unnamed_module = new_entry(0, Handle(NULL), NULL, NULL, NULL, loader_data); + _unnamed_module = new_entry(0, Handle(NULL), true, NULL, NULL, NULL, loader_data); } else { // For all other class loaders the java.lang.reflect.Module for their // corresponding unnamed module can be found in the java.lang.ClassLoader object. oop module = java_lang_ClassLoader::unnamedModule(loader_data->class_loader()); - _unnamed_module = new_entry(0, Handle(module), NULL, NULL, NULL, loader_data); + _unnamed_module = new_entry(0, Handle(module), true, NULL, NULL, NULL, loader_data); // Store pointer to the ModuleEntry in the unnamed module's java.lang.reflect.Module // object. @@ -285,7 +291,8 @@ add_entry(0, _unnamed_module); } -ModuleEntry* ModuleEntryTable::new_entry(unsigned int hash, Handle module_handle, Symbol* name, +ModuleEntry* ModuleEntryTable::new_entry(unsigned int hash, Handle module_handle, + bool is_open, Symbol* name, Symbol* version, Symbol* location, ClassLoaderData* loader_data) { assert(Module_lock->owned_by_self(), "should have the Module_lock"); @@ -312,6 +319,7 @@ entry->set_loader_data(loader_data); entry->set_version(version); entry->set_location(location); + entry->set_is_open(is_open); if (ClassLoader::is_in_patch_mod_entries(name)) { entry->set_is_patched(); @@ -332,6 +340,7 @@ } ModuleEntry* ModuleEntryTable::locked_create_entry_or_null(Handle module_handle, + bool is_open, Symbol* module_name, Symbol* module_version, Symbol* module_location, @@ -342,7 +351,7 @@ if (lookup_only(module_name) != NULL) { return NULL; } else { - ModuleEntry* entry = new_entry(compute_hash(module_name), module_handle, module_name, + ModuleEntry* entry = new_entry(compute_hash(module_name), module_handle, is_open, module_name, module_version, module_location, loader_data); add_entry(index_for(module_name), entry); return entry; --- old/src/share/vm/classfile/moduleEntry.hpp 2017-03-23 14:05:07.106147730 -0400 +++ new/src/share/vm/classfile/moduleEntry.hpp 2017-03-23 14:05:06.598147709 -0400 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2017, 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 @@ -65,6 +65,7 @@ bool _can_read_all_unnamed; bool _has_default_read_edges; // JVMTI redefine/retransform support bool _must_walk_reads; // walk module's reads list at GC safepoints to purge out dead modules + bool _is_open; // whether the packages in the module are all unqualifiedly exported bool _is_patched; // whether the module is patched via --patch-module TRACE_DEFINE_TRACE_ID_FIELD; enum {MODULE_READS_SIZE = 101}; // Initial size of list of modules that the module can read. @@ -81,6 +82,7 @@ _has_default_read_edges = false; _must_walk_reads = false; _is_patched = false; + _is_open = false; } Symbol* name() const { return literal(); } @@ -112,6 +114,9 @@ void add_read(ModuleEntry* m); void set_read_walk_required(ClassLoaderData* m_loader_data); + bool is_open() const { return _is_open; } + void set_is_open(bool is_open); + bool is_named() const { return (name() != NULL); } bool can_read_all_unnamed() const { @@ -193,8 +198,8 @@ static ModuleEntry* _javabase_module; ModuleEntry* _unnamed_module; - ModuleEntry* new_entry(unsigned int hash, Handle module_handle, Symbol* name, Symbol* version, - Symbol* location, ClassLoaderData* loader_data); + ModuleEntry* new_entry(unsigned int hash, Handle module_handle, bool is_open, + Symbol* name, Symbol* version, Symbol* location, ClassLoaderData* loader_data); void add_entry(int index, ModuleEntry* new_entry); int entry_size() const { return BasicHashtable::entry_size(); } @@ -217,6 +222,7 @@ // Create module in loader's module entry table, if already exists then // return null. Assume Module_lock has been locked by caller. ModuleEntry* locked_create_entry_or_null(Handle module_handle, + bool is_open, Symbol* module_name, Symbol* module_version, Symbol* module_location, --- old/src/share/vm/classfile/modules.cpp 2017-03-23 14:05:08.622147793 -0400 +++ new/src/share/vm/classfile/modules.cpp 2017-03-23 14:05:08.114147772 -0400 @@ -244,9 +244,11 @@ pkg_list->length()); // packages defined to java.base - for (int x = 0; x < pkg_list->length(); x++) { - log_trace(modules)("define_javabase_module(): creation of package %s for module " JAVA_BASE_NAME, - (pkg_list->at(x))->as_C_string()); + if (log_is_enabled(Trace, modules)) { + for (int x = 0; x < pkg_list->length(); x++) { + log_trace(modules)("define_javabase_module(): creation of package %s for module " JAVA_BASE_NAME, + (pkg_list->at(x))->as_C_string()); + } } } @@ -264,7 +266,7 @@ } } -void Modules::define_module(jobject module, jstring version, +void Modules::define_module(jobject module, jboolean is_open, jstring version, jstring location, const char* const* packages, jsize num_packages, TRAPS) { ResourceMark rm(THREAD); @@ -404,7 +406,8 @@ // Add the module and its packages. if (!dupl_modules && existing_pkg == NULL) { // Create the entry for this module in the class loader's module entry table. - ModuleEntry* module_entry = module_table->locked_create_entry_or_null(module_handle, module_symbol, + ModuleEntry* module_entry = module_table->locked_create_entry_or_null(module_handle, + (is_open == JNI_TRUE), module_symbol, version_symbol, location_symbol, loader_data); if (module_entry == NULL) { @@ -514,8 +517,8 @@ "from_module cannot be found"); } - // All packages in unnamed are exported by default. - if (!from_module_entry->is_named()) return; + // All packages in unnamed and open modules are exported by default. + if (!from_module_entry->is_named() || from_module_entry->is_open()) return; ModuleEntry* to_module_entry; if (to_module == NULL) { --- old/src/share/vm/classfile/modules.hpp 2017-03-23 14:05:10.134147855 -0400 +++ new/src/share/vm/classfile/modules.hpp 2017-03-23 14:05:09.638147835 -0400 @@ -1,5 +1,5 @@ /* -* Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. +* Copyright (c) 2016, 2017, 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 @@ -51,7 +51,7 @@ // * num_packages is negative // * num_packages is non-zero when packages is null // NullPointerExceptions are thrown if module is null. - static void define_module(jobject module, jstring version, + static void define_module(jobject module, jboolean is_open, jstring version, jstring location, const char* const* packages, jsize num_packages, TRAPS); --- old/src/share/vm/classfile/packageEntry.cpp 2017-03-23 14:05:11.654147918 -0400 +++ new/src/share/vm/classfile/packageEntry.cpp 2017-03-23 14:05:11.142147897 -0400 @@ -96,12 +96,15 @@ // Illegal to convert an unqualified exported package to be qualifiedly exported return; } + if (module()->is_open()) { + // No-op for open modules since all packages are unqualifiedly exported + return; + } if (m == NULL) { // NULL indicates the package is being unqualifiedly exported. Clean up // the qualified list at the next safepoint. set_unqual_exported(); - } else { // Add the exported module add_qexport(m); @@ -111,6 +114,11 @@ // Set the package as exported to all unnamed modules unless the package is // already unqualifiedly exported. void PackageEntry::set_is_exported_allUnnamed() { + if (module()->is_open()) { + // No-op for open modules since all packages are unqualifiedly exported + return; + } + MutexLocker m1(Module_lock); if (!is_unqual_exported()) { _export_flags = PKG_EXP_ALLUNNAMED; @@ -208,11 +216,6 @@ // Initialize fields specific to a PackageEntry entry->init(); entry->name()->increment_refcount(); - if (!module->is_named()) { - // Set the exported state to true because all packages - // within the unnamed module are unqualifiedly exported - entry->set_unqual_exported(); - } entry->set_module(module); return entry; } --- old/src/share/vm/classfile/packageEntry.hpp 2017-03-23 14:05:13.186147981 -0400 +++ new/src/share/vm/classfile/packageEntry.hpp 2017-03-23 14:05:12.686147961 -0400 @@ -128,7 +128,9 @@ // package's export state bool is_exported() const { // qualifiedly or unqualifiedly exported assert_locked_or_safepoint(Module_lock); - return ((_export_flags & PKG_EXP_UNQUALIFIED_OR_ALL_UNAMED) != 0) || has_qual_exports_list(); + return module()->is_open() || + ((_export_flags & PKG_EXP_UNQUALIFIED_OR_ALL_UNAMED) != 0) || + has_qual_exports_list(); } // Returns true if the package has any explicit qualified exports or is exported to all unnamed bool is_qual_exported() const { @@ -149,7 +151,7 @@ } bool is_unqual_exported() const { assert_locked_or_safepoint(Module_lock); - return (_export_flags == PKG_EXP_UNQUALIFIED); + return module()->is_open() || (_export_flags == PKG_EXP_UNQUALIFIED); } // Explicitly set _export_flags to PKG_EXP_UNQUALIFIED and clear --- old/src/share/vm/prims/jvm.cpp 2017-03-23 14:05:14.710148044 -0400 +++ new/src/share/vm/prims/jvm.cpp 2017-03-23 14:05:14.194148023 -0400 @@ -1011,7 +1011,7 @@ JVM_ENTRY(void, JVM_DefineModule(JNIEnv *env, jobject module, jboolean is_open, jstring version, jstring location, const char* const* packages, jsize num_packages)) JVMWrapper("JVM_DefineModule"); - Modules::define_module(module, version, location, packages, num_packages, CHECK); + Modules::define_module(module, is_open, version, location, packages, num_packages, CHECK); JVM_END JVM_ENTRY(void, JVM_SetBootLoaderUnnamedModule(JNIEnv *env, jobject module)) --- old/src/share/vm/prims/whitebox.cpp 2017-03-23 14:05:16.262148109 -0400 +++ new/src/share/vm/prims/whitebox.cpp 2017-03-23 14:05:15.762148088 -0400 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2017, 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 @@ -1403,8 +1403,8 @@ MetadataFactory::free_array(cld, (Array*)(uintptr_t)addr); WB_END -WB_ENTRY(void, WB_DefineModule(JNIEnv* env, jobject o, jobject module, jstring version, jstring location, - jobjectArray packages)) +WB_ENTRY(void, WB_DefineModule(JNIEnv* env, jobject o, jobject module, jboolean is_open, + jstring version, jstring location, jobjectArray packages)) ResourceMark rm(THREAD); objArrayOop packages_oop = objArrayOop(JNIHandles::resolve(packages)); @@ -1423,7 +1423,7 @@ pkgs[x] = java_lang_String::as_utf8_string(pkg_str); } } - Modules::define_module(module, version, location, (const char* const*)pkgs, num_packages, CHECK); + Modules::define_module(module, is_open, version, location, (const char* const*)pkgs, num_packages, CHECK); WB_END WB_ENTRY(void, WB_AddModuleExports(JNIEnv* env, jobject o, jobject from_module, jstring package, jobject to_module)) @@ -1904,7 +1904,7 @@ {CC"getCodeBlob", CC"(J)[Ljava/lang/Object;",(void*)&WB_GetCodeBlob }, {CC"getThreadStackSize", CC"()J", (void*)&WB_GetThreadStackSize }, {CC"getThreadRemainingStackSize", CC"()J", (void*)&WB_GetThreadRemainingStackSize }, - {CC"DefineModule", CC"(Ljava/lang/Object;Ljava/lang/String;Ljava/lang/String;[Ljava/lang/Object;)V", + {CC"DefineModule", CC"(Ljava/lang/Object;ZLjava/lang/String;Ljava/lang/String;[Ljava/lang/Object;)V", (void*)&WB_DefineModule }, {CC"AddModuleExports", CC"(Ljava/lang/Object;Ljava/lang/String;Ljava/lang/Object;)V", (void*)&WB_AddModuleExports }, --- old/src/share/vm/runtime/reflection.cpp 2017-03-23 14:05:18.398148197 -0400 +++ new/src/share/vm/runtime/reflection.cpp 2017-03-23 14:05:17.882148175 -0400 @@ -464,8 +464,9 @@ Caller S in package If MS is loose: YES If same classloader/package (PS == PT): YES PS, runtime module MS If MS can read T's If same runtime module: (MS == MT): YES unnamed module: YES - Else if (MS can read MT (Establish readability) && - MT exports PT to MS or to all modules): YES + Else if (MS can read MT (establish readability) && + ((MT exports PT to MS or to all modules) || + (MT is open))): YES ------------------------------------------------------------------------------------------------ Caller S in unnamed YES Readability exists because unnamed module @@ -518,7 +519,7 @@ return ACCESS_OK; } - // Acceptable access to a type in an unamed module. Note that since + // Acceptable access to a type in an unnamed module. Note that since // unnamed modules can read all unnamed modules, this also handles the // case where module_from is also unnamed but in a different class loader. if (!module_to->is_named() && @@ -531,6 +532,11 @@ return MODULE_NOT_READABLE; } + // Access is allowed if module_to is open, i.e. all its packages are unqualifiedly exported + if (module_to->is_open()) { + return ACCESS_OK; + } + PackageEntry* package_to = new_class->package(); assert(package_to != NULL, "can not obtain new_class' package"); --- old/test/runtime/modules/AccessCheckAllUnnamed.java 2017-03-23 14:05:19.918148260 -0400 +++ new/test/runtime/modules/AccessCheckAllUnnamed.java 2017-03-23 14:05:19.402148238 -0400 @@ -57,13 +57,13 @@ // Define a module for p3. m1x = ModuleHelper.ModuleObject("module_one", this_cldr, new String[] { "p3" }); assertNotNull(m1x, "Module should not be null"); - ModuleHelper.DefineModule(m1x, "9.0", "m1x/there", new String[] { "p3" }); + ModuleHelper.DefineModule(m1x, false, "9.0", "m1x/there", new String[] { "p3" }); ModuleHelper.AddReadsModule(m1x, jlObject_jlrM); // Define a module for p2. m2x = ModuleHelper.ModuleObject("module_two", this_cldr, new String[] { "p2" }); assertNotNull(m2x, "Module should not be null"); - ModuleHelper.DefineModule(m2x, "9.0", "m2x/there", new String[] { "p2" }); + ModuleHelper.DefineModule(m2x, false, "9.0", "m2x/there", new String[] { "p2" }); ModuleHelper.AddReadsModule(m2x, jlObject_jlrM); try { --- old/test/runtime/modules/AccessCheckExp.java 2017-03-23 14:05:21.410148321 -0400 +++ new/test/runtime/modules/AccessCheckExp.java 2017-03-23 14:05:20.910148301 -0400 @@ -56,13 +56,13 @@ // Define a module for p1. m1x = ModuleHelper.ModuleObject("module_one", this_cldr, new String[] { "p1" }); assertNotNull(m1x, "Module should not be null"); - ModuleHelper.DefineModule(m1x, "9.0", "m1x/here", new String[] { "p1" }); + ModuleHelper.DefineModule(m1x, false, "9.0", "m1x/here", new String[] { "p1" }); ModuleHelper.AddReadsModule(m1x, jlObject_jlrM); // Define a module for p2. m2x = ModuleHelper.ModuleObject("module_two", this_cldr, new String[] { "p2" }); assertNotNull(m2x, "Module should not be null"); - ModuleHelper.DefineModule(m2x, "9.0", "m2x/there", new String[] { "p2" }); + ModuleHelper.DefineModule(m2x, false, "9.0", "m2x/there", new String[] { "p2" }); ModuleHelper.AddReadsModule(m2x, jlObject_jlrM); // Make package p1 in m1x visible to everyone. @@ -75,7 +75,7 @@ Class p1_c1_class = Class.forName("p1.c1"); try { p1_c1_class.newInstance(); - throw new RuntimeException("Failed to get IAE (p2 in m2x is not exported"); + throw new RuntimeException("Failed to get IAE (p2 in m2x is not exported)"); } catch (IllegalAccessError f) { System.out.println(f.getMessage()); if (!f.getMessage().contains("does not export")) { --- old/test/runtime/modules/AccessCheckJavaBase.java 2017-03-23 14:05:22.922148384 -0400 +++ new/test/runtime/modules/AccessCheckJavaBase.java 2017-03-23 14:05:22.410148363 -0400 @@ -47,7 +47,7 @@ // Define a module for p2. Object m2x = ModuleHelper.ModuleObject("module_two", this_cldr, new String[] { "p2" }); assertNotNull(m2x, "Module should not be null"); - ModuleHelper.DefineModule(m2x, "9.0", "m2x/there", new String[] { "p2" }); + ModuleHelper.DefineModule(m2x, false, "9.0", "m2x/there", new String[] { "p2" }); // p2.c2 can read its superclass java.lang.Object defined within java.base try { --- old/test/runtime/modules/AccessCheckRead.java 2017-03-23 14:05:25.974148510 -0400 +++ new/test/runtime/modules/AccessCheckRead.java 2017-03-23 14:05:23.938148426 -0400 @@ -56,13 +56,13 @@ // Define a module for p1. m1x = ModuleHelper.ModuleObject("module_one", this_cldr, new String[] { "p1" }); assertNotNull(m1x, "Module should not be null"); - ModuleHelper.DefineModule(m1x, "9.0", "m1x/here", new String[] { "p1" }); + ModuleHelper.DefineModule(m1x, false, "9.0", "m1x/here", new String[] { "p1" }); ModuleHelper.AddReadsModule(m1x, jlObject_jlrM); // Define a module for p2. m2x = ModuleHelper.ModuleObject("module_two", this_cldr, new String[] { "p2" }); assertNotNull(m2x, "Module should not be null"); - ModuleHelper.DefineModule(m2x, "9.0", "m2x/there", new String[] { "p2" }); + ModuleHelper.DefineModule(m2x, false, "9.0", "m2x/there", new String[] { "p2" }); ModuleHelper.AddReadsModule(m2x, jlObject_jlrM); // Make package p1 in m1x visible to everyone. --- old/test/runtime/modules/AccessCheckSuper.java 2017-03-23 14:05:29.718148665 -0400 +++ new/test/runtime/modules/AccessCheckSuper.java 2017-03-23 14:05:28.638148620 -0400 @@ -50,12 +50,12 @@ // Define a module for p2. Object m2x = ModuleHelper.ModuleObject("module_two", this_cldr, new String[] { "p2" }); assertNotNull(m2x, "Module should not be null"); - ModuleHelper.DefineModule(m2x, "9.0", "m2x/there", new String[] { "p2" }); + ModuleHelper.DefineModule(m2x, false, "9.0", "m2x/there", new String[] { "p2" }); // Define a module for p3. Object m3x = ModuleHelper.ModuleObject("module_three", this_cldr, new String[] { "p3" }); assertNotNull(m3x, "Module should not be null"); - ModuleHelper.DefineModule(m3x, "9.0", "m3x/there", new String[] { "p3" }); + ModuleHelper.DefineModule(m3x, false, "9.0", "m3x/there", new String[] { "p3" }); // Since a readability edge has not been established between module_two // and module_three, p3.c3 cannot read its superclass p2.c2. --- old/test/runtime/modules/AccessCheckUnnamed.java 2017-03-23 14:05:31.690148746 -0400 +++ new/test/runtime/modules/AccessCheckUnnamed.java 2017-03-23 14:05:31.166148724 -0400 @@ -56,7 +56,7 @@ // Define a module for p2. m2x = ModuleHelper.ModuleObject("module_two", this_cldr, new String[] { "p2" }); assertNotNull(m2x, "Module should not be null"); - ModuleHelper.DefineModule(m2x, "9.0", "m2x/there", new String[] { "p2" }); + ModuleHelper.DefineModule(m2x, false, "9.0", "m2x/there", new String[] { "p2" }); ModuleHelper.AddReadsModule(m2x, jlObject_jlrM); // p1.c1's ctor tries to call a method in p2.c2. This should fail because --- old/test/runtime/modules/AccessCheckWorks.java 2017-03-23 14:05:33.182148808 -0400 +++ new/test/runtime/modules/AccessCheckWorks.java 2017-03-23 14:05:32.686148787 -0400 @@ -57,13 +57,13 @@ // Define a module for p1. m1x = ModuleHelper.ModuleObject("module_one", this_cldr, new String[] { "p1" }); assertNotNull(m1x, "Module should not be null"); - ModuleHelper.DefineModule(m1x, "9.0", "m1x/here", new String[] { "p1" }); + ModuleHelper.DefineModule(m1x, false, "9.0", "m1x/here", new String[] { "p1" }); ModuleHelper.AddReadsModule(m1x, jlObject_jlrM); // Define a module for p2. m2x = ModuleHelper.ModuleObject("module_two", this_cldr, new String[] { "p2" }); assertNotNull(m2x, "Module should not be null"); - ModuleHelper.DefineModule(m2x, "9.0", "m2x/there", new String[] { "p2" }); + ModuleHelper.DefineModule(m2x, false, "9.0", "m2x/there", new String[] { "p2" }); ModuleHelper.AddReadsModule(m2x, jlObject_jlrM); // Make package p1 in m1x visible to everyone. --- old/test/runtime/modules/CCE_module_msg.java 2017-03-23 14:05:34.686148870 -0400 +++ new/test/runtime/modules/CCE_module_msg.java 2017-03-23 14:05:34.166148848 -0400 @@ -85,7 +85,7 @@ // Define a module for p2. Object m2x = ModuleHelper.ModuleObject("module_two", this_cldr, new String[] { "p2" }); assertNotNull(m2x, "Module should not be null"); - ModuleHelper.DefineModule(m2x, "9.0", "m2x/there", new String[] { "p2" }); + ModuleHelper.DefineModule(m2x, false, "9.0", "m2x/there", new String[] { "p2" }); ModuleHelper.AddReadsModule(m2x, jlObject_jlrM); try { --- old/test/runtime/modules/ExportTwice.java 2017-03-23 14:05:36.206148933 -0400 +++ new/test/runtime/modules/ExportTwice.java 2017-03-23 14:05:35.686148911 -0400 @@ -58,19 +58,19 @@ // Define a module for p1. m1x = ModuleHelper.ModuleObject("module_one", this_cldr, new String[] { "p1" }); assertNotNull(m1x, "Module should not be null"); - ModuleHelper.DefineModule(m1x, "9.0", "m1x/here", new String[] { "p1" }); + ModuleHelper.DefineModule(m1x, false, "9.0", "m1x/here", new String[] { "p1" }); ModuleHelper.AddReadsModule(m1x, jlObject_jlrM); // Define a module for p2. m2x = ModuleHelper.ModuleObject("module_two", this_cldr, new String[] { "p2" }); assertNotNull(m2x, "Module should not be null"); - ModuleHelper.DefineModule(m2x, "9.0", "m2x/there", new String[] { "p2" }); + ModuleHelper.DefineModule(m2x, false, "9.0", "m2x/there", new String[] { "p2" }); ModuleHelper.AddReadsModule(m2x, jlObject_jlrM); // Define a module for p3. m3x = ModuleHelper.ModuleObject("module_three", this_cldr, new String[] { "p3" }); assertNotNull(m3x, "Module should not be null"); - ModuleHelper.DefineModule(m3x, "9.0", "m3x/there", new String[] { "p3" }); + ModuleHelper.DefineModule(m3x, false, "9.0", "m3x/there", new String[] { "p3" }); ModuleHelper.AddReadsModule(m3x, jlObject_jlrM); // Make package p1 in m1x visible to everyone. --- old/test/runtime/modules/JVMAddModuleExportToAllUnnamed.java 2017-03-23 14:05:38.306149019 -0400 +++ new/test/runtime/modules/JVMAddModuleExportToAllUnnamed.java 2017-03-23 14:05:37.214148974 -0400 @@ -56,7 +56,7 @@ // Define a module for p1. m1x = ModuleHelper.ModuleObject("module_one", this_cldr, new String[] { "p1" }); assertNotNull(m1x, "Module should not be null"); - ModuleHelper.DefineModule(m1x, "9.0", "m1x/here", new String[] { "p1" }); + ModuleHelper.DefineModule(m1x, false, "9.0", "m1x/here", new String[] { "p1" }); ModuleHelper.AddReadsModule(m1x, jlObject_jlrM); // Make package p1 in m1x visible to everyone. --- old/test/runtime/modules/JVMAddModuleExports.java 2017-03-23 14:05:39.886149085 -0400 +++ new/test/runtime/modules/JVMAddModuleExports.java 2017-03-23 14:05:39.382149064 -0400 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2017, 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,10 +44,10 @@ from_module = ModuleHelper.ModuleObject("from_module", from_cl, new String[] { "mypackage", "this/package" }); assertNotNull(from_module, "Module should not be null"); - ModuleHelper.DefineModule(from_module, "9.0", "from_module/here", new String[] { "mypackage", "this/package" }); + ModuleHelper.DefineModule(from_module, false, "9.0", "from_module/here", new String[] { "mypackage", "this/package" }); to_module = ModuleHelper.ModuleObject("to_module", to_cl, new String[] { "yourpackage", "that/package" }); assertNotNull(to_module, "Module should not be null"); - ModuleHelper.DefineModule(to_module, "9.0", "to_module/here", new String[] { "yourpackage", "that/package" }); + ModuleHelper.DefineModule(to_module, false, "9.0", "to_module/here", new String[] { "yourpackage", "that/package" }); // Null from_module argument, expect an NPE try { --- old/test/runtime/modules/JVMAddModuleExportsToAll.java 2017-03-23 14:05:41.366149146 -0400 +++ new/test/runtime/modules/JVMAddModuleExportsToAll.java 2017-03-23 14:05:40.846149124 -0400 @@ -57,13 +57,13 @@ // Define a module for p3. m1x = ModuleHelper.ModuleObject("module_one", this_cldr, new String[] { "p3" }); assertNotNull(m1x, "Module should not be null"); - ModuleHelper.DefineModule(m1x, "9.0", "m1x/there", new String[] { "p3" }); + ModuleHelper.DefineModule(m1x, false, "9.0", "m1x/there", new String[] { "p3" }); ModuleHelper.AddReadsModule(m1x, jlObject_jlrM); // Define a module for p2. m2x = ModuleHelper.ModuleObject("module_two", this_cldr, new String[] { "p2" }); assertNotNull(m2x, "Module should not be null"); - ModuleHelper.DefineModule(m2x, "9.0", "m2x/there", new String[] { "p2" }); + ModuleHelper.DefineModule(m2x, false, "9.0", "m2x/there", new String[] { "p2" }); ModuleHelper.AddReadsModule(m2x, jlObject_jlrM); try { @@ -105,7 +105,7 @@ // of p2 in m2x to m3x. This should not affect the unqualified export. m3x = ModuleHelper.ModuleObject("module_three", this_cldr, new String[] { "p4" }); assertNotNull(m3x, "Module m3x should not be null"); - ModuleHelper.DefineModule(m3x, "9.0", "m3x/there", new String[] { "p4" }); + ModuleHelper.DefineModule(m3x, false, "9.0", "m3x/there", new String[] { "p4" }); ModuleHelper.AddModuleExportsToAll(m2x, "p2"); ModuleHelper.AddModuleExports(m2x, "p2", m3x); --- old/test/runtime/modules/JVMAddModulePackage.java 2017-03-23 14:05:42.882149208 -0400 +++ new/test/runtime/modules/JVMAddModulePackage.java 2017-03-23 14:05:42.378149188 -0400 @@ -45,13 +45,13 @@ module_one = ModuleHelper.ModuleObject("module_one", cl1, new String[] { "mypackage" }); assertNotNull(module_one, "Module should not be null"); - ModuleHelper.DefineModule(module_one, "9.0", "module_one/here", new String[] { "mypackage" }); + ModuleHelper.DefineModule(module_one, false, "9.0", "module_one/here", new String[] { "mypackage" }); module_two = ModuleHelper.ModuleObject("module_two", cl1, new String[] { "yourpackage" }); assertNotNull(module_two, "Module should not be null"); - ModuleHelper.DefineModule(module_two, "9.0", "module_two/here", new String[] { "yourpackage" }); + ModuleHelper.DefineModule(module_two, false, "9.0", "module_two/here", new String[] { "yourpackage" }); module_three = ModuleHelper.ModuleObject("module_three", cl3, new String[] { "package/num3" }); assertNotNull(module_three, "Module should not be null"); - ModuleHelper.DefineModule(module_three, "9.0", "module_three/here", new String[] { "package/num3" }); + ModuleHelper.DefineModule(module_three, false, "9.0", "module_three/here", new String[] { "package/num3" }); // Simple call ModuleHelper.AddModulePackage(module_one, "new_package"); --- old/test/runtime/modules/JVMAddReadsModule.java 2017-03-23 14:05:44.382149270 -0400 +++ new/test/runtime/modules/JVMAddReadsModule.java 2017-03-23 14:05:43.882149250 -0400 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2017, 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 @@ -43,11 +43,11 @@ from_module = ModuleHelper.ModuleObject("from_module", from_cl, new String[] { "mypackage" }); assertNotNull(from_module, "Module should not be null"); - ModuleHelper.DefineModule(from_module, "9.0", "from_module/here", new String[] { "mypackage" }); + ModuleHelper.DefineModule(from_module, false, "9.0", "from_module/here", new String[] { "mypackage" }); to_module = ModuleHelper.ModuleObject("to_module", to_cl, new String[] { "yourpackage" }); assertNotNull(to_module, "Module should not be null"); - ModuleHelper.DefineModule(to_module, "9.0", "to_module/here", new String[] { "yourpackage" }); + ModuleHelper.DefineModule(to_module, false, "9.0", "to_module/here", new String[] { "yourpackage" }); // Null from_module argument, expect NPE try { --- old/test/runtime/modules/JVMDefineModule.java 2017-03-23 14:05:45.886149332 -0400 +++ new/test/runtime/modules/JVMDefineModule.java 2017-03-23 14:05:45.370149311 -0400 @@ -44,13 +44,13 @@ // NULL classloader argument, expect success m = ModuleHelper.ModuleObject("mymodule", null, new String[] { "mypackage" }); assertNotNull(m, "Module should not be null"); - ModuleHelper.DefineModule(m, "9.0", "mymodule/here", new String[] { "mypackage" }); + ModuleHelper.DefineModule(m, false, "9.0", "mymodule/here", new String[] { "mypackage" }); /* Invalid test, won't compile. // Invalid classloader argument, expect an IAE try { m = ModuleHelper.ModuleObject("mymodule_one", new Object(), new String[] { "mypackage1" }); - ModuleHelper.DefineModule(m, "9.0", "mymodule/here", new String[] { "mypackage1" }); + ModuleHelper.DefineModule(m, false, "9.0", "mymodule/here", new String[] { "mypackage1" }); throw new RuntimeException("Failed to get expected IAE for bad loader"); } catch(IllegalArgumentException e) { // Expected @@ -60,11 +60,11 @@ // NULL package argument, should not throw an exception m = ModuleHelper.ModuleObject("mymoduleTwo", cl, new String[] { "nullpkg" }); assertNotNull(m, "Module should not be null"); - ModuleHelper.DefineModule(m, "9.0", "mymoduleTwo/here", null); + ModuleHelper.DefineModule(m, false, "9.0", "mymoduleTwo/here", null); // Null module argument, expect an NPE try { - ModuleHelper.DefineModule(null, "9.0", "mymodule/here", new String[] { "mypackage1" }); + ModuleHelper.DefineModule(null, false, "9.0", "mymodule/here", new String[] { "mypackage1" }); throw new RuntimeException("Failed to get expected NPE for null module"); } catch(NullPointerException e) { if (!e.getMessage().contains("Null module object")) { @@ -75,7 +75,7 @@ // Invalid module argument, expect an IAE try { - ModuleHelper.DefineModule(new Object(), "9.0", "mymodule/here", new String[] { "mypackage1" }); + ModuleHelper.DefineModule(new Object(), false, "9.0", "mymodule/here", new String[] { "mypackage1" }); throw new RuntimeException("Failed to get expected IAE or NPE for bad module"); } catch(IllegalArgumentException e) { if (!e.getMessage().contains("module is not an instance of type java.lang.reflect.Module")) { @@ -86,7 +86,7 @@ // NULL module name, expect an IAE or NPE try { m = ModuleHelper.ModuleObject(null, cl, new String[] { "mypackage2" }); - ModuleHelper.DefineModule(m, "9.0", "mymodule/here", new String[] { "mypackage2" }); + ModuleHelper.DefineModule(m, false, "9.0", "mymodule/here", new String[] { "mypackage2" }); throw new RuntimeException("Failed to get expected NPE for NULL module"); } catch(IllegalArgumentException e) { // Expected @@ -97,7 +97,7 @@ // module name is java.base, expect an IAE m = ModuleHelper.ModuleObject("java.base", cl, new String[] { "mypackage3" }); try { - ModuleHelper.DefineModule(m, "9.0", "mymodule/here", new String[] { "mypackage3" }); + ModuleHelper.DefineModule(m, false, "9.0", "mymodule/here", new String[] { "mypackage3" }); throw new RuntimeException("Failed to get expected IAE for java.base, not defined with boot class loader"); } catch(IllegalArgumentException e) { if (!e.getMessage().contains("Class loader must be the boot class loader")) { @@ -108,7 +108,7 @@ // Duplicates in package list, expect an IAE m = ModuleHelper.ModuleObject("module.x", cl, new String[] { "mypackage4", "mypackage5" }); try { - ModuleHelper.DefineModule(m, "9.0", "mymodule/here", new String[] { "mypackage4", "mypackage5", "mypackage4" }); + ModuleHelper.DefineModule(m, false, "9.0", "mymodule/here", new String[] { "mypackage4", "mypackage5", "mypackage4" }); throw new RuntimeException("Failed to get IAE for duplicate packages"); } catch(IllegalArgumentException e) { if (!e.getMessage().contains("Duplicate package name")) { @@ -119,7 +119,7 @@ // Empty entry in package list, expect an IAE m = ModuleHelper.ModuleObject("module.y", cl, new String[] { "mypackageX", "mypackageY" }); try { - ModuleHelper.DefineModule(m, "9.0", "mymodule/here", new String[] { "mypackageX", "", "mypackageY" }); + ModuleHelper.DefineModule(m, false, "9.0", "mymodule/here", new String[] { "mypackageX", "", "mypackageY" }); throw new RuntimeException("Failed to get IAE for empty package"); } catch(IllegalArgumentException e) { if (!e.getMessage().contains("Invalid package name")) { @@ -130,9 +130,9 @@ // Duplicate module name, expect an ISE m = ModuleHelper.ModuleObject("Module_A", cl, new String[] { "mypackage6" }); assertNotNull(m, "Module should not be null"); - ModuleHelper.DefineModule(m, "9.0", "module.name/here", new String[] { "mypackage6" }); + ModuleHelper.DefineModule(m, false, "9.0", "module.name/here", new String[] { "mypackage6" }); try { - ModuleHelper.DefineModule(m, "9.0", "module.name/here", new String[] { "mypackage6a" }); + ModuleHelper.DefineModule(m, false, "9.0", "module.name/here", new String[] { "mypackage6a" }); throw new RuntimeException("Failed to get ISE for duplicate module"); } catch(IllegalStateException e) { if (!e.getMessage().contains("Module Module_A is already defined")) { @@ -143,7 +143,7 @@ // Package is already defined for class loader, expect an ISE m = ModuleHelper.ModuleObject("dupl.pkg.module", cl, new String[] { "mypackage6b" }); try { - ModuleHelper.DefineModule(m, "9.0", "module.name/here", new String[] { "mypackage6" }); + ModuleHelper.DefineModule(m, false, "9.0", "module.name/here", new String[] { "mypackage6" }); throw new RuntimeException("Failed to get ISE for existing package"); } catch(IllegalStateException e) { if (!e.getMessage().contains("Package mypackage6 for module dupl.pkg.module is already in another module, Module_A, defined to the class loader")) { @@ -154,7 +154,7 @@ // Empty module name, expect an IAE try { m = ModuleHelper.ModuleObject("", cl, new String[] { "mypackage8" }); - ModuleHelper.DefineModule(m, "9.0", "module.name/here", new String[] { "mypackage8" }); + ModuleHelper.DefineModule(m, false, "9.0", "module.name/here", new String[] { "mypackage8" }); throw new RuntimeException("Failed to get expected IAE for empty module name"); } catch(IllegalArgumentException e) { // Expected @@ -163,7 +163,7 @@ // Module name with ';', not allowed in java source try { m = ModuleHelper.ModuleObject("bad;name", cl, new String[] { "mypackage9" }); - ModuleHelper.DefineModule(m, "9.0", "module.name/here", new String[] { "mypackage9" }); + ModuleHelper.DefineModule(m, false, "9.0", "module.name/here", new String[] { "mypackage9" }); throw new RuntimeException("Failed to get expected IAE for bad;name"); } catch(IllegalArgumentException e) { // Expected @@ -172,7 +172,7 @@ // Module name with leading dot, not allowed in java source try { m = ModuleHelper.ModuleObject(".leadingdot", cl, new String[] { "mypackage9a" }); - ModuleHelper.DefineModule(m, "9.0", "module.name/here", new String[] { "mypackage9a" }); + ModuleHelper.DefineModule(m, false, "9.0", "module.name/here", new String[] { "mypackage9a" }); throw new RuntimeException("Failed to get expected IAE for .leadingdot"); } catch(IllegalArgumentException e) { // Expected @@ -181,7 +181,7 @@ // Module name with trailing dot, not allowed in java source try { m = ModuleHelper.ModuleObject("trailingdot.", cl, new String[] { "mypackage9b" }); - ModuleHelper.DefineModule(m, "9.0", "module.name/here", new String[] { "mypackage9b" }); + ModuleHelper.DefineModule(m, false, "9.0", "module.name/here", new String[] { "mypackage9b" }); throw new RuntimeException("Failed to get expected IAE for trailingdot."); } catch(IllegalArgumentException e) { // Expected @@ -190,7 +190,7 @@ // Module name with consecutive dots, not allowed in java source try { m = ModuleHelper.ModuleObject("trailingdot.", cl, new String[] { "mypackage9b" }); - ModuleHelper.DefineModule(m, "9.0", "module.name/here", new String[] { "mypackage9b" }); + ModuleHelper.DefineModule(m, false, "9.0", "module.name/here", new String[] { "mypackage9b" }); throw new RuntimeException("Failed to get expected IAE for trailingdot."); } catch(IllegalArgumentException e) { // Expected @@ -199,17 +199,17 @@ // module name with multiple dots, should be okay m = ModuleHelper.ModuleObject("more.than.one.dat", cl, new String[] { "mypackage9d" }); assertNotNull(m, "Module should not be null"); - ModuleHelper.DefineModule(m, "9.0", "module.name/here", new String[] { "mypackage9d" }); + ModuleHelper.DefineModule(m, false, "9.0", "module.name/here", new String[] { "mypackage9d" }); // Zero length package list, should be okay m = ModuleHelper.ModuleObject("zero.packages", cl, new String[] { }); assertNotNull(m, "Module should not be null"); - ModuleHelper.DefineModule(m, "9.0", "module.name/here", new String[] { }); + ModuleHelper.DefineModule(m, false, "9.0", "module.name/here", new String[] { }); // Invalid package name, expect an IAE m = ModuleHelper.ModuleObject("moduleFive", cl, new String[] { "your.package" }); try { - ModuleHelper.DefineModule(m, "9.0", "module.name/here", new String[] { "your.package" }); + ModuleHelper.DefineModule(m, false, "9.0", "module.name/here", new String[] { "your.package" }); throw new RuntimeException("Failed to get expected IAE for your.package"); } catch(IllegalArgumentException e) { if (!e.getMessage().contains("Invalid package name")) { @@ -220,7 +220,7 @@ // Invalid package name, expect an IAE m = ModuleHelper.ModuleObject("moduleSix", cl, new String[] { "foo" }); // Name irrelevant try { - ModuleHelper.DefineModule(m, "9.0", "module.name/here", new String[] { ";your/package" }); + ModuleHelper.DefineModule(m, false, "9.0", "module.name/here", new String[] { ";your/package" }); throw new RuntimeException("Failed to get expected IAE for ;your.package"); } catch(IllegalArgumentException e) { if (!e.getMessage().contains("Invalid package name")) { @@ -231,7 +231,7 @@ // Invalid package name, expect an IAE m = ModuleHelper.ModuleObject("moduleSeven", cl, new String[] { "foo" }); // Name irrelevant try { - ModuleHelper.DefineModule(m, "9.0", "module.name/here", new String[] { "7[743" }); + ModuleHelper.DefineModule(m, false, "9.0", "module.name/here", new String[] { "7[743" }); throw new RuntimeException("Failed to get expected IAE for package 7[743"); } catch(IllegalArgumentException e) { if (!e.getMessage().contains("Invalid package name")) { @@ -243,7 +243,7 @@ m = ModuleHelper.ModuleObject("modulejavapkgOne", cl, new String[] { "java/foo" }); try { // module m is defined to an instance of MyClassLoader class loader - ModuleHelper.DefineModule(m, "9.0", "modulejavapkgOne", new String[] { "java/foo" }); + ModuleHelper.DefineModule(m, false, "9.0", "modulejavapkgOne", new String[] { "java/foo" }); throw new RuntimeException("Failed to get expected IAE for package java/foo"); } catch(IllegalArgumentException e) { if (!e.getMessage().contains("prohibited package name")) { @@ -254,7 +254,7 @@ // Package named "javabar" defined to a class loader other than the boot or platform class loader, should be ok m = ModuleHelper.ModuleObject("modulejavapkgTwo", cl, new String[] { "javabar" }); assertNotNull(m, "Module should not be null"); - ModuleHelper.DefineModule(m, "9.0", "modulejavapkgTwo", new String[] { "javabar" }); + ModuleHelper.DefineModule(m, false, "9.0", "modulejavapkgTwo", new String[] { "javabar" }); // Package named "java" defined to the boot class loader, should be ok // m's type is a java.lang.Object, module is java.base @@ -262,7 +262,7 @@ ClassLoader boot_loader = m.getClass().getClassLoader(); m = ModuleHelper.ModuleObject("modulejavapkgThree", boot_loader, new String[] { "java/foo" }); assertNotNull(m, "Module should not be null"); - ModuleHelper.DefineModule(m, "9.0", "modulejavapkgThree", new String[] { "java/foo" }); + ModuleHelper.DefineModule(m, false, "9.0", "modulejavapkgThree", new String[] { "java/foo" }); // Package named "java" defined to the platform class loader, should be ok // java.sql module defined to the platform class loader. @@ -270,27 +270,27 @@ ClassLoader platform_loader = jst.getClass().getClassLoader(); m = ModuleHelper.ModuleObject("modulejavapkgFour", platform_loader, new String[] { "java/foo" }); assertNotNull(m, "Module should not be null"); - ModuleHelper.DefineModule(m, "9.0", "modulejavapkgFour", new String[] { "java/foo" }); + ModuleHelper.DefineModule(m, false, "9.0", "modulejavapkgFour", new String[] { "java/foo" }); // module version that is null, should be okay m = ModuleHelper.ModuleObject("moduleEight", cl, new String[] { "a_package_8" }); assertNotNull(m, "Module should not be null"); - ModuleHelper.DefineModule(m, null, "moduleEight/here", new String[] { "a_package_8" }); + ModuleHelper.DefineModule(m, false, null, "moduleEight/here", new String[] { "a_package_8" }); // module version that is "", should be okay m = ModuleHelper.ModuleObject("moduleNine", cl, new String[] { "a_package_9" }); assertNotNull(m, "Module should not be null"); - ModuleHelper.DefineModule(m, "", "moduleNine/here", new String[] { "a_package_9" }); + ModuleHelper.DefineModule(m, false, "", "moduleNine/here", new String[] { "a_package_9" }); // module location that is null, should be okay m = ModuleHelper.ModuleObject("moduleTen", cl, new String[] { "a_package_10" }); assertNotNull(m, "Module should not be null"); - ModuleHelper.DefineModule(m, "9.0", null, new String[] { "a_package_10" }); + ModuleHelper.DefineModule(m, false, "9.0", null, new String[] { "a_package_10" }); // module location that is "", should be okay m = ModuleHelper.ModuleObject("moduleEleven", cl, new String[] { "a_package_11" }); assertNotNull(m, "Module should not be null"); - ModuleHelper.DefineModule(m, "9.0", "", new String[] { "a_package_11" }); + ModuleHelper.DefineModule(m, false, "9.0", "", new String[] { "a_package_11" }); } static class MyClassLoader extends ClassLoader { } --- old/test/runtime/modules/JVMGetModuleByPkgName.java 2017-03-23 14:05:47.490149399 -0400 +++ new/test/runtime/modules/JVMGetModuleByPkgName.java 2017-03-23 14:05:46.974149377 -0400 @@ -81,7 +81,7 @@ MyClassLoader cl1 = new MyClassLoader(); Module module_one = (Module)ModuleHelper.ModuleObject("module_one", cl1, new String[] { "mypackage" }); assertNotNull(module_one, "Module should not be null"); - ModuleHelper.DefineModule(module_one, "9.0", "module_one/here", new String[] { "mypackage" }); + ModuleHelper.DefineModule(module_one, false, "9.0", "module_one/here", new String[] { "mypackage" }); if (ModuleHelper.GetModuleByPackageName(cl1, "mypackage") != module_one) { throw new RuntimeException("Wrong module returned for cl1 mypackage"); } --- old/test/runtime/modules/LoadUnloadModuleStress.java 2017-03-23 14:05:49.022149462 -0400 +++ new/test/runtime/modules/LoadUnloadModuleStress.java 2017-03-23 14:05:48.522149441 -0400 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2017, 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 @@ -48,7 +48,7 @@ MyClassLoader cl = new MyClassLoader(); Object module = ModuleHelper.ModuleObject("mymodule", cl, new String [] {"PackageA"}); assertNotNull(module); - ModuleHelper.DefineModule(module, "9.0", "mymodule", new String[] { "PackageA" }); + ModuleHelper.DefineModule(module, false, "9.0", "mymodule", new String[] { "PackageA" }); clweak = new WeakReference<>(cl); return module; } --- old/test/runtime/modules/ModuleHelper.java 2017-03-23 14:05:50.882149539 -0400 +++ new/test/runtime/modules/ModuleHelper.java 2017-03-23 14:05:50.018149503 -0400 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2017, 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 @@ -32,10 +32,10 @@ public class ModuleHelper { - public static void DefineModule(Object module, String version, String location, - String[] pkgs) throws Throwable { + public static void DefineModule(Object module, boolean is_open, String version, + String location, String[] pkgs) throws Throwable { WhiteBox wb = WhiteBox.getWhiteBox(); - wb.DefineModule(module, version, location, pkgs); + wb.DefineModule(module, is_open, version, location, pkgs); } public static void AddModuleExports(Object from, String pkg, Object to) throws Throwable { --- /dev/null 2017-01-26 15:51:40.882659453 -0500 +++ new/test/runtime/modules/AccessCheckOpen.java 2017-03-23 14:05:51.990149585 -0400 @@ -0,0 +1,84 @@ +/* + * Copyright (c) 2017, 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 + * @modules java.base/jdk.internal.misc + * @library /test/lib .. + * @compile p2/c2.java + * @compile p1/c1.java + * @build sun.hotspot.WhiteBox + * @compile/module=java.base java/lang/reflect/ModuleHelper.java + * @run main ClassFileInstaller sun.hotspot.WhiteBox + * sun.hotspot.WhiteBox$WhiteBoxPermission + * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI AccessCheckOpen + */ + +import java.lang.reflect.Module; +import static jdk.test.lib.Asserts.*; + +public class AccessCheckOpen { + + // Test that if module1 can read module2 and module2 is open, then + // p1.c1 can read p2.c2 + public static void main(String args[]) throws Throwable { + Object m1, m2; + + // Get the java.lang.reflect.Module object for module java.base + Class jlObject = Class.forName("java.lang.Object"); + Object jlObject_jlrM = jlObject.getModule(); + assertNotNull(jlObject_jlrM, "jlrModule object of java.lang.Object should not be null"); + + // Get the class loader for AccessCheckOpen, which is also used to + // load classes p1.c1 and p2.c2 + ClassLoader this_cldr = AccessCheckOpen.class.getClassLoader(); + + // Define a module for p1 + m1 = ModuleHelper.ModuleObject("module1", this_cldr, new String[] { "p1" }); + assertNotNull(m1, "Module should not be null"); + ModuleHelper.DefineModule(m1, false, "9.0", "m1/here", new String[] { "p1" }); + ModuleHelper.AddReadsModule(m1, jlObject_jlrM); + + // Define a module for p2 + m2 = ModuleHelper.ModuleObject("module2", this_cldr, new String[] { "p2" }); + assertNotNull(m2, "Module should not be null"); + ModuleHelper.DefineModule(m2, true, "9.0", "m2/there", new String[] { "p2" }); + ModuleHelper.AddReadsModule(m2, jlObject_jlrM); + + // Make package p1 in m1 visible to everyone so this test can run it + ModuleHelper.AddModuleExportsToAll(m1, "p1"); + + // Let m1 read m2 + ModuleHelper.AddReadsModule(m1, m2); + + // p1.c1's ctor calls a method in p2.c2, and m2 is open. + // So should not get IllegalAccessError + Class p1_c1_class = Class.forName("p1.c1"); + try { + p1_c1_class.newInstance(); + } catch (IllegalAccessError f) { + System.out.println(f.getMessage()); + } + } +} +