1.1 --- a/src/share/vm/ci/ciField.cpp Mon Sep 09 19:53:28 2013 +0200 1.2 +++ b/src/share/vm/ci/ciField.cpp Tue Sep 10 14:51:48 2013 -0700 1.3 @@ -189,12 +189,14 @@ 1.4 _holder = CURRENT_ENV->get_instance_klass(fd->field_holder()); 1.5 1.6 // Check to see if the field is constant. 1.7 - if (_holder->is_initialized() && this->is_final()) { 1.8 + bool is_final = this->is_final(); 1.9 + bool is_stable = FoldStableValues && this->is_stable(); 1.10 + if (_holder->is_initialized() && (is_final || is_stable)) { 1.11 if (!this->is_static()) { 1.12 // A field can be constant if it's a final static field or if 1.13 // it's a final non-static field of a trusted class (classes in 1.14 // java.lang.invoke and sun.invoke packages and subpackages). 1.15 - if (trust_final_non_static_fields(_holder)) { 1.16 + if (is_stable || trust_final_non_static_fields(_holder)) { 1.17 _is_constant = true; 1.18 return; 1.19 } 1.20 @@ -227,7 +229,6 @@ 1.21 1.22 Handle mirror = k->java_mirror(); 1.23 1.24 - _is_constant = true; 1.25 switch(type()->basic_type()) { 1.26 case T_BYTE: 1.27 _constant_value = ciConstant(type()->basic_type(), mirror->byte_field(_offset)); 1.28 @@ -273,6 +274,12 @@ 1.29 } 1.30 } 1.31 } 1.32 + if (is_stable && _constant_value.is_null_or_zero()) { 1.33 + // It is not a constant after all; treat it as uninitialized. 1.34 + _is_constant = false; 1.35 + } else { 1.36 + _is_constant = true; 1.37 + } 1.38 } else { 1.39 _is_constant = false; 1.40 } 1.41 @@ -373,8 +380,11 @@ 1.42 tty->print(" signature="); 1.43 _signature->print_symbol(); 1.44 tty->print(" offset=%d type=", _offset); 1.45 - if (_type != NULL) _type->print_name(); 1.46 - else tty->print("(reference)"); 1.47 + if (_type != NULL) 1.48 + _type->print_name(); 1.49 + else 1.50 + tty->print("(reference)"); 1.51 + tty->print(" flags=%04x", flags().as_int()); 1.52 tty->print(" is_constant=%s", bool_to_str(_is_constant)); 1.53 if (_is_constant && is_static()) { 1.54 tty->print(" constant_value=");