2007-12-01 00:00:00 +00:00
|
|
|
/*
|
2019-01-05 20:08:24 +01:00
|
|
|
* Copyright (c) 1997, 2019, Oracle and/or its affiliates. All rights reserved.
|
2007-12-01 00:00:00 +00:00
|
|
|
* 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.
|
|
|
|
*
|
2010-05-27 19:08:38 -07:00
|
|
|
* 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.
|
2007-12-01 00:00:00 +00:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2010-11-23 13:22:55 -08:00
|
|
|
#include "precompiled.hpp"
|
2017-10-31 11:55:09 -04:00
|
|
|
#include "jvm.h"
|
2016-12-11 19:07:04 -08:00
|
|
|
#include "aot/aotLoader.hpp"
|
2015-12-08 20:04:03 +01:00
|
|
|
#include "classfile/classFileParser.hpp"
|
2016-02-03 11:40:30 -05:00
|
|
|
#include "classfile/classFileStream.hpp"
|
2016-12-11 19:07:04 -08:00
|
|
|
#include "classfile/classLoader.hpp"
|
2018-04-18 18:43:04 -04:00
|
|
|
#include "classfile/classLoaderData.inline.hpp"
|
2010-11-23 13:22:55 -08:00
|
|
|
#include "classfile/javaClasses.hpp"
|
2016-12-01 08:56:41 +00:00
|
|
|
#include "classfile/moduleEntry.hpp"
|
2010-11-23 13:22:55 -08:00
|
|
|
#include "classfile/systemDictionary.hpp"
|
2016-04-06 21:53:44 -07:00
|
|
|
#include "classfile/systemDictionaryShared.hpp"
|
2010-11-23 13:22:55 -08:00
|
|
|
#include "classfile/verifier.hpp"
|
|
|
|
#include "classfile/vmSymbols.hpp"
|
2015-11-18 03:03:43 +03:00
|
|
|
#include "code/dependencyContext.hpp"
|
2010-11-23 13:22:55 -08:00
|
|
|
#include "compiler/compileBroker.hpp"
|
2015-05-13 15:16:06 +02:00
|
|
|
#include "gc/shared/collectedHeap.inline.hpp"
|
2010-11-23 13:22:55 -08:00
|
|
|
#include "interpreter/oopMapCache.hpp"
|
|
|
|
#include "interpreter/rewriter.hpp"
|
|
|
|
#include "jvmtifiles/jvmti.h"
|
2016-02-03 11:40:30 -05:00
|
|
|
#include "logging/log.hpp"
|
2017-05-08 09:45:24 -04:00
|
|
|
#include "logging/logMessage.hpp"
|
2017-07-21 09:50:12 +02:00
|
|
|
#include "logging/logStream.hpp"
|
2018-03-08 09:56:29 +01:00
|
|
|
#include "memory/allocation.inline.hpp"
|
2013-01-25 15:06:18 -05:00
|
|
|
#include "memory/heapInspection.hpp"
|
2014-06-24 16:20:15 +02:00
|
|
|
#include "memory/iterator.inline.hpp"
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
#include "memory/metadataFactory.hpp"
|
2017-08-02 18:06:38 -07:00
|
|
|
#include "memory/metaspaceClosure.hpp"
|
2016-09-18 21:10:48 -04:00
|
|
|
#include "memory/metaspaceShared.hpp"
|
2010-11-23 13:22:55 -08:00
|
|
|
#include "memory/oopFactory.hpp"
|
2016-04-04 12:57:48 -04:00
|
|
|
#include "memory/resourceArea.hpp"
|
2011-09-10 17:29:02 -07:00
|
|
|
#include "oops/fieldStreams.hpp"
|
2019-02-20 09:53:28 +01:00
|
|
|
#include "oops/constantPool.hpp"
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
#include "oops/instanceClassLoaderKlass.hpp"
|
2015-04-02 10:04:27 +02:00
|
|
|
#include "oops/instanceKlass.inline.hpp"
|
2011-03-18 16:00:34 -07:00
|
|
|
#include "oops/instanceMirrorKlass.hpp"
|
2010-11-23 13:22:55 -08:00
|
|
|
#include "oops/instanceOop.hpp"
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
#include "oops/klass.inline.hpp"
|
|
|
|
#include "oops/method.hpp"
|
2010-11-23 13:22:55 -08:00
|
|
|
#include "oops/oop.inline.hpp"
|
2011-01-27 16:11:27 -08:00
|
|
|
#include "oops/symbol.hpp"
|
2010-11-23 13:22:55 -08:00
|
|
|
#include "prims/jvmtiExport.hpp"
|
2013-07-17 18:06:29 -04:00
|
|
|
#include "prims/jvmtiRedefineClasses.hpp"
|
2014-02-24 10:28:22 +01:00
|
|
|
#include "prims/jvmtiThreadState.hpp"
|
2013-01-02 20:28:09 -05:00
|
|
|
#include "prims/methodComparator.hpp"
|
2016-08-21 20:56:37 -04:00
|
|
|
#include "runtime/atomic.hpp"
|
2018-08-20 13:58:23 -07:00
|
|
|
#include "runtime/fieldDescriptor.inline.hpp"
|
2010-11-23 13:22:55 -08:00
|
|
|
#include "runtime/handles.inline.hpp"
|
|
|
|
#include "runtime/javaCalls.hpp"
|
|
|
|
#include "runtime/mutexLocker.hpp"
|
2018-06-06 10:45:40 -04:00
|
|
|
#include "runtime/orderAccess.hpp"
|
2012-11-27 14:20:21 +01:00
|
|
|
#include "runtime/thread.inline.hpp"
|
2013-04-24 16:19:35 -04:00
|
|
|
#include "services/classLoadingService.hpp"
|
2010-11-23 13:22:55 -08:00
|
|
|
#include "services/threadService.hpp"
|
|
|
|
#include "utilities/dtrace.hpp"
|
2019-02-13 06:48:34 -05:00
|
|
|
#include "utilities/events.hpp"
|
2013-01-23 13:02:39 -05:00
|
|
|
#include "utilities/macros.hpp"
|
2016-07-27 08:31:48 -04:00
|
|
|
#include "utilities/stringUtils.hpp"
|
2010-11-23 13:22:55 -08:00
|
|
|
#ifdef COMPILER1
|
|
|
|
#include "c1/c1_Compiler.hpp"
|
|
|
|
#endif
|
2018-08-28 10:10:11 -04:00
|
|
|
#if INCLUDE_JFR
|
|
|
|
#include "jfr/jfrEvents.hpp"
|
|
|
|
#endif
|
|
|
|
|
2007-12-01 00:00:00 +00:00
|
|
|
|
2010-03-17 11:01:05 +01:00
|
|
|
#ifdef DTRACE_ENABLED
|
|
|
|
|
2011-10-13 09:35:42 -07:00
|
|
|
|
|
|
|
#define HOTSPOT_CLASS_INITIALIZATION_required HOTSPOT_CLASS_INITIALIZATION_REQUIRED
|
|
|
|
#define HOTSPOT_CLASS_INITIALIZATION_recursive HOTSPOT_CLASS_INITIALIZATION_RECURSIVE
|
|
|
|
#define HOTSPOT_CLASS_INITIALIZATION_concurrent HOTSPOT_CLASS_INITIALIZATION_CONCURRENT
|
|
|
|
#define HOTSPOT_CLASS_INITIALIZATION_erroneous HOTSPOT_CLASS_INITIALIZATION_ERRONEOUS
|
|
|
|
#define HOTSPOT_CLASS_INITIALIZATION_super__failed HOTSPOT_CLASS_INITIALIZATION_SUPER_FAILED
|
|
|
|
#define HOTSPOT_CLASS_INITIALIZATION_clinit HOTSPOT_CLASS_INITIALIZATION_CLINIT
|
|
|
|
#define HOTSPOT_CLASS_INITIALIZATION_error HOTSPOT_CLASS_INITIALIZATION_ERROR
|
|
|
|
#define HOTSPOT_CLASS_INITIALIZATION_end HOTSPOT_CLASS_INITIALIZATION_END
|
2017-03-21 11:25:18 -04:00
|
|
|
#define DTRACE_CLASSINIT_PROBE(type, thread_type) \
|
2011-10-13 09:35:42 -07:00
|
|
|
{ \
|
|
|
|
char* data = NULL; \
|
|
|
|
int len = 0; \
|
2017-03-21 11:25:18 -04:00
|
|
|
Symbol* clss_name = name(); \
|
|
|
|
if (clss_name != NULL) { \
|
|
|
|
data = (char*)clss_name->bytes(); \
|
|
|
|
len = clss_name->utf8_length(); \
|
2011-10-13 09:35:42 -07:00
|
|
|
} \
|
|
|
|
HOTSPOT_CLASS_INITIALIZATION_##type( \
|
2017-08-07 12:19:17 +02:00
|
|
|
data, len, (void*)class_loader(), thread_type); \
|
2011-10-13 09:35:42 -07:00
|
|
|
}
|
|
|
|
|
2017-03-21 11:25:18 -04:00
|
|
|
#define DTRACE_CLASSINIT_PROBE_WAIT(type, thread_type, wait) \
|
2011-10-13 09:35:42 -07:00
|
|
|
{ \
|
|
|
|
char* data = NULL; \
|
|
|
|
int len = 0; \
|
2017-03-21 11:25:18 -04:00
|
|
|
Symbol* clss_name = name(); \
|
|
|
|
if (clss_name != NULL) { \
|
|
|
|
data = (char*)clss_name->bytes(); \
|
|
|
|
len = clss_name->utf8_length(); \
|
2011-10-13 09:35:42 -07:00
|
|
|
} \
|
|
|
|
HOTSPOT_CLASS_INITIALIZATION_##type( \
|
2017-08-07 12:19:17 +02:00
|
|
|
data, len, (void*)class_loader(), thread_type, wait); \
|
2011-10-13 09:35:42 -07:00
|
|
|
}
|
2010-03-17 11:01:05 +01:00
|
|
|
|
|
|
|
#else // ndef DTRACE_ENABLED
|
|
|
|
|
2017-03-21 11:25:18 -04:00
|
|
|
#define DTRACE_CLASSINIT_PROBE(type, thread_type)
|
|
|
|
#define DTRACE_CLASSINIT_PROBE_WAIT(type, thread_type, wait)
|
2010-03-17 11:01:05 +01:00
|
|
|
|
|
|
|
#endif // ndef DTRACE_ENABLED
|
|
|
|
|
2015-12-08 20:04:03 +01:00
|
|
|
static inline bool is_class_loader(const Symbol* class_name,
|
|
|
|
const ClassFileParser& parser) {
|
|
|
|
assert(class_name != NULL, "invariant");
|
|
|
|
|
|
|
|
if (class_name == vmSymbols::java_lang_ClassLoader()) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (SystemDictionary::ClassLoader_klass_loaded()) {
|
|
|
|
const Klass* const super_klass = parser.super_klass();
|
|
|
|
if (super_klass != NULL) {
|
|
|
|
if (super_klass->is_subtype_of(SystemDictionary::ClassLoader_klass())) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2018-06-23 01:32:41 -04:00
|
|
|
// called to verify that k is a member of this nest
|
|
|
|
bool InstanceKlass::has_nest_member(InstanceKlass* k, TRAPS) const {
|
|
|
|
if (_nest_members == NULL || _nest_members == Universe::the_empty_short_array()) {
|
|
|
|
if (log_is_enabled(Trace, class, nestmates)) {
|
|
|
|
ResourceMark rm(THREAD);
|
|
|
|
log_trace(class, nestmates)("Checked nest membership of %s in non-nest-host class %s",
|
|
|
|
k->external_name(), this->external_name());
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (log_is_enabled(Trace, class, nestmates)) {
|
|
|
|
ResourceMark rm(THREAD);
|
|
|
|
log_trace(class, nestmates)("Checking nest membership of %s in %s",
|
|
|
|
k->external_name(), this->external_name());
|
|
|
|
}
|
|
|
|
|
2018-10-23 17:01:48 -04:00
|
|
|
// Check for a resolved cp entry , else fall back to a name check.
|
|
|
|
// We don't want to resolve any class other than the one being checked.
|
2018-06-23 01:32:41 -04:00
|
|
|
for (int i = 0; i < _nest_members->length(); i++) {
|
|
|
|
int cp_index = _nest_members->at(i);
|
2018-10-23 17:01:48 -04:00
|
|
|
if (_constants->tag_at(cp_index).is_klass()) {
|
2018-06-23 01:32:41 -04:00
|
|
|
Klass* k2 = _constants->klass_at(cp_index, CHECK_false);
|
|
|
|
if (k2 == k) {
|
2018-10-23 17:01:48 -04:00
|
|
|
log_trace(class, nestmates)("- class is listed at nest_members[%d] => cp[%d]", i, cp_index);
|
2018-06-23 01:32:41 -04:00
|
|
|
return true;
|
2018-10-23 17:01:48 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
Symbol* name = _constants->klass_name_at(cp_index);
|
|
|
|
if (name == k->name()) {
|
|
|
|
log_trace(class, nestmates)("- Found it at nest_members[%d] => cp[%d]", i, cp_index);
|
|
|
|
|
2019-02-20 19:41:43 -05:00
|
|
|
// Names match so check actual klass - this may trigger class loading if
|
|
|
|
// it doesn't match (though that should be impossible). But to be safe we
|
|
|
|
// have to check for a compiler thread executing here.
|
|
|
|
if (!THREAD->can_call_java() && !_constants->tag_at(cp_index).is_klass()) {
|
|
|
|
log_trace(class, nestmates)("- validation required resolution in an unsuitable thread");
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2018-10-23 17:01:48 -04:00
|
|
|
Klass* k2 = _constants->klass_at(cp_index, CHECK_false);
|
|
|
|
if (k2 == k) {
|
|
|
|
log_trace(class, nestmates)("- class is listed as a nest member");
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
// same name but different klass!
|
|
|
|
log_trace(class, nestmates)(" - klass comparison failed!");
|
|
|
|
// can't have two names the same, so we're done
|
|
|
|
return false;
|
|
|
|
}
|
2018-06-23 01:32:41 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
log_trace(class, nestmates)("- class is NOT a nest member!");
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Return nest-host class, resolving, validating and saving it if needed.
|
|
|
|
// In cases where this is called from a thread that can not do classloading
|
|
|
|
// (such as a native JIT thread) then we simply return NULL, which in turn
|
|
|
|
// causes the access check to return false. Such code will retry the access
|
|
|
|
// from a more suitable environment later.
|
|
|
|
InstanceKlass* InstanceKlass::nest_host(Symbol* validationException, TRAPS) {
|
|
|
|
InstanceKlass* nest_host_k = _nest_host;
|
|
|
|
if (nest_host_k == NULL) {
|
|
|
|
// need to resolve and save our nest-host class. This could be attempted
|
|
|
|
// concurrently but as the result is idempotent and we don't use the class
|
|
|
|
// then we do not need any synchronization beyond what is implicitly used
|
|
|
|
// during class loading.
|
|
|
|
if (_nest_host_index != 0) { // we have a real nest_host
|
|
|
|
// Before trying to resolve check if we're in a suitable context
|
|
|
|
if (!THREAD->can_call_java() && !_constants->tag_at(_nest_host_index).is_klass()) {
|
|
|
|
if (log_is_enabled(Trace, class, nestmates)) {
|
|
|
|
ResourceMark rm(THREAD);
|
|
|
|
log_trace(class, nestmates)("Rejected resolution of nest-host of %s in unsuitable thread",
|
|
|
|
this->external_name());
|
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (log_is_enabled(Trace, class, nestmates)) {
|
|
|
|
ResourceMark rm(THREAD);
|
|
|
|
log_trace(class, nestmates)("Resolving nest-host of %s using cp entry for %s",
|
|
|
|
this->external_name(),
|
|
|
|
_constants->klass_name_at(_nest_host_index)->as_C_string());
|
|
|
|
}
|
|
|
|
|
|
|
|
Klass* k = _constants->klass_at(_nest_host_index, THREAD);
|
|
|
|
if (HAS_PENDING_EXCEPTION) {
|
|
|
|
Handle exc_h = Handle(THREAD, PENDING_EXCEPTION);
|
|
|
|
if (exc_h->is_a(SystemDictionary::NoClassDefFoundError_klass())) {
|
|
|
|
// throw a new CDNFE with the original as its cause, and a clear msg
|
|
|
|
ResourceMark rm(THREAD);
|
|
|
|
char buf[200];
|
|
|
|
CLEAR_PENDING_EXCEPTION;
|
|
|
|
jio_snprintf(buf, sizeof(buf),
|
|
|
|
"Unable to load nest-host class (%s) of %s",
|
|
|
|
_constants->klass_name_at(_nest_host_index)->as_C_string(),
|
|
|
|
this->external_name());
|
|
|
|
log_trace(class, nestmates)("%s - NoClassDefFoundError", buf);
|
|
|
|
THROW_MSG_CAUSE_NULL(vmSymbols::java_lang_NoClassDefFoundError(), buf, exc_h);
|
|
|
|
}
|
|
|
|
// All other exceptions pass through (OOME, StackOverflowError, LinkageErrors etc).
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
// A valid nest-host is an instance class in the current package that lists this
|
|
|
|
// class as a nest member. If any of these conditions are not met we post the
|
|
|
|
// requested exception type (if any) and return NULL
|
|
|
|
|
|
|
|
const char* error = NULL;
|
|
|
|
|
|
|
|
// JVMS 5.4.4 indicates package check comes first
|
|
|
|
if (is_same_class_package(k)) {
|
|
|
|
|
|
|
|
// Now check actual membership. We can't be a member if our "host" is
|
|
|
|
// not an instance class.
|
|
|
|
if (k->is_instance_klass()) {
|
|
|
|
nest_host_k = InstanceKlass::cast(k);
|
|
|
|
|
|
|
|
bool is_member = nest_host_k->has_nest_member(this, CHECK_NULL);
|
|
|
|
if (is_member) {
|
|
|
|
// save resolved nest-host value
|
|
|
|
_nest_host = nest_host_k;
|
|
|
|
|
|
|
|
if (log_is_enabled(Trace, class, nestmates)) {
|
|
|
|
ResourceMark rm(THREAD);
|
|
|
|
log_trace(class, nestmates)("Resolved nest-host of %s to %s",
|
|
|
|
this->external_name(), k->external_name());
|
|
|
|
}
|
|
|
|
return nest_host_k;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
error = "current type is not listed as a nest member";
|
|
|
|
} else {
|
|
|
|
error = "types are in different packages";
|
|
|
|
}
|
|
|
|
|
|
|
|
if (log_is_enabled(Trace, class, nestmates)) {
|
|
|
|
ResourceMark rm(THREAD);
|
2018-11-27 21:20:16 -05:00
|
|
|
log_trace(class, nestmates)
|
|
|
|
("Type %s (loader: %s) is not a nest member of "
|
|
|
|
"resolved type %s (loader: %s): %s",
|
|
|
|
this->external_name(),
|
|
|
|
this->class_loader_data()->loader_name_and_id(),
|
|
|
|
k->external_name(),
|
|
|
|
k->class_loader_data()->loader_name_and_id(),
|
|
|
|
error);
|
2018-06-23 01:32:41 -04:00
|
|
|
}
|
|
|
|
|
2019-02-20 19:41:43 -05:00
|
|
|
if (validationException != NULL && THREAD->can_call_java()) {
|
2018-06-23 01:32:41 -04:00
|
|
|
ResourceMark rm(THREAD);
|
|
|
|
Exceptions::fthrow(THREAD_AND_LOCATION,
|
|
|
|
validationException,
|
2018-11-27 21:20:16 -05:00
|
|
|
"Type %s (loader: %s) is not a nest member of %s (loader: %s): %s",
|
2018-06-23 01:32:41 -04:00
|
|
|
this->external_name(),
|
2018-11-27 21:20:16 -05:00
|
|
|
this->class_loader_data()->loader_name_and_id(),
|
2018-06-23 01:32:41 -04:00
|
|
|
k->external_name(),
|
2018-11-27 21:20:16 -05:00
|
|
|
k->class_loader_data()->loader_name_and_id(),
|
2018-06-23 01:32:41 -04:00
|
|
|
error
|
|
|
|
);
|
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
} else {
|
|
|
|
if (log_is_enabled(Trace, class, nestmates)) {
|
|
|
|
ResourceMark rm(THREAD);
|
|
|
|
log_trace(class, nestmates)("Type %s is not part of a nest: setting nest-host to self",
|
|
|
|
this->external_name());
|
|
|
|
}
|
|
|
|
// save resolved nest-host value
|
|
|
|
return (_nest_host = this);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return nest_host_k;
|
|
|
|
}
|
|
|
|
|
|
|
|
// check if 'this' and k are nestmates (same nest_host), or k is our nest_host,
|
|
|
|
// or we are k's nest_host - all of which is covered by comparing the two
|
|
|
|
// resolved_nest_hosts
|
|
|
|
bool InstanceKlass::has_nestmate_access_to(InstanceKlass* k, TRAPS) {
|
|
|
|
|
|
|
|
assert(this != k, "this should be handled by higher-level code");
|
|
|
|
|
|
|
|
// Per JVMS 5.4.4 we first resolve and validate the current class, then
|
|
|
|
// the target class k. Resolution exceptions will be passed on by upper
|
|
|
|
// layers. IncompatibleClassChangeErrors from membership validation failures
|
|
|
|
// will also be passed through.
|
|
|
|
|
|
|
|
Symbol* icce = vmSymbols::java_lang_IncompatibleClassChangeError();
|
|
|
|
InstanceKlass* cur_host = nest_host(icce, CHECK_false);
|
|
|
|
if (cur_host == NULL) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
Klass* k_nest_host = k->nest_host(icce, CHECK_false);
|
|
|
|
if (k_nest_host == NULL) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool access = (cur_host == k_nest_host);
|
|
|
|
|
|
|
|
if (log_is_enabled(Trace, class, nestmates)) {
|
|
|
|
ResourceMark rm(THREAD);
|
|
|
|
log_trace(class, nestmates)("Class %s does %shave nestmate access to %s",
|
|
|
|
this->external_name(),
|
|
|
|
access ? "" : "NOT ",
|
|
|
|
k->external_name());
|
|
|
|
}
|
|
|
|
|
|
|
|
return access;
|
|
|
|
}
|
|
|
|
|
2015-12-08 20:04:03 +01:00
|
|
|
InstanceKlass* InstanceKlass::allocate_instance_klass(const ClassFileParser& parser, TRAPS) {
|
|
|
|
const int size = InstanceKlass::size(parser.vtable_size(),
|
|
|
|
parser.itable_size(),
|
|
|
|
nonstatic_oop_map_size(parser.total_oop_map_count()),
|
|
|
|
parser.is_interface(),
|
2018-08-20 08:25:57 -04:00
|
|
|
parser.is_unsafe_anonymous(),
|
|
|
|
should_store_fingerprint(parser.is_unsafe_anonymous()));
|
2015-12-08 20:04:03 +01:00
|
|
|
|
|
|
|
const Symbol* const class_name = parser.class_name();
|
|
|
|
assert(class_name != NULL, "invariant");
|
|
|
|
ClassLoaderData* loader_data = parser.loader_data();
|
|
|
|
assert(loader_data != NULL, "invariant");
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
|
|
|
|
InstanceKlass* ik;
|
2015-12-08 20:04:03 +01:00
|
|
|
|
|
|
|
// Allocation
|
|
|
|
if (REF_NONE == parser.reference_type()) {
|
|
|
|
if (class_name == vmSymbols::java_lang_Class()) {
|
|
|
|
// mirror
|
|
|
|
ik = new (loader_data, size, THREAD) InstanceMirrorKlass(parser);
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
}
|
2015-12-08 20:04:03 +01:00
|
|
|
else if (is_class_loader(class_name, parser)) {
|
|
|
|
// class loader
|
|
|
|
ik = new (loader_data, size, THREAD) InstanceClassLoaderKlass(parser);
|
2018-06-23 01:32:41 -04:00
|
|
|
} else {
|
2015-12-08 20:04:03 +01:00
|
|
|
// normal
|
|
|
|
ik = new (loader_data, size, THREAD) InstanceKlass(parser, InstanceKlass::_misc_kind_other);
|
|
|
|
}
|
2018-06-23 01:32:41 -04:00
|
|
|
} else {
|
2015-12-08 20:04:03 +01:00
|
|
|
// reference
|
|
|
|
ik = new (loader_data, size, THREAD) InstanceRefKlass(parser);
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
}
|
|
|
|
|
2013-03-13 17:34:29 -04:00
|
|
|
// Check for pending exception before adding to the loader data and incrementing
|
|
|
|
// class count. Can get OOM here.
|
|
|
|
if (HAS_PENDING_EXCEPTION) {
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
return ik;
|
|
|
|
}
|
|
|
|
|
2013-03-13 17:34:29 -04:00
|
|
|
|
|
|
|
// copy method ordering from resource area to Metaspace
|
2015-12-08 20:04:03 +01:00
|
|
|
void InstanceKlass::copy_method_ordering(const intArray* m, TRAPS) {
|
2013-03-13 17:34:29 -04:00
|
|
|
if (m != NULL) {
|
|
|
|
// allocate a new array and copy contents (memcpy?)
|
|
|
|
_method_ordering = MetadataFactory::new_array<int>(class_loader_data(), m->length(), CHECK);
|
|
|
|
for (int i = 0; i < m->length(); i++) {
|
|
|
|
_method_ordering->at_put(i, m->at(i));
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
_method_ordering = Universe::the_empty_int_array();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-10-07 12:20:28 -04:00
|
|
|
// create a new array of vtable_indices for default methods
|
|
|
|
Array<int>* InstanceKlass::create_new_default_vtable_indices(int len, TRAPS) {
|
|
|
|
Array<int>* vtable_indices = MetadataFactory::new_array<int>(class_loader_data(), len, CHECK_NULL);
|
|
|
|
assert(default_vtable_indices() == NULL, "only create once");
|
|
|
|
set_default_vtable_indices(vtable_indices);
|
|
|
|
return vtable_indices;
|
|
|
|
}
|
2013-03-13 17:34:29 -04:00
|
|
|
|
2018-05-26 06:59:49 +02:00
|
|
|
InstanceKlass::InstanceKlass(const ClassFileParser& parser, unsigned kind, KlassID id) :
|
|
|
|
Klass(id),
|
2018-08-08 15:31:07 +02:00
|
|
|
_nest_members(NULL),
|
|
|
|
_nest_host_index(0),
|
|
|
|
_nest_host(NULL),
|
2015-12-08 20:04:03 +01:00
|
|
|
_static_field_size(parser.static_field_size()),
|
|
|
|
_nonstatic_oop_map_size(nonstatic_oop_map_size(parser.total_oop_map_count())),
|
|
|
|
_itable_len(parser.itable_size()),
|
2018-11-07 19:40:27 -08:00
|
|
|
_reference_type(parser.reference_type())
|
|
|
|
{
|
|
|
|
set_vtable_length(parser.vtable_size());
|
|
|
|
set_kind(kind);
|
|
|
|
set_access_flags(parser.access_flags());
|
|
|
|
set_is_unsafe_anonymous(parser.is_unsafe_anonymous());
|
|
|
|
set_layout_helper(Klass::instance_layout_helper(parser.layout_size(),
|
2015-12-08 20:04:03 +01:00
|
|
|
false));
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
|
2018-11-07 19:40:27 -08:00
|
|
|
assert(NULL == _methods, "underlying memory not zeroed?");
|
|
|
|
assert(is_instance_klass(), "is layout incorrect?");
|
|
|
|
assert(size_helper() == parser.layout_size(), "incorrect size_helper?");
|
|
|
|
|
|
|
|
if (DumpSharedSpaces) {
|
|
|
|
SystemDictionaryShared::init_dumptime_info(this);
|
|
|
|
}
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
}
|
|
|
|
|
2013-03-13 17:34:29 -04:00
|
|
|
void InstanceKlass::deallocate_methods(ClassLoaderData* loader_data,
|
|
|
|
Array<Method*>* methods) {
|
2013-10-12 15:39:16 -04:00
|
|
|
if (methods != NULL && methods != Universe::the_empty_method_array() &&
|
|
|
|
!methods->is_shared()) {
|
2013-03-13 17:34:29 -04:00
|
|
|
for (int i = 0; i < methods->length(); i++) {
|
|
|
|
Method* method = methods->at(i);
|
|
|
|
if (method == NULL) continue; // maybe null if error processing
|
|
|
|
// Only want to delete methods that are not executing for RedefineClasses.
|
|
|
|
// The previous version will point to them so they're not totally dangling
|
|
|
|
assert (!method->on_stack(), "shouldn't be called with methods on stack");
|
|
|
|
MetadataFactory::free_metadata(loader_data, method);
|
|
|
|
}
|
|
|
|
MetadataFactory::free_array<Method*>(loader_data, methods);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void InstanceKlass::deallocate_interfaces(ClassLoaderData* loader_data,
|
2015-12-08 20:04:03 +01:00
|
|
|
const Klass* super_klass,
|
2018-08-07 15:45:07 -07:00
|
|
|
Array<InstanceKlass*>* local_interfaces,
|
|
|
|
Array<InstanceKlass*>* transitive_interfaces) {
|
2013-03-13 17:34:29 -04:00
|
|
|
// Only deallocate transitive interfaces if not empty, same as super class
|
|
|
|
// or same as local interfaces. See code in parseClassFile.
|
2018-08-07 15:45:07 -07:00
|
|
|
Array<InstanceKlass*>* ti = transitive_interfaces;
|
|
|
|
if (ti != Universe::the_empty_instance_klass_array() && ti != local_interfaces) {
|
2013-03-13 17:34:29 -04:00
|
|
|
// check that the interfaces don't come from super class
|
2018-08-07 15:45:07 -07:00
|
|
|
Array<InstanceKlass*>* sti = (super_klass == NULL) ? NULL :
|
2013-03-13 17:34:29 -04:00
|
|
|
InstanceKlass::cast(super_klass)->transitive_interfaces();
|
2013-10-12 15:39:16 -04:00
|
|
|
if (ti != sti && ti != NULL && !ti->is_shared()) {
|
2018-08-07 15:45:07 -07:00
|
|
|
MetadataFactory::free_array<InstanceKlass*>(loader_data, ti);
|
2013-03-13 17:34:29 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// local interfaces can be empty
|
2018-08-07 15:45:07 -07:00
|
|
|
if (local_interfaces != Universe::the_empty_instance_klass_array() &&
|
2013-10-12 15:39:16 -04:00
|
|
|
local_interfaces != NULL && !local_interfaces->is_shared()) {
|
2018-08-07 15:45:07 -07:00
|
|
|
MetadataFactory::free_array<InstanceKlass*>(loader_data, local_interfaces);
|
2013-03-13 17:34:29 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
// This function deallocates the metadata and C heap pointers that the
|
|
|
|
// InstanceKlass points to.
|
|
|
|
void InstanceKlass::deallocate_contents(ClassLoaderData* loader_data) {
|
|
|
|
|
|
|
|
// Orphan the mirror first, CMS thinks it's still live.
|
2013-03-13 17:34:29 -04:00
|
|
|
if (java_mirror() != NULL) {
|
|
|
|
java_lang_Class::set_klass(java_mirror(), NULL);
|
|
|
|
}
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
|
2017-10-03 16:42:04 -04:00
|
|
|
// Also remove mirror from handles
|
|
|
|
loader_data->remove_handle(_java_mirror);
|
|
|
|
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
// Need to take this class off the class loader data list.
|
|
|
|
loader_data->remove_class(this);
|
|
|
|
|
|
|
|
// The array_klass for this class is created later, after error handling.
|
|
|
|
// For class redefinition, we keep the original class so this scratch class
|
|
|
|
// doesn't have an array class. Either way, assert that there is nothing
|
|
|
|
// to deallocate.
|
|
|
|
assert(array_klasses() == NULL, "array classes shouldn't be created for this class yet");
|
|
|
|
|
|
|
|
// Release C heap allocated data that this might point to, which includes
|
|
|
|
// reference counting symbol names.
|
|
|
|
release_C_heap_structures();
|
|
|
|
|
2013-03-13 17:34:29 -04:00
|
|
|
deallocate_methods(loader_data, methods());
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
set_methods(NULL);
|
|
|
|
|
2013-10-12 15:39:16 -04:00
|
|
|
if (method_ordering() != NULL &&
|
|
|
|
method_ordering() != Universe::the_empty_int_array() &&
|
|
|
|
!method_ordering()->is_shared()) {
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
MetadataFactory::free_array<int>(loader_data, method_ordering());
|
|
|
|
}
|
|
|
|
set_method_ordering(NULL);
|
|
|
|
|
2013-10-07 12:20:28 -04:00
|
|
|
// default methods can be empty
|
|
|
|
if (default_methods() != NULL &&
|
2013-10-12 15:39:16 -04:00
|
|
|
default_methods() != Universe::the_empty_method_array() &&
|
|
|
|
!default_methods()->is_shared()) {
|
2013-10-07 12:20:28 -04:00
|
|
|
MetadataFactory::free_array<Method*>(loader_data, default_methods());
|
|
|
|
}
|
|
|
|
// Do NOT deallocate the default methods, they are owned by superinterfaces.
|
|
|
|
set_default_methods(NULL);
|
|
|
|
|
|
|
|
// default methods vtable indices can be empty
|
2013-10-12 15:39:16 -04:00
|
|
|
if (default_vtable_indices() != NULL &&
|
|
|
|
!default_vtable_indices()->is_shared()) {
|
2013-10-07 12:20:28 -04:00
|
|
|
MetadataFactory::free_array<int>(loader_data, default_vtable_indices());
|
|
|
|
}
|
|
|
|
set_default_vtable_indices(NULL);
|
|
|
|
|
|
|
|
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
// This array is in Klass, but remove it with the InstanceKlass since
|
|
|
|
// this place would be the only caller and it can share memory with transitive
|
|
|
|
// interfaces.
|
2013-10-12 15:39:16 -04:00
|
|
|
if (secondary_supers() != NULL &&
|
|
|
|
secondary_supers() != Universe::the_empty_klass_array() &&
|
2018-08-07 15:45:07 -07:00
|
|
|
// see comments in compute_secondary_supers about the following cast
|
|
|
|
(address)(secondary_supers()) != (address)(transitive_interfaces()) &&
|
2013-10-12 15:39:16 -04:00
|
|
|
!secondary_supers()->is_shared()) {
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
MetadataFactory::free_array<Klass*>(loader_data, secondary_supers());
|
|
|
|
}
|
|
|
|
set_secondary_supers(NULL);
|
|
|
|
|
2013-03-13 17:34:29 -04:00
|
|
|
deallocate_interfaces(loader_data, super(), local_interfaces(), transitive_interfaces());
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
set_transitive_interfaces(NULL);
|
|
|
|
set_local_interfaces(NULL);
|
|
|
|
|
2013-10-12 15:39:16 -04:00
|
|
|
if (fields() != NULL && !fields()->is_shared()) {
|
|
|
|
MetadataFactory::free_array<jushort>(loader_data, fields());
|
|
|
|
}
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
set_fields(NULL, 0);
|
|
|
|
|
|
|
|
// If a method from a redefined class is using this constant pool, don't
|
|
|
|
// delete it, yet. The new class's previous version will point to this.
|
2013-03-13 17:34:29 -04:00
|
|
|
if (constants() != NULL) {
|
|
|
|
assert (!constants()->on_stack(), "shouldn't be called if anything is onstack");
|
2013-10-12 15:39:16 -04:00
|
|
|
if (!constants()->is_shared()) {
|
|
|
|
MetadataFactory::free_metadata(loader_data, constants());
|
|
|
|
}
|
2015-06-16 15:59:57 +02:00
|
|
|
// Delete any cached resolution errors for the constant pool
|
|
|
|
SystemDictionary::delete_resolution_error(constants());
|
|
|
|
|
2013-03-13 17:34:29 -04:00
|
|
|
set_constants(NULL);
|
|
|
|
}
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
|
2013-10-12 15:39:16 -04:00
|
|
|
if (inner_classes() != NULL &&
|
|
|
|
inner_classes() != Universe::the_empty_short_array() &&
|
|
|
|
!inner_classes()->is_shared()) {
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
MetadataFactory::free_array<jushort>(loader_data, inner_classes());
|
|
|
|
}
|
|
|
|
set_inner_classes(NULL);
|
|
|
|
|
2018-06-23 01:32:41 -04:00
|
|
|
if (nest_members() != NULL &&
|
|
|
|
nest_members() != Universe::the_empty_short_array() &&
|
|
|
|
!nest_members()->is_shared()) {
|
|
|
|
MetadataFactory::free_array<jushort>(loader_data, nest_members());
|
|
|
|
}
|
|
|
|
set_nest_members(NULL);
|
|
|
|
|
2013-10-12 15:39:16 -04:00
|
|
|
// We should deallocate the Annotations instance if it's not in shared spaces.
|
|
|
|
if (annotations() != NULL && !annotations()->is_shared()) {
|
|
|
|
MetadataFactory::free_metadata(loader_data, annotations());
|
|
|
|
}
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
set_annotations(NULL);
|
2018-11-07 19:40:27 -08:00
|
|
|
|
|
|
|
if (DumpSharedSpaces) {
|
|
|
|
SystemDictionaryShared::remove_dumptime_info(this);
|
|
|
|
}
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
bool InstanceKlass::should_be_initialized() const {
|
2007-12-01 00:00:00 +00:00
|
|
|
return !is_initialized();
|
|
|
|
}
|
|
|
|
|
2017-04-13 01:56:01 -07:00
|
|
|
klassItable InstanceKlass::itable() const {
|
|
|
|
return klassItable(const_cast<InstanceKlass*>(this));
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
|
|
|
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
void InstanceKlass::eager_initialize(Thread *thread) {
|
2007-12-01 00:00:00 +00:00
|
|
|
if (!EagerInitialization) return;
|
|
|
|
|
|
|
|
if (this->is_not_initialized()) {
|
|
|
|
// abort if the the class has a class initializer
|
|
|
|
if (this->class_initializer() != NULL) return;
|
|
|
|
|
|
|
|
// abort if it is java.lang.Object (initialization is handled in genesis)
|
2017-03-21 11:25:18 -04:00
|
|
|
Klass* super_klass = super();
|
|
|
|
if (super_klass == NULL) return;
|
2007-12-01 00:00:00 +00:00
|
|
|
|
|
|
|
// abort if the super class should be initialized
|
2017-03-21 11:25:18 -04:00
|
|
|
if (!InstanceKlass::cast(super_klass)->is_initialized()) return;
|
2007-12-01 00:00:00 +00:00
|
|
|
|
|
|
|
// call body to expose the this pointer
|
2017-03-21 11:25:18 -04:00
|
|
|
eager_initialize_impl();
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-05-22 14:37:49 -04:00
|
|
|
// JVMTI spec thinks there are signers and protection domain in the
|
|
|
|
// instanceKlass. These accessors pretend these fields are there.
|
|
|
|
// The hprof specification also thinks these fields are in InstanceKlass.
|
|
|
|
oop InstanceKlass::protection_domain() const {
|
|
|
|
// return the protection_domain from the mirror
|
|
|
|
return java_lang_Class::protection_domain(java_mirror());
|
|
|
|
}
|
|
|
|
|
|
|
|
// To remove these from requires an incompatible change and CCC request.
|
|
|
|
objArrayOop InstanceKlass::signers() const {
|
|
|
|
// return the signers from the mirror
|
|
|
|
return java_lang_Class::signers(java_mirror());
|
|
|
|
}
|
|
|
|
|
2013-10-03 18:50:58 -04:00
|
|
|
oop InstanceKlass::init_lock() const {
|
2013-05-22 14:37:49 -04:00
|
|
|
// return the init lock from the mirror
|
2013-10-22 14:29:02 -07:00
|
|
|
oop lock = java_lang_Class::init_lock(java_mirror());
|
2014-09-02 21:27:08 -04:00
|
|
|
// Prevent reordering with any access of initialization state
|
|
|
|
OrderAccess::loadload();
|
2013-10-22 14:29:02 -07:00
|
|
|
assert((oop)lock != NULL || !is_not_initialized(), // initialized or in_error state
|
|
|
|
"only fully initialized state can have a null lock");
|
|
|
|
return lock;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Set the initialization lock to null so the object can be GC'ed. Any racing
|
|
|
|
// threads to get this lock will see a null lock and will not lock.
|
|
|
|
// That's okay because they all check for initialized state after getting
|
|
|
|
// the lock and return.
|
|
|
|
void InstanceKlass::fence_and_clear_init_lock() {
|
|
|
|
// make sure previous stores are all done, notably the init_state.
|
|
|
|
OrderAccess::storestore();
|
|
|
|
java_lang_Class::set_init_lock(java_mirror(), NULL);
|
|
|
|
assert(!is_not_initialized(), "class must be initialized now");
|
2013-05-22 14:37:49 -04:00
|
|
|
}
|
2007-12-01 00:00:00 +00:00
|
|
|
|
2017-03-21 11:25:18 -04:00
|
|
|
void InstanceKlass::eager_initialize_impl() {
|
2007-12-01 00:00:00 +00:00
|
|
|
EXCEPTION_MARK;
|
2017-02-15 22:59:57 -05:00
|
|
|
HandleMark hm(THREAD);
|
2017-03-21 11:25:18 -04:00
|
|
|
Handle h_init_lock(THREAD, init_lock());
|
2017-06-23 09:54:52 -04:00
|
|
|
ObjectLocker ol(h_init_lock, THREAD, h_init_lock() != NULL);
|
2007-12-01 00:00:00 +00:00
|
|
|
|
|
|
|
// abort if someone beat us to the initialization
|
2017-03-21 11:25:18 -04:00
|
|
|
if (!is_not_initialized()) return; // note: not equivalent to is_initialized()
|
2007-12-01 00:00:00 +00:00
|
|
|
|
2017-03-21 11:25:18 -04:00
|
|
|
ClassState old_state = init_state();
|
2018-09-11 09:53:41 -04:00
|
|
|
link_class_impl(THREAD);
|
2007-12-01 00:00:00 +00:00
|
|
|
if (HAS_PENDING_EXCEPTION) {
|
|
|
|
CLEAR_PENDING_EXCEPTION;
|
|
|
|
// Abort if linking the class throws an exception.
|
|
|
|
|
|
|
|
// Use a test to avoid redundantly resetting the state if there's
|
|
|
|
// no change. Set_init_state() asserts that state changes make
|
|
|
|
// progress, whereas here we might just be spinning in place.
|
2017-03-21 11:25:18 -04:00
|
|
|
if (old_state != _init_state)
|
|
|
|
set_init_state(old_state);
|
2007-12-01 00:00:00 +00:00
|
|
|
} else {
|
|
|
|
// linking successfull, mark class as initialized
|
2017-03-21 11:25:18 -04:00
|
|
|
set_init_state(fully_initialized);
|
|
|
|
fence_and_clear_init_lock();
|
2007-12-01 00:00:00 +00:00
|
|
|
// trace
|
2016-04-29 22:40:51 -04:00
|
|
|
if (log_is_enabled(Info, class, init)) {
|
2007-12-01 00:00:00 +00:00
|
|
|
ResourceMark rm(THREAD);
|
2017-03-21 11:25:18 -04:00
|
|
|
log_info(class, init)("[Initialized %s without side effects]", external_name());
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// See "The Virtual Machine Specification" section 2.16.5 for a detailed explanation of the class initialization
|
|
|
|
// process. The step comments refers to the procedure described in that section.
|
|
|
|
// Note: implementation moved to static method to expose the this pointer.
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
void InstanceKlass::initialize(TRAPS) {
|
2007-12-01 00:00:00 +00:00
|
|
|
if (this->should_be_initialized()) {
|
2017-03-21 11:25:18 -04:00
|
|
|
initialize_impl(CHECK);
|
2007-12-01 00:00:00 +00:00
|
|
|
// Note: at this point the class may be initialized
|
|
|
|
// OR it may be in the state of being initialized
|
|
|
|
// in case of recursive initialization!
|
|
|
|
} else {
|
|
|
|
assert(is_initialized(), "sanity check");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2018-09-11 09:53:41 -04:00
|
|
|
bool InstanceKlass::verify_code(TRAPS) {
|
2007-12-01 00:00:00 +00:00
|
|
|
// 1) Verify the bytecodes
|
2018-09-11 09:53:41 -04:00
|
|
|
return Verifier::verify(this, should_verify_class(), THREAD);
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
|
|
|
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
void InstanceKlass::link_class(TRAPS) {
|
2007-12-01 00:00:00 +00:00
|
|
|
assert(is_loaded(), "must be loaded");
|
|
|
|
if (!is_linked()) {
|
2018-09-11 09:53:41 -04:00
|
|
|
link_class_impl(CHECK);
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Called to verify that a class can link during initialization, without
|
|
|
|
// throwing a VerifyError.
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
bool InstanceKlass::link_class_or_fail(TRAPS) {
|
2007-12-01 00:00:00 +00:00
|
|
|
assert(is_loaded(), "must be loaded");
|
|
|
|
if (!is_linked()) {
|
2018-09-11 09:53:41 -04:00
|
|
|
link_class_impl(CHECK_false);
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
|
|
|
return is_linked();
|
|
|
|
}
|
|
|
|
|
2018-09-11 09:53:41 -04:00
|
|
|
bool InstanceKlass::link_class_impl(TRAPS) {
|
2017-03-21 11:25:18 -04:00
|
|
|
if (DumpSharedSpaces && is_in_error_state()) {
|
2016-10-20 13:41:07 -07:00
|
|
|
// This is for CDS dumping phase only -- we use the in_error_state to indicate that
|
|
|
|
// the class has failed verification. Throwing the NoClassDefFoundError here is just
|
|
|
|
// a convenient way to stop repeat attempts to verify the same (bad) class.
|
|
|
|
//
|
|
|
|
// Note that the NoClassDefFoundError is not part of the JLS, and should not be thrown
|
|
|
|
// if we are executing Java code. This is not a problem for CDS dumping phase since
|
|
|
|
// it doesn't execute any Java code.
|
2007-12-01 00:00:00 +00:00
|
|
|
ResourceMark rm(THREAD);
|
2017-05-04 10:05:29 -04:00
|
|
|
Exceptions::fthrow(THREAD_AND_LOCATION,
|
|
|
|
vmSymbols::java_lang_NoClassDefFoundError(),
|
|
|
|
"Class %s, or one of its supertypes, failed class initialization",
|
|
|
|
external_name());
|
|
|
|
return false;
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
|
|
|
// return if already verified
|
2017-03-21 11:25:18 -04:00
|
|
|
if (is_linked()) {
|
2007-12-01 00:00:00 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Timing
|
|
|
|
// timer handles recursion
|
|
|
|
assert(THREAD->is_Java_thread(), "non-JavaThread in link_class_impl");
|
|
|
|
JavaThread* jt = (JavaThread*)THREAD;
|
|
|
|
|
|
|
|
// link super class before linking this class
|
2017-03-21 11:25:18 -04:00
|
|
|
Klass* super_klass = super();
|
|
|
|
if (super_klass != NULL) {
|
|
|
|
if (super_klass->is_interface()) { // check if super class is an interface
|
2007-12-01 00:00:00 +00:00
|
|
|
ResourceMark rm(THREAD);
|
|
|
|
Exceptions::fthrow(
|
|
|
|
THREAD_AND_LOCATION,
|
2011-01-27 16:11:27 -08:00
|
|
|
vmSymbols::java_lang_IncompatibleClassChangeError(),
|
2007-12-01 00:00:00 +00:00
|
|
|
"class %s has interface %s as super class",
|
2017-03-21 11:25:18 -04:00
|
|
|
external_name(),
|
|
|
|
super_klass->external_name()
|
2007-12-01 00:00:00 +00:00
|
|
|
);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2017-03-21 11:25:18 -04:00
|
|
|
InstanceKlass* ik_super = InstanceKlass::cast(super_klass);
|
2018-09-11 09:53:41 -04:00
|
|
|
ik_super->link_class_impl(CHECK_false);
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// link all interfaces implemented by this class before linking this class
|
2018-08-07 15:45:07 -07:00
|
|
|
Array<InstanceKlass*>* interfaces = local_interfaces();
|
2007-12-01 00:00:00 +00:00
|
|
|
int num_interfaces = interfaces->length();
|
|
|
|
for (int index = 0; index < num_interfaces; index++) {
|
2018-08-07 15:45:07 -07:00
|
|
|
InstanceKlass* interk = interfaces->at(index);
|
2018-09-11 09:53:41 -04:00
|
|
|
interk->link_class_impl(CHECK_false);
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// in case the class is linked in the process of linking its superclasses
|
2017-03-21 11:25:18 -04:00
|
|
|
if (is_linked()) {
|
2007-12-01 00:00:00 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2009-07-10 11:10:00 -07:00
|
|
|
// trace only the link time for this klass that includes
|
|
|
|
// the verification time
|
|
|
|
PerfClassTraceTime vmtimer(ClassLoader::perf_class_link_time(),
|
|
|
|
ClassLoader::perf_class_link_selftime(),
|
|
|
|
ClassLoader::perf_classes_linked(),
|
|
|
|
jt->get_thread_stat()->perf_recursion_counts_addr(),
|
|
|
|
jt->get_thread_stat()->perf_timers_addr(),
|
|
|
|
PerfClassTraceTime::CLASS_LINK);
|
|
|
|
|
2007-12-01 00:00:00 +00:00
|
|
|
// verification & rewriting
|
|
|
|
{
|
2017-02-15 22:59:57 -05:00
|
|
|
HandleMark hm(THREAD);
|
2017-03-21 11:25:18 -04:00
|
|
|
Handle h_init_lock(THREAD, init_lock());
|
2017-06-23 09:54:52 -04:00
|
|
|
ObjectLocker ol(h_init_lock, THREAD, h_init_lock() != NULL);
|
2007-12-01 00:00:00 +00:00
|
|
|
// rewritten will have been set if loader constraint error found
|
|
|
|
// on an earlier link attempt
|
|
|
|
// don't verify or rewrite if already rewritten
|
2017-02-15 22:59:57 -05:00
|
|
|
//
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
|
2017-03-21 11:25:18 -04:00
|
|
|
if (!is_linked()) {
|
|
|
|
if (!is_rewritten()) {
|
2007-12-01 00:00:00 +00:00
|
|
|
{
|
2018-09-11 09:53:41 -04:00
|
|
|
bool verify_ok = verify_code(THREAD);
|
2007-12-01 00:00:00 +00:00
|
|
|
if (!verify_ok) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Just in case a side-effect of verify linked this class already
|
|
|
|
// (which can sometimes happen since the verifier loads classes
|
|
|
|
// using custom class loaders, which are free to initialize things)
|
2017-03-21 11:25:18 -04:00
|
|
|
if (is_linked()) {
|
2007-12-01 00:00:00 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
// also sets rewritten
|
2017-03-21 11:25:18 -04:00
|
|
|
rewrite_class(CHECK_false);
|
|
|
|
} else if (is_shared()) {
|
|
|
|
SystemDictionaryShared::check_verification_constraints(this, CHECK_false);
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
|
|
|
|
2011-05-21 15:39:54 -07:00
|
|
|
// relocate jsrs and link methods after they are all rewritten
|
2017-03-21 11:25:18 -04:00
|
|
|
link_methods(CHECK_false);
|
2011-05-21 15:39:54 -07:00
|
|
|
|
2007-12-01 00:00:00 +00:00
|
|
|
// Initialize the vtable and interface table after
|
|
|
|
// methods have been rewritten since rewrite may
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
// fabricate new Method*s.
|
2007-12-01 00:00:00 +00:00
|
|
|
// also does loader constraint checking
|
2016-04-20 16:39:37 -04:00
|
|
|
//
|
|
|
|
// initialize_vtable and initialize_itable need to be rerun for
|
|
|
|
// a shared class if the class is not loaded by the NULL classloader.
|
2017-03-21 11:25:18 -04:00
|
|
|
ClassLoaderData * loader_data = class_loader_data();
|
|
|
|
if (!(is_shared() &&
|
2016-04-20 16:39:37 -04:00
|
|
|
loader_data->is_the_null_class_loader_data())) {
|
2017-04-13 01:56:01 -07:00
|
|
|
vtable().initialize_vtable(true, CHECK_false);
|
|
|
|
itable().initialize_itable(true, CHECK_false);
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
|
|
|
#ifdef ASSERT
|
|
|
|
else {
|
2017-04-13 01:56:01 -07:00
|
|
|
vtable().verify(tty, true);
|
2007-12-01 00:00:00 +00:00
|
|
|
// In case itable verification is ever added.
|
2017-04-13 01:56:01 -07:00
|
|
|
// itable().verify(tty, true);
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
|
|
|
#endif
|
2017-03-21 11:25:18 -04:00
|
|
|
set_init_state(linked);
|
2007-12-01 00:00:00 +00:00
|
|
|
if (JvmtiExport::should_post_class_prepare()) {
|
|
|
|
Thread *thread = THREAD;
|
|
|
|
assert(thread->is_Java_thread(), "thread->is_Java_thread()");
|
2017-03-21 11:25:18 -04:00
|
|
|
JvmtiExport::post_class_prepare((JavaThread *) thread, this);
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Rewrite the byte codes of all of the methods of a class.
|
|
|
|
// The rewriter must be called exactly once. Rewriting must happen after
|
|
|
|
// verification but before the first method of the class is executed.
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
void InstanceKlass::rewrite_class(TRAPS) {
|
2007-12-01 00:00:00 +00:00
|
|
|
assert(is_loaded(), "must be loaded");
|
2017-03-15 10:25:37 -04:00
|
|
|
if (is_rewritten()) {
|
|
|
|
assert(is_shared(), "rewriting an unshared class?");
|
2007-12-01 00:00:00 +00:00
|
|
|
return;
|
|
|
|
}
|
2017-03-15 10:25:37 -04:00
|
|
|
Rewriter::rewrite(this, CHECK);
|
|
|
|
set_rewritten();
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
|
|
|
|
2011-05-21 15:39:54 -07:00
|
|
|
// Now relocate and link method entry points after class is rewritten.
|
|
|
|
// This is outside is_rewritten flag. In case of an exception, it can be
|
|
|
|
// executed more than once.
|
2013-01-02 20:28:09 -05:00
|
|
|
void InstanceKlass::link_methods(TRAPS) {
|
|
|
|
int len = methods()->length();
|
|
|
|
for (int i = len-1; i >= 0; i--) {
|
|
|
|
methodHandle m(THREAD, methods()->at(i));
|
|
|
|
|
|
|
|
// Set up method entry points for compiler and interpreter .
|
|
|
|
m->link_method(m, CHECK);
|
|
|
|
}
|
2011-05-21 15:39:54 -07:00
|
|
|
}
|
|
|
|
|
2014-10-22 15:24:37 -07:00
|
|
|
// Eagerly initialize superinterfaces that declare default methods (concrete instance: any access)
|
2017-03-21 11:25:18 -04:00
|
|
|
void InstanceKlass::initialize_super_interfaces(TRAPS) {
|
|
|
|
assert (has_nonstatic_concrete_methods(), "caller should have checked this");
|
|
|
|
for (int i = 0; i < local_interfaces()->length(); ++i) {
|
2018-08-07 15:45:07 -07:00
|
|
|
InstanceKlass* ik = local_interfaces()->at(i);
|
2016-09-21 09:56:18 -04:00
|
|
|
|
|
|
|
// Initialization is depth first search ie. we start with top of the inheritance tree
|
2016-10-03 21:48:21 -04:00
|
|
|
// has_nonstatic_concrete_methods drives searching superinterfaces since it
|
|
|
|
// means has_nonstatic_concrete_methods in its superinterface hierarchy
|
|
|
|
if (ik->has_nonstatic_concrete_methods()) {
|
2017-03-21 11:25:18 -04:00
|
|
|
ik->initialize_super_interfaces(CHECK);
|
2016-09-21 09:56:18 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
// Only initialize() interfaces that "declare" concrete methods.
|
2016-10-03 21:48:21 -04:00
|
|
|
if (ik->should_be_initialized() && ik->declares_nonstatic_concrete_methods()) {
|
2016-09-21 09:56:18 -04:00
|
|
|
ik->initialize(CHECK);
|
2014-10-22 15:24:37 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2007-12-01 00:00:00 +00:00
|
|
|
|
2017-03-21 11:25:18 -04:00
|
|
|
void InstanceKlass::initialize_impl(TRAPS) {
|
2017-02-15 22:59:57 -05:00
|
|
|
HandleMark hm(THREAD);
|
|
|
|
|
2007-12-01 00:00:00 +00:00
|
|
|
// Make sure klass is linked (verified) before initialization
|
|
|
|
// A class could already be verified, since it has been reflected upon.
|
2017-03-21 11:25:18 -04:00
|
|
|
link_class(CHECK);
|
2007-12-01 00:00:00 +00:00
|
|
|
|
2017-03-21 11:25:18 -04:00
|
|
|
DTRACE_CLASSINIT_PROBE(required, -1);
|
2010-03-17 11:01:05 +01:00
|
|
|
|
|
|
|
bool wait = false;
|
|
|
|
|
2019-01-15 16:40:31 -05:00
|
|
|
assert(THREAD->is_Java_thread(), "non-JavaThread in initialize_impl");
|
|
|
|
JavaThread* jt = (JavaThread*)THREAD;
|
|
|
|
|
2007-12-01 00:00:00 +00:00
|
|
|
// refer to the JVM book page 47 for description of steps
|
|
|
|
// Step 1
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
{
|
2017-03-21 11:25:18 -04:00
|
|
|
Handle h_init_lock(THREAD, init_lock());
|
2017-06-23 09:54:52 -04:00
|
|
|
ObjectLocker ol(h_init_lock, THREAD, h_init_lock() != NULL);
|
2007-12-01 00:00:00 +00:00
|
|
|
|
|
|
|
// Step 2
|
|
|
|
// If we were to use wait() instead of waitInterruptibly() then
|
|
|
|
// we might end up throwing IE from link/symbol resolution sites
|
|
|
|
// that aren't expected to throw. This would wreak havoc. See 6320309.
|
2019-01-15 16:40:31 -05:00
|
|
|
while (is_being_initialized() && !is_reentrant_initialization(jt)) {
|
|
|
|
wait = true;
|
|
|
|
jt->set_class_to_be_initialized(this);
|
|
|
|
ol.waitUninterruptibly(jt);
|
|
|
|
jt->set_class_to_be_initialized(NULL);
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Step 3
|
2019-01-15 16:40:31 -05:00
|
|
|
if (is_being_initialized() && is_reentrant_initialization(jt)) {
|
2017-03-21 11:25:18 -04:00
|
|
|
DTRACE_CLASSINIT_PROBE_WAIT(recursive, -1, wait);
|
2007-12-01 00:00:00 +00:00
|
|
|
return;
|
2010-03-17 11:01:05 +01:00
|
|
|
}
|
2007-12-01 00:00:00 +00:00
|
|
|
|
|
|
|
// Step 4
|
2017-03-21 11:25:18 -04:00
|
|
|
if (is_initialized()) {
|
|
|
|
DTRACE_CLASSINIT_PROBE_WAIT(concurrent, -1, wait);
|
2007-12-01 00:00:00 +00:00
|
|
|
return;
|
2010-03-17 11:01:05 +01:00
|
|
|
}
|
2007-12-01 00:00:00 +00:00
|
|
|
|
|
|
|
// Step 5
|
2017-03-21 11:25:18 -04:00
|
|
|
if (is_in_error_state()) {
|
|
|
|
DTRACE_CLASSINIT_PROBE_WAIT(erroneous, -1, wait);
|
2007-12-01 00:00:00 +00:00
|
|
|
ResourceMark rm(THREAD);
|
|
|
|
const char* desc = "Could not initialize class ";
|
2017-03-21 11:25:18 -04:00
|
|
|
const char* className = external_name();
|
2007-12-01 00:00:00 +00:00
|
|
|
size_t msglen = strlen(desc) + strlen(className) + 1;
|
2010-08-27 15:05:28 -04:00
|
|
|
char* message = NEW_RESOURCE_ARRAY(char, msglen);
|
2007-12-01 00:00:00 +00:00
|
|
|
if (NULL == message) {
|
|
|
|
// Out of memory: can't create detailed error message
|
2017-08-28 15:34:04 -07:00
|
|
|
THROW_MSG(vmSymbols::java_lang_NoClassDefFoundError(), className);
|
2007-12-01 00:00:00 +00:00
|
|
|
} else {
|
|
|
|
jio_snprintf(message, msglen, "%s%s", desc, className);
|
2017-08-28 15:34:04 -07:00
|
|
|
THROW_MSG(vmSymbols::java_lang_NoClassDefFoundError(), message);
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Step 6
|
2017-03-21 11:25:18 -04:00
|
|
|
set_init_state(being_initialized);
|
2019-01-15 16:40:31 -05:00
|
|
|
set_init_thread(jt);
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Step 7
|
2016-09-21 09:56:18 -04:00
|
|
|
// Next, if C is a class rather than an interface, initialize it's super class and super
|
|
|
|
// interfaces.
|
2017-03-21 11:25:18 -04:00
|
|
|
if (!is_interface()) {
|
|
|
|
Klass* super_klass = super();
|
2016-09-21 09:56:18 -04:00
|
|
|
if (super_klass != NULL && super_klass->should_be_initialized()) {
|
|
|
|
super_klass->initialize(THREAD);
|
|
|
|
}
|
2016-10-03 21:48:21 -04:00
|
|
|
// If C implements any interface that declares a non-static, concrete method,
|
2016-09-21 09:56:18 -04:00
|
|
|
// the initialization of C triggers initialization of its super interfaces.
|
2016-10-03 21:48:21 -04:00
|
|
|
// Only need to recurse if has_nonstatic_concrete_methods which includes declaring and
|
|
|
|
// having a superinterface that declares, non-static, concrete methods
|
2017-03-21 11:25:18 -04:00
|
|
|
if (!HAS_PENDING_EXCEPTION && has_nonstatic_concrete_methods()) {
|
|
|
|
initialize_super_interfaces(THREAD);
|
2016-09-21 09:56:18 -04:00
|
|
|
}
|
2007-12-01 00:00:00 +00:00
|
|
|
|
2016-09-21 09:56:18 -04:00
|
|
|
// If any exceptions, complete abruptly, throwing the same exception as above.
|
2007-12-01 00:00:00 +00:00
|
|
|
if (HAS_PENDING_EXCEPTION) {
|
|
|
|
Handle e(THREAD, PENDING_EXCEPTION);
|
|
|
|
CLEAR_PENDING_EXCEPTION;
|
|
|
|
{
|
|
|
|
EXCEPTION_MARK;
|
2016-09-21 09:56:18 -04:00
|
|
|
// Locks object, set state, and notify all waiting threads
|
2017-03-21 11:25:18 -04:00
|
|
|
set_initialization_state_and_notify(initialization_error, THREAD);
|
2016-09-21 09:56:18 -04:00
|
|
|
CLEAR_PENDING_EXCEPTION;
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
2017-03-21 11:25:18 -04:00
|
|
|
DTRACE_CLASSINIT_PROBE_WAIT(super__failed, -1, wait);
|
2007-12-01 00:00:00 +00:00
|
|
|
THROW_OOP(e());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-10-11 12:25:42 -04:00
|
|
|
|
2016-12-11 19:07:04 -08:00
|
|
|
// Look for aot compiled methods for this klass, including class initializer.
|
2017-03-21 11:25:18 -04:00
|
|
|
AOTLoader::load_for_klass(this, THREAD);
|
2016-12-11 19:07:04 -08:00
|
|
|
|
2007-12-01 00:00:00 +00:00
|
|
|
// Step 8
|
|
|
|
{
|
2017-03-21 11:25:18 -04:00
|
|
|
DTRACE_CLASSINIT_PROBE_WAIT(clinit, -1, wait);
|
2007-12-01 00:00:00 +00:00
|
|
|
// Timer includes any side effects of class initialization (resolution,
|
|
|
|
// etc), but not recursive entry into call_class_initializer().
|
2009-07-10 11:10:00 -07:00
|
|
|
PerfClassTraceTime timer(ClassLoader::perf_class_init_time(),
|
|
|
|
ClassLoader::perf_class_init_selftime(),
|
|
|
|
ClassLoader::perf_classes_inited(),
|
|
|
|
jt->get_thread_stat()->perf_recursion_counts_addr(),
|
|
|
|
jt->get_thread_stat()->perf_timers_addr(),
|
|
|
|
PerfClassTraceTime::CLASS_CLINIT);
|
2017-03-21 11:25:18 -04:00
|
|
|
call_class_initializer(THREAD);
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Step 9
|
|
|
|
if (!HAS_PENDING_EXCEPTION) {
|
2017-03-21 11:25:18 -04:00
|
|
|
set_initialization_state_and_notify(fully_initialized, CHECK);
|
2017-04-13 01:56:01 -07:00
|
|
|
{
|
|
|
|
debug_only(vtable().verify(tty, true);)
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
// Step 10 and 11
|
|
|
|
Handle e(THREAD, PENDING_EXCEPTION);
|
|
|
|
CLEAR_PENDING_EXCEPTION;
|
2014-02-24 10:28:22 +01:00
|
|
|
// JVMTI has already reported the pending exception
|
|
|
|
// JVMTI internal flag reset is needed in order to report ExceptionInInitializerError
|
2019-01-15 16:40:31 -05:00
|
|
|
JvmtiExport::clear_detected_exception(jt);
|
2007-12-01 00:00:00 +00:00
|
|
|
{
|
|
|
|
EXCEPTION_MARK;
|
2017-03-21 11:25:18 -04:00
|
|
|
set_initialization_state_and_notify(initialization_error, THREAD);
|
2007-12-01 00:00:00 +00:00
|
|
|
CLEAR_PENDING_EXCEPTION; // ignore any exception thrown, class initialization error is thrown below
|
2014-02-24 10:28:22 +01:00
|
|
|
// JVMTI has already reported the pending exception
|
|
|
|
// JVMTI internal flag reset is needed in order to report ExceptionInInitializerError
|
2019-01-15 16:40:31 -05:00
|
|
|
JvmtiExport::clear_detected_exception(jt);
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
2017-03-21 11:25:18 -04:00
|
|
|
DTRACE_CLASSINIT_PROBE_WAIT(error, -1, wait);
|
2010-01-06 14:22:39 -08:00
|
|
|
if (e->is_a(SystemDictionary::Error_klass())) {
|
2007-12-01 00:00:00 +00:00
|
|
|
THROW_OOP(e());
|
|
|
|
} else {
|
|
|
|
JavaCallArguments args(e);
|
2011-01-27 16:11:27 -08:00
|
|
|
THROW_ARG(vmSymbols::java_lang_ExceptionInInitializerError(),
|
|
|
|
vmSymbols::throwable_void_signature(),
|
2007-12-01 00:00:00 +00:00
|
|
|
&args);
|
|
|
|
}
|
|
|
|
}
|
2017-03-21 11:25:18 -04:00
|
|
|
DTRACE_CLASSINIT_PROBE_WAIT(end, -1, wait);
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
void InstanceKlass::set_initialization_state_and_notify(ClassState state, TRAPS) {
|
2017-03-21 11:25:18 -04:00
|
|
|
Handle h_init_lock(THREAD, init_lock());
|
2017-06-23 09:54:52 -04:00
|
|
|
if (h_init_lock() != NULL) {
|
2017-03-21 11:25:18 -04:00
|
|
|
ObjectLocker ol(h_init_lock, THREAD);
|
|
|
|
set_init_state(state);
|
|
|
|
fence_and_clear_init_lock();
|
2016-09-21 09:56:18 -04:00
|
|
|
ol.notify_all(CHECK);
|
|
|
|
} else {
|
2017-06-23 09:54:52 -04:00
|
|
|
assert(h_init_lock() != NULL, "The initialization state should never be set twice");
|
2017-03-21 11:25:18 -04:00
|
|
|
set_init_state(state);
|
2016-09-21 09:56:18 -04:00
|
|
|
}
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
|
|
|
|
2018-10-31 14:38:14 -04:00
|
|
|
Klass* InstanceKlass::implementor() const {
|
2018-11-30 15:29:19 +01:00
|
|
|
Klass* volatile* k = adr_implementor();
|
2018-08-11 12:49:33 -04:00
|
|
|
if (k == NULL) {
|
|
|
|
return NULL;
|
|
|
|
} else {
|
2018-11-30 15:29:19 +01:00
|
|
|
// This load races with inserts, and therefore needs acquire.
|
|
|
|
Klass* kls = OrderAccess::load_acquire(k);
|
|
|
|
if (kls != NULL && !kls->is_loader_alive()) {
|
|
|
|
return NULL; // don't return unloaded class
|
|
|
|
} else {
|
|
|
|
return kls;
|
|
|
|
}
|
2018-08-11 12:49:33 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-11-30 15:29:19 +01:00
|
|
|
|
2018-08-11 12:49:33 -04:00
|
|
|
void InstanceKlass::set_implementor(Klass* k) {
|
|
|
|
assert_lock_strong(Compile_lock);
|
|
|
|
assert(is_interface(), "not interface");
|
2018-11-30 15:29:19 +01:00
|
|
|
Klass* volatile* addr = adr_implementor();
|
2018-08-11 12:49:33 -04:00
|
|
|
assert(addr != NULL, "null addr");
|
|
|
|
if (addr != NULL) {
|
2018-11-30 15:29:19 +01:00
|
|
|
OrderAccess::release_store(addr, k);
|
2018-08-11 12:49:33 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
int InstanceKlass::nof_implementors() const {
|
|
|
|
Klass* k = implementor();
|
|
|
|
if (k == NULL) {
|
|
|
|
return 0;
|
|
|
|
} else if (k != this) {
|
|
|
|
return 1;
|
|
|
|
} else {
|
|
|
|
return 2;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-03-29 22:18:56 -04:00
|
|
|
// The embedded _implementor field can only record one implementor.
|
|
|
|
// When there are more than one implementors, the _implementor field
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
// is set to the interface Klass* itself. Following are the possible
|
2012-03-29 22:18:56 -04:00
|
|
|
// values for the _implementor field:
|
|
|
|
// NULL - no implementor
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
// implementor Klass* - one implementor
|
2012-03-29 22:18:56 -04:00
|
|
|
// self - more than one implementor
|
|
|
|
//
|
|
|
|
// The _implementor field only exists for interfaces.
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
void InstanceKlass::add_implementor(Klass* k) {
|
2018-08-11 12:49:33 -04:00
|
|
|
assert_lock_strong(Compile_lock);
|
2012-03-29 22:18:56 -04:00
|
|
|
assert(is_interface(), "not interface");
|
2007-12-01 00:00:00 +00:00
|
|
|
// Filter out my subinterfaces.
|
|
|
|
// (Note: Interfaces are never on the subklass list.)
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
if (InstanceKlass::cast(k)->is_interface()) return;
|
2007-12-01 00:00:00 +00:00
|
|
|
|
|
|
|
// Filter out subclasses whose supers already implement me.
|
|
|
|
// (Note: CHA must walk subclasses of direct implementors
|
|
|
|
// in order to locate indirect implementors.)
|
2015-10-26 13:11:36 -04:00
|
|
|
Klass* sk = k->super();
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
if (sk != NULL && InstanceKlass::cast(sk)->implements_interface(this))
|
2007-12-01 00:00:00 +00:00
|
|
|
// We only need to check one immediate superclass, since the
|
|
|
|
// implements_interface query looks at transitive_interfaces.
|
|
|
|
// Any supers of the super have the same (or fewer) transitive_interfaces.
|
|
|
|
return;
|
|
|
|
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
Klass* ik = implementor();
|
2012-03-29 22:18:56 -04:00
|
|
|
if (ik == NULL) {
|
|
|
|
set_implementor(k);
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
} else if (ik != this) {
|
2012-03-29 22:18:56 -04:00
|
|
|
// There is already an implementor. Use itself as an indicator of
|
|
|
|
// more than one implementors.
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
set_implementor(this);
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// The implementor also implements the transitive_interfaces
|
|
|
|
for (int index = 0; index < local_interfaces()->length(); index++) {
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
InstanceKlass::cast(local_interfaces()->at(index))->add_implementor(k);
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
void InstanceKlass::init_implementor() {
|
2012-03-29 22:18:56 -04:00
|
|
|
if (is_interface()) {
|
|
|
|
set_implementor(NULL);
|
|
|
|
}
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
void InstanceKlass::process_interfaces(Thread *thread) {
|
2007-12-01 00:00:00 +00:00
|
|
|
// link this class into the implementors list of every interface it implements
|
|
|
|
for (int i = local_interfaces()->length() - 1; i >= 0; i--) {
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
assert(local_interfaces()->at(i)->is_klass(), "must be a klass");
|
|
|
|
InstanceKlass* interf = InstanceKlass::cast(local_interfaces()->at(i));
|
2007-12-01 00:00:00 +00:00
|
|
|
assert(interf->is_interface(), "expected interface");
|
2014-03-26 21:47:45 -04:00
|
|
|
interf->add_implementor(this);
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
bool InstanceKlass::can_be_primary_super_slow() const {
|
2007-12-01 00:00:00 +00:00
|
|
|
if (is_interface())
|
|
|
|
return false;
|
|
|
|
else
|
|
|
|
return Klass::can_be_primary_super_slow();
|
|
|
|
}
|
|
|
|
|
2018-05-02 09:26:10 -07:00
|
|
|
GrowableArray<Klass*>* InstanceKlass::compute_secondary_supers(int num_extra_slots,
|
2018-08-07 15:45:07 -07:00
|
|
|
Array<InstanceKlass*>* transitive_interfaces) {
|
2007-12-01 00:00:00 +00:00
|
|
|
// The secondaries are the implemented interfaces.
|
2018-08-07 15:45:07 -07:00
|
|
|
Array<InstanceKlass*>* interfaces = transitive_interfaces;
|
2007-12-01 00:00:00 +00:00
|
|
|
int num_secondaries = num_extra_slots + interfaces->length();
|
|
|
|
if (num_secondaries == 0) {
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
// Must share this for correct bootstrapping!
|
|
|
|
set_secondary_supers(Universe::the_empty_klass_array());
|
|
|
|
return NULL;
|
2007-12-01 00:00:00 +00:00
|
|
|
} else if (num_extra_slots == 0) {
|
2018-08-07 15:45:07 -07:00
|
|
|
// The secondary super list is exactly the same as the transitive interfaces, so
|
|
|
|
// let's use it instead of making a copy.
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
// Redefine classes has to be careful not to delete this!
|
2018-08-07 15:45:07 -07:00
|
|
|
// We need the cast because Array<Klass*> is NOT a supertype of Array<InstanceKlass*>,
|
|
|
|
// (but it's safe to do here because we won't write into _secondary_supers from this point on).
|
|
|
|
set_secondary_supers((Array<Klass*>*)(address)interfaces);
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
return NULL;
|
2007-12-01 00:00:00 +00:00
|
|
|
} else {
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
// Copy transitive interfaces to a temporary growable array to be constructed
|
|
|
|
// into the secondary super list with extra slots.
|
|
|
|
GrowableArray<Klass*>* secondaries = new GrowableArray<Klass*>(interfaces->length());
|
2007-12-01 00:00:00 +00:00
|
|
|
for (int i = 0; i < interfaces->length(); i++) {
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
secondaries->push(interfaces->at(i));
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
|
|
|
return secondaries;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
bool InstanceKlass::implements_interface(Klass* k) const {
|
|
|
|
if (this == k) return true;
|
2012-11-12 16:15:05 -05:00
|
|
|
assert(k->is_interface(), "should be an interface class");
|
2007-12-01 00:00:00 +00:00
|
|
|
for (int i = 0; i < transitive_interfaces()->length(); i++) {
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
if (transitive_interfaces()->at(i) == k) {
|
2007-12-01 00:00:00 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2013-11-26 09:52:22 -05:00
|
|
|
bool InstanceKlass::is_same_or_direct_interface(Klass *k) const {
|
|
|
|
// Verify direct super interface
|
|
|
|
if (this == k) return true;
|
|
|
|
assert(k->is_interface(), "should be an interface class");
|
|
|
|
for (int i = 0; i < local_interfaces()->length(); i++) {
|
|
|
|
if (local_interfaces()->at(i) == k) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
objArrayOop InstanceKlass::allocate_objArray(int n, int length, TRAPS) {
|
2018-10-05 20:03:14 +02:00
|
|
|
check_array_allocation_length(length, arrayOopDesc::max_array_length(T_OBJECT), CHECK_NULL);
|
2007-12-01 00:00:00 +00:00
|
|
|
int size = objArrayOopDesc::object_size(length);
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
Klass* ak = array_klass(n, CHECK_NULL);
|
2018-06-28 14:22:28 +02:00
|
|
|
objArrayOop o = (objArrayOop)Universe::heap()->array_allocate(ak, size, length,
|
|
|
|
/* do_zero */ true, CHECK_NULL);
|
2007-12-01 00:00:00 +00:00
|
|
|
return o;
|
|
|
|
}
|
|
|
|
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
instanceOop InstanceKlass::register_finalizer(instanceOop i, TRAPS) {
|
2007-12-01 00:00:00 +00:00
|
|
|
if (TraceFinalizerRegistration) {
|
|
|
|
tty->print("Registered ");
|
|
|
|
i->print_value_on(tty);
|
2015-10-09 09:42:33 +02:00
|
|
|
tty->print_cr(" (" INTPTR_FORMAT ") as finalizable", p2i(i));
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
|
|
|
instanceHandle h_i(THREAD, i);
|
|
|
|
// Pass the handle as argument, JavaCalls::call expects oop as jobjects
|
|
|
|
JavaValue result(T_VOID);
|
|
|
|
JavaCallArguments args(h_i);
|
|
|
|
methodHandle mh (THREAD, Universe::finalizer_register_method());
|
|
|
|
JavaCalls::call(&result, mh, &args, CHECK_NULL);
|
|
|
|
return h_i();
|
|
|
|
}
|
|
|
|
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
instanceOop InstanceKlass::allocate_instance(TRAPS) {
|
2007-12-01 00:00:00 +00:00
|
|
|
bool has_finalizer_flag = has_finalizer(); // Query before possible GC
|
|
|
|
int size = size_helper(); // Query before forming handle.
|
|
|
|
|
|
|
|
instanceOop i;
|
|
|
|
|
2018-06-28 14:22:28 +02:00
|
|
|
i = (instanceOop)Universe::heap()->obj_allocate(this, size, CHECK_NULL);
|
2007-12-01 00:00:00 +00:00
|
|
|
if (has_finalizer_flag && !RegisterFinalizersAtInit) {
|
|
|
|
i = register_finalizer(i, CHECK_NULL);
|
|
|
|
}
|
|
|
|
return i;
|
|
|
|
}
|
|
|
|
|
2018-03-14 12:12:00 +01:00
|
|
|
instanceHandle InstanceKlass::allocate_instance_handle(TRAPS) {
|
|
|
|
return instanceHandle(THREAD, allocate_instance(THREAD));
|
|
|
|
}
|
|
|
|
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
void InstanceKlass::check_valid_for_instantiation(bool throwError, TRAPS) {
|
2007-12-01 00:00:00 +00:00
|
|
|
if (is_interface() || is_abstract()) {
|
|
|
|
ResourceMark rm(THREAD);
|
|
|
|
THROW_MSG(throwError ? vmSymbols::java_lang_InstantiationError()
|
|
|
|
: vmSymbols::java_lang_InstantiationException(), external_name());
|
|
|
|
}
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
if (this == SystemDictionary::Class_klass()) {
|
2007-12-01 00:00:00 +00:00
|
|
|
ResourceMark rm(THREAD);
|
|
|
|
THROW_MSG(throwError ? vmSymbols::java_lang_IllegalAccessError()
|
|
|
|
: vmSymbols::java_lang_IllegalAccessException(), external_name());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
Klass* InstanceKlass::array_klass_impl(bool or_null, int n, TRAPS) {
|
2016-08-29 20:13:45 -04:00
|
|
|
// Need load-acquire for lock-free read
|
2017-03-21 11:25:18 -04:00
|
|
|
if (array_klasses_acquire() == NULL) {
|
2007-12-01 00:00:00 +00:00
|
|
|
if (or_null) return NULL;
|
|
|
|
|
|
|
|
ResourceMark rm;
|
|
|
|
JavaThread *jt = (JavaThread *)THREAD;
|
|
|
|
{
|
|
|
|
// Atomic creation of array_klasses
|
|
|
|
MutexLocker ma(MultiArray_lock, THREAD);
|
|
|
|
|
|
|
|
// Check if update has already taken place
|
2017-03-21 11:25:18 -04:00
|
|
|
if (array_klasses() == NULL) {
|
|
|
|
Klass* k = ObjArrayKlass::allocate_objArray_klass(class_loader_data(), 1, this, CHECK_NULL);
|
2016-08-29 20:13:45 -04:00
|
|
|
// use 'release' to pair with lock-free load
|
2017-03-21 11:25:18 -04:00
|
|
|
release_set_array_klasses(k);
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// _this will always be set at this point
|
2017-03-21 11:25:18 -04:00
|
|
|
ObjArrayKlass* oak = (ObjArrayKlass*)array_klasses();
|
2007-12-01 00:00:00 +00:00
|
|
|
if (or_null) {
|
|
|
|
return oak->array_klass_or_null(n);
|
|
|
|
}
|
2014-11-14 09:47:09 +01:00
|
|
|
return oak->array_klass(n, THREAD);
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
|
|
|
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
Klass* InstanceKlass::array_klass_impl(bool or_null, TRAPS) {
|
2007-12-01 00:00:00 +00:00
|
|
|
return array_klass_impl(or_null, 1, THREAD);
|
|
|
|
}
|
|
|
|
|
2017-03-21 11:25:18 -04:00
|
|
|
static int call_class_initializer_counter = 0; // for debugging
|
2007-12-01 00:00:00 +00:00
|
|
|
|
2017-03-15 10:25:37 -04:00
|
|
|
Method* InstanceKlass::class_initializer() const {
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
Method* clinit = find_method(
|
2011-03-04 14:40:46 -05:00
|
|
|
vmSymbols::class_initializer_name(), vmSymbols::void_method_signature());
|
|
|
|
if (clinit != NULL && clinit->has_valid_initializer_flags()) {
|
|
|
|
return clinit;
|
|
|
|
}
|
|
|
|
return NULL;
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
|
|
|
|
2017-03-21 11:25:18 -04:00
|
|
|
void InstanceKlass::call_class_initializer(TRAPS) {
|
2012-11-12 14:03:53 -08:00
|
|
|
if (ReplayCompiles &&
|
|
|
|
(ReplaySuppressInitializers == 1 ||
|
2017-07-06 01:50:26 +02:00
|
|
|
(ReplaySuppressInitializers >= 2 && class_loader() != NULL))) {
|
2012-11-12 14:03:53 -08:00
|
|
|
// Hide the existence of the initializer for the purpose of replaying the compile
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2017-03-21 11:25:18 -04:00
|
|
|
methodHandle h_method(THREAD, class_initializer());
|
|
|
|
assert(!is_initialized(), "we cannot initialize twice");
|
2017-07-21 09:50:12 +02:00
|
|
|
LogTarget(Info, class, init) lt;
|
|
|
|
if (lt.is_enabled()) {
|
2015-12-02 14:07:58 -05:00
|
|
|
ResourceMark rm;
|
2017-07-21 09:50:12 +02:00
|
|
|
LogStream ls(lt);
|
|
|
|
ls.print("%d Initializing ", call_class_initializer_counter++);
|
|
|
|
name()->print_value_on(&ls);
|
|
|
|
ls.print_cr("%s (" INTPTR_FORMAT ")", h_method() == NULL ? "(no method)" : "", p2i(this));
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
|
|
|
if (h_method() != NULL) {
|
|
|
|
JavaCallArguments args; // No arguments
|
|
|
|
JavaValue result(T_VOID);
|
|
|
|
JavaCalls::call(&result, h_method, &args, CHECK); // Static call (no args)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-10-23 16:48:38 -04:00
|
|
|
void InstanceKlass::mask_for(const methodHandle& method, int bci,
|
2007-12-01 00:00:00 +00:00
|
|
|
InterpreterOopMap* entry_for) {
|
2016-06-02 23:37:09 -04:00
|
|
|
// Lazily create the _oop_map_cache at first request
|
2017-10-16 22:36:06 -04:00
|
|
|
// Lock-free access requires load_acquire.
|
|
|
|
OopMapCache* oop_map_cache = OrderAccess::load_acquire(&_oop_map_cache);
|
2016-06-02 23:37:09 -04:00
|
|
|
if (oop_map_cache == NULL) {
|
2007-12-01 00:00:00 +00:00
|
|
|
MutexLocker x(OopMapCacheAlloc_lock);
|
2016-06-02 23:37:09 -04:00
|
|
|
// Check if _oop_map_cache was allocated while we were waiting for this lock
|
|
|
|
if ((oop_map_cache = _oop_map_cache) == NULL) {
|
|
|
|
oop_map_cache = new OopMapCache();
|
|
|
|
// Ensure _oop_map_cache is stable, since it is examined without a lock
|
2017-10-16 22:36:06 -04:00
|
|
|
OrderAccess::release_store(&_oop_map_cache, oop_map_cache);
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
|
|
|
}
|
2016-06-02 23:37:09 -04:00
|
|
|
// _oop_map_cache is constant after init; lookup below does its own locking.
|
|
|
|
oop_map_cache->lookup(method, bci, entry_for);
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
bool InstanceKlass::find_local_field(Symbol* name, Symbol* sig, fieldDescriptor* fd) const {
|
|
|
|
for (JavaFieldStream fs(this); !fs.done(); fs.next()) {
|
2011-09-10 17:29:02 -07:00
|
|
|
Symbol* f_name = fs.name();
|
|
|
|
Symbol* f_sig = fs.signature();
|
2007-12-01 00:00:00 +00:00
|
|
|
if (f_name == name && f_sig == sig) {
|
2013-09-13 22:38:02 -04:00
|
|
|
fd->reinitialize(const_cast<InstanceKlass*>(this), fs.index());
|
2007-12-01 00:00:00 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
Klass* InstanceKlass::find_interface_field(Symbol* name, Symbol* sig, fieldDescriptor* fd) const {
|
2007-12-01 00:00:00 +00:00
|
|
|
const int n = local_interfaces()->length();
|
|
|
|
for (int i = 0; i < n; i++) {
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
Klass* intf1 = local_interfaces()->at(i);
|
2012-11-12 16:15:05 -05:00
|
|
|
assert(intf1->is_interface(), "just checking type");
|
2007-12-01 00:00:00 +00:00
|
|
|
// search for field in current interface
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
if (InstanceKlass::cast(intf1)->find_local_field(name, sig, fd)) {
|
2007-12-01 00:00:00 +00:00
|
|
|
assert(fd->is_static(), "interface field must be static");
|
|
|
|
return intf1;
|
|
|
|
}
|
|
|
|
// search for field in direct superinterfaces
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
Klass* intf2 = InstanceKlass::cast(intf1)->find_interface_field(name, sig, fd);
|
2007-12-01 00:00:00 +00:00
|
|
|
if (intf2 != NULL) return intf2;
|
|
|
|
}
|
|
|
|
// otherwise field lookup fails
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
Klass* InstanceKlass::find_field(Symbol* name, Symbol* sig, fieldDescriptor* fd) const {
|
2007-12-01 00:00:00 +00:00
|
|
|
// search order according to newest JVM spec (5.4.3.2, p.167).
|
|
|
|
// 1) search for field in current klass
|
|
|
|
if (find_local_field(name, sig, fd)) {
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
return const_cast<InstanceKlass*>(this);
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
|
|
|
// 2) search for field recursively in direct superinterfaces
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
{ Klass* intf = find_interface_field(name, sig, fd);
|
2007-12-01 00:00:00 +00:00
|
|
|
if (intf != NULL) return intf;
|
|
|
|
}
|
|
|
|
// 3) apply field lookup recursively if superclass exists
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
{ Klass* supr = super();
|
|
|
|
if (supr != NULL) return InstanceKlass::cast(supr)->find_field(name, sig, fd);
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
|
|
|
// 4) otherwise field lookup fails
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
Klass* InstanceKlass::find_field(Symbol* name, Symbol* sig, bool is_static, fieldDescriptor* fd) const {
|
2007-12-01 00:00:00 +00:00
|
|
|
// search order according to newest JVM spec (5.4.3.2, p.167).
|
|
|
|
// 1) search for field in current klass
|
|
|
|
if (find_local_field(name, sig, fd)) {
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
if (fd->is_static() == is_static) return const_cast<InstanceKlass*>(this);
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
|
|
|
// 2) search for field recursively in direct superinterfaces
|
|
|
|
if (is_static) {
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
Klass* intf = find_interface_field(name, sig, fd);
|
2007-12-01 00:00:00 +00:00
|
|
|
if (intf != NULL) return intf;
|
|
|
|
}
|
|
|
|
// 3) apply field lookup recursively if superclass exists
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
{ Klass* supr = super();
|
|
|
|
if (supr != NULL) return InstanceKlass::cast(supr)->find_field(name, sig, is_static, fd);
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
|
|
|
// 4) otherwise field lookup fails
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
bool InstanceKlass::find_local_field_from_offset(int offset, bool is_static, fieldDescriptor* fd) const {
|
|
|
|
for (JavaFieldStream fs(this); !fs.done(); fs.next()) {
|
2011-09-10 17:29:02 -07:00
|
|
|
if (fs.offset() == offset) {
|
2013-09-13 22:38:02 -04:00
|
|
|
fd->reinitialize(const_cast<InstanceKlass*>(this), fs.index());
|
2007-12-01 00:00:00 +00:00
|
|
|
if (fd->is_static() == is_static) return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
bool InstanceKlass::find_field_from_offset(int offset, bool is_static, fieldDescriptor* fd) const {
|
|
|
|
Klass* klass = const_cast<InstanceKlass*>(this);
|
2007-12-01 00:00:00 +00:00
|
|
|
while (klass != NULL) {
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
if (InstanceKlass::cast(klass)->find_local_field_from_offset(offset, is_static, fd)) {
|
2007-12-01 00:00:00 +00:00
|
|
|
return true;
|
|
|
|
}
|
2012-11-12 16:15:05 -05:00
|
|
|
klass = klass->super();
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
void InstanceKlass::methods_do(void f(Method* method)) {
|
2014-05-21 14:36:18 -04:00
|
|
|
// Methods aren't stable until they are loaded. This can be read outside
|
|
|
|
// a lock through the ClassLoaderData for profiling
|
|
|
|
if (!is_loaded()) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2007-12-01 00:00:00 +00:00
|
|
|
int len = methods()->length();
|
|
|
|
for (int index = 0; index < len; index++) {
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
Method* m = methods()->at(index);
|
2007-12-01 00:00:00 +00:00
|
|
|
assert(m->is_method(), "must be method");
|
|
|
|
f(m);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-03-18 16:00:34 -07:00
|
|
|
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
void InstanceKlass::do_local_static_fields(FieldClosure* cl) {
|
2011-09-10 17:29:02 -07:00
|
|
|
for (JavaFieldStream fs(this); !fs.done(); fs.next()) {
|
|
|
|
if (fs.access_flags().is_static()) {
|
2013-09-13 22:38:02 -04:00
|
|
|
fieldDescriptor& fd = fs.field_descriptor();
|
2011-09-10 17:29:02 -07:00
|
|
|
cl->do_field(&fd);
|
|
|
|
}
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-04-08 13:58:38 -04:00
|
|
|
void InstanceKlass::do_local_static_fields(void f(fieldDescriptor*, Handle, TRAPS), Handle mirror, TRAPS) {
|
2017-03-21 11:25:18 -04:00
|
|
|
for (JavaFieldStream fs(this); !fs.done(); fs.next()) {
|
2011-09-10 17:29:02 -07:00
|
|
|
if (fs.access_flags().is_static()) {
|
2013-09-13 22:38:02 -04:00
|
|
|
fieldDescriptor& fd = fs.field_descriptor();
|
2014-04-08 13:58:38 -04:00
|
|
|
f(&fd, mirror, CHECK);
|
2011-09-10 17:29:02 -07:00
|
|
|
}
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-03-11 11:25:13 -07:00
|
|
|
static int compare_fields_by_offset(int* a, int* b) {
|
|
|
|
return a[0] - b[0];
|
|
|
|
}
|
|
|
|
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
void InstanceKlass::do_nonstatic_fields(FieldClosure* cl) {
|
|
|
|
InstanceKlass* super = superklass();
|
2007-12-01 00:00:00 +00:00
|
|
|
if (super != NULL) {
|
|
|
|
super->do_nonstatic_fields(cl);
|
|
|
|
}
|
2008-03-11 11:25:13 -07:00
|
|
|
fieldDescriptor fd;
|
2011-09-10 17:29:02 -07:00
|
|
|
int length = java_fields_count();
|
2008-03-11 11:25:13 -07:00
|
|
|
// In DebugInfo nonstatic fields are sorted by offset.
|
2012-06-28 17:03:16 -04:00
|
|
|
int* fields_sorted = NEW_C_HEAP_ARRAY(int, 2*(length+1), mtClass);
|
2008-03-11 11:25:13 -07:00
|
|
|
int j = 0;
|
2011-09-10 17:29:02 -07:00
|
|
|
for (int i = 0; i < length; i += 1) {
|
2013-09-13 22:38:02 -04:00
|
|
|
fd.reinitialize(this, i);
|
2008-03-11 11:25:13 -07:00
|
|
|
if (!fd.is_static()) {
|
|
|
|
fields_sorted[j + 0] = fd.offset();
|
|
|
|
fields_sorted[j + 1] = i;
|
|
|
|
j += 2;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (j > 0) {
|
|
|
|
length = j;
|
|
|
|
// _sort_Fn is defined in growableArray.hpp.
|
|
|
|
qsort(fields_sorted, length/2, 2*sizeof(int), (_sort_Fn)compare_fields_by_offset);
|
|
|
|
for (int i = 0; i < length; i += 2) {
|
2013-09-13 22:38:02 -04:00
|
|
|
fd.reinitialize(this, fields_sorted[i + 1]);
|
2008-03-11 11:25:13 -07:00
|
|
|
assert(!fd.is_static() && fd.offset() == fields_sorted[i], "only nonstatic fields");
|
|
|
|
cl->do_field(&fd);
|
|
|
|
}
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
2014-12-01 12:16:15 -05:00
|
|
|
FREE_C_HEAP_ARRAY(int, fields_sorted);
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
void InstanceKlass::array_klasses_do(void f(Klass* k, TRAPS), TRAPS) {
|
|
|
|
if (array_klasses() != NULL)
|
2012-09-29 06:40:00 -04:00
|
|
|
ArrayKlass::cast(array_klasses())->array_klasses_do(f, THREAD);
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void InstanceKlass::array_klasses_do(void f(Klass* k)) {
|
2007-12-01 00:00:00 +00:00
|
|
|
if (array_klasses() != NULL)
|
2012-09-29 06:40:00 -04:00
|
|
|
ArrayKlass::cast(array_klasses())->array_klasses_do(f);
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef ASSERT
|
2015-12-08 20:04:03 +01:00
|
|
|
static int linear_search(const Array<Method*>* methods,
|
|
|
|
const Symbol* name,
|
|
|
|
const Symbol* signature) {
|
|
|
|
const int len = methods->length();
|
2007-12-01 00:00:00 +00:00
|
|
|
for (int index = 0; index < len; index++) {
|
2015-12-08 20:04:03 +01:00
|
|
|
const Method* const m = methods->at(index);
|
2007-12-01 00:00:00 +00:00
|
|
|
assert(m->is_method(), "must be method");
|
|
|
|
if (m->signature() == signature && m->name() == name) {
|
|
|
|
return index;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2015-12-08 20:04:03 +01:00
|
|
|
static int binary_search(const Array<Method*>* methods, const Symbol* name) {
|
2007-12-01 00:00:00 +00:00
|
|
|
int len = methods->length();
|
|
|
|
// methods are sorted, so do binary search
|
|
|
|
int l = 0;
|
|
|
|
int h = len - 1;
|
|
|
|
while (l <= h) {
|
|
|
|
int mid = (l + h) >> 1;
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
Method* m = methods->at(mid);
|
2007-12-01 00:00:00 +00:00
|
|
|
assert(m->is_method(), "must be method");
|
|
|
|
int res = m->name()->fast_compare(name);
|
|
|
|
if (res == 0) {
|
2012-10-11 12:25:42 -04:00
|
|
|
return mid;
|
|
|
|
} else if (res < 0) {
|
|
|
|
l = mid + 1;
|
|
|
|
} else {
|
|
|
|
h = mid - 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2013-10-07 12:20:28 -04:00
|
|
|
// find_method looks up the name/signature in the local methods array
|
2015-12-08 20:04:03 +01:00
|
|
|
Method* InstanceKlass::find_method(const Symbol* name,
|
|
|
|
const Symbol* signature) const {
|
2015-08-06 13:02:15 -04:00
|
|
|
return find_method_impl(name, signature, find_overpass, find_static, find_private);
|
2014-04-14 14:27:45 -04:00
|
|
|
}
|
|
|
|
|
2015-12-08 20:04:03 +01:00
|
|
|
Method* InstanceKlass::find_method_impl(const Symbol* name,
|
|
|
|
const Symbol* signature,
|
2015-08-06 13:02:15 -04:00
|
|
|
OverpassLookupMode overpass_mode,
|
|
|
|
StaticLookupMode static_mode,
|
|
|
|
PrivateLookupMode private_mode) const {
|
2015-12-08 20:04:03 +01:00
|
|
|
return InstanceKlass::find_method_impl(methods(),
|
|
|
|
name,
|
|
|
|
signature,
|
|
|
|
overpass_mode,
|
|
|
|
static_mode,
|
|
|
|
private_mode);
|
2012-10-11 12:25:42 -04:00
|
|
|
}
|
|
|
|
|
2013-12-03 11:13:14 -08:00
|
|
|
// find_instance_method looks up the name/signature in the local methods array
|
|
|
|
// and skips over static methods
|
2015-12-08 20:04:03 +01:00
|
|
|
Method* InstanceKlass::find_instance_method(const Array<Method*>* methods,
|
|
|
|
const Symbol* name,
|
2018-06-23 01:32:41 -04:00
|
|
|
const Symbol* signature,
|
|
|
|
PrivateLookupMode private_mode) {
|
2015-12-08 20:04:03 +01:00
|
|
|
Method* const meth = InstanceKlass::find_method_impl(methods,
|
|
|
|
name,
|
|
|
|
signature,
|
|
|
|
find_overpass,
|
|
|
|
skip_static,
|
2018-06-23 01:32:41 -04:00
|
|
|
private_mode);
|
2015-12-08 20:04:03 +01:00
|
|
|
assert(((meth == NULL) || !meth->is_static()),
|
|
|
|
"find_instance_method should have skipped statics");
|
2013-12-03 11:13:14 -08:00
|
|
|
return meth;
|
|
|
|
}
|
|
|
|
|
2014-12-01 13:06:20 -05:00
|
|
|
// find_instance_method looks up the name/signature in the local methods array
|
|
|
|
// and skips over static methods
|
2018-06-23 01:32:41 -04:00
|
|
|
Method* InstanceKlass::find_instance_method(const Symbol* name,
|
|
|
|
const Symbol* signature,
|
|
|
|
PrivateLookupMode private_mode) const {
|
|
|
|
return InstanceKlass::find_instance_method(methods(), name, signature, private_mode);
|
2014-12-01 13:06:20 -05:00
|
|
|
}
|
|
|
|
|
2015-08-06 13:02:15 -04:00
|
|
|
// Find looks up the name/signature in the local methods array
|
|
|
|
// and filters on the overpass, static and private flags
|
|
|
|
// This returns the first one found
|
|
|
|
// note that the local methods array can have up to one overpass, one static
|
|
|
|
// and one instance (private or not) with the same name/signature
|
2015-12-08 20:04:03 +01:00
|
|
|
Method* InstanceKlass::find_local_method(const Symbol* name,
|
|
|
|
const Symbol* signature,
|
|
|
|
OverpassLookupMode overpass_mode,
|
|
|
|
StaticLookupMode static_mode,
|
|
|
|
PrivateLookupMode private_mode) const {
|
|
|
|
return InstanceKlass::find_method_impl(methods(),
|
|
|
|
name,
|
|
|
|
signature,
|
|
|
|
overpass_mode,
|
|
|
|
static_mode,
|
|
|
|
private_mode);
|
2015-08-06 13:02:15 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
// Find looks up the name/signature in the local methods array
|
|
|
|
// and filters on the overpass, static and private flags
|
|
|
|
// This returns the first one found
|
|
|
|
// note that the local methods array can have up to one overpass, one static
|
|
|
|
// and one instance (private or not) with the same name/signature
|
2015-12-08 20:04:03 +01:00
|
|
|
Method* InstanceKlass::find_local_method(const Array<Method*>* methods,
|
|
|
|
const Symbol* name,
|
|
|
|
const Symbol* signature,
|
|
|
|
OverpassLookupMode overpass_mode,
|
|
|
|
StaticLookupMode static_mode,
|
|
|
|
PrivateLookupMode private_mode) {
|
|
|
|
return InstanceKlass::find_method_impl(methods,
|
|
|
|
name,
|
|
|
|
signature,
|
|
|
|
overpass_mode,
|
|
|
|
static_mode,
|
|
|
|
private_mode);
|
|
|
|
}
|
|
|
|
|
|
|
|
Method* InstanceKlass::find_method(const Array<Method*>* methods,
|
|
|
|
const Symbol* name,
|
|
|
|
const Symbol* signature) {
|
|
|
|
return InstanceKlass::find_method_impl(methods,
|
|
|
|
name,
|
|
|
|
signature,
|
|
|
|
find_overpass,
|
|
|
|
find_static,
|
|
|
|
find_private);
|
|
|
|
}
|
|
|
|
|
|
|
|
Method* InstanceKlass::find_method_impl(const Array<Method*>* methods,
|
|
|
|
const Symbol* name,
|
|
|
|
const Symbol* signature,
|
2015-08-06 13:02:15 -04:00
|
|
|
OverpassLookupMode overpass_mode,
|
|
|
|
StaticLookupMode static_mode,
|
|
|
|
PrivateLookupMode private_mode) {
|
|
|
|
int hit = find_method_index(methods, name, signature, overpass_mode, static_mode, private_mode);
|
2013-10-07 12:20:28 -04:00
|
|
|
return hit >= 0 ? methods->at(hit): NULL;
|
|
|
|
}
|
|
|
|
|
2015-12-08 20:04:03 +01:00
|
|
|
// true if method matches signature and conforms to skipping_X conditions.
|
|
|
|
static bool method_matches(const Method* m,
|
|
|
|
const Symbol* signature,
|
|
|
|
bool skipping_overpass,
|
|
|
|
bool skipping_static,
|
|
|
|
bool skipping_private) {
|
|
|
|
return ((m->signature() == signature) &&
|
|
|
|
(!skipping_overpass || !m->is_overpass()) &&
|
|
|
|
(!skipping_static || !m->is_static()) &&
|
|
|
|
(!skipping_private || !m->is_private()));
|
2014-12-01 13:06:20 -05:00
|
|
|
}
|
|
|
|
|
2013-10-07 12:20:28 -04:00
|
|
|
// Used directly for default_methods to find the index into the
|
|
|
|
// default_vtable_indices, and indirectly by find_method
|
|
|
|
// find_method_index looks in the local methods array to return the index
|
2014-04-14 14:27:45 -04:00
|
|
|
// of the matching name/signature. If, overpass methods are being ignored,
|
|
|
|
// the search continues to find a potential non-overpass match. This capability
|
|
|
|
// is important during method resolution to prefer a static method, for example,
|
|
|
|
// over an overpass method.
|
2015-08-06 13:02:15 -04:00
|
|
|
// There is the possibility in any _method's array to have the same name/signature
|
|
|
|
// for a static method, an overpass method and a local instance method
|
|
|
|
// To correctly catch a given method, the search criteria may need
|
|
|
|
// to explicitly skip the other two. For local instance methods, it
|
|
|
|
// is often necessary to skip private methods
|
2015-12-08 20:04:03 +01:00
|
|
|
int InstanceKlass::find_method_index(const Array<Method*>* methods,
|
|
|
|
const Symbol* name,
|
|
|
|
const Symbol* signature,
|
|
|
|
OverpassLookupMode overpass_mode,
|
|
|
|
StaticLookupMode static_mode,
|
|
|
|
PrivateLookupMode private_mode) {
|
|
|
|
const bool skipping_overpass = (overpass_mode == skip_overpass);
|
|
|
|
const bool skipping_static = (static_mode == skip_static);
|
|
|
|
const bool skipping_private = (private_mode == skip_private);
|
|
|
|
const int hit = binary_search(methods, name);
|
2012-10-11 12:25:42 -04:00
|
|
|
if (hit != -1) {
|
2015-12-08 20:04:03 +01:00
|
|
|
const Method* const m = methods->at(hit);
|
2014-12-01 13:06:20 -05:00
|
|
|
|
2012-10-11 12:25:42 -04:00
|
|
|
// Do linear search to find matching signature. First, quick check
|
2014-04-14 14:27:45 -04:00
|
|
|
// for common case, ignoring overpasses if requested.
|
2015-12-08 20:04:03 +01:00
|
|
|
if (method_matches(m, signature, skipping_overpass, skipping_static, skipping_private)) {
|
2018-06-23 01:32:41 -04:00
|
|
|
return hit;
|
2015-12-08 20:04:03 +01:00
|
|
|
}
|
2014-04-14 14:27:45 -04:00
|
|
|
|
2012-10-11 12:25:42 -04:00
|
|
|
// search downwards through overloaded methods
|
|
|
|
int i;
|
|
|
|
for (i = hit - 1; i >= 0; --i) {
|
2015-12-08 20:04:03 +01:00
|
|
|
const Method* const m = methods->at(i);
|
2007-12-01 00:00:00 +00:00
|
|
|
assert(m->is_method(), "must be method");
|
2015-12-08 20:04:03 +01:00
|
|
|
if (m->name() != name) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (method_matches(m, signature, skipping_overpass, skipping_static, skipping_private)) {
|
|
|
|
return i;
|
|
|
|
}
|
2012-10-11 12:25:42 -04:00
|
|
|
}
|
|
|
|
// search upwards
|
|
|
|
for (i = hit + 1; i < methods->length(); ++i) {
|
2015-12-08 20:04:03 +01:00
|
|
|
const Method* const m = methods->at(i);
|
2007-12-01 00:00:00 +00:00
|
|
|
assert(m->is_method(), "must be method");
|
2015-12-08 20:04:03 +01:00
|
|
|
if (m->name() != name) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (method_matches(m, signature, skipping_overpass, skipping_static, skipping_private)) {
|
|
|
|
return i;
|
|
|
|
}
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
2012-10-11 12:25:42 -04:00
|
|
|
// not found
|
2007-12-01 00:00:00 +00:00
|
|
|
#ifdef ASSERT
|
2015-12-08 20:04:03 +01:00
|
|
|
const int index = (skipping_overpass || skipping_static || skipping_private) ? -1 :
|
|
|
|
linear_search(methods, name, signature);
|
|
|
|
assert(-1 == index, "binary search should have found entry %d", index);
|
2007-12-01 00:00:00 +00:00
|
|
|
#endif
|
2012-10-11 12:25:42 -04:00
|
|
|
}
|
2013-10-07 12:20:28 -04:00
|
|
|
return -1;
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
2015-12-08 20:04:03 +01:00
|
|
|
|
|
|
|
int InstanceKlass::find_method_by_name(const Symbol* name, int* end) const {
|
2012-10-11 12:25:42 -04:00
|
|
|
return find_method_by_name(methods(), name, end);
|
|
|
|
}
|
|
|
|
|
2015-12-08 20:04:03 +01:00
|
|
|
int InstanceKlass::find_method_by_name(const Array<Method*>* methods,
|
|
|
|
const Symbol* name,
|
|
|
|
int* end_ptr) {
|
2012-10-11 12:25:42 -04:00
|
|
|
assert(end_ptr != NULL, "just checking");
|
|
|
|
int start = binary_search(methods, name);
|
|
|
|
int end = start + 1;
|
|
|
|
if (start != -1) {
|
|
|
|
while (start - 1 >= 0 && (methods->at(start - 1))->name() == name) --start;
|
|
|
|
while (end < methods->length() && (methods->at(end))->name() == name) ++end;
|
|
|
|
*end_ptr = end;
|
|
|
|
return start;
|
|
|
|
}
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2013-12-16 08:24:33 -05:00
|
|
|
// uncached_lookup_method searches both the local class methods array and all
|
2018-06-23 01:32:41 -04:00
|
|
|
// superclasses methods arrays, skipping any overpass methods in superclasses,
|
|
|
|
// and possibly skipping private methods.
|
2015-12-08 20:04:03 +01:00
|
|
|
Method* InstanceKlass::uncached_lookup_method(const Symbol* name,
|
|
|
|
const Symbol* signature,
|
2018-06-23 01:32:41 -04:00
|
|
|
OverpassLookupMode overpass_mode,
|
|
|
|
PrivateLookupMode private_mode) const {
|
2015-01-23 09:54:33 -05:00
|
|
|
OverpassLookupMode overpass_local_mode = overpass_mode;
|
2015-12-08 20:04:03 +01:00
|
|
|
const Klass* klass = this;
|
2007-12-01 00:00:00 +00:00
|
|
|
while (klass != NULL) {
|
2015-12-08 20:04:03 +01:00
|
|
|
Method* const method = InstanceKlass::cast(klass)->find_method_impl(name,
|
|
|
|
signature,
|
|
|
|
overpass_local_mode,
|
|
|
|
find_static,
|
2018-06-23 01:32:41 -04:00
|
|
|
private_mode);
|
2014-04-14 14:27:45 -04:00
|
|
|
if (method != NULL) {
|
2013-12-16 08:24:33 -05:00
|
|
|
return method;
|
|
|
|
}
|
2015-10-26 13:11:36 -04:00
|
|
|
klass = klass->super();
|
2015-01-23 09:54:33 -05:00
|
|
|
overpass_local_mode = skip_overpass; // Always ignore overpass methods in superclasses
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2014-05-28 07:36:32 -07:00
|
|
|
#ifdef ASSERT
|
|
|
|
// search through class hierarchy and return true if this class or
|
|
|
|
// one of the superclasses was redefined
|
2015-12-08 20:04:03 +01:00
|
|
|
bool InstanceKlass::has_redefined_this_or_super() const {
|
|
|
|
const Klass* klass = this;
|
2014-05-28 07:36:32 -07:00
|
|
|
while (klass != NULL) {
|
2015-10-26 13:11:36 -04:00
|
|
|
if (InstanceKlass::cast(klass)->has_been_redefined()) {
|
2014-05-28 07:36:32 -07:00
|
|
|
return true;
|
|
|
|
}
|
2015-10-26 13:11:36 -04:00
|
|
|
klass = klass->super();
|
2014-05-28 07:36:32 -07:00
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2013-10-07 12:20:28 -04:00
|
|
|
// lookup a method in the default methods list then in all transitive interfaces
|
|
|
|
// Do NOT return private or static methods
|
|
|
|
Method* InstanceKlass::lookup_method_in_ordered_interfaces(Symbol* name,
|
|
|
|
Symbol* signature) const {
|
2013-10-09 17:57:17 -04:00
|
|
|
Method* m = NULL;
|
2013-10-07 12:20:28 -04:00
|
|
|
if (default_methods() != NULL) {
|
|
|
|
m = find_method(default_methods(), name, signature);
|
|
|
|
}
|
|
|
|
// Look up interfaces
|
|
|
|
if (m == NULL) {
|
2015-01-23 09:54:33 -05:00
|
|
|
m = lookup_method_in_all_interfaces(name, signature, find_defaults);
|
2013-10-07 12:20:28 -04:00
|
|
|
}
|
|
|
|
return m;
|
|
|
|
}
|
|
|
|
|
2007-12-01 00:00:00 +00:00
|
|
|
// lookup a method in all the interfaces that this class implements
|
2013-10-01 08:10:42 -04:00
|
|
|
// Do NOT return private or static methods, new in JDK8 which are not externally visible
|
|
|
|
// They should only be found in the initial InterfaceMethodRef
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
Method* InstanceKlass::lookup_method_in_all_interfaces(Symbol* name,
|
2013-12-16 08:24:33 -05:00
|
|
|
Symbol* signature,
|
2015-01-23 09:54:33 -05:00
|
|
|
DefaultsLookupMode defaults_mode) const {
|
2018-08-07 15:45:07 -07:00
|
|
|
Array<InstanceKlass*>* all_ifs = transitive_interfaces();
|
2007-12-01 00:00:00 +00:00
|
|
|
int num_ifs = all_ifs->length();
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
InstanceKlass *ik = NULL;
|
2007-12-01 00:00:00 +00:00
|
|
|
for (int i = 0; i < num_ifs; i++) {
|
2018-08-07 15:45:07 -07:00
|
|
|
ik = all_ifs->at(i);
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
Method* m = ik->lookup_method(name, signature);
|
2013-12-16 08:24:33 -05:00
|
|
|
if (m != NULL && m->is_public() && !m->is_static() &&
|
2015-01-23 09:54:33 -05:00
|
|
|
((defaults_mode != skip_defaults) || !m->is_default_method())) {
|
2007-12-01 00:00:00 +00:00
|
|
|
return m;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* jni_id_for_impl for jfieldIds only */
|
2017-03-21 11:25:18 -04:00
|
|
|
JNIid* InstanceKlass::jni_id_for_impl(int offset) {
|
2007-12-01 00:00:00 +00:00
|
|
|
MutexLocker ml(JfieldIdCreation_lock);
|
|
|
|
// Retry lookup after we got the lock
|
2017-03-21 11:25:18 -04:00
|
|
|
JNIid* probe = jni_ids() == NULL ? NULL : jni_ids()->find(offset);
|
2007-12-01 00:00:00 +00:00
|
|
|
if (probe == NULL) {
|
|
|
|
// Slow case, allocate new static field identifier
|
2017-03-21 11:25:18 -04:00
|
|
|
probe = new JNIid(this, offset, jni_ids());
|
|
|
|
set_jni_ids(probe);
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
|
|
|
return probe;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* jni_id_for for jfieldIds only */
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
JNIid* InstanceKlass::jni_id_for(int offset) {
|
2007-12-01 00:00:00 +00:00
|
|
|
JNIid* probe = jni_ids() == NULL ? NULL : jni_ids()->find(offset);
|
|
|
|
if (probe == NULL) {
|
2017-03-21 11:25:18 -04:00
|
|
|
probe = jni_id_for_impl(offset);
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
|
|
|
return probe;
|
|
|
|
}
|
|
|
|
|
2015-12-08 20:04:03 +01:00
|
|
|
u2 InstanceKlass::enclosing_method_data(int offset) const {
|
|
|
|
const Array<jushort>* const inner_class_list = inner_classes();
|
2012-03-13 13:50:48 -04:00
|
|
|
if (inner_class_list == NULL) {
|
|
|
|
return 0;
|
|
|
|
}
|
2015-12-08 20:04:03 +01:00
|
|
|
const int length = inner_class_list->length();
|
2012-03-13 13:50:48 -04:00
|
|
|
if (length % inner_class_next_offset == 0) {
|
|
|
|
return 0;
|
|
|
|
}
|
2015-12-08 20:04:03 +01:00
|
|
|
const int index = length - enclosing_method_attribute_size;
|
|
|
|
assert(offset < enclosing_method_attribute_size, "invalid offset");
|
|
|
|
return inner_class_list->at(index + offset);
|
2012-03-13 13:50:48 -04:00
|
|
|
}
|
|
|
|
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
void InstanceKlass::set_enclosing_method_indices(u2 class_index,
|
2012-03-13 13:50:48 -04:00
|
|
|
u2 method_index) {
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
Array<jushort>* inner_class_list = inner_classes();
|
2012-03-13 13:50:48 -04:00
|
|
|
assert (inner_class_list != NULL, "_inner_classes list is not set up");
|
|
|
|
int length = inner_class_list->length();
|
|
|
|
if (length % inner_class_next_offset == enclosing_method_attribute_size) {
|
|
|
|
int index = length - enclosing_method_attribute_size;
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
inner_class_list->at_put(
|
2012-03-13 13:50:48 -04:00
|
|
|
index + enclosing_method_class_index_offset, class_index);
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
inner_class_list->at_put(
|
2012-03-13 13:50:48 -04:00
|
|
|
index + enclosing_method_method_index_offset, method_index);
|
|
|
|
}
|
|
|
|
}
|
2007-12-01 00:00:00 +00:00
|
|
|
|
|
|
|
// Lookup or create a jmethodID.
|
2009-09-21 09:30:24 -06:00
|
|
|
// This code is called by the VMThread and JavaThreads so the
|
|
|
|
// locking has to be done very carefully to avoid deadlocks
|
|
|
|
// and/or other cache consistency problems.
|
|
|
|
//
|
2017-03-21 11:25:18 -04:00
|
|
|
jmethodID InstanceKlass::get_jmethod_id(const methodHandle& method_h) {
|
2007-12-01 00:00:00 +00:00
|
|
|
size_t idnum = (size_t)method_h->method_idnum();
|
2017-03-21 11:25:18 -04:00
|
|
|
jmethodID* jmeths = methods_jmethod_ids_acquire();
|
2007-12-01 00:00:00 +00:00
|
|
|
size_t length = 0;
|
|
|
|
jmethodID id = NULL;
|
|
|
|
|
2009-09-21 09:30:24 -06:00
|
|
|
// We use a double-check locking idiom here because this cache is
|
|
|
|
// performance sensitive. In the normal system, this cache only
|
|
|
|
// transitions from NULL to non-NULL which is safe because we use
|
|
|
|
// release_set_methods_jmethod_ids() to advertise the new cache.
|
|
|
|
// A partially constructed cache should never be seen by a racing
|
2017-10-16 22:36:06 -04:00
|
|
|
// thread. We also use release_store() to save a new jmethodID
|
2009-09-21 09:30:24 -06:00
|
|
|
// in the cache so a partially constructed jmethodID should never be
|
|
|
|
// seen either. Cache reads of existing jmethodIDs proceed without a
|
|
|
|
// lock, but cache writes of a new jmethodID requires uniqueness and
|
|
|
|
// creation of the cache itself requires no leaks so a lock is
|
|
|
|
// generally acquired in those two cases.
|
|
|
|
//
|
|
|
|
// If the RedefineClasses() API has been used, then this cache can
|
|
|
|
// grow and we'll have transitions from non-NULL to bigger non-NULL.
|
|
|
|
// Cache creation requires no leaks and we require safety between all
|
|
|
|
// cache accesses and freeing of the old cache so a lock is generally
|
|
|
|
// acquired when the RedefineClasses() API has been used.
|
|
|
|
|
|
|
|
if (jmeths != NULL) {
|
|
|
|
// the cache already exists
|
2017-03-21 11:25:18 -04:00
|
|
|
if (!idnum_can_increment()) {
|
2009-09-21 09:30:24 -06:00
|
|
|
// the cache can't grow so we can just get the current values
|
|
|
|
get_jmethod_id_length_value(jmeths, idnum, &length, &id);
|
|
|
|
} else {
|
|
|
|
// cache can grow so we have to be more careful
|
|
|
|
if (Threads::number_of_threads() == 0 ||
|
|
|
|
SafepointSynchronize::is_at_safepoint()) {
|
|
|
|
// we're single threaded or at a safepoint - no locking needed
|
|
|
|
get_jmethod_id_length_value(jmeths, idnum, &length, &id);
|
|
|
|
} else {
|
|
|
|
MutexLocker ml(JmethodIdCreation_lock);
|
|
|
|
get_jmethod_id_length_value(jmeths, idnum, &length, &id);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// implied else:
|
|
|
|
// we need to allocate a cache so default length and id values are good
|
|
|
|
|
|
|
|
if (jmeths == NULL || // no cache yet
|
|
|
|
length <= idnum || // cache is too short
|
|
|
|
id == NULL) { // cache doesn't contain entry
|
2007-12-01 00:00:00 +00:00
|
|
|
|
2009-09-21 09:30:24 -06:00
|
|
|
// This function can be called by the VMThread so we have to do all
|
|
|
|
// things that might block on a safepoint before grabbing the lock.
|
|
|
|
// Otherwise, we can deadlock with the VMThread or have a cache
|
|
|
|
// consistency issue. These vars keep track of what we might have
|
|
|
|
// to free after the lock is dropped.
|
|
|
|
jmethodID to_dealloc_id = NULL;
|
|
|
|
jmethodID* to_dealloc_jmeths = NULL;
|
|
|
|
|
|
|
|
// may not allocate new_jmeths or use it if we allocate it
|
2007-12-01 00:00:00 +00:00
|
|
|
jmethodID* new_jmeths = NULL;
|
|
|
|
if (length <= idnum) {
|
2009-09-21 09:30:24 -06:00
|
|
|
// allocate a new cache that might be used
|
2017-03-21 11:25:18 -04:00
|
|
|
size_t size = MAX2(idnum+1, (size_t)idnum_allocated_count());
|
2012-06-28 17:03:16 -04:00
|
|
|
new_jmeths = NEW_C_HEAP_ARRAY(jmethodID, size+1, mtClass);
|
2007-12-01 00:00:00 +00:00
|
|
|
memset(new_jmeths, 0, (size+1)*sizeof(jmethodID));
|
2009-09-21 09:30:24 -06:00
|
|
|
// cache size is stored in element[0], other elements offset by one
|
|
|
|
new_jmeths[0] = (jmethodID)size;
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
|
|
|
|
2009-09-21 09:30:24 -06:00
|
|
|
// allocate a new jmethodID that might be used
|
2007-12-01 00:00:00 +00:00
|
|
|
jmethodID new_id = NULL;
|
|
|
|
if (method_h->is_old() && !method_h->is_obsolete()) {
|
|
|
|
// The method passed in is old (but not obsolete), we need to use the current version
|
2017-03-21 11:25:18 -04:00
|
|
|
Method* current_method = method_with_idnum((int)idnum);
|
2007-12-01 00:00:00 +00:00
|
|
|
assert(current_method != NULL, "old and but not obsolete, so should exist");
|
2017-03-21 11:25:18 -04:00
|
|
|
new_id = Method::make_jmethod_id(class_loader_data(), current_method);
|
2007-12-01 00:00:00 +00:00
|
|
|
} else {
|
|
|
|
// It is the current version of the method or an obsolete method,
|
|
|
|
// use the version passed in
|
2017-03-21 11:25:18 -04:00
|
|
|
new_id = Method::make_jmethod_id(class_loader_data(), method_h());
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
|
|
|
|
2009-09-21 09:30:24 -06:00
|
|
|
if (Threads::number_of_threads() == 0 ||
|
|
|
|
SafepointSynchronize::is_at_safepoint()) {
|
|
|
|
// we're single threaded or at a safepoint - no locking needed
|
2017-03-21 11:25:18 -04:00
|
|
|
id = get_jmethod_id_fetch_or_update(idnum, new_id, new_jmeths,
|
2009-09-21 09:30:24 -06:00
|
|
|
&to_dealloc_id, &to_dealloc_jmeths);
|
2008-03-12 18:09:34 -07:00
|
|
|
} else {
|
2007-12-01 00:00:00 +00:00
|
|
|
MutexLocker ml(JmethodIdCreation_lock);
|
2017-03-21 11:25:18 -04:00
|
|
|
id = get_jmethod_id_fetch_or_update(idnum, new_id, new_jmeths,
|
2009-09-21 09:30:24 -06:00
|
|
|
&to_dealloc_id, &to_dealloc_jmeths);
|
|
|
|
}
|
|
|
|
|
|
|
|
// The lock has been dropped so we can free resources.
|
|
|
|
// Free up either the old cache or the new cache if we allocated one.
|
|
|
|
if (to_dealloc_jmeths != NULL) {
|
|
|
|
FreeHeap(to_dealloc_jmeths);
|
|
|
|
}
|
|
|
|
// free up the new ID since it wasn't needed
|
|
|
|
if (to_dealloc_id != NULL) {
|
2017-03-21 11:25:18 -04:00
|
|
|
Method::destroy_jmethod_id(class_loader_data(), to_dealloc_id);
|
2008-03-12 18:09:34 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return id;
|
|
|
|
}
|
2007-12-01 00:00:00 +00:00
|
|
|
|
2014-11-05 16:47:37 -08:00
|
|
|
// Figure out how many jmethodIDs haven't been allocated, and make
|
|
|
|
// sure space for them is pre-allocated. This makes getting all
|
|
|
|
// method ids much, much faster with classes with more than 8
|
|
|
|
// methods, and has a *substantial* effect on performance with jvmti
|
|
|
|
// code that loads all jmethodIDs for all classes.
|
|
|
|
void InstanceKlass::ensure_space_for_methodids(int start_offset) {
|
|
|
|
int new_jmeths = 0;
|
|
|
|
int length = methods()->length();
|
|
|
|
for (int index = start_offset; index < length; index++) {
|
|
|
|
Method* m = methods()->at(index);
|
|
|
|
jmethodID id = m->find_jmethod_id_or_null();
|
|
|
|
if (id == NULL) {
|
|
|
|
new_jmeths++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (new_jmeths != 0) {
|
|
|
|
Method::ensure_jmethod_ids(class_loader_data(), new_jmeths);
|
|
|
|
}
|
|
|
|
}
|
2007-12-01 00:00:00 +00:00
|
|
|
|
2009-09-21 09:30:24 -06:00
|
|
|
// Common code to fetch the jmethodID from the cache or update the
|
|
|
|
// cache with the new jmethodID. This function should never do anything
|
|
|
|
// that causes the caller to go to a safepoint or we can deadlock with
|
|
|
|
// the VMThread or have cache consistency issues.
|
|
|
|
//
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
jmethodID InstanceKlass::get_jmethod_id_fetch_or_update(
|
2017-03-21 11:25:18 -04:00
|
|
|
size_t idnum, jmethodID new_id,
|
2009-09-21 09:30:24 -06:00
|
|
|
jmethodID* new_jmeths, jmethodID* to_dealloc_id_p,
|
|
|
|
jmethodID** to_dealloc_jmeths_p) {
|
|
|
|
assert(new_id != NULL, "sanity check");
|
|
|
|
assert(to_dealloc_id_p != NULL, "sanity check");
|
|
|
|
assert(to_dealloc_jmeths_p != NULL, "sanity check");
|
|
|
|
assert(Threads::number_of_threads() == 0 ||
|
|
|
|
SafepointSynchronize::is_at_safepoint() ||
|
|
|
|
JmethodIdCreation_lock->owned_by_self(), "sanity check");
|
|
|
|
|
|
|
|
// reacquire the cache - we are locked, single threaded or at a safepoint
|
2017-03-21 11:25:18 -04:00
|
|
|
jmethodID* jmeths = methods_jmethod_ids_acquire();
|
2009-09-21 09:30:24 -06:00
|
|
|
jmethodID id = NULL;
|
|
|
|
size_t length = 0;
|
2008-03-12 18:09:34 -07:00
|
|
|
|
2009-09-21 09:30:24 -06:00
|
|
|
if (jmeths == NULL || // no cache yet
|
|
|
|
(length = (size_t)jmeths[0]) <= idnum) { // cache is too short
|
2008-03-12 18:09:34 -07:00
|
|
|
if (jmeths != NULL) {
|
2009-09-21 09:30:24 -06:00
|
|
|
// copy any existing entries from the old cache
|
2008-03-12 18:09:34 -07:00
|
|
|
for (size_t index = 0; index < length; index++) {
|
|
|
|
new_jmeths[index+1] = jmeths[index+1];
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
2009-09-21 09:30:24 -06:00
|
|
|
*to_dealloc_jmeths_p = jmeths; // save old cache for later delete
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
2017-03-21 11:25:18 -04:00
|
|
|
release_set_methods_jmethod_ids(jmeths = new_jmeths);
|
2008-03-12 18:09:34 -07:00
|
|
|
} else {
|
2009-09-21 09:30:24 -06:00
|
|
|
// fetch jmethodID (if any) from the existing cache
|
2008-03-12 18:09:34 -07:00
|
|
|
id = jmeths[idnum+1];
|
2009-09-21 09:30:24 -06:00
|
|
|
*to_dealloc_jmeths_p = new_jmeths; // save new cache for later delete
|
2008-03-12 18:09:34 -07:00
|
|
|
}
|
|
|
|
if (id == NULL) {
|
2009-09-21 09:30:24 -06:00
|
|
|
// No matching jmethodID in the existing cache or we have a new
|
|
|
|
// cache or we just grew the cache. This cache write is done here
|
|
|
|
// by the first thread to win the foot race because a jmethodID
|
|
|
|
// needs to be unique once it is generally available.
|
2008-03-12 18:09:34 -07:00
|
|
|
id = new_id;
|
2009-09-21 09:30:24 -06:00
|
|
|
|
|
|
|
// The jmethodID cache can be read while unlocked so we have to
|
|
|
|
// make sure the new jmethodID is complete before installing it
|
|
|
|
// in the cache.
|
2017-10-16 22:36:06 -04:00
|
|
|
OrderAccess::release_store(&jmeths[idnum+1], id);
|
2008-03-12 18:09:34 -07:00
|
|
|
} else {
|
2009-09-21 09:30:24 -06:00
|
|
|
*to_dealloc_id_p = new_id; // save new id for later delete
|
2008-03-12 18:09:34 -07:00
|
|
|
}
|
2009-09-21 09:30:24 -06:00
|
|
|
return id;
|
|
|
|
}
|
2007-12-01 00:00:00 +00:00
|
|
|
|
2009-09-21 09:30:24 -06:00
|
|
|
|
|
|
|
// Common code to get the jmethodID cache length and the jmethodID
|
|
|
|
// value at index idnum if there is one.
|
|
|
|
//
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
void InstanceKlass::get_jmethod_id_length_value(jmethodID* cache,
|
2009-09-21 09:30:24 -06:00
|
|
|
size_t idnum, size_t *length_p, jmethodID* id_p) {
|
|
|
|
assert(cache != NULL, "sanity check");
|
|
|
|
assert(length_p != NULL, "sanity check");
|
|
|
|
assert(id_p != NULL, "sanity check");
|
|
|
|
|
|
|
|
// cache size is stored in element[0], other elements offset by one
|
|
|
|
*length_p = (size_t)cache[0];
|
|
|
|
if (*length_p <= idnum) { // cache is too short
|
|
|
|
*id_p = NULL;
|
|
|
|
} else {
|
|
|
|
*id_p = cache[idnum+1]; // fetch jmethodID (if any)
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Lookup a jmethodID, NULL if not found. Do no blocking, no allocations, no handles
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
jmethodID InstanceKlass::jmethod_id_or_null(Method* method) {
|
2007-12-01 00:00:00 +00:00
|
|
|
size_t idnum = (size_t)method->method_idnum();
|
|
|
|
jmethodID* jmeths = methods_jmethod_ids_acquire();
|
|
|
|
size_t length; // length assigned as debugging crumb
|
|
|
|
jmethodID id = NULL;
|
2009-09-21 09:30:24 -06:00
|
|
|
if (jmeths != NULL && // If there is a cache
|
2007-12-01 00:00:00 +00:00
|
|
|
(length = (size_t)jmeths[0]) > idnum) { // and if it is long enough,
|
|
|
|
id = jmeths[idnum+1]; // Look up the id (may be NULL)
|
|
|
|
}
|
|
|
|
return id;
|
|
|
|
}
|
|
|
|
|
2015-11-18 03:03:43 +03:00
|
|
|
inline DependencyContext InstanceKlass::dependencies() {
|
2018-11-30 11:40:48 +01:00
|
|
|
DependencyContext dep_context(&_dep_context, &_dep_context_last_cleaned);
|
2015-11-18 03:03:43 +03:00
|
|
|
return dep_context;
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
|
|
|
|
2016-02-19 20:40:20 +03:00
|
|
|
int InstanceKlass::mark_dependent_nmethods(KlassDepChange& changes) {
|
2015-11-18 03:03:43 +03:00
|
|
|
return dependencies().mark_dependent_nmethods(changes);
|
2015-05-15 19:23:11 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void InstanceKlass::add_dependent_nmethod(nmethod* nm) {
|
2015-11-18 03:03:43 +03:00
|
|
|
dependencies().add_dependent_nmethod(nm);
|
2015-05-15 19:23:11 +03:00
|
|
|
}
|
|
|
|
|
2018-11-30 11:40:48 +01:00
|
|
|
void InstanceKlass::remove_dependent_nmethod(nmethod* nm) {
|
|
|
|
dependencies().remove_dependent_nmethod(nm);
|
|
|
|
}
|
|
|
|
|
|
|
|
void InstanceKlass::clean_dependency_context() {
|
|
|
|
dependencies().clean_unloading_dependents();
|
2015-05-15 19:23:11 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
#ifndef PRODUCT
|
|
|
|
void InstanceKlass::print_dependent_nmethods(bool verbose) {
|
2015-11-18 03:03:43 +03:00
|
|
|
dependencies().print_dependent_nmethods(verbose);
|
2015-05-15 19:23:11 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
bool InstanceKlass::is_dependent_nmethod(nmethod* nm) {
|
2015-11-18 03:03:43 +03:00
|
|
|
return dependencies().is_dependent_nmethod(nm);
|
2015-05-15 19:23:11 +03:00
|
|
|
}
|
|
|
|
#endif //PRODUCT
|
|
|
|
|
2018-04-18 13:37:39 -04:00
|
|
|
void InstanceKlass::clean_weak_instanceklass_links() {
|
|
|
|
clean_implementors_list();
|
|
|
|
clean_method_data();
|
2015-10-13 10:06:46 +02:00
|
|
|
}
|
|
|
|
|
2018-04-18 13:37:39 -04:00
|
|
|
void InstanceKlass::clean_implementors_list() {
|
|
|
|
assert(is_loader_alive(), "this klass should be live");
|
2012-03-29 22:18:56 -04:00
|
|
|
if (is_interface()) {
|
2018-11-30 15:29:19 +01:00
|
|
|
assert (ClassUnloading, "only called for ClassUnloading");
|
|
|
|
for (;;) {
|
|
|
|
// Use load_acquire due to competing with inserts
|
|
|
|
Klass* impl = OrderAccess::load_acquire(adr_implementor());
|
|
|
|
if (impl != NULL && !impl->is_loader_alive()) {
|
|
|
|
// NULL this field, might be an unloaded klass or NULL
|
|
|
|
Klass* volatile* klass = adr_implementor();
|
|
|
|
if (Atomic::cmpxchg((Klass*)NULL, klass, impl) == impl) {
|
|
|
|
// Successfully unlinking implementor.
|
|
|
|
if (log_is_enabled(Trace, class, unload)) {
|
|
|
|
ResourceMark rm;
|
|
|
|
log_trace(class, unload)("unlinking class (implementor): %s", impl->external_name());
|
2018-10-31 14:38:14 -04:00
|
|
|
}
|
2018-11-30 15:29:19 +01:00
|
|
|
return;
|
2018-10-31 14:38:14 -04:00
|
|
|
}
|
2018-11-30 15:29:19 +01:00
|
|
|
} else {
|
|
|
|
return;
|
2018-10-31 14:38:14 -04:00
|
|
|
}
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
|
|
|
}
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
}
|
2012-03-29 22:18:56 -04:00
|
|
|
|
2018-04-18 13:37:39 -04:00
|
|
|
void InstanceKlass::clean_method_data() {
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
for (int m = 0; m < methods()->length(); m++) {
|
|
|
|
MethodData* mdo = methods()->at(m)->method_data();
|
|
|
|
if (mdo != NULL) {
|
2019-01-10 18:10:15 +01:00
|
|
|
MutexLockerEx ml(SafepointSynchronize::is_at_safepoint() ? NULL : mdo->extra_data_lock());
|
2018-04-18 13:37:39 -04:00
|
|
|
mdo->clean_method_data(/*always_clean*/false);
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
}
|
|
|
|
}
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
|
|
|
|
2016-12-11 19:07:04 -08:00
|
|
|
bool InstanceKlass::supers_have_passed_fingerprint_checks() {
|
|
|
|
if (java_super() != NULL && !java_super()->has_passed_fingerprint_check()) {
|
|
|
|
ResourceMark rm;
|
|
|
|
log_trace(class, fingerprint)("%s : super %s not fingerprinted", external_name(), java_super()->external_name());
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2018-08-07 15:45:07 -07:00
|
|
|
Array<InstanceKlass*>* local_interfaces = this->local_interfaces();
|
2016-12-11 19:07:04 -08:00
|
|
|
if (local_interfaces != NULL) {
|
|
|
|
int length = local_interfaces->length();
|
|
|
|
for (int i = 0; i < length; i++) {
|
2018-08-07 15:45:07 -07:00
|
|
|
InstanceKlass* intf = local_interfaces->at(i);
|
2016-12-11 19:07:04 -08:00
|
|
|
if (!intf->has_passed_fingerprint_check()) {
|
|
|
|
ResourceMark rm;
|
|
|
|
log_trace(class, fingerprint)("%s : interface %s not fingerprinted", external_name(), intf->external_name());
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2018-08-20 08:25:57 -04:00
|
|
|
bool InstanceKlass::should_store_fingerprint(bool is_unsafe_anonymous) {
|
2016-12-11 19:07:04 -08:00
|
|
|
#if INCLUDE_AOT
|
|
|
|
// We store the fingerprint into the InstanceKlass only in the following 2 cases:
|
2017-06-21 10:28:27 -07:00
|
|
|
if (CalculateClassFingerprint) {
|
2016-12-11 19:07:04 -08:00
|
|
|
// (1) We are running AOT to generate a shared library.
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
if (DumpSharedSpaces) {
|
|
|
|
// (2) We are running -Xshare:dump to create a shared archive
|
|
|
|
return true;
|
|
|
|
}
|
2018-08-20 08:25:57 -04:00
|
|
|
if (UseAOT && is_unsafe_anonymous) {
|
|
|
|
// (3) We are using AOT code from a shared library and see an unsafe anonymous class
|
2017-10-19 19:23:48 -07:00
|
|
|
return true;
|
|
|
|
}
|
2016-12-11 19:07:04 -08:00
|
|
|
#endif
|
|
|
|
|
|
|
|
// In all other cases we might set the _misc_has_passed_fingerprint_check bit,
|
|
|
|
// but do not store the 64-bit fingerprint to save space.
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool InstanceKlass::has_stored_fingerprint() const {
|
|
|
|
#if INCLUDE_AOT
|
|
|
|
return should_store_fingerprint() || is_shared();
|
|
|
|
#else
|
|
|
|
return false;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
uint64_t InstanceKlass::get_stored_fingerprint() const {
|
|
|
|
address adr = adr_fingerprint();
|
|
|
|
if (adr != NULL) {
|
|
|
|
return (uint64_t)Bytes::get_native_u8(adr); // adr may not be 64-bit aligned
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
void InstanceKlass::store_fingerprint(uint64_t fingerprint) {
|
|
|
|
address adr = adr_fingerprint();
|
|
|
|
if (adr != NULL) {
|
|
|
|
Bytes::put_native_u8(adr, (u8)fingerprint); // adr may not be 64-bit aligned
|
|
|
|
|
|
|
|
ResourceMark rm;
|
|
|
|
log_trace(class, fingerprint)("stored as " PTR64_FORMAT " for class %s", fingerprint, external_name());
|
|
|
|
}
|
|
|
|
}
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
|
2017-08-02 18:06:38 -07:00
|
|
|
void InstanceKlass::metaspace_pointers_do(MetaspaceClosure* it) {
|
|
|
|
Klass::metaspace_pointers_do(it);
|
|
|
|
|
|
|
|
if (log_is_enabled(Trace, cds)) {
|
|
|
|
ResourceMark rm;
|
|
|
|
log_trace(cds)("Iter(InstanceKlass): %p (%s)", this, external_name());
|
|
|
|
}
|
|
|
|
|
|
|
|
it->push(&_annotations);
|
|
|
|
it->push((Klass**)&_array_klasses);
|
|
|
|
it->push(&_constants);
|
|
|
|
it->push(&_inner_classes);
|
|
|
|
it->push(&_array_name);
|
|
|
|
#if INCLUDE_JVMTI
|
|
|
|
it->push(&_previous_versions);
|
|
|
|
#endif
|
|
|
|
it->push(&_methods);
|
|
|
|
it->push(&_default_methods);
|
|
|
|
it->push(&_local_interfaces);
|
|
|
|
it->push(&_transitive_interfaces);
|
|
|
|
it->push(&_method_ordering);
|
|
|
|
it->push(&_default_vtable_indices);
|
|
|
|
it->push(&_fields);
|
|
|
|
|
|
|
|
if (itable_length() > 0) {
|
|
|
|
itableOffsetEntry* ioe = (itableOffsetEntry*)start_of_itable();
|
|
|
|
int method_table_offset_in_words = ioe->offset()/wordSize;
|
|
|
|
int nof_interfaces = (method_table_offset_in_words - itable_offset_in_words())
|
|
|
|
/ itableOffsetEntry::size();
|
|
|
|
|
|
|
|
for (int i = 0; i < nof_interfaces; i ++, ioe ++) {
|
|
|
|
if (ioe->interface_klass() != NULL) {
|
|
|
|
it->push(ioe->interface_klass_addr());
|
|
|
|
itableMethodEntry* ime = ioe->first_method_entry(this);
|
|
|
|
int n = klassItable::method_count_for_interface(ioe->interface_klass());
|
|
|
|
for (int index = 0; index < n; index ++) {
|
|
|
|
it->push(ime[index].method_addr());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2018-06-23 01:32:41 -04:00
|
|
|
|
|
|
|
it->push(&_nest_members);
|
2017-08-02 18:06:38 -07:00
|
|
|
}
|
|
|
|
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
void InstanceKlass::remove_unshareable_info() {
|
2015-05-29 17:04:21 +03:00
|
|
|
Klass::remove_unshareable_info();
|
2017-05-16 19:36:55 -04:00
|
|
|
|
|
|
|
if (is_in_error_state()) {
|
|
|
|
// Classes are attempted to link during dumping and may fail,
|
|
|
|
// but these classes are still in the dictionary and class list in CLD.
|
|
|
|
// Check in_error state first because in_error is > linked state, so
|
|
|
|
// is_linked() is true.
|
|
|
|
// If there's a linking error, there is nothing else to remove.
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2018-10-01 00:52:37 -04:00
|
|
|
// Reset to the 'allocated' state to prevent any premature accessing to
|
|
|
|
// a shared class at runtime while the class is still being loaded and
|
|
|
|
// restored. A class' init_state is set to 'loaded' at runtime when it's
|
|
|
|
// being added to class hierarchy (see SystemDictionary:::add_to_hierarchy()).
|
|
|
|
_init_state = allocated;
|
|
|
|
|
2018-08-11 12:49:33 -04:00
|
|
|
{
|
|
|
|
MutexLocker ml(Compile_lock);
|
|
|
|
init_implementor();
|
|
|
|
}
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
|
|
|
|
constants()->remove_unshareable_info();
|
|
|
|
|
|
|
|
for (int i = 0; i < methods()->length(); i++) {
|
|
|
|
Method* m = methods()->at(i);
|
|
|
|
m->remove_unshareable_info();
|
|
|
|
}
|
2017-08-02 18:06:38 -07:00
|
|
|
|
2017-08-28 15:34:04 -07:00
|
|
|
// do array classes also.
|
|
|
|
if (array_klasses() != NULL) {
|
|
|
|
array_klasses()->remove_unshareable_info();
|
|
|
|
}
|
|
|
|
|
2017-08-02 18:06:38 -07:00
|
|
|
// These are not allocated from metaspace, but they should should all be empty
|
2017-08-28 15:34:04 -07:00
|
|
|
// during dump time, so we don't need to worry about them in InstanceKlass::iterate().
|
2017-08-02 18:06:38 -07:00
|
|
|
guarantee(_source_debug_extension == NULL, "must be");
|
2018-11-30 11:40:48 +01:00
|
|
|
guarantee(_dep_context == NULL, "must be");
|
2017-08-02 18:06:38 -07:00
|
|
|
guarantee(_osr_nmethods_head == NULL, "must be");
|
|
|
|
|
|
|
|
#if INCLUDE_JVMTI
|
|
|
|
guarantee(_breakpoints == NULL, "must be");
|
|
|
|
guarantee(_previous_versions == NULL, "must be");
|
2019-02-21 17:07:35 -08:00
|
|
|
_cached_class_file = NULL;
|
2017-08-02 18:06:38 -07:00
|
|
|
#endif
|
2017-08-28 15:34:04 -07:00
|
|
|
|
2018-06-23 01:32:41 -04:00
|
|
|
_init_thread = NULL;
|
|
|
|
_methods_jmethod_ids = NULL;
|
|
|
|
_jni_ids = NULL;
|
|
|
|
_oop_map_cache = NULL;
|
|
|
|
// clear _nest_host to ensure re-load at runtime
|
|
|
|
_nest_host = NULL;
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
}
|
|
|
|
|
2017-08-28 15:34:04 -07:00
|
|
|
void InstanceKlass::remove_java_mirror() {
|
|
|
|
Klass::remove_java_mirror();
|
|
|
|
|
|
|
|
// do array classes also.
|
|
|
|
if (array_klasses() != NULL) {
|
|
|
|
array_klasses()->remove_java_mirror();
|
|
|
|
}
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
}
|
|
|
|
|
2014-08-12 17:29:00 -07:00
|
|
|
void InstanceKlass::restore_unshareable_info(ClassLoaderData* loader_data, Handle protection_domain, TRAPS) {
|
2018-10-01 00:52:37 -04:00
|
|
|
// SystemDictionary::add_to_hierarchy() sets the init_state to loaded
|
|
|
|
// before the InstanceKlass is added to the SystemDictionary. Make
|
|
|
|
// sure the current state is <loaded.
|
|
|
|
assert(!is_loaded(), "invalid init state");
|
2017-03-15 10:25:37 -04:00
|
|
|
set_package(loader_data, CHECK);
|
8142968: Module System implementation
Initial integration of JEP 200, JEP 260, JEP 261, and JEP 282
Co-authored-by: Alex Buckley <alex.buckley@oracle.com>
Co-authored-by: Jonathan Gibbons <jonathan.gibbons@oracle.com>
Co-authored-by: Karen Kinnear <karen.kinnear@oracle.com>
Co-authored-by: Mandy Chung <mandy.chung@oracle.com>
Co-authored-by: Mark Reinhold <mark.reinhold@oracle.com>
Co-authored-by: Harold Seigel <harold.seigel@oracle.com>
Co-authored-by: Lois Foltan <lois.foltan@oracle.com>
Co-authored-by: Calvin Cheung <calvin.cheung@oracle.com>
Co-authored-by: Christian Tornqvist <christian.tornqvist@oracle.com>
Co-authored-by: Erik Joelsson <erik.joelsson@oracle.com>
Co-authored-by: George Triantafillou <george.triantafillou@oracle.com>
Co-authored-by: Igor Ignatyev <igor.ignatyev@oracle.com>
Co-authored-by: Ioi Lam <ioi.lam@oracle.com>
Co-authored-by: James Laskey <james.laskey@oracle.com>
Co-authored-by: Jean-Francois Denise <jean-francois.denise@oracle.com>
Co-authored-by: Jiangli Zhou <jiangli.zhou@oracle.com>
Co-authored-by: Markus Gronlund <markus.gronlund@oracle.com>
Co-authored-by: Serguei Spitsyn <serguei.spitsyn@oracle.com>
Co-authored-by: Staffan Larsen <staffan.larsen@oracle.com>
Co-authored-by: Sundararajan Athijegannathan <sundararajan.athijegannathan@oracle.com>
Reviewed-by: acorn, ccheung, coleenp, ctornqvi, dholmes, dsimms, gtriantafill, iklam, jiangli, mgronlun, mseledtsov, cjplummer, sspitsyn, stefank, twisti, hseigel, lfoltan, alanb, mchung, dfazunen
2016-03-17 19:04:01 +00:00
|
|
|
Klass::restore_unshareable_info(loader_data, protection_domain, CHECK);
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
|
2017-03-15 10:25:37 -04:00
|
|
|
Array<Method*>* methods = this->methods();
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
int num_methods = methods->length();
|
2019-01-18 16:21:07 +01:00
|
|
|
for (int index = 0; index < num_methods; ++index) {
|
|
|
|
methods->at(index)->restore_unshareable_info(CHECK);
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
}
|
|
|
|
if (JvmtiExport::has_redefined_a_class()) {
|
|
|
|
// Reinitialize vtable because RedefineClasses may have changed some
|
|
|
|
// entries in this vtable for super classes so the CDS vtable might
|
|
|
|
// point to old or obsolete entries. RedefineClasses doesn't fix up
|
|
|
|
// vtables in the shared system dictionary, only the main one.
|
|
|
|
// It also redefines the itable too so fix that too.
|
2017-04-13 01:56:01 -07:00
|
|
|
vtable().initialize_vtable(false, CHECK);
|
|
|
|
itable().initialize_itable(false, CHECK);
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
// restore constant pool resolved references
|
2017-03-15 10:25:37 -04:00
|
|
|
constants()->restore_unshareable_info(CHECK);
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
|
2017-08-28 15:34:04 -07:00
|
|
|
if (array_klasses() != NULL) {
|
|
|
|
// Array classes have null protection domain.
|
|
|
|
// --> see ArrayKlass::complete_create_array_klass()
|
|
|
|
array_klasses()->restore_unshareable_info(ClassLoaderData::the_null_class_loader_data(), Handle(), CHECK);
|
|
|
|
}
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
|
|
|
|
2014-08-12 17:29:00 -07:00
|
|
|
// returns true IFF is_in_error_state() has been changed as a result of this call.
|
|
|
|
bool InstanceKlass::check_sharing_error_state() {
|
|
|
|
assert(DumpSharedSpaces, "should only be called during dumping");
|
|
|
|
bool old_state = is_in_error_state();
|
|
|
|
|
|
|
|
if (!is_in_error_state()) {
|
|
|
|
bool bad = false;
|
|
|
|
for (InstanceKlass* sup = java_super(); sup; sup = sup->java_super()) {
|
|
|
|
if (sup->is_in_error_state()) {
|
|
|
|
bad = true;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (!bad) {
|
2018-08-07 15:45:07 -07:00
|
|
|
Array<InstanceKlass*>* interfaces = transitive_interfaces();
|
2014-08-12 17:29:00 -07:00
|
|
|
for (int i = 0; i < interfaces->length(); i++) {
|
2018-08-07 15:45:07 -07:00
|
|
|
InstanceKlass* iface = interfaces->at(i);
|
|
|
|
if (iface->is_in_error_state()) {
|
2014-08-12 17:29:00 -07:00
|
|
|
bad = true;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (bad) {
|
|
|
|
set_in_error_state();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return (old_state != is_in_error_state());
|
|
|
|
}
|
|
|
|
|
2016-04-21 20:49:11 -07:00
|
|
|
#if INCLUDE_JVMTI
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
static void clear_all_breakpoints(Method* m) {
|
2007-12-01 00:00:00 +00:00
|
|
|
m->clear_all_breakpoints();
|
|
|
|
}
|
2016-04-21 20:49:11 -07:00
|
|
|
#endif
|
2013-04-24 16:19:35 -04:00
|
|
|
|
2018-09-26 14:01:48 -04:00
|
|
|
void InstanceKlass::unload_class(InstanceKlass* ik) {
|
|
|
|
// Release dependencies.
|
|
|
|
ik->dependencies().remove_all_dependents();
|
|
|
|
|
2013-04-24 16:19:35 -04:00
|
|
|
// notify the debugger
|
|
|
|
if (JvmtiExport::should_post_class_unload()) {
|
|
|
|
JvmtiExport::post_class_unload(ik);
|
|
|
|
}
|
|
|
|
|
|
|
|
// notify ClassLoadingService of class unload
|
|
|
|
ClassLoadingService::notify_class_unloaded(ik);
|
2018-08-28 10:10:11 -04:00
|
|
|
|
2019-02-13 06:48:34 -05:00
|
|
|
if (log_is_enabled(Info, class, unload)) {
|
|
|
|
ResourceMark rm;
|
|
|
|
log_info(class, unload)("unloading class %s " INTPTR_FORMAT, ik->external_name(), p2i(ik));
|
|
|
|
}
|
|
|
|
|
|
|
|
Events::log_class_unloading(Thread::current(), ik);
|
|
|
|
|
2018-08-28 10:10:11 -04:00
|
|
|
#if INCLUDE_JFR
|
|
|
|
assert(ik != NULL, "invariant");
|
|
|
|
EventClassUnload event;
|
|
|
|
event.set_unloadedClass(ik);
|
|
|
|
event.set_definingClassLoader(ik->class_loader_data());
|
|
|
|
event.commit();
|
|
|
|
#endif
|
2013-04-24 16:19:35 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void InstanceKlass::release_C_heap_structures(InstanceKlass* ik) {
|
|
|
|
// Clean up C heap
|
|
|
|
ik->release_C_heap_structures();
|
|
|
|
ik->constants()->release_C_heap_structures();
|
|
|
|
}
|
|
|
|
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
void InstanceKlass::release_C_heap_structures() {
|
2013-04-24 16:19:35 -04:00
|
|
|
// Can't release the constant pool here because the constant pool can be
|
|
|
|
// deallocated separately from the InstanceKlass for default methods and
|
|
|
|
// redefine classes.
|
|
|
|
|
2007-12-01 00:00:00 +00:00
|
|
|
// Deallocate oop map cache
|
|
|
|
if (_oop_map_cache != NULL) {
|
|
|
|
delete _oop_map_cache;
|
|
|
|
_oop_map_cache = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Deallocate JNI identifiers for jfieldIDs
|
|
|
|
JNIid::deallocate(jni_ids());
|
|
|
|
set_jni_ids(NULL);
|
|
|
|
|
|
|
|
jmethodID* jmeths = methods_jmethod_ids_acquire();
|
|
|
|
if (jmeths != (jmethodID*)NULL) {
|
|
|
|
release_set_methods_jmethod_ids(NULL);
|
|
|
|
FreeHeap(jmeths);
|
|
|
|
}
|
|
|
|
|
2018-11-30 11:40:48 +01:00
|
|
|
assert(_dep_context == NULL,
|
2018-09-26 14:01:48 -04:00
|
|
|
"dependencies should already be cleaned");
|
2007-12-01 00:00:00 +00:00
|
|
|
|
2016-04-21 20:49:11 -07:00
|
|
|
#if INCLUDE_JVMTI
|
2007-12-01 00:00:00 +00:00
|
|
|
// Deallocate breakpoint records
|
|
|
|
if (breakpoints() != 0x0) {
|
|
|
|
methods_do(clear_all_breakpoints);
|
|
|
|
assert(breakpoints() == 0x0, "should have cleared breakpoints");
|
|
|
|
}
|
|
|
|
|
|
|
|
// deallocate the cached class file
|
2019-02-21 17:07:35 -08:00
|
|
|
if (_cached_class_file != NULL) {
|
2014-12-01 12:16:15 -05:00
|
|
|
os::free(_cached_class_file);
|
2013-07-17 18:06:29 -04:00
|
|
|
_cached_class_file = NULL;
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
2016-04-21 20:49:11 -07:00
|
|
|
#endif
|
2011-01-27 16:11:27 -08:00
|
|
|
|
|
|
|
// Decrement symbol reference counts associated with the unloaded class.
|
|
|
|
if (_name != NULL) _name->decrement_refcount();
|
|
|
|
// unreference array name derived from this class name (arrays of an unloaded
|
|
|
|
// class can't be referenced anymore).
|
|
|
|
if (_array_name != NULL) _array_name->decrement_refcount();
|
2014-12-01 12:16:15 -05:00
|
|
|
if (_source_debug_extension != NULL) FREE_C_HEAP_ARRAY(char, _source_debug_extension);
|
2011-01-27 16:11:27 -08:00
|
|
|
}
|
|
|
|
|
2015-12-08 20:04:03 +01:00
|
|
|
void InstanceKlass::set_source_debug_extension(const char* array, int length) {
|
2012-07-09 01:28:37 -07:00
|
|
|
if (array == NULL) {
|
|
|
|
_source_debug_extension = NULL;
|
|
|
|
} else {
|
|
|
|
// Adding one to the attribute length in order to store a null terminator
|
|
|
|
// character could cause an overflow because the attribute length is
|
|
|
|
// already coded with an u4 in the classfile, but in practice, it's
|
|
|
|
// unlikely to happen.
|
|
|
|
assert((length+1) > length, "Overflow checking");
|
|
|
|
char* sde = NEW_C_HEAP_ARRAY(char, (length + 1), mtClass);
|
|
|
|
for (int i = 0; i < length; i++) {
|
|
|
|
sde[i] = array[i];
|
|
|
|
}
|
|
|
|
sde[length] = '\0';
|
|
|
|
_source_debug_extension = sde;
|
|
|
|
}
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
|
|
|
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
const char* InstanceKlass::signature_name() const {
|
2013-10-24 10:02:02 +02:00
|
|
|
int hash_len = 0;
|
|
|
|
char hash_buf[40];
|
|
|
|
|
2018-08-20 08:25:57 -04:00
|
|
|
// If this is an unsafe anonymous class, append a hash to make the name unique
|
|
|
|
if (is_unsafe_anonymous()) {
|
2013-10-24 10:02:02 +02:00
|
|
|
intptr_t hash = (java_mirror() != NULL) ? java_mirror()->identity_hash() : 0;
|
2014-10-29 10:13:24 +01:00
|
|
|
jio_snprintf(hash_buf, sizeof(hash_buf), "/" UINTX_FORMAT, (uintx)hash);
|
2013-10-24 10:02:02 +02:00
|
|
|
hash_len = (int)strlen(hash_buf);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Get the internal name as a c string
|
2007-12-01 00:00:00 +00:00
|
|
|
const char* src = (const char*) (name()->as_C_string());
|
|
|
|
const int src_length = (int)strlen(src);
|
2013-10-24 10:02:02 +02:00
|
|
|
|
|
|
|
char* dest = NEW_RESOURCE_ARRAY(char, src_length + hash_len + 3);
|
|
|
|
|
|
|
|
// Add L as type indicator
|
2007-12-01 00:00:00 +00:00
|
|
|
int dest_index = 0;
|
|
|
|
dest[dest_index++] = 'L';
|
2013-10-24 10:02:02 +02:00
|
|
|
|
|
|
|
// Add the actual class name
|
|
|
|
for (int src_index = 0; src_index < src_length; ) {
|
2007-12-01 00:00:00 +00:00
|
|
|
dest[dest_index++] = src[src_index++];
|
|
|
|
}
|
2013-10-24 10:02:02 +02:00
|
|
|
|
|
|
|
// If we have a hash, append it
|
|
|
|
for (int hash_index = 0; hash_index < hash_len; ) {
|
|
|
|
dest[dest_index++] = hash_buf[hash_index++];
|
|
|
|
}
|
|
|
|
|
|
|
|
// Add the semicolon and the NULL
|
2007-12-01 00:00:00 +00:00
|
|
|
dest[dest_index++] = ';';
|
|
|
|
dest[dest_index] = '\0';
|
|
|
|
return dest;
|
|
|
|
}
|
|
|
|
|
2016-06-07 11:39:47 -04:00
|
|
|
// Used to obtain the package name from a fully qualified class name.
|
|
|
|
Symbol* InstanceKlass::package_from_name(const Symbol* name, TRAPS) {
|
8142968: Module System implementation
Initial integration of JEP 200, JEP 260, JEP 261, and JEP 282
Co-authored-by: Alex Buckley <alex.buckley@oracle.com>
Co-authored-by: Jonathan Gibbons <jonathan.gibbons@oracle.com>
Co-authored-by: Karen Kinnear <karen.kinnear@oracle.com>
Co-authored-by: Mandy Chung <mandy.chung@oracle.com>
Co-authored-by: Mark Reinhold <mark.reinhold@oracle.com>
Co-authored-by: Harold Seigel <harold.seigel@oracle.com>
Co-authored-by: Lois Foltan <lois.foltan@oracle.com>
Co-authored-by: Calvin Cheung <calvin.cheung@oracle.com>
Co-authored-by: Christian Tornqvist <christian.tornqvist@oracle.com>
Co-authored-by: Erik Joelsson <erik.joelsson@oracle.com>
Co-authored-by: George Triantafillou <george.triantafillou@oracle.com>
Co-authored-by: Igor Ignatyev <igor.ignatyev@oracle.com>
Co-authored-by: Ioi Lam <ioi.lam@oracle.com>
Co-authored-by: James Laskey <james.laskey@oracle.com>
Co-authored-by: Jean-Francois Denise <jean-francois.denise@oracle.com>
Co-authored-by: Jiangli Zhou <jiangli.zhou@oracle.com>
Co-authored-by: Markus Gronlund <markus.gronlund@oracle.com>
Co-authored-by: Serguei Spitsyn <serguei.spitsyn@oracle.com>
Co-authored-by: Staffan Larsen <staffan.larsen@oracle.com>
Co-authored-by: Sundararajan Athijegannathan <sundararajan.athijegannathan@oracle.com>
Reviewed-by: acorn, ccheung, coleenp, ctornqvi, dholmes, dsimms, gtriantafill, iklam, jiangli, mgronlun, mseledtsov, cjplummer, sspitsyn, stefank, twisti, hseigel, lfoltan, alanb, mchung, dfazunen
2016-03-17 19:04:01 +00:00
|
|
|
if (name == NULL) {
|
|
|
|
return NULL;
|
|
|
|
} else {
|
2016-06-07 11:39:47 -04:00
|
|
|
if (name->utf8_length() <= 0) {
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
ResourceMark rm;
|
|
|
|
const char* package_name = ClassLoader::package_from_name((const char*) name->as_C_string());
|
|
|
|
if (package_name == NULL) {
|
8142968: Module System implementation
Initial integration of JEP 200, JEP 260, JEP 261, and JEP 282
Co-authored-by: Alex Buckley <alex.buckley@oracle.com>
Co-authored-by: Jonathan Gibbons <jonathan.gibbons@oracle.com>
Co-authored-by: Karen Kinnear <karen.kinnear@oracle.com>
Co-authored-by: Mandy Chung <mandy.chung@oracle.com>
Co-authored-by: Mark Reinhold <mark.reinhold@oracle.com>
Co-authored-by: Harold Seigel <harold.seigel@oracle.com>
Co-authored-by: Lois Foltan <lois.foltan@oracle.com>
Co-authored-by: Calvin Cheung <calvin.cheung@oracle.com>
Co-authored-by: Christian Tornqvist <christian.tornqvist@oracle.com>
Co-authored-by: Erik Joelsson <erik.joelsson@oracle.com>
Co-authored-by: George Triantafillou <george.triantafillou@oracle.com>
Co-authored-by: Igor Ignatyev <igor.ignatyev@oracle.com>
Co-authored-by: Ioi Lam <ioi.lam@oracle.com>
Co-authored-by: James Laskey <james.laskey@oracle.com>
Co-authored-by: Jean-Francois Denise <jean-francois.denise@oracle.com>
Co-authored-by: Jiangli Zhou <jiangli.zhou@oracle.com>
Co-authored-by: Markus Gronlund <markus.gronlund@oracle.com>
Co-authored-by: Serguei Spitsyn <serguei.spitsyn@oracle.com>
Co-authored-by: Staffan Larsen <staffan.larsen@oracle.com>
Co-authored-by: Sundararajan Athijegannathan <sundararajan.athijegannathan@oracle.com>
Reviewed-by: acorn, ccheung, coleenp, ctornqvi, dholmes, dsimms, gtriantafill, iklam, jiangli, mgronlun, mseledtsov, cjplummer, sspitsyn, stefank, twisti, hseigel, lfoltan, alanb, mchung, dfazunen
2016-03-17 19:04:01 +00:00
|
|
|
return NULL;
|
|
|
|
}
|
2016-06-07 11:39:47 -04:00
|
|
|
Symbol* pkg_name = SymbolTable::new_symbol(package_name, THREAD);
|
|
|
|
return pkg_name;
|
8142968: Module System implementation
Initial integration of JEP 200, JEP 260, JEP 261, and JEP 282
Co-authored-by: Alex Buckley <alex.buckley@oracle.com>
Co-authored-by: Jonathan Gibbons <jonathan.gibbons@oracle.com>
Co-authored-by: Karen Kinnear <karen.kinnear@oracle.com>
Co-authored-by: Mandy Chung <mandy.chung@oracle.com>
Co-authored-by: Mark Reinhold <mark.reinhold@oracle.com>
Co-authored-by: Harold Seigel <harold.seigel@oracle.com>
Co-authored-by: Lois Foltan <lois.foltan@oracle.com>
Co-authored-by: Calvin Cheung <calvin.cheung@oracle.com>
Co-authored-by: Christian Tornqvist <christian.tornqvist@oracle.com>
Co-authored-by: Erik Joelsson <erik.joelsson@oracle.com>
Co-authored-by: George Triantafillou <george.triantafillou@oracle.com>
Co-authored-by: Igor Ignatyev <igor.ignatyev@oracle.com>
Co-authored-by: Ioi Lam <ioi.lam@oracle.com>
Co-authored-by: James Laskey <james.laskey@oracle.com>
Co-authored-by: Jean-Francois Denise <jean-francois.denise@oracle.com>
Co-authored-by: Jiangli Zhou <jiangli.zhou@oracle.com>
Co-authored-by: Markus Gronlund <markus.gronlund@oracle.com>
Co-authored-by: Serguei Spitsyn <serguei.spitsyn@oracle.com>
Co-authored-by: Staffan Larsen <staffan.larsen@oracle.com>
Co-authored-by: Sundararajan Athijegannathan <sundararajan.athijegannathan@oracle.com>
Reviewed-by: acorn, ccheung, coleenp, ctornqvi, dholmes, dsimms, gtriantafill, iklam, jiangli, mgronlun, mseledtsov, cjplummer, sspitsyn, stefank, twisti, hseigel, lfoltan, alanb, mchung, dfazunen
2016-03-17 19:04:01 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
ModuleEntry* InstanceKlass::module() const {
|
2018-08-20 08:25:57 -04:00
|
|
|
// For an unsafe anonymous class return the host class' module
|
|
|
|
if (is_unsafe_anonymous()) {
|
|
|
|
assert(unsafe_anonymous_host() != NULL, "unsafe anonymous class must have a host class");
|
|
|
|
return unsafe_anonymous_host()->module();
|
|
|
|
}
|
|
|
|
|
|
|
|
// Class is in a named package
|
8142968: Module System implementation
Initial integration of JEP 200, JEP 260, JEP 261, and JEP 282
Co-authored-by: Alex Buckley <alex.buckley@oracle.com>
Co-authored-by: Jonathan Gibbons <jonathan.gibbons@oracle.com>
Co-authored-by: Karen Kinnear <karen.kinnear@oracle.com>
Co-authored-by: Mandy Chung <mandy.chung@oracle.com>
Co-authored-by: Mark Reinhold <mark.reinhold@oracle.com>
Co-authored-by: Harold Seigel <harold.seigel@oracle.com>
Co-authored-by: Lois Foltan <lois.foltan@oracle.com>
Co-authored-by: Calvin Cheung <calvin.cheung@oracle.com>
Co-authored-by: Christian Tornqvist <christian.tornqvist@oracle.com>
Co-authored-by: Erik Joelsson <erik.joelsson@oracle.com>
Co-authored-by: George Triantafillou <george.triantafillou@oracle.com>
Co-authored-by: Igor Ignatyev <igor.ignatyev@oracle.com>
Co-authored-by: Ioi Lam <ioi.lam@oracle.com>
Co-authored-by: James Laskey <james.laskey@oracle.com>
Co-authored-by: Jean-Francois Denise <jean-francois.denise@oracle.com>
Co-authored-by: Jiangli Zhou <jiangli.zhou@oracle.com>
Co-authored-by: Markus Gronlund <markus.gronlund@oracle.com>
Co-authored-by: Serguei Spitsyn <serguei.spitsyn@oracle.com>
Co-authored-by: Staffan Larsen <staffan.larsen@oracle.com>
Co-authored-by: Sundararajan Athijegannathan <sundararajan.athijegannathan@oracle.com>
Reviewed-by: acorn, ccheung, coleenp, ctornqvi, dholmes, dsimms, gtriantafill, iklam, jiangli, mgronlun, mseledtsov, cjplummer, sspitsyn, stefank, twisti, hseigel, lfoltan, alanb, mchung, dfazunen
2016-03-17 19:04:01 +00:00
|
|
|
if (!in_unnamed_package()) {
|
|
|
|
return _package_entry->module();
|
|
|
|
}
|
2018-08-20 08:25:57 -04:00
|
|
|
|
|
|
|
// Class is in an unnamed package, return its loader's unnamed module
|
|
|
|
return class_loader_data()->unnamed_module();
|
8142968: Module System implementation
Initial integration of JEP 200, JEP 260, JEP 261, and JEP 282
Co-authored-by: Alex Buckley <alex.buckley@oracle.com>
Co-authored-by: Jonathan Gibbons <jonathan.gibbons@oracle.com>
Co-authored-by: Karen Kinnear <karen.kinnear@oracle.com>
Co-authored-by: Mandy Chung <mandy.chung@oracle.com>
Co-authored-by: Mark Reinhold <mark.reinhold@oracle.com>
Co-authored-by: Harold Seigel <harold.seigel@oracle.com>
Co-authored-by: Lois Foltan <lois.foltan@oracle.com>
Co-authored-by: Calvin Cheung <calvin.cheung@oracle.com>
Co-authored-by: Christian Tornqvist <christian.tornqvist@oracle.com>
Co-authored-by: Erik Joelsson <erik.joelsson@oracle.com>
Co-authored-by: George Triantafillou <george.triantafillou@oracle.com>
Co-authored-by: Igor Ignatyev <igor.ignatyev@oracle.com>
Co-authored-by: Ioi Lam <ioi.lam@oracle.com>
Co-authored-by: James Laskey <james.laskey@oracle.com>
Co-authored-by: Jean-Francois Denise <jean-francois.denise@oracle.com>
Co-authored-by: Jiangli Zhou <jiangli.zhou@oracle.com>
Co-authored-by: Markus Gronlund <markus.gronlund@oracle.com>
Co-authored-by: Serguei Spitsyn <serguei.spitsyn@oracle.com>
Co-authored-by: Staffan Larsen <staffan.larsen@oracle.com>
Co-authored-by: Sundararajan Athijegannathan <sundararajan.athijegannathan@oracle.com>
Reviewed-by: acorn, ccheung, coleenp, ctornqvi, dholmes, dsimms, gtriantafill, iklam, jiangli, mgronlun, mseledtsov, cjplummer, sspitsyn, stefank, twisti, hseigel, lfoltan, alanb, mchung, dfazunen
2016-03-17 19:04:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void InstanceKlass::set_package(ClassLoaderData* loader_data, TRAPS) {
|
2016-07-27 08:31:48 -04:00
|
|
|
|
|
|
|
// ensure java/ packages only loaded by boot or platform builtin loaders
|
2018-06-19 07:54:11 -04:00
|
|
|
check_prohibited_package(name(), loader_data, CHECK);
|
2016-07-27 08:31:48 -04:00
|
|
|
|
2016-06-07 11:39:47 -04:00
|
|
|
TempNewSymbol pkg_name = package_from_name(name(), CHECK);
|
8142968: Module System implementation
Initial integration of JEP 200, JEP 260, JEP 261, and JEP 282
Co-authored-by: Alex Buckley <alex.buckley@oracle.com>
Co-authored-by: Jonathan Gibbons <jonathan.gibbons@oracle.com>
Co-authored-by: Karen Kinnear <karen.kinnear@oracle.com>
Co-authored-by: Mandy Chung <mandy.chung@oracle.com>
Co-authored-by: Mark Reinhold <mark.reinhold@oracle.com>
Co-authored-by: Harold Seigel <harold.seigel@oracle.com>
Co-authored-by: Lois Foltan <lois.foltan@oracle.com>
Co-authored-by: Calvin Cheung <calvin.cheung@oracle.com>
Co-authored-by: Christian Tornqvist <christian.tornqvist@oracle.com>
Co-authored-by: Erik Joelsson <erik.joelsson@oracle.com>
Co-authored-by: George Triantafillou <george.triantafillou@oracle.com>
Co-authored-by: Igor Ignatyev <igor.ignatyev@oracle.com>
Co-authored-by: Ioi Lam <ioi.lam@oracle.com>
Co-authored-by: James Laskey <james.laskey@oracle.com>
Co-authored-by: Jean-Francois Denise <jean-francois.denise@oracle.com>
Co-authored-by: Jiangli Zhou <jiangli.zhou@oracle.com>
Co-authored-by: Markus Gronlund <markus.gronlund@oracle.com>
Co-authored-by: Serguei Spitsyn <serguei.spitsyn@oracle.com>
Co-authored-by: Staffan Larsen <staffan.larsen@oracle.com>
Co-authored-by: Sundararajan Athijegannathan <sundararajan.athijegannathan@oracle.com>
Reviewed-by: acorn, ccheung, coleenp, ctornqvi, dholmes, dsimms, gtriantafill, iklam, jiangli, mgronlun, mseledtsov, cjplummer, sspitsyn, stefank, twisti, hseigel, lfoltan, alanb, mchung, dfazunen
2016-03-17 19:04:01 +00:00
|
|
|
|
2016-06-07 11:39:47 -04:00
|
|
|
if (pkg_name != NULL && loader_data != NULL) {
|
2016-07-27 08:31:48 -04:00
|
|
|
|
8142968: Module System implementation
Initial integration of JEP 200, JEP 260, JEP 261, and JEP 282
Co-authored-by: Alex Buckley <alex.buckley@oracle.com>
Co-authored-by: Jonathan Gibbons <jonathan.gibbons@oracle.com>
Co-authored-by: Karen Kinnear <karen.kinnear@oracle.com>
Co-authored-by: Mandy Chung <mandy.chung@oracle.com>
Co-authored-by: Mark Reinhold <mark.reinhold@oracle.com>
Co-authored-by: Harold Seigel <harold.seigel@oracle.com>
Co-authored-by: Lois Foltan <lois.foltan@oracle.com>
Co-authored-by: Calvin Cheung <calvin.cheung@oracle.com>
Co-authored-by: Christian Tornqvist <christian.tornqvist@oracle.com>
Co-authored-by: Erik Joelsson <erik.joelsson@oracle.com>
Co-authored-by: George Triantafillou <george.triantafillou@oracle.com>
Co-authored-by: Igor Ignatyev <igor.ignatyev@oracle.com>
Co-authored-by: Ioi Lam <ioi.lam@oracle.com>
Co-authored-by: James Laskey <james.laskey@oracle.com>
Co-authored-by: Jean-Francois Denise <jean-francois.denise@oracle.com>
Co-authored-by: Jiangli Zhou <jiangli.zhou@oracle.com>
Co-authored-by: Markus Gronlund <markus.gronlund@oracle.com>
Co-authored-by: Serguei Spitsyn <serguei.spitsyn@oracle.com>
Co-authored-by: Staffan Larsen <staffan.larsen@oracle.com>
Co-authored-by: Sundararajan Athijegannathan <sundararajan.athijegannathan@oracle.com>
Reviewed-by: acorn, ccheung, coleenp, ctornqvi, dholmes, dsimms, gtriantafill, iklam, jiangli, mgronlun, mseledtsov, cjplummer, sspitsyn, stefank, twisti, hseigel, lfoltan, alanb, mchung, dfazunen
2016-03-17 19:04:01 +00:00
|
|
|
// Find in class loader's package entry table.
|
|
|
|
_package_entry = loader_data->packages()->lookup_only(pkg_name);
|
2015-12-08 20:04:03 +01:00
|
|
|
|
8142968: Module System implementation
Initial integration of JEP 200, JEP 260, JEP 261, and JEP 282
Co-authored-by: Alex Buckley <alex.buckley@oracle.com>
Co-authored-by: Jonathan Gibbons <jonathan.gibbons@oracle.com>
Co-authored-by: Karen Kinnear <karen.kinnear@oracle.com>
Co-authored-by: Mandy Chung <mandy.chung@oracle.com>
Co-authored-by: Mark Reinhold <mark.reinhold@oracle.com>
Co-authored-by: Harold Seigel <harold.seigel@oracle.com>
Co-authored-by: Lois Foltan <lois.foltan@oracle.com>
Co-authored-by: Calvin Cheung <calvin.cheung@oracle.com>
Co-authored-by: Christian Tornqvist <christian.tornqvist@oracle.com>
Co-authored-by: Erik Joelsson <erik.joelsson@oracle.com>
Co-authored-by: George Triantafillou <george.triantafillou@oracle.com>
Co-authored-by: Igor Ignatyev <igor.ignatyev@oracle.com>
Co-authored-by: Ioi Lam <ioi.lam@oracle.com>
Co-authored-by: James Laskey <james.laskey@oracle.com>
Co-authored-by: Jean-Francois Denise <jean-francois.denise@oracle.com>
Co-authored-by: Jiangli Zhou <jiangli.zhou@oracle.com>
Co-authored-by: Markus Gronlund <markus.gronlund@oracle.com>
Co-authored-by: Serguei Spitsyn <serguei.spitsyn@oracle.com>
Co-authored-by: Staffan Larsen <staffan.larsen@oracle.com>
Co-authored-by: Sundararajan Athijegannathan <sundararajan.athijegannathan@oracle.com>
Reviewed-by: acorn, ccheung, coleenp, ctornqvi, dholmes, dsimms, gtriantafill, iklam, jiangli, mgronlun, mseledtsov, cjplummer, sspitsyn, stefank, twisti, hseigel, lfoltan, alanb, mchung, dfazunen
2016-03-17 19:04:01 +00:00
|
|
|
// If the package name is not found in the loader's package
|
|
|
|
// entry table, it is an indication that the package has not
|
|
|
|
// been defined. Consider it defined within the unnamed module.
|
|
|
|
if (_package_entry == NULL) {
|
|
|
|
ResourceMark rm;
|
|
|
|
|
|
|
|
if (!ModuleEntryTable::javabase_defined()) {
|
|
|
|
// Before java.base is defined during bootstrapping, define all packages in
|
|
|
|
// the java.base module. If a non-java.base package is erroneously placed
|
|
|
|
// in the java.base module it will be caught later when java.base
|
|
|
|
// is defined by ModuleEntryTable::verify_javabase_packages check.
|
2016-12-05 16:08:20 -05:00
|
|
|
assert(ModuleEntryTable::javabase_moduleEntry() != NULL, JAVA_BASE_NAME " module is NULL");
|
2016-09-19 12:04:28 -04:00
|
|
|
_package_entry = loader_data->packages()->lookup(pkg_name, ModuleEntryTable::javabase_moduleEntry());
|
8142968: Module System implementation
Initial integration of JEP 200, JEP 260, JEP 261, and JEP 282
Co-authored-by: Alex Buckley <alex.buckley@oracle.com>
Co-authored-by: Jonathan Gibbons <jonathan.gibbons@oracle.com>
Co-authored-by: Karen Kinnear <karen.kinnear@oracle.com>
Co-authored-by: Mandy Chung <mandy.chung@oracle.com>
Co-authored-by: Mark Reinhold <mark.reinhold@oracle.com>
Co-authored-by: Harold Seigel <harold.seigel@oracle.com>
Co-authored-by: Lois Foltan <lois.foltan@oracle.com>
Co-authored-by: Calvin Cheung <calvin.cheung@oracle.com>
Co-authored-by: Christian Tornqvist <christian.tornqvist@oracle.com>
Co-authored-by: Erik Joelsson <erik.joelsson@oracle.com>
Co-authored-by: George Triantafillou <george.triantafillou@oracle.com>
Co-authored-by: Igor Ignatyev <igor.ignatyev@oracle.com>
Co-authored-by: Ioi Lam <ioi.lam@oracle.com>
Co-authored-by: James Laskey <james.laskey@oracle.com>
Co-authored-by: Jean-Francois Denise <jean-francois.denise@oracle.com>
Co-authored-by: Jiangli Zhou <jiangli.zhou@oracle.com>
Co-authored-by: Markus Gronlund <markus.gronlund@oracle.com>
Co-authored-by: Serguei Spitsyn <serguei.spitsyn@oracle.com>
Co-authored-by: Staffan Larsen <staffan.larsen@oracle.com>
Co-authored-by: Sundararajan Athijegannathan <sundararajan.athijegannathan@oracle.com>
Reviewed-by: acorn, ccheung, coleenp, ctornqvi, dholmes, dsimms, gtriantafill, iklam, jiangli, mgronlun, mseledtsov, cjplummer, sspitsyn, stefank, twisti, hseigel, lfoltan, alanb, mchung, dfazunen
2016-03-17 19:04:01 +00:00
|
|
|
} else {
|
2017-04-18 13:19:42 -04:00
|
|
|
assert(loader_data->unnamed_module() != NULL, "unnamed module is NULL");
|
8142968: Module System implementation
Initial integration of JEP 200, JEP 260, JEP 261, and JEP 282
Co-authored-by: Alex Buckley <alex.buckley@oracle.com>
Co-authored-by: Jonathan Gibbons <jonathan.gibbons@oracle.com>
Co-authored-by: Karen Kinnear <karen.kinnear@oracle.com>
Co-authored-by: Mandy Chung <mandy.chung@oracle.com>
Co-authored-by: Mark Reinhold <mark.reinhold@oracle.com>
Co-authored-by: Harold Seigel <harold.seigel@oracle.com>
Co-authored-by: Lois Foltan <lois.foltan@oracle.com>
Co-authored-by: Calvin Cheung <calvin.cheung@oracle.com>
Co-authored-by: Christian Tornqvist <christian.tornqvist@oracle.com>
Co-authored-by: Erik Joelsson <erik.joelsson@oracle.com>
Co-authored-by: George Triantafillou <george.triantafillou@oracle.com>
Co-authored-by: Igor Ignatyev <igor.ignatyev@oracle.com>
Co-authored-by: Ioi Lam <ioi.lam@oracle.com>
Co-authored-by: James Laskey <james.laskey@oracle.com>
Co-authored-by: Jean-Francois Denise <jean-francois.denise@oracle.com>
Co-authored-by: Jiangli Zhou <jiangli.zhou@oracle.com>
Co-authored-by: Markus Gronlund <markus.gronlund@oracle.com>
Co-authored-by: Serguei Spitsyn <serguei.spitsyn@oracle.com>
Co-authored-by: Staffan Larsen <staffan.larsen@oracle.com>
Co-authored-by: Sundararajan Athijegannathan <sundararajan.athijegannathan@oracle.com>
Reviewed-by: acorn, ccheung, coleenp, ctornqvi, dholmes, dsimms, gtriantafill, iklam, jiangli, mgronlun, mseledtsov, cjplummer, sspitsyn, stefank, twisti, hseigel, lfoltan, alanb, mchung, dfazunen
2016-03-17 19:04:01 +00:00
|
|
|
_package_entry = loader_data->packages()->lookup(pkg_name,
|
2017-04-18 13:19:42 -04:00
|
|
|
loader_data->unnamed_module());
|
8142968: Module System implementation
Initial integration of JEP 200, JEP 260, JEP 261, and JEP 282
Co-authored-by: Alex Buckley <alex.buckley@oracle.com>
Co-authored-by: Jonathan Gibbons <jonathan.gibbons@oracle.com>
Co-authored-by: Karen Kinnear <karen.kinnear@oracle.com>
Co-authored-by: Mandy Chung <mandy.chung@oracle.com>
Co-authored-by: Mark Reinhold <mark.reinhold@oracle.com>
Co-authored-by: Harold Seigel <harold.seigel@oracle.com>
Co-authored-by: Lois Foltan <lois.foltan@oracle.com>
Co-authored-by: Calvin Cheung <calvin.cheung@oracle.com>
Co-authored-by: Christian Tornqvist <christian.tornqvist@oracle.com>
Co-authored-by: Erik Joelsson <erik.joelsson@oracle.com>
Co-authored-by: George Triantafillou <george.triantafillou@oracle.com>
Co-authored-by: Igor Ignatyev <igor.ignatyev@oracle.com>
Co-authored-by: Ioi Lam <ioi.lam@oracle.com>
Co-authored-by: James Laskey <james.laskey@oracle.com>
Co-authored-by: Jean-Francois Denise <jean-francois.denise@oracle.com>
Co-authored-by: Jiangli Zhou <jiangli.zhou@oracle.com>
Co-authored-by: Markus Gronlund <markus.gronlund@oracle.com>
Co-authored-by: Serguei Spitsyn <serguei.spitsyn@oracle.com>
Co-authored-by: Staffan Larsen <staffan.larsen@oracle.com>
Co-authored-by: Sundararajan Athijegannathan <sundararajan.athijegannathan@oracle.com>
Reviewed-by: acorn, ccheung, coleenp, ctornqvi, dholmes, dsimms, gtriantafill, iklam, jiangli, mgronlun, mseledtsov, cjplummer, sspitsyn, stefank, twisti, hseigel, lfoltan, alanb, mchung, dfazunen
2016-03-17 19:04:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// A package should have been successfully created
|
|
|
|
assert(_package_entry != NULL, "Package entry for class %s not found, loader %s",
|
2018-06-19 07:54:11 -04:00
|
|
|
name()->as_C_string(), loader_data->loader_name_and_id());
|
8142968: Module System implementation
Initial integration of JEP 200, JEP 260, JEP 261, and JEP 282
Co-authored-by: Alex Buckley <alex.buckley@oracle.com>
Co-authored-by: Jonathan Gibbons <jonathan.gibbons@oracle.com>
Co-authored-by: Karen Kinnear <karen.kinnear@oracle.com>
Co-authored-by: Mandy Chung <mandy.chung@oracle.com>
Co-authored-by: Mark Reinhold <mark.reinhold@oracle.com>
Co-authored-by: Harold Seigel <harold.seigel@oracle.com>
Co-authored-by: Lois Foltan <lois.foltan@oracle.com>
Co-authored-by: Calvin Cheung <calvin.cheung@oracle.com>
Co-authored-by: Christian Tornqvist <christian.tornqvist@oracle.com>
Co-authored-by: Erik Joelsson <erik.joelsson@oracle.com>
Co-authored-by: George Triantafillou <george.triantafillou@oracle.com>
Co-authored-by: Igor Ignatyev <igor.ignatyev@oracle.com>
Co-authored-by: Ioi Lam <ioi.lam@oracle.com>
Co-authored-by: James Laskey <james.laskey@oracle.com>
Co-authored-by: Jean-Francois Denise <jean-francois.denise@oracle.com>
Co-authored-by: Jiangli Zhou <jiangli.zhou@oracle.com>
Co-authored-by: Markus Gronlund <markus.gronlund@oracle.com>
Co-authored-by: Serguei Spitsyn <serguei.spitsyn@oracle.com>
Co-authored-by: Staffan Larsen <staffan.larsen@oracle.com>
Co-authored-by: Sundararajan Athijegannathan <sundararajan.athijegannathan@oracle.com>
Reviewed-by: acorn, ccheung, coleenp, ctornqvi, dholmes, dsimms, gtriantafill, iklam, jiangli, mgronlun, mseledtsov, cjplummer, sspitsyn, stefank, twisti, hseigel, lfoltan, alanb, mchung, dfazunen
2016-03-17 19:04:01 +00:00
|
|
|
}
|
|
|
|
|
2017-05-04 07:26:28 +00:00
|
|
|
if (log_is_enabled(Debug, module)) {
|
8142968: Module System implementation
Initial integration of JEP 200, JEP 260, JEP 261, and JEP 282
Co-authored-by: Alex Buckley <alex.buckley@oracle.com>
Co-authored-by: Jonathan Gibbons <jonathan.gibbons@oracle.com>
Co-authored-by: Karen Kinnear <karen.kinnear@oracle.com>
Co-authored-by: Mandy Chung <mandy.chung@oracle.com>
Co-authored-by: Mark Reinhold <mark.reinhold@oracle.com>
Co-authored-by: Harold Seigel <harold.seigel@oracle.com>
Co-authored-by: Lois Foltan <lois.foltan@oracle.com>
Co-authored-by: Calvin Cheung <calvin.cheung@oracle.com>
Co-authored-by: Christian Tornqvist <christian.tornqvist@oracle.com>
Co-authored-by: Erik Joelsson <erik.joelsson@oracle.com>
Co-authored-by: George Triantafillou <george.triantafillou@oracle.com>
Co-authored-by: Igor Ignatyev <igor.ignatyev@oracle.com>
Co-authored-by: Ioi Lam <ioi.lam@oracle.com>
Co-authored-by: James Laskey <james.laskey@oracle.com>
Co-authored-by: Jean-Francois Denise <jean-francois.denise@oracle.com>
Co-authored-by: Jiangli Zhou <jiangli.zhou@oracle.com>
Co-authored-by: Markus Gronlund <markus.gronlund@oracle.com>
Co-authored-by: Serguei Spitsyn <serguei.spitsyn@oracle.com>
Co-authored-by: Staffan Larsen <staffan.larsen@oracle.com>
Co-authored-by: Sundararajan Athijegannathan <sundararajan.athijegannathan@oracle.com>
Reviewed-by: acorn, ccheung, coleenp, ctornqvi, dholmes, dsimms, gtriantafill, iklam, jiangli, mgronlun, mseledtsov, cjplummer, sspitsyn, stefank, twisti, hseigel, lfoltan, alanb, mchung, dfazunen
2016-03-17 19:04:01 +00:00
|
|
|
ResourceMark rm;
|
|
|
|
ModuleEntry* m = _package_entry->module();
|
2017-05-04 07:26:28 +00:00
|
|
|
log_trace(module)("Setting package: class: %s, package: %s, loader: %s, module: %s",
|
|
|
|
external_name(),
|
|
|
|
pkg_name->as_C_string(),
|
2018-06-19 07:54:11 -04:00
|
|
|
loader_data->loader_name_and_id(),
|
2017-05-04 07:26:28 +00:00
|
|
|
(m->is_named() ? m->name()->as_C_string() : UNNAMED_MODULE));
|
8142968: Module System implementation
Initial integration of JEP 200, JEP 260, JEP 261, and JEP 282
Co-authored-by: Alex Buckley <alex.buckley@oracle.com>
Co-authored-by: Jonathan Gibbons <jonathan.gibbons@oracle.com>
Co-authored-by: Karen Kinnear <karen.kinnear@oracle.com>
Co-authored-by: Mandy Chung <mandy.chung@oracle.com>
Co-authored-by: Mark Reinhold <mark.reinhold@oracle.com>
Co-authored-by: Harold Seigel <harold.seigel@oracle.com>
Co-authored-by: Lois Foltan <lois.foltan@oracle.com>
Co-authored-by: Calvin Cheung <calvin.cheung@oracle.com>
Co-authored-by: Christian Tornqvist <christian.tornqvist@oracle.com>
Co-authored-by: Erik Joelsson <erik.joelsson@oracle.com>
Co-authored-by: George Triantafillou <george.triantafillou@oracle.com>
Co-authored-by: Igor Ignatyev <igor.ignatyev@oracle.com>
Co-authored-by: Ioi Lam <ioi.lam@oracle.com>
Co-authored-by: James Laskey <james.laskey@oracle.com>
Co-authored-by: Jean-Francois Denise <jean-francois.denise@oracle.com>
Co-authored-by: Jiangli Zhou <jiangli.zhou@oracle.com>
Co-authored-by: Markus Gronlund <markus.gronlund@oracle.com>
Co-authored-by: Serguei Spitsyn <serguei.spitsyn@oracle.com>
Co-authored-by: Staffan Larsen <staffan.larsen@oracle.com>
Co-authored-by: Sundararajan Athijegannathan <sundararajan.athijegannathan@oracle.com>
Reviewed-by: acorn, ccheung, coleenp, ctornqvi, dholmes, dsimms, gtriantafill, iklam, jiangli, mgronlun, mseledtsov, cjplummer, sspitsyn, stefank, twisti, hseigel, lfoltan, alanb, mchung, dfazunen
2016-03-17 19:04:01 +00:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
ResourceMark rm;
|
2017-05-04 07:26:28 +00:00
|
|
|
log_trace(module)("Setting package: class: %s, package: unnamed, loader: %s, module: %s",
|
|
|
|
external_name(),
|
2018-06-19 07:54:11 -04:00
|
|
|
(loader_data != NULL) ? loader_data->loader_name_and_id() : "NULL",
|
2017-05-04 07:26:28 +00:00
|
|
|
UNNAMED_MODULE);
|
8142968: Module System implementation
Initial integration of JEP 200, JEP 260, JEP 261, and JEP 282
Co-authored-by: Alex Buckley <alex.buckley@oracle.com>
Co-authored-by: Jonathan Gibbons <jonathan.gibbons@oracle.com>
Co-authored-by: Karen Kinnear <karen.kinnear@oracle.com>
Co-authored-by: Mandy Chung <mandy.chung@oracle.com>
Co-authored-by: Mark Reinhold <mark.reinhold@oracle.com>
Co-authored-by: Harold Seigel <harold.seigel@oracle.com>
Co-authored-by: Lois Foltan <lois.foltan@oracle.com>
Co-authored-by: Calvin Cheung <calvin.cheung@oracle.com>
Co-authored-by: Christian Tornqvist <christian.tornqvist@oracle.com>
Co-authored-by: Erik Joelsson <erik.joelsson@oracle.com>
Co-authored-by: George Triantafillou <george.triantafillou@oracle.com>
Co-authored-by: Igor Ignatyev <igor.ignatyev@oracle.com>
Co-authored-by: Ioi Lam <ioi.lam@oracle.com>
Co-authored-by: James Laskey <james.laskey@oracle.com>
Co-authored-by: Jean-Francois Denise <jean-francois.denise@oracle.com>
Co-authored-by: Jiangli Zhou <jiangli.zhou@oracle.com>
Co-authored-by: Markus Gronlund <markus.gronlund@oracle.com>
Co-authored-by: Serguei Spitsyn <serguei.spitsyn@oracle.com>
Co-authored-by: Staffan Larsen <staffan.larsen@oracle.com>
Co-authored-by: Sundararajan Athijegannathan <sundararajan.athijegannathan@oracle.com>
Reviewed-by: acorn, ccheung, coleenp, ctornqvi, dholmes, dsimms, gtriantafill, iklam, jiangli, mgronlun, mseledtsov, cjplummer, sspitsyn, stefank, twisti, hseigel, lfoltan, alanb, mchung, dfazunen
2016-03-17 19:04:01 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// different versions of is_same_class_package
|
|
|
|
|
|
|
|
bool InstanceKlass::is_same_class_package(const Klass* class2) const {
|
|
|
|
oop classloader1 = this->class_loader();
|
|
|
|
PackageEntry* classpkg1 = this->package();
|
2015-10-28 09:47:23 -04:00
|
|
|
if (class2->is_objArray_klass()) {
|
2012-09-29 06:40:00 -04:00
|
|
|
class2 = ObjArrayKlass::cast(class2)->bottom_klass();
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
8142968: Module System implementation
Initial integration of JEP 200, JEP 260, JEP 261, and JEP 282
Co-authored-by: Alex Buckley <alex.buckley@oracle.com>
Co-authored-by: Jonathan Gibbons <jonathan.gibbons@oracle.com>
Co-authored-by: Karen Kinnear <karen.kinnear@oracle.com>
Co-authored-by: Mandy Chung <mandy.chung@oracle.com>
Co-authored-by: Mark Reinhold <mark.reinhold@oracle.com>
Co-authored-by: Harold Seigel <harold.seigel@oracle.com>
Co-authored-by: Lois Foltan <lois.foltan@oracle.com>
Co-authored-by: Calvin Cheung <calvin.cheung@oracle.com>
Co-authored-by: Christian Tornqvist <christian.tornqvist@oracle.com>
Co-authored-by: Erik Joelsson <erik.joelsson@oracle.com>
Co-authored-by: George Triantafillou <george.triantafillou@oracle.com>
Co-authored-by: Igor Ignatyev <igor.ignatyev@oracle.com>
Co-authored-by: Ioi Lam <ioi.lam@oracle.com>
Co-authored-by: James Laskey <james.laskey@oracle.com>
Co-authored-by: Jean-Francois Denise <jean-francois.denise@oracle.com>
Co-authored-by: Jiangli Zhou <jiangli.zhou@oracle.com>
Co-authored-by: Markus Gronlund <markus.gronlund@oracle.com>
Co-authored-by: Serguei Spitsyn <serguei.spitsyn@oracle.com>
Co-authored-by: Staffan Larsen <staffan.larsen@oracle.com>
Co-authored-by: Sundararajan Athijegannathan <sundararajan.athijegannathan@oracle.com>
Reviewed-by: acorn, ccheung, coleenp, ctornqvi, dholmes, dsimms, gtriantafill, iklam, jiangli, mgronlun, mseledtsov, cjplummer, sspitsyn, stefank, twisti, hseigel, lfoltan, alanb, mchung, dfazunen
2016-03-17 19:04:01 +00:00
|
|
|
|
2015-12-08 20:04:03 +01:00
|
|
|
oop classloader2;
|
8142968: Module System implementation
Initial integration of JEP 200, JEP 260, JEP 261, and JEP 282
Co-authored-by: Alex Buckley <alex.buckley@oracle.com>
Co-authored-by: Jonathan Gibbons <jonathan.gibbons@oracle.com>
Co-authored-by: Karen Kinnear <karen.kinnear@oracle.com>
Co-authored-by: Mandy Chung <mandy.chung@oracle.com>
Co-authored-by: Mark Reinhold <mark.reinhold@oracle.com>
Co-authored-by: Harold Seigel <harold.seigel@oracle.com>
Co-authored-by: Lois Foltan <lois.foltan@oracle.com>
Co-authored-by: Calvin Cheung <calvin.cheung@oracle.com>
Co-authored-by: Christian Tornqvist <christian.tornqvist@oracle.com>
Co-authored-by: Erik Joelsson <erik.joelsson@oracle.com>
Co-authored-by: George Triantafillou <george.triantafillou@oracle.com>
Co-authored-by: Igor Ignatyev <igor.ignatyev@oracle.com>
Co-authored-by: Ioi Lam <ioi.lam@oracle.com>
Co-authored-by: James Laskey <james.laskey@oracle.com>
Co-authored-by: Jean-Francois Denise <jean-francois.denise@oracle.com>
Co-authored-by: Jiangli Zhou <jiangli.zhou@oracle.com>
Co-authored-by: Markus Gronlund <markus.gronlund@oracle.com>
Co-authored-by: Serguei Spitsyn <serguei.spitsyn@oracle.com>
Co-authored-by: Staffan Larsen <staffan.larsen@oracle.com>
Co-authored-by: Sundararajan Athijegannathan <sundararajan.athijegannathan@oracle.com>
Reviewed-by: acorn, ccheung, coleenp, ctornqvi, dholmes, dsimms, gtriantafill, iklam, jiangli, mgronlun, mseledtsov, cjplummer, sspitsyn, stefank, twisti, hseigel, lfoltan, alanb, mchung, dfazunen
2016-03-17 19:04:01 +00:00
|
|
|
PackageEntry* classpkg2;
|
2015-12-08 20:04:03 +01:00
|
|
|
if (class2->is_instance_klass()) {
|
8142968: Module System implementation
Initial integration of JEP 200, JEP 260, JEP 261, and JEP 282
Co-authored-by: Alex Buckley <alex.buckley@oracle.com>
Co-authored-by: Jonathan Gibbons <jonathan.gibbons@oracle.com>
Co-authored-by: Karen Kinnear <karen.kinnear@oracle.com>
Co-authored-by: Mandy Chung <mandy.chung@oracle.com>
Co-authored-by: Mark Reinhold <mark.reinhold@oracle.com>
Co-authored-by: Harold Seigel <harold.seigel@oracle.com>
Co-authored-by: Lois Foltan <lois.foltan@oracle.com>
Co-authored-by: Calvin Cheung <calvin.cheung@oracle.com>
Co-authored-by: Christian Tornqvist <christian.tornqvist@oracle.com>
Co-authored-by: Erik Joelsson <erik.joelsson@oracle.com>
Co-authored-by: George Triantafillou <george.triantafillou@oracle.com>
Co-authored-by: Igor Ignatyev <igor.ignatyev@oracle.com>
Co-authored-by: Ioi Lam <ioi.lam@oracle.com>
Co-authored-by: James Laskey <james.laskey@oracle.com>
Co-authored-by: Jean-Francois Denise <jean-francois.denise@oracle.com>
Co-authored-by: Jiangli Zhou <jiangli.zhou@oracle.com>
Co-authored-by: Markus Gronlund <markus.gronlund@oracle.com>
Co-authored-by: Serguei Spitsyn <serguei.spitsyn@oracle.com>
Co-authored-by: Staffan Larsen <staffan.larsen@oracle.com>
Co-authored-by: Sundararajan Athijegannathan <sundararajan.athijegannathan@oracle.com>
Reviewed-by: acorn, ccheung, coleenp, ctornqvi, dholmes, dsimms, gtriantafill, iklam, jiangli, mgronlun, mseledtsov, cjplummer, sspitsyn, stefank, twisti, hseigel, lfoltan, alanb, mchung, dfazunen
2016-03-17 19:04:01 +00:00
|
|
|
classloader2 = class2->class_loader();
|
2016-04-26 09:08:12 -04:00
|
|
|
classpkg2 = class2->package();
|
2015-12-08 20:04:03 +01:00
|
|
|
} else {
|
|
|
|
assert(class2->is_typeArray_klass(), "should be type array");
|
|
|
|
classloader2 = NULL;
|
8142968: Module System implementation
Initial integration of JEP 200, JEP 260, JEP 261, and JEP 282
Co-authored-by: Alex Buckley <alex.buckley@oracle.com>
Co-authored-by: Jonathan Gibbons <jonathan.gibbons@oracle.com>
Co-authored-by: Karen Kinnear <karen.kinnear@oracle.com>
Co-authored-by: Mandy Chung <mandy.chung@oracle.com>
Co-authored-by: Mark Reinhold <mark.reinhold@oracle.com>
Co-authored-by: Harold Seigel <harold.seigel@oracle.com>
Co-authored-by: Lois Foltan <lois.foltan@oracle.com>
Co-authored-by: Calvin Cheung <calvin.cheung@oracle.com>
Co-authored-by: Christian Tornqvist <christian.tornqvist@oracle.com>
Co-authored-by: Erik Joelsson <erik.joelsson@oracle.com>
Co-authored-by: George Triantafillou <george.triantafillou@oracle.com>
Co-authored-by: Igor Ignatyev <igor.ignatyev@oracle.com>
Co-authored-by: Ioi Lam <ioi.lam@oracle.com>
Co-authored-by: James Laskey <james.laskey@oracle.com>
Co-authored-by: Jean-Francois Denise <jean-francois.denise@oracle.com>
Co-authored-by: Jiangli Zhou <jiangli.zhou@oracle.com>
Co-authored-by: Markus Gronlund <markus.gronlund@oracle.com>
Co-authored-by: Serguei Spitsyn <serguei.spitsyn@oracle.com>
Co-authored-by: Staffan Larsen <staffan.larsen@oracle.com>
Co-authored-by: Sundararajan Athijegannathan <sundararajan.athijegannathan@oracle.com>
Reviewed-by: acorn, ccheung, coleenp, ctornqvi, dholmes, dsimms, gtriantafill, iklam, jiangli, mgronlun, mseledtsov, cjplummer, sspitsyn, stefank, twisti, hseigel, lfoltan, alanb, mchung, dfazunen
2016-03-17 19:04:01 +00:00
|
|
|
classpkg2 = NULL;
|
2015-12-08 20:04:03 +01:00
|
|
|
}
|
2007-12-01 00:00:00 +00:00
|
|
|
|
8142968: Module System implementation
Initial integration of JEP 200, JEP 260, JEP 261, and JEP 282
Co-authored-by: Alex Buckley <alex.buckley@oracle.com>
Co-authored-by: Jonathan Gibbons <jonathan.gibbons@oracle.com>
Co-authored-by: Karen Kinnear <karen.kinnear@oracle.com>
Co-authored-by: Mandy Chung <mandy.chung@oracle.com>
Co-authored-by: Mark Reinhold <mark.reinhold@oracle.com>
Co-authored-by: Harold Seigel <harold.seigel@oracle.com>
Co-authored-by: Lois Foltan <lois.foltan@oracle.com>
Co-authored-by: Calvin Cheung <calvin.cheung@oracle.com>
Co-authored-by: Christian Tornqvist <christian.tornqvist@oracle.com>
Co-authored-by: Erik Joelsson <erik.joelsson@oracle.com>
Co-authored-by: George Triantafillou <george.triantafillou@oracle.com>
Co-authored-by: Igor Ignatyev <igor.ignatyev@oracle.com>
Co-authored-by: Ioi Lam <ioi.lam@oracle.com>
Co-authored-by: James Laskey <james.laskey@oracle.com>
Co-authored-by: Jean-Francois Denise <jean-francois.denise@oracle.com>
Co-authored-by: Jiangli Zhou <jiangli.zhou@oracle.com>
Co-authored-by: Markus Gronlund <markus.gronlund@oracle.com>
Co-authored-by: Serguei Spitsyn <serguei.spitsyn@oracle.com>
Co-authored-by: Staffan Larsen <staffan.larsen@oracle.com>
Co-authored-by: Sundararajan Athijegannathan <sundararajan.athijegannathan@oracle.com>
Reviewed-by: acorn, ccheung, coleenp, ctornqvi, dholmes, dsimms, gtriantafill, iklam, jiangli, mgronlun, mseledtsov, cjplummer, sspitsyn, stefank, twisti, hseigel, lfoltan, alanb, mchung, dfazunen
2016-03-17 19:04:01 +00:00
|
|
|
// Same package is determined by comparing class loader
|
|
|
|
// and package entries. Both must be the same. This rule
|
|
|
|
// applies even to classes that are defined in the unnamed
|
|
|
|
// package, they still must have the same class loader.
|
2018-04-03 13:15:27 +02:00
|
|
|
if (oopDesc::equals(classloader1, classloader2) && (classpkg1 == classpkg2)) {
|
8142968: Module System implementation
Initial integration of JEP 200, JEP 260, JEP 261, and JEP 282
Co-authored-by: Alex Buckley <alex.buckley@oracle.com>
Co-authored-by: Jonathan Gibbons <jonathan.gibbons@oracle.com>
Co-authored-by: Karen Kinnear <karen.kinnear@oracle.com>
Co-authored-by: Mandy Chung <mandy.chung@oracle.com>
Co-authored-by: Mark Reinhold <mark.reinhold@oracle.com>
Co-authored-by: Harold Seigel <harold.seigel@oracle.com>
Co-authored-by: Lois Foltan <lois.foltan@oracle.com>
Co-authored-by: Calvin Cheung <calvin.cheung@oracle.com>
Co-authored-by: Christian Tornqvist <christian.tornqvist@oracle.com>
Co-authored-by: Erik Joelsson <erik.joelsson@oracle.com>
Co-authored-by: George Triantafillou <george.triantafillou@oracle.com>
Co-authored-by: Igor Ignatyev <igor.ignatyev@oracle.com>
Co-authored-by: Ioi Lam <ioi.lam@oracle.com>
Co-authored-by: James Laskey <james.laskey@oracle.com>
Co-authored-by: Jean-Francois Denise <jean-francois.denise@oracle.com>
Co-authored-by: Jiangli Zhou <jiangli.zhou@oracle.com>
Co-authored-by: Markus Gronlund <markus.gronlund@oracle.com>
Co-authored-by: Serguei Spitsyn <serguei.spitsyn@oracle.com>
Co-authored-by: Staffan Larsen <staffan.larsen@oracle.com>
Co-authored-by: Sundararajan Athijegannathan <sundararajan.athijegannathan@oracle.com>
Reviewed-by: acorn, ccheung, coleenp, ctornqvi, dholmes, dsimms, gtriantafill, iklam, jiangli, mgronlun, mseledtsov, cjplummer, sspitsyn, stefank, twisti, hseigel, lfoltan, alanb, mchung, dfazunen
2016-03-17 19:04:01 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
|
|
|
|
2017-07-20 11:01:20 -04:00
|
|
|
// return true if this class and other_class are in the same package. Classloader
|
|
|
|
// and classname information is enough to determine a class's package
|
2015-12-08 20:04:03 +01:00
|
|
|
bool InstanceKlass::is_same_class_package(oop other_class_loader,
|
|
|
|
const Symbol* other_class_name) const {
|
2018-04-03 13:15:27 +02:00
|
|
|
if (!oopDesc::equals(class_loader(), other_class_loader)) {
|
2007-12-01 00:00:00 +00:00
|
|
|
return false;
|
2017-07-20 11:01:20 -04:00
|
|
|
}
|
|
|
|
if (name()->fast_compare(other_class_name) == 0) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
{
|
2007-12-01 00:00:00 +00:00
|
|
|
ResourceMark rm;
|
|
|
|
|
2016-06-07 11:39:47 -04:00
|
|
|
bool bad_class_name = false;
|
2017-07-20 11:01:20 -04:00
|
|
|
const char* other_pkg =
|
|
|
|
ClassLoader::package_from_name((const char*) other_class_name->as_C_string(), &bad_class_name);
|
2016-06-07 11:39:47 -04:00
|
|
|
if (bad_class_name) {
|
|
|
|
return false;
|
|
|
|
}
|
2017-07-20 11:01:20 -04:00
|
|
|
// Check that package_from_name() returns NULL, not "", if there is no package.
|
|
|
|
assert(other_pkg == NULL || strlen(other_pkg) > 0, "package name is empty string");
|
2007-12-01 00:00:00 +00:00
|
|
|
|
2017-07-20 11:01:20 -04:00
|
|
|
const Symbol* const this_package_name =
|
|
|
|
this->package() != NULL ? this->package()->name() : NULL;
|
2007-12-01 00:00:00 +00:00
|
|
|
|
2017-07-20 11:01:20 -04:00
|
|
|
if (this_package_name == NULL || other_pkg == NULL) {
|
|
|
|
// One of the two doesn't have a package. Only return true if the other
|
|
|
|
// one also doesn't have a package.
|
|
|
|
return (const char*)this_package_name == other_pkg;
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
8142968: Module System implementation
Initial integration of JEP 200, JEP 260, JEP 261, and JEP 282
Co-authored-by: Alex Buckley <alex.buckley@oracle.com>
Co-authored-by: Jonathan Gibbons <jonathan.gibbons@oracle.com>
Co-authored-by: Karen Kinnear <karen.kinnear@oracle.com>
Co-authored-by: Mandy Chung <mandy.chung@oracle.com>
Co-authored-by: Mark Reinhold <mark.reinhold@oracle.com>
Co-authored-by: Harold Seigel <harold.seigel@oracle.com>
Co-authored-by: Lois Foltan <lois.foltan@oracle.com>
Co-authored-by: Calvin Cheung <calvin.cheung@oracle.com>
Co-authored-by: Christian Tornqvist <christian.tornqvist@oracle.com>
Co-authored-by: Erik Joelsson <erik.joelsson@oracle.com>
Co-authored-by: George Triantafillou <george.triantafillou@oracle.com>
Co-authored-by: Igor Ignatyev <igor.ignatyev@oracle.com>
Co-authored-by: Ioi Lam <ioi.lam@oracle.com>
Co-authored-by: James Laskey <james.laskey@oracle.com>
Co-authored-by: Jean-Francois Denise <jean-francois.denise@oracle.com>
Co-authored-by: Jiangli Zhou <jiangli.zhou@oracle.com>
Co-authored-by: Markus Gronlund <markus.gronlund@oracle.com>
Co-authored-by: Serguei Spitsyn <serguei.spitsyn@oracle.com>
Co-authored-by: Staffan Larsen <staffan.larsen@oracle.com>
Co-authored-by: Sundararajan Athijegannathan <sundararajan.athijegannathan@oracle.com>
Reviewed-by: acorn, ccheung, coleenp, ctornqvi, dholmes, dsimms, gtriantafill, iklam, jiangli, mgronlun, mseledtsov, cjplummer, sspitsyn, stefank, twisti, hseigel, lfoltan, alanb, mchung, dfazunen
2016-03-17 19:04:01 +00:00
|
|
|
|
2017-07-20 11:01:20 -04:00
|
|
|
// Check if package is identical
|
|
|
|
return this_package_name->equals(other_pkg);
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-03-18 17:20:57 -04:00
|
|
|
// Returns true iff super_method can be overridden by a method in targetclassname
|
2016-06-07 11:39:47 -04:00
|
|
|
// See JLS 3rd edition 8.4.6.1
|
2009-03-18 17:20:57 -04:00
|
|
|
// Assumes name-signature match
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
// "this" is InstanceKlass of super_method which must exist
|
|
|
|
// note that the InstanceKlass of the method in the targetclassname has not always been created yet
|
2015-10-23 16:48:38 -04:00
|
|
|
bool InstanceKlass::is_override(const methodHandle& super_method, Handle targetclassloader, Symbol* targetclassname, TRAPS) {
|
2009-03-18 17:20:57 -04:00
|
|
|
// Private methods can not be overridden
|
|
|
|
if (super_method->is_private()) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
// If super method is accessible, then override
|
|
|
|
if ((super_method->is_protected()) ||
|
|
|
|
(super_method->is_public())) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
// Package-private methods are not inherited outside of package
|
|
|
|
assert(super_method->is_package_private(), "must be package private");
|
2011-01-27 16:11:27 -08:00
|
|
|
return(is_same_class_package(targetclassloader(), targetclassname));
|
2009-03-18 17:20:57 -04:00
|
|
|
}
|
2007-12-01 00:00:00 +00:00
|
|
|
|
2016-07-27 08:31:48 -04:00
|
|
|
// Only boot and platform class loaders can define classes in "java/" packages.
|
|
|
|
void InstanceKlass::check_prohibited_package(Symbol* class_name,
|
2018-06-19 07:54:11 -04:00
|
|
|
ClassLoaderData* loader_data,
|
2016-12-01 08:56:41 +00:00
|
|
|
TRAPS) {
|
2018-06-19 07:54:11 -04:00
|
|
|
if (!loader_data->is_boot_class_loader_data() &&
|
|
|
|
!loader_data->is_platform_class_loader_data() &&
|
2017-03-22 16:26:09 +00:00
|
|
|
class_name != NULL) {
|
|
|
|
ResourceMark rm(THREAD);
|
|
|
|
char* name = class_name->as_C_string();
|
|
|
|
if (strncmp(name, JAVAPKG, JAVAPKG_LEN) == 0 && name[JAVAPKG_LEN] == '/') {
|
|
|
|
TempNewSymbol pkg_name = InstanceKlass::package_from_name(class_name, CHECK);
|
|
|
|
assert(pkg_name != NULL, "Error in parsing package name starting with 'java/'");
|
|
|
|
name = pkg_name->as_C_string();
|
2018-06-19 07:54:11 -04:00
|
|
|
const char* class_loader_name = loader_data->loader_name_and_id();
|
2017-03-22 16:26:09 +00:00
|
|
|
StringUtils::replace_no_expand(name, "/", ".");
|
|
|
|
const char* msg_text1 = "Class loader (instance of): ";
|
|
|
|
const char* msg_text2 = " tried to load prohibited package name: ";
|
|
|
|
size_t len = strlen(msg_text1) + strlen(class_loader_name) + strlen(msg_text2) + strlen(name) + 1;
|
|
|
|
char* message = NEW_RESOURCE_ARRAY_IN_THREAD(THREAD, char, len);
|
|
|
|
jio_snprintf(message, len, "%s%s%s%s", msg_text1, class_loader_name, msg_text2, name);
|
|
|
|
THROW_MSG(vmSymbols::java_lang_SecurityException(), message);
|
|
|
|
}
|
2016-07-27 08:31:48 -04:00
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2017-03-21 11:25:18 -04:00
|
|
|
bool InstanceKlass::find_inner_classes_attr(int* ooff, int* noff, TRAPS) const {
|
|
|
|
constantPoolHandle i_cp(THREAD, constants());
|
|
|
|
for (InnerClassesIterator iter(this); !iter.done(); iter.next()) {
|
2015-04-14 18:03:43 +03:00
|
|
|
int ioff = iter.inner_class_info_index();
|
|
|
|
if (ioff != 0) {
|
|
|
|
// Check to see if the name matches the class we're looking for
|
|
|
|
// before attempting to find the class.
|
2017-03-21 11:25:18 -04:00
|
|
|
if (i_cp->klass_name_at_matches(this, ioff)) {
|
2015-04-14 18:03:43 +03:00
|
|
|
Klass* inner_klass = i_cp->klass_at(ioff, CHECK_false);
|
2017-03-21 11:25:18 -04:00
|
|
|
if (this == inner_klass) {
|
2015-04-14 18:03:43 +03:00
|
|
|
*ooff = iter.outer_class_info_index();
|
|
|
|
*noff = iter.inner_name_index();
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2017-03-21 11:25:18 -04:00
|
|
|
InstanceKlass* InstanceKlass::compute_enclosing_class(bool* inner_is_member, TRAPS) const {
|
2015-12-08 20:04:03 +01:00
|
|
|
InstanceKlass* outer_klass = NULL;
|
2015-04-14 18:03:43 +03:00
|
|
|
*inner_is_member = false;
|
|
|
|
int ooff = 0, noff = 0;
|
2017-03-21 11:25:18 -04:00
|
|
|
bool has_inner_classes_attr = find_inner_classes_attr(&ooff, &noff, THREAD);
|
|
|
|
if (has_inner_classes_attr) {
|
|
|
|
constantPoolHandle i_cp(THREAD, constants());
|
2015-04-14 18:03:43 +03:00
|
|
|
if (ooff != 0) {
|
|
|
|
Klass* ok = i_cp->klass_at(ooff, CHECK_NULL);
|
2015-12-08 20:04:03 +01:00
|
|
|
outer_klass = InstanceKlass::cast(ok);
|
2015-04-14 18:03:43 +03:00
|
|
|
*inner_is_member = true;
|
|
|
|
}
|
2015-12-08 20:04:03 +01:00
|
|
|
if (NULL == outer_klass) {
|
2018-08-20 08:25:57 -04:00
|
|
|
// It may be unsafe anonymous; try for that.
|
2017-03-21 11:25:18 -04:00
|
|
|
int encl_method_class_idx = enclosing_method_class_index();
|
2015-04-14 18:03:43 +03:00
|
|
|
if (encl_method_class_idx != 0) {
|
|
|
|
Klass* ok = i_cp->klass_at(encl_method_class_idx, CHECK_NULL);
|
2015-12-08 20:04:03 +01:00
|
|
|
outer_klass = InstanceKlass::cast(ok);
|
2015-04-14 18:03:43 +03:00
|
|
|
*inner_is_member = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// If no inner class attribute found for this class.
|
2015-12-08 20:04:03 +01:00
|
|
|
if (NULL == outer_klass) return NULL;
|
2015-04-14 18:03:43 +03:00
|
|
|
|
|
|
|
// Throws an exception if outer klass has not declared k as an inner klass
|
|
|
|
// We need evidence that each klass knows about the other, or else
|
|
|
|
// the system could allow a spoof of an inner class to gain access rights.
|
2017-03-21 11:25:18 -04:00
|
|
|
Reflection::check_for_inner_class(outer_klass, this, *inner_is_member, CHECK_NULL);
|
2015-12-08 20:04:03 +01:00
|
|
|
return outer_klass;
|
2015-04-14 18:03:43 +03:00
|
|
|
}
|
2007-12-01 00:00:00 +00:00
|
|
|
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
jint InstanceKlass::compute_modifier_flags(TRAPS) const {
|
2007-12-01 00:00:00 +00:00
|
|
|
jint access = access_flags().as_int();
|
|
|
|
|
|
|
|
// But check if it happens to be member class.
|
2017-03-15 10:25:37 -04:00
|
|
|
InnerClassesIterator iter(this);
|
2012-03-13 13:50:48 -04:00
|
|
|
for (; !iter.done(); iter.next()) {
|
|
|
|
int ioff = iter.inner_class_info_index();
|
|
|
|
// Inner class attribute can be zero, skip it.
|
|
|
|
// Strange but true: JVM spec. allows null inner class refs.
|
|
|
|
if (ioff == 0) continue;
|
|
|
|
|
|
|
|
// only look at classes that are already loaded
|
|
|
|
// since we are looking for the flags for our self.
|
2017-03-15 10:25:37 -04:00
|
|
|
Symbol* inner_name = constants()->klass_name_at(ioff);
|
|
|
|
if (name() == inner_name) {
|
2012-03-13 13:50:48 -04:00
|
|
|
// This is really a member class.
|
|
|
|
access = iter.inner_access_flags();
|
|
|
|
break;
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
// Remember to strip ACC_SUPER bit
|
|
|
|
return (access & (~JVM_ACC_SUPER)) & JVM_ACC_WRITTEN_FLAGS;
|
|
|
|
}
|
|
|
|
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
jint InstanceKlass::jvmti_class_status() const {
|
2007-12-01 00:00:00 +00:00
|
|
|
jint result = 0;
|
|
|
|
|
|
|
|
if (is_linked()) {
|
|
|
|
result |= JVMTI_CLASS_STATUS_VERIFIED | JVMTI_CLASS_STATUS_PREPARED;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (is_initialized()) {
|
|
|
|
assert(is_linked(), "Class status is not consistent");
|
|
|
|
result |= JVMTI_CLASS_STATUS_INITIALIZED;
|
|
|
|
}
|
|
|
|
if (is_in_error_state()) {
|
|
|
|
result |= JVMTI_CLASS_STATUS_ERROR;
|
|
|
|
}
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
Method* InstanceKlass::method_at_itable(Klass* holder, int index, TRAPS) {
|
2007-12-01 00:00:00 +00:00
|
|
|
itableOffsetEntry* ioe = (itableOffsetEntry*)start_of_itable();
|
|
|
|
int method_table_offset_in_words = ioe->offset()/wordSize;
|
|
|
|
int nof_interfaces = (method_table_offset_in_words - itable_offset_in_words())
|
|
|
|
/ itableOffsetEntry::size();
|
|
|
|
|
|
|
|
for (int cnt = 0 ; ; cnt ++, ioe ++) {
|
2009-02-27 13:27:09 -08:00
|
|
|
// If the interface isn't implemented by the receiver class,
|
2007-12-01 00:00:00 +00:00
|
|
|
// the VM should throw IncompatibleClassChangeError.
|
|
|
|
if (cnt >= nof_interfaces) {
|
2018-06-15 12:31:28 +02:00
|
|
|
ResourceMark rm(THREAD);
|
|
|
|
stringStream ss;
|
2018-06-25 11:33:11 -04:00
|
|
|
bool same_module = (module() == holder->module());
|
2018-06-15 12:31:28 +02:00
|
|
|
ss.print("Receiver class %s does not implement "
|
2018-06-25 11:33:11 -04:00
|
|
|
"the interface %s defining the method to be called "
|
|
|
|
"(%s%s%s)",
|
|
|
|
external_name(), holder->external_name(),
|
|
|
|
(same_module) ? joint_in_module_of_loader(holder) : class_in_module_of_loader(),
|
|
|
|
(same_module) ? "" : "; ",
|
|
|
|
(same_module) ? "" : holder->class_in_module_of_loader());
|
2018-06-15 12:31:28 +02:00
|
|
|
THROW_MSG_NULL(vmSymbols::java_lang_IncompatibleClassChangeError(), ss.as_string());
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
|
|
|
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
Klass* ik = ioe->interface_klass();
|
2007-12-01 00:00:00 +00:00
|
|
|
if (ik == holder) break;
|
|
|
|
}
|
|
|
|
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
itableMethodEntry* ime = ioe->first_method_entry(this);
|
|
|
|
Method* m = ime[index].method();
|
2007-12-01 00:00:00 +00:00
|
|
|
if (m == NULL) {
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
THROW_NULL(vmSymbols::java_lang_AbstractMethodError());
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
|
|
|
return m;
|
|
|
|
}
|
|
|
|
|
2013-10-07 12:20:28 -04:00
|
|
|
|
|
|
|
#if INCLUDE_JVMTI
|
|
|
|
// update default_methods for redefineclasses for methods that are
|
|
|
|
// not yet in the vtable due to concurrent subclass define and superinterface
|
|
|
|
// redefinition
|
|
|
|
// Note: those in the vtable, should have been updated via adjust_method_entries
|
2019-02-22 13:56:08 -05:00
|
|
|
void InstanceKlass::adjust_default_methods(bool* trace_name_printed) {
|
2013-10-07 12:20:28 -04:00
|
|
|
// search the default_methods for uses of either obsolete or EMCP methods
|
|
|
|
if (default_methods() != NULL) {
|
2015-02-25 00:30:54 -08:00
|
|
|
for (int index = 0; index < default_methods()->length(); index ++) {
|
|
|
|
Method* old_method = default_methods()->at(index);
|
2019-02-22 13:56:08 -05:00
|
|
|
if (old_method == NULL || !old_method->is_old()) {
|
2015-02-25 00:30:54 -08:00
|
|
|
continue; // skip uninteresting entries
|
|
|
|
}
|
|
|
|
assert(!old_method->is_deleted(), "default methods may not be deleted");
|
2019-02-22 13:56:08 -05:00
|
|
|
Method* new_method = old_method->get_new_method();
|
2015-02-25 00:30:54 -08:00
|
|
|
default_methods()->at_put(index, new_method);
|
2019-02-22 13:56:08 -05:00
|
|
|
|
2016-05-09 22:22:15 +02:00
|
|
|
if (log_is_enabled(Info, redefine, class, update)) {
|
|
|
|
ResourceMark rm;
|
2015-02-25 00:30:54 -08:00
|
|
|
if (!(*trace_name_printed)) {
|
2016-05-09 22:22:15 +02:00
|
|
|
log_info(redefine, class, update)
|
|
|
|
("adjust: klassname=%s default methods from name=%s",
|
|
|
|
external_name(), old_method->method_holder()->external_name());
|
2015-02-25 00:30:54 -08:00
|
|
|
*trace_name_printed = true;
|
2013-10-07 12:20:28 -04:00
|
|
|
}
|
2016-05-09 22:22:15 +02:00
|
|
|
log_debug(redefine, class, update, vtables)
|
|
|
|
("default method update: %s(%s) ",
|
|
|
|
new_method->name()->as_C_string(), new_method->signature()->as_C_string());
|
2013-10-07 12:20:28 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif // INCLUDE_JVMTI
|
|
|
|
|
2007-12-01 00:00:00 +00:00
|
|
|
// On-stack replacement stuff
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
void InstanceKlass::add_osr_nmethod(nmethod* n) {
|
2007-12-01 00:00:00 +00:00
|
|
|
// only one compilation can be active
|
2014-10-16 12:57:04 +02:00
|
|
|
{
|
|
|
|
// This is a short non-blocking critical region, so the no safepoint check is ok.
|
|
|
|
MutexLockerEx ml(OsrList_lock, Mutex::_no_safepoint_check_flag);
|
|
|
|
assert(n->is_osr_method(), "wrong kind of nmethod");
|
|
|
|
n->set_osr_link(osr_nmethods_head());
|
|
|
|
set_osr_nmethods_head(n);
|
|
|
|
// Raise the highest osr level if necessary
|
|
|
|
if (TieredCompilation) {
|
|
|
|
Method* m = n->method();
|
|
|
|
m->set_highest_osr_comp_level(MAX2(m->highest_osr_comp_level(), n->comp_level()));
|
|
|
|
}
|
2010-09-03 17:51:07 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
// Get rid of the osr methods for the same bci that have lower levels.
|
|
|
|
if (TieredCompilation) {
|
|
|
|
for (int l = CompLevel_limited_profile; l < n->comp_level(); l++) {
|
|
|
|
nmethod *inv = lookup_osr_nmethod(n->method(), n->osr_entry_bci(), l, true);
|
|
|
|
if (inv != NULL && inv->is_in_use()) {
|
|
|
|
inv->make_not_entrant();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
|
|
|
|
2016-03-18 09:32:29 +01:00
|
|
|
// Remove osr nmethod from the list. Return true if found and removed.
|
|
|
|
bool InstanceKlass::remove_osr_nmethod(nmethod* n) {
|
2007-12-01 00:00:00 +00:00
|
|
|
// This is a short non-blocking critical region, so the no safepoint check is ok.
|
2014-10-16 12:57:04 +02:00
|
|
|
MutexLockerEx ml(OsrList_lock, Mutex::_no_safepoint_check_flag);
|
2007-12-01 00:00:00 +00:00
|
|
|
assert(n->is_osr_method(), "wrong kind of nmethod");
|
|
|
|
nmethod* last = NULL;
|
|
|
|
nmethod* cur = osr_nmethods_head();
|
2010-09-03 17:51:07 -07:00
|
|
|
int max_level = CompLevel_none; // Find the max comp level excluding n
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
Method* m = n->method();
|
2007-12-01 00:00:00 +00:00
|
|
|
// Search for match
|
2016-03-18 09:32:29 +01:00
|
|
|
bool found = false;
|
2007-12-01 00:00:00 +00:00
|
|
|
while(cur != NULL && cur != n) {
|
2014-02-11 13:29:53 +01:00
|
|
|
if (TieredCompilation && m == cur->method()) {
|
2010-09-03 17:51:07 -07:00
|
|
|
// Find max level before n
|
|
|
|
max_level = MAX2(max_level, cur->comp_level());
|
|
|
|
}
|
2007-12-01 00:00:00 +00:00
|
|
|
last = cur;
|
2009-09-15 21:53:47 -07:00
|
|
|
cur = cur->osr_link();
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
2010-09-03 17:51:07 -07:00
|
|
|
nmethod* next = NULL;
|
2007-12-01 00:00:00 +00:00
|
|
|
if (cur == n) {
|
2016-03-18 09:32:29 +01:00
|
|
|
found = true;
|
2010-09-03 17:51:07 -07:00
|
|
|
next = cur->osr_link();
|
2007-12-01 00:00:00 +00:00
|
|
|
if (last == NULL) {
|
|
|
|
// Remove first element
|
2010-09-03 17:51:07 -07:00
|
|
|
set_osr_nmethods_head(next);
|
2007-12-01 00:00:00 +00:00
|
|
|
} else {
|
2010-09-03 17:51:07 -07:00
|
|
|
last->set_osr_link(next);
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
|
|
|
}
|
2009-09-15 21:53:47 -07:00
|
|
|
n->set_osr_link(NULL);
|
2010-09-03 17:51:07 -07:00
|
|
|
if (TieredCompilation) {
|
|
|
|
cur = next;
|
|
|
|
while (cur != NULL) {
|
|
|
|
// Find max level after n
|
2014-02-11 13:29:53 +01:00
|
|
|
if (m == cur->method()) {
|
|
|
|
max_level = MAX2(max_level, cur->comp_level());
|
|
|
|
}
|
2010-09-03 17:51:07 -07:00
|
|
|
cur = cur->osr_link();
|
|
|
|
}
|
|
|
|
m->set_highest_osr_comp_level(max_level);
|
|
|
|
}
|
2016-03-18 09:32:29 +01:00
|
|
|
return found;
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
|
|
|
|
2014-10-30 13:03:30 +01:00
|
|
|
int InstanceKlass::mark_osr_nmethods(const Method* m) {
|
|
|
|
// This is a short non-blocking critical region, so the no safepoint check is ok.
|
|
|
|
MutexLockerEx ml(OsrList_lock, Mutex::_no_safepoint_check_flag);
|
|
|
|
nmethod* osr = osr_nmethods_head();
|
|
|
|
int found = 0;
|
|
|
|
while (osr != NULL) {
|
|
|
|
assert(osr->is_osr_method(), "wrong kind of nmethod found in chain");
|
|
|
|
if (osr->method() == m) {
|
|
|
|
osr->mark_for_deoptimization();
|
|
|
|
found++;
|
|
|
|
}
|
|
|
|
osr = osr->osr_link();
|
|
|
|
}
|
|
|
|
return found;
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
|
|
|
|
2013-05-10 08:27:30 -07:00
|
|
|
nmethod* InstanceKlass::lookup_osr_nmethod(const Method* m, int bci, int comp_level, bool match_level) const {
|
2007-12-01 00:00:00 +00:00
|
|
|
// This is a short non-blocking critical region, so the no safepoint check is ok.
|
2014-10-16 12:57:04 +02:00
|
|
|
MutexLockerEx ml(OsrList_lock, Mutex::_no_safepoint_check_flag);
|
2007-12-01 00:00:00 +00:00
|
|
|
nmethod* osr = osr_nmethods_head();
|
2010-09-03 17:51:07 -07:00
|
|
|
nmethod* best = NULL;
|
2007-12-01 00:00:00 +00:00
|
|
|
while (osr != NULL) {
|
|
|
|
assert(osr->is_osr_method(), "wrong kind of nmethod found in chain");
|
2010-09-03 17:51:07 -07:00
|
|
|
// There can be a time when a c1 osr method exists but we are waiting
|
|
|
|
// for a c2 version. When c2 completes its osr nmethod we will trash
|
|
|
|
// the c1 version and only be able to find the c2 version. However
|
|
|
|
// while we overflow in the c1 code at back branches we don't want to
|
|
|
|
// try and switch to the same code as we are already running
|
|
|
|
|
2007-12-01 00:00:00 +00:00
|
|
|
if (osr->method() == m &&
|
|
|
|
(bci == InvocationEntryBci || osr->osr_entry_bci() == bci)) {
|
2010-09-03 17:51:07 -07:00
|
|
|
if (match_level) {
|
|
|
|
if (osr->comp_level() == comp_level) {
|
|
|
|
// Found a match - return it.
|
|
|
|
return osr;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if (best == NULL || (osr->comp_level() > best->comp_level())) {
|
|
|
|
if (osr->comp_level() == CompLevel_highest_tier) {
|
|
|
|
// Found the best possible - return it.
|
|
|
|
return osr;
|
|
|
|
}
|
|
|
|
best = osr;
|
|
|
|
}
|
|
|
|
}
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
2009-09-15 21:53:47 -07:00
|
|
|
osr = osr->osr_link();
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
2010-09-03 17:51:07 -07:00
|
|
|
if (best != NULL && best->comp_level() >= comp_level && match_level == false) {
|
|
|
|
return best;
|
|
|
|
}
|
2007-12-01 00:00:00 +00:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------------------------------------
|
|
|
|
// Printing
|
|
|
|
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
#ifndef PRODUCT
|
|
|
|
|
2009-03-20 23:19:36 -07:00
|
|
|
#define BULLET " - "
|
|
|
|
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
static const char* state_names[] = {
|
|
|
|
"allocated", "loaded", "linked", "being_initialized", "fully_initialized", "initialization_error"
|
|
|
|
};
|
|
|
|
|
2013-09-13 22:38:02 -04:00
|
|
|
static void print_vtable(intptr_t* start, int len, outputStream* st) {
|
|
|
|
for (int i = 0; i < len; i++) {
|
|
|
|
intptr_t e = start[i];
|
|
|
|
st->print("%d : " INTPTR_FORMAT, i, e);
|
|
|
|
if (e != 0 && ((Metadata*)e)->is_metaspace_object()) {
|
|
|
|
st->print(" ");
|
|
|
|
((Metadata*)e)->print_value_on(st);
|
|
|
|
}
|
|
|
|
st->cr();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-01-19 12:07:32 +01:00
|
|
|
static void print_vtable(vtableEntry* start, int len, outputStream* st) {
|
|
|
|
return print_vtable(reinterpret_cast<intptr_t*>(start), len, st);
|
|
|
|
}
|
|
|
|
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
void InstanceKlass::print_on(outputStream* st) const {
|
|
|
|
assert(is_klass(), "must be klass");
|
|
|
|
Klass::print_on(st);
|
|
|
|
|
|
|
|
st->print(BULLET"instance size: %d", size_helper()); st->cr();
|
|
|
|
st->print(BULLET"klass size: %d", size()); st->cr();
|
|
|
|
st->print(BULLET"access: "); access_flags().print_on(st); st->cr();
|
2014-05-09 16:50:54 -04:00
|
|
|
st->print(BULLET"state: "); st->print_cr("%s", state_names[_init_state]);
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
st->print(BULLET"name: "); name()->print_value_on(st); st->cr();
|
2018-07-31 09:55:09 -04:00
|
|
|
st->print(BULLET"super: "); Metadata::print_value_on_maybe_null(st, super()); st->cr();
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
st->print(BULLET"sub: ");
|
2018-10-31 14:38:14 -04:00
|
|
|
Klass* sub = subklass();
|
|
|
|
int n;
|
|
|
|
for (n = 0; sub != NULL; n++, sub = sub->next_sibling()) {
|
|
|
|
if (n < MaxSubklassPrintSize) {
|
|
|
|
sub->print_value_on(st);
|
|
|
|
st->print(" ");
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
}
|
2018-10-31 14:38:14 -04:00
|
|
|
}
|
|
|
|
if (n >= MaxSubklassPrintSize) st->print("(" INTX_FORMAT " more klasses...)", n - MaxSubklassPrintSize);
|
|
|
|
st->cr();
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
|
2018-10-31 14:38:14 -04:00
|
|
|
if (is_interface()) {
|
|
|
|
st->print_cr(BULLET"nof implementors: %d", nof_implementors());
|
|
|
|
if (nof_implementors() == 1) {
|
|
|
|
st->print_cr(BULLET"implementor: ");
|
|
|
|
st->print(" ");
|
|
|
|
implementor()->print_value_on(st);
|
|
|
|
st->cr();
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
}
|
|
|
|
}
|
2018-10-31 14:38:14 -04:00
|
|
|
|
2018-07-31 09:55:09 -04:00
|
|
|
st->print(BULLET"arrays: "); Metadata::print_value_on_maybe_null(st, array_klasses()); st->cr();
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
st->print(BULLET"methods: "); methods()->print_value_on(st); st->cr();
|
2013-09-13 22:38:02 -04:00
|
|
|
if (Verbose || WizardMode) {
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
Array<Method*>* method_array = methods();
|
2013-10-07 12:20:28 -04:00
|
|
|
for (int i = 0; i < method_array->length(); i++) {
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
st->print("%d : ", i); method_array->at(i)->print_value(); st->cr();
|
|
|
|
}
|
|
|
|
}
|
2013-10-07 12:20:28 -04:00
|
|
|
st->print(BULLET"method ordering: "); method_ordering()->print_value_on(st); st->cr();
|
|
|
|
st->print(BULLET"default_methods: "); default_methods()->print_value_on(st); st->cr();
|
|
|
|
if (Verbose && default_methods() != NULL) {
|
|
|
|
Array<Method*>* method_array = default_methods();
|
|
|
|
for (int i = 0; i < method_array->length(); i++) {
|
|
|
|
st->print("%d : ", i); method_array->at(i)->print_value(); st->cr();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (default_vtable_indices() != NULL) {
|
|
|
|
st->print(BULLET"default vtable indices: "); default_vtable_indices()->print_value_on(st); st->cr();
|
|
|
|
}
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
st->print(BULLET"local interfaces: "); local_interfaces()->print_value_on(st); st->cr();
|
|
|
|
st->print(BULLET"trans. interfaces: "); transitive_interfaces()->print_value_on(st); st->cr();
|
|
|
|
st->print(BULLET"constants: "); constants()->print_value_on(st); st->cr();
|
|
|
|
if (class_loader_data() != NULL) {
|
|
|
|
st->print(BULLET"class loader data: ");
|
|
|
|
class_loader_data()->print_value_on(st);
|
|
|
|
st->cr();
|
|
|
|
}
|
2018-08-20 08:25:57 -04:00
|
|
|
st->print(BULLET"unsafe anonymous host class: "); Metadata::print_value_on_maybe_null(st, unsafe_anonymous_host()); st->cr();
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
if (source_file_name() != NULL) {
|
|
|
|
st->print(BULLET"source file: ");
|
|
|
|
source_file_name()->print_value_on(st);
|
|
|
|
st->cr();
|
|
|
|
}
|
|
|
|
if (source_debug_extension() != NULL) {
|
|
|
|
st->print(BULLET"source debug extension: ");
|
|
|
|
st->print("%s", source_debug_extension());
|
|
|
|
st->cr();
|
|
|
|
}
|
2013-02-11 14:06:22 -05:00
|
|
|
st->print(BULLET"class annotations: "); class_annotations()->print_value_on(st); st->cr();
|
|
|
|
st->print(BULLET"class type annotations: "); class_type_annotations()->print_value_on(st); st->cr();
|
|
|
|
st->print(BULLET"field annotations: "); fields_annotations()->print_value_on(st); st->cr();
|
|
|
|
st->print(BULLET"field type annotations: "); fields_type_annotations()->print_value_on(st); st->cr();
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
{
|
2013-09-20 09:30:02 -04:00
|
|
|
bool have_pv = false;
|
2014-09-03 19:13:18 -04:00
|
|
|
// previous versions are linked together through the InstanceKlass
|
2016-04-21 20:49:11 -07:00
|
|
|
for (InstanceKlass* pv_node = previous_versions();
|
2014-09-03 19:13:18 -04:00
|
|
|
pv_node != NULL;
|
|
|
|
pv_node = pv_node->previous_versions()) {
|
2013-09-20 09:30:02 -04:00
|
|
|
if (!have_pv)
|
|
|
|
st->print(BULLET"previous version: ");
|
|
|
|
have_pv = true;
|
2014-09-03 19:13:18 -04:00
|
|
|
pv_node->constants()->print_value_on(st);
|
2013-09-20 09:30:02 -04:00
|
|
|
}
|
|
|
|
if (have_pv) st->cr();
|
2014-09-03 19:13:18 -04:00
|
|
|
}
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
|
|
|
|
if (generic_signature() != NULL) {
|
|
|
|
st->print(BULLET"generic signature: ");
|
|
|
|
generic_signature()->print_value_on(st);
|
|
|
|
st->cr();
|
|
|
|
}
|
|
|
|
st->print(BULLET"inner classes: "); inner_classes()->print_value_on(st); st->cr();
|
2018-06-23 01:32:41 -04:00
|
|
|
st->print(BULLET"nest members: "); nest_members()->print_value_on(st); st->cr();
|
2018-07-31 14:24:10 -04:00
|
|
|
if (java_mirror() != NULL) {
|
|
|
|
st->print(BULLET"java mirror: ");
|
|
|
|
java_mirror()->print_value_on(st);
|
|
|
|
st->cr();
|
|
|
|
} else {
|
|
|
|
st->print_cr(BULLET"java mirror: NULL");
|
|
|
|
}
|
2015-10-09 09:42:33 +02:00
|
|
|
st->print(BULLET"vtable length %d (start addr: " INTPTR_FORMAT ")", vtable_length(), p2i(start_of_vtable())); st->cr();
|
2013-09-13 22:38:02 -04:00
|
|
|
if (vtable_length() > 0 && (Verbose || WizardMode)) print_vtable(start_of_vtable(), vtable_length(), st);
|
2015-10-09 09:42:33 +02:00
|
|
|
st->print(BULLET"itable length %d (start addr: " INTPTR_FORMAT ")", itable_length(), p2i(start_of_itable())); st->cr();
|
2013-09-13 22:38:02 -04:00
|
|
|
if (itable_length() > 0 && (Verbose || WizardMode)) print_vtable(start_of_itable(), itable_length(), st);
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
st->print_cr(BULLET"---- static fields (%d words):", static_field_size());
|
|
|
|
FieldPrinter print_static_field(st);
|
|
|
|
((InstanceKlass*)this)->do_local_static_fields(&print_static_field);
|
|
|
|
st->print_cr(BULLET"---- non-static fields (%d words):", nonstatic_field_size());
|
|
|
|
FieldPrinter print_nonstatic_field(st);
|
2015-10-26 13:11:36 -04:00
|
|
|
InstanceKlass* ik = const_cast<InstanceKlass*>(this);
|
|
|
|
ik->do_nonstatic_fields(&print_nonstatic_field);
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
|
|
|
|
st->print(BULLET"non-static oop maps: ");
|
|
|
|
OopMapBlock* map = start_of_nonstatic_oop_maps();
|
|
|
|
OopMapBlock* end_map = map + nonstatic_oop_map_count();
|
|
|
|
while (map < end_map) {
|
|
|
|
st->print("%d-%d ", map->offset(), map->offset() + heapOopSize*(map->count() - 1));
|
|
|
|
map++;
|
|
|
|
}
|
|
|
|
st->cr();
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif //PRODUCT
|
|
|
|
|
|
|
|
void InstanceKlass::print_value_on(outputStream* st) const {
|
|
|
|
assert(is_klass(), "must be klass");
|
2013-09-13 22:38:02 -04:00
|
|
|
if (Verbose || WizardMode) access_flags().print_on(st);
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
name()->print_value_on(st);
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifndef PRODUCT
|
|
|
|
|
2007-12-01 00:00:00 +00:00
|
|
|
void FieldPrinter::do_field(fieldDescriptor* fd) {
|
2009-03-20 23:19:36 -07:00
|
|
|
_st->print(BULLET);
|
2011-03-18 16:00:34 -07:00
|
|
|
if (_obj == NULL) {
|
2007-12-01 00:00:00 +00:00
|
|
|
fd->print_on(_st);
|
|
|
|
_st->cr();
|
|
|
|
} else {
|
|
|
|
fd->print_on_for(_st, _obj);
|
|
|
|
_st->cr();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
void InstanceKlass::oop_print_on(oop obj, outputStream* st) {
|
2007-12-01 00:00:00 +00:00
|
|
|
Klass::oop_print_on(obj, st);
|
|
|
|
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
if (this == SystemDictionary::String_klass()) {
|
2007-12-01 00:00:00 +00:00
|
|
|
typeArrayOop value = java_lang_String::value(obj);
|
|
|
|
juint length = java_lang_String::length(obj);
|
|
|
|
if (value != NULL &&
|
|
|
|
value->is_typeArray() &&
|
8141132: JEP 254: Compact Strings
Adopt a more space-efficient internal representation for strings.
Co-authored-by: Brent Christian <brent.christian@oracle.com>
Co-authored-by: Vivek Deshpande <vivek.r.deshpande@intel.com>
Co-authored-by: Charlie Hunt <charlie.hunt@oracle.com>
Co-authored-by: Vladimir Kozlov <vladimir.kozlov@oracle.com>
Co-authored-by: Roger Riggs <roger.riggs@oracle.com>
Co-authored-by: Xueming Shen <xueming.shen@oracle.com>
Co-authored-by: Aleksey Shipilev <aleksey.shipilev@oracle.com>
Co-authored-by: Sandhya Viswanathan <sandhya.viswanathan@intel.com>
Reviewed-by: alanb, bdelsart, coleenp, iklam, jiangli, jrose, kevinw, naoto, pliden, roland, smarks, twisti
2015-11-03 09:41:03 +01:00
|
|
|
length <= (juint) value->length()) {
|
2009-03-20 23:19:36 -07:00
|
|
|
st->print(BULLET"string: ");
|
2014-02-27 10:34:55 +01:00
|
|
|
java_lang_String::print(obj, st);
|
2007-12-01 00:00:00 +00:00
|
|
|
st->cr();
|
|
|
|
if (!WizardMode) return; // that is enough
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-03-20 23:19:36 -07:00
|
|
|
st->print_cr(BULLET"---- fields (total size %d words):", oop_size(obj));
|
2011-03-18 16:00:34 -07:00
|
|
|
FieldPrinter print_field(st, obj);
|
|
|
|
do_nonstatic_fields(&print_field);
|
2007-12-01 00:00:00 +00:00
|
|
|
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
if (this == SystemDictionary::Class_klass()) {
|
2009-03-20 23:19:36 -07:00
|
|
|
st->print(BULLET"signature: ");
|
|
|
|
java_lang_Class::print_signature(obj, st);
|
|
|
|
st->cr();
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
Klass* mirrored_klass = java_lang_Class::as_Klass(obj);
|
2009-03-20 23:19:36 -07:00
|
|
|
st->print(BULLET"fake entry for mirror: ");
|
2018-07-31 09:55:09 -04:00
|
|
|
Metadata::print_value_on_maybe_null(st, mirrored_klass);
|
2007-12-01 00:00:00 +00:00
|
|
|
st->cr();
|
2017-07-26 10:41:07 -04:00
|
|
|
Klass* array_klass = java_lang_Class::array_klass_acquire(obj);
|
2009-03-20 23:19:36 -07:00
|
|
|
st->print(BULLET"fake entry for array: ");
|
2018-07-31 09:55:09 -04:00
|
|
|
Metadata::print_value_on_maybe_null(st, array_klass);
|
2007-12-01 00:00:00 +00:00
|
|
|
st->cr();
|
2011-03-18 16:00:34 -07:00
|
|
|
st->print_cr(BULLET"fake entry for oop_size: %d", java_lang_Class::oop_size(obj));
|
|
|
|
st->print_cr(BULLET"fake entry for static_oop_field_count: %d", java_lang_Class::static_oop_field_count(obj));
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
Klass* real_klass = java_lang_Class::as_Klass(obj);
|
2015-10-28 09:47:23 -04:00
|
|
|
if (real_klass != NULL && real_klass->is_instance_klass()) {
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
InstanceKlass::cast(real_klass)->do_local_static_fields(&print_field);
|
2011-03-18 16:00:34 -07:00
|
|
|
}
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
} else if (this == SystemDictionary::MethodType_klass()) {
|
2009-10-17 19:51:05 -07:00
|
|
|
st->print(BULLET"signature: ");
|
2011-03-11 22:34:57 -08:00
|
|
|
java_lang_invoke_MethodType::print_signature(obj, st);
|
2009-10-17 19:51:05 -07:00
|
|
|
st->cr();
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-08-07 15:45:07 -07:00
|
|
|
bool InstanceKlass::verify_itable_index(int i) {
|
|
|
|
int method_count = klassItable::method_count_for_interface(this);
|
|
|
|
assert(i >= 0 && i < method_count, "index out of bounds");
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2010-01-08 13:47:01 -08:00
|
|
|
#endif //PRODUCT
|
|
|
|
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
void InstanceKlass::oop_print_value_on(oop obj, outputStream* st) {
|
2007-12-01 00:00:00 +00:00
|
|
|
st->print("a ");
|
|
|
|
name()->print_value_on(st);
|
|
|
|
obj->print_address_on(st);
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
if (this == SystemDictionary::String_klass()
|
2009-03-20 23:19:36 -07:00
|
|
|
&& java_lang_String::value(obj) != NULL) {
|
|
|
|
ResourceMark rm;
|
|
|
|
int len = java_lang_String::length(obj);
|
|
|
|
int plen = (len < 24 ? len : 12);
|
|
|
|
char* str = java_lang_String::as_utf8_string(obj, 0, plen);
|
|
|
|
st->print(" = \"%s\"", str);
|
|
|
|
if (len > plen)
|
|
|
|
st->print("...[%d]", len);
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
} else if (this == SystemDictionary::Class_klass()) {
|
|
|
|
Klass* k = java_lang_Class::as_Klass(obj);
|
2009-03-20 23:19:36 -07:00
|
|
|
st->print(" = ");
|
|
|
|
if (k != NULL) {
|
|
|
|
k->print_value_on(st);
|
|
|
|
} else {
|
|
|
|
const char* tname = type2name(java_lang_Class::primitive_type(obj));
|
|
|
|
st->print("%s", tname ? tname : "type?");
|
|
|
|
}
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
} else if (this == SystemDictionary::MethodType_klass()) {
|
2009-10-17 19:51:05 -07:00
|
|
|
st->print(" = ");
|
2011-03-11 22:34:57 -08:00
|
|
|
java_lang_invoke_MethodType::print_signature(obj, st);
|
2009-03-20 23:19:36 -07:00
|
|
|
} else if (java_lang_boxing_object::is_instance(obj)) {
|
|
|
|
st->print(" = ");
|
|
|
|
java_lang_boxing_object::print(obj, st);
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
} else if (this == SystemDictionary::LambdaForm_klass()) {
|
2012-07-24 10:51:00 -07:00
|
|
|
oop vmentry = java_lang_invoke_LambdaForm::vmentry(obj);
|
|
|
|
if (vmentry != NULL) {
|
|
|
|
st->print(" => ");
|
|
|
|
vmentry->print_value_on(st);
|
|
|
|
}
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
} else if (this == SystemDictionary::MemberName_klass()) {
|
|
|
|
Metadata* vmtarget = java_lang_invoke_MemberName::vmtarget(obj);
|
2012-07-24 10:51:00 -07:00
|
|
|
if (vmtarget != NULL) {
|
|
|
|
st->print(" = ");
|
|
|
|
vmtarget->print_value_on(st);
|
|
|
|
} else {
|
|
|
|
java_lang_invoke_MemberName::clazz(obj)->print_value_on(st);
|
|
|
|
st->print(".");
|
|
|
|
java_lang_invoke_MemberName::name(obj)->print_value_on(st);
|
|
|
|
}
|
2009-03-20 23:19:36 -07:00
|
|
|
}
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
|
|
|
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
const char* InstanceKlass::internal_name() const {
|
2007-12-01 00:00:00 +00:00
|
|
|
return external_name();
|
|
|
|
}
|
|
|
|
|
2017-05-08 09:45:24 -04:00
|
|
|
void InstanceKlass::print_class_load_logging(ClassLoaderData* loader_data,
|
|
|
|
const char* module_name,
|
|
|
|
const ClassFileStream* cfs) const {
|
|
|
|
if (!log_is_enabled(Info, class, load)) {
|
|
|
|
return;
|
2016-02-03 11:40:30 -05:00
|
|
|
}
|
|
|
|
|
2017-05-08 09:45:24 -04:00
|
|
|
ResourceMark rm;
|
|
|
|
LogMessage(class, load) msg;
|
|
|
|
stringStream info_stream;
|
|
|
|
|
2016-02-03 11:40:30 -05:00
|
|
|
// Name and class hierarchy info
|
2017-05-08 09:45:24 -04:00
|
|
|
info_stream.print("%s", external_name());
|
2016-02-03 11:40:30 -05:00
|
|
|
|
|
|
|
// Source
|
|
|
|
if (cfs != NULL) {
|
|
|
|
if (cfs->source() != NULL) {
|
8142968: Module System implementation
Initial integration of JEP 200, JEP 260, JEP 261, and JEP 282
Co-authored-by: Alex Buckley <alex.buckley@oracle.com>
Co-authored-by: Jonathan Gibbons <jonathan.gibbons@oracle.com>
Co-authored-by: Karen Kinnear <karen.kinnear@oracle.com>
Co-authored-by: Mandy Chung <mandy.chung@oracle.com>
Co-authored-by: Mark Reinhold <mark.reinhold@oracle.com>
Co-authored-by: Harold Seigel <harold.seigel@oracle.com>
Co-authored-by: Lois Foltan <lois.foltan@oracle.com>
Co-authored-by: Calvin Cheung <calvin.cheung@oracle.com>
Co-authored-by: Christian Tornqvist <christian.tornqvist@oracle.com>
Co-authored-by: Erik Joelsson <erik.joelsson@oracle.com>
Co-authored-by: George Triantafillou <george.triantafillou@oracle.com>
Co-authored-by: Igor Ignatyev <igor.ignatyev@oracle.com>
Co-authored-by: Ioi Lam <ioi.lam@oracle.com>
Co-authored-by: James Laskey <james.laskey@oracle.com>
Co-authored-by: Jean-Francois Denise <jean-francois.denise@oracle.com>
Co-authored-by: Jiangli Zhou <jiangli.zhou@oracle.com>
Co-authored-by: Markus Gronlund <markus.gronlund@oracle.com>
Co-authored-by: Serguei Spitsyn <serguei.spitsyn@oracle.com>
Co-authored-by: Staffan Larsen <staffan.larsen@oracle.com>
Co-authored-by: Sundararajan Athijegannathan <sundararajan.athijegannathan@oracle.com>
Reviewed-by: acorn, ccheung, coleenp, ctornqvi, dholmes, dsimms, gtriantafill, iklam, jiangli, mgronlun, mseledtsov, cjplummer, sspitsyn, stefank, twisti, hseigel, lfoltan, alanb, mchung, dfazunen
2016-03-17 19:04:01 +00:00
|
|
|
if (module_name != NULL) {
|
2017-10-21 15:15:46 -07:00
|
|
|
if (ClassLoader::is_modules_image(cfs->source())) {
|
2017-05-08 09:45:24 -04:00
|
|
|
info_stream.print(" source: jrt:/%s", module_name);
|
2016-06-13 13:47:21 -04:00
|
|
|
} else {
|
2017-05-08 09:45:24 -04:00
|
|
|
info_stream.print(" source: %s", cfs->source());
|
2016-06-13 13:47:21 -04:00
|
|
|
}
|
8142968: Module System implementation
Initial integration of JEP 200, JEP 260, JEP 261, and JEP 282
Co-authored-by: Alex Buckley <alex.buckley@oracle.com>
Co-authored-by: Jonathan Gibbons <jonathan.gibbons@oracle.com>
Co-authored-by: Karen Kinnear <karen.kinnear@oracle.com>
Co-authored-by: Mandy Chung <mandy.chung@oracle.com>
Co-authored-by: Mark Reinhold <mark.reinhold@oracle.com>
Co-authored-by: Harold Seigel <harold.seigel@oracle.com>
Co-authored-by: Lois Foltan <lois.foltan@oracle.com>
Co-authored-by: Calvin Cheung <calvin.cheung@oracle.com>
Co-authored-by: Christian Tornqvist <christian.tornqvist@oracle.com>
Co-authored-by: Erik Joelsson <erik.joelsson@oracle.com>
Co-authored-by: George Triantafillou <george.triantafillou@oracle.com>
Co-authored-by: Igor Ignatyev <igor.ignatyev@oracle.com>
Co-authored-by: Ioi Lam <ioi.lam@oracle.com>
Co-authored-by: James Laskey <james.laskey@oracle.com>
Co-authored-by: Jean-Francois Denise <jean-francois.denise@oracle.com>
Co-authored-by: Jiangli Zhou <jiangli.zhou@oracle.com>
Co-authored-by: Markus Gronlund <markus.gronlund@oracle.com>
Co-authored-by: Serguei Spitsyn <serguei.spitsyn@oracle.com>
Co-authored-by: Staffan Larsen <staffan.larsen@oracle.com>
Co-authored-by: Sundararajan Athijegannathan <sundararajan.athijegannathan@oracle.com>
Reviewed-by: acorn, ccheung, coleenp, ctornqvi, dholmes, dsimms, gtriantafill, iklam, jiangli, mgronlun, mseledtsov, cjplummer, sspitsyn, stefank, twisti, hseigel, lfoltan, alanb, mchung, dfazunen
2016-03-17 19:04:01 +00:00
|
|
|
} else {
|
2017-05-08 09:45:24 -04:00
|
|
|
info_stream.print(" source: %s", cfs->source());
|
8142968: Module System implementation
Initial integration of JEP 200, JEP 260, JEP 261, and JEP 282
Co-authored-by: Alex Buckley <alex.buckley@oracle.com>
Co-authored-by: Jonathan Gibbons <jonathan.gibbons@oracle.com>
Co-authored-by: Karen Kinnear <karen.kinnear@oracle.com>
Co-authored-by: Mandy Chung <mandy.chung@oracle.com>
Co-authored-by: Mark Reinhold <mark.reinhold@oracle.com>
Co-authored-by: Harold Seigel <harold.seigel@oracle.com>
Co-authored-by: Lois Foltan <lois.foltan@oracle.com>
Co-authored-by: Calvin Cheung <calvin.cheung@oracle.com>
Co-authored-by: Christian Tornqvist <christian.tornqvist@oracle.com>
Co-authored-by: Erik Joelsson <erik.joelsson@oracle.com>
Co-authored-by: George Triantafillou <george.triantafillou@oracle.com>
Co-authored-by: Igor Ignatyev <igor.ignatyev@oracle.com>
Co-authored-by: Ioi Lam <ioi.lam@oracle.com>
Co-authored-by: James Laskey <james.laskey@oracle.com>
Co-authored-by: Jean-Francois Denise <jean-francois.denise@oracle.com>
Co-authored-by: Jiangli Zhou <jiangli.zhou@oracle.com>
Co-authored-by: Markus Gronlund <markus.gronlund@oracle.com>
Co-authored-by: Serguei Spitsyn <serguei.spitsyn@oracle.com>
Co-authored-by: Staffan Larsen <staffan.larsen@oracle.com>
Co-authored-by: Sundararajan Athijegannathan <sundararajan.athijegannathan@oracle.com>
Reviewed-by: acorn, ccheung, coleenp, ctornqvi, dholmes, dsimms, gtriantafill, iklam, jiangli, mgronlun, mseledtsov, cjplummer, sspitsyn, stefank, twisti, hseigel, lfoltan, alanb, mchung, dfazunen
2016-03-17 19:04:01 +00:00
|
|
|
}
|
2016-02-03 11:40:30 -05:00
|
|
|
} else if (loader_data == ClassLoaderData::the_null_class_loader_data()) {
|
|
|
|
Thread* THREAD = Thread::current();
|
|
|
|
Klass* caller =
|
|
|
|
THREAD->is_Java_thread()
|
|
|
|
? ((JavaThread*)THREAD)->security_get_caller_class(1)
|
|
|
|
: NULL;
|
|
|
|
// caller can be NULL, for example, during a JVMTI VM_Init hook
|
|
|
|
if (caller != NULL) {
|
2017-05-08 09:45:24 -04:00
|
|
|
info_stream.print(" source: instance of %s", caller->external_name());
|
2016-02-03 11:40:30 -05:00
|
|
|
} else {
|
|
|
|
// source is unknown
|
|
|
|
}
|
|
|
|
} else {
|
2017-02-15 22:59:57 -05:00
|
|
|
oop class_loader = loader_data->class_loader();
|
2017-05-08 09:45:24 -04:00
|
|
|
info_stream.print(" source: %s", class_loader->klass()->external_name());
|
2016-02-03 11:40:30 -05:00
|
|
|
}
|
|
|
|
} else {
|
2017-05-08 09:45:24 -04:00
|
|
|
info_stream.print(" source: shared objects file");
|
2016-02-03 11:40:30 -05:00
|
|
|
}
|
|
|
|
|
2017-05-08 09:45:24 -04:00
|
|
|
msg.info("%s", info_stream.as_string());
|
|
|
|
|
|
|
|
if (log_is_enabled(Debug, class, load)) {
|
|
|
|
stringStream debug_stream;
|
|
|
|
|
2016-02-03 11:40:30 -05:00
|
|
|
// Class hierarchy info
|
2017-05-08 09:45:24 -04:00
|
|
|
debug_stream.print(" klass: " INTPTR_FORMAT " super: " INTPTR_FORMAT,
|
|
|
|
p2i(this), p2i(superklass()));
|
2016-02-03 11:40:30 -05:00
|
|
|
|
2017-05-08 09:45:24 -04:00
|
|
|
// Interfaces
|
2016-02-03 11:40:30 -05:00
|
|
|
if (local_interfaces() != NULL && local_interfaces()->length() > 0) {
|
2017-05-08 09:45:24 -04:00
|
|
|
debug_stream.print(" interfaces:");
|
2016-02-03 11:40:30 -05:00
|
|
|
int length = local_interfaces()->length();
|
|
|
|
for (int i = 0; i < length; i++) {
|
2017-05-08 09:45:24 -04:00
|
|
|
debug_stream.print(" " INTPTR_FORMAT,
|
|
|
|
p2i(InstanceKlass::cast(local_interfaces()->at(i))));
|
2016-02-03 11:40:30 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Class loader
|
2017-05-08 09:45:24 -04:00
|
|
|
debug_stream.print(" loader: [");
|
|
|
|
loader_data->print_value_on(&debug_stream);
|
|
|
|
debug_stream.print("]");
|
2016-02-03 11:40:30 -05:00
|
|
|
|
|
|
|
// Classfile checksum
|
|
|
|
if (cfs) {
|
2017-05-08 09:45:24 -04:00
|
|
|
debug_stream.print(" bytes: %d checksum: %08x",
|
|
|
|
cfs->length(),
|
|
|
|
ClassLoader::crc32(0, (const char*)cfs->buffer(),
|
|
|
|
cfs->length()));
|
2016-02-03 11:40:30 -05:00
|
|
|
}
|
2017-05-08 09:45:24 -04:00
|
|
|
|
|
|
|
msg.debug("%s", debug_stream.as_string());
|
2016-02-03 11:40:30 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-01-25 15:06:18 -05:00
|
|
|
#if INCLUDE_SERVICES
|
|
|
|
// Size Statistics
|
|
|
|
void InstanceKlass::collect_statistics(KlassSizeStats *sz) const {
|
|
|
|
Klass::collect_statistics(sz);
|
|
|
|
|
2016-01-30 11:02:29 -05:00
|
|
|
sz->_inst_size = wordSize * size_helper();
|
|
|
|
sz->_vtab_bytes = wordSize * vtable_length();
|
|
|
|
sz->_itab_bytes = wordSize * itable_length();
|
|
|
|
sz->_nonstatic_oopmap_bytes = wordSize * nonstatic_oop_map_size();
|
2013-01-25 15:06:18 -05:00
|
|
|
|
|
|
|
int n = 0;
|
|
|
|
n += (sz->_methods_array_bytes = sz->count_array(methods()));
|
|
|
|
n += (sz->_method_ordering_bytes = sz->count_array(method_ordering()));
|
|
|
|
n += (sz->_local_interfaces_bytes = sz->count_array(local_interfaces()));
|
|
|
|
n += (sz->_transitive_interfaces_bytes = sz->count_array(transitive_interfaces()));
|
|
|
|
n += (sz->_fields_bytes = sz->count_array(fields()));
|
|
|
|
n += (sz->_inner_classes_bytes = sz->count_array(inner_classes()));
|
2018-06-23 01:32:41 -04:00
|
|
|
n += (sz->_nest_members_bytes = sz->count_array(nest_members()));
|
2013-01-25 15:06:18 -05:00
|
|
|
sz->_ro_bytes += n;
|
|
|
|
|
|
|
|
const ConstantPool* cp = constants();
|
|
|
|
if (cp) {
|
|
|
|
cp->collect_statistics(sz);
|
|
|
|
}
|
|
|
|
|
|
|
|
const Annotations* anno = annotations();
|
|
|
|
if (anno) {
|
|
|
|
anno->collect_statistics(sz);
|
|
|
|
}
|
|
|
|
|
|
|
|
const Array<Method*>* methods_array = methods();
|
|
|
|
if (methods()) {
|
|
|
|
for (int i = 0; i < methods_array->length(); i++) {
|
|
|
|
Method* method = methods_array->at(i);
|
|
|
|
if (method) {
|
|
|
|
sz->_method_count ++;
|
|
|
|
method->collect_statistics(sz);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif // INCLUDE_SERVICES
|
|
|
|
|
2007-12-01 00:00:00 +00:00
|
|
|
// Verification
|
|
|
|
|
2018-06-26 13:54:19 +02:00
|
|
|
class VerifyFieldClosure: public BasicOopIterateClosure {
|
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
Compressed oops in instances, arrays, and headers. Code contributors are coleenp, phh, never, swamyv
Reviewed-by: jmasa, kamg, acorn, tbell, kvn, rasbold
2008-04-13 17:43:42 -04:00
|
|
|
protected:
|
|
|
|
template <class T> void do_oop_work(T* p) {
|
2018-03-15 21:24:10 +01:00
|
|
|
oop obj = RawAccess<>::oop_load(p);
|
2017-08-23 14:52:55 -04:00
|
|
|
if (!oopDesc::is_oop_or_null(obj)) {
|
2015-10-09 09:42:33 +02:00
|
|
|
tty->print_cr("Failed: " PTR_FORMAT " -> " PTR_FORMAT, p2i(p), p2i(obj));
|
2015-12-10 14:57:55 +01:00
|
|
|
Universe::print_on(tty);
|
2007-12-01 00:00:00 +00:00
|
|
|
guarantee(false, "boom");
|
|
|
|
}
|
|
|
|
}
|
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
Compressed oops in instances, arrays, and headers. Code contributors are coleenp, phh, never, swamyv
Reviewed-by: jmasa, kamg, acorn, tbell, kvn, rasbold
2008-04-13 17:43:42 -04:00
|
|
|
public:
|
|
|
|
virtual void do_oop(oop* p) { VerifyFieldClosure::do_oop_work(p); }
|
|
|
|
virtual void do_oop(narrowOop* p) { VerifyFieldClosure::do_oop_work(p); }
|
2007-12-01 00:00:00 +00:00
|
|
|
};
|
|
|
|
|
2014-02-15 13:03:38 -05:00
|
|
|
void InstanceKlass::verify_on(outputStream* st) {
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
#ifndef PRODUCT
|
2013-06-24 18:55:46 -04:00
|
|
|
// Avoid redundant verifies, this really should be in product.
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
if (_verify_count == Universe::verify_count()) return;
|
|
|
|
_verify_count = Universe::verify_count();
|
|
|
|
#endif
|
2013-06-24 18:55:46 -04:00
|
|
|
|
|
|
|
// Verify Klass
|
2014-02-15 13:03:38 -05:00
|
|
|
Klass::verify_on(st);
|
2013-06-24 18:55:46 -04:00
|
|
|
|
2014-02-15 13:03:38 -05:00
|
|
|
// Verify that klass is present in ClassLoaderData
|
|
|
|
guarantee(class_loader_data()->contains_klass(this),
|
|
|
|
"this class isn't found in class loader data");
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
|
|
|
|
// Verify vtables
|
|
|
|
if (is_linked()) {
|
|
|
|
// $$$ This used to be done only for m/s collections. Doing it
|
|
|
|
// always seemed a valid generalization. (DLD -- 6/00)
|
2017-04-13 01:56:01 -07:00
|
|
|
vtable().verify(st);
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
}
|
|
|
|
|
2018-10-31 14:38:14 -04:00
|
|
|
// Verify first subklass
|
|
|
|
if (subklass() != NULL) {
|
|
|
|
guarantee(subklass()->is_klass(), "should be klass");
|
|
|
|
}
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
|
2018-10-31 14:38:14 -04:00
|
|
|
// Verify siblings
|
|
|
|
Klass* super = this->super();
|
|
|
|
Klass* sib = next_sibling();
|
|
|
|
if (sib != NULL) {
|
|
|
|
if (sib == this) {
|
|
|
|
fatal("subclass points to itself " PTR_FORMAT, p2i(sib));
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
}
|
|
|
|
|
2018-10-31 14:38:14 -04:00
|
|
|
guarantee(sib->is_klass(), "should be klass");
|
|
|
|
guarantee(sib->super() == super, "siblings should have same superklass");
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
// Verify local interfaces
|
|
|
|
if (local_interfaces()) {
|
2018-08-07 15:45:07 -07:00
|
|
|
Array<InstanceKlass*>* local_interfaces = this->local_interfaces();
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
for (int j = 0; j < local_interfaces->length(); j++) {
|
2018-08-07 15:45:07 -07:00
|
|
|
InstanceKlass* e = local_interfaces->at(j);
|
2012-11-12 16:15:05 -05:00
|
|
|
guarantee(e->is_klass() && e->is_interface(), "invalid local interface");
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Verify transitive interfaces
|
|
|
|
if (transitive_interfaces() != NULL) {
|
2018-08-07 15:45:07 -07:00
|
|
|
Array<InstanceKlass*>* transitive_interfaces = this->transitive_interfaces();
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
for (int j = 0; j < transitive_interfaces->length(); j++) {
|
2018-08-07 15:45:07 -07:00
|
|
|
InstanceKlass* e = transitive_interfaces->at(j);
|
2012-11-12 16:15:05 -05:00
|
|
|
guarantee(e->is_klass() && e->is_interface(), "invalid transitive interface");
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Verify methods
|
|
|
|
if (methods() != NULL) {
|
|
|
|
Array<Method*>* methods = this->methods();
|
|
|
|
for (int j = 0; j < methods->length(); j++) {
|
|
|
|
guarantee(methods->at(j)->is_method(), "non-method in methods array");
|
|
|
|
}
|
|
|
|
for (int j = 0; j < methods->length() - 1; j++) {
|
|
|
|
Method* m1 = methods->at(j);
|
|
|
|
Method* m2 = methods->at(j + 1);
|
|
|
|
guarantee(m1->name()->fast_compare(m2->name()) <= 0, "methods not sorted correctly");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Verify method ordering
|
|
|
|
if (method_ordering() != NULL) {
|
|
|
|
Array<int>* method_ordering = this->method_ordering();
|
|
|
|
int length = method_ordering->length();
|
|
|
|
if (JvmtiExport::can_maintain_original_method_order() ||
|
2013-04-04 08:47:39 -04:00
|
|
|
((UseSharedSpaces || DumpSharedSpaces) && length != 0)) {
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
guarantee(length == methods()->length(), "invalid method ordering length");
|
|
|
|
jlong sum = 0;
|
|
|
|
for (int j = 0; j < length; j++) {
|
|
|
|
int original_index = method_ordering->at(j);
|
|
|
|
guarantee(original_index >= 0, "invalid method ordering index");
|
|
|
|
guarantee(original_index < length, "invalid method ordering index");
|
|
|
|
sum += original_index;
|
|
|
|
}
|
|
|
|
// Verify sum of indices 0,1,...,length-1
|
|
|
|
guarantee(sum == ((jlong)length*(length-1))/2, "invalid method ordering sum");
|
|
|
|
} else {
|
|
|
|
guarantee(length == 0, "invalid method ordering length");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-10-07 12:20:28 -04:00
|
|
|
// Verify default methods
|
|
|
|
if (default_methods() != NULL) {
|
|
|
|
Array<Method*>* methods = this->default_methods();
|
|
|
|
for (int j = 0; j < methods->length(); j++) {
|
|
|
|
guarantee(methods->at(j)->is_method(), "non-method in methods array");
|
|
|
|
}
|
|
|
|
for (int j = 0; j < methods->length() - 1; j++) {
|
|
|
|
Method* m1 = methods->at(j);
|
|
|
|
Method* m2 = methods->at(j + 1);
|
|
|
|
guarantee(m1->name()->fast_compare(m2->name()) <= 0, "methods not sorted correctly");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
// Verify JNI static field identifiers
|
|
|
|
if (jni_ids() != NULL) {
|
|
|
|
jni_ids()->verify(this);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Verify other fields
|
|
|
|
if (array_klasses() != NULL) {
|
|
|
|
guarantee(array_klasses()->is_klass(), "should be klass");
|
|
|
|
}
|
|
|
|
if (constants() != NULL) {
|
|
|
|
guarantee(constants()->is_constantPool(), "should be constant pool");
|
|
|
|
}
|
2018-08-20 08:25:57 -04:00
|
|
|
const Klass* anonymous_host = unsafe_anonymous_host();
|
|
|
|
if (anonymous_host != NULL) {
|
|
|
|
guarantee(anonymous_host->is_klass(), "should be klass");
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void InstanceKlass::oop_verify_on(oop obj, outputStream* st) {
|
2007-12-01 00:00:00 +00:00
|
|
|
Klass::oop_verify_on(obj, st);
|
|
|
|
VerifyFieldClosure blk;
|
2018-06-26 13:54:19 +02:00
|
|
|
obj->oop_iterate(&blk);
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
|
|
|
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
|
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
Compressed oops in instances, arrays, and headers. Code contributors are coleenp, phh, never, swamyv
Reviewed-by: jmasa, kamg, acorn, tbell, kvn, rasbold
2008-04-13 17:43:42 -04:00
|
|
|
// JNIid class for jfieldIDs only
|
|
|
|
// Note to reviewers:
|
|
|
|
// These JNI functions are just moved over to column 1 and not changed
|
|
|
|
// in the compressed oops workspace.
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
JNIid::JNIid(Klass* holder, int offset, JNIid* next) {
|
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
Compressed oops in instances, arrays, and headers. Code contributors are coleenp, phh, never, swamyv
Reviewed-by: jmasa, kamg, acorn, tbell, kvn, rasbold
2008-04-13 17:43:42 -04:00
|
|
|
_holder = holder;
|
|
|
|
_offset = offset;
|
|
|
|
_next = next;
|
|
|
|
debug_only(_is_static_field_id = false;)
|
|
|
|
}
|
2007-12-01 00:00:00 +00:00
|
|
|
|
|
|
|
|
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
Compressed oops in instances, arrays, and headers. Code contributors are coleenp, phh, never, swamyv
Reviewed-by: jmasa, kamg, acorn, tbell, kvn, rasbold
2008-04-13 17:43:42 -04:00
|
|
|
JNIid* JNIid::find(int offset) {
|
|
|
|
JNIid* current = this;
|
|
|
|
while (current != NULL) {
|
|
|
|
if (current->offset() == offset) return current;
|
|
|
|
current = current->next();
|
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
2007-12-01 00:00:00 +00:00
|
|
|
|
|
|
|
void JNIid::deallocate(JNIid* current) {
|
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
Compressed oops in instances, arrays, and headers. Code contributors are coleenp, phh, never, swamyv
Reviewed-by: jmasa, kamg, acorn, tbell, kvn, rasbold
2008-04-13 17:43:42 -04:00
|
|
|
while (current != NULL) {
|
|
|
|
JNIid* next = current->next();
|
|
|
|
delete current;
|
|
|
|
current = next;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-12-01 00:00:00 +00:00
|
|
|
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
void JNIid::verify(Klass* holder) {
|
2012-09-07 12:04:16 -04:00
|
|
|
int first_field_offset = InstanceMirrorKlass::offset_of_static_fields();
|
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
Compressed oops in instances, arrays, and headers. Code contributors are coleenp, phh, never, swamyv
Reviewed-by: jmasa, kamg, acorn, tbell, kvn, rasbold
2008-04-13 17:43:42 -04:00
|
|
|
int end_field_offset;
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
end_field_offset = first_field_offset + (InstanceKlass::cast(holder)->static_field_size() * wordSize);
|
2007-12-01 00:00:00 +00:00
|
|
|
|
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
Compressed oops in instances, arrays, and headers. Code contributors are coleenp, phh, never, swamyv
Reviewed-by: jmasa, kamg, acorn, tbell, kvn, rasbold
2008-04-13 17:43:42 -04:00
|
|
|
JNIid* current = this;
|
|
|
|
while (current != NULL) {
|
|
|
|
guarantee(current->holder() == holder, "Invalid klass in JNIid");
|
2007-12-01 00:00:00 +00:00
|
|
|
#ifdef ASSERT
|
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
Compressed oops in instances, arrays, and headers. Code contributors are coleenp, phh, never, swamyv
Reviewed-by: jmasa, kamg, acorn, tbell, kvn, rasbold
2008-04-13 17:43:42 -04:00
|
|
|
int o = current->offset();
|
|
|
|
if (current->is_static_field_id()) {
|
|
|
|
guarantee(o >= first_field_offset && o < end_field_offset, "Invalid static field offset in JNIid");
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
current = current->next();
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
Compressed oops in instances, arrays, and headers. Code contributors are coleenp, phh, never, swamyv
Reviewed-by: jmasa, kamg, acorn, tbell, kvn, rasbold
2008-04-13 17:43:42 -04:00
|
|
|
}
|
|
|
|
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
void InstanceKlass::set_init_state(ClassState state) {
|
2019-01-09 07:52:45 -05:00
|
|
|
#ifdef ASSERT
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
bool good_state = is_shared() ? (_init_state <= state)
|
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
Compressed oops in instances, arrays, and headers. Code contributors are coleenp, phh, never, swamyv
Reviewed-by: jmasa, kamg, acorn, tbell, kvn, rasbold
2008-04-13 17:43:42 -04:00
|
|
|
: (_init_state < state);
|
|
|
|
assert(good_state || state == allocated, "illegal state transition");
|
2019-01-09 07:52:45 -05:00
|
|
|
#endif
|
2011-12-06 18:28:51 -05:00
|
|
|
_init_state = (u1)state;
|
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
Compressed oops in instances, arrays, and headers. Code contributors are coleenp, phh, never, swamyv
Reviewed-by: jmasa, kamg, acorn, tbell, kvn, rasbold
2008-04-13 17:43:42 -04:00
|
|
|
}
|
2007-12-01 00:00:00 +00:00
|
|
|
|
2016-04-21 20:49:11 -07:00
|
|
|
#if INCLUDE_JVMTI
|
2015-03-13 12:40:39 -04:00
|
|
|
|
2016-09-07 15:25:21 -04:00
|
|
|
// RedefineClasses() support for previous versions
|
|
|
|
|
|
|
|
// Globally, there is at least one previous version of a class to walk
|
|
|
|
// during class unloading, which is saved because old methods in the class
|
|
|
|
// are still running. Otherwise the previous version list is cleaned up.
|
|
|
|
bool InstanceKlass::_has_previous_versions = false;
|
|
|
|
|
|
|
|
// Returns true if there are previous versions of a class for class
|
|
|
|
// unloading only. Also resets the flag to false. purge_previous_version
|
|
|
|
// will set the flag to true if there are any left, i.e., if there's any
|
|
|
|
// work to do for next time. This is to avoid the expensive code cache
|
2018-08-08 15:24:21 -04:00
|
|
|
// walk in CLDG::clean_deallocate_lists().
|
2016-09-07 15:25:21 -04:00
|
|
|
bool InstanceKlass::has_previous_versions_and_reset() {
|
|
|
|
bool ret = _has_previous_versions;
|
|
|
|
log_trace(redefine, class, iklass, purge)("Class unloading: has_previous_versions = %s",
|
|
|
|
ret ? "true" : "false");
|
|
|
|
_has_previous_versions = false;
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Purge previous versions before adding new previous versions of the class and
|
|
|
|
// during class unloading.
|
|
|
|
void InstanceKlass::purge_previous_version_list() {
|
|
|
|
assert(SafepointSynchronize::is_at_safepoint(), "only called at safepoint");
|
|
|
|
assert(has_been_redefined(), "Should only be called for main class");
|
|
|
|
|
|
|
|
// Quick exit.
|
|
|
|
if (previous_versions() == NULL) {
|
|
|
|
return;
|
|
|
|
}
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
|
2016-09-07 15:25:21 -04:00
|
|
|
// This klass has previous versions so see what we can cleanup
|
|
|
|
// while it is safe to do so.
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
|
2016-09-07 15:25:21 -04:00
|
|
|
int deleted_count = 0; // leave debugging breadcrumbs
|
|
|
|
int live_count = 0;
|
|
|
|
ClassLoaderData* loader_data = class_loader_data();
|
|
|
|
assert(loader_data != NULL, "should never be null");
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
|
2016-09-07 15:25:21 -04:00
|
|
|
ResourceMark rm;
|
|
|
|
log_trace(redefine, class, iklass, purge)("%s: previous versions", external_name());
|
|
|
|
|
|
|
|
// previous versions are linked together through the InstanceKlass
|
|
|
|
InstanceKlass* pv_node = previous_versions();
|
|
|
|
InstanceKlass* last = this;
|
|
|
|
int version = 0;
|
|
|
|
|
|
|
|
// check the previous versions list
|
|
|
|
for (; pv_node != NULL; ) {
|
|
|
|
|
|
|
|
ConstantPool* pvcp = pv_node->constants();
|
|
|
|
assert(pvcp != NULL, "cp ref was unexpectedly cleared");
|
|
|
|
|
|
|
|
if (!pvcp->on_stack()) {
|
|
|
|
// If the constant pool isn't on stack, none of the methods
|
|
|
|
// are executing. Unlink this previous_version.
|
|
|
|
// The previous version InstanceKlass is on the ClassLoaderData deallocate list
|
|
|
|
// so will be deallocated during the next phase of class unloading.
|
|
|
|
log_trace(redefine, class, iklass, purge)
|
|
|
|
("previous version " INTPTR_FORMAT " is dead.", p2i(pv_node));
|
|
|
|
// For debugging purposes.
|
|
|
|
pv_node->set_is_scratch_class();
|
|
|
|
// Unlink from previous version list.
|
|
|
|
assert(pv_node->class_loader_data() == loader_data, "wrong loader_data");
|
|
|
|
InstanceKlass* next = pv_node->previous_versions();
|
|
|
|
pv_node->link_previous_versions(NULL); // point next to NULL
|
|
|
|
last->link_previous_versions(next);
|
|
|
|
// Add to the deallocate list after unlinking
|
|
|
|
loader_data->add_to_deallocate_list(pv_node);
|
|
|
|
pv_node = next;
|
|
|
|
deleted_count++;
|
|
|
|
version++;
|
|
|
|
continue;
|
|
|
|
} else {
|
|
|
|
log_trace(redefine, class, iklass, purge)("previous version " INTPTR_FORMAT " is alive", p2i(pv_node));
|
|
|
|
assert(pvcp->pool_holder() != NULL, "Constant pool with no holder");
|
|
|
|
guarantee (!loader_data->is_unloading(), "unloaded classes can't be on the stack");
|
|
|
|
live_count++;
|
|
|
|
// found a previous version for next time we do class unloading
|
|
|
|
_has_previous_versions = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
// At least one method is live in this previous version.
|
|
|
|
// Reset dead EMCP methods not to get breakpoints.
|
|
|
|
// All methods are deallocated when all of the methods for this class are no
|
|
|
|
// longer running.
|
|
|
|
Array<Method*>* method_refs = pv_node->methods();
|
|
|
|
if (method_refs != NULL) {
|
|
|
|
log_trace(redefine, class, iklass, purge)("previous methods length=%d", method_refs->length());
|
|
|
|
for (int j = 0; j < method_refs->length(); j++) {
|
|
|
|
Method* method = method_refs->at(j);
|
|
|
|
|
|
|
|
if (!method->on_stack()) {
|
|
|
|
// no breakpoints for non-running methods
|
|
|
|
if (method->is_running_emcp()) {
|
|
|
|
method->set_running_emcp(false);
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
}
|
2016-09-07 15:25:21 -04:00
|
|
|
} else {
|
|
|
|
assert (method->is_obsolete() || method->is_running_emcp(),
|
|
|
|
"emcp method cannot run after emcp bit is cleared");
|
|
|
|
log_trace(redefine, class, iklass, purge)
|
|
|
|
("purge: %s(%s): prev method @%d in version @%d is alive",
|
|
|
|
method->name()->as_C_string(), method->signature()->as_C_string(), j, version);
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2016-09-07 15:25:21 -04:00
|
|
|
// next previous version
|
|
|
|
last = pv_node;
|
|
|
|
pv_node = pv_node->previous_versions();
|
|
|
|
version++;
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
}
|
2016-09-07 15:25:21 -04:00
|
|
|
log_trace(redefine, class, iklass, purge)
|
|
|
|
("previous version stats: live=%d, deleted=%d", live_count, deleted_count);
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
}
|
|
|
|
|
2014-09-03 19:13:18 -04:00
|
|
|
void InstanceKlass::mark_newly_obsolete_methods(Array<Method*>* old_methods,
|
|
|
|
int emcp_method_count) {
|
2007-12-01 00:00:00 +00:00
|
|
|
int obsolete_method_count = old_methods->length() - emcp_method_count;
|
|
|
|
|
|
|
|
if (emcp_method_count != 0 && obsolete_method_count != 0 &&
|
2014-09-03 19:13:18 -04:00
|
|
|
_previous_versions != NULL) {
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
// We have a mix of obsolete and EMCP methods so we have to
|
2007-12-01 00:00:00 +00:00
|
|
|
// clear out any matching EMCP method entries the hard way.
|
|
|
|
int local_count = 0;
|
|
|
|
for (int i = 0; i < old_methods->length(); i++) {
|
2014-09-03 19:13:18 -04:00
|
|
|
Method* old_method = old_methods->at(i);
|
|
|
|
if (old_method->is_obsolete()) {
|
2007-12-01 00:00:00 +00:00
|
|
|
// only obsolete methods are interesting
|
2011-01-27 16:11:27 -08:00
|
|
|
Symbol* m_name = old_method->name();
|
|
|
|
Symbol* m_signature = old_method->signature();
|
2007-12-01 00:00:00 +00:00
|
|
|
|
2014-09-03 19:13:18 -04:00
|
|
|
// previous versions are linked together through the InstanceKlass
|
|
|
|
int j = 0;
|
|
|
|
for (InstanceKlass* prev_version = _previous_versions;
|
|
|
|
prev_version != NULL;
|
|
|
|
prev_version = prev_version->previous_versions(), j++) {
|
2007-12-01 00:00:00 +00:00
|
|
|
|
2014-09-03 19:13:18 -04:00
|
|
|
Array<Method*>* method_refs = prev_version->methods();
|
|
|
|
for (int k = 0; k < method_refs->length(); k++) {
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
Method* method = method_refs->at(k);
|
2007-12-01 00:00:00 +00:00
|
|
|
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
if (!method->is_obsolete() &&
|
|
|
|
method->name() == m_name &&
|
2007-12-01 00:00:00 +00:00
|
|
|
method->signature() == m_signature) {
|
|
|
|
// The current RedefineClasses() call has made all EMCP
|
|
|
|
// versions of this method obsolete so mark it as obsolete
|
2016-05-09 22:22:15 +02:00
|
|
|
log_trace(redefine, class, iklass, add)
|
|
|
|
("%s(%s): flush obsolete method @%d in version @%d",
|
|
|
|
m_name->as_C_string(), m_signature->as_C_string(), k, j);
|
2007-12-01 00:00:00 +00:00
|
|
|
|
|
|
|
method->set_is_obsolete();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// The previous loop may not find a matching EMCP method, but
|
|
|
|
// that doesn't mean that we can optimize and not go any
|
|
|
|
// further back in the PreviousVersion generations. The EMCP
|
2014-09-03 19:13:18 -04:00
|
|
|
// method for this generation could have already been made obsolete,
|
2007-12-01 00:00:00 +00:00
|
|
|
// but there still may be an older EMCP method that has not
|
2014-09-03 19:13:18 -04:00
|
|
|
// been made obsolete.
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (++local_count >= obsolete_method_count) {
|
|
|
|
// no more obsolete methods so bail out now
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2014-09-03 19:13:18 -04:00
|
|
|
}
|
2007-12-01 00:00:00 +00:00
|
|
|
|
2014-09-03 19:13:18 -04:00
|
|
|
// Save the scratch_class as the previous version if any of the methods are running.
|
|
|
|
// The previous_versions are used to set breakpoints in EMCP methods and they are
|
|
|
|
// also used to clean MethodData links to redefined methods that are no longer running.
|
2017-03-15 10:25:37 -04:00
|
|
|
void InstanceKlass::add_previous_version(InstanceKlass* scratch_class,
|
2014-09-03 19:13:18 -04:00
|
|
|
int emcp_method_count) {
|
|
|
|
assert(Thread::current()->is_VM_thread(),
|
|
|
|
"only VMThread can add previous versions");
|
|
|
|
|
2016-05-09 22:22:15 +02:00
|
|
|
ResourceMark rm;
|
|
|
|
log_trace(redefine, class, iklass, add)
|
|
|
|
("adding previous version ref for %s, EMCP_cnt=%d", scratch_class->external_name(), emcp_method_count);
|
2014-09-03 19:13:18 -04:00
|
|
|
|
2016-09-07 15:25:21 -04:00
|
|
|
// Clean out old previous versions for this class
|
|
|
|
purge_previous_version_list();
|
2014-09-03 19:13:18 -04:00
|
|
|
|
|
|
|
// Mark newly obsolete methods in remaining previous versions. An EMCP method from
|
|
|
|
// a previous redefinition may be made obsolete by this redefinition.
|
|
|
|
Array<Method*>* old_methods = scratch_class->methods();
|
|
|
|
mark_newly_obsolete_methods(old_methods, emcp_method_count);
|
|
|
|
|
|
|
|
// If the constant pool for this previous version of the class
|
|
|
|
// is not marked as being on the stack, then none of the methods
|
|
|
|
// in this previous version of the class are on the stack so
|
|
|
|
// we don't need to add this as a previous version.
|
|
|
|
ConstantPool* cp_ref = scratch_class->constants();
|
|
|
|
if (!cp_ref->on_stack()) {
|
2016-05-09 22:22:15 +02:00
|
|
|
log_trace(redefine, class, iklass, add)("scratch class not added; no methods are running");
|
2015-03-13 12:40:39 -04:00
|
|
|
// For debugging purposes.
|
|
|
|
scratch_class->set_is_scratch_class();
|
2017-03-15 10:25:37 -04:00
|
|
|
scratch_class->class_loader_data()->add_to_deallocate_list(scratch_class);
|
2014-09-03 19:13:18 -04:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (emcp_method_count != 0) {
|
|
|
|
// At least one method is still running, check for EMCP methods
|
|
|
|
for (int i = 0; i < old_methods->length(); i++) {
|
|
|
|
Method* old_method = old_methods->at(i);
|
|
|
|
if (!old_method->is_obsolete() && old_method->on_stack()) {
|
|
|
|
// if EMCP method (not obsolete) is on the stack, mark as EMCP so that
|
|
|
|
// we can add breakpoints for it.
|
|
|
|
|
2015-03-13 12:40:39 -04:00
|
|
|
// We set the method->on_stack bit during safepoints for class redefinition
|
|
|
|
// and use this bit to set the is_running_emcp bit.
|
2014-09-03 19:13:18 -04:00
|
|
|
// After the safepoint, the on_stack bit is cleared and the running emcp
|
|
|
|
// method may exit. If so, we would set a breakpoint in a method that
|
|
|
|
// is never reached, but this won't be noticeable to the programmer.
|
|
|
|
old_method->set_running_emcp(true);
|
2016-05-09 22:22:15 +02:00
|
|
|
log_trace(redefine, class, iklass, add)
|
|
|
|
("EMCP method %s is on_stack " INTPTR_FORMAT, old_method->name_and_sig_as_C_string(), p2i(old_method));
|
2014-09-03 19:13:18 -04:00
|
|
|
} else if (!old_method->is_obsolete()) {
|
2016-05-09 22:22:15 +02:00
|
|
|
log_trace(redefine, class, iklass, add)
|
|
|
|
("EMCP method %s is NOT on_stack " INTPTR_FORMAT, old_method->name_and_sig_as_C_string(), p2i(old_method));
|
2014-09-03 19:13:18 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2007-12-01 00:00:00 +00:00
|
|
|
|
2014-09-03 19:13:18 -04:00
|
|
|
// Add previous version if any methods are still running.
|
2016-09-07 15:25:21 -04:00
|
|
|
// Set has_previous_version flag for processing during class unloading.
|
|
|
|
_has_previous_versions = true;
|
|
|
|
log_trace(redefine, class, iklass, add) ("scratch class added; one of its methods is on_stack.");
|
2014-09-03 19:13:18 -04:00
|
|
|
assert(scratch_class->previous_versions() == NULL, "shouldn't have a previous version");
|
|
|
|
scratch_class->link_previous_versions(previous_versions());
|
2017-03-15 10:25:37 -04:00
|
|
|
link_previous_versions(scratch_class);
|
2014-09-03 19:13:18 -04:00
|
|
|
} // end add_previous_version()
|
2007-12-01 00:00:00 +00:00
|
|
|
|
2016-04-21 20:49:11 -07:00
|
|
|
#endif // INCLUDE_JVMTI
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
|
|
|
|
Method* InstanceKlass::method_with_idnum(int idnum) {
|
|
|
|
Method* m = NULL;
|
2007-12-01 00:00:00 +00:00
|
|
|
if (idnum < methods()->length()) {
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
m = methods()->at(idnum);
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
|
|
|
if (m == NULL || m->method_idnum() != idnum) {
|
|
|
|
for (int index = 0; index < methods()->length(); ++index) {
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
m = methods()->at(index);
|
2007-12-01 00:00:00 +00:00
|
|
|
if (m->method_idnum() == idnum) {
|
|
|
|
return m;
|
|
|
|
}
|
|
|
|
}
|
2013-09-20 09:30:02 -04:00
|
|
|
// None found, return null for the caller to handle.
|
|
|
|
return NULL;
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
|
|
|
return m;
|
|
|
|
}
|
|
|
|
|
2015-03-20 02:44:51 -07:00
|
|
|
|
|
|
|
Method* InstanceKlass::method_with_orig_idnum(int idnum) {
|
|
|
|
if (idnum >= methods()->length()) {
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
Method* m = methods()->at(idnum);
|
|
|
|
if (m != NULL && m->orig_method_idnum() == idnum) {
|
|
|
|
return m;
|
|
|
|
}
|
|
|
|
// Obsolete method idnum does not match the original idnum
|
|
|
|
for (int index = 0; index < methods()->length(); ++index) {
|
|
|
|
m = methods()->at(index);
|
|
|
|
if (m->orig_method_idnum() == idnum) {
|
|
|
|
return m;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// None found, return null for the caller to handle.
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Method* InstanceKlass::method_with_orig_idnum(int idnum, int version) {
|
|
|
|
InstanceKlass* holder = get_klass_version(version);
|
|
|
|
if (holder == NULL) {
|
|
|
|
return NULL; // The version of klass is gone, no method is found
|
|
|
|
}
|
|
|
|
Method* method = holder->method_with_orig_idnum(idnum);
|
|
|
|
return method;
|
|
|
|
}
|
|
|
|
|
2016-04-21 20:49:11 -07:00
|
|
|
#if INCLUDE_JVMTI
|
2016-09-18 21:10:48 -04:00
|
|
|
JvmtiCachedClassFileData* InstanceKlass::get_cached_class_file() {
|
2019-02-21 17:07:35 -08:00
|
|
|
return _cached_class_file;
|
2016-09-18 21:10:48 -04:00
|
|
|
}
|
|
|
|
|
2013-07-17 18:06:29 -04:00
|
|
|
jint InstanceKlass::get_cached_class_file_len() {
|
|
|
|
return VM_RedefineClasses::get_cached_class_file_len(_cached_class_file);
|
|
|
|
}
|
|
|
|
|
|
|
|
unsigned char * InstanceKlass::get_cached_class_file_bytes() {
|
|
|
|
return VM_RedefineClasses::get_cached_class_file_bytes(_cached_class_file);
|
|
|
|
}
|
2016-04-21 20:49:11 -07:00
|
|
|
#endif
|