194 initialize_from(fd); 195 196 // Either (a) it is marked shared, or else (b) we are done bootstrapping. 197 assert(is_shared() || ciObjectFactory::is_initialized(), 198 "bootstrap classes must not create & cache unshared fields"); 199 } 200 201 static bool trust_final_non_static_fields(ciInstanceKlass* holder) { 202 if (holder == NULL) 203 return false; 204 if (holder->name() == ciSymbol::java_lang_System()) 205 // Never trust strangely unstable finals: System.out, etc. 206 return false; 207 // Even if general trusting is disabled, trust system-built closures in these packages. 208 if (holder->is_in_package("java/lang/invoke") || holder->is_in_package("sun/invoke")) 209 return true; 210 // Trust VM anonymous classes. They are private API (sun.misc.Unsafe) and can't be serialized, 211 // so there is no hacking of finals going on with them. 212 if (holder->is_anonymous()) 213 return true; 214 // Trust Atomic*FieldUpdaters: they are very important for performance, and make up one 215 // more reason not to use Unsafe, if their final fields are trusted. See more in JDK-8140483. 216 if (holder->name() == ciSymbol::java_util_concurrent_atomic_AtomicIntegerFieldUpdater_Impl() || 217 holder->name() == ciSymbol::java_util_concurrent_atomic_AtomicLongFieldUpdater_CASUpdater() || 218 holder->name() == ciSymbol::java_util_concurrent_atomic_AtomicLongFieldUpdater_LockedUpdater() || 219 holder->name() == ciSymbol::java_util_concurrent_atomic_AtomicReferenceFieldUpdater_Impl()) { 220 return true; 221 } 222 return TrustFinalNonStaticFields; 223 } 224 225 void ciField::initialize_from(fieldDescriptor* fd) { 226 // Get the flags, offset, and canonical holder of the field. 227 _flags = ciFlags(fd->access_flags()); 228 _offset = fd->offset(); 229 _holder = CURRENT_ENV->get_instance_klass(fd->field_holder()); 230 231 // Check to see if the field is constant. 232 bool is_final = this->is_final(); 233 bool is_stable = FoldStableValues && this->is_stable(); | 194 initialize_from(fd); 195 196 // Either (a) it is marked shared, or else (b) we are done bootstrapping. 197 assert(is_shared() || ciObjectFactory::is_initialized(), 198 "bootstrap classes must not create & cache unshared fields"); 199 } 200 201 static bool trust_final_non_static_fields(ciInstanceKlass* holder) { 202 if (holder == NULL) 203 return false; 204 if (holder->name() == ciSymbol::java_lang_System()) 205 // Never trust strangely unstable finals: System.out, etc. 206 return false; 207 // Even if general trusting is disabled, trust system-built closures in these packages. 208 if (holder->is_in_package("java/lang/invoke") || holder->is_in_package("sun/invoke")) 209 return true; 210 // Trust VM anonymous classes. They are private API (sun.misc.Unsafe) and can't be serialized, 211 // so there is no hacking of finals going on with them. 212 if (holder->is_anonymous()) 213 return true; 214 // Trust final fields in all boxed classes 215 if (holder->is_box_klass()) 216 return true; 217 // Trust final fields in String 218 if (holder->name() == ciSymbol::java_lang_String()) 219 return true; 220 // Trust Atomic*FieldUpdaters: they are very important for performance, and make up one 221 // more reason not to use Unsafe, if their final fields are trusted. See more in JDK-8140483. 222 if (holder->name() == ciSymbol::java_util_concurrent_atomic_AtomicIntegerFieldUpdater_Impl() || 223 holder->name() == ciSymbol::java_util_concurrent_atomic_AtomicLongFieldUpdater_CASUpdater() || 224 holder->name() == ciSymbol::java_util_concurrent_atomic_AtomicLongFieldUpdater_LockedUpdater() || 225 holder->name() == ciSymbol::java_util_concurrent_atomic_AtomicReferenceFieldUpdater_Impl()) { 226 return true; 227 } 228 return TrustFinalNonStaticFields; 229 } 230 231 void ciField::initialize_from(fieldDescriptor* fd) { 232 // Get the flags, offset, and canonical holder of the field. 233 _flags = ciFlags(fd->access_flags()); 234 _offset = fd->offset(); 235 _holder = CURRENT_ENV->get_instance_klass(fd->field_holder()); 236 237 // Check to see if the field is constant. 238 bool is_final = this->is_final(); 239 bool is_stable = FoldStableValues && this->is_stable(); |