8178380: Module system implementation refresh (5/2017)
Co-authored-by: Serguei Spitsyn <serguei.spitsyn@oracle.com> Reviewed-by: lfoltan, hseigel, mchung, sspitsyn
This commit is contained in:
parent
fd4f7d938a
commit
aefdcda532
@ -158,10 +158,10 @@ void ModuleEntry::set_read_walk_required(ClassLoaderData* m_loader_data) {
|
||||
loader_data() != m_loader_data &&
|
||||
!m_loader_data->is_builtin_class_loader_data()) {
|
||||
_must_walk_reads = true;
|
||||
if (log_is_enabled(Trace, modules)) {
|
||||
if (log_is_enabled(Trace, module)) {
|
||||
ResourceMark rm;
|
||||
log_trace(modules)("ModuleEntry::set_read_walk_required(): module %s reads list must be walked",
|
||||
(name() != NULL) ? name()->as_C_string() : UNNAMED_MODULE);
|
||||
log_trace(module)("ModuleEntry::set_read_walk_required(): module %s reads list must be walked",
|
||||
(name() != NULL) ? name()->as_C_string() : UNNAMED_MODULE);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -180,10 +180,10 @@ void ModuleEntry::purge_reads() {
|
||||
// on the remaining live modules on the reads list.
|
||||
_must_walk_reads = false;
|
||||
|
||||
if (log_is_enabled(Trace, modules)) {
|
||||
if (log_is_enabled(Trace, module)) {
|
||||
ResourceMark rm;
|
||||
log_trace(modules)("ModuleEntry::purge_reads(): module %s reads list being walked",
|
||||
(name() != NULL) ? name()->as_C_string() : UNNAMED_MODULE);
|
||||
log_trace(module)("ModuleEntry::purge_reads(): module %s reads list being walked",
|
||||
(name() != NULL) ? name()->as_C_string() : UNNAMED_MODULE);
|
||||
}
|
||||
|
||||
// Go backwards because this removes entries that are dead.
|
||||
@ -236,8 +236,11 @@ ModuleEntryTable::~ModuleEntryTable() {
|
||||
m = m->next();
|
||||
|
||||
ResourceMark rm;
|
||||
log_debug(modules)("ModuleEntryTable: deleting module: %s", to_remove->name() != NULL ?
|
||||
to_remove->name()->as_C_string() : UNNAMED_MODULE);
|
||||
if (to_remove->name() != NULL) {
|
||||
log_info(module, unload)("unloading module %s", to_remove->name()->as_C_string());
|
||||
}
|
||||
log_debug(module)("ModuleEntryTable: deleting module: %s", to_remove->name() != NULL ?
|
||||
to_remove->name()->as_C_string() : UNNAMED_MODULE);
|
||||
|
||||
// Clean out the C heap allocated reads list first before freeing the entry
|
||||
to_remove->delete_reads();
|
||||
@ -315,9 +318,9 @@ ModuleEntry* ModuleEntryTable::new_entry(unsigned int hash, Handle module_handle
|
||||
|
||||
if (ClassLoader::is_in_patch_mod_entries(name)) {
|
||||
entry->set_is_patched();
|
||||
if (log_is_enabled(Trace, modules, patch)) {
|
||||
if (log_is_enabled(Trace, module, patch)) {
|
||||
ResourceMark rm;
|
||||
log_trace(modules, patch)("Marked module %s as patched from --patch-module", name->as_C_string());
|
||||
log_trace(module, patch)("Marked module %s as patched from --patch-module", name->as_C_string());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -237,16 +237,18 @@ static void define_javabase_module(jobject module, jstring version,
|
||||
// Patch any previously loaded class's module field with java.base's java.lang.Module.
|
||||
ModuleEntryTable::patch_javabase_entries(module_handle);
|
||||
|
||||
log_debug(modules)("define_javabase_module(): Definition of module: "
|
||||
JAVA_BASE_NAME ", version: %s, location: %s, package #: %d",
|
||||
module_version != NULL ? module_version : "NULL",
|
||||
module_location != NULL ? module_location : "NULL",
|
||||
pkg_list->length());
|
||||
log_info(module, load)(JAVA_BASE_NAME " location: %s",
|
||||
module_location != NULL ? module_location : "NULL");
|
||||
log_debug(module)("define_javabase_module(): Definition of module: "
|
||||
JAVA_BASE_NAME ", version: %s, location: %s, package #: %d",
|
||||
module_version != NULL ? module_version : "NULL",
|
||||
module_location != NULL ? module_location : "NULL",
|
||||
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());
|
||||
log_trace(module)("define_javabase_module(): creation of package %s for module " JAVA_BASE_NAME,
|
||||
(pkg_list->at(x))->as_C_string());
|
||||
}
|
||||
}
|
||||
|
||||
@ -438,23 +440,24 @@ void Modules::define_module(jobject module, jstring version,
|
||||
throw_dup_pkg_exception(module_name, existing_pkg, CHECK);
|
||||
}
|
||||
|
||||
if (log_is_enabled(Debug, modules)) {
|
||||
outputStream* logst = Log(modules)::debug_stream();
|
||||
log_info(module, load)("%s location: %s", module_name,
|
||||
module_location != NULL ? module_location : "NULL");
|
||||
if (log_is_enabled(Debug, module)) {
|
||||
outputStream* logst = Log(module)::debug_stream();
|
||||
logst->print("define_module(): creation of module: %s, version: %s, location: %s, ",
|
||||
module_name, module_version != NULL ? module_version : "NULL",
|
||||
module_location != NULL ? module_location : "NULL");
|
||||
loader_data->print_value_on(logst);
|
||||
logst->print_cr(", package #: %d", pkg_list->length());
|
||||
for (int y = 0; y < pkg_list->length(); y++) {
|
||||
log_trace(modules)("define_module(): creation of package %s for module %s",
|
||||
(pkg_list->at(y))->as_C_string(), module_name);
|
||||
log_trace(module)("define_module(): creation of package %s for module %s",
|
||||
(pkg_list->at(y))->as_C_string(), module_name);
|
||||
}
|
||||
}
|
||||
|
||||
// If the module is defined to the boot loader and an exploded build is being
|
||||
// used, prepend <java.home>/modules/modules_name, if it exists, to the system boot class path.
|
||||
if (loader == NULL &&
|
||||
!Universe::is_module_initialized() &&
|
||||
!ClassLoader::has_jrt_entry()) {
|
||||
ClassLoader::add_to_exploded_build_list(module_symbol, CHECK);
|
||||
}
|
||||
@ -487,7 +490,7 @@ void Modules::set_bootloader_unnamed_module(jobject module, TRAPS) {
|
||||
}
|
||||
Handle h_loader = Handle(THREAD, loader);
|
||||
|
||||
log_debug(modules)("set_bootloader_unnamed_module(): recording unnamed module for boot loader");
|
||||
log_debug(module)("set_bootloader_unnamed_module(): recording unnamed module for boot loader");
|
||||
|
||||
// Ensure the boot loader's PackageEntryTable has been created
|
||||
ModuleEntryTable* module_table = get_module_entry_table(h_loader, CHECK);
|
||||
@ -545,10 +548,10 @@ void Modules::add_module_exports(jobject from_module, const char* package_name,
|
||||
from_module_entry->name()->as_C_string()));
|
||||
}
|
||||
|
||||
log_debug(modules)("add_module_exports(): package %s in module %s is exported to module %s",
|
||||
package_entry->name()->as_C_string(),
|
||||
from_module_entry->name()->as_C_string(),
|
||||
to_module_entry == NULL ? "NULL" :
|
||||
log_debug(module)("add_module_exports(): package %s in module %s is exported to module %s",
|
||||
package_entry->name()->as_C_string(),
|
||||
from_module_entry->name()->as_C_string(),
|
||||
to_module_entry == NULL ? "NULL" :
|
||||
to_module_entry->is_named() ?
|
||||
to_module_entry->name()->as_C_string() : UNNAMED_MODULE);
|
||||
|
||||
@ -592,12 +595,12 @@ void Modules::add_reads_module(jobject from_module, jobject to_module, TRAPS) {
|
||||
}
|
||||
|
||||
ResourceMark rm(THREAD);
|
||||
log_debug(modules)("add_reads_module(): Adding read from module %s to module %s",
|
||||
from_module_entry->is_named() ?
|
||||
from_module_entry->name()->as_C_string() : UNNAMED_MODULE,
|
||||
to_module_entry == NULL ? "all unnamed" :
|
||||
(to_module_entry->is_named() ?
|
||||
to_module_entry->name()->as_C_string() : UNNAMED_MODULE));
|
||||
log_debug(module)("add_reads_module(): Adding read from module %s to module %s",
|
||||
from_module_entry->is_named() ?
|
||||
from_module_entry->name()->as_C_string() : UNNAMED_MODULE,
|
||||
to_module_entry == NULL ? "all unnamed" :
|
||||
(to_module_entry->is_named() ?
|
||||
to_module_entry->name()->as_C_string() : UNNAMED_MODULE));
|
||||
|
||||
// if modules are the same or if from_module is unnamed then no need to add the read.
|
||||
if (from_module_entry != to_module_entry && from_module_entry->is_named()) {
|
||||
@ -616,7 +619,7 @@ jobject Modules::get_module(jclass clazz, TRAPS) {
|
||||
}
|
||||
oop mirror = JNIHandles::resolve_non_null(clazz);
|
||||
if (mirror == NULL) {
|
||||
log_debug(modules)("get_module(): no mirror, returning NULL");
|
||||
log_debug(module)("get_module(): no mirror, returning NULL");
|
||||
return NULL;
|
||||
}
|
||||
if (!java_lang_Class::is_instance(mirror)) {
|
||||
@ -629,9 +632,9 @@ jobject Modules::get_module(jclass clazz, TRAPS) {
|
||||
assert(module != NULL, "java.lang.Class module field not set");
|
||||
assert(java_lang_Module::is_instance(module), "module is not an instance of type java.lang.Module");
|
||||
|
||||
if (log_is_enabled(Debug, modules)) {
|
||||
if (log_is_enabled(Debug, module)) {
|
||||
ResourceMark rm(THREAD);
|
||||
outputStream* logst = Log(modules)::debug_stream();
|
||||
outputStream* logst = Log(module)::debug_stream();
|
||||
Klass* klass = java_lang_Class::as_Klass(mirror);
|
||||
oop module_name = java_lang_Module::name(module);
|
||||
if (module_name != NULL) {
|
||||
@ -764,8 +767,8 @@ void Modules::add_module_package(jobject module, const char* package_name, TRAPS
|
||||
THROW_MSG(vmSymbols::java_lang_IllegalArgumentException(), message);
|
||||
}
|
||||
|
||||
log_debug(modules)("add_module_package(): Adding package %s to module %s",
|
||||
package_name, module_entry->name()->as_C_string());
|
||||
log_debug(module)("add_module_package(): Adding package %s to module %s",
|
||||
package_name, module_entry->name()->as_C_string());
|
||||
|
||||
TempNewSymbol pkg_symbol = SymbolTable::new_symbol(package_name, CHECK);
|
||||
PackageEntryTable* package_table = loader_data->packages();
|
||||
@ -820,8 +823,8 @@ void Modules::add_module_exports_to_all_unnamed(jobject module, const char* pack
|
||||
module_entry->name()->as_C_string()));
|
||||
}
|
||||
|
||||
log_debug(modules)("add_module_exports_to_all_unnamed(): package %s in module"
|
||||
" %s is exported to all unnamed modules",
|
||||
log_debug(module)("add_module_exports_to_all_unnamed(): package %s in module"
|
||||
" %s is exported to all unnamed modules",
|
||||
package_entry->name()->as_C_string(),
|
||||
module_entry->name()->as_C_string());
|
||||
|
||||
|
@ -77,13 +77,13 @@ void PackageEntry::set_export_walk_required(ClassLoaderData* m_loader_data) {
|
||||
(this_pkg_mod == NULL || this_pkg_mod->loader_data() != m_loader_data) &&
|
||||
!m_loader_data->is_builtin_class_loader_data()) {
|
||||
_must_walk_exports = true;
|
||||
if (log_is_enabled(Trace, modules)) {
|
||||
if (log_is_enabled(Trace, module)) {
|
||||
ResourceMark rm;
|
||||
assert(name() != NULL, "PackageEntry without a valid name");
|
||||
log_trace(modules)("PackageEntry::set_export_walk_required(): package %s defined in module %s, exports list must be walked",
|
||||
name()->as_C_string(),
|
||||
(this_pkg_mod == NULL || this_pkg_mod->name() == NULL) ?
|
||||
UNNAMED_MODULE : this_pkg_mod->name()->as_C_string());
|
||||
log_trace(module)("PackageEntry::set_export_walk_required(): package %s defined in module %s, exports list must be walked",
|
||||
name()->as_C_string(),
|
||||
(this_pkg_mod == NULL || this_pkg_mod->name() == NULL) ?
|
||||
UNNAMED_MODULE : this_pkg_mod->name()->as_C_string());
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -132,13 +132,13 @@ void PackageEntry::purge_qualified_exports() {
|
||||
// on the remaining live modules on the exports list.
|
||||
_must_walk_exports = false;
|
||||
|
||||
if (log_is_enabled(Trace, modules)) {
|
||||
if (log_is_enabled(Trace, module)) {
|
||||
ResourceMark rm;
|
||||
assert(name() != NULL, "PackageEntry without a valid name");
|
||||
ModuleEntry* pkg_mod = module();
|
||||
log_trace(modules)("PackageEntry::purge_qualified_exports(): package %s defined in module %s, exports list being walked",
|
||||
name()->as_C_string(),
|
||||
(pkg_mod == NULL || pkg_mod->name() == NULL) ? UNNAMED_MODULE : pkg_mod->name()->as_C_string());
|
||||
log_trace(module)("PackageEntry::purge_qualified_exports(): package %s defined in module %s, exports list being walked",
|
||||
name()->as_C_string(),
|
||||
(pkg_mod == NULL || pkg_mod->name() == NULL) ? UNNAMED_MODULE : pkg_mod->name()->as_C_string());
|
||||
}
|
||||
|
||||
// Go backwards because this removes entries that are dead.
|
||||
|
@ -650,6 +650,8 @@
|
||||
template(addUses_signature, "(Ljava/lang/Module;Ljava/lang/Class;)V") \
|
||||
template(addProvides_name, "addProvides") \
|
||||
template(addProvides_signature, "(Ljava/lang/Module;Ljava/lang/Class;Ljava/lang/Class;)V") \
|
||||
template(loadModule_name, "loadModule") \
|
||||
template(loadModule_signature, "(Ljava/lang/String;)Ljava/lang/Module;") \
|
||||
template(transformedByAgent_name, "transformedByAgent") \
|
||||
template(transformedByAgent_signature, "(Ljava/lang/Module;)V") \
|
||||
template(appendToClassPathForInstrumentation_name, "appendToClassPathForInstrumentation") \
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2015, 2016, 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
|
||||
@ -82,7 +82,7 @@
|
||||
LOG_TAG(metadata) \
|
||||
LOG_TAG(metaspace) \
|
||||
LOG_TAG(mmu) \
|
||||
LOG_TAG(modules) \
|
||||
LOG_TAG(module) \
|
||||
LOG_TAG(monitorinflation) \
|
||||
LOG_TAG(monitormismatch) \
|
||||
LOG_TAG(nmethod) \
|
||||
|
@ -2331,21 +2331,21 @@ void InstanceKlass::set_package(ClassLoaderData* loader_data, TRAPS) {
|
||||
name()->as_C_string(), loader_data->loader_name());
|
||||
}
|
||||
|
||||
if (log_is_enabled(Debug, modules)) {
|
||||
if (log_is_enabled(Debug, module)) {
|
||||
ResourceMark rm;
|
||||
ModuleEntry* m = _package_entry->module();
|
||||
log_trace(modules)("Setting package: class: %s, package: %s, loader: %s, module: %s",
|
||||
external_name(),
|
||||
pkg_name->as_C_string(),
|
||||
loader_data->loader_name(),
|
||||
(m->is_named() ? m->name()->as_C_string() : UNNAMED_MODULE));
|
||||
log_trace(module)("Setting package: class: %s, package: %s, loader: %s, module: %s",
|
||||
external_name(),
|
||||
pkg_name->as_C_string(),
|
||||
loader_data->loader_name(),
|
||||
(m->is_named() ? m->name()->as_C_string() : UNNAMED_MODULE));
|
||||
}
|
||||
} else {
|
||||
ResourceMark rm;
|
||||
log_trace(modules)("Setting package: class: %s, package: unnamed, loader: %s, module: %s",
|
||||
external_name(),
|
||||
(loader_data != NULL) ? loader_data->loader_name() : "NULL",
|
||||
UNNAMED_MODULE);
|
||||
log_trace(module)("Setting package: class: %s, package: unnamed, loader: %s, module: %s",
|
||||
external_name(),
|
||||
(loader_data != NULL) ? loader_data->loader_name() : "NULL",
|
||||
UNNAMED_MODULE);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -6814,7 +6814,9 @@ class C2 extends C1 implements I2 {
|
||||
<functionlink id="AddModuleReads"/>, <functionlink id="AddModuleExports"/>,
|
||||
<functionlink id="AddModuleOpens"/>, <functionlink id="AddModuleUses"/>,
|
||||
and <functionlink id="AddModuleProvides"/>. If a module is not modifiable
|
||||
then the module can not be updated with these functions.
|
||||
then the module can not be updated with these functions. The result of
|
||||
this function is always <code>JNI_TRUE</code> when called to determine
|
||||
if an unnamed module is modifiable.
|
||||
</description>
|
||||
<origin>new</origin>
|
||||
<capabilities>
|
||||
|
@ -54,7 +54,6 @@
|
||||
#include "runtime/os.inline.hpp"
|
||||
#include "runtime/thread.inline.hpp"
|
||||
#include "runtime/vframe.hpp"
|
||||
#include "services/attachListener.hpp"
|
||||
#include "services/serviceUtil.hpp"
|
||||
#include "utilities/macros.hpp"
|
||||
#if INCLUDE_ALL_GCS
|
||||
@ -2479,15 +2478,6 @@ extern "C" {
|
||||
typedef jint (JNICALL *OnAttachEntry_t)(JavaVM*, char *, void *);
|
||||
}
|
||||
|
||||
jint JvmtiExport::load_agent_library(AttachOperation* op, outputStream* st) {
|
||||
// get agent name and options
|
||||
const char* agent = op->arg(0);
|
||||
const char* absParam = op->arg(1);
|
||||
const char* options = op->arg(2);
|
||||
|
||||
return load_agent_library(agent, absParam, options, st);
|
||||
}
|
||||
|
||||
jint JvmtiExport::load_agent_library(const char *agent, const char *absParam,
|
||||
const char *options, outputStream* st) {
|
||||
char ebuf[1024];
|
||||
|
@ -45,7 +45,6 @@ class JvmtiEventControllerPrivate;
|
||||
class JvmtiManageCapabilities;
|
||||
class JvmtiEnv;
|
||||
class JvmtiThreadState;
|
||||
class AttachOperation;
|
||||
|
||||
#define JVMTI_SUPPORT_FLAG(key) \
|
||||
private: \
|
||||
@ -396,7 +395,6 @@ class JvmtiExport : public AllStatic {
|
||||
#if INCLUDE_SERVICES
|
||||
// attach support
|
||||
static jint load_agent_library(const char *agent, const char *absParam, const char *options, outputStream* out) NOT_JVMTI_RETURN_(JNI_ERR);
|
||||
static jint load_agent_library(AttachOperation* op, outputStream* out) NOT_JVMTI_RETURN_(JNI_ERR);
|
||||
#endif
|
||||
|
||||
// SetNativeMethodPrefix support
|
||||
|
@ -2837,11 +2837,14 @@ jint Arguments::parse_each_vm_init_arg(const JavaVMInitArgs* args, bool* patch_m
|
||||
build_jvm_args(option->optionString);
|
||||
}
|
||||
|
||||
// -verbose:[class/gc/jni]
|
||||
// -verbose:[class/module/gc/jni]
|
||||
if (match_option(option, "-verbose", &tail)) {
|
||||
if (!strcmp(tail, ":class") || !strcmp(tail, "")) {
|
||||
LogConfiguration::configure_stdout(LogLevel::Info, true, LOG_TAGS(class, load));
|
||||
LogConfiguration::configure_stdout(LogLevel::Info, true, LOG_TAGS(class, unload));
|
||||
} else if (!strcmp(tail, ":module")) {
|
||||
LogConfiguration::configure_stdout(LogLevel::Info, true, LOG_TAGS(module, load));
|
||||
LogConfiguration::configure_stdout(LogLevel::Info, true, LOG_TAGS(module, unload));
|
||||
} else if (!strcmp(tail, ":gc")) {
|
||||
LogConfiguration::configure_stdout(LogLevel::Info, true, LOG_TAGS(gc));
|
||||
} else if (!strcmp(tail, ":jni")) {
|
||||
|
@ -3874,6 +3874,9 @@ public:
|
||||
product(bool, StartAttachListener, false, \
|
||||
"Always start Attach Listener at VM startup") \
|
||||
\
|
||||
product(bool, EnableDynamicAgentLoading, true, \
|
||||
"Allow tools to load agents with the attach mechanism") \
|
||||
\
|
||||
manageable(bool, PrintConcurrentLocks, false, \
|
||||
"Print java.util.concurrent locks in thread dump") \
|
||||
\
|
||||
|
@ -3404,7 +3404,7 @@ static void call_initPhase1(TRAPS) {
|
||||
//
|
||||
// After phase 2, The VM will begin search classes from -Xbootclasspath/a.
|
||||
static void call_initPhase2(TRAPS) {
|
||||
TraceTime timer("Phase2 initialization", TRACETIME_LOG(Info, modules, startuptime));
|
||||
TraceTime timer("Phase2 initialization", TRACETIME_LOG(Info, module, startuptime));
|
||||
|
||||
Klass* k = SystemDictionary::resolve_or_fail(vmSymbols::java_lang_System(), true, CHECK);
|
||||
instanceKlassHandle klass (THREAD, k);
|
||||
|
@ -100,6 +100,36 @@ static jint get_properties(AttachOperation* op, outputStream* out, Symbol* seria
|
||||
return JNI_OK;
|
||||
}
|
||||
|
||||
// Implementation of "load" command.
|
||||
static jint load_agent(AttachOperation* op, outputStream* out) {
|
||||
// get agent name and options
|
||||
const char* agent = op->arg(0);
|
||||
const char* absParam = op->arg(1);
|
||||
const char* options = op->arg(2);
|
||||
|
||||
// If loading a java agent then need to ensure that the java.instrument module is loaded
|
||||
if (strcmp(agent, "instrument") == 0) {
|
||||
Thread* THREAD = Thread::current();
|
||||
ResourceMark rm(THREAD);
|
||||
HandleMark hm(THREAD);
|
||||
JavaValue result(T_OBJECT);
|
||||
Handle h_module_name = java_lang_String::create_from_str("java.instrument", THREAD);
|
||||
JavaCalls::call_static(&result,
|
||||
SystemDictionary::module_Modules_klass(),
|
||||
vmSymbols::loadModule_name(),
|
||||
vmSymbols::loadModule_signature(),
|
||||
h_module_name,
|
||||
THREAD);
|
||||
if (HAS_PENDING_EXCEPTION) {
|
||||
java_lang_Throwable::print(PENDING_EXCEPTION, out);
|
||||
CLEAR_PENDING_EXCEPTION;
|
||||
return JNI_ERR;
|
||||
}
|
||||
}
|
||||
|
||||
return JvmtiExport::load_agent_library(agent, absParam, options, out);
|
||||
}
|
||||
|
||||
// Implementation of "properties" command.
|
||||
// See also: PrintSystemPropertiesDCmd class
|
||||
static jint get_system_properties(AttachOperation* op, outputStream* out) {
|
||||
@ -282,7 +312,7 @@ static AttachOperationFunctionInfo funcs[] = {
|
||||
{ "agentProperties", get_agent_properties },
|
||||
{ "datadump", data_dump },
|
||||
{ "dumpheap", dump_heap },
|
||||
{ "load", JvmtiExport::load_agent_library },
|
||||
{ "load", load_agent },
|
||||
{ "properties", get_system_properties },
|
||||
{ "threaddump", thread_dump },
|
||||
{ "inspectheap", heap_inspection },
|
||||
@ -321,6 +351,10 @@ static void attach_listener_thread_entry(JavaThread* thread, TRAPS) {
|
||||
// handle special detachall operation
|
||||
if (strcmp(op->name(), AttachOperation::detachall_operation_name()) == 0) {
|
||||
AttachListener::detachall();
|
||||
} else if (!EnableDynamicAgentLoading && strcmp(op->name(), "load") == 0) {
|
||||
st.print("Dynamic agent loading is not enabled. "
|
||||
"Use -XX:+EnableDynamicAgentLoading to launch target VM.");
|
||||
res = JNI_ERR;
|
||||
} else {
|
||||
// find the function to dispatch too
|
||||
AttachOperationFunctionInfo* info = NULL;
|
||||
|
@ -42,6 +42,21 @@
|
||||
#include "utilities/macros.hpp"
|
||||
#include "oops/objArrayOop.inline.hpp"
|
||||
|
||||
|
||||
static void loadAgentModule(TRAPS) {
|
||||
ResourceMark rm(THREAD);
|
||||
HandleMark hm(THREAD);
|
||||
|
||||
JavaValue result(T_OBJECT);
|
||||
Handle h_module_name = java_lang_String::create_from_str("jdk.management.agent", CHECK);
|
||||
JavaCalls::call_static(&result,
|
||||
SystemDictionary::module_Modules_klass(),
|
||||
vmSymbols::loadModule_name(),
|
||||
vmSymbols::loadModule_signature(),
|
||||
h_module_name,
|
||||
THREAD);
|
||||
}
|
||||
|
||||
void DCmdRegistrant::register_dcmds(){
|
||||
// Registration of the diagnostic commands
|
||||
// First argument specifies which interfaces will export the command
|
||||
@ -753,6 +768,7 @@ void JMXStartRemoteDCmd::execute(DCmdSource source, TRAPS) {
|
||||
// the remote management server.
|
||||
// throw java.lang.NoSuchMethodError if the method doesn't exist
|
||||
|
||||
loadAgentModule(CHECK);
|
||||
Handle loader = Handle(THREAD, SystemDictionary::java_system_loader());
|
||||
Klass* k = SystemDictionary::resolve_or_fail(vmSymbols::jdk_internal_agent_Agent(), loader, Handle(), true, CHECK);
|
||||
instanceKlassHandle ik (THREAD, k);
|
||||
@ -826,6 +842,7 @@ void JMXStartLocalDCmd::execute(DCmdSource source, TRAPS) {
|
||||
// the local management server
|
||||
// throw java.lang.NoSuchMethodError if method doesn't exist
|
||||
|
||||
loadAgentModule(CHECK);
|
||||
Handle loader = Handle(THREAD, SystemDictionary::java_system_loader());
|
||||
Klass* k = SystemDictionary::resolve_or_fail(vmSymbols::jdk_internal_agent_Agent(), loader, Handle(), true, CHECK);
|
||||
instanceKlassHandle ik (THREAD, k);
|
||||
@ -843,6 +860,7 @@ void JMXStopRemoteDCmd::execute(DCmdSource source, TRAPS) {
|
||||
// management server
|
||||
// throw java.lang.NoSuchMethodError if method doesn't exist
|
||||
|
||||
loadAgentModule(CHECK);
|
||||
Handle loader = Handle(THREAD, SystemDictionary::java_system_loader());
|
||||
Klass* k = SystemDictionary::resolve_or_fail(vmSymbols::jdk_internal_agent_Agent(), loader, Handle(), true, CHECK);
|
||||
instanceKlassHandle ik (THREAD, k);
|
||||
@ -864,6 +882,7 @@ void JMXStatusDCmd::execute(DCmdSource source, TRAPS) {
|
||||
// invoke getManagementAgentStatus() method to generate the status info
|
||||
// throw java.lang.NoSuchMethodError if method doesn't exist
|
||||
|
||||
loadAgentModule(CHECK);
|
||||
Handle loader = Handle(THREAD, SystemDictionary::java_system_loader());
|
||||
Klass* k = SystemDictionary::resolve_or_fail(vmSymbols::jdk_internal_agent_Agent(), loader, Handle(), true, CHECK);
|
||||
instanceKlassHandle ik (THREAD, k);
|
||||
|
@ -32,7 +32,7 @@
|
||||
* java.management
|
||||
* jdk.attach
|
||||
*
|
||||
* @run main/othervm compiler.jsr292.RedefineMethodUsedByMultipleMethodHandles
|
||||
* @run main/othervm -Djdk.attach.allowAttachSelf compiler.jsr292.RedefineMethodUsedByMultipleMethodHandles
|
||||
*/
|
||||
|
||||
package compiler.jsr292;
|
||||
|
@ -29,7 +29,8 @@
|
||||
* jdk.internal.vm.ci/jdk.vm.ci.runtime
|
||||
* jdk.attach
|
||||
* java.base/jdk.internal.misc
|
||||
* @run junit/othervm -XX:+UnlockExperimentalVMOptions -XX:+EnableJVMCI jdk.vm.ci.runtime.test.RedefineClassTest
|
||||
* @run junit/othervm -XX:+UnlockExperimentalVMOptions -XX:+EnableJVMCI -Djdk.attach.allowAttachSelf
|
||||
* jdk.vm.ci.runtime.test.RedefineClassTest
|
||||
*/
|
||||
|
||||
package jdk.vm.ci.runtime.test;
|
||||
|
@ -33,7 +33,7 @@
|
||||
* @run driver compiler.profiling.spectrapredefineclass.Launcher
|
||||
* @run main/othervm -XX:-TieredCompilation -XX:-BackgroundCompilation
|
||||
* -XX:-UseOnStackReplacement -XX:TypeProfileLevel=222
|
||||
* -XX:ReservedCodeCacheSize=3M
|
||||
* -XX:ReservedCodeCacheSize=3M -Djdk.attach.allowAttachSelf
|
||||
* compiler.profiling.spectrapredefineclass.Agent
|
||||
*/
|
||||
|
||||
|
@ -36,7 +36,7 @@
|
||||
* @run driver compiler.profiling.spectrapredefineclass_classloaders.Launcher
|
||||
* @run main/othervm -XX:-TieredCompilation -XX:-BackgroundCompilation
|
||||
* -XX:-UseOnStackReplacement -XX:TypeProfileLevel=222
|
||||
* -XX:ReservedCodeCacheSize=3M
|
||||
* -XX:ReservedCodeCacheSize=3M -Djdk.attach.allowAttachSelf
|
||||
* compiler.profiling.spectrapredefineclass_classloaders.Agent
|
||||
*/
|
||||
|
||||
|
@ -28,7 +28,7 @@
|
||||
* @modules java.base/jdk.internal.misc
|
||||
* jdk.attach/sun.tools.attach
|
||||
* java.management
|
||||
* @run main/othervm -XX:MinHeapFreeRatio=0 -XX:MaxHeapFreeRatio=100 TestOptionsWithRangesDynamic
|
||||
* @run main/othervm -XX:MinHeapFreeRatio=0 -XX:MaxHeapFreeRatio=100 -Djdk.attach.allowAttachSelf TestOptionsWithRangesDynamic
|
||||
*/
|
||||
|
||||
import java.util.List;
|
||||
|
@ -41,8 +41,8 @@
|
||||
* @run main/othervm -XX:+UnlockDiagnosticVMOptions
|
||||
-XX:-UnsyncloadClass -XX:-AllowParallelDefineClass
|
||||
test.DefineClass defineClassParallel
|
||||
* @run main/othervm test.DefineClass redefineClass
|
||||
* @run main/othervm test.DefineClass redefineClassWithError
|
||||
* @run main/othervm -Djdk.attach.allowAttachSelf test.DefineClass redefineClass
|
||||
* @run main/othervm -Djdk.attach.allowAttachSelf test.DefineClass redefineClassWithError
|
||||
* @author volker.simonis@gmail.com
|
||||
*/
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2015, 2016, 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
|
||||
@ -23,7 +23,7 @@
|
||||
|
||||
/*
|
||||
* @test
|
||||
* @summary modules=debug should have logging from statements in the code
|
||||
* @summary -Xlog:module should emit logging output
|
||||
* @library /test/lib
|
||||
* @modules java.base/jdk.internal.misc
|
||||
* java.management
|
||||
@ -35,9 +35,16 @@ import jdk.test.lib.process.ProcessTools;
|
||||
|
||||
public class ModulesTest {
|
||||
public static void main(String[] args) throws Exception {
|
||||
ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(
|
||||
"-Xlog:modules=trace", "-version");
|
||||
OutputAnalyzer output = new OutputAnalyzer(pb.start());
|
||||
testModuleTrace("-Xlog:module=trace", "-version");
|
||||
testModuleLoad("-Xlog:module+load", "-version");
|
||||
testModuleUnload("-Xlog:module+unload", "-version");
|
||||
|
||||
// same as -Xlog:module+load -Xlog:module+unload
|
||||
testModuleLoad("-verbose:module", "-version");
|
||||
}
|
||||
|
||||
static void testModuleTrace(String... args) throws Exception {
|
||||
OutputAnalyzer output = run(args);
|
||||
output.shouldContain("define_javabase_module(): Definition of module:");
|
||||
output.shouldContain("define_javabase_module(): creation of package");
|
||||
output.shouldContain("define_module(): creation of module");
|
||||
@ -48,5 +55,22 @@ public class ModulesTest {
|
||||
output.shouldContain("Setting package: class:");
|
||||
output.shouldHaveExitValue(0);
|
||||
}
|
||||
|
||||
static void testModuleLoad(String... args) throws Exception {
|
||||
OutputAnalyzer output = run(args);
|
||||
output.shouldContain("java.base location:");
|
||||
output.shouldContain("java.management location:");
|
||||
output.shouldHaveExitValue(0);
|
||||
}
|
||||
|
||||
static void testModuleUnload(String... args) throws Exception {
|
||||
OutputAnalyzer output = run(args);
|
||||
output.shouldHaveExitValue(0);
|
||||
}
|
||||
|
||||
static OutputAnalyzer run(String... args) throws Exception {
|
||||
ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(args);
|
||||
return new OutputAnalyzer(pb.start());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2015, 2016, 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
|
||||
@ -57,7 +57,7 @@ public class StartupTimeTest {
|
||||
|
||||
static void analyzeModulesOutputOff(ProcessBuilder pb) throws Exception {
|
||||
OutputAnalyzer output = new OutputAnalyzer(pb.start());
|
||||
output.shouldNotContain("[modules,startuptime]");
|
||||
output.shouldNotContain("[module,startuptime]");
|
||||
output.shouldHaveExitValue(0);
|
||||
}
|
||||
|
||||
@ -70,11 +70,11 @@ public class StartupTimeTest {
|
||||
InnerClass.class.getName());
|
||||
analyzeOutputOff(pb);
|
||||
|
||||
pb = ProcessTools.createJavaProcessBuilder("-Xlog:startuptime+modules",
|
||||
pb = ProcessTools.createJavaProcessBuilder("-Xlog:startuptime+module",
|
||||
InnerClass.class.getName());
|
||||
analyzeModulesOutputOn(pb);
|
||||
|
||||
pb = ProcessTools.createJavaProcessBuilder("-Xlog:startuptime+modules=off",
|
||||
pb = ProcessTools.createJavaProcessBuilder("-Xlog:startuptime+module=off",
|
||||
InnerClass.class.getName());
|
||||
analyzeModulesOutputOff(pb);
|
||||
}
|
||||
|
@ -41,12 +41,12 @@ public class JVMAddModuleExports {
|
||||
MyClassLoader to_cl = new MyClassLoader();
|
||||
Module from_module, to_module;
|
||||
|
||||
from_module = ModuleHelper.ModuleObject("from_module", from_cl, new String[] { "mypackage", "this/package" });
|
||||
from_module = ModuleHelper.ModuleObject("from_module", from_cl, new String[] { "mypackage", "x/apackage" });
|
||||
assertNotNull(from_module, "Module should not be null");
|
||||
ModuleHelper.DefineModule(from_module, "9.0", "from_module/here", new String[] { "mypackage", "this/package" });
|
||||
to_module = ModuleHelper.ModuleObject("to_module", to_cl, new String[] { "yourpackage", "that/package" });
|
||||
ModuleHelper.DefineModule(from_module, "9.0", "from_module/here", new String[] { "mypackage", "x/apackage" });
|
||||
to_module = ModuleHelper.ModuleObject("to_module", to_cl, new String[] { "yourpackage", "that/apackage" });
|
||||
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, "9.0", "to_module/here", new String[] { "yourpackage", "that/apackage" });
|
||||
|
||||
// Null from_module argument, expect an NPE
|
||||
try {
|
||||
@ -117,19 +117,19 @@ public class JVMAddModuleExports {
|
||||
|
||||
// Export a package, that is not in from_module, to from_module
|
||||
try {
|
||||
ModuleHelper.AddModuleExports(from_module, "that/package", from_module);
|
||||
ModuleHelper.AddModuleExports(from_module, "that/apackage", from_module);
|
||||
throw new RuntimeException("Failed to get the expected IAE");
|
||||
} catch(IllegalArgumentException e) {
|
||||
// Expected
|
||||
}
|
||||
|
||||
// Export the same package twice to the same module
|
||||
ModuleHelper.AddModuleExports(from_module, "this/package", to_module);
|
||||
ModuleHelper.AddModuleExports(from_module, "this/package", to_module);
|
||||
ModuleHelper.AddModuleExports(from_module, "x/apackage", to_module);
|
||||
ModuleHelper.AddModuleExports(from_module, "x/apackage", to_module);
|
||||
|
||||
// Export a package, using '.' instead of '/'
|
||||
try {
|
||||
ModuleHelper.AddModuleExports(from_module, "this.package", to_module);
|
||||
ModuleHelper.AddModuleExports(from_module, "x.apackage", to_module);
|
||||
throw new RuntimeException("Failed to get the expected IAE");
|
||||
} catch(IllegalArgumentException e) {
|
||||
// Expected
|
||||
@ -137,8 +137,8 @@ public class JVMAddModuleExports {
|
||||
|
||||
// Export a package to the unnamed module and then to a specific module.
|
||||
// The qualified export should be ignored.
|
||||
ModuleHelper.AddModuleExportsToAll(to_module, "that/package");
|
||||
ModuleHelper.AddModuleExports(to_module, "that/package", from_module);
|
||||
ModuleHelper.AddModuleExportsToAll(to_module, "that/apackage");
|
||||
ModuleHelper.AddModuleExports(to_module, "that/apackage", from_module);
|
||||
}
|
||||
|
||||
static class MyClassLoader extends ClassLoader { }
|
||||
|
@ -49,16 +49,16 @@ public class JVMAddModulePackage {
|
||||
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" });
|
||||
module_three = ModuleHelper.ModuleObject("module_three", cl3, new String[] { "package/num3" });
|
||||
module_three = ModuleHelper.ModuleObject("module_three", cl3, new String[] { "apackage/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, "9.0", "module_three/here", new String[] { "apackage/num3" });
|
||||
|
||||
// Simple call
|
||||
ModuleHelper.AddModulePackage(module_one, "new_package");
|
||||
|
||||
// Add a package and export it
|
||||
ModuleHelper.AddModulePackage(module_one, "package/num3");
|
||||
ModuleHelper.AddModuleExportsToAll(module_one, "package/num3");
|
||||
ModuleHelper.AddModulePackage(module_one, "apackage/num3");
|
||||
ModuleHelper.AddModuleExportsToAll(module_one, "apackage/num3");
|
||||
|
||||
// Null module argument, expect an NPE
|
||||
try {
|
||||
@ -94,7 +94,7 @@ public class JVMAddModulePackage {
|
||||
|
||||
// Invalid package name, expect an IAE
|
||||
try {
|
||||
ModuleHelper.AddModulePackage(module_one, "your.package");
|
||||
ModuleHelper.AddModulePackage(module_one, "your.apackage");
|
||||
throw new RuntimeException("Failed to get the expected IAE");
|
||||
} catch(IllegalArgumentException e) {
|
||||
// Expected
|
||||
@ -102,7 +102,7 @@ public class JVMAddModulePackage {
|
||||
|
||||
// Invalid package name, expect an IAE
|
||||
try {
|
||||
ModuleHelper.AddModulePackage(module_one, ";your/package");
|
||||
ModuleHelper.AddModulePackage(module_one, ";your/apackage");
|
||||
throw new RuntimeException("Failed to get the expected IAE");
|
||||
} catch(IllegalArgumentException e) {
|
||||
// Expected
|
||||
|
@ -207,10 +207,10 @@ public class JVMDefineModule {
|
||||
ModuleHelper.DefineModule(m, "9.0", "module.name/here", new String[] { });
|
||||
|
||||
// Invalid package name, expect an IAE
|
||||
m = ModuleHelper.ModuleObject("moduleFive", cl, new String[] { "your.package" });
|
||||
m = ModuleHelper.ModuleObject("moduleFive", cl, new String[] { "your.apackage" });
|
||||
try {
|
||||
ModuleHelper.DefineModule(m, "9.0", "module.name/here", new String[] { "your.package" });
|
||||
throw new RuntimeException("Failed to get expected IAE for your.package");
|
||||
ModuleHelper.DefineModule(m, "9.0", "module.name/here", new String[] { "your.apackage" });
|
||||
throw new RuntimeException("Failed to get expected IAE for your.apackage");
|
||||
} catch(IllegalArgumentException e) {
|
||||
if (!e.getMessage().contains("Invalid package name")) {
|
||||
throw new RuntimeException("Failed to get expected IAE message for bad package name: " + e.getMessage());
|
||||
@ -220,8 +220,8 @@ public class JVMDefineModule {
|
||||
// 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" });
|
||||
throw new RuntimeException("Failed to get expected IAE for ;your.package");
|
||||
ModuleHelper.DefineModule(m, "9.0", "module.name/here", new String[] { ";your/apackage" });
|
||||
throw new RuntimeException("Failed to get expected IAE for ;your.apackage");
|
||||
} catch(IllegalArgumentException e) {
|
||||
if (!e.getMessage().contains("Invalid package name")) {
|
||||
throw new RuntimeException("Failed to get expected IAE message for bad package name: " + e.getMessage());
|
||||
|
@ -53,7 +53,7 @@ public class ModuleStress {
|
||||
// those loaders never die.
|
||||
ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(
|
||||
"-Xbootclasspath/a:.",
|
||||
"-Xlog:modules=trace",
|
||||
"-Xlog:module=trace",
|
||||
"-version");
|
||||
|
||||
OutputAnalyzer oa = new OutputAnalyzer(pb.start());
|
||||
@ -88,7 +88,7 @@ public class ModuleStress {
|
||||
// the same loader and thus have the exact same life cycle.
|
||||
pb = ProcessTools.createJavaProcessBuilder(
|
||||
"-Xbootclasspath/a:.",
|
||||
"-Xlog:modules=trace",
|
||||
"-Xlog:module=trace",
|
||||
"ModuleSameCLMain");
|
||||
|
||||
oa = new OutputAnalyzer(pb.start());
|
||||
@ -102,7 +102,7 @@ public class ModuleStress {
|
||||
// class loaders which could die and thus be unloaded.
|
||||
pb = ProcessTools.createJavaProcessBuilder(
|
||||
"-Xbootclasspath/a:.",
|
||||
"-Xlog:modules=trace",
|
||||
"-Xlog:module=trace",
|
||||
"ModuleNonBuiltinCLMain");
|
||||
|
||||
oa = new OutputAnalyzer(pb.start());
|
||||
@ -120,7 +120,7 @@ public class ModuleStress {
|
||||
pb = ProcessTools.createJavaProcessBuilder(
|
||||
"-Djava.system.class.loader=CustomSystemClassLoader",
|
||||
"-Xbootclasspath/a:.",
|
||||
"-Xlog:modules=trace",
|
||||
"-Xlog:module=trace",
|
||||
"ModuleNonBuiltinCLMain");
|
||||
|
||||
oa = new OutputAnalyzer(pb.start());
|
||||
|
@ -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
|
||||
@ -73,7 +73,7 @@ public class ModuleStressGC {
|
||||
// test's, defined to module jdk.translet, export list at
|
||||
// GC safepoints.
|
||||
ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(
|
||||
"-Xlog:modules=trace",
|
||||
"-Xlog:module=trace",
|
||||
"-p", MODS_DIR.toString(),
|
||||
"-m", "jdk.test/test.MainGC");
|
||||
OutputAnalyzer oa = new OutputAnalyzer(pb.start());
|
||||
|
Loading…
x
Reference in New Issue
Block a user