7
7
\*******************************************************************/
8
8
9
9
#include " load_java_class.h"
10
+ #include " free_form_cmdline.h"
10
11
#include < testing-utils/catch.hpp>
11
12
#include < iostream>
12
13
13
14
#include < util/config.h>
14
- #include < util/options.h>
15
15
#include < util/suffix.h>
16
16
17
17
#include < goto-programs/lazy_goto_model.h>
18
18
19
19
#include < java_bytecode/java_bytecode_language.h>
20
20
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
+
21
47
// / Go through the process of loading, type-checking and finalising loading a
22
48
// / specific class file to build the symbol table.
23
49
// / \param java_class_name: The name of the class file to load. It should not
@@ -51,7 +77,8 @@ symbol_tablet load_java_class(
51
77
const std::string &java_class_name,
52
78
const std::string &class_path,
53
79
const std::string &main,
54
- std::unique_ptr<languaget> &&java_lang)
80
+ std::unique_ptr<languaget> &&java_lang,
81
+ const cmdlinet &command_line)
55
82
{
56
83
// We expect the name of the class without the .class suffix to allow us to
57
84
// check it
@@ -66,8 +93,6 @@ symbol_tablet load_java_class(
66
93
message_handler);
67
94
68
95
// Configure the path loading
69
- cmdlinet command_line;
70
- command_line.set (" java-cp-include-files" , class_path);
71
96
config.java .classpath .clear ();
72
97
config.java .classpath .push_back (class_path);
73
98
config.main = main;
@@ -109,3 +134,19 @@ symbol_tablet load_java_class(
109
134
REQUIRE_FALSE (class_type.get_bool (ID_incomplete_class));
110
135
return std::move (maybe_goto_model->symbol_table );
111
136
}
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