mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-27 23:04:50 +02:00
8185717: Make ModuleEntry->module() return an oop not a jobject
Change ModuleEntry::module() to return an oop and add a ModuleEntry::module_handle() that returns a jobject Reviewed-by: shade, coleenp, lfoltan
This commit is contained in:
parent
2787fd2cd7
commit
1a92a2ad53
9 changed files with 22 additions and 19 deletions
|
@ -5440,7 +5440,7 @@ void ClassFileParser::fill_instance_klass(InstanceKlass* ik, bool changed_by_loa
|
||||||
assert(module_entry != NULL, "module_entry should always be set");
|
assert(module_entry != NULL, "module_entry should always be set");
|
||||||
|
|
||||||
// Obtain java.lang.Module
|
// 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
|
// Allocate mirror and initialize static fields
|
||||||
// The create_mirror() call will also call compute_modifiers()
|
// The create_mirror() call will also call compute_modifiers()
|
||||||
|
|
|
@ -799,15 +799,15 @@ void java_lang_Class::set_mirror_module_field(Klass* k, Handle mirror, Handle mo
|
||||||
// If java.base was already defined then patch this particular class with java.base.
|
// If java.base was already defined then patch this particular class with java.base.
|
||||||
if (javabase_was_defined) {
|
if (javabase_was_defined) {
|
||||||
ModuleEntry *javabase_entry = ModuleEntryTable::javabase_moduleEntry();
|
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");
|
"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());
|
set_module(mirror(), javabase_handle());
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
assert(Universe::is_module_initialized() ||
|
assert(Universe::is_module_initialized() ||
|
||||||
(ModuleEntryTable::javabase_defined() &&
|
(ModuleEntryTable::javabase_defined() &&
|
||||||
(module() == JNIHandles::resolve(ModuleEntryTable::javabase_moduleEntry()->module()))),
|
(module() == ModuleEntryTable::javabase_moduleEntry()->module())),
|
||||||
"Incorrect java.lang.Module specification while creating mirror");
|
"Incorrect java.lang.Module specification while creating mirror");
|
||||||
set_module(mirror(), module());
|
set_module(mirror(), module());
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,6 +29,7 @@
|
||||||
#include "classfile/vmSymbols.hpp"
|
#include "classfile/vmSymbols.hpp"
|
||||||
#include "oops/symbol.hpp"
|
#include "oops/symbol.hpp"
|
||||||
#include "prims/jni.h"
|
#include "prims/jni.h"
|
||||||
|
#include "runtime/jniHandles.hpp"
|
||||||
#include "runtime/mutexLocker.hpp"
|
#include "runtime/mutexLocker.hpp"
|
||||||
#include "trace/traceMacros.hpp"
|
#include "trace/traceMacros.hpp"
|
||||||
#include "utilities/growableArray.hpp"
|
#include "utilities/growableArray.hpp"
|
||||||
|
@ -88,7 +89,8 @@ public:
|
||||||
Symbol* name() const { return literal(); }
|
Symbol* name() const { return literal(); }
|
||||||
void set_name(Symbol* n) { set_literal(n); }
|
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; }
|
void set_module(jobject j) { _module = j; }
|
||||||
|
|
||||||
// The shared ProtectionDomain reference is set once the VM loads a shared class
|
// The shared ProtectionDomain reference is set once the VM loads a shared class
|
||||||
|
@ -242,8 +244,9 @@ public:
|
||||||
// Special handling for java.base
|
// Special handling for java.base
|
||||||
static ModuleEntry* javabase_moduleEntry() { return _javabase_module; }
|
static ModuleEntry* javabase_moduleEntry() { return _javabase_module; }
|
||||||
static void set_javabase_moduleEntry(ModuleEntry* java_base) { _javabase_module = java_base; }
|
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 finalize_javabase(Handle module_handle, Symbol* version, Symbol* location);
|
||||||
static void patch_javabase_entries(Handle module_handle);
|
static void patch_javabase_entries(Handle module_handle);
|
||||||
|
|
||||||
|
|
|
@ -663,7 +663,7 @@ jobject Modules::get_named_module(Handle h_loader, const char* package_name, TRA
|
||||||
const ModuleEntry* const module_entry = (pkg_entry != NULL ? pkg_entry->module() : NULL);
|
const ModuleEntry* const module_entry = (pkg_entry != NULL ? pkg_entry->module() : NULL);
|
||||||
|
|
||||||
if (module_entry != NULL && module_entry->module() != NULL && module_entry->is_named()) {
|
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;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
@ -677,7 +677,7 @@ jobject Modules::get_module(Symbol* package_name, Handle h_loader, TRAPS) {
|
||||||
|
|
||||||
if (module_entry != NULL &&
|
if (module_entry != NULL &&
|
||||||
module_entry->module() != 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;
|
return NULL;
|
||||||
|
|
|
@ -107,7 +107,7 @@ void ArrayKlass::complete_create_array_klass(ArrayKlass* k, Klass* super_klass,
|
||||||
// java.base is defined.
|
// java.base is defined.
|
||||||
assert((module_entry != NULL) || ((module_entry == NULL) && !ModuleEntryTable::javabase_defined()),
|
assert((module_entry != NULL) || ((module_entry == NULL) && !ModuleEntryTable::javabase_defined()),
|
||||||
"module entry not available post " JAVA_BASE_NAME " definition");
|
"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);
|
java_lang_Class::create_mirror(k, Handle(THREAD, k->class_loader()), Handle(THREAD, module), Handle(), CHECK);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -559,7 +559,7 @@ void Klass::restore_unshareable_info(ClassLoaderData* loader_data, Handle protec
|
||||||
module_entry = ModuleEntryTable::javabase_moduleEntry();
|
module_entry = ModuleEntryTable::javabase_moduleEntry();
|
||||||
}
|
}
|
||||||
// Obtain java.lang.Module, if available
|
// 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);
|
java_lang_Class::create_mirror(this, loader, module_handle, protection_domain, CHECK);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -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.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
|
@ -708,7 +708,7 @@ private:
|
||||||
|
|
||||||
static void do_module(ModuleEntry* entry) {
|
static void do_module(ModuleEntry* entry) {
|
||||||
assert_locked_or_safepoint(Module_lock);
|
assert_locked_or_safepoint(Module_lock);
|
||||||
jobject module = entry->module();
|
jobject module = entry->module_handle();
|
||||||
guarantee(module != NULL, "module object is NULL");
|
guarantee(module != NULL, "module object is NULL");
|
||||||
_tbl->push(module);
|
_tbl->push(module);
|
||||||
}
|
}
|
||||||
|
|
|
@ -764,12 +764,12 @@ class JvmtiClassFileLoadHookPoster : public StackObj {
|
||||||
ModuleEntry* module_entry = InstanceKlass::cast(klass)->module();
|
ModuleEntry* module_entry = InstanceKlass::cast(klass)->module();
|
||||||
assert(module_entry != NULL, "module_entry should always be set");
|
assert(module_entry != NULL, "module_entry should always be set");
|
||||||
if (module_entry->is_named() &&
|
if (module_entry->is_named() &&
|
||||||
module_entry->module() != NULL &&
|
module_entry->module_handle() != NULL &&
|
||||||
!module_entry->has_default_read_edges()) {
|
!module_entry->has_default_read_edges()) {
|
||||||
if (!module_entry->set_has_default_read_edges()) {
|
if (!module_entry->set_has_default_read_edges()) {
|
||||||
// We won a potential race.
|
// We won a potential race.
|
||||||
// Add read edges to the unnamed modules of the bootstrap and app class loaders
|
// 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);
|
JvmtiExport::add_default_read_edges(class_module, _thread);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -603,9 +603,9 @@ char* Reflection::verify_class_access_msg(const Klass* current_class,
|
||||||
current_class_name, module_from_name, new_class_name,
|
current_class_name, module_from_name, new_class_name,
|
||||||
module_to_name, module_from_name, module_to_name);
|
module_to_name, module_from_name, module_to_name);
|
||||||
} else {
|
} else {
|
||||||
jobject jlm = module_to->module();
|
oop jlm = module_to->module();
|
||||||
assert(jlm != NULL, "Null jlm in module_to ModuleEntry");
|
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) +
|
size_t len = 160 + strlen(current_class_name) + 2*strlen(module_from_name) +
|
||||||
strlen(new_class_name) + 2*sizeof(uintx);
|
strlen(new_class_name) + 2*sizeof(uintx);
|
||||||
msg = NEW_RESOURCE_ARRAY(char, len);
|
msg = NEW_RESOURCE_ARRAY(char, len);
|
||||||
|
@ -630,9 +630,9 @@ char* Reflection::verify_class_access_msg(const Klass* current_class,
|
||||||
current_class_name, module_from_name, new_class_name,
|
current_class_name, module_from_name, new_class_name,
|
||||||
module_to_name, module_to_name, package_name, module_from_name);
|
module_to_name, module_to_name, package_name, module_from_name);
|
||||||
} else {
|
} else {
|
||||||
jobject jlm = module_from->module();
|
oop jlm = module_from->module();
|
||||||
assert(jlm != NULL, "Null jlm in module_from ModuleEntry");
|
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) +
|
size_t len = 170 + strlen(current_class_name) + strlen(new_class_name) +
|
||||||
2*strlen(module_to_name) + strlen(package_name) + 2*sizeof(uintx);
|
2*strlen(module_to_name) + strlen(package_name) + 2*sizeof(uintx);
|
||||||
msg = NEW_RESOURCE_ARRAY(char, len);
|
msg = NEW_RESOURCE_ARRAY(char, len);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue