< prev index next >

src/hotspot/share/oops/instanceKlass.cpp

Print this page
rev 49250 : [mq]: JDK-8199739.patch


2238 }
2239 
2240 void InstanceKlass::set_source_debug_extension(const char* array, int length) {
2241   if (array == NULL) {
2242     _source_debug_extension = NULL;
2243   } else {
2244     // Adding one to the attribute length in order to store a null terminator
2245     // character could cause an overflow because the attribute length is
2246     // already coded with an u4 in the classfile, but in practice, it's
2247     // unlikely to happen.
2248     assert((length+1) > length, "Overflow checking");
2249     char* sde = NEW_C_HEAP_ARRAY(char, (length + 1), mtClass);
2250     for (int i = 0; i < length; i++) {
2251       sde[i] = array[i];
2252     }
2253     sde[length] = '\0';
2254     _source_debug_extension = sde;
2255   }
2256 }
2257 
2258 address InstanceKlass::static_field_addr(int offset) {
2259   assert(offset >= InstanceMirrorKlass::offset_of_static_fields(), "has already been adjusted");
2260   return (address)(offset + cast_from_oop<intptr_t>(java_mirror()));
2261 }
2262 
2263 
2264 const char* InstanceKlass::signature_name() const {
2265   int hash_len = 0;
2266   char hash_buf[40];
2267 
2268   // If this is an anonymous class, append a hash to make the name unique
2269   if (is_anonymous()) {
2270     intptr_t hash = (java_mirror() != NULL) ? java_mirror()->identity_hash() : 0;
2271     jio_snprintf(hash_buf, sizeof(hash_buf), "/" UINTX_FORMAT, (uintx)hash);
2272     hash_len = (int)strlen(hash_buf);
2273   }
2274 
2275   // Get the internal name as a c string
2276   const char* src = (const char*) (name()->as_C_string());
2277   const int src_length = (int)strlen(src);
2278 
2279   char* dest = NEW_RESOURCE_ARRAY(char, src_length + hash_len + 3);
2280 
2281   // Add L as type indicator
2282   int dest_index = 0;
2283   dest[dest_index++] = 'L';




2238 }
2239 
2240 void InstanceKlass::set_source_debug_extension(const char* array, int length) {
2241   if (array == NULL) {
2242     _source_debug_extension = NULL;
2243   } else {
2244     // Adding one to the attribute length in order to store a null terminator
2245     // character could cause an overflow because the attribute length is
2246     // already coded with an u4 in the classfile, but in practice, it's
2247     // unlikely to happen.
2248     assert((length+1) > length, "Overflow checking");
2249     char* sde = NEW_C_HEAP_ARRAY(char, (length + 1), mtClass);
2250     for (int i = 0; i < length; i++) {
2251       sde[i] = array[i];
2252     }
2253     sde[length] = '\0';
2254     _source_debug_extension = sde;
2255   }
2256 }
2257 






2258 const char* InstanceKlass::signature_name() const {
2259   int hash_len = 0;
2260   char hash_buf[40];
2261 
2262   // If this is an anonymous class, append a hash to make the name unique
2263   if (is_anonymous()) {
2264     intptr_t hash = (java_mirror() != NULL) ? java_mirror()->identity_hash() : 0;
2265     jio_snprintf(hash_buf, sizeof(hash_buf), "/" UINTX_FORMAT, (uintx)hash);
2266     hash_len = (int)strlen(hash_buf);
2267   }
2268 
2269   // Get the internal name as a c string
2270   const char* src = (const char*) (name()->as_C_string());
2271   const int src_length = (int)strlen(src);
2272 
2273   char* dest = NEW_RESOURCE_ARRAY(char, src_length + hash_len + 3);
2274 
2275   // Add L as type indicator
2276   int dest_index = 0;
2277   dest[dest_index++] = 'L';


< prev index next >