8339316: Test runtime/exceptionMsgs/NoClassDefFoundError/NoClassDefFoundErrorTest.java fails after JDK-8338257

Reviewed-by: jsjolen, coleenp
This commit is contained in:
David Holmes 2024-09-04 23:58:17 +00:00
parent 55312e1549
commit 96df5a6d8f
7 changed files with 7 additions and 10 deletions

View File

@ -463,7 +463,7 @@ void ClassListParser::check_class_name(const char* class_name) {
err = "class name too long";
} else {
assert(Symbol::max_length() < INT_MAX && len < INT_MAX, "must be");
if (!UTF8::is_legal_utf8((const unsigned char*)class_name, (int)len, /*version_leq_47*/false)) {
if (!UTF8::is_legal_utf8((const unsigned char*)class_name, len, /*version_leq_47*/false)) {
err = "class name is not valid UTF8";
}
}
@ -849,4 +849,3 @@ void ClassListParser::parse_constant_pool_tag() {
ClassPrelinker::preresolve_field_and_method_cp_entries(THREAD, ik, &preresolve_list);
}
}

View File

@ -4559,7 +4559,8 @@ void ClassFileParser::verify_legal_utf8(const unsigned char* buffer,
int length,
TRAPS) const {
assert(_need_verify, "only called when _need_verify is true");
if (!UTF8::is_legal_utf8(buffer, length, _major_version <= 47)) {
// Note: 0 <= length < 64K, as it comes from a u2 entry in the CP.
if (!UTF8::is_legal_utf8(buffer, static_cast<size_t>(length), _major_version <= 47)) {
classfile_parse_error("Illegal UTF8 string in constant pool in class file %s", THREAD);
}
}

View File

@ -285,8 +285,7 @@ Symbol* SystemDictionary::class_name_symbol(const char* name, Symbol* exception,
return nullptr;
}
// Callers should ensure that the name is never an illegal UTF8 string.
assert(UTF8::is_legal_utf8((const unsigned char*)name,
static_cast<int>(name_len), false),
assert(UTF8::is_legal_utf8((const unsigned char*)name, name_len, false),
"Class name is not a valid utf8 string.");
// Make a new symbol for the class name.

View File

@ -475,7 +475,7 @@ void jniCheck::validate_class_descriptor(JavaThread* thr, const char* name) {
}
// Verify that the class name given is a valid utf8 string
if (!UTF8::is_legal_utf8((const unsigned char*)name, (int)strlen(name), false)) {
if (!UTF8::is_legal_utf8((const unsigned char*)name, strlen(name), false)) {
char msg[JVM_MAXPATHLEN];
jio_snprintf(msg, JVM_MAXPATHLEN, "%s%s%s", fatal_non_utf8_class_name1, name, fatal_non_utf8_class_name2);
ReportJNIFatalError(thr, msg);

View File

@ -809,7 +809,7 @@ JVM_ENTRY(jclass, JVM_FindClassFromBootLoader(JNIEnv* env,
// into the constant pool.
return nullptr;
}
assert(UTF8::is_legal_utf8((const unsigned char*)name, (int)strlen(name), false), "illegal UTF name");
assert(UTF8::is_legal_utf8((const unsigned char*)name, strlen(name), false), "illegal UTF name");
TempNewSymbol h_name = SymbolTable::new_symbol(name);
Klass* k = SystemDictionary::resolve_or_null(h_name, CHECK_NULL);

View File

@ -288,7 +288,7 @@ void Exceptions::fthrow(JavaThread* thread, const char* file, int line, Symbol*
// parameter controls a check for a specific character appearing in the "name", which is only
// allowed for classfile versions <= 47. We pass `true` so that we allow such strings as this code
// know nothing about the actual string content.
assert(UTF8::is_legal_utf8((const unsigned char*)msg, (int)strlen(msg), true), "must be");
assert(UTF8::is_legal_utf8((const unsigned char*)msg, strlen(msg), true), "must be");
_throw_msg(thread, file, line, h_name, msg);
}

View File

@ -118,8 +118,6 @@ runtime/ErrorHandling/TestDwarf.java#checkDecoder 8305489 linux-all
runtime/ErrorHandling/MachCodeFramesInErrorFile.java 8313315 linux-ppc64le
runtime/Thread/TestAlwaysPreTouchStacks.java 8335167 macosx-aarch64
runtime/cds/appcds/customLoader/HelloCustom_JFR.java 8241075 linux-all,windows-x64
runtime/exceptionMsgs/NoClassDefFoundError/NoClassDefFoundErrorTest.java 8339316 generic-all
applications/jcstress/copy.java 8229852 linux-all