204 } else { 205 _type = ciType::make(field_type); 206 } 207 208 initialize_from(fd); 209 210 // Either (a) it is marked shared, or else (b) we are done bootstrapping. 211 assert(is_shared() || ciObjectFactory::is_initialized(), 212 "bootstrap classes must not create & cache unshared fields"); 213 } 214 215 static bool trust_final_non_static_fields(ciInstanceKlass* holder) { 216 if (holder == NULL) 217 return false; 218 if (holder->name() == ciSymbol::java_lang_System()) 219 // Never trust strangely unstable finals: System.out, etc. 220 return false; 221 // Even if general trusting is disabled, trust system-built closures in these packages. 222 if (holder->is_in_package("java/lang/invoke") || holder->is_in_package("sun/invoke")) 223 return true; 224 // Trust VM unsafe anonymous classes. They are private API (jdk.internal.misc.Unsafe) 225 // and can't be serialized, so there is no hacking of finals going on with them. 226 if (holder->is_unsafe_anonymous()) 227 return true; 228 // Trust final fields in all boxed classes 229 if (holder->is_box_klass()) 230 return true; 231 // Trust final fields in String 232 if (holder->name() == ciSymbol::java_lang_String()) 233 return true; 234 // Trust Atomic*FieldUpdaters: they are very important for performance, and make up one 235 // more reason not to use Unsafe, if their final fields are trusted. See more in JDK-8140483. 236 if (holder->name() == ciSymbol::java_util_concurrent_atomic_AtomicIntegerFieldUpdater_Impl() || 237 holder->name() == ciSymbol::java_util_concurrent_atomic_AtomicLongFieldUpdater_CASUpdater() || 238 holder->name() == ciSymbol::java_util_concurrent_atomic_AtomicLongFieldUpdater_LockedUpdater() || 239 holder->name() == ciSymbol::java_util_concurrent_atomic_AtomicReferenceFieldUpdater_Impl()) { 240 return true; 241 } 242 return TrustFinalNonStaticFields; 243 } 244 245 void ciField::initialize_from(fieldDescriptor* fd) { 246 // Get the flags, offset, and canonical holder of the field. | 204 } else { 205 _type = ciType::make(field_type); 206 } 207 208 initialize_from(fd); 209 210 // Either (a) it is marked shared, or else (b) we are done bootstrapping. 211 assert(is_shared() || ciObjectFactory::is_initialized(), 212 "bootstrap classes must not create & cache unshared fields"); 213 } 214 215 static bool trust_final_non_static_fields(ciInstanceKlass* holder) { 216 if (holder == NULL) 217 return false; 218 if (holder->name() == ciSymbol::java_lang_System()) 219 // Never trust strangely unstable finals: System.out, etc. 220 return false; 221 // Even if general trusting is disabled, trust system-built closures in these packages. 222 if (holder->is_in_package("java/lang/invoke") || holder->is_in_package("sun/invoke")) 223 return true; 224 // Trust VM hidden and unsafe anonymous classes. They are created via Lookup.defineClass or 225 // the private API (jdk.internal.misc.Unsafe) and can't be serialized, so there is no hacking 226 // of finals going on with them. 227 if (holder->is_hidden() || holder->is_unsafe_anonymous()) 228 return true; 229 // Trust final fields in all boxed classes 230 if (holder->is_box_klass()) 231 return true; 232 // Trust final fields in String 233 if (holder->name() == ciSymbol::java_lang_String()) 234 return true; 235 // Trust Atomic*FieldUpdaters: they are very important for performance, and make up one 236 // more reason not to use Unsafe, if their final fields are trusted. See more in JDK-8140483. 237 if (holder->name() == ciSymbol::java_util_concurrent_atomic_AtomicIntegerFieldUpdater_Impl() || 238 holder->name() == ciSymbol::java_util_concurrent_atomic_AtomicLongFieldUpdater_CASUpdater() || 239 holder->name() == ciSymbol::java_util_concurrent_atomic_AtomicLongFieldUpdater_LockedUpdater() || 240 holder->name() == ciSymbol::java_util_concurrent_atomic_AtomicReferenceFieldUpdater_Impl()) { 241 return true; 242 } 243 return TrustFinalNonStaticFields; 244 } 245 246 void ciField::initialize_from(fieldDescriptor* fd) { 247 // Get the flags, offset, and canonical holder of the field. |