diff --git a/unit/testing-utils/load_java_class.cpp b/unit/testing-utils/load_java_class.cpp index 737dae1a162..1a18a7bfa7d 100644 --- a/unit/testing-utils/load_java_class.cpp +++ b/unit/testing-utils/load_java_class.cpp @@ -19,24 +19,39 @@ #include -/// Go through the process of loading, typechecking and finalising loading a +/// Go through the process of loading, type-checking and finalising loading a /// specific class file to build the symbol table. /// \param java_class_name: The name of the class file to load. It should not /// include the .class extension. /// \param class_path: The path to load the class from. Should be relative to /// the unit directory. +/// \param main: The name of the main function or "" to use the default +/// behaviour to find a main function. /// \return The symbol table that is generated by parsing this file. symbol_tablet load_java_class( const std::string &java_class_name, - const std::string &class_path) + const std::string &class_path, + const std::string &main) { return load_java_class( - java_class_name, class_path, new_java_bytecode_language()); + java_class_name, class_path, main, new_java_bytecode_language()); } +/// Go through the process of loading, type-checking and finalising loading a +/// specific class file to build the symbol table. +/// \param java_class_name: The name of the class file to load. It should not +/// include the .class extension. +/// \param class_path: The path to load the class from. Should be relative to +/// the unit directory. +/// \param main: The name of the main function or "" to use the default +/// behaviour to find a main function. +/// \param java_lang: The language implementation to use for the loading, +/// which will be destroyed by this function. +/// \return The symbol table that is generated by parsing this file. symbol_tablet load_java_class( const std::string &java_class_name, const std::string &class_path, + const std::string &main, std::unique_ptr &&java_lang) { // We expect the name of the class without the .class suffix to allow us to @@ -58,6 +73,7 @@ symbol_tablet load_java_class( command_line.set("java-cp-include-files", class_path); config.java.classpath.clear(); config.java.classpath.push_back(class_path); + config.main = main; // Add the language to the model language_filet &lf=lazy_goto_model.add_language_file(filename); diff --git a/unit/testing-utils/load_java_class.h b/unit/testing-utils/load_java_class.h index 7460ca6d693..dc66a171511 100644 --- a/unit/testing-utils/load_java_class.h +++ b/unit/testing-utils/load_java_class.h @@ -19,11 +19,13 @@ symbol_tablet load_java_class( const std::string &java_class_name, - const std::string &class_path); + const std::string &class_path, + const std::string &main = ""); symbol_tablet load_java_class( const std::string &java_class_name, const std::string &class_path, + const std::string &main, std::unique_ptr &&java_lang); #endif // CPROVER_TESTING_UTILS_LOAD_JAVA_CLASS_H