Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

8264711: More runtime TRAPS cleanups #3345

Closed
wants to merge 4 commits into from
Closed
Changes from 1 commit
Commits
File filter
Filter file types
Jump to
Jump to file
Failed to load files.

Always

Just for now

@@ -393,7 +393,7 @@ Handle java_lang_String::create_from_symbol(Symbol* symbol, TRAPS) {
}

// Converts a C string to a Java String based on current encoding
Handle java_lang_String::create_from_platform_dependent_str(JavaThread* current, const char* str) {
Handle java_lang_String::create_from_platform_dependent_str(const char* str, TRAPS) {
assert(str != NULL, "bad arguments");

typedef jstring (JNICALL *to_java_string_fn_t)(JNIEnv*, const char *);
@@ -415,19 +415,20 @@ Handle java_lang_String::create_from_platform_dependent_str(JavaThread* current,

jstring js = NULL;
{
HandleMark hm(current);
ThreadToNativeFromVM ttn(current);
js = (_to_java_string_fn)(current->jni_environment(), str);
JavaThread* thread = THREAD->as_Java_thread();
HandleMark hm(thread);
ThreadToNativeFromVM ttn(thread);
js = (_to_java_string_fn)(thread->jni_environment(), str);
}

Handle native_platform_string(current, JNIHandles::resolve(js));
Handle native_platform_string(THREAD, JNIHandles::resolve(js));
JNIHandles::destroy_local(js); // destroy local JNIHandle.
return native_platform_string;
}

// Converts a Java String to a native C string that can be used for
// native OS calls.
char* java_lang_String::as_platform_dependent_str(JavaThread* current, Handle java_string) {
char* java_lang_String::as_platform_dependent_str(Handle java_string, TRAPS) {
typedef char* (*to_platform_string_fn_t)(JNIEnv*, jstring, bool*);
static to_platform_string_fn_t _to_platform_string_fn = NULL;

@@ -440,12 +441,12 @@ char* java_lang_String::as_platform_dependent_str(JavaThread* current, Handle ja
}

char *native_platform_string;
{
jstring js = (jstring) JNIHandles::make_local(current, java_string());
{ JavaThread* thread = THREAD->as_Java_thread();
jstring js = (jstring) JNIHandles::make_local(thread, java_string());
bool is_copy;
HandleMark hm(current);
ThreadToNativeFromVM ttn(current);
JNIEnv *env = current->jni_environment();
HandleMark hm(thread);
ThreadToNativeFromVM ttn(thread);
JNIEnv *env = thread->jni_environment();
native_platform_string = (_to_platform_string_fn)(env, js, &is_copy);
assert(is_copy == JNI_TRUE, "is_copy value changed");
JNIHandles::destroy_local(js);
@@ -126,7 +126,7 @@ class java_lang_String : AllStatic {
static Handle create_from_str(const char* utf8_str, TRAPS);
static oop create_oop_from_str(const char* utf8_str, TRAPS);
static Handle create_from_symbol(Symbol* symbol, TRAPS);
static Handle create_from_platform_dependent_str(JavaThread* current, const char* str);
static Handle create_from_platform_dependent_str(const char* str, TRAPS);
static Handle char_converter(Handle java_string, jchar from_char, jchar to_char, TRAPS);

static void set_compact_strings(bool value);
@@ -155,7 +155,7 @@ class java_lang_String : AllStatic {
static char* as_utf8_string(oop java_string, int start, int len);
static char* as_utf8_string(oop java_string, typeArrayOop value, char* buf, int buflen);
static char* as_utf8_string(oop java_string, typeArrayOop value, int start, int len, char* buf, int buflen);
static char* as_platform_dependent_str(JavaThread* current, Handle java_string);
static char* as_platform_dependent_str(Handle java_string, TRAPS);
static jchar* as_unicode_string(oop java_string, int& length, TRAPS);
// produce an ascii string with all other values quoted using \u####
static char* as_quoted_ascii(oop java_string);
@@ -109,25 +109,27 @@ InstanceKlass* KlassFactory::check_shared_class_file_load_hook(
}


static ClassFileStream* check_class_file_load_hook(JavaThread* current,
ClassFileStream* stream,
static ClassFileStream* check_class_file_load_hook(ClassFileStream* stream,
Symbol* name,
ClassLoaderData* loader_data,
Handle protection_domain,
JvmtiCachedClassFileData** cached_class_file) {
JvmtiCachedClassFileData** cached_class_file,
TRAPS) {

assert(stream != NULL, "invariant");

if (JvmtiExport::should_post_class_file_load_hook()) {
Handle class_loader(current, loader_data->class_loader());
const JavaThread* jt = THREAD->as_Java_thread();

Handle class_loader(THREAD, loader_data->class_loader());

// Get the cached class file bytes (if any) from the class that
// is being redefined or retransformed. We use jvmti_thread_state()
// instead of JvmtiThreadState::state_for(current) so we don't allocate
// instead of JvmtiThreadState::state_for(jt) so we don't allocate
// a JvmtiThreadState any earlier than necessary. This will help
// avoid the bug described by 7126851.

JvmtiThreadState* state = current->jvmti_thread_state();
JvmtiThreadState* state = jt->jvmti_thread_state();

if (state != NULL) {
Klass* k = state->get_class_being_redefined();
@@ -186,12 +188,12 @@ InstanceKlass* KlassFactory::create_from_stream(ClassFileStream* stream,

// Skip this processing for VM hidden or anonymous classes
if (!cl_info.is_hidden() && (cl_info.unsafe_anonymous_host() == NULL)) {
stream = check_class_file_load_hook(THREAD->as_Java_thread(),
stream,
stream = check_class_file_load_hook(stream,
name,
loader_data,
cl_info.protection_domain(),
&cached_class_file);
&cached_class_file,
CHECK_NULL);
}

ClassFileParser parser(stream,
@@ -299,8 +299,8 @@ static void set_property(Handle props, const char* key, const char* value, TRAPS
JavaValue r(T_OBJECT);
// public synchronized Object put(Object key, Object value);
HandleMark hm(THREAD);
Handle key_str = java_lang_String::create_from_platform_dependent_str(THREAD->as_Java_thread(), key);
Handle value_str = java_lang_String::create_from_platform_dependent_str(THREAD->as_Java_thread(), (value != NULL ? value : ""));
Handle key_str = java_lang_String::create_from_platform_dependent_str(key, CHECK);
Handle value_str = java_lang_String::create_from_platform_dependent_str((value != NULL ? value : ""), CHECK);
JavaCalls::call_virtual(&r,
props,
vmClasses::Properties_klass(),
@@ -322,7 +322,6 @@ static void set_property(Handle props, const char* key, const char* value, TRAPS
JVM_ENTRY(jobjectArray, JVM_GetProperties(JNIEnv *env))
ResourceMark rm(THREAD);
HandleMark hm(THREAD);
JavaThread* current = THREAD->as_Java_thread();
int ndx = 0;
int fixedCount = 2;

@@ -338,8 +337,8 @@ JVM_ENTRY(jobjectArray, JVM_GetProperties(JNIEnv *env))
const char * key = p->key();
if (strcmp(key, "sun.nio.MaxDirectMemorySize") != 0) {
const char * value = p->value();
Handle key_str = java_lang_String::create_from_platform_dependent_str(current, key);
Handle value_str = java_lang_String::create_from_platform_dependent_str(current, (value != NULL ? value : ""));
Handle key_str = java_lang_String::create_from_platform_dependent_str(key, CHECK_NULL);
Handle value_str = java_lang_String::create_from_platform_dependent_str((value != NULL ? value : ""), CHECK_NULL);
result_h->obj_at_put(ndx * 2, key_str());
result_h->obj_at_put(ndx * 2 + 1, value_str());
ndx++;
@@ -355,8 +354,8 @@ JVM_ENTRY(jobjectArray, JVM_GetProperties(JNIEnv *env))
if (!FLAG_IS_DEFAULT(MaxDirectMemorySize)) {
char as_chars[256];
jio_snprintf(as_chars, sizeof(as_chars), JULONG_FORMAT, MaxDirectMemorySize);
Handle key_str = java_lang_String::create_from_platform_dependent_str(current, "sun.nio.MaxDirectMemorySize");
Handle value_str = java_lang_String::create_from_platform_dependent_str(current, as_chars);
Handle key_str = java_lang_String::create_from_platform_dependent_str("sun.nio.MaxDirectMemorySize", CHECK_NULL);
Handle value_str = java_lang_String::create_from_platform_dependent_str(as_chars, CHECK_NULL);
result_h->obj_at_put(ndx * 2, key_str());
result_h->obj_at_put(ndx * 2 + 1, value_str());
ndx++;
@@ -388,8 +387,8 @@ JVM_ENTRY(jobjectArray, JVM_GetProperties(JNIEnv *env))

if (*compiler_name != '\0' &&
(Arguments::mode() != Arguments::_int)) {
Handle key_str = java_lang_String::create_from_platform_dependent_str(current, "sun.management.compiler");
Handle value_str = java_lang_String::create_from_platform_dependent_str(current, compiler_name);
Handle key_str = java_lang_String::create_from_platform_dependent_str("sun.management.compiler", CHECK_NULL);
Handle value_str = java_lang_String::create_from_platform_dependent_str(compiler_name, CHECK_NULL);
result_h->obj_at_put(ndx * 2, key_str());
result_h->obj_at_put(ndx * 2 + 1, value_str());
ndx++;
@@ -411,7 +410,7 @@ JVM_END
JVM_ENTRY(jstring, JVM_GetTemporaryDirectory(JNIEnv *env))
HandleMark hm(THREAD);
const char* temp_dir = os::get_temp_directory();
Handle h = java_lang_String::create_from_platform_dependent_str(THREAD->as_Java_thread(), temp_dir);
Handle h = java_lang_String::create_from_platform_dependent_str(temp_dir, CHECK_NULL);
return (jstring) JNIHandles::make_local(THREAD, h());
JVM_END

@@ -3847,11 +3846,11 @@ JVM_ENTRY(jobjectArray, JVM_GetVmArguments(JNIEnv *env))
int index = 0;
JavaThread* current = THREAD->as_Java_thread();
for (int j = 0; j < num_flags; j++, index++) {
Handle h = java_lang_String::create_from_platform_dependent_str(current, vm_flags[j]);
Handle h = java_lang_String::create_from_platform_dependent_str(vm_flags[j], CHECK_NULL);
result_h->obj_at_put(index, h());
}
for (int i = 0; i < num_args; i++, index++) {
Handle h = java_lang_String::create_from_platform_dependent_str(current, vm_args[i]);
Handle h = java_lang_String::create_from_platform_dependent_str(vm_args[i], CHECK_NULL);
result_h->obj_at_put(index, h());
}
return (jobjectArray) JNIHandles::make_local(THREAD, result_h());
@@ -706,7 +706,7 @@ JvmtiEnv::AddToSystemClassLoaderSearch(const char* segment) {
ObjectLocker ol(loader, THREAD);

// need the path as java.lang.String
Handle path = java_lang_String::create_from_platform_dependent_str(THREAD, segment);
Handle path = java_lang_String::create_from_platform_dependent_str(segment, THREAD);
if (HAS_PENDING_EXCEPTION) {
CLEAR_PENDING_EXCEPTION;
return JVMTI_ERROR_INTERNAL;
@@ -1919,7 +1919,7 @@ JVM_ENTRY(jint, jmm_DumpHeap0(JNIEnv *env, jstring outputfile, jboolean live))
"Output file name cannot be null.", -1);
}
Handle onhandle(THREAD, on);
char* name = java_lang_String::as_platform_dependent_str(THREAD->as_Java_thread(), onhandle);
char* name = java_lang_String::as_platform_dependent_str(onhandle, CHECK_(-1));
if (name == NULL) {
THROW_MSG_(vmSymbols::java_lang_NullPointerException(),
"Output file name cannot be null.", -1);
@@ -378,7 +378,7 @@ Handle Exceptions::new_exception(Thread* thread, Symbol* name,
msg = java_lang_String::create_from_str(message, thread);
} else {
// Make a java string keeping the encoding scheme of the original string.
msg = java_lang_String::create_from_platform_dependent_str(thread->as_Java_thread(), message);
msg = java_lang_String::create_from_platform_dependent_str(message, thread);
}
if (thread->has_pending_exception()) {
Handle exception(thread, thread->pending_exception());
ProTip! Use n and p to navigate between commits in a pull request.