提交 c5aa05e3 编写于 作者: D dcubed

Merge

/* /*
* Copyright 2003-2007 Sun Microsystems, Inc. All Rights Reserved. * Copyright 2003-2009 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -32,15 +32,15 @@ ...@@ -32,15 +32,15 @@
// FIXLATER: hook into JvmtiTrace // FIXLATER: hook into JvmtiTrace
#define TraceJVMTICalls false #define TraceJVMTICalls false
JvmtiEnv::JvmtiEnv() : JvmtiEnvBase() { JvmtiEnv::JvmtiEnv(jint version) : JvmtiEnvBase(version) {
} }
JvmtiEnv::~JvmtiEnv() { JvmtiEnv::~JvmtiEnv() {
} }
JvmtiEnv* JvmtiEnv*
JvmtiEnv::create_a_jvmti() { JvmtiEnv::create_a_jvmti(jint version) {
return new JvmtiEnv(); return new JvmtiEnv(version);
} }
// VM operation class to copy jni function table at safepoint. // VM operation class to copy jni function table at safepoint.
...@@ -411,8 +411,15 @@ JvmtiEnv::AddToBootstrapClassLoaderSearch(const char* segment) { ...@@ -411,8 +411,15 @@ JvmtiEnv::AddToBootstrapClassLoaderSearch(const char* segment) {
if (phase == JVMTI_PHASE_ONLOAD) { if (phase == JVMTI_PHASE_ONLOAD) {
Arguments::append_sysclasspath(segment); Arguments::append_sysclasspath(segment);
return JVMTI_ERROR_NONE; return JVMTI_ERROR_NONE;
} else { } else if (use_version_1_0_semantics()) {
assert(phase == JVMTI_PHASE_LIVE, "sanity check"); // This JvmtiEnv requested version 1.0 semantics and this function
// is only allowed in the ONLOAD phase in version 1.0 so we need to
// return an error here.
return JVMTI_ERROR_WRONG_PHASE;
} else if (phase == JVMTI_PHASE_LIVE) {
// The phase is checked by the wrapper that called this function,
// but this thread could be racing with the thread that is
// terminating the VM so we check one more time.
// create the zip entry // create the zip entry
ClassPathZipEntry* zip_entry = ClassLoader::create_class_path_zip_entry(segment); ClassPathZipEntry* zip_entry = ClassLoader::create_class_path_zip_entry(segment);
...@@ -433,6 +440,8 @@ JvmtiEnv::AddToBootstrapClassLoaderSearch(const char* segment) { ...@@ -433,6 +440,8 @@ JvmtiEnv::AddToBootstrapClassLoaderSearch(const char* segment) {
} }
ClassLoader::add_to_list(zip_entry); ClassLoader::add_to_list(zip_entry);
return JVMTI_ERROR_NONE; return JVMTI_ERROR_NONE;
} else {
return JVMTI_ERROR_WRONG_PHASE;
} }
} /* end AddToBootstrapClassLoaderSearch */ } /* end AddToBootstrapClassLoaderSearch */
...@@ -451,11 +460,12 @@ JvmtiEnv::AddToSystemClassLoaderSearch(const char* segment) { ...@@ -451,11 +460,12 @@ JvmtiEnv::AddToSystemClassLoaderSearch(const char* segment) {
} }
} }
return JVMTI_ERROR_NONE; return JVMTI_ERROR_NONE;
} else { } else if (phase == JVMTI_PHASE_LIVE) {
// The phase is checked by the wrapper that called this function,
// but this thread could be racing with the thread that is
// terminating the VM so we check one more time.
HandleMark hm; HandleMark hm;
assert(phase == JVMTI_PHASE_LIVE, "sanity check");
// create the zip entry (which will open the zip file and hence // create the zip entry (which will open the zip file and hence
// check that the segment is indeed a zip file). // check that the segment is indeed a zip file).
ClassPathZipEntry* zip_entry = ClassLoader::create_class_path_zip_entry(segment); ClassPathZipEntry* zip_entry = ClassLoader::create_class_path_zip_entry(segment);
...@@ -504,6 +514,8 @@ JvmtiEnv::AddToSystemClassLoaderSearch(const char* segment) { ...@@ -504,6 +514,8 @@ JvmtiEnv::AddToSystemClassLoaderSearch(const char* segment) {
} }
return JVMTI_ERROR_NONE; return JVMTI_ERROR_NONE;
} else {
return JVMTI_ERROR_WRONG_PHASE;
} }
} /* end AddToSystemClassLoaderSearch */ } /* end AddToSystemClassLoaderSearch */
...@@ -2863,6 +2875,14 @@ JvmtiEnv::IsMethodSynthetic(methodOop method_oop, jboolean* is_synthetic_ptr) { ...@@ -2863,6 +2875,14 @@ JvmtiEnv::IsMethodSynthetic(methodOop method_oop, jboolean* is_synthetic_ptr) {
// is_obsolete_ptr - pre-checked for NULL // is_obsolete_ptr - pre-checked for NULL
jvmtiError jvmtiError
JvmtiEnv::IsMethodObsolete(methodOop method_oop, jboolean* is_obsolete_ptr) { JvmtiEnv::IsMethodObsolete(methodOop method_oop, jboolean* is_obsolete_ptr) {
if (use_version_1_0_semantics() &&
get_capabilities()->can_redefine_classes == 0) {
// This JvmtiEnv requested version 1.0 semantics and this function
// requires the can_redefine_classes capability in version 1.0 so
// we need to return an error here.
return JVMTI_ERROR_MUST_POSSESS_CAPABILITY;
}
if (method_oop == NULL || method_oop->is_obsolete()) { if (method_oop == NULL || method_oop->is_obsolete()) {
*is_obsolete_ptr = true; *is_obsolete_ptr = true;
} else { } else {
......
...@@ -123,7 +123,26 @@ JvmtiEnvBase::is_valid() { ...@@ -123,7 +123,26 @@ JvmtiEnvBase::is_valid() {
} }
JvmtiEnvBase::JvmtiEnvBase() : _env_event_enable() { bool
JvmtiEnvBase::use_version_1_0_semantics() {
int major, minor, micro;
JvmtiExport::decode_version_values(_version, &major, &minor, &micro);
return major == 1 && minor == 0; // micro version doesn't matter here
}
bool
JvmtiEnvBase::use_version_1_1_semantics() {
int major, minor, micro;
JvmtiExport::decode_version_values(_version, &major, &minor, &micro);
return major == 1 && minor == 1; // micro version doesn't matter here
}
JvmtiEnvBase::JvmtiEnvBase(jint version) : _env_event_enable() {
_version = version;
_env_local_storage = NULL; _env_local_storage = NULL;
_tag_map = NULL; _tag_map = NULL;
_native_method_prefix_count = 0; _native_method_prefix_count = 0;
......
/* /*
* Copyright 2003-2006 Sun Microsystems, Inc. All Rights Reserved. * Copyright 2003-2009 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -76,6 +76,7 @@ class JvmtiEnvBase : public CHeapObj { ...@@ -76,6 +76,7 @@ class JvmtiEnvBase : public CHeapObj {
jvmtiEnv _jvmti_external; jvmtiEnv _jvmti_external;
jint _magic; jint _magic;
jint _version; // version value passed to JNI GetEnv()
JvmtiEnvBase* _next; JvmtiEnvBase* _next;
bool _is_retransformable; bool _is_retransformable;
const void *_env_local_storage; // per env agent allocated data. const void *_env_local_storage; // per env agent allocated data.
...@@ -91,7 +92,7 @@ class JvmtiEnvBase : public CHeapObj { ...@@ -91,7 +92,7 @@ class JvmtiEnvBase : public CHeapObj {
int _native_method_prefix_count; int _native_method_prefix_count;
protected: protected:
JvmtiEnvBase(); JvmtiEnvBase(jint version);
~JvmtiEnvBase(); ~JvmtiEnvBase();
void dispose(); void dispose();
void env_dispose(); void env_dispose();
...@@ -122,6 +123,9 @@ class JvmtiEnvBase : public CHeapObj { ...@@ -122,6 +123,9 @@ class JvmtiEnvBase : public CHeapObj {
bool is_valid(); bool is_valid();
bool use_version_1_0_semantics(); // agent asked for version 1.0
bool use_version_1_1_semantics(); // agent asked for version 1.1
bool is_retransformable() { return _is_retransformable; } bool is_retransformable() { return _is_retransformable; }
static ByteSize jvmti_external_offset() { static ByteSize jvmti_external_offset() {
......
...@@ -319,7 +319,27 @@ address JvmtiExport::get_field_modification_count_addr() { ...@@ -319,7 +319,27 @@ address JvmtiExport::get_field_modification_count_addr() {
jint jint
JvmtiExport::get_jvmti_interface(JavaVM *jvm, void **penv, jint version) { JvmtiExport::get_jvmti_interface(JavaVM *jvm, void **penv, jint version) {
/* To Do: add version checks */ // The JVMTI_VERSION_INTERFACE_JVMTI part of the version number
// has already been validated in JNI GetEnv().
int major, minor, micro;
// micro version doesn't matter here (yet?)
decode_version_values(version, &major, &minor, &micro);
switch (major) {
case 1:
switch (minor) {
case 0: // version 1.0.<micro> is recognized
case 1: // version 1.1.<micro> is recognized
break;
default:
return JNI_EVERSION; // unsupported minor version number
}
break;
default:
return JNI_EVERSION; // unsupported major version number
}
if (JvmtiEnv::get_phase() == JVMTI_PHASE_LIVE) { if (JvmtiEnv::get_phase() == JVMTI_PHASE_LIVE) {
JavaThread* current_thread = (JavaThread*) ThreadLocalStorage::thread(); JavaThread* current_thread = (JavaThread*) ThreadLocalStorage::thread();
...@@ -328,13 +348,13 @@ JvmtiExport::get_jvmti_interface(JavaVM *jvm, void **penv, jint version) { ...@@ -328,13 +348,13 @@ JvmtiExport::get_jvmti_interface(JavaVM *jvm, void **penv, jint version) {
__ENTRY(jvmtiEnv*, JvmtiExport::get_jvmti_interface, current_thread) __ENTRY(jvmtiEnv*, JvmtiExport::get_jvmti_interface, current_thread)
debug_only(VMNativeEntryWrapper __vew;) debug_only(VMNativeEntryWrapper __vew;)
JvmtiEnv *jvmti_env = JvmtiEnv::create_a_jvmti(); JvmtiEnv *jvmti_env = JvmtiEnv::create_a_jvmti(version);
*penv = jvmti_env->jvmti_external(); // actual type is jvmtiEnv* -- not to be confused with JvmtiEnv* *penv = jvmti_env->jvmti_external(); // actual type is jvmtiEnv* -- not to be confused with JvmtiEnv*
return JNI_OK; return JNI_OK;
} else if (JvmtiEnv::get_phase() == JVMTI_PHASE_ONLOAD) { } else if (JvmtiEnv::get_phase() == JVMTI_PHASE_ONLOAD) {
// not live, no thread to transition // not live, no thread to transition
JvmtiEnv *jvmti_env = JvmtiEnv::create_a_jvmti(); JvmtiEnv *jvmti_env = JvmtiEnv::create_a_jvmti(version);
*penv = jvmti_env->jvmti_external(); // actual type is jvmtiEnv* -- not to be confused with JvmtiEnv* *penv = jvmti_env->jvmti_external(); // actual type is jvmtiEnv* -- not to be confused with JvmtiEnv*
return JNI_OK; return JNI_OK;
...@@ -345,6 +365,15 @@ JvmtiExport::get_jvmti_interface(JavaVM *jvm, void **penv, jint version) { ...@@ -345,6 +365,15 @@ JvmtiExport::get_jvmti_interface(JavaVM *jvm, void **penv, jint version) {
} }
} }
void
JvmtiExport::decode_version_values(jint version, int * major, int * minor,
int * micro) {
*major = (version & JVMTI_VERSION_MASK_MAJOR) >> JVMTI_VERSION_SHIFT_MAJOR;
*minor = (version & JVMTI_VERSION_MASK_MINOR) >> JVMTI_VERSION_SHIFT_MINOR;
*micro = (version & JVMTI_VERSION_MASK_MICRO) >> JVMTI_VERSION_SHIFT_MICRO;
}
void JvmtiExport::enter_primordial_phase() { void JvmtiExport::enter_primordial_phase() {
JvmtiEnvBase::set_phase(JVMTI_PHASE_PRIMORDIAL); JvmtiEnvBase::set_phase(JVMTI_PHASE_PRIMORDIAL);
} }
......
/* /*
* Copyright 1998-2006 Sun Microsystems, Inc. All Rights Reserved. * Copyright 1998-2009 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -236,6 +236,8 @@ class JvmtiExport : public AllStatic { ...@@ -236,6 +236,8 @@ class JvmtiExport : public AllStatic {
static bool is_jvmti_version(jint version) { return (version & JVMTI_VERSION_MASK) == JVMTI_VERSION_VALUE; } static bool is_jvmti_version(jint version) { return (version & JVMTI_VERSION_MASK) == JVMTI_VERSION_VALUE; }
static bool is_jvmdi_version(jint version) { return (version & JVMTI_VERSION_MASK) == JVMDI_VERSION_VALUE; } static bool is_jvmdi_version(jint version) { return (version & JVMTI_VERSION_MASK) == JVMDI_VERSION_VALUE; }
static jint get_jvmti_interface(JavaVM *jvm, void **penv, jint version); static jint get_jvmti_interface(JavaVM *jvm, void **penv, jint version);
static void decode_version_values(jint version, int * major, int * minor,
int * micro);
// single stepping management methods // single stepping management methods
static void at_single_stepping_point(JavaThread *thread, methodOop method, address location) KERNEL_RETURN; static void at_single_stepping_point(JavaThread *thread, methodOop method, address location) KERNEL_RETURN;
......
<?xml version="1.0"?> <?xml version="1.0"?>
<!-- <!--
Copyright 2002-2005 Sun Microsystems, Inc. All Rights Reserved. Copyright 2002-2009 Sun Microsystems, Inc. All Rights Reserved.
DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
This code is free software; you can redistribute it and/or modify it This code is free software; you can redistribute it and/or modify it
...@@ -48,12 +48,12 @@ class JvmtiEnv : public JvmtiEnvBase { ...@@ -48,12 +48,12 @@ class JvmtiEnv : public JvmtiEnvBase {
private: private:
JvmtiEnv(); JvmtiEnv(jint version);
~JvmtiEnv(); ~JvmtiEnv();
public: public:
static JvmtiEnv* create_a_jvmti(); static JvmtiEnv* create_a_jvmti(jint version);
</xsl:text> </xsl:text>
<xsl:apply-templates select="functionsection"/> <xsl:apply-templates select="functionsection"/>
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册