Mercurial > hg > truffle
comparison src/share/vm/oops/instanceKlass.cpp @ 6203:04ade88d9712
6294277: java -Xdebug crashes on SourceDebugExtension attribute larger than 64K
Reviewed-by: sspitsyn, dholmes, coleenp, kamg
author | fparain |
---|---|
date | Mon, 09 Jul 2012 01:28:37 -0700 |
parents | d2a62e0f25eb |
children | 1d7922586cf6 |
comparison
equal
deleted
inserted
replaced
6202:5a1f452f8f90 | 6203:04ade88d9712 |
---|---|
845 | 845 |
846 void instanceKlass::shared_symbols_iterate(SymbolClosure* closure) { | 846 void instanceKlass::shared_symbols_iterate(SymbolClosure* closure) { |
847 Klass::shared_symbols_iterate(closure); | 847 Klass::shared_symbols_iterate(closure); |
848 closure->do_symbol(&_generic_signature); | 848 closure->do_symbol(&_generic_signature); |
849 closure->do_symbol(&_source_file_name); | 849 closure->do_symbol(&_source_file_name); |
850 closure->do_symbol(&_source_debug_extension); | |
851 | 850 |
852 for (JavaFieldStream fs(this); !fs.done(); fs.next()) { | 851 for (JavaFieldStream fs(this); !fs.done(); fs.next()) { |
853 int name_index = fs.name_index(); | 852 int name_index = fs.name_index(); |
854 closure->do_symbol(constants()->symbol_at_addr(name_index)); | 853 closure->do_symbol(constants()->symbol_at_addr(name_index)); |
855 int sig_index = fs.signature_index(); | 854 int sig_index = fs.signature_index(); |
1942 if (_name != NULL) _name->decrement_refcount(); | 1941 if (_name != NULL) _name->decrement_refcount(); |
1943 // unreference array name derived from this class name (arrays of an unloaded | 1942 // unreference array name derived from this class name (arrays of an unloaded |
1944 // class can't be referenced anymore). | 1943 // class can't be referenced anymore). |
1945 if (_array_name != NULL) _array_name->decrement_refcount(); | 1944 if (_array_name != NULL) _array_name->decrement_refcount(); |
1946 if (_source_file_name != NULL) _source_file_name->decrement_refcount(); | 1945 if (_source_file_name != NULL) _source_file_name->decrement_refcount(); |
1947 if (_source_debug_extension != NULL) _source_debug_extension->decrement_refcount(); | |
1948 // walk constant pool and decrement symbol reference counts | 1946 // walk constant pool and decrement symbol reference counts |
1949 _constants->unreference_symbols(); | 1947 _constants->unreference_symbols(); |
1948 | |
1949 if (_source_debug_extension != NULL) FREE_C_HEAP_ARRAY(char, _source_debug_extension, mtClass); | |
1950 } | 1950 } |
1951 | 1951 |
1952 void instanceKlass::set_source_file_name(Symbol* n) { | 1952 void instanceKlass::set_source_file_name(Symbol* n) { |
1953 _source_file_name = n; | 1953 _source_file_name = n; |
1954 if (_source_file_name != NULL) _source_file_name->increment_refcount(); | 1954 if (_source_file_name != NULL) _source_file_name->increment_refcount(); |
1955 } | 1955 } |
1956 | 1956 |
1957 void instanceKlass::set_source_debug_extension(Symbol* n) { | 1957 void instanceKlass::set_source_debug_extension(char* array, int length) { |
1958 _source_debug_extension = n; | 1958 if (array == NULL) { |
1959 if (_source_debug_extension != NULL) _source_debug_extension->increment_refcount(); | 1959 _source_debug_extension = NULL; |
1960 } else { | |
1961 // Adding one to the attribute length in order to store a null terminator | |
1962 // character could cause an overflow because the attribute length is | |
1963 // already coded with an u4 in the classfile, but in practice, it's | |
1964 // unlikely to happen. | |
1965 assert((length+1) > length, "Overflow checking"); | |
1966 char* sde = NEW_C_HEAP_ARRAY(char, (length + 1), mtClass); | |
1967 for (int i = 0; i < length; i++) { | |
1968 sde[i] = array[i]; | |
1969 } | |
1970 sde[length] = '\0'; | |
1971 _source_debug_extension = sde; | |
1972 } | |
1960 } | 1973 } |
1961 | 1974 |
1962 address instanceKlass::static_field_addr(int offset) { | 1975 address instanceKlass::static_field_addr(int offset) { |
1963 return (address)(offset + instanceMirrorKlass::offset_of_static_fields() + (intptr_t)java_mirror()); | 1976 return (address)(offset + instanceMirrorKlass::offset_of_static_fields() + (intptr_t)java_mirror()); |
1964 } | 1977 } |