181 _name = env->get_symbol(fd->name()); 182 _signature = env->get_symbol(fd->signature()); 183 184 BasicType field_type = fd->field_type(); 185 186 // If the field is a pointer type, get the klass of the 187 // field. 188 if (field_type == T_OBJECT || field_type == T_ARRAY || field_type == T_VALUETYPE) { 189 _type = NULL; // must call compute_type on first access 190 } else { 191 _type = ciType::make(field_type); 192 } 193 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 | 181 _name = env->get_symbol(fd->name()); 182 _signature = env->get_symbol(fd->signature()); 183 184 BasicType field_type = fd->field_type(); 185 186 // If the field is a pointer type, get the klass of the 187 // field. 188 if (field_type == T_OBJECT || field_type == T_ARRAY || field_type == T_VALUETYPE) { 189 _type = NULL; // must call compute_type on first access 190 } else { 191 _type = ciType::make(field_type); 192 } 193 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 // Special copy constructor used to flatten value type fields by 202 // copying the fields of the value type to a new holder klass. 203 ciField::ciField(ciField* field, ciInstanceKlass* holder, int offset, bool is_final) { 204 assert(field->holder()->is_valuetype(), "should only be used for value type field flattening"); 205 // Set the is_final flag 206 jint final = is_final ? JVM_ACC_FINAL : ~JVM_ACC_FINAL; 207 AccessFlags flags(field->flags().as_int() & final); 208 _flags = ciFlags(flags); 209 _holder = holder; 210 _offset = offset; 211 // Copy remaining fields 212 _name = field->_name; 213 _signature = field->_signature; 214 _type = field->_type; 215 _is_constant = field->_is_constant; 216 _known_to_link_with_put = field->_known_to_link_with_put; 217 _known_to_link_with_get = field->_known_to_link_with_get; 218 _constant_value = field->_constant_value; 219 } 220 221 static bool trust_final_non_static_fields(ciInstanceKlass* holder) { 222 if (holder == NULL) 223 return false; 224 if (holder->name() == ciSymbol::java_lang_System()) 225 // Never trust strangely unstable finals: System.out, etc. 226 return false; 227 // Even if general trusting is disabled, trust system-built closures in these packages. 228 if (holder->is_in_package("java/lang/invoke") || holder->is_in_package("sun/invoke")) 229 return true; 230 // Trust VM anonymous classes. They are private API (sun.misc.Unsafe) and can't be serialized, 231 // so there is no hacking of finals going on with them. 232 if (holder->is_anonymous()) 233 return true; 234 // Trust final fields in all boxed classes 235 if (holder->is_box_klass()) 236 return true; 237 // Trust final fields in String 238 if (holder->name() == ciSymbol::java_lang_String()) 239 return true; 240 // Trust Atomic*FieldUpdaters: they are very important for performance, and make up one |