8234185: Cleanup usage of canonicalize function between libjava, hotspot and libinstrument

Reviewed-by: dholmes, alanb, sspitsyn
This commit is contained in:
Christoph Langer 2019-12-06 14:13:10 +01:00
parent b8dbdd1232
commit 547e472c42
9 changed files with 54 additions and 81 deletions

View file

@ -75,6 +75,8 @@
// Entry point in java.dll for path canonicalization
typedef int (*canonicalize_fn_t)(const char *orig, char *out, int len);
static canonicalize_fn_t CanonicalizeEntry = NULL;
// Entry points in zip.dll for loading zip/jar file entries
@ -980,7 +982,7 @@ void ClassLoader::load_java_library() {
vm_exit_during_initialization("Unable to load java library", NULL);
}
CanonicalizeEntry = CAST_TO_FN_PTR(canonicalize_fn_t, dll_lookup(javalib_handle, "Canonicalize", NULL));
CanonicalizeEntry = CAST_TO_FN_PTR(canonicalize_fn_t, dll_lookup(javalib_handle, "JDK_Canonicalize", NULL));
}
void ClassLoader::load_zip_library() {
@ -1643,13 +1645,12 @@ void ClassLoader::classLoader_init2(TRAPS) {
bool ClassLoader::get_canonical_path(const char* orig, char* out, int len) {
assert(orig != NULL && out != NULL && len > 0, "bad arguments");
JavaThread* THREAD = JavaThread::current();
JNIEnv* env = THREAD->jni_environment();
ResourceMark rm(THREAD);
// os::native_path writes into orig_copy
char* orig_copy = NEW_RESOURCE_ARRAY_IN_THREAD(THREAD, char, strlen(orig)+1);
strcpy(orig_copy, orig);
if ((CanonicalizeEntry)(env, os::native_path(orig_copy), out, len) < 0) {
if ((CanonicalizeEntry)(os::native_path(orig_copy), out, len) < 0) {
return false;
}
return true;