8214707: Prevent GCC 8 from reporting error in ClassLoader::file_name_for_class_name()
Reviewed-by: hseigel, dholmes
--- 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;
}