hotspot/src/share/vm/prims/jvmtiRedefineClasses.cpp
changeset 33604 ad1cd9269bd4
parent 33602 16053580a684
child 33606 af4ec8a4635b
equal deleted inserted replaced
33603:450d454670a7 33604:ad1cd9269bd4
  1890       ("length() is too small for annotation_struct"));
  1890       ("length() is too small for annotation_struct"));
  1891     return false;
  1891     return false;
  1892   }
  1892   }
  1893 
  1893 
  1894   u2 type_index = rewrite_cp_ref_in_annotation_data(annotations_typeArray,
  1894   u2 type_index = rewrite_cp_ref_in_annotation_data(annotations_typeArray,
  1895                     byte_i_ref, "mapped old type_index=%d", THREAD);
  1895                     byte_i_ref, "type_index", THREAD);
  1896 
  1896 
  1897   u2 num_element_value_pairs = Bytes::get_Java_u2((address)
  1897   u2 num_element_value_pairs = Bytes::get_Java_u2((address)
  1898                                  annotations_typeArray->adr_at(byte_i_ref));
  1898                                  annotations_typeArray->adr_at(byte_i_ref));
  1899   byte_i_ref += 2;
  1899   byte_i_ref += 2;
  1900 
  1900 
  1913       return false;
  1913       return false;
  1914     }
  1914     }
  1915 
  1915 
  1916     u2 element_name_index = rewrite_cp_ref_in_annotation_data(
  1916     u2 element_name_index = rewrite_cp_ref_in_annotation_data(
  1917                               annotations_typeArray, byte_i_ref,
  1917                               annotations_typeArray, byte_i_ref,
  1918                               "mapped old element_name_index=%d", THREAD);
  1918                               "element_name_index", THREAD);
  1919 
  1919 
  1920     RC_TRACE_WITH_THREAD(0x02000000, THREAD,
  1920     RC_TRACE_WITH_THREAD(0x02000000, THREAD,
  1921       ("element_name_index=%d", element_name_index));
  1921       ("element_name_index=%d", element_name_index));
  1922 
  1922 
  1923     if (!rewrite_cp_refs_in_element_value(annotations_typeArray,
  1923     if (!rewrite_cp_refs_in_element_value(annotations_typeArray,
  1937 
  1937 
  1938 // Rewrite a constant pool reference at the current position in
  1938 // Rewrite a constant pool reference at the current position in
  1939 // annotations_typeArray if needed. Returns the original constant
  1939 // annotations_typeArray if needed. Returns the original constant
  1940 // pool reference if a rewrite was not needed or the new constant
  1940 // pool reference if a rewrite was not needed or the new constant
  1941 // pool reference if a rewrite was needed.
  1941 // pool reference if a rewrite was needed.
  1942 PRAGMA_DIAG_PUSH
       
  1943 PRAGMA_FORMAT_NONLITERAL_IGNORED
       
  1944 u2 VM_RedefineClasses::rewrite_cp_ref_in_annotation_data(
  1942 u2 VM_RedefineClasses::rewrite_cp_ref_in_annotation_data(
  1945      AnnotationArray* annotations_typeArray, int &byte_i_ref,
  1943      AnnotationArray* annotations_typeArray, int &byte_i_ref,
  1946      const char * trace_mesg, TRAPS) {
  1944      const char * trace_mesg, TRAPS) {
  1947 
  1945 
  1948   address cp_index_addr = (address)
  1946   address cp_index_addr = (address)
  1949     annotations_typeArray->adr_at(byte_i_ref);
  1947     annotations_typeArray->adr_at(byte_i_ref);
  1950   u2 old_cp_index = Bytes::get_Java_u2(cp_index_addr);
  1948   u2 old_cp_index = Bytes::get_Java_u2(cp_index_addr);
  1951   u2 new_cp_index = find_new_index(old_cp_index);
  1949   u2 new_cp_index = find_new_index(old_cp_index);
  1952   if (new_cp_index != 0) {
  1950   if (new_cp_index != 0) {
  1953     RC_TRACE_WITH_THREAD(0x02000000, THREAD, (trace_mesg, old_cp_index));
  1951     RC_TRACE_WITH_THREAD(0x02000000, THREAD, ("mapped old %s=%d", trace_mesg, old_cp_index));
  1954     Bytes::put_Java_u2(cp_index_addr, new_cp_index);
  1952     Bytes::put_Java_u2(cp_index_addr, new_cp_index);
  1955     old_cp_index = new_cp_index;
  1953     old_cp_index = new_cp_index;
  1956   }
  1954   }
  1957   byte_i_ref += 2;
  1955   byte_i_ref += 2;
  1958   return old_cp_index;
  1956   return old_cp_index;
  1959 }
  1957 }
  1960 PRAGMA_DIAG_POP
       
  1961 
  1958 
  1962 
  1959 
  1963 // Rewrite constant pool references in the element_value portion of an
  1960 // Rewrite constant pool references in the element_value portion of an
  1964 // annotations_typeArray. This "structure" is from section 4.8.15.1 of
  1961 // annotations_typeArray. This "structure" is from section 4.8.15.1 of
  1965 // the 2nd-edition of the VM spec:
  1962 // the 2nd-edition of the VM spec:
  2020         return false;
  2017         return false;
  2021       }
  2018       }
  2022 
  2019 
  2023       u2 const_value_index = rewrite_cp_ref_in_annotation_data(
  2020       u2 const_value_index = rewrite_cp_ref_in_annotation_data(
  2024                                annotations_typeArray, byte_i_ref,
  2021                                annotations_typeArray, byte_i_ref,
  2025                                "mapped old const_value_index=%d", THREAD);
  2022                                "const_value_index", THREAD);
  2026 
  2023 
  2027       RC_TRACE_WITH_THREAD(0x02000000, THREAD,
  2024       RC_TRACE_WITH_THREAD(0x02000000, THREAD,
  2028         ("const_value_index=%d", const_value_index));
  2025         ("const_value_index=%d", const_value_index));
  2029     } break;
  2026     } break;
  2030 
  2027 
  2039         return false;
  2036         return false;
  2040       }
  2037       }
  2041 
  2038 
  2042       u2 type_name_index = rewrite_cp_ref_in_annotation_data(
  2039       u2 type_name_index = rewrite_cp_ref_in_annotation_data(
  2043                              annotations_typeArray, byte_i_ref,
  2040                              annotations_typeArray, byte_i_ref,
  2044                              "mapped old type_name_index=%d", THREAD);
  2041                              "type_name_index", THREAD);
  2045 
  2042 
  2046       u2 const_name_index = rewrite_cp_ref_in_annotation_data(
  2043       u2 const_name_index = rewrite_cp_ref_in_annotation_data(
  2047                               annotations_typeArray, byte_i_ref,
  2044                               annotations_typeArray, byte_i_ref,
  2048                               "mapped old const_name_index=%d", THREAD);
  2045                               "const_name_index", THREAD);
  2049 
  2046 
  2050       RC_TRACE_WITH_THREAD(0x02000000, THREAD,
  2047       RC_TRACE_WITH_THREAD(0x02000000, THREAD,
  2051         ("type_name_index=%d  const_name_index=%d", type_name_index,
  2048         ("type_name_index=%d  const_name_index=%d", type_name_index,
  2052         const_name_index));
  2049         const_name_index));
  2053     } break;
  2050     } break;
  2063         return false;
  2060         return false;
  2064       }
  2061       }
  2065 
  2062 
  2066       u2 class_info_index = rewrite_cp_ref_in_annotation_data(
  2063       u2 class_info_index = rewrite_cp_ref_in_annotation_data(
  2067                               annotations_typeArray, byte_i_ref,
  2064                               annotations_typeArray, byte_i_ref,
  2068                               "mapped old class_info_index=%d", THREAD);
  2065                               "class_info_index", THREAD);
  2069 
  2066 
  2070       RC_TRACE_WITH_THREAD(0x02000000, THREAD,
  2067       RC_TRACE_WITH_THREAD(0x02000000, THREAD,
  2071         ("class_info_index=%d", class_info_index));
  2068         ("class_info_index=%d", class_info_index));
  2072     } break;
  2069     } break;
  2073 
  2070