77\*******************************************************************/
88
99#include " load_java_class.h"
10+ #include " free_form_cmdline.h"
1011#include < testing-utils/catch.hpp>
1112#include < iostream>
1213
1314#include < util/config.h>
14- #include < util/options.h>
1515#include < util/suffix.h>
1616
1717#include < goto-programs/lazy_goto_model.h>
1818
1919#include < java_bytecode/java_bytecode_language.h>
2020
21+ // / Go through the process of loading, type-checking and finalising loading a
22+ // / specific class file to build the symbol table. The functions are converted
23+ // / using ci_lazy_methods (equivalent to passing --lazy-methods to JBMC)
24+ // / \param java_class_name: The name of the class file to load. It should not
25+ // / include the .class extension.
26+ // / \param class_path: The path to load the class from. Should be relative to
27+ // / the unit directory.
28+ // / \param main: The name of the main function or "" to use the default
29+ // / behaviour to find a main function.
30+ // / \return The symbol table that is generated by parsing this file.
31+ symbol_tablet load_java_class_lazy (
32+ const std::string &java_class_name,
33+ const std::string &class_path,
34+ const std::string &main)
35+ {
36+ free_form_cmdlinet lazy_command_line;
37+ lazy_command_line.add_flag (" lazy-methods" );
38+
39+ return load_java_class (
40+ java_class_name,
41+ class_path,
42+ main,
43+ new_java_bytecode_language (),
44+ lazy_command_line);
45+ }
46+
2147// / Go through the process of loading, type-checking and finalising loading a
2248// / specific class file to build the symbol table.
2349// / \param java_class_name: The name of the class file to load. It should not
@@ -51,7 +77,8 @@ symbol_tablet load_java_class(
5177 const std::string &java_class_name,
5278 const std::string &class_path,
5379 const std::string &main,
54- std::unique_ptr<languaget> &&java_lang)
80+ std::unique_ptr<languaget> &&java_lang,
81+ const cmdlinet &command_line)
5582{
5683 // We expect the name of the class without the .class suffix to allow us to
5784 // check it
@@ -66,8 +93,6 @@ symbol_tablet load_java_class(
6693 message_handler);
6794
6895 // Configure the path loading
69- cmdlinet command_line;
70- command_line.set (" java-cp-include-files" , class_path);
7196 config.java .classpath .clear ();
7297 config.java .classpath .push_back (class_path);
7398 config.main = main;
@@ -109,3 +134,19 @@ symbol_tablet load_java_class(
109134 REQUIRE_FALSE (class_type.get_bool (ID_incomplete_class));
110135 return std::move (maybe_goto_model->symbol_table );
111136}
137+
138+ symbol_tablet load_java_class (
139+ const std::string &java_class_name,
140+ const std::string &class_path,
141+ const std::string &main,
142+ std::unique_ptr<languaget> &&java_lang)
143+ {
144+ cmdlinet command_line;
145+ // TODO(tkiley): This doesn't do anything as "java-cp-include-files" is an
146+ // TODO(tkiley): unknown argument. This could be changed by using the
147+ // TODO(tkiley): free_form_cmdlinet however this causes some tests to fail.
148+ // TODO(tkiley): TG-2708 to investigate and fix
149+ command_line.set (" java-cp-include-files" , class_path);
150+ return load_java_class (
151+ java_class_name, class_path, main, std::move (java_lang), command_line);
152+ }
0 commit comments