1*33edd672SMark /* 2*33edd672SMark * Copyright 2021 Code Intelligence GmbH 3*33edd672SMark * 4*33edd672SMark * Licensed under the Apache License, Version 2.0 (the "License"); 5*33edd672SMark * you may not use this file except in compliance with the License. 6*33edd672SMark * You may obtain a copy of the License at 7*33edd672SMark * 8*33edd672SMark * http://www.apache.org/licenses/LICENSE-2.0 9*33edd672SMark * 10*33edd672SMark * Unless required by applicable law or agreed to in writing, software 11*33edd672SMark * distributed under the License is distributed on an "AS IS" BASIS, 12*33edd672SMark * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13*33edd672SMark * See the License for the specific language governing permissions and 14*33edd672SMark * limitations under the License. 15*33edd672SMark */ 16*33edd672SMark 17*33edd672SMark #pragma once 18*33edd672SMark 19*33edd672SMark #include <jni.h> 20*33edd672SMark 21*33edd672SMark #include <string> 22*33edd672SMark 23*33edd672SMark extern std::string FLAGS_cp; 24*33edd672SMark extern std::string FLAGS_jvm_args; 25*33edd672SMark extern std::string FLAGS_additional_jvm_args; 26*33edd672SMark extern std::string FLAGS_agent_path; 27*33edd672SMark 28*33edd672SMark namespace jazzer { 29*33edd672SMark 30*33edd672SMark void DumpJvmStackTraces(); 31*33edd672SMark 32*33edd672SMark // JVM is a thin wrapper around JNI_CreateJavaVM and DestroyJavaVM. The JVM 33*33edd672SMark // instance is created inside the constructor with some default JNI options 34*33edd672SMark // + options which can be added to via command line flags. 35*33edd672SMark class JVM { 36*33edd672SMark private: 37*33edd672SMark JavaVM *jvm_; 38*33edd672SMark JNIEnv *env_; 39*33edd672SMark 40*33edd672SMark public: 41*33edd672SMark // Creates a JVM instance with default options + options that were provided as 42*33edd672SMark // command line flags. 43*33edd672SMark explicit JVM(); 44*33edd672SMark 45*33edd672SMark // Destroy the running JVM instance. 46*33edd672SMark ~JVM(); 47*33edd672SMark 48*33edd672SMark // Get the JNI environment for interaction with the running JVM instance. 49*33edd672SMark JNIEnv &GetEnv() const; 50*33edd672SMark }; 51*33edd672SMark } /* namespace jazzer */ 52