17
17
#include " java_bytecode_parser.h"
18
18
19
19
java_class_loadert::parse_tree_with_overlayst &java_class_loadert::operator ()(
20
- const irep_idt &class_name)
20
+ const irep_idt &class_name,
21
+ message_handlert &message_handler)
21
22
{
22
23
debug () << " Classpath:" ;
23
24
for (const auto &entry : classpath_entries)
@@ -44,7 +45,7 @@ java_class_loadert::parse_tree_with_overlayst &java_class_loadert::operator()(
44
45
queue.push (id);
45
46
46
47
java_class_loader_limitt class_loader_limit (
47
- get_message_handler () , java_cp_include_files);
48
+ message_handler , java_cp_include_files);
48
49
49
50
while (!queue.empty ())
50
51
{
@@ -54,10 +55,11 @@ java_class_loadert::parse_tree_with_overlayst &java_class_loadert::operator()(
54
55
if (class_map.count (c) != 0 )
55
56
continue ;
56
57
57
- debug () << " Reading class " << c << eom;
58
+ messaget log (message_handler);
59
+ log.debug () << " Reading class " << c << messaget::eom;
58
60
59
61
parse_tree_with_overlayst &parse_trees =
60
- get_parse_tree (class_loader_limit, c);
62
+ get_parse_tree (class_loader_limit, c, message_handler );
61
63
62
64
// Add any dependencies to queue
63
65
for (const java_bytecode_parse_treet &parse_tree : parse_trees)
@@ -121,6 +123,7 @@ bool java_class_loadert::can_load_class(const irep_idt &class_name)
121
123
// / to find the .class file.
122
124
// / \param class_loader_limit: Filter to decide whether to load classes
123
125
// / \param class_name: Name of class to load
126
+ // / \param message_handler: message handler
124
127
// / \return The list of valid implementations, including overlays
125
128
// / \remarks
126
129
// / Allows multiple definitions of the same class to appear on the
@@ -129,23 +132,26 @@ bool java_class_loadert::can_load_class(const irep_idt &class_name)
129
132
java_class_loadert::parse_tree_with_overlayst &
130
133
java_class_loadert::get_parse_tree (
131
134
java_class_loader_limitt &class_loader_limit,
132
- const irep_idt &class_name)
135
+ const irep_idt &class_name,
136
+ message_handlert &message_handler)
133
137
{
134
138
parse_tree_with_overlayst &parse_trees = class_map[class_name];
135
139
PRECONDITION (parse_trees.empty ());
136
140
141
+ messaget log (message_handler);
142
+
137
143
// do we refuse to load?
138
144
if (!class_loader_limit.load_class_file (class_name_to_jar_file (class_name)))
139
145
{
140
- debug () << " not loading " << class_name << " because of limit" << eom;
146
+ log. debug () << " not loading " << class_name << " because of limit" << messaget:: eom;
141
147
parse_trees.emplace_back (class_name);
142
148
return parse_trees;
143
149
}
144
150
145
151
// Rummage through the class path
146
152
for (const auto &cp_entry : classpath_entries)
147
153
{
148
- auto parse_tree = load_class (class_name, cp_entry);
154
+ auto parse_tree = load_class (class_name, cp_entry, message_handler );
149
155
if (parse_tree.has_value ())
150
156
parse_trees.emplace_back (std::move (*parse_tree));
151
157
}
@@ -164,10 +170,18 @@ java_class_loadert::get_parse_tree(
164
170
++parse_tree_it;
165
171
break ;
166
172
}
173
+ <<<<<<< HEAD
167
174
debug () << " Skipping class " << class_name
168
175
<< " marked with OverlayClassImplementation but found before"
169
176
" original definition"
170
177
<< eom;
178
+ =======
179
+ log.warning ()
180
+ << " Skipping class " << class_name
181
+ << " marked with OverlayClassImplementation but found before"
182
+ " original definition"
183
+ << messaget::eom;
184
+ >>>>>>> java_class_loader (_base)t isn' t a messaget
171
185
}
172
186
auto unloaded_or_overlay_out_of_order_it = parse_tree_it;
173
187
++parse_tree_it;
@@ -179,8 +193,14 @@ java_class_loadert::get_parse_tree(
179
193
// Remove non-initial classes that aren' t overlays
180
194
if (!is_overlay_class (parse_tree_it->parsed_class ))
181
195
{
196
+ <<<<<<< HEAD
182
197
debug () << " Skipping duplicate definition of class " << class_name
183
198
<< " not marked with OverlayClassImplementation" << eom;
199
+ =======
200
+ log.warning ()
201
+ << " Skipping duplicate definition of class " << class_name
202
+ << " not marked with OverlayClassImplementation" << messaget::eom;
203
+ >>>>>>> java_class_loader (_base)t isn' t a messaget
184
204
auto duplicate_non_overlay_it = parse_tree_it;
185
205
++parse_tree_it;
186
206
parse_trees.erase(duplicate_non_overlay_it);
@@ -192,45 +212,60 @@ java_class_loadert::get_parse_tree(
192
212
return parse_trees;
193
213
194
214
// Not found or failed to load
215
+ <<<<<<< HEAD
195
216
debug() << "failed to load class " << class_name << eom;
217
+ =======
218
+ log.warning() << "failed to load class `" << class_name << ' \' ' << messaget::eom;
219
+ >>>>>>> java_class_loader (_base)t isn' t a messaget
196
220
parse_trees.emplace_back(class_name);
197
221
return parse_trees;
198
222
}
199
223
200
224
/// Load all class files from a .jar file
201
225
/// \p aram jar_path: the path for the .jar to load
202
226
std::vector<irep_idt> java_class_loadert::load_entire_jar(
203
- const std::string &jar_path)
227
+ const std::string &jar_path,
228
+ message_handlert &message_handler)
204
229
{
205
- auto classes = read_jar_file (jar_path);
230
+ auto classes = read_jar_file(jar_path, message_handler );
206
231
if(!classes.has_value())
207
232
return {};
208
233
209
234
classpath_entries.push_front(
210
235
classpath_entryt(classpath_entryt::JAR, jar_path));
211
236
212
237
for(const auto &c : *classes)
213
- operator ()(c);
238
+ operator()(c, message_handler );
214
239
215
240
classpath_entries.pop_front();
216
241
217
242
return *classes;
218
243
}
219
244
220
245
optionalt<std::vector<irep_idt>>
221
- java_class_loadert::read_jar_file (const std::string &jar_path)
246
+ java_class_loadert::read_jar_file(const std::string &jar_path,
247
+ message_handlert &message_handler)
222
248
{
249
+ messaget log(message_handler);
250
+
223
251
std::vector<std::string> filenames;
224
252
try
225
253
{
226
254
filenames = jar_pool(jar_path).filenames();
227
255
}
228
256
catch(const std::runtime_error &)
229
257
{
258
+ <<<<<<< HEAD
230
259
error() << "failed to open JAR file ' " << jar_path << " ' " << eom;
231
260
return {};
232
261
}
233
262
debug() << "Adding JAR file ' " << jar_path << " ' " << eom;
263
+ =======
264
+ log.error() << "failed to open JAR file `" << jar_path << "' " << messaget::eom;
265
+ return {};
266
+ }
267
+ log.debug() << " Adding JAR file `" << jar_path << " ' " << messaget::eom;
268
+ >>>>>>> java_class_loader(_base)t isn' t a messaget
234
269
235
270
// Create a new entry in the map and initialize using the list of file names
236
271
// that are in jar_filet
@@ -239,8 +274,14 @@ java_class_loadert::read_jar_file(const std::string &jar_path)
239
274
{
240
275
if (has_suffix (file_name, " .class" ))
241
276
{
277
+ <<<<<<< HEAD
242
278
debug () << " Found class file " << file_name << " in JAR '" << jar_path
243
279
<< " '" << eom;
280
+ =======
281
+ log.debug ()
282
+ << " Found class file " << file_name << " in JAR `" << jar_path << " '"
283
+ << messaget::eom;
284
+ >>>>>>> java_class_loader (_base)t isn' t a messaget
244
285
irep_idt class_name=file_to_class_name(file_name);
245
286
classes.push_back(class_name);
246
287
}
0 commit comments