src/hotspot/share/jfr/jni/jfrJavaSupport.cpp
changeset 53418 bc2bb4eee477
parent 51467 12997ebbc0d8
child 54847 59ea39bb2809
equal deleted inserted replaced
53417:126c5e7b97b1 53418:bc2bb4eee477
     1 /*
     1 /*
     2  * Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved.
     2  * Copyright (c) 2016, 2019, Oracle and/or its affiliates. All rights reserved.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     4  *
     4  *
     5  * This code is free software; you can redistribute it and/or modify it
     5  * This code is free software; you can redistribute it and/or modify it
     6  * under the terms of the GNU General Public License version 2 only, as
     6  * under the terms of the GNU General Public License version 2 only, as
     7  * published by the Free Software Foundation.
     7  * published by the Free Software Foundation.
   472   if (string == NULL) {
   472   if (string == NULL) {
   473     return NULL;
   473     return NULL;
   474   }
   474   }
   475   const char* temp = NULL;
   475   const char* temp = NULL;
   476   const oop java_string = resolve_non_null(string);
   476   const oop java_string = resolve_non_null(string);
   477   if (java_lang_String::value(java_string) != NULL) {
   477   const typeArrayOop value = java_lang_String::value(java_string);
   478     const size_t length = java_lang_String::utf8_length(java_string);
   478   if (value != NULL) {
       
   479     const size_t length = java_lang_String::utf8_length(java_string, value);
   479     temp = NEW_RESOURCE_ARRAY_IN_THREAD(t, const char, (length + 1));
   480     temp = NEW_RESOURCE_ARRAY_IN_THREAD(t, const char, (length + 1));
   480     if (temp == NULL) {
   481     if (temp == NULL) {
   481        JfrJavaSupport::throw_out_of_memory_error("Unable to allocate thread local native memory", t);
   482        JfrJavaSupport::throw_out_of_memory_error("Unable to allocate thread local native memory", t);
   482        return NULL;
   483        return NULL;
   483     }
   484     }
   484     assert(temp != NULL, "invariant");
   485     assert(temp != NULL, "invariant");
   485     java_lang_String::as_utf8_string(java_string, const_cast<char*>(temp), (int) length + 1);
   486     java_lang_String::as_utf8_string(java_string, value, const_cast<char*>(temp), (int) length + 1);
   486   }
   487   }
   487   return temp;
   488   return temp;
   488 }
   489 }
   489 
   490 
   490 /*
   491 /*