Skip to content

Commit c0e1999

Browse files
author
Daniel Kroening
committed
strip ./ prefix from class file names
1 parent a4aba84 commit c0e1999

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

src/java_bytecode/java_class_loader.cpp

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ Author: Daniel Kroening, kroening@kroening.com
1111
#include <fstream>
1212

1313
#include <util/suffix.h>
14+
#include <util/prefix.h>
1415
#include <util/config.h>
1516

1617
#include "java_bytecode_parser.h"
@@ -254,10 +255,21 @@ std::string java_class_loadert::file_to_class_name(const std::string &file)
254255
{
255256
std::string result=file;
256257

257-
// strip .class
258+
// Strip .class. Note that the Java class loader would
259+
// not do that.
258260
if(has_suffix(result, ".class"))
259261
result.resize(result.size()-6);
260262

263+
// Strip a "./" prefix. Note that the Java class loader
264+
// would not do that.
265+
#ifdef _WIN32
266+
while(has_prefix(result, ".\\"))
267+
result=std::string(result, 2, std::string::npos);
268+
#else
269+
while(has_prefix(result, "./"))
270+
result=std::string(result, 2, std::string::npos);
271+
#endif
272+
261273
// slash to dot
262274
for(std::string::iterator it=result.begin(); it!=result.end(); it++)
263275
if(*it=='/') *it='.';

0 commit comments

Comments
 (0)