8185717: Make ModuleEntry->module() return an oop not a jobject
Summary: Change ModuleEntry::module() to return an oop and add a ModuleEntry::module_handle() that returns a jobject
Reviewed-by: shade, coleenp, lfoltan
--- a/hotspot/src/share/vm/classfile/classFileParser.cpp Tue Aug 08 08:41:36 2017 -0400
+++ b/hotspot/src/share/vm/classfile/classFileParser.cpp Tue Aug 08 09:53:52 2017 -0400
@@ -5440,7 +5440,7 @@
assert(module_entry != NULL, "module_entry should always be set");
// Obtain java.lang.Module
- Handle module_handle(THREAD, JNIHandles::resolve(module_entry->module()));
+ Handle module_handle(THREAD, module_entry->module());
// Allocate mirror and initialize static fields
// The create_mirror() call will also call compute_modifiers()
--- a/hotspot/src/share/vm/classfile/javaClasses.cpp Tue Aug 08 08:41:36 2017 -0400
+++ b/hotspot/src/share/vm/classfile/javaClasses.cpp Tue Aug 08 09:53:52 2017 -0400
@@ -799,15 +799,15 @@
// If java.base was already defined then patch this particular class with java.base.
if (javabase_was_defined) {
ModuleEntry *javabase_entry = ModuleEntryTable::javabase_moduleEntry();
- assert(javabase_entry != NULL && javabase_entry->module() != NULL,
+ assert(javabase_entry != NULL && javabase_entry->module_handle() != NULL,
"Setting class module field, " JAVA_BASE_NAME " should be defined");
- Handle javabase_handle(THREAD, JNIHandles::resolve(javabase_entry->module()));
+ Handle javabase_handle(THREAD, javabase_entry->module());
set_module(mirror(), javabase_handle());
}
} else {
assert(Universe::is_module_initialized() ||
(ModuleEntryTable::javabase_defined() &&
- (module() == JNIHandles::resolve(ModuleEntryTable::javabase_moduleEntry()->module()))),
+ (module() == ModuleEntryTable::javabase_moduleEntry()->module())),
"Incorrect java.lang.Module specification while creating mirror");
set_module(mirror(), module());
}
--- a/hotspot/src/share/vm/classfile/moduleEntry.hpp Tue Aug 08 08:41:36 2017 -0400
+++ b/hotspot/src/share/vm/classfile/moduleEntry.hpp Tue Aug 08 09:53:52 2017 -0400
@@ -29,6 +29,7 @@
#include "classfile/vmSymbols.hpp"
#include "oops/symbol.hpp"
#include "prims/jni.h"
+#include "runtime/jniHandles.hpp"
#include "runtime/mutexLocker.hpp"
#include "trace/traceMacros.hpp"
#include "utilities/growableArray.hpp"
@@ -88,7 +89,8 @@
Symbol* name() const { return literal(); }
void set_name(Symbol* n) { set_literal(n); }
- jobject module() const { return _module; }
+ oop module() const { return JNIHandles::resolve(_module); }
+ jobject module_handle() const { return _module; }
void set_module(jobject j) { _module = j; }
// The shared ProtectionDomain reference is set once the VM loads a shared class
@@ -242,8 +244,9 @@
// Special handling for java.base
static ModuleEntry* javabase_moduleEntry() { return _javabase_module; }
static void set_javabase_moduleEntry(ModuleEntry* java_base) { _javabase_module = java_base; }
- static bool javabase_defined() { return ((_javabase_module != NULL) &&
- (_javabase_module->module() != NULL)); }
+
+ static bool javabase_defined() { return ((_javabase_module != NULL) &&
+ (_javabase_module->module_handle() != NULL)); }
static void finalize_javabase(Handle module_handle, Symbol* version, Symbol* location);
static void patch_javabase_entries(Handle module_handle);
--- a/hotspot/src/share/vm/classfile/modules.cpp Tue Aug 08 08:41:36 2017 -0400
+++ b/hotspot/src/share/vm/classfile/modules.cpp Tue Aug 08 09:53:52 2017 -0400
@@ -663,7 +663,7 @@
const ModuleEntry* const module_entry = (pkg_entry != NULL ? pkg_entry->module() : NULL);
if (module_entry != NULL && module_entry->module() != NULL && module_entry->is_named()) {
- return JNIHandles::make_local(THREAD, JNIHandles::resolve(module_entry->module()));
+ return JNIHandles::make_local(THREAD, module_entry->module());
}
return NULL;
}
@@ -677,7 +677,7 @@
if (module_entry != NULL &&
module_entry->module() != NULL) {
- return JNIHandles::make_local(THREAD, JNIHandles::resolve(module_entry->module()));
+ return JNIHandles::make_local(THREAD, module_entry->module());
}
return NULL;
--- a/hotspot/src/share/vm/oops/arrayKlass.cpp Tue Aug 08 08:41:36 2017 -0400
+++ b/hotspot/src/share/vm/oops/arrayKlass.cpp Tue Aug 08 09:53:52 2017 -0400
@@ -107,7 +107,7 @@
// java.base is defined.
assert((module_entry != NULL) || ((module_entry == NULL) && !ModuleEntryTable::javabase_defined()),
"module entry not available post " JAVA_BASE_NAME " definition");
- oop module = (module_entry != NULL) ? JNIHandles::resolve(module_entry->module()) : (oop)NULL;
+ oop module = (module_entry != NULL) ? module_entry->module() : (oop)NULL;
java_lang_Class::create_mirror(k, Handle(THREAD, k->class_loader()), Handle(THREAD, module), Handle(), CHECK);
}
--- a/hotspot/src/share/vm/oops/klass.cpp Tue Aug 08 08:41:36 2017 -0400
+++ b/hotspot/src/share/vm/oops/klass.cpp Tue Aug 08 09:53:52 2017 -0400
@@ -559,7 +559,7 @@
module_entry = ModuleEntryTable::javabase_moduleEntry();
}
// Obtain java.lang.Module, if available
- Handle module_handle(THREAD, ((module_entry != NULL) ? JNIHandles::resolve(module_entry->module()) : (oop)NULL));
+ Handle module_handle(THREAD, ((module_entry != NULL) ? module_entry->module() : (oop)NULL));
java_lang_Class::create_mirror(this, loader, module_handle, protection_domain, CHECK);
}
}
--- a/hotspot/src/share/vm/prims/jvmtiEnvBase.hpp Tue Aug 08 08:41:36 2017 -0400
+++ b/hotspot/src/share/vm/prims/jvmtiEnvBase.hpp Tue Aug 08 09:53:52 2017 -0400
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2003, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 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
@@ -708,7 +708,7 @@
static void do_module(ModuleEntry* entry) {
assert_locked_or_safepoint(Module_lock);
- jobject module = entry->module();
+ jobject module = entry->module_handle();
guarantee(module != NULL, "module object is NULL");
_tbl->push(module);
}
--- a/hotspot/src/share/vm/prims/jvmtiExport.cpp Tue Aug 08 08:41:36 2017 -0400
+++ b/hotspot/src/share/vm/prims/jvmtiExport.cpp Tue Aug 08 09:53:52 2017 -0400
@@ -764,12 +764,12 @@
ModuleEntry* module_entry = InstanceKlass::cast(klass)->module();
assert(module_entry != NULL, "module_entry should always be set");
if (module_entry->is_named() &&
- module_entry->module() != NULL &&
+ module_entry->module_handle() != NULL &&
!module_entry->has_default_read_edges()) {
if (!module_entry->set_has_default_read_edges()) {
// We won a potential race.
// Add read edges to the unnamed modules of the bootstrap and app class loaders
- Handle class_module(_thread, JNIHandles::resolve(module_entry->module())); // Obtain j.l.r.Module
+ Handle class_module(_thread, module_entry->module()); // Obtain j.l.r.Module
JvmtiExport::add_default_read_edges(class_module, _thread);
}
}
--- a/hotspot/src/share/vm/runtime/reflection.cpp Tue Aug 08 08:41:36 2017 -0400
+++ b/hotspot/src/share/vm/runtime/reflection.cpp Tue Aug 08 09:53:52 2017 -0400
@@ -603,9 +603,9 @@
current_class_name, module_from_name, new_class_name,
module_to_name, module_from_name, module_to_name);
} else {
- jobject jlm = module_to->module();
+ oop jlm = module_to->module();
assert(jlm != NULL, "Null jlm in module_to ModuleEntry");
- intptr_t identity_hash = JNIHandles::resolve(jlm)->identity_hash();
+ intptr_t identity_hash = jlm->identity_hash();
size_t len = 160 + strlen(current_class_name) + 2*strlen(module_from_name) +
strlen(new_class_name) + 2*sizeof(uintx);
msg = NEW_RESOURCE_ARRAY(char, len);
@@ -630,9 +630,9 @@
current_class_name, module_from_name, new_class_name,
module_to_name, module_to_name, package_name, module_from_name);
} else {
- jobject jlm = module_from->module();
+ oop jlm = module_from->module();
assert(jlm != NULL, "Null jlm in module_from ModuleEntry");
- intptr_t identity_hash = JNIHandles::resolve(jlm)->identity_hash();
+ intptr_t identity_hash = jlm->identity_hash();
size_t len = 170 + strlen(current_class_name) + strlen(new_class_name) +
2*strlen(module_to_name) + strlen(package_name) + 2*sizeof(uintx);
msg = NEW_RESOURCE_ARRAY(char, len);