8214707: Prevent GCC 8 from reporting error in ClassLoader::file_name_for_class_name()
authordchuyko
Fri, 07 Dec 2018 10:48:39 +0300
changeset 52891 e1fcdc7ead4d
parent 52890 b0e751c70385
child 52892 442d322bb6d8
8214707: Prevent GCC 8 from reporting error in ClassLoader::file_name_for_class_name() Reviewed-by: hseigel, dholmes
src/hotspot/share/classfile/classLoader.cpp
--- a/src/hotspot/share/classfile/classLoader.cpp	Thu Dec 06 22:05:31 2018 -0800
+++ b/src/hotspot/share/classfile/classLoader.cpp	Fri Dec 07 10:48:39 2018 +0300
@@ -1224,13 +1224,14 @@
   assert((int)strlen(class_name) == class_name_len, "invariant");
 
   static const char class_suffix[] = ".class";
+  size_t class_suffix_len = sizeof(class_suffix);
 
   char* const file_name = NEW_RESOURCE_ARRAY(char,
                                              class_name_len +
-                                             sizeof(class_suffix)); // includes term NULL
+                                             class_suffix_len); // includes term NULL
 
   strncpy(file_name, class_name, class_name_len);
-  strncpy(&file_name[class_name_len], class_suffix, sizeof(class_suffix));
+  strncpy(&file_name[class_name_len], class_suffix, class_suffix_len);
 
   return file_name;
 }