Skip to content

Commit 384f0d4

Browse files
author
Daniel Kroening
committed
use jar_poolt in java_class_loadert
1 parent d601a44 commit 384f0d4

File tree

2 files changed

+5
-48
lines changed

2 files changed

+5
-48
lines changed

jbmc/src/java_bytecode/java_class_loader.cpp

Lines changed: 1 addition & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,7 @@ java_class_loadert::jar_index_optcreft java_class_loadert::read_jar_file(
252252
std::vector<std::string> filenames;
253253
try
254254
{
255-
filenames = this->jar_pool(jar_path).filenames();
255+
filenames = jar_pool(jar_path).filenames();
256256
}
257257
catch(const std::runtime_error &)
258258
{
@@ -325,33 +325,3 @@ std::string java_class_loadert::class_name_to_file(const irep_idt &class_name)
325325

326326
return result;
327327
}
328-
329-
jar_filet &java_class_loadert::jar_pool(
330-
const std::string &file_name)
331-
{
332-
const auto it=m_archives.find(file_name);
333-
if(it==m_archives.end())
334-
{
335-
// VS: Can't construct in place
336-
auto file = jar_filet(file_name);
337-
return m_archives.emplace(file_name, std::move(file)).first->second;
338-
}
339-
else
340-
return it->second;
341-
}
342-
343-
jar_filet &java_class_loadert::jar_pool(
344-
const std::string &buffer_name,
345-
const void *pmem,
346-
size_t size)
347-
{
348-
const auto it=m_archives.find(buffer_name);
349-
if(it==m_archives.end())
350-
{
351-
// VS: Can't construct in place
352-
auto file = jar_filet(pmem, size);
353-
return m_archives.emplace(buffer_name, std::move(file)).first->second;
354-
}
355-
else
356-
return it->second;
357-
}

jbmc/src/java_bytecode/java_class_loader.h

Lines changed: 4 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,10 @@ Author: Daniel Kroening, [email protected]
1717
#include <util/message.h>
1818
#include <util/fixed_keys_map_wrapper.h>
1919

20+
#include "jar_file.h"
21+
#include "jar_pool.h"
2022
#include "java_bytecode_parse_tree.h"
2123
#include "java_class_loader_limit.h"
22-
#include "jar_file.h"
2324

2425
class java_class_loadert:public messaget
2526
{
@@ -99,20 +100,8 @@ class java_class_loadert:public messaget
99100
return class_map.at(class_name).front();
100101
}
101102

102-
/// Load jar archive or retrieve from cache if already loaded
103-
/// \param filename name of the file
104-
jar_filet &jar_pool(const std::string &filename);
105-
106-
/// Load jar archive or retrieve from cache if already loaded
107-
/// \param buffer_name name of the original file
108-
/// \param pmem memory pointer to the contents of the file
109-
/// \param size size of the memory buffer
110-
/// Note that this mocks the existence of a file which may
111-
/// or may not exist since the actual data bis retrieved from memory.
112-
jar_filet &jar_pool(
113-
const std::string &buffer_name,
114-
const void *pmem,
115-
size_t size);
103+
/// a cache for jar_filet, by path name
104+
jar_poolt jar_pool;
116105

117106
private:
118107
/// Either a regular expression matching files that will be allowed to be
@@ -134,8 +123,6 @@ class java_class_loadert:public messaget
134123
/// The jar_indext for each jar file we've read
135124
std::map<std::string, jar_indext> jars_by_path;
136125

137-
/// Jar files that have been loaded
138-
std::map<std::string, jar_filet> m_archives;
139126
/// Map from class names to the bytecode parse trees
140127
parse_tree_with_overridest_mapt class_map;
141128

0 commit comments

Comments
 (0)