# HG changeset patch # User rprotacio # Date 1480956320 18000 # Node ID 7459867ebf98401e1323b47b5a733dd308c64492 # Parent c4f00b77b6d4a21b238b3953489e5429409c6ecd 8168850: Mark module entries that have been specified by --patch-module Summary: Adds a boolean to ModuleEntry to specify whether the module has been patched using the command line --patch-module Reviewed-by: jiangli, lfoltan, dholmes diff -r c4f00b77b6d4 -r 7459867ebf98 hotspot/src/share/vm/classfile/classLoader.cpp --- a/hotspot/src/share/vm/classfile/classLoader.cpp Fri Dec 02 11:07:27 2016 +0100 +++ b/hotspot/src/share/vm/classfile/classLoader.cpp Mon Dec 05 11:45:20 2016 -0500 @@ -751,6 +751,21 @@ } } +// Determine whether the module has been patched via the command-line +// option --patch-module +bool ClassLoader::is_in_patch_mod_entries(Symbol* module_name) { + if (_patch_mod_entries != NULL && _patch_mod_entries->is_nonempty()) { + int table_len = _patch_mod_entries->length(); + for (int i = 0; i < table_len; i++) { + ModuleClassPathList* patch_mod = _patch_mod_entries->at(i); + if (module_name->fast_compare(patch_mod->module_name()) == 0) { + return true; + } + } + } + return false; +} + void ClassLoader::setup_search_path(const char *class_path, bool bootstrap_search) { int len = (int)strlen(class_path); int end = 0; @@ -1764,9 +1779,6 @@ // Complete the ClassPathEntry setup for the boot loader void ClassLoader::classLoader_init2(TRAPS) { - // Create the moduleEntry for java.base - create_javabase(); - // 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. @@ -1774,6 +1786,10 @@ setup_patch_mod_entries(); } + // Create the ModuleEntry for java.base (must occur after setup_patch_mod_entries + // to successfully determine if java.base has been patched) + create_javabase(); + // Setup the initial java.base/path pair for the exploded build entries. // As more modules are defined during module system initialization, more // entries will be added to the exploded build array. diff -r c4f00b77b6d4 -r 7459867ebf98 hotspot/src/share/vm/classfile/classLoader.hpp --- a/hotspot/src/share/vm/classfile/classLoader.hpp Fri Dec 02 11:07:27 2016 +0100 +++ b/hotspot/src/share/vm/classfile/classLoader.hpp Mon Dec 05 11:45:20 2016 -0500 @@ -418,6 +418,8 @@ } } + static bool is_in_patch_mod_entries(Symbol* module_name); + #if INCLUDE_CDS // Sharing dump and restore diff -r c4f00b77b6d4 -r 7459867ebf98 hotspot/src/share/vm/classfile/moduleEntry.cpp --- a/hotspot/src/share/vm/classfile/moduleEntry.cpp Fri Dec 02 11:07:27 2016 +0100 +++ b/hotspot/src/share/vm/classfile/moduleEntry.cpp Mon Dec 05 11:45:20 2016 -0500 @@ -301,6 +301,14 @@ entry->set_version(version); entry->set_location(location); + if (ClassLoader::is_in_patch_mod_entries(name)) { + entry->set_is_patched(); + if (log_is_enabled(Trace, modules, patch)) { + ResourceMark rm; + log_trace(modules, patch)("Marked module %s as patched from --patch-module", name->as_C_string()); + } + } + TRACE_INIT_MODULE_ID(entry); return entry; diff -r c4f00b77b6d4 -r 7459867ebf98 hotspot/src/share/vm/classfile/moduleEntry.hpp --- a/hotspot/src/share/vm/classfile/moduleEntry.hpp Fri Dec 02 11:07:27 2016 +0100 +++ b/hotspot/src/share/vm/classfile/moduleEntry.hpp Mon Dec 05 11:45:20 2016 -0500 @@ -63,6 +63,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_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. @@ -77,6 +78,7 @@ _can_read_all_unnamed = false; _has_default_read_edges = false; _must_walk_reads = false; + _is_patched = false; } Symbol* name() const { return literal(); } @@ -131,6 +133,13 @@ return prev; } + void set_is_patched() { + _is_patched = true; + } + bool is_patched() { + return _is_patched; + } + ModuleEntry* next() const { return (ModuleEntry*)HashtableEntry::next(); } diff -r c4f00b77b6d4 -r 7459867ebf98 hotspot/src/share/vm/logging/logTag.hpp --- a/hotspot/src/share/vm/logging/logTag.hpp Fri Dec 02 11:07:27 2016 +0100 +++ b/hotspot/src/share/vm/logging/logTag.hpp Mon Dec 05 11:45:20 2016 -0500 @@ -90,6 +90,7 @@ LOG_TAG(oopmap) \ LOG_TAG(os) \ LOG_TAG(pagesize) \ + LOG_TAG(patch) \ LOG_TAG(path) \ LOG_TAG(phases) \ LOG_TAG(plab) \