MCPcopy Create free account
hub / github.com/async-profiler/async-profiler / ClassFileLoadHook

Method ClassFileLoadHook

src/instrument.cpp:1237–1258  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1235}
1236
1237void JNICALL Instrument::ClassFileLoadHook(jvmtiEnv* jvmti, JNIEnv* jni,
1238 jclass class_being_redefined, jobject loader,
1239 const char* name, jobject protection_domain,
1240 jint class_data_len, const u8* class_data,
1241 jint* new_class_data_len, u8** new_class_data) {
1242 // Do not retransform if the profiling has stopped
1243 if (!_running) return;
1244
1245 if (name == NULL) {
1246 // Maybe we'll find a matching class name in the cpool?
1247 BytecodeRewriter rewriter(class_data, class_data_len, &_targets, nullptr);
1248 rewriter.rewrite(new_class_data, new_class_data_len);
1249 return;
1250 }
1251
1252 size_t len = strlen(name);
1253 const MethodTargets* method_targets = findMethodTargets(&_targets, name, len);
1254 if (method_targets != nullptr) {
1255 BytecodeRewriter rewriter(class_data, class_data_len, nullptr, method_targets);
1256 rewriter.rewrite(new_class_data, new_class_data_len);
1257 }
1258}
1259
1260void JNICALL Instrument::recordEntry(JNIEnv* jni, jobject unused) {
1261 if (!_enabled) return;

Callers

nothing calls this directly

Calls 2

findMethodTargetsFunction · 0.85
rewriteMethod · 0.80

Tested by

no test coverage detected