1992 |
1992 |
1993 void JvmtiExport::post_raw_field_modification(JavaThread *thread, Method* method, |
1993 void JvmtiExport::post_raw_field_modification(JavaThread *thread, Method* method, |
1994 address location, Klass* field_klass, Handle object, jfieldID field, |
1994 address location, Klass* field_klass, Handle object, jfieldID field, |
1995 char sig_type, jvalue *value) { |
1995 char sig_type, jvalue *value) { |
1996 |
1996 |
1997 if (sig_type == 'I' || sig_type == 'Z' || sig_type == 'B' || sig_type == 'C' || sig_type == 'S') { |
1997 if (sig_type == JVM_SIGNATURE_INT || sig_type == JVM_SIGNATURE_BOOLEAN || |
|
1998 sig_type == JVM_SIGNATURE_BYTE || sig_type == JVM_SIGNATURE_CHAR || |
|
1999 sig_type == JVM_SIGNATURE_SHORT) { |
1998 // 'I' instructions are used for byte, char, short and int. |
2000 // 'I' instructions are used for byte, char, short and int. |
1999 // determine which it really is, and convert |
2001 // determine which it really is, and convert |
2000 fieldDescriptor fd; |
2002 fieldDescriptor fd; |
2001 bool found = JvmtiEnv::get_field_descriptor(field_klass, field, &fd); |
2003 bool found = JvmtiEnv::get_field_descriptor(field_klass, field, &fd); |
2002 // should be found (if not, leave as is) |
2004 // should be found (if not, leave as is) |
2003 if (found) { |
2005 if (found) { |
2004 jint ival = value->i; |
2006 jint ival = value->i; |
2005 // convert value from int to appropriate type |
2007 // convert value from int to appropriate type |
2006 switch (fd.field_type()) { |
2008 switch (fd.field_type()) { |
2007 case T_BOOLEAN: |
2009 case T_BOOLEAN: |
2008 sig_type = 'Z'; |
2010 sig_type = JVM_SIGNATURE_BOOLEAN; |
2009 value->i = 0; // clear it |
2011 value->i = 0; // clear it |
2010 value->z = (jboolean)ival; |
2012 value->z = (jboolean)ival; |
2011 break; |
2013 break; |
2012 case T_BYTE: |
2014 case T_BYTE: |
2013 sig_type = 'B'; |
2015 sig_type = JVM_SIGNATURE_BYTE; |
2014 value->i = 0; // clear it |
2016 value->i = 0; // clear it |
2015 value->b = (jbyte)ival; |
2017 value->b = (jbyte)ival; |
2016 break; |
2018 break; |
2017 case T_CHAR: |
2019 case T_CHAR: |
2018 sig_type = 'C'; |
2020 sig_type = JVM_SIGNATURE_CHAR; |
2019 value->i = 0; // clear it |
2021 value->i = 0; // clear it |
2020 value->c = (jchar)ival; |
2022 value->c = (jchar)ival; |
2021 break; |
2023 break; |
2022 case T_SHORT: |
2024 case T_SHORT: |
2023 sig_type = 'S'; |
2025 sig_type = JVM_SIGNATURE_SHORT; |
2024 value->i = 0; // clear it |
2026 value->i = 0; // clear it |
2025 value->s = (jshort)ival; |
2027 value->s = (jshort)ival; |
2026 break; |
2028 break; |
2027 case T_INT: |
2029 case T_INT: |
2028 // nothing to do |
2030 // nothing to do |
2033 break; |
2035 break; |
2034 } |
2036 } |
2035 } |
2037 } |
2036 } |
2038 } |
2037 |
2039 |
2038 assert(sig_type != '[', "array should have sig_type == 'L'"); |
2040 assert(sig_type != JVM_SIGNATURE_ARRAY, "array should have sig_type == 'L'"); |
2039 bool handle_created = false; |
2041 bool handle_created = false; |
2040 |
2042 |
2041 // convert oop to JNI handle. |
2043 // convert oop to JNI handle. |
2042 if (sig_type == 'L') { |
2044 if (sig_type == JVM_SIGNATURE_CLASS) { |
2043 handle_created = true; |
2045 handle_created = true; |
2044 value->l = (jobject)JNIHandles::make_local(thread, (oop)value->l); |
2046 value->l = (jobject)JNIHandles::make_local(thread, (oop)value->l); |
2045 } |
2047 } |
2046 |
2048 |
2047 post_field_modification(thread, method, location, field_klass, object, field, sig_type, value); |
2049 post_field_modification(thread, method, location, field_klass, object, field, sig_type, value); |