8368961: Remove redundant checks in ciField.cpp

Reviewed-by: bmaillard, aseoane, thartmann
This commit is contained in:
Zihao Lin 2025-11-17 11:49:01 +00:00 committed by Tobias Hartmann
parent d19e072f97
commit df35412db1

View File

@ -216,9 +216,6 @@ ciField::ciField(fieldDescriptor *fd) :
static bool trust_final_non_static_fields(ciInstanceKlass* holder) {
if (holder == nullptr)
return false;
if (holder->name() == ciSymbols::java_lang_System())
// Never trust strangely unstable finals: System.out, etc.
return false;
// Even if general trusting is disabled, trust system-built closures in these packages.
if (holder->is_in_package("java/lang/invoke") || holder->is_in_package("sun/invoke") ||
holder->is_in_package("java/lang/reflect") || holder->is_in_package("jdk/internal/reflect") ||
@ -230,15 +227,9 @@ static bool trust_final_non_static_fields(ciInstanceKlass* holder) {
// can't be serialized, so there is no hacking of finals going on with them.
if (holder->is_hidden())
return true;
// Trust final fields in all boxed classes
if (holder->is_box_klass())
return true;
// Trust final fields in records
if (holder->is_record())
return true;
// Trust final fields in String
if (holder->name() == ciSymbols::java_lang_String())
return true;
// Trust Atomic*FieldUpdaters: they are very important for performance, and make up one
// more reason not to use Unsafe, if their final fields are trusted. See more in JDK-8140483.
if (holder->name() == ciSymbols::java_util_concurrent_atomic_AtomicIntegerFieldUpdater_Impl() ||