< prev index next >

src/hotspot/share/jfr/instrumentation/jfrEventClassTransformer.cpp

Print this page




1448   new_ik->set_cached_class_file(p);
1449   JvmtiCachedClassFileData* const cached_class_data = ik->get_cached_class_file();
1450   if (cached_class_data != NULL) {
1451     os::free(cached_class_data);
1452     ik->set_cached_class_file(NULL);
1453   }
1454   return true;
1455 }
1456 
1457 static InstanceKlass* create_new_instance_klass(InstanceKlass* ik, ClassFileStream* stream, TRAPS) {
1458   assert(stream != NULL, "invariant");
1459   ResourceMark rm(THREAD);
1460   ClassLoaderData* const cld = ik->class_loader_data();
1461   Handle pd(THREAD, ik->protection_domain());
1462   Symbol* const class_name = ik->name();
1463   const char* const klass_name = class_name != NULL ? class_name->as_C_string() : "";
1464   ClassFileParser new_parser(stream,
1465                              class_name,
1466                              cld,
1467                              pd,
1468                              NULL, // host klass
1469                              NULL, // cp_patches


1470                              ClassFileParser::INTERNAL, // internal visibility
1471                              THREAD);
1472   if (HAS_PENDING_EXCEPTION) {
1473     log_pending_exception(PENDING_EXCEPTION);
1474     CLEAR_PENDING_EXCEPTION;
1475     return NULL;
1476   }
1477   InstanceKlass* const new_ik = new_parser.create_instance_klass(false, THREAD);

1478   if (HAS_PENDING_EXCEPTION) {
1479     log_pending_exception(PENDING_EXCEPTION);
1480     CLEAR_PENDING_EXCEPTION;
1481     return NULL;
1482   }
1483   assert(new_ik != NULL, "invariant");
1484   assert(new_ik->name() != NULL, "invariant");
1485   assert(strncmp(ik->name()->as_C_string(), new_ik->name()->as_C_string(), strlen(ik->name()->as_C_string())) == 0, "invariant");
1486   return cache_bytes(ik, stream, new_ik, THREAD) ? new_ik : NULL;
1487 }
1488 
1489 static void rewrite_klass_pointer(InstanceKlass*& ik, InstanceKlass* new_ik, ClassFileParser& parser, TRAPS) {
1490   assert(ik != NULL, "invariant");
1491   assert(new_ik != NULL, "invariant");
1492   assert(new_ik->name() != NULL, "invariant");
1493   assert(JdkJfrEvent::is(new_ik) || JdkJfrEvent::is_subklass(new_ik), "invariant");
1494   assert(!HAS_PENDING_EXCEPTION, "invariant");
1495   // assign original InstanceKlass* back onto "its" parser object for proper destruction
1496   parser.set_klass_to_deallocate(ik);
1497   // now rewrite original pointer to newly created InstanceKlass




1448   new_ik->set_cached_class_file(p);
1449   JvmtiCachedClassFileData* const cached_class_data = ik->get_cached_class_file();
1450   if (cached_class_data != NULL) {
1451     os::free(cached_class_data);
1452     ik->set_cached_class_file(NULL);
1453   }
1454   return true;
1455 }
1456 
1457 static InstanceKlass* create_new_instance_klass(InstanceKlass* ik, ClassFileStream* stream, TRAPS) {
1458   assert(stream != NULL, "invariant");
1459   ResourceMark rm(THREAD);
1460   ClassLoaderData* const cld = ik->class_loader_data();
1461   Handle pd(THREAD, ik->protection_domain());
1462   Symbol* const class_name = ik->name();
1463   const char* const klass_name = class_name != NULL ? class_name->as_C_string() : "";
1464   ClassFileParser new_parser(stream,
1465                              class_name,
1466                              cld,
1467                              pd,
1468                              NULL,  // host klass
1469                              NULL,  // cp_patches
1470                              false, // is_nonfindable
1471                              false, // can_access_vm_annotations
1472                              ClassFileParser::INTERNAL, // internal visibility
1473                              THREAD);
1474   if (HAS_PENDING_EXCEPTION) {
1475     log_pending_exception(PENDING_EXCEPTION);
1476     CLEAR_PENDING_EXCEPTION;
1477     return NULL;
1478   }
1479   InstanceKlass* const new_ik = new_parser.create_instance_klass(false, NULL,
1480                                                                  Handle(), THREAD);
1481   if (HAS_PENDING_EXCEPTION) {
1482     log_pending_exception(PENDING_EXCEPTION);
1483     CLEAR_PENDING_EXCEPTION;
1484     return NULL;
1485   }
1486   assert(new_ik != NULL, "invariant");
1487   assert(new_ik->name() != NULL, "invariant");
1488   assert(strncmp(ik->name()->as_C_string(), new_ik->name()->as_C_string(), strlen(ik->name()->as_C_string())) == 0, "invariant");
1489   return cache_bytes(ik, stream, new_ik, THREAD) ? new_ik : NULL;
1490 }
1491 
1492 static void rewrite_klass_pointer(InstanceKlass*& ik, InstanceKlass* new_ik, ClassFileParser& parser, TRAPS) {
1493   assert(ik != NULL, "invariant");
1494   assert(new_ik != NULL, "invariant");
1495   assert(new_ik->name() != NULL, "invariant");
1496   assert(JdkJfrEvent::is(new_ik) || JdkJfrEvent::is_subklass(new_ik), "invariant");
1497   assert(!HAS_PENDING_EXCEPTION, "invariant");
1498   // assign original InstanceKlass* back onto "its" parser object for proper destruction
1499   parser.set_klass_to_deallocate(ik);
1500   // now rewrite original pointer to newly created InstanceKlass


< prev index next >