| 55 | } |
| 56 | |
| 57 | extern "C" DLLEXPORT jstring JNICALL |
| 58 | Java_one_profiler_AsyncProfiler_execute0(JNIEnv* env, jobject unused, jstring command) { |
| 59 | Arguments args; |
| 60 | const char* command_str = env->GetStringUTFChars(command, NULL); |
| 61 | Error error = args.parse(command_str); |
| 62 | env->ReleaseStringUTFChars(command, command_str); |
| 63 | |
| 64 | if (error) { |
| 65 | throwNew(env, "java/lang/IllegalArgumentException", error.message()); |
| 66 | return NULL; |
| 67 | } |
| 68 | |
| 69 | Log::open(args); |
| 70 | |
| 71 | if (!args.hasOutputFile()) { |
| 72 | BufferWriter out; |
| 73 | error = Profiler::instance()->runInternal(args, out); |
| 74 | if (!error) { |
| 75 | out << '\0'; |
| 76 | if (out.size() >= 0x3fffffff) { |
| 77 | throwNew(env, "java/lang/IllegalStateException", "Output exceeds string size limit"); |
| 78 | return NULL; |
| 79 | } |
| 80 | return env->NewStringUTF(out.buf()); |
| 81 | } |
| 82 | } else { |
| 83 | FileWriter out(args.file()); |
| 84 | if (!out.is_open()) { |
| 85 | throwNew(env, "java/io/IOException", strerror(errno)); |
| 86 | return NULL; |
| 87 | } |
| 88 | error = Profiler::instance()->runInternal(args, out); |
| 89 | if (!error) { |
| 90 | return env->NewStringUTF("OK"); |
| 91 | } |
| 92 | } |
| 93 | |
| 94 | throwNew(env, "java/lang/IllegalStateException", error.message()); |
| 95 | return NULL; |
| 96 | } |
| 97 | |
| 98 | extern "C" DLLEXPORT jbyteArray JNICALL |
| 99 | Java_one_profiler_AsyncProfiler_execute1(JNIEnv* env, jobject unused, jstring command) { |
nothing calls this directly
no test coverage detected