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

Function executeJvmTask

test/test/nonjava/non_java_app.cpp:158–181  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

156}
157
158void executeJvmTask() {
159 jclass customClass = _env->FindClass("test/nonjava/JavaClass");
160 if (customClass == nullptr) {
161 std::cerr << "Can't find JavaClass" << std::endl;
162 exit(1);
163 }
164
165 jmethodID cpuHeavyTask = _env->GetStaticMethodID(customClass, "cpuHeavyTask", "()D");
166 if (cpuHeavyTask == nullptr) {
167 std::cerr << "Can't find cpuHeavyTask" << std::endl;
168 exit(1);
169 }
170
171 for (int i = 0; i < 300; ++i) {
172 jdouble result = _env->CallStaticDoubleMethod(customClass, cpuHeavyTask);
173 if (_env->ExceptionCheck()) {
174 _env->ExceptionDescribe();
175 std::cerr << "Exception in cpuHeavyTask" << std::endl;
176 exit(1);
177 }
178 std::cout << "Result: " << result << std::endl;
179 }
180 _env->DeleteLocalRef(customClass);
181}
182
183void stopJvm() {
184 jint rc = _jvm->DestroyJavaVM();

Callers 4

testFlow1Function · 0.85
testFlow2Function · 0.85
testFlow3Function · 0.85
jvmThreadWrapperFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected